diff --git a/backend/src/main/resources/algorithm-filter.schema.json b/backend/src/main/resources/algorithm-filter.schema.json index f570dacb7..552d92ec2 100644 --- a/backend/src/main/resources/algorithm-filter.schema.json +++ b/backend/src/main/resources/algorithm-filter.schema.json @@ -1,65 +1,82 @@ { - "type": "object", - "required": [ - "name" - ], - "properties": { - "name": { - "title": "label.filter-name", - "description": "tooltip.filter-name", - "type": "string" - }, - "filterEnabled": { - "title": "label.enable-filter", - "description": "tooltip.enable-filter", - "type": "boolean", - "default": false - }, - "AlgorithmFilterTarget": { - "title": "label.search-criteria", - "description": "tooltip.search-criteria", - "type": "object", - "properties": { - "nameIdFormatFilterTargetType": { - "title": "label.filter-target-type", - "type": "string", - "default": "ENTITY", - "enum": [ - "ENTITY", - "CONDITION_REF", - "CONDITION_SCRIPT" - ], - "enumNames": [ - "value.entity-id", - "value.reference", - "value.script" - ] - }, - "value": { - "title": "label.filter-target-value", - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items": { - "type": "string" - } - } - }, - "required": [ - "value", - "algorithmFilterTargetType" - ] - }, - "@type": { - "type": "string", - "default": "Algorithm" - }, - "version": { - "type": "integer" + "type": "object", + "required": ["name"], + "properties": { + "name": { + "title": "label.filter-name", + "description": "tooltip.filter-name", + "type": "string" + }, + "filterEnabled": { + "title": "label.enable-filter", + "description": "tooltip.enable-filter", + "type": "boolean", + "default": false + }, + "algorithmFilterTarget": { + "title": "label.search-criteria", + "description": "tooltip.search-criteria", + "type": "object", + "properties": { + "algorithmFilterTargetType": { + "title": "label.filter-target-type", + "type": "string", + "default": "ENTITY", + "enum": ["ENTITY", "CONDITION_REF", "CONDITION_SCRIPT"], + "enumNames": ["value.entity-id", "value.reference", "value.script"] }, - "resourceId": { + "value": { + "title": "label.filter-target-value", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { "type": "string" + } } + }, + "required": ["value", "algorithmFilterTargetType"] + }, + "@type": { + "type": "string", + "default": "Algorithm" + }, + "version": { + "type": "integer" + }, + "resourceId": { + "type": "string" }, - "definitions": {} -} \ No newline at end of file + "algorithms": { + "$ref": "#/definitions/AlgorithmList" + } + }, + "definitions": { + "AlgorithmList": { + "title": "label.algorithm", + "description": "tooltip.algorithm", + "type": "array", + "items": { + "type": "string", + "enum": [ + "http://www.w3.org/2009/xmlenc11#aes256-gcm", + "http://www.w3.org/2009/xmlenc11#aes192-gcm", + "http://www.w3.org/2009/xmlenc11#aes128-gcm", + "http://www.w3.org/2001/04/xmlenc#aes256-cbc", + "http://www.w3.org/2001/04/xmlenc#aes192-cbc", + "http://www.w3.org/2001/04/xmlenc#aes128-cbc", + "http://www.w3.org/2001/04/xmlenc#tripledes-cbc" + ], + "enumNames": [ + "value.algorithm-gcm-256", + "value.algorithm-gcm-192", + "value.algorithm-gcm-128", + "value.algorithm-cbc-256", + "value.algorithm-cbc-192", + "value.algorithm-cbc-128", + "value.algorithm-cbc-tripledes" + ] + } + } + } +} diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 8cc2c8dd3..3f23fc105 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -589,6 +589,7 @@ message.wizard-status=Step { index } of { length } message.entity-id-min-unique=You must add at least one entity id target and they must each be unique. message.required-for-scripts=Required for Scripts message.required-for-regex=Required for Regex +message.required-for-condition-ref=Required for Condition Ref message.file-doesnt-exist=The requested file to be processed does not exist on the server. message.database-constraint=There was a database constraint problem processing the request. Check the request to ensure that fields that must be unique are truly unique. diff --git a/ui/public/assets/schema/filter/algorithm.schema.json b/ui/public/assets/schema/filter/algorithm.schema.json index 879bb4ddc..a7abba111 100644 --- a/ui/public/assets/schema/filter/algorithm.schema.json +++ b/ui/public/assets/schema/filter/algorithm.schema.json @@ -22,10 +22,10 @@ "title": "label.filter-target-type", "type": "string", "default": "ENTITY", - "enum": ["ENTITY", "REGEX", "CONDITION_SCRIPT"], + "enum": ["ENTITY", "CONDITION_REF", "CONDITION_SCRIPT"], "enumNames": [ "value.entity-id", - "value.regex", + "value.reference", "value.script" ] }, @@ -43,34 +43,44 @@ }, "@type": { "type": "string", - "default": "NameIDFormat" + "default": "Algorithm" }, "version": { "type": "integer" }, - "algorithm": { + "resourceId": { + "type": "string" + }, + "algorithms": { + "$ref": "#/definitions/AlgorithmList" + } + }, + "definitions": { + "AlgorithmList": { "title": "label.algorithm", "description": "tooltip.algorithm", - "type": "string", - "enum": [ - "http://www.w3.org/2009/xmlenc11#aes256-gcm", - "http://www.w3.org/2009/xmlenc11#aes192-gcm", - "http://www.w3.org/2009/xmlenc11#aes128-gcm", - "http://www.w3.org/2001/04/xmlenc#aes256-cbc", - "http://www.w3.org/2001/04/xmlenc#aes192-cbc", - "http://www.w3.org/2001/04/xmlenc#aes128-cbc", - "http://www.w3.org/2001/04/xmlenc#tripledes-cbc" - ], - "enumNames": [ - "value.algorithm-gcm-256", - "value.algorithm-gcm-192", - "value.algorithm-gcm-128", - "value.algorithm-cbc-256", - "value.algorithm-cbc-192", - "value.algorithm-cbc-128", - "value.algorithm-cbc-tripledes" - ] + "type": "array", + "items": { + "type": "string", + "enum": [ + "http://www.w3.org/2009/xmlenc11#aes256-gcm", + "http://www.w3.org/2009/xmlenc11#aes192-gcm", + "http://www.w3.org/2009/xmlenc11#aes128-gcm", + "http://www.w3.org/2001/04/xmlenc#aes256-cbc", + "http://www.w3.org/2001/04/xmlenc#aes192-cbc", + "http://www.w3.org/2001/04/xmlenc#aes128-cbc", + "http://www.w3.org/2001/04/xmlenc#tripledes-cbc" + ], + "enumNames": [ + "value.algorithm-gcm-256", + "value.algorithm-gcm-192", + "value.algorithm-gcm-128", + "value.algorithm-cbc-256", + "value.algorithm-cbc-192", + "value.algorithm-cbc-128", + "value.algorithm-cbc-tripledes" + ] + } } - }, - "definitions": {} + } } diff --git a/ui/src/app/core/components/ProtectRoute.js b/ui/src/app/core/components/ProtectRoute.js index c01706920..68420b3b9 100644 --- a/ui/src/app/core/components/ProtectRoute.js +++ b/ui/src/app/core/components/ProtectRoute.js @@ -1,9 +1,14 @@ +import { isUndefined } from 'lodash'; import React from 'react'; import { Redirect } from 'react-router-dom'; -import { useIsAdmin } from '../user/UserContext'; +import { useCurrentUser, useIsAdmin } from '../user/UserContext'; export function ProtectRoute({ children, redirectTo, ...rest }) { + const user = useCurrentUser(); const isAdmin = useIsAdmin(); + if (isUndefined(user.role)) { + return <> + } return isAdmin ? children : ; } \ No newline at end of file diff --git a/ui/src/app/form/component/fields/FilterTargetField.js b/ui/src/app/form/component/fields/FilterTargetField.js index 0866ab2bf..6bcb94218 100644 --- a/ui/src/app/form/component/fields/FilterTargetField.js +++ b/ui/src/app/form/component/fields/FilterTargetField.js @@ -128,7 +128,8 @@ const FilterTargetField = ({ }; const selectType = (option) => { - setSelectedTarget([]); + const t = option.value === 'REGEX' || option.value === 'CONDITION_REF' ? [''] : []; + setSelectedTarget(t); setSelectedType(option); }; @@ -240,7 +241,6 @@ const FilterTargetField = ({ {errorSchema?.value?.__errors ? {errors} - : Required for Regex @@ -249,7 +249,25 @@ const FilterTargetField = ({ } } - + {targetType === 'CONDITION_REF' && + <> + handleTextChange(value) } /> + {errorSchema?.value?.__errors ? + + {errors} + : + + Required for Condition Ref +   + + } + + } {targetType === 'ENTITY' &&
diff --git a/ui/src/app/metadata/Filter.js b/ui/src/app/metadata/Filter.js index 4c1bc707c..58b867040 100644 --- a/ui/src/app/metadata/Filter.js +++ b/ui/src/app/metadata/Filter.js @@ -11,6 +11,8 @@ export function Filter() { const { path, url } = useRouteMatch(); + console.log(path, url) + return ( diff --git a/ui/src/app/metadata/domain/filter/definition/AlgorithmFilterDefinition.js b/ui/src/app/metadata/domain/filter/definition/AlgorithmFilterDefinition.js index 4841b5c89..51e3fa846 100644 --- a/ui/src/app/metadata/domain/filter/definition/AlgorithmFilterDefinition.js +++ b/ui/src/app/metadata/domain/filter/definition/AlgorithmFilterDefinition.js @@ -1,6 +1,5 @@ import defaultsDeep from "lodash/defaultsDeep"; -// import API_BASE_PATH from "../../../../App.constant"; -import { BASE_PATH } from '../../../../App.constant'; +import API_BASE_PATH from "../../../../App.constant"; import { BaseFilterDefinition } from "./BaseFilterDefinition"; export const AlgorithmFilterWizard = { @@ -10,19 +9,16 @@ export const AlgorithmFilterWizard = { 'ui:field': 'FilterTargetField', api: '' }, - formats: { + algorithms: { "ui:options": { orderable: false - }, - items: { - 'ui:widget': 'OptionWidget' } } }, BaseFilterDefinition.uiSchema), label: 'Algorithm', type: 'Algorithm', - // schema: `${API_BASE_PATH}/ui/AlgorithmFilter`, - schema: `${BASE_PATH}assets/schema/filter/algorithm.schema.json`, + schema: `${API_BASE_PATH}/ui/AlgorithmFilter`, + // schema: `${BASE_PATH}assets/schema/filter/algorithm.schema.json`, steps: [], validator: (data = [], current = { resourceId: null }, group) => { return BaseFilterDefinition.validator(data, current, group, 'algorithmFilterTarget', 'algorithmFilterTargetType') @@ -54,7 +50,7 @@ export const AlgorithmFilterEditor = { index: 2, initialValues: [], fields: [ - 'algorithm' + 'algorithms' ] } ] diff --git a/ui/src/app/metadata/domain/filter/definition/BaseFilterDefinition.js b/ui/src/app/metadata/domain/filter/definition/BaseFilterDefinition.js index daed4cadc..1f8191cdc 100644 --- a/ui/src/app/metadata/domain/filter/definition/BaseFilterDefinition.js +++ b/ui/src/app/metadata/domain/filter/definition/BaseFilterDefinition.js @@ -29,6 +29,13 @@ export const BaseFilterDefinition = { errors[targetProp].value.addError('message.required-for-scripts'); } } + + if (formData[targetProp][typeProp] === 'CONDITION_REF') { + const { [targetProp]: { value } } = formData; + if (!value[0]) { + errors[targetProp].value.addError('message.required-for-condition-ref'); + } + } } return errors;