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B,EAAQ,UAAoB,EAC9CC,EAAmB,EAAQ,UAAqB,EAGhDC,EAAc,OAAO,UAGrBC,EAAiBD,EAAY,eAwB7BE,EAAUH,EAAiB,SAASI,EAAQ5D,EAAO6D,EAAK,CACtDH,EAAe,KAAKE,EAAQC,CAAG,EACjC,EAAED,EAAOC,CAAG,EAEZN,EAAgBK,EAAQC,EAAK,CAAC,CAElC,CAAC,EAEDC,EAAO,QAAUH,C","sources":["webpack://graylog-web-interface/./src/components/indices/IndexSetFieldTypeProfiles/ProfileForm.tsx","webpack://graylog-web-interface/./src/components/indices/IndexSetFieldTypeProfiles/hooks/useProfileMutations.ts","webpack://graylog-web-interface/./src/components/indices/IndexSetFieldTypeProfiles/CreateProfile.tsx","webpack://graylog-web-interface/./src/pages/IndexSetFieldTypeProfileCreatePage.tsx","webpack://graylog-web-interface/./node_modules/lodash/countBy.js"],"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 */\n\nimport { styled } from 'styled-components';\nimport React, { useMemo } from 'react';\nimport { Formik, Form, FieldArray, Field } from 'formik';\nimport countBy from 'lodash/countBy';\n\nimport type { IndexSetFieldTypeProfileForm } from 'components/indices/IndexSetFieldTypeProfiles/types';\nimport { FormikInput, IconButton, Select, FormSubmit, Spinner, InputOptionalInfo } from 'components/common';\nimport { Button, Col, HelpBlock, Input } from 'components/bootstrap';\nimport useFieldTypes from 'views/logic/fieldtypes/useFieldTypes';\nimport useFieldTypesForMapping from 'views/logic/fieldactions/ChangeFieldType/hooks/useFieldTypesForMappings';\nimport { defaultCompare } from 'logic/DefaultCompare';\nimport isReservedField from 'views/logic/IsReservedField';\n\nconst SelectContainer = styled.div`\n flex-basis: 100%;\n`;\n\nconst SelectGroup = styled.div`\n flex-grow: 1;\n display: flex;\n gap: 5px;\n`;\nconst List = styled.div`\n display: flex;\n flex-direction: column;\n`;\nconst StyledLabel = styled.h5`\n font-weight: bold;\n margin-bottom: 5px;\n`;\n\nconst Item = styled.div`\n display: flex;\n gap: 5px;\n`;\n\nconst StyledFormSubmit = styled(FormSubmit)`\n margin-top: 30px;\n`;\ntype Props = {\n initialValues?: IndexSetFieldTypeProfileForm,\n submitButtonText: string,\n submitLoadingText: string,\n onCancel: () => void,\n onSubmit: (profile: IndexSetFieldTypeProfileForm) => void\n}\n\nconst getFieldError = (field: string, occurrences: number) => {\n if (!field) return 'Field is required';\n if (isReservedField(field)) return 'Field is reserved';\n if (occurrences > 1) return 'This field occurs several times';\n\n return undefined;\n};\n\nconst validate = (formValues: IndexSetFieldTypeProfileForm) => {\n const errors: { name?: string, customFieldMappings?: Array<{ field?: string, type?: string }>} = {};\n\n if (!formValues.name) {\n errors.name = 'Profile name is required';\n }\n\n const fieldsOccurrences = countBy(formValues.customFieldMappings, 'field');\n\n const customFieldMappings: Array<{ field: string, type: string }> = formValues\n .customFieldMappings\n .map(({ field, type }) => {\n if (field && type && (fieldsOccurrences[field] === 1)) return undefined;\n\n return ({\n field: getFieldError(field, fieldsOccurrences[field]),\n type: !type ? 'Type is required' : undefined,\n });\n });\n\n if (customFieldMappings.filter((item) => item).length > 0) {\n errors.customFieldMappings = customFieldMappings;\n }\n\n return errors;\n};\n\ntype ProfileFormSelectProps = {\n onChange: (param: { target: { value: string, name: string } }) => void,\n options: Array<{ value: string, label: string, disabled?: boolean }>,\n error: string,\n name: string,\n value: string | undefined | null,\n placeholder: string,\n allowCreate: boolean,\n}\n\nconst ProfileFormSelect = ({ onChange, options, error, name, value, placeholder, allowCreate }: ProfileFormSelectProps) => (\n \n \n \n);\n\nconst ProfileForm = ({ initialValues, submitButtonText, submitLoadingText, onCancel, onSubmit }: Props) => {\n const { data, isLoading } = useFieldTypes(undefined, undefined);\n const { data: { fieldTypes }, isLoading: isLoadingFieldTypes } = useFieldTypesForMapping();\n const fieldTypeOptions = useMemo(() => Object.entries(fieldTypes)\n .sort(([, label1], [, label2]) => defaultCompare(label1, label2))\n .map(([value, label]) => ({\n value,\n label,\n })), [fieldTypes]);\n const fields = useMemo(() => (isLoading ? [] : data.map(({ value: { name } }) => ({ value: name, label: name, disabled: isReservedField(name) }))), [data, isLoading]);\n\n const _onSubmit = (profile: IndexSetFieldTypeProfileForm) => {\n onSubmit(profile);\n };\n\n return (\n \n initialValues={initialValues}\n onSubmit={_onSubmit}\n validate={validate}\n validateOnChange>\n {({ isSubmitting, isValid, isValidating, values: { customFieldMappings } }) => (\n \n )}\n \n \n );\n};\n\nProfileForm.defaultProps = {\n initialValues: { name: '', description: '', customFieldMappings: [{ type: '', field: '' }] },\n};\n\nexport default ProfileForm;\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 { useMutation, useQueryClient } from '@tanstack/react-query';\n\nimport { qualifyUrl } from 'util/URLUtils';\nimport fetch from 'logic/rest/FetchProvider';\nimport UserNotification from 'util/UserNotification';\nimport type {\n IndexSetFieldTypeProfileForm,\n IndexSetFieldTypeProfileRequestJson,\n} from 'components/indices/IndexSetFieldTypeProfiles/types';\n\nexport const urlPrefix = '/system/indices/index_sets/profiles';\n\nconst putProfile = async ({ profile, id }: { profile: IndexSetFieldTypeProfileForm, id: string }) => {\n const url = qualifyUrl(urlPrefix);\n const body: IndexSetFieldTypeProfileRequestJson = {\n id,\n name: profile.name,\n description: profile.description,\n custom_field_mappings: profile.customFieldMappings,\n };\n\n return fetch('PUT', url, body);\n};\n\nconst postProfile = async (profile: IndexSetFieldTypeProfileForm) => {\n const url = qualifyUrl(urlPrefix);\n const body: IndexSetFieldTypeProfileRequestJson = {\n name: profile.name,\n description: profile.description,\n custom_field_mappings: profile.customFieldMappings,\n };\n\n return fetch('POST', url, body);\n};\n\nconst deleteProfile = async (id: string) => {\n const url = qualifyUrl(`${urlPrefix}/${id}`);\n\n return fetch('DELETE', url);\n};\n\nconst useProfileMutation = () => {\n const queryClient = useQueryClient();\n\n const post = useMutation(postProfile, {\n onError: (errorThrown) => {\n UserNotification.error(`Creating index set field type profile failed with status: ${errorThrown}`,\n 'Could not create index set field type profile');\n },\n onSuccess: () => {\n UserNotification.success('Index set field type profile has been successfully created.', 'Success!');\n\n return queryClient.refetchQueries({ queryKey: ['indexSetFieldTypeProfiles'], type: 'active' });\n },\n });\n const put = useMutation(putProfile, {\n onError: (errorThrown) => {\n UserNotification.error(`Updating index set field type profile failed with status: ${errorThrown}`,\n 'Could not update index set field type profile');\n },\n onSuccess: () => {\n UserNotification.success('Index set field type profile has been successfully updated.', 'Success!');\n\n return queryClient.refetchQueries({ queryKey: ['indexSetFieldTypeProfiles'], type: 'active' });\n },\n });\n const remove = useMutation(deleteProfile, {\n onError: (errorThrown) => {\n UserNotification.error(`Deleting index set field type profile failed with status: ${errorThrown}`,\n 'Could not delete index set field type profile');\n },\n onSuccess: () => {\n UserNotification.success('Index set field type profile has been successfully deleted.', 'Success!');\n\n return queryClient.refetchQueries({ queryKey: ['indexSetFieldTypeProfiles'], type: 'active' });\n },\n });\n\n return ({\n editProfile: put.mutateAsync,\n isEditLoading: put.isLoading,\n createProfile: post.mutateAsync,\n isCreateLoading: post.isLoading,\n isLoading: post.mutateAsync || post.isLoading || remove.isLoading,\n deleteProfile: remove.mutateAsync,\n });\n};\n\nexport default useProfileMutation;\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, { useMemo, useCallback, useEffect } from 'react';\nimport { useNavigate } from 'react-router-dom';\n\nimport useSendTelemetry from 'logic/telemetry/useSendTelemetry';\nimport { TELEMETRY_EVENT_TYPE } from 'logic/telemetry/Constants';\nimport { getPathnameWithoutId } from 'util/URLUtils';\nimport useLocation from 'routing/useLocation';\nimport ProfileForm from 'components/indices/IndexSetFieldTypeProfiles/ProfileForm';\nimport type {\n IndexSetFieldTypeProfileForm,\n} from 'components/indices/IndexSetFieldTypeProfiles/types';\nimport useProfileMutations from 'components/indices/IndexSetFieldTypeProfiles/hooks/useProfileMutations';\nimport Routes from 'routing/Routes';\nimport useHistory from 'routing/useHistory';\n\nconst CreateProfile = () => {\n const sendTelemetry = useSendTelemetry();\n const { pathname } = useLocation();\n const navigate = useNavigate();\n const { createProfile } = useProfileMutations();\n const telemetryPathName = useMemo(() => getPathnameWithoutId(pathname), [pathname]);\n const location = useLocation();\n const history = useHistory();\n const initialValues = useMemo(() => {\n const defaultCustomFieldMappings = location?.state?.customFieldMappings;\n\n if (defaultCustomFieldMappings) {\n return ({\n customFieldMappings: defaultCustomFieldMappings,\n name: null,\n description: null,\n });\n }\n\n return undefined;\n }, [location?.state?.customFieldMappings]);\n\n const onSubmit = useCallback((profile: IndexSetFieldTypeProfileForm) => {\n createProfile(profile).then(() => {\n sendTelemetry(TELEMETRY_EVENT_TYPE.INDEX_SET_FIELD_TYPE_PROFILE.CREATED, {\n app_pathname: telemetryPathName,\n app_action_value: { mappingsQuantity: profile?.customFieldMappings?.length },\n });\n\n navigate(Routes.SYSTEM.INDICES.FIELD_TYPE_PROFILES.OVERVIEW);\n });\n }, [createProfile, navigate, sendTelemetry, telemetryPathName]);\n\n useEffect(() => {\n sendTelemetry(TELEMETRY_EVENT_TYPE.INDEX_SET_FIELD_TYPE_PROFILE.NEW_OPENED, { app_pathname: telemetryPathName, app_action_value: 'create-new-index-set-field-type-profile-opened' });\n }, [sendTelemetry, telemetryPathName]);\n\n const onCancel = useCallback(() => {\n sendTelemetry(TELEMETRY_EVENT_TYPE.INDEX_SET_FIELD_TYPE_PROFILE.NEW_CANCELED, { app_pathname: telemetryPathName, app_action_value: 'create-new-index-set-field-type-profile-canceled' });\n history.goBack();\n }, [history, sendTelemetry, telemetryPathName]);\n\n return (\n \n );\n};\n\nexport default CreateProfile;\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, { useEffect } from 'react';\nimport { useNavigate } from 'react-router-dom';\n\nimport { DocumentTitle, PageHeader } from 'components/common';\nimport DocsHelper from 'util/DocsHelper';\nimport Routes from 'routing/Routes';\nimport { Col, Row } from 'components/bootstrap';\nimport CreateProfile from 'components/indices/IndexSetFieldTypeProfiles/CreateProfile';\nimport useHasTypeMappingPermission from 'hooks/useHasTypeMappingPermission';\nimport { IndicesPageNavigation } from 'components/indices';\n\nconst IndexSetFieldTypeProfileCreatePage = () => {\n const navigate = useNavigate();\n const hasMappingPermission = useHasTypeMappingPermission();\n\n useEffect(() => {\n if (!hasMappingPermission) {\n navigate(Routes.NOTFOUND);\n }\n }, [hasMappingPermission, navigate]);\n\n return (\n \n \n \n \n With index set field type profiles you can bundle up custom field types into profiles.\n Then you can assign this profile to any index set.\n On this page you can create a new profile.\n \n \n \n \n \n \n
\n \n );\n};\n\nexport default IndexSetFieldTypeProfileCreatePage;\n","var baseAssignValue = require('./_baseAssignValue'),\n createAggregator = require('./_createAggregator');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Creates an object composed of keys generated from the results of running\n * each element of `collection` thru `iteratee`. The corresponding value of\n * each key is the number of times the key was returned by `iteratee`. The\n * iteratee is invoked with one argument: (value).\n *\n * @static\n * @memberOf _\n * @since 0.5.0\n * @category Collection\n * @param {Array|Object} collection The collection to iterate over.\n * @param {Function} [iteratee=_.identity] The iteratee to transform keys.\n * @returns {Object} Returns the composed aggregate object.\n * @example\n *\n * _.countBy([6.1, 4.2, 6.3], Math.floor);\n * // => { '4': 1, '6': 2 }\n *\n * // The `_.property` iteratee shorthand.\n * _.countBy(['one', 'two', 'three'], 'length');\n * // => { '3': 2, '5': 1 }\n */\nvar countBy = createAggregator(function(result, value, key) {\n if (hasOwnProperty.call(result, key)) {\n ++result[key];\n } else {\n baseAssignValue(result, key, 1);\n }\n});\n\nmodule.exports = countBy;\n"],"names":["SelectContainer","SelectGroup","List","StyledLabel","Item","StyledFormSubmit","getFieldError","field","occurrences","validate","formValues","errors","fieldsOccurrences","customFieldMappings","type","item","ProfileFormSelect","onChange","options","error","name","value","placeholder","allowCreate","newVal","ProfileForm","initialValues","submitButtonText","submitLoadingText","onCancel","onSubmit","data","isLoading","fieldTypes","isLoadingFieldTypes","fieldTypeOptions","label1","label2","label","fields","_onSubmit","profile","isSubmitting","isValid","isValidating","remove","push","index","urlPrefix","putProfile","id","url","body","postProfile","deleteProfile","queryClient","post","errorThrown","put","sendTelemetry","useSendTelemetry","pathname","useLocation","navigate","createProfile","useProfileMutations","telemetryPathName","location","history","useHistory","_a","defaultCustomFieldMappings","Routes","hasMappingPermission","useHasTypeMappingPermission","DocsHelper","baseAssignValue","createAggregator","objectProto","hasOwnProperty","countBy","result","key","module"],"sourceRoot":""}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy