@finos/legend-extension-dsl-data-quality
Version:
Legend extension for Data Quality
65 lines • 4.63 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) 2026-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 { runInAction } from 'mobx';
import { CustomSelectorInput, XIcon } from '@finos/legend-art';
import { SuggestedValidationsFilter } from './states/DataQualityRelationValidationSuggestedValidationState.js';
import { DataQualityRelationValidationSuggestionItem } from './DataQualityReltionValidationSuggestionItem.js';
export const DataQualityRelationValidationSuggestionPanel = observer((props) => {
const { configurationState: state } = props;
const { suggestedValidationsState: suggestionsState } = state;
const { suggestionPanelState } = suggestionsState;
const isLoading = suggestionsState.fetchState.isInProgress;
const unappliedSuggestions = suggestionsState.filteredSuggestions;
const selectedSuggestions = suggestionsState.selectedSuggestions;
const suggestions = suggestionsState.suggestedValidations;
const filterOptions = [
{ label: 'All', value: SuggestedValidationsFilter.ALL },
{ label: 'New', value: SuggestedValidationsFilter.NEW },
{
label: 'Modifications',
value: SuggestedValidationsFilter.MODIFICATIONS,
},
];
const addAllSuggestedValidations = () => {
runInAction(() => {
unappliedSuggestions.forEach((validationState) => {
validationState.setIsSelected(false);
state.applyOrModifySuggestion(validationState);
});
});
};
const addSelectedValidations = () => {
if (selectedSuggestions.length === 0) {
return;
}
runInAction(() => {
selectedSuggestions.forEach((validationState) => {
validationState.setIsSelected(false);
state.applyOrModifySuggestion(validationState);
});
});
};
return (_jsxs("div", { className: "rule-suggestion-panel", children: [_jsxs("div", { className: "rule-suggestion-panel__header", children: [_jsxs("div", { className: "rule-suggestion-panel__header__controls", children: [_jsx("span", { className: "rule-suggestion-panel__header__title", children: "SUGGESTED VALIDATIONS" }), _jsx(CustomSelectorInput, { className: "rule-suggestion-panel__header__filter", options: filterOptions, onChange: (option) => {
suggestionsState.onFilterChange(option.value);
}, value: filterOptions.find((option) => option.value === suggestionsState.filter), darkMode: true, placeholder: "Filter...", disabled: isLoading })] }), _jsxs("div", { className: "rule-suggestion-panel__header__actions", children: [selectedSuggestions.length > 0 && (_jsx("button", { className: "rule-suggestion-panel__action-btn btn--dark", onClick: addSelectedValidations, disabled: isLoading, title: "Add selected validations", children: "Add Selection" })), !isLoading && unappliedSuggestions.length > 0 && (_jsx("button", { className: "rule-suggestion-panel__action-btn btn--dark", onClick: addAllSuggestedValidations, title: "Apply all suggested validations", children: "Apply All Suggested Validations" })), _jsx("div", { className: "rule-suggestion-panel__close-btn", children: _jsx(XIcon, { onClick: () => suggestionPanelState.toggle() }) })] })] }), !isLoading && unappliedSuggestions.length > 0 && (_jsx("div", { className: "rule-suggestion-panel__content", children: unappliedSuggestions.map((validationState) => {
return (_jsx(DataQualityRelationValidationSuggestionItem, { validationState: validationState, configurationState: state }, validationState.lambdaId));
}) })), !isLoading && unappliedSuggestions.length === 0 && (_jsx("div", { className: "panel__content__empty-text", children: suggestions.length === 0
? 'No suggestions available'
: 'All suggestions have been applied' }))] }));
});
//# sourceMappingURL=DataQualityRelationValidationSuggestionPanel.js.map