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AAP,GAAA,YAAAA,EAAiB,SAAjB,cAAyB,UAAW,CAAC,GAEtC,OAAQQ,GAAa,IAAC,MAAYT,EAAY,YAAa,gBAAgBS,CAAQ,EAAE,CAAC,CACvG,KAEK,MAAYT,EAAY,YAAa,yBAAyBD,EAAO,YAAY,EAAE,GACtFI,EAAQ,KAAK,KAAO,QAAQ,EAG9B,MAAMO,EAAiBF,EAA8B,EAErD,OAAIE,EAAe,OAAS,EACnB,gBAAC,IAAyB,CAAC,MAAO,KAAM,iBAAkBA,CAAA,CAAgB,EAG/E,CAACT,GAAmBK,EAEpB,gBAAC,KAAa,CAAC,MAAM,yBACnB,gBAAC,YACC,gBAAC,KAAU,CAAC,MAAM,yBAChB,gBAAC,KAAO,CAAC,KAAK,6BAA8B,EAC9C,CACF,CACF,EAKF,gBAAC,KAAa,CAAC,MAAO,SAASL,EAAgB,KAAK,sBAClD,gBAAC,IAAoB,IAAC,EACtB,gBAAC,MAAW,MAAO,SAASA,EAAgB,KAAK,qBACrC,kBAAmB,CACjB,MAAO,uBACP,KAAM,IAAW,MAAM,MACzB,GACV,gBAAC,YAAK,2FAEN,CACF,EACCM,EAAiB,WAChB,gBAAC,MAAG,CAAC,UAAU,WACb,gBAAC,MAAG,CAAC,GAAI,IACP,gBAAC,IAA4B,CAAC,OAAO,OAAO,gBAAAN,CAAA,CAAkC,CAChF,CACF,EAEA,gBAAC,MAAG,CAAC,UAAU,WACb,gBAAC,MAAG,CAAC,GAAI,IACP,gBAAC,MAAG,KACF,gBAAC,MAAG,CAAC,GAAI,EAAG,SAAU,EAAG,GAAI,EAAG,SAAU,GACxC,gBAAC,OAAI,MAAO,CAAE,UAAW,QAAS,GAChC,gBAAC,SAAE,mHAAiH,CACtH,CACF,CACF,CACF,CACF,CAGJ,CAEJ,C","sources":["webpack://graylog-web-interface/./src/hooks/useScopePermissions.ts","webpack://graylog-web-interface/./src/pages/EditEventDefinitionPage.tsx"],"sourcesContent":["/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport { useQuery } from '@tanstack/react-query';\n\nimport fetch from 'logic/rest/FetchProvider';\nimport { qualifyUrl } from 'util/URLUtils';\nimport ApiRoutes from 'routing/ApiRoutes';\nimport UserNotification from 'util/UserNotification';\nimport type { GenericEntityType } from 'logic/lookup-tables/types';\n\ntype ScopeParams = {\n is_mutable: boolean,\n}\n\ntype ScopeName = 'DEFAULT' | 'ILLUMINATE';\n\ntype EntityScopeRecord = Record;\n\ntype EntityScopeType = {\n entity_scopes: EntityScopeRecord,\n};\n\nfunction fetchScopePermissions() {\n return fetch('GET', qualifyUrl(ApiRoutes.EntityScopeController.getScope().url));\n}\n\nconst useGetPermissionsByScope = (entity: Partial) => {\n const { data, isLoading, error } = useQuery(\n ['scope-permissions'],\n fetchScopePermissions,\n {\n onError: () => UserNotification.error(error.message),\n retry: 1,\n cacheTime: 1000 * 60 * 60 * 3, // cache for 3 hours\n staleTime: 1000 * 60 * 60 * 3, // data is valid for 3 hours\n },\n );\n\n const scope = entity?._scope?.toUpperCase() || 'DEFAULT';\n const permissions: ScopeParams = isLoading ? { is_mutable: false } : data.entity_scopes[scope];\n\n return {\n loadingScopePermissions: isLoading,\n scopePermissions: permissions,\n };\n};\n\nexport default useGetPermissionsByScope;\n","/*\n * Copyright (C) 2020 Graylog, Inc.\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the Server Side Public License, version 1,\n * as published by MongoDB, Inc.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * Server Side Public License for more details.\n *\n * You should have received a copy of the Server Side Public License\n * along with this program. If not, see\n * .\n */\nimport React from 'react';\nimport { useParams } from 'react-router-dom';\n\nimport EventsPageNavigation from 'components/events/EventsPageNavigation';\nimport useScopePermissions from 'hooks/useScopePermissions';\nimport { Col, Row } from 'components/bootstrap';\nimport { DocumentTitle, PageHeader, Spinner } from 'components/common';\nimport EventDefinitionFormContainer from 'components/event-definitions/event-definition-form/EventDefinitionFormContainer';\nimport Routes from 'routing/Routes';\nimport DocsHelper from 'util/DocsHelper';\nimport { isPermitted } from 'util/PermissionsMixin';\nimport useCurrentUser from 'hooks/useCurrentUser';\nimport { EventDefinitionsActions } from 'stores/event-definitions/EventDefinitionsStore';\nimport type { EventDefinition } from 'components/event-definitions/event-definitions-types';\nimport useHistory from 'routing/useHistory';\n\nimport StreamPermissionErrorPage from './StreamPermissionErrorPage';\n\nconst EditEventDefinitionPage = () => {\n const params = useParams<{definitionId?: string}>();\n const currentUser = useCurrentUser();\n const [eventDefinition, setEventDefinition] = React.useState(undefined);\n const history = useHistory();\n\n React.useEffect(() => {\n if (isPermitted(currentUser.permissions, `eventdefinitions:edit:${params.definitionId}`)) {\n EventDefinitionsActions.get(params.definitionId)\n .then(\n (response) => {\n const eventDefinitionResponse = response.event_definition;\n\n // Inject an internal \"_is_scheduled\" field to indicate if the event definition should be scheduled in the\n // backend. This field will be removed in the event definitions store before sending an event definition\n // back to the server.\n eventDefinitionResponse.config._is_scheduled = response.context.scheduler.is_scheduled;\n setEventDefinition(eventDefinitionResponse);\n },\n (error) => {\n if (error.status === 404) {\n history.push(Routes.ALERTS.DEFINITIONS.LIST);\n }\n },\n );\n }\n }, [params, currentUser, history]);\n\n const { loadingScopePermissions, scopePermissions } = useScopePermissions(eventDefinition);\n\n const streamsWithMissingPermissions = () => {\n const streams = eventDefinition?.config?.streams || [];\n\n return streams.filter((streamId) => !isPermitted(currentUser.permissions, `streams:read:${streamId}`));\n };\n\n if (!isPermitted(currentUser.permissions, `eventdefinitions:edit:${params.definitionId}`)) {\n history.push(Routes.NOTFOUND);\n }\n\n const missingStreams = streamsWithMissingPermissions();\n\n if (missingStreams.length > 0) {\n return ;\n }\n\n if (!eventDefinition || loadingScopePermissions) {\n return (\n \n \n \n \n \n \n \n );\n }\n\n return (\n \n \n \n \n Event Definitions allow you to create Events from different Conditions and alert on them.\n \n \n {scopePermissions.is_mutable ? (\n \n \n \n \n
\n ) : (\n \n \n \n \n \n This particular Event Definition has been marked as immutable when it was created, therefore it cannot be edited.
\n \n \n
\n \n
\n )}\n\n \n );\n};\n\nexport default EditEventDefinitionPage;\n"],"names":["fetchScopePermissions","entity","data","isLoading","error","scope","permissions","params","currentUser","eventDefinition","setEventDefinition","history","response","eventDefinitionResponse","loadingScopePermissions","scopePermissions","streamsWithMissingPermissions","streamId","missingStreams"],"sourceRoot":""}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy