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

theme.keycloak.v2.admin.resources.assets.ResourceDetails-DqME319T.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"ResourceDetails-DqME319T.js","sources":["../../src/clients/authorization/ScopePicker.tsx","../../src/clients/authorization/ResourceDetails.tsx"],"sourcesContent":["import type ScopeRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/scopeRepresentation\";\nimport {\n  HelpItem,\n  KeycloakSelect,\n  SelectVariant,\n} from \"@keycloak/keycloak-ui-shared\";\nimport { FormGroup, SelectOption } from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { Controller, useFormContext } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { KeycloakSpinner } from \"../../components/keycloak-spinner/KeycloakSpinner\";\nimport { useFetch } from \"../../utils/useFetch\";\n\ntype Scope = {\n  id: string;\n  name: string;\n};\n\nexport const ScopePicker = ({ clientId }: { clientId: string }) => {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const { control } = useFormContext();\n\n  const [open, setOpen] = useState(false);\n  const [scopes, setScopes] = useState();\n  const [search, setSearch] = useState(\"\");\n\n  useFetch(\n    () => {\n      const params = {\n        id: clientId,\n        first: 0,\n        max: 20,\n        deep: false,\n        name: search,\n      };\n      return adminClient.clients.listAllScopes(params);\n    },\n    setScopes,\n    [search],\n  );\n\n  const renderScopes = (scopes: ScopeRepresentation[]) =>\n    scopes.map((option) => (\n      \n        {option.name}\n      \n    ));\n\n  if (!scopes) return ;\n  return (\n    \n      }\n      fieldId=\"scopes\"\n    >\n       (\n           setOpen(val)}\n            isOpen={open}\n            selections={field.value.map((o: Scope) => o.name)}\n            onFilter={(value) => {\n              setSearch(value);\n              return renderScopes(scopes);\n            }}\n            onSelect={(selectedValue) => {\n              const option =\n                typeof selectedValue === \"string\"\n                  ? selectedValue\n                  : (selectedValue as Scope).name;\n              const changedValue = field.value.find(\n                (o: Scope) => o.name === option,\n              )\n                ? field.value.filter((item: Scope) => item.name !== option)\n                : [...field.value, selectedValue];\n              field.onChange(changedValue);\n            }}\n            onClear={() => {\n              setSearch(\"\");\n              field.onChange([]);\n            }}\n            typeAheadAriaLabel={t(\"authorizationScopes\")}\n          >\n            {renderScopes(scopes)}\n          \n        )}\n      />\n    \n  );\n};\n","import type ClientRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/clientRepresentation\";\nimport type ResourceRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation\";\nimport type ResourceServerRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/resourceServerRepresentation\";\nimport {\n  ActionGroup,\n  Alert,\n  AlertVariant,\n  Button,\n  ButtonVariant,\n  DropdownItem,\n  FormGroup,\n  PageSection,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, useNavigate } from \"react-router-dom\";\nimport { HelpItem, TextControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { DefaultSwitchControl } from \"../../components/SwitchControl\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { useConfirmDialog } from \"../../components/confirm-dialog/ConfirmDialog\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport { KeyValueInput } from \"../../components/key-value-form/KeyValueInput\";\nimport type { KeyValueType } from \"../../components/key-value-form/key-value-convert\";\nimport { KeycloakSpinner } from \"../../components/keycloak-spinner/KeycloakSpinner\";\nimport { MultiLineInput } from \"../../components/multi-line-input/MultiLineInput\";\nimport { ViewHeader } from \"../../components/view-header/ViewHeader\";\nimport { useAccess } from \"../../context/access/Access\";\nimport { convertFormValuesToObject, convertToFormValues } from \"../../util\";\nimport { useFetch } from \"../../utils/useFetch\";\nimport { useParams } from \"../../utils/useParams\";\nimport { toAuthorizationTab } from \"../routes/AuthenticationTab\";\nimport { ResourceDetailsParams, toResourceDetails } from \"../routes/Resource\";\nimport { ScopePicker } from \"./ScopePicker\";\nimport \"./resource-details.css\";\n\ntype SubmittedResource = Omit<\n  ResourceRepresentation,\n  \"attributes\" | \"scopes\"\n> & {\n  attributes: KeyValueType[];\n};\n\nexport default function ResourceDetails() {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const [client, setClient] = useState();\n  const [resource, setResource] = useState();\n\n  const [permissions, setPermission] =\n    useState();\n\n  const { addAlert, addError } = useAlerts();\n  const form = useForm({\n    mode: \"onChange\",\n  });\n  const { setValue, handleSubmit } = form;\n\n  const { id, resourceId, realm } = useParams();\n  const navigate = useNavigate();\n\n  const setupForm = (resource: ResourceRepresentation = {}) => {\n    convertToFormValues(resource, setValue);\n  };\n\n  const { hasAccess } = useAccess();\n\n  const isDisabled = !hasAccess(\"manage-authorization\");\n\n  useFetch(\n    () =>\n      Promise.all([\n        adminClient.clients.findOne({ id }),\n        resourceId\n          ? adminClient.clients.getResource({ id, resourceId })\n          : Promise.resolve(undefined),\n        resourceId\n          ? adminClient.clients.listPermissionsByResource({ id, resourceId })\n          : Promise.resolve(undefined),\n      ]),\n    ([client, resource, permissions]) => {\n      if (!client) {\n        throw new Error(t(\"notFound\"));\n      }\n      setClient(client);\n      setPermission(permissions);\n      setResource(resource);\n      setupForm(resource);\n    },\n    [],\n  );\n\n  const submit = async (submitted: SubmittedResource) => {\n    const resource = convertFormValuesToObject<\n      SubmittedResource,\n      ResourceRepresentation\n    >(submitted);\n\n    try {\n      if (resourceId) {\n        await adminClient.clients.updateResource({ id, resourceId }, resource);\n      } else {\n        const result = await adminClient.clients.createResource(\n          { id },\n          resource,\n        );\n        setResource(resource);\n        navigate(toResourceDetails({ realm, id, resourceId: result._id! }));\n      }\n      addAlert(\n        t((resourceId ? \"update\" : \"create\") + \"ResourceSuccess\"),\n        AlertVariant.success,\n      );\n    } catch (error) {\n      addError(\"resourceSaveError\", error);\n    }\n  };\n\n  const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({\n    titleKey: \"deleteResource\",\n    children: (\n      <>\n        {t(\"deleteResourceConfirm\")}\n        {permissions?.length !== 0 && (\n          \n            

\n {permissions?.map((permission) => (\n \n {permission.name}\n \n ))}\n

\n \n )}\n \n ),\n continueButtonLabel: \"confirm\",\n onConfirm: async () => {\n try {\n await adminClient.clients.delResource({\n id,\n resourceId: resourceId!,\n });\n addAlert(t(\"resourceDeletedSuccess\"), AlertVariant.success);\n navigate(toAuthorizationTab({ realm, clientId: id, tab: \"resources\" }));\n } catch (error) {\n addError(\"resourceDeletedError\", error);\n }\n },\n });\n\n if (!client) {\n return ;\n }\n\n return (\n <>\n \n toggleDeleteDialog()}\n >\n {t(\"delete\")}\n ,\n ]\n : undefined\n }\n />\n \n \n \n \n \n \n \n \n }\n >\n \n \n \n \n \n \n }\n fieldId=\"resourceAttribute\"\n >\n \n \n \n
\n \n {t(\"save\")}\n \n\n (\n \n )}\n >\n {t(\"cancel\")}\n \n
\n
\n \n
\n
\n \n );\n}\n"],"names":["ScopePicker","clientId","adminClient","useAdminClient","t","useTranslation","control","useFormContext","open","setOpen","useState","scopes","setScopes","search","setSearch","useFetch","params","renderScopes","option","jsx","SelectOption","FormGroup","HelpItem","Controller","field","KeycloakSelect","SelectVariant","val","o","value","selectedValue","changedValue","item","KeycloakSpinner","ResourceDetails","client","setClient","resource","setResource","permissions","setPermission","addAlert","addError","useAlerts","form","useForm","setValue","handleSubmit","id","resourceId","realm","useParams","navigate","useNavigate","setupForm","convertToFormValues","hasAccess","useAccess","isDisabled","submit","submitted","convertFormValuesToObject","result","toResourceDetails","AlertVariant","error","toggleDeleteDialog","DeleteConfirm","useConfirmDialog","jsxs","Fragment","Alert","permission","toAuthorizationTab","ViewHeader","DropdownItem","PageSection","FormProvider","FormAccess","TextControl","MultiLineInput","DefaultSwitchControl","KeyValueInput","ActionGroup","Button","ButtonVariant","props","Link"],"mappings":"m0BAmBO,MAAMA,GAAc,CAAC,C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