All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.account.resources.content.my-resources-page.PermissionRequest.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"PermissionRequest.js","names":["React","Button","Modal","Text","Badge","DataListItem","DataList","TextVariants","DataListItemRow","DataListItemCells","DataListCell","Chip","Split","SplitItem","ModalVariant","UserCheckIcon","AccountServiceContext","Msg","ContentAlert","PermissionRequest","Component","constructor","props","context","_defineProperty","shareRequest","index","handle","username","scopes","resource","shareRequests","splice","approve","id","_id","handleToggleDialog","permissionsRequest","doGet","encodeURIComponent","permissions","data","foundPermission","find","p","userScopes","push","doPut","success","localize","onClose","e","console","error","setState","isOpen","state","render","name","replace","createElement","Fragment","variant","onClick","size","length","title","large","actions","key","msgKey","dataListCells","width","map","i","firstName","lastName","component","small","email","scope","j","isReadOnly","hasGutter","handleApprove","handleDeny","row"],"sources":["../../../src/app/content/my-resources-page/PermissionRequest.tsx"],"sourcesContent":["/*\n * Copyright 2019 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 */\nimport * as React from 'react';\nimport {\n    Button,\n    Modal,\n    Text,\n    Badge,\n    DataListItem,\n    DataList,\n    TextVariants,\n    DataListItemRow,\n    DataListItemCells,\n    DataListCell,\n    Chip,\n    Split,\n    SplitItem,\n    ModalVariant\n} from '@patternfly/react-core';\nimport { UserCheckIcon } from '@patternfly/react-icons';\n\nimport { HttpResponse } from '../../account-service/account.service';\nimport { AccountServiceContext } from '../../account-service/AccountServiceContext';\nimport { Msg } from '../../widgets/Msg';\nimport { ContentAlert } from '../ContentAlert';\nimport { Resource, Scope, Permission, Permissions } from './resource-model';\n\n\ninterface PermissionRequestProps {\n    resource: Resource;\n    onClose: () => void;\n}\n\ninterface PermissionRequestState {\n    isOpen: boolean;\n}\n\nexport class PermissionRequest extends React.Component {\n    protected static defaultProps:Permissions = { permissions: [], row: 0 };\n    static contextType = AccountServiceContext;\n    context: React.ContextType;\n\n    public constructor(props: PermissionRequestProps, context: React.ContextType) {\n        super(props);\n        this.context = context;\n    \n        this.state = {\n            isOpen: false,\n        };\n    }\n\n    private handleApprove = async (shareRequest: Permission, index: number) => {\n        this.handle(shareRequest.username, shareRequest.scopes as Scope[], true);\n        this.props.resource.shareRequests.splice(index, 1);\n    };\n\n    private handleDeny = async (shareRequest: Permission, index: number) => {\n        this.handle(shareRequest.username, shareRequest.scopes as Scope[]);\n        this.props.resource.shareRequests.splice(index, 1)\n    };\n\n    private handle = async (username: string, scopes: Scope[], approve: boolean = false) => {\n        const id = this.props.resource._id\n        this.handleToggleDialog();\n\n        const permissionsRequest: HttpResponse = await this.context!.doGet(`/resources/${encodeURIComponent(id)}/permissions`);\n        const permissions = permissionsRequest.data || [];\n        const foundPermission = permissions.find(p => p.username === username);\n        const userScopes = foundPermission ? (foundPermission.scopes as Scope[]): [];\n        if (approve) {\n            userScopes.push(...scopes);\n        }\n        try {\n            await this.context!.doPut(`/resources/${encodeURIComponent(id)}/permissions`, [{ username: username, scopes: userScopes }] )\n            ContentAlert.success(Msg.localize('shareSuccess'));\n            this.props.onClose();\n        } catch (e) {\n            console.error('Could not update permissions', (e as any).error);\n        }\n    };\n\n    private handleToggleDialog = () => {\n        this.setState({ isOpen: !this.state.isOpen });\n    };\n\n    public render(): React.ReactNode {\n        const id = `shareRequest-${this.props.resource.name.replace(/\\s/, '-')}`;\n        return (\n            \n                \n\n                \n                            \n                        ,\n                    ]}\n                >\n                    \n                        \n                            \n                                        Requestor\n                                    ,\n                                    \n                                        \n                                    ,\n                                    \n                                    \n                                ]}\n                            />\n                        \n                        {this.props.resource.shareRequests.map((shareRequest, i) =>\n                            \n                                \n                                    \n                                                \n                                                    {shareRequest.firstName} {shareRequest.lastName} {shareRequest.lastName ? '' : shareRequest.username}\n                                                
\n {shareRequest.email}\n ,\n \n {(shareRequest.scopes as Scope[]).map((scope, j) => {scope})}\n ,\n \n \n \n this.handleApprove(shareRequest, i)}\n >\n Accept\n \n \n \n this.handleDeny(shareRequest, i)}\n >\n Deny\n \n \n \n \n ]}\n />\n
\n
\n )}\n
\n \n
\n );\n }\n}\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK;AACjB,SACIC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,KAAK,EACLC,YAAY,EACZC,QAAQ,EACRC,YAAY,EACZC,eAAe,EACfC,iBAAiB,EACjBC,YAAY,EACZC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,YAAY;AAEhB,SAASC,aAAa;AAGtB,SAASC,qBAAqB;AAC9B,SAASC,GAAG;AACZ,SAASC,YAAY;AAarB,OAAO,MAAMC,iBAAiB,SAASnB,KAAK,CAACoB,SAAS,CAAiD;EAK5FC,WAAWA,CAACC,KAA6B,EAAEC,OAAwD,EAAE;IACxG,KAAK,CAACD,KAAK,CAAC;IAACE,eAAA;IAAAA,eAAA,wBAQO,OAAOC,YAAwB,EAAEC,KAAa,KAAK;MACvE,IAAI,CAACC,MAAM,CAACF,YAAY,CAACG,QAAQ,EAAEH,YAAY,CAACI,MAAM,EAAa,IAAI,CAAC;MACxE,IAAI,CAACP,KAAK,CAACQ,QAAQ,CAACC,aAAa,CAACC,MAAM,CAACN,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;IAAAF,eAAA,qBAEoB,OAAOC,YAAwB,EAAEC,KAAa,KAAK;MACpE,IAAI,CAACC,MAAM,CAACF,YAAY,CAACG,QAAQ,EAAEH,YAAY,CAACI,MAAiB,CAAC;M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