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

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

There is a newer version: 26.0.5
Show newest version
{"version":3,"file":"EditTheResource.js","names":["React","Button","Modal","Form","FormGroup","TextInput","InputGroup","ModalVariant","OkIcon","Scope","Msg","AccountServiceContext","ContentAlert","PermissionSelect","EditTheResource","Component","constructor","props","context","_defineProperty","state","isOpen","setState","onClose","clearState","row","changed","savePermission","permission","doPut","encodeURIComponent","resource","_id","success","localize","render","createElement","Fragment","children","handleToggleDialog","title","name","variant","large","actions","key","id","onClick","msgKey","isHorizontal","permissions","map","p","fieldId","label","type","value","username","isDisabled","isRequired","scopes","selected","s","direction","length","onSelect","selection","updateChanged"],"sources":["../../../src/app/content/my-resources-page/EditTheResource.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 */\n\nimport * as React from 'react';\n\nimport {\n    Button,\n    Modal,\n    Form,\n    FormGroup,\n    TextInput,\n    InputGroup,\n    ModalVariant\n} from '@patternfly/react-core';\nimport { OkIcon } from '@patternfly/react-icons';\n\nimport { Resource, Permission, Permissions, Scope } from './resource-model';\nimport { Msg } from '../../widgets/Msg';\nimport { AccountServiceContext } from '../../account-service/AccountServiceContext';\nimport { ContentAlert } from '../ContentAlert';\nimport { PermissionSelect } from './PermissionSelect';\n\ninterface EditTheResourceProps {\n    resource: Resource;\n    permissions: Permission[];\n    onClose: () => void;\n    children: (toggle: () => void) => void;\n}\n\ninterface EditTheResourceState {\n    changed: boolean[];\n    isOpen: boolean;\n}\n\nexport class EditTheResource extends React.Component {\n    protected static defaultProps:Permissions = { permissions: [] };\n    static contextType = AccountServiceContext;\n    context: React.ContextType;\n\n    public constructor(props: EditTheResourceProps, context: React.ContextType) {\n        super(props);\n        this.context = context;\n\n        this.state = {\n            changed: [],\n            isOpen: false,\n        };\n    }\n\n    private clearState(): void {\n        this.setState({});\n    }\n\n    private handleToggleDialog = () => {\n        if (this.state.isOpen) {\n            this.setState({ isOpen: false });\n            this.props.onClose();\n        } else {\n            this.clearState();\n            this.setState({ isOpen: true });\n        }\n    };\n\n    private updateChanged = (row: number) => {\n        const changed = this.state.changed;\n        changed[row] = !changed[row];\n        this.setState({ changed });\n    }\n\n    async savePermission(permission: Permission): Promise {\n        await this.context!.doPut(`/resources/${encodeURIComponent(this.props.resource._id)}/permissions`, [permission]);\n        ContentAlert.success(Msg.localize('updateSuccess'));\n    }\n\n    public render(): React.ReactNode {\n        return (\n            \n                {this.props.children(this.handleToggleDialog)}\n\n                \n                            \n                        ,\n                    ]}\n                >\n                    
\n {this.props.permissions.map((p, row) => (\n \n \n \n\n \n \n \n new Scope(s))}\n direction={row === this.props.permissions.length - 1 ? \"up\" : \"down\"}\n onSelect={selection => {\n p.scopes = selection.map(s => s.name);\n this.updateChanged(row);\n }}\n />\n this.savePermission(p)}\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;;AAEA,OAAO,KAAKA,KAAK;AAEjB,SACIC,MAAM,EACNC,KAAK,EACLC,IAAI,EACJC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,YAAY;AAEhB,SAASC,MAAM;AAEf,SAA4CC,KAAK;AACjD,SAASC,GAAG;AACZ,SAASC,qBAAqB;AAC9B,SAASC,YAAY;AACrB,SAASC,gBAAgB;AAczB,OAAO,MAAMC,eAAe,SAASd,KAAK,CAACe,SAAS,C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