@finos/legend-extension-dsl-data-quality
Version:
Legend extension for Data Quality
80 lines • 6.55 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { observer } from 'mobx-react-lite';
import { useEditorStore } from '@finos/legend-application-studio';
import { BaseRadioGroup, CustomSelectorInput } from '@finos/legend-art';
import { buildElementOption, } from '@finos/legend-lego/graph-editor';
import { DataQuality_ElementDriver, CLASS_ELEMENT_CREATION_BASIS, DQ_VALIDATION_ELEMENT_TYPE, } from './DSL_DataQuality_ElementDriver.js';
import { prettyCONSTName } from '@finos/legend-shared';
export const NewDataQualityValidationElementEditor = observer(() => {
const editorStore = useEditorStore();
const applicationStore = editorStore.applicationStore;
const dataQualityValidationDriver = editorStore.newElementState.getNewElementDriver(DataQuality_ElementDriver);
const dqValidationElementType = dataQualityValidationDriver.dqValidationElementType;
const dqElementCreationBasis = dataQualityValidationDriver.dqClassElementCreationBasis;
const dataSpacesOptions = dataQualityValidationDriver.dataSpaceOptions;
const mappingOptions = dataQualityValidationDriver.mappingOptions;
const runtimeOptions = dataQualityValidationDriver.compatibleMappingRuntimes.map(buildElementOption);
const dqValidationElementTypeOptions = Object.values(DQ_VALIDATION_ELEMENT_TYPE)
.filter((validation) => validation !== DQ_VALIDATION_ELEMENT_TYPE.SERVICE_VALIDATION)
.map((validationType) => ({
label: prettyCONSTName(validationType),
value: validationType,
}));
const onDataSpaceChange = (val) => {
if (val) {
dataQualityValidationDriver.setDataSpaceSelected(val);
}
};
const onMappingChange = (val) => {
if (val) {
dataQualityValidationDriver.setMappingSelected(val);
}
else {
dataQualityValidationDriver.setMappingSelected(undefined);
}
dataQualityValidationDriver.setRuntimeSelected(dataQualityValidationDriver.runtimeOptions.length > 0
? dataQualityValidationDriver.runtimeOptions[0]
: undefined);
};
const onRuntimeChange = (val) => {
if (val) {
dataQualityValidationDriver.setRuntimeSelected(val);
}
};
const handleDQClassElementCreationBasisChange = (event) => {
const classValidationElementCreationBasis = event.target.value;
dataQualityValidationDriver.setDqClassElementCreationBasis(classValidationElementCreationBasis);
};
const handleDQValidationElementTypeChange = (val) => {
dataQualityValidationDriver.setDqValidationElementType(val.value);
};
const selectedDqValidationElementType = {
label: prettyCONSTName(dataQualityValidationDriver.dqValidationElementType),
value: dataQualityValidationDriver.dqValidationElementType,
};
return (_jsxs("div", { children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Validation Type" }), _jsx("div", { className: "panel__content__form__section__header__prompt", children: "Type of Data Quality Validation to be configured" }), _jsx(CustomSelectorInput, { options: dqValidationElementTypeOptions, onChange: handleDQValidationElementTypeChange, value: selectedDqValidationElementType, darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, placeholder: "Choose a data quality validation type", isClearable: false, className: 'dq-validation-element-type' }), dqValidationElementType ===
DQ_VALIDATION_ELEMENT_TYPE.CLASS_VALIDATION && (_jsxs("div", { children: [_jsxs("div", { className: "element-creation-basis", children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Basis of Data Quality Class Validation" }), _jsx(BaseRadioGroup, { value: dqElementCreationBasis, onChange: handleDQClassElementCreationBasisChange, row: false, options: [
CLASS_ELEMENT_CREATION_BASIS.DATASPACE_BASED,
CLASS_ELEMENT_CREATION_BASIS.MAPPING_RUNTIME_BASED,
], size: 2 })] }), dqElementCreationBasis ===
CLASS_ELEMENT_CREATION_BASIS.DATASPACE_BASED ? (_jsxs("div", { children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Data Product" }), _jsx("div", { className: "data-quality-explorer__new-element-modal__driver", children: _jsx(CustomSelectorInput, { className: "data-quality-explorer__new-element-modal__driver__dropdown", options: dataSpacesOptions, onChange: onDataSpaceChange, value: dataQualityValidationDriver.dataSpaceSelected, darkMode: !applicationStore.layoutService
.TEMPORARY__isLightColorThemeEnabled }) })] })) : (_jsxs("div", { children: [_jsx("div", { className: "panel__content__form__section__header__label", children: "Mapping" }), _jsx("div", { className: "data-quality-explorer__new-element-modal__driver", children: _jsx(CustomSelectorInput, { className: "data-quality-explorer__new-element-modal__driver__dropdown", options: mappingOptions, onChange: onMappingChange, value: dataQualityValidationDriver.mappingSelected, darkMode: !applicationStore.layoutService
.TEMPORARY__isLightColorThemeEnabled }) }), _jsx("div", { className: "panel__content__form__section__header__label", children: "Runtime" }), _jsx("div", { className: "data-quality-explorer__new-element-modal__driver", children: _jsx(CustomSelectorInput, { className: "data-quality-explorer__new-element-modal__driver__dropdown", options: runtimeOptions, onChange: onRuntimeChange, value: dataQualityValidationDriver.runtimeSelected, darkMode: !applicationStore.layoutService
.TEMPORARY__isLightColorThemeEnabled }) })] }))] }))] }));
});
//# sourceMappingURL=DSL_NewDataQualityValidationElement.js.map