From 84ef2c9d6c41381673378f4b7afcff8f4c02c696 Mon Sep 17 00:00:00 2001 From: Ryan Mathis Date: Fri, 11 Jun 2021 09:36:27 -0700 Subject: [PATCH] Added check for real changes --- .../src/main/resources/i18n/messages.properties | 5 +++-- .../resources/metadata-sources-ui-schema.json | 6 ++---- .../metadata/domain/source/SourceDefinition.js | 9 +++++++++ ui/src/app/metadata/editor/MetadataEditor.js | 11 ++++++++++- ui/src/app/metadata/editor/MetadataEditorForm.js | 4 +--- .../app/metadata/editor/MetadataFilterEditor.js | 3 ++- ui/src/app/metadata/hooks/utility.js | 9 +++++++++ ui/src/app/metadata/new/NewFilter.js | 2 +- ui/src/app/metadata/view/EditFilter.js | 2 +- .../metadata/wizard/MetadataProviderWizard.js | 4 ++-- .../app/metadata/wizard/MetadataSourceWizard.js | 16 ++++++++++------ 11 files changed, 50 insertions(+), 21 deletions(-) diff --git a/backend/src/main/resources/i18n/messages.properties b/backend/src/main/resources/i18n/messages.properties index 60b8dfd78..2c6a85bbb 100644 --- a/backend/src/main/resources/i18n/messages.properties +++ b/backend/src/main/resources/i18n/messages.properties @@ -551,8 +551,9 @@ tooltip.want-assertions-signed=Want Assertions Signed tooltip.certificate-name=Certificate Name tooltip.certificate-type=Certificate Type tooltip.certificate=Certificate -tooltip.logout-endpoints-url=Logout Endpoints Url -tooltip.logout-endpoints-binding-type=Logout Endpoints Binding Type +tooltip.logout-endpoints=Logout Endpoints +tooltip.url=Logout Endpoints Url +tooltip.binding-type=Logout Endpoints Binding Type tooltip.mdui-display-name=Typically, the IdP Display Name field will be presented on IdP discovery service interfaces. tooltip.mdui-information-url=The IdP Information URL is a link to a comprehensive information page about the IdP. This page should expand on the content of the IdP Description field. tooltip.mdui-description=The IdP Description is a brief description of the IdP service. On a well-designed discovery interface, the IdP Description will be presented to the user in addition to the IdP Display Name, and so the IdP Description helps disambiguate duplicate or similar IdP Display Names. diff --git a/backend/src/main/resources/metadata-sources-ui-schema.json b/backend/src/main/resources/metadata-sources-ui-schema.json index e156a4c62..0f5b06d4c 100644 --- a/backend/src/main/resources/metadata-sources-ui-schema.json +++ b/backend/src/main/resources/metadata-sources-ui-schema.json @@ -22,8 +22,7 @@ "serviceEnabled": { "title": "label.enable-this-service", "description": "tooltip.enable-this-service-upon-saving", - "type": "boolean", - "default": false + "type": "boolean" }, "organization": { "$ref": "#/definitions/Organization" @@ -72,8 +71,7 @@ }, "properties": { "x509CertificateAvailable": { - "type": "boolean", - "default": true + "type": "boolean" }, "authenticationRequestsSigned": { "title": "label.authentication-requests-signed", diff --git a/ui/src/app/metadata/domain/source/SourceDefinition.js b/ui/src/app/metadata/domain/source/SourceDefinition.js index 2cbf83679..d3db4f603 100644 --- a/ui/src/app/metadata/domain/source/SourceDefinition.js +++ b/ui/src/app/metadata/domain/source/SourceDefinition.js @@ -64,6 +64,15 @@ export const SourceBase = { } } } + + if (formData?.securityInfo?.x509Certificates) { + if (formData.securityInfo.x509Certificates?.length > 0) { + d.securityInfo.x509CertificateAvailable = true; + } else { + d.securityInfo.x509CertificateAvailable = false; + } + } + return d; }, diff --git a/ui/src/app/metadata/editor/MetadataEditor.js b/ui/src/app/metadata/editor/MetadataEditor.js index d2ee2e56d..ffe6f01b6 100644 --- a/ui/src/app/metadata/editor/MetadataEditor.js +++ b/ui/src/app/metadata/editor/MetadataEditor.js @@ -18,6 +18,9 @@ import API_BASE_PATH from '../../App.constant'; import { MetadataObjectContext } from '../hoc/MetadataSelector'; import { FilterableProviders } from '../domain/provider'; +import { detailedDiff } from 'deep-object-diff'; +import { removeNull } from '../../core/utility/remove_null'; + export function MetadataEditor ({ current }) { const translator = useTranslator(); @@ -35,10 +38,16 @@ export function MetadataEditor ({ current }) { const { state, dispatch } = React.useContext(MetadataFormContext); const { metadata, errors } = state; + const checkChanges = (original, updates) => { + const diff = detailedDiff(original, removeNull(updates, true)); + const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0); + return hasChanges; + }; + const onChange = (changes) => { dispatch(setFormDataAction(changes.formData)); dispatch(setFormErrorAction(changes.errors)); - setBlocking(true); + setBlocking(checkChanges(metadata, changes.formData)); }; function save(metadata) { diff --git a/ui/src/app/metadata/editor/MetadataEditorForm.js b/ui/src/app/metadata/editor/MetadataEditorForm.js index f1288fd16..eecd61530 100644 --- a/ui/src/app/metadata/editor/MetadataEditorForm.js +++ b/ui/src/app/metadata/editor/MetadataEditorForm.js @@ -34,8 +34,6 @@ export function MetadataEditorForm({ metadata, definition, schema, current, onCh onChange(definition.bindings ? { ...form, formData: definition.bindings(data, form.formData) }: form); }; - console.log(uiSchema); - return ( <> {step.locked &&
@@ -72,8 +70,8 @@ export function MetadataEditorForm({ metadata, definition, schema, current, onCh validate={validator}> <> +
- ); } \ No newline at end of file diff --git a/ui/src/app/metadata/editor/MetadataFilterEditor.js b/ui/src/app/metadata/editor/MetadataFilterEditor.js index 3f2432b77..85e41755e 100644 --- a/ui/src/app/metadata/editor/MetadataFilterEditor.js +++ b/ui/src/app/metadata/editor/MetadataFilterEditor.js @@ -12,6 +12,7 @@ import { MetadataEditorForm } from './MetadataEditorForm'; import { MetadataEditorNav } from './MetadataEditorNav'; import { useMetadataFilters } from '../hooks/api'; import { MetadataFilterContext } from '../hoc/MetadataFilterSelector'; +import { checkChanges } from '../hooks/utility'; export function MetadataFilterEditor({children, onNavigate, block}) { @@ -28,7 +29,7 @@ export function MetadataFilterEditor({children, onNavigate, block}) { const onChange = (changes) => { dispatch(setFormDataAction(changes.formData)); dispatch(setFormErrorAction(changes.errors)); - block(); + block(checkChanges(metadata, changes.formData)); }; const validator = definition.validator(data, current); diff --git a/ui/src/app/metadata/hooks/utility.js b/ui/src/app/metadata/hooks/utility.js index 8b8ab5961..c197911a8 100644 --- a/ui/src/app/metadata/hooks/utility.js +++ b/ui/src/app/metadata/hooks/utility.js @@ -1,3 +1,12 @@ +import { detailedDiff } from "deep-object-diff"; +import { removeNull } from "../../core/utility/remove_null"; + +export const checkChanges = (original, updates) => { + const diff = detailedDiff(original, removeNull(updates, true)); + const hasChanges = Object.keys(diff).some(d => Object.keys(diff[d]).length > 0); + return hasChanges; +} + export function getDefinition(path, definitions) { let def = path.split('/').pop(); return definitions[def]; diff --git a/ui/src/app/metadata/new/NewFilter.js b/ui/src/app/metadata/new/NewFilter.js index 3b00cfaee..5fce5d31f 100644 --- a/ui/src/app/metadata/new/NewFilter.js +++ b/ui/src/app/metadata/new/NewFilter.js @@ -67,7 +67,7 @@ export function NewFilter() { {(type, base) => - setBlocking(true)}> + setBlocking(b)}> {(filter, isInvalid) =>

- setBlocking(true) }> + setBlocking(b) }> {(filter, isInvalid) =>