PermissionSelect.js.map 5.9 KB

1
  1. {"version":3,"sources":["../../../src/app/content/my-resources-page/PermissionSelect.tsx"],"names":["React","Select","SelectOption","SelectVariant","ScopeValue","constructor","value","toString","displayName","name","compareTo","selectOption","PermissionSelect","Component","props","_event","selection","selected","state","onSelect","includes","setState","prevState","filter","item","map","sv","isExpanded","values","s","scopes","option","index","find","render","titleId","direction","typeaheadMulti","onToggle","clearSelection"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ;AAEA,SAASC,MAAT,EAAiBC,YAAjB,EAA+BC,aAA/B;;AAgBA,MAAMC,UAAN,CAA+C;AAE7CC,EAAAA,WAAW,CAACC,KAAD,EAAe;AAAA;;AACxB,SAAKA,KAAL,GAAaA,KAAb;AACD;;AAEDC,EAAAA,QAAQ,GAAG;AACT,WAAO,KAAKD,KAAL,CAAWE,WAAX,GAAyB,KAAKF,KAAL,CAAWE,WAApC,GAAkD,KAAKF,KAAL,CAAWG,IAApE;AACD;;AAEDC,EAAAA,SAAS,CAACC,YAAD,EAA+B;AACtC,WAAOA,YAAY,CAACF,IAAb,KAAsB,KAAKH,KAAL,CAAWG,IAAxC;AACD;;AAZ4C;;AAe/C,OAAO,MAAMG,gBAAN,SAA+BZ,KAAK,CAACa,SAArC,CAA6F;AAClGR,EAAAA,WAAW,CAACS,KAAD,EAA+B;AACxC,UAAMA,KAAN;;AADwC,sCAiBvB,CAACC,MAAD,EAA+CC,SAA/C,KAA+E;AAChG,YAAM;AAAEC,QAAAA;AAAF,UAAe,KAAKC,KAA1B;AACA,YAAM;AAAEC,QAAAA;AAAF,UAAe,KAAKL,KAA1B;;AACA,UAAIG,QAAQ,CAACG,QAAT,CAAkBJ,SAAlB,CAAJ,EAAkC;AAChC,aAAKK,QAAL,CACEC,SAAS,KAAK;AAAEL,UAAAA,QAAQ,EAAEK,SAAS,CAACL,QAAV,CAAmBM,MAAnB,CAA0BC,IAAI,IAAIA,IAAI,KAAKR,SAA3C;AAAZ,SAAL,CADX,EAEE,MAAM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B,MAAZ,CAAjB,KAAyC,IAAI3B,UAAJ,CAAe2B,MAAf;AAA1E,QADM;AAHG,KAAb;AAOD;;AAgCDG,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEP,MAAAA,UAAF;AAAcV,MAAAA;AAAd,QAA2B,KAAKC,KAAtC;AACA,UAAMiB,OAAO,GAAG,eAAhB;AAEA,WACE,iCACE;AAAM,MAAA,EAAE,EAAEA,OAAV;AAAmB,MAAA,MAAM;AAAzB,gCADF,EAIE,oBAAC,MAAD;AACE,MAAA,SAAS,EAAE,KAAKrB,KAAL,CAAWsB,SAAX,IAAwB,MADrC;AAEE,MAAA,OAAO,EAAEjC,aAAa,CAACkC,cAFzB;AAGE,MAAA,kBAAkB,EAAC,wBAHrB;AAIE,MAAA,QAAQ,EAAE,KAAKC,QAJjB;AAKE,MAAA,QAAQ,EAAE,KAAKnB,QALjB;AAME,MAAA,OAAO,EAAE,KAAKoB,cANhB;AAOE,MAAA,UAAU,EAAEtB,QAPd;AAQE,MAAA,UAAU,EAAEU,UARd;AASE,MAAA,cAAc,EAAEQ,OATlB;AAUE,MAAA,eAAe,EAAC;AAVlB,OAYG,KAAKjB,KAAL,CAAWY,MAZd,CAJF,CADF;AAqBD;;AAzEiG","sourcesContent":["import * as React from 'react';\n\nimport { Select, SelectOption, SelectVariant, SelectOptionObject } from '@patternfly/react-core';\nimport { Scope } from './resource-model';\n\ninterface PermissionSelectState {\n selected: ScopeValue[];\n isExpanded: boolean;\n scopes: JSX.Element[];\n}\n\ninterface PermissionSelectProps {\n scopes: Scope[];\n selected?: Scope[];\n direction?: 'up' | 'down';\n onSelect: (selected: Scope[]) => void;\n}\n\nclass ScopeValue implements SelectOptionObject {\n value: Scope;\n constructor(value: Scope) {\n this.value = value;\n }\n\n toString() {\n return this.value.displayName ? this.value.displayName : this.value.name;\n }\n\n compareTo(selectOption: Scope): boolean {\n return selectOption.name === this.value.name;\n }\n}\n\nexport class PermissionSelect extends React.Component<PermissionSelectProps, PermissionSelectState> {\n constructor(props: PermissionSelectProps) {\n super(props);\n\n let values: ScopeValue[] = [];\n if (this.props.selected) {\n values = this.props.selected!.map(s => new ScopeValue(s))\n }\n\n this.state = {\n isExpanded: false,\n selected: values,\n scopes: this.props.scopes.map((option, index) => (\n <SelectOption key={index} value={values.find(s => s.compareTo(option)) || new ScopeValue(option)} />\n ))\n };\n }\n\n private onSelect = (_event: React.MouseEvent | React.ChangeEvent, selection: ScopeValue): void => {\n const { selected } = this.state;\n const { onSelect } = this.props;\n if (selected.includes(selection)) {\n this.setState(\n prevState => ({ selected: prevState.selected.filter(item => item !== selection) }),\n () => onSelect(this.state.selected.map(sv => sv.value))\n );\n } else {\n this.setState(\n prevState => ({ selected: [...prevState.selected, selection] }),\n () => onSelect(this.state.selected.map(sv => sv.value))\n );\n }\n }\n\n private onToggle = (isExpanded: boolean) => {\n this.setState({\n isExpanded\n });\n }\n\n private clearSelection = () => {\n this.setState({\n selected: [],\n isExpanded: false\n });\n this.props.onSelect([]);\n };\n\n render() {\n const { isExpanded, selected } = this.state;\n const titleId = 'permission-id';\n\n return (\n <div>\n <span id={titleId} hidden>\n Select the permissions\n </span>\n <Select\n direction={this.props.direction || 'down'}\n variant={SelectVariant.typeaheadMulti}\n ariaLabelTypeAhead=\"Select the permissions\"\n onToggle={this.onToggle}\n onSelect={this.onSelect}\n onClear={this.clearSelection}\n selections={selected}\n isExpanded={isExpanded}\n ariaLabelledBy={titleId}\n placeholderText=\"Select the permissions\"\n >\n {this.state.scopes}\n </Select>\n </div>\n );\n }\n}"],"file":"PermissionSelect.js"}