1 |
- {"version":3,"sources":["../../../src/app/content/my-resources-page/MyResourcesPage.tsx"],"names":["React","parse","Button","Level","LevelItem","Stack","StackItem","Tab","Tabs","TextInput","AccountServiceContext","Scope","ResourcesTable","ContentPage","Msg","SharedResourcesTable","MY_RESOURCES_TAB","SHARED_WITH_ME_TAB","MyResourcesPage","Component","constructor","props","context","scope","name","displayName","state","myResources","data","forEach","resource","fetchShareRequests","response","doGet","resources","pendingRequest","sharedWithMe","_id","shareRequests","username","scopes","forceUpdate","value","setState","nameFilter","fetchFilteredResources","fetchInitialResources","isSharedWithMeTab","fetchResources","nextUrl","prevUrl","event","tabIndex","activeTabKey","isModalOpen","hasNext","hasPrevious","first","max","params","url","extraParams","then","map","makeScopeObj","parseResourceResponse","fetchPending","fetchPermissionRequests","length","links","headers","get","undefined","parsed","next","prev","makeTab","eventKey","title","sharedResourcesTab","localize","handleFilterRequest","render","bind","handleTabClick","handlePreviousClick","handleFirstPageClick","handleNextClick","clearNextPrev","newMyResources"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AAEA,OAAOC,KAAP;AAEA,SAASC,MAAT,EAAiBC,KAAjB,EAAwBC,SAAxB,EAAmCC,KAAnC,EAA0CC,SAA1C,EAAqDC,GAArD,EAA0DC,IAA1D,EAAgEC,SAAhE;AAGA,SAAQC,qBAAR;AAEA,SAAuCC,KAAvC;AACA,SAAQC,cAAR;AACA,SAAQC,WAAR;AACA,SAAQC,GAAR;AACA,SAASC,oBAAT;AAaA,MAAMC,gBAAgB,GAAG,CAAzB;AACA,MAAMC,kBAAkB,GAAG,CAA3B;AAEA,OAAO,MAAMC,eAAN,SAA8BlB,KAAK,CAACmB,SAApC,CAA0F;AAMtFC,EAAAA,WAAW,CAACC,KAAD,EAA8BC,OAA9B,EAAwF;AACtG,UAAMD,KAAN;;AADsG;;AAAA,mCAH1F,CAG0F;;AAAA,iCA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C,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,MAA5C,CAD3B,CALJ,EASI,oBAAC,SAAD,QACK,KAAK/B,OAAL,MAAkB,oBAAC,MAAD;AAAQ,MAAA,OAAO,EAAE,KAAKgC;AAAtB,OAAuC,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,MAAvC,MADvB,CATJ,CANJ,CADJ;AAsBH;;AAOOC,EAAAA,aAAa,GAAS;AAC1B,UAAMC,cAAkC,GAAG,KAAK/D,KAAL,CAAWC,WAAtD;AACA8D,IAAAA,cAAc,CAACxC,OAAf,GAAyB,EAAzB;AACAwC,IAAAA,cAAc,CAACvC,OAAf,GAAyB,EAAzB;AACA,SAAKP,QAAL,CAAc;AAAChB,MAAAA,WAAW,EAAE8D;AAAd,KAAd;AACH;;AApL4F;;gBAApFvE,e,iBACYR,qB;;AAiNxB","sourcesContent":["/*\n * Copyright 2018 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\n\nimport parse from '../../util/ParseLink';\n\nimport { Button, Level, LevelItem, Stack, StackItem, Tab, Tabs, TextInput } from '@patternfly/react-core';\n\nimport {HttpResponse} from '../../account-service/account.service';\nimport {AccountServiceContext} from '../../account-service/AccountServiceContext';\n\nimport { PaginatedResources, Resource, Scope, Permission } from './resource-model';\nimport {ResourcesTable} from './ResourcesTable';\nimport {ContentPage} from '../ContentPage';\nimport {Msg} from '../../widgets/Msg';\nimport { SharedResourcesTable } from './SharedResourcesTable';\n\nexport interface MyResourcesPageProps {\n}\n\nexport interface MyResourcesPageState {\n activeTabKey: number;\n isModalOpen: boolean;\n nameFilter: string;\n myResources: PaginatedResources;\n sharedWithMe: PaginatedResources;\n}\n\nconst MY_RESOURCES_TAB = 0;\nconst SHARED_WITH_ME_TAB = 1;\n\nexport class MyResourcesPage extends React.Component<MyResourcesPageProps, MyResourcesPageState> {\n static contextType = AccountServiceContext;\n context: React.ContextType<typeof AccountServiceContext>;\n private first = 0;\n private max = 5;\n\n public constructor(props: MyResourcesPageProps, context: React.ContextType<typeof AccountServiceContext>) {\n super(props);\n this.context = context;\n\n this.state = {\n activeTabKey: MY_RESOURCES_TAB,\n nameFilter: '',\n isModalOpen: false,\n myResources: {nextUrl: '', prevUrl: '', data: []},\n sharedWithMe: {nextUrl: '', prevUrl: '', data: []}\n };\n\n this.fetchInitialResources();\n }\n\n private isSharedWithMeTab(): boolean {\n return this.state.activeTabKey === SHARED_WITH_ME_TAB;\n }\n\n private hasNext(): boolean {\n if (this.isSharedWithMeTab()) {\n return (this.state.sharedWithMe.nextUrl !== null) && (this.state.sharedWithMe.nextUrl !== '');\n } else {\n return (this.state.myResources.nextUrl !== null) && (this.state.myResources.nextUrl !== '');\n }\n }\n\n private hasPrevious(): boolean {\n if (this.isSharedWithMeTab()) {\n return (this.state.sharedWithMe.prevUrl !== null) && (this.state.sharedWithMe.prevUrl !== '');\n } else {\n return (this.state.myResources.prevUrl !== null) && (this.state.myResources.prevUrl !== '');\n }\n }\n\n private fetchInitialResources(): void {\n if (this.isSharedWithMeTab()) {\n this.fetchResources(\"/resources/shared-with-me\");\n } else {\n this.fetchResources(\"/resources\", {first: this.first, max: this.max});\n }\n }\n\n private fetchFilteredResources(params: Record<string, string|number>): void {\n if (this.isSharedWithMeTab()) {\n this.fetchResources(\"/resources/shared-with-me\", params);\n } else {\n this.fetchResources(\"/resources\", {...params, first: this.first, max: this.max});\n }\n }\n\n private fetchResources(url: string, extraParams?: Record<string, string|number>): void {\n this.context!.doGet<Resource[]>(url, {params: extraParams})\n .then((response: HttpResponse<Resource[]>) => {\n const resources: Resource[] = response.data || [];\n resources.forEach((resource: Resource) => resource.shareRequests = []);\n\n // serialize the Scope objects from JSON so that toString() will work.\n resources.forEach((resource: Resource) => resource.scopes = resource.scopes.map(this.makeScopeObj));\n\n if (this.isSharedWithMeTab()) {\n this.setState({sharedWithMe: this.parseResourceResponse(response)}, this.fetchPending);\n } else {\n this.setState({myResources: this.parseResourceResponse(response)}, this.fetchPermissionRequests);\n }\n });\n }\n\n private makeScopeObj = (scope: Scope): Scope => {\n return new Scope(scope.name, scope.displayName);\n }\n\n private fetchPermissionRequests = () => {\n this.state.myResources.data.forEach((resource: Resource) => {\n this.fetchShareRequests(resource);\n });\n }\n\n private fetchShareRequests(resource: Resource): void {\n this.context!.doGet('/resources/' + resource._id + '/permissions/requests')\n .then((response: HttpResponse<Permission[]>) => {\n resource.shareRequests = response.data || [];\n if (resource.shareRequests.length > 0) {\n this.forceUpdate();\n }\n });\n }\n\n private fetchPending = async () => {\n const response: HttpResponse<Resource[]> = await this.context!.doGet(`/resources/pending-requests`);\n const resources: Resource[] = response.data || [];\n resources.forEach((pendingRequest: Resource) => {\n this.state.sharedWithMe.data.forEach(resource => {\n if (resource._id === pendingRequest._id) {\n resource.shareRequests = [{username: 'me', scopes: pendingRequest.scopes}]\n this.forceUpdate();\n }\n });\n });\n }\n\n private parseResourceResponse(response: HttpResponse<Resource[]>): PaginatedResources {\n const links: string | undefined = response.headers.get('link') || undefined;\n const parsed = parse(links);\n\n let next = '';\n let prev = '';\n\n if (parsed !== null) {\n if (parsed.next) next = parsed.next;\n if (parsed.prev) prev = parsed.prev;\n }\n\n const resources: Resource[] = response.data || [];\n\n return {nextUrl: next, prevUrl: prev, data: resources};\n }\n\n private makeTab(eventKey: number, title: string, resources: PaginatedResources, sharedResourcesTab: boolean): React.ReactNode {\n return (\n <Tab id={title} eventKey={eventKey} title={Msg.localize(title)}>\n <Stack gutter=\"md\">\n <StackItem isFilled><span/></StackItem>\n <StackItem isFilled>\n <Level gutter='md'>\n <LevelItem>\n <TextInput value={this.state.nameFilter} onChange={this.handleFilterRequest} id={'filter-' + title} type=\"text\" placeholder={Msg.localize('filterByName')} />\n </LevelItem>\n </Level>\n </StackItem>\n <StackItem isFilled>\n {!sharedResourcesTab && <ResourcesTable resources={resources}/>}\n {sharedResourcesTab && <SharedResourcesTable resources={resources}/>}\n </StackItem>\n </Stack>\n </Tab>\n )\n }\n\n public render(): React.ReactNode {\n return (\n <ContentPage title=\"resources\" onRefresh={this.fetchInitialResources.bind(this)}>\n <Tabs isFilled activeKey={this.state.activeTabKey} onSelect={this.handleTabClick}>\n {this.makeTab(0, 'myResources', this.state.myResources, false)}\n {this.makeTab(1, 'sharedwithMe', this.state.sharedWithMe, true)}\n </Tabs>\n\n <Level gutter='md'>\n <LevelItem>\n {this.hasPrevious() && <Button onClick={this.handlePreviousClick}><<Msg msgKey='previousPage'/></Button>}\n </LevelItem>\n\n <LevelItem>\n {this.hasPrevious() && <Button onClick={this.handleFirstPageClick}><Msg msgKey='firstPage'/></Button>}\n </LevelItem>\n\n <LevelItem>\n {this.hasNext() && <Button onClick={this.handleNextClick}><Msg msgKey='nextPage'/>></Button>}\n </LevelItem>\n </Level>\n </ContentPage>\n );\n }\n\n private handleFilterRequest = (value: string) => {\n this.setState({nameFilter: value});\n this.fetchFilteredResources({name: value});\n }\n\n private clearNextPrev(): void {\n const newMyResources: PaginatedResources = this.state.myResources;\n newMyResources.nextUrl = '';\n newMyResources.prevUrl = '';\n this.setState({myResources: newMyResources});\n }\n\n private handleFirstPageClick = () => {\n this.fetchInitialResources();\n }\n\n private handleNextClick = () => {\n if (this.isSharedWithMeTab()) {\n this.fetchResources(this.state.sharedWithMe.nextUrl);\n } else {\n this.fetchResources(this.state.myResources.nextUrl);\n }\n }\n\n private handlePreviousClick = () => {\n if (this.isSharedWithMeTab()) {\n this.fetchResources(this.state.sharedWithMe.prevUrl);\n } else {\n this.fetchResources(this.state.myResources.prevUrl);\n }\n }\n\n private handleTabClick = (event: React.MouseEvent<HTMLInputElement>, tabIndex: number) => {\n if (this.state.activeTabKey === tabIndex) return;\n\n this.setState({\n nameFilter: '',\n activeTabKey: tabIndex\n }, () => {this.fetchInitialResources()});\n };\n};\n"],"file":"MyResourcesPage.js"}
|