Skip to content

Commit 00e6efb

Browse files
committed
fix(data-catalog): bugs in editing tags
1 parent bef5693 commit 00e6efb

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

testgen/ui/components/frontend/js/data_profiling/metadata_tags.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const MetadataTagsCard = (props, item) => {
100100
help: TAG_HELP[key],
101101
label: key === 'pii_flag' ? 'PII Data' : capitalize(key.replaceAll('_', ' ')),
102102
state: van.state(value),
103+
initialValue: value,
103104
inheritTableGroup: item[`table_group_${key}`] ?? null, // Table group values inherited by table or column
104105
inheritTable: item[`table_${key}`] ?? null, // Table values inherited by column
105106
};
@@ -198,13 +199,15 @@ const MetadataTagsCard = (props, item) => {
198199
content, editingContent,
199200
onSave: () => {
200201
const items = [{ type: item.type, id: item.id }];
201-
const tags = attributes.reduce((object, { key, state }) => {
202-
object[key] = state.rawVal;
202+
const tags = attributes.reduce((object, { key, state, initialValue }) => {
203+
if (state.rawVal !== initialValue) {
204+
object[key] = state.rawVal;
205+
}
203206
return object;
204207
}, {});
205208

206-
warnCde.val = props.autoflagSettings.profile_flag_cdes && tags.critical_data_element !== item.critical_data_element;
207-
warnPii.val = props.autoflagSettings.profile_flag_pii && tags.pii_flag !== item.pii_flag;
209+
warnCde.val = props.autoflagSettings.profile_flag_cdes && 'critical_data_element' in tags;
210+
warnPii.val = props.autoflagSettings.profile_flag_pii && 'pii_flag' in tags;
208211

209212
if (warnCde.val || warnPii.val) {
210213
const disableFlags = [];
@@ -221,8 +224,8 @@ const MetadataTagsCard = (props, item) => {
221224
}
222225
},
223226
// Reset states to original values on cancel
224-
onCancel: () => attributes.forEach(({ key, state }) => state.val = item[key]),
225-
hasChanges: () => attributes.some(({ key, state }) => state.val !== item[key]),
227+
onCancel: () => attributes.forEach(({ state, initialValue }) => state.val = initialValue),
228+
hasChanges: () => attributes.some(({ state, initialValue }) => state.val !== initialValue),
226229
}),
227230
WarningDialog(warningDialogOpen, pendingSaveAction, warnCde, warnPii),
228231
);

0 commit comments

Comments
 (0)