@finos/legend-extension-dsl-data-space-studio 0.1.363 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/DataSpaceGeneralEditor/DataSpaceAISuggestionReviewModal.d.ts +35 -0
- package/lib/components/DataSpaceGeneralEditor/DataSpaceAISuggestionReviewModal.d.ts.map +1 -0
- package/lib/components/DataSpaceGeneralEditor/DataSpaceAISuggestionReviewModal.js +92 -0
- package/lib/components/DataSpaceGeneralEditor/DataSpaceAISuggestionReviewModal.js.map +1 -0
- package/lib/components/DataSpaceGeneralEditor/DataSpaceHomeTab.d.ts.map +1 -1
- package/lib/components/DataSpaceGeneralEditor/DataSpaceHomeTab.js +38 -27
- package/lib/components/DataSpaceGeneralEditor/DataSpaceHomeTab.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/package.json +1 -1
- package/lib/stores/DataSpaceAISuggestion.d.ts +45 -0
- package/lib/stores/DataSpaceAISuggestion.d.ts.map +1 -0
- package/lib/stores/DataSpaceAISuggestion.js +175 -0
- package/lib/stores/DataSpaceAISuggestion.js.map +1 -0
- package/package.json +12 -12
- package/src/components/DataSpaceGeneralEditor/DataSpaceAISuggestionReviewModal.tsx +339 -0
- package/src/components/DataSpaceGeneralEditor/DataSpaceHomeTab.tsx +83 -74
- package/src/stores/DataSpaceAISuggestion.ts +255 -0
- package/tsconfig.json +2 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { dataSpace_setDescription, dataSpace_setDiagramDescription, dataSpace_setDiagramTitle, dataSpace_setExecutableDescription, dataSpace_setExecutableTitle, dataSpace_setExecutionContextDescription, dataSpace_setTitle, } from './studio/DSL_DataSpace_GraphModifierHelper.js';
|
|
17
|
+
const isBlank = (value) => !value?.trim();
|
|
18
|
+
/**
|
|
19
|
+
* Executables are matched by id; those declared without one are paired, in
|
|
20
|
+
* order, with the remaining suggestions, as LegendAI lists them in grammar
|
|
21
|
+
* order.
|
|
22
|
+
*/
|
|
23
|
+
const matchExecutables = (executables, metas) => {
|
|
24
|
+
const matches = new Map();
|
|
25
|
+
const unmatchedMetaIndexes = [];
|
|
26
|
+
metas.forEach((meta, metaIdx) => {
|
|
27
|
+
const execIdx = meta.id === undefined || meta.id === null
|
|
28
|
+
? -1
|
|
29
|
+
: executables.findIndex((executable, idx) => executable.id !== undefined &&
|
|
30
|
+
executable.id === String(meta.id) &&
|
|
31
|
+
!matches.has(idx));
|
|
32
|
+
if (execIdx === -1) {
|
|
33
|
+
unmatchedMetaIndexes.push(metaIdx);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
matches.set(execIdx, meta);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const idlessExecIndexes = executables
|
|
40
|
+
.map((executable, idx) => (executable.id === undefined ? idx : -1))
|
|
41
|
+
.filter((idx) => idx !== -1 && !matches.has(idx));
|
|
42
|
+
unmatchedMetaIndexes
|
|
43
|
+
.slice(0, idlessExecIndexes.length)
|
|
44
|
+
.forEach((metaIdx, i) => matches.set(idlessExecIndexes[i], metas[metaIdx]));
|
|
45
|
+
return matches;
|
|
46
|
+
};
|
|
47
|
+
export const buildDataSpaceAISuggestionRows = (dataSpace, suggestion) => {
|
|
48
|
+
const rows = [];
|
|
49
|
+
rows.push({
|
|
50
|
+
key: 'dataSpace.title',
|
|
51
|
+
groupKey: 'dataSpace',
|
|
52
|
+
groupLabel: 'Data Space',
|
|
53
|
+
fieldLabel: 'Title',
|
|
54
|
+
suggestedValue: suggestion.title,
|
|
55
|
+
read: (ds) => ds.title,
|
|
56
|
+
write: (ds, value) => dataSpace_setTitle(ds, value),
|
|
57
|
+
}, {
|
|
58
|
+
key: 'dataSpace.description',
|
|
59
|
+
groupKey: 'dataSpace',
|
|
60
|
+
groupLabel: 'Data Space',
|
|
61
|
+
fieldLabel: 'Description',
|
|
62
|
+
suggestedValue: suggestion.description,
|
|
63
|
+
read: (ds) => ds.description,
|
|
64
|
+
write: (ds, value) => dataSpace_setDescription(ds, value),
|
|
65
|
+
});
|
|
66
|
+
suggestion.executionContexts?.forEach((meta) => {
|
|
67
|
+
const find = (ds) => ds.executionContexts?.find((ec) => ec.name === meta.name);
|
|
68
|
+
if (!find(dataSpace)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const groupKey = `executionContext:${meta.name}`;
|
|
72
|
+
rows.push({
|
|
73
|
+
key: `${groupKey}.description`,
|
|
74
|
+
groupKey,
|
|
75
|
+
groupLabel: `Execution Context · ${meta.name}`,
|
|
76
|
+
fieldLabel: 'Description',
|
|
77
|
+
suggestedValue: meta.description,
|
|
78
|
+
read: (ds) => find(ds)?.description,
|
|
79
|
+
write: (ds, value) => {
|
|
80
|
+
const executionContext = find(ds);
|
|
81
|
+
if (executionContext) {
|
|
82
|
+
dataSpace_setExecutionContextDescription(executionContext, value);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
suggestion.diagrams?.forEach((meta) => {
|
|
88
|
+
const find = (ds) => ds.diagrams?.find((d) => d.diagram.value.path === meta.diagram);
|
|
89
|
+
const diagram = find(dataSpace);
|
|
90
|
+
if (!diagram) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const groupKey = `diagram:${meta.diagram}`;
|
|
94
|
+
const groupLabel = `Diagram · ${diagram.title || meta.diagram}`;
|
|
95
|
+
rows.push({
|
|
96
|
+
key: `${groupKey}.title`,
|
|
97
|
+
groupKey,
|
|
98
|
+
groupLabel,
|
|
99
|
+
fieldLabel: 'Title',
|
|
100
|
+
suggestedValue: meta.title,
|
|
101
|
+
read: (ds) => find(ds)?.title,
|
|
102
|
+
write: (ds, value) => {
|
|
103
|
+
const target = find(ds);
|
|
104
|
+
if (target) {
|
|
105
|
+
dataSpace_setDiagramTitle(target, value);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
}, {
|
|
109
|
+
key: `${groupKey}.description`,
|
|
110
|
+
groupKey,
|
|
111
|
+
groupLabel,
|
|
112
|
+
fieldLabel: 'Description',
|
|
113
|
+
suggestedValue: meta.description,
|
|
114
|
+
read: (ds) => find(ds)?.description,
|
|
115
|
+
write: (ds, value) => {
|
|
116
|
+
const target = find(ds);
|
|
117
|
+
if (target) {
|
|
118
|
+
dataSpace_setDiagramDescription(target, value);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
const executables = dataSpace.executables ?? [];
|
|
124
|
+
const executableMatches = matchExecutables(executables, suggestion.executables ?? []);
|
|
125
|
+
Array.from(executableMatches.entries())
|
|
126
|
+
.sort(([a], [b]) => a - b)
|
|
127
|
+
.forEach(([idx, meta]) => {
|
|
128
|
+
const executable = executables[idx];
|
|
129
|
+
const find = (ds) => ds.executables?.[idx];
|
|
130
|
+
const groupKey = `executable:${idx}`;
|
|
131
|
+
const groupLabel = `Executable · ${executable.title || (executable.id ?? idx + 1)}`;
|
|
132
|
+
rows.push({
|
|
133
|
+
key: `${groupKey}.title`,
|
|
134
|
+
groupKey,
|
|
135
|
+
groupLabel,
|
|
136
|
+
fieldLabel: 'Title',
|
|
137
|
+
suggestedValue: meta.title,
|
|
138
|
+
read: (ds) => find(ds)?.title,
|
|
139
|
+
write: (ds, value) => {
|
|
140
|
+
const target = find(ds);
|
|
141
|
+
if (target) {
|
|
142
|
+
dataSpace_setExecutableTitle(target, value);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
}, {
|
|
146
|
+
key: `${groupKey}.description`,
|
|
147
|
+
groupKey,
|
|
148
|
+
groupLabel,
|
|
149
|
+
fieldLabel: 'Description',
|
|
150
|
+
suggestedValue: meta.description,
|
|
151
|
+
read: (ds) => find(ds)?.description,
|
|
152
|
+
write: (ds, value) => {
|
|
153
|
+
const target = find(ds);
|
|
154
|
+
if (target) {
|
|
155
|
+
dataSpace_setExecutableDescription(target, value);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
return rows
|
|
161
|
+
.map((row) => ({ ...row, currentValue: row.read(dataSpace) }))
|
|
162
|
+
.filter((row) => !isBlank(row.suggestedValue) &&
|
|
163
|
+
row.suggestedValue.trim() !== (row.currentValue ?? '').trim());
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Rows whose current value is empty are pre-selected; when the user asked to
|
|
167
|
+
* regenerate everything, all rows are.
|
|
168
|
+
*/
|
|
169
|
+
export const isDataSpaceAISuggestionRowSelectedByDefault = (row, overwrite) => overwrite || isBlank(row.currentValue);
|
|
170
|
+
/**
|
|
171
|
+
* Flattens the fields a suggestion wrote so the applied value can be compared
|
|
172
|
+
* with what is eventually pushed.
|
|
173
|
+
*/
|
|
174
|
+
export const serializeDataSpaceAISuggestionFields = (dataSpace, rows) => rows.map((row) => row.read(dataSpace) ?? '').join('\n');
|
|
175
|
+
//# sourceMappingURL=DataSpaceAISuggestion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataSpaceAISuggestion.js","sourceRoot":"","sources":["../../src/stores/DataSpaceAISuggestion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EACL,wBA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AE,WAAW;YACnC,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;gBACnB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;gBACxB,IAAI,MAAM,EAAE,CAAC;oBACX,kCAAkC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;SACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;SAC7D,MAAM,CACL,CAAC,GAAG,EAAE,EAAE,CACN,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC5B,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAChE,CAAC;AACN,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG,CACzD,GAA6B,EAC7B,SAAkB,EACT,EAAE,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAClD,SAAoB,EACpB,IAAgC,EACxB,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos/legend-extension-dsl-data-space-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Legend extension for Data Space DSL - Studio",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"legend",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"test:watch": "jest --watch"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@finos/legend-application": "16.0
|
|
46
|
-
"@finos/legend-application-studio": "28.
|
|
47
|
-
"@finos/legend-art": "7.1.
|
|
48
|
-
"@finos/legend-code-editor": "2.0.
|
|
49
|
-
"@finos/legend-extension-dsl-data-space": "10.4.
|
|
50
|
-
"@finos/legend-graph": "32.
|
|
51
|
-
"@finos/legend-query-builder": "4.19.
|
|
52
|
-
"@finos/legend-server-depot": "6.1.
|
|
53
|
-
"@finos/legend-server-sdlc": "5.5.
|
|
54
|
-
"@finos/legend-shared": "11.0.
|
|
45
|
+
"@finos/legend-application": "16.1.0",
|
|
46
|
+
"@finos/legend-application-studio": "28.22.0",
|
|
47
|
+
"@finos/legend-art": "7.1.171",
|
|
48
|
+
"@finos/legend-code-editor": "2.0.214",
|
|
49
|
+
"@finos/legend-extension-dsl-data-space": "10.4.268",
|
|
50
|
+
"@finos/legend-graph": "32.9.1",
|
|
51
|
+
"@finos/legend-query-builder": "4.19.23",
|
|
52
|
+
"@finos/legend-server-depot": "6.1.25",
|
|
53
|
+
"@finos/legend-server-sdlc": "5.5.3",
|
|
54
|
+
"@finos/legend-shared": "11.0.33",
|
|
55
55
|
"@types/react": "19.0.10",
|
|
56
56
|
"mobx": "6.13.6",
|
|
57
57
|
"mobx-react-lite": "4.1.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-dnd": "16.0.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@finos/legend-dev-utils": "2.2.
|
|
62
|
+
"@finos/legend-dev-utils": "2.2.12",
|
|
63
63
|
"@jest/globals": "29.7.0",
|
|
64
64
|
"cross-env": "7.0.3",
|
|
65
65
|
"eslint": "9.22.0",
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026-present, Goldman Sachs
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
CheckSquareIcon,
|
|
19
|
+
clsx,
|
|
20
|
+
Dialog,
|
|
21
|
+
EmptySquareIcon,
|
|
22
|
+
MinusSquareIcon,
|
|
23
|
+
Modal,
|
|
24
|
+
ModalBody,
|
|
25
|
+
ModalFooter,
|
|
26
|
+
ModalFooterButton,
|
|
27
|
+
ModalFooterStatus,
|
|
28
|
+
ModalHeader,
|
|
29
|
+
ModalTitle,
|
|
30
|
+
PanelLoadingIndicator,
|
|
31
|
+
SparkleIcon,
|
|
32
|
+
} from '@finos/legend-art';
|
|
33
|
+
import { useApplicationStore } from '@finos/legend-application';
|
|
34
|
+
import { observer } from 'mobx-react-lite';
|
|
35
|
+
import { useState } from 'react';
|
|
36
|
+
import {
|
|
37
|
+
isDataSpaceAISuggestionRowSelectedByDefault,
|
|
38
|
+
type DataSpaceAISuggestionRow,
|
|
39
|
+
} from '../../stores/DataSpaceAISuggestion.js';
|
|
40
|
+
|
|
41
|
+
export type DataSpaceAISuggestionSelection = {
|
|
42
|
+
row: DataSpaceAISuggestionRow;
|
|
43
|
+
value: string;
|
|
44
|
+
}[];
|
|
45
|
+
|
|
46
|
+
type CheckboxState = 'all' | 'some' | 'none';
|
|
47
|
+
|
|
48
|
+
const getCheckboxState = (
|
|
49
|
+
selectedCount: number,
|
|
50
|
+
totalCount: number,
|
|
51
|
+
): CheckboxState =>
|
|
52
|
+
totalCount > 0 && selectedCount === totalCount
|
|
53
|
+
? 'all'
|
|
54
|
+
: selectedCount
|
|
55
|
+
? 'some'
|
|
56
|
+
: 'none';
|
|
57
|
+
|
|
58
|
+
const DataSpaceAISuggestionCheckbox = observer(
|
|
59
|
+
(props: { state: CheckboxState; onToggle: () => void; title: string }) => {
|
|
60
|
+
const { state, onToggle, title } = props;
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<button
|
|
64
|
+
className={clsx('dataSpace-editor__ai-review__checkbox', {
|
|
65
|
+
'dataSpace-editor__ai-review__checkbox--checked': state !== 'none',
|
|
66
|
+
})}
|
|
67
|
+
onClick={onToggle}
|
|
68
|
+
title={title}
|
|
69
|
+
type="button"
|
|
70
|
+
>
|
|
71
|
+
{state === 'all' ? (
|
|
72
|
+
<CheckSquareIcon />
|
|
73
|
+
) : state === 'some' ? (
|
|
74
|
+
<MinusSquareIcon />
|
|
75
|
+
) : (
|
|
76
|
+
<EmptySquareIcon />
|
|
77
|
+
)}
|
|
78
|
+
</button>
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const DataSpaceAISuggestionRowEditor = observer(
|
|
84
|
+
(props: {
|
|
85
|
+
row: DataSpaceAISuggestionRow;
|
|
86
|
+
value: string;
|
|
87
|
+
isSelected: boolean;
|
|
88
|
+
setSelected: (selected: boolean) => void;
|
|
89
|
+
setValue: (value: string) => void;
|
|
90
|
+
}) => {
|
|
91
|
+
const { row, value, isSelected, setSelected, setValue } = props;
|
|
92
|
+
const hasCurrentValue = Boolean(row.currentValue?.trim());
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
className={clsx('dataSpace-editor__ai-review__row', {
|
|
97
|
+
'dataSpace-editor__ai-review__row--selected': isSelected,
|
|
98
|
+
})}
|
|
99
|
+
>
|
|
100
|
+
<div className="dataSpace-editor__ai-review__row__header">
|
|
101
|
+
<DataSpaceAISuggestionCheckbox
|
|
102
|
+
state={isSelected ? 'all' : 'none'}
|
|
103
|
+
onToggle={(): void => setSelected(!isSelected)}
|
|
104
|
+
title={
|
|
105
|
+
isSelected ? 'Keep the current value' : 'Use the suggested value'
|
|
106
|
+
}
|
|
107
|
+
/>
|
|
108
|
+
<span className="dataSpace-editor__ai-review__row__label">
|
|
109
|
+
{row.fieldLabel}
|
|
110
|
+
</span>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="dataSpace-editor__ai-review__row__compare">
|
|
113
|
+
<div className="dataSpace-editor__ai-review__row__side">
|
|
114
|
+
<div className="dataSpace-editor__ai-review__row__side__label">
|
|
115
|
+
Current
|
|
116
|
+
</div>
|
|
117
|
+
<div
|
|
118
|
+
className={clsx('dataSpace-editor__ai-review__row__current', {
|
|
119
|
+
'dataSpace-editor__ai-review__row__current--empty':
|
|
120
|
+
!hasCurrentValue,
|
|
121
|
+
'dataSpace-editor__ai-review__row__current--replaced':
|
|
122
|
+
isSelected && hasCurrentValue,
|
|
123
|
+
})}
|
|
124
|
+
>
|
|
125
|
+
{hasCurrentValue ? row.currentValue : '(empty)'}
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
<div className="dataSpace-editor__ai-review__row__side">
|
|
129
|
+
<div className="dataSpace-editor__ai-review__row__side__label">
|
|
130
|
+
<SparkleIcon />
|
|
131
|
+
Suggested
|
|
132
|
+
</div>
|
|
133
|
+
<textarea
|
|
134
|
+
className="dataSpace-editor__ai-review__row__suggested"
|
|
135
|
+
spellCheck={false}
|
|
136
|
+
rows={row.fieldLabel === 'Title' ? 1 : 3}
|
|
137
|
+
value={value}
|
|
138
|
+
onChange={(event): void => setValue(event.target.value)}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Lays the suggested titles and descriptions next to the current ones so the
|
|
149
|
+
* user can pick (and tweak) which to fill into the form.
|
|
150
|
+
*/
|
|
151
|
+
export const DataSpaceAISuggestionReviewModal = observer(
|
|
152
|
+
(props: {
|
|
153
|
+
rows: DataSpaceAISuggestionRow[];
|
|
154
|
+
overwrite: boolean;
|
|
155
|
+
isRegenerating: boolean;
|
|
156
|
+
onApply: (selection: DataSpaceAISuggestionSelection) => void;
|
|
157
|
+
onDismiss: () => void;
|
|
158
|
+
onRegenerate: () => void;
|
|
159
|
+
}) => {
|
|
160
|
+
const {
|
|
161
|
+
rows,
|
|
162
|
+
overwrite,
|
|
163
|
+
isRegenerating,
|
|
164
|
+
onApply,
|
|
165
|
+
onDismiss,
|
|
166
|
+
onRegenerate,
|
|
167
|
+
} = props;
|
|
168
|
+
const applicationStore = useApplicationStore();
|
|
169
|
+
const darkMode =
|
|
170
|
+
!applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled;
|
|
171
|
+
const [selectedKeys, setSelectedKeys] = useState(
|
|
172
|
+
() =>
|
|
173
|
+
new Set(
|
|
174
|
+
rows
|
|
175
|
+
.filter((row) =>
|
|
176
|
+
isDataSpaceAISuggestionRowSelectedByDefault(row, overwrite),
|
|
177
|
+
)
|
|
178
|
+
.map((row) => row.key),
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
const [editedValues, setEditedValues] = useState<Map<string, string>>(
|
|
182
|
+
() => new Map(),
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
const valueOf = (row: DataSpaceAISuggestionRow): string =>
|
|
186
|
+
editedValues.get(row.key) ?? row.suggestedValue;
|
|
187
|
+
const setSelected = (keys: string[], selected: boolean): void => {
|
|
188
|
+
setSelectedKeys((prev) => {
|
|
189
|
+
const next = new Set(prev);
|
|
190
|
+
keys.forEach((key) => (selected ? next.add(key) : next.delete(key)));
|
|
191
|
+
return next;
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const selectedCount = rows.filter((row) =>
|
|
195
|
+
selectedKeys.has(row.key),
|
|
196
|
+
).length;
|
|
197
|
+
const allSelected = rows.length > 0 && selectedCount === rows.length;
|
|
198
|
+
|
|
199
|
+
const groups = rows.reduce((acc, row) => {
|
|
200
|
+
const group = acc.get(row.groupKey);
|
|
201
|
+
if (group) {
|
|
202
|
+
group.rows.push(row);
|
|
203
|
+
} else {
|
|
204
|
+
acc.set(row.groupKey, { label: row.groupLabel, rows: [row] });
|
|
205
|
+
}
|
|
206
|
+
return acc;
|
|
207
|
+
}, new Map<string, { label: string; rows: DataSpaceAISuggestionRow[] }>());
|
|
208
|
+
|
|
209
|
+
const apply = (): void =>
|
|
210
|
+
onApply(
|
|
211
|
+
rows
|
|
212
|
+
.filter((row) => selectedKeys.has(row.key))
|
|
213
|
+
.map((row) => ({ row, value: valueOf(row) })),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<Dialog
|
|
218
|
+
open={true}
|
|
219
|
+
onClose={onDismiss}
|
|
220
|
+
classes={{ container: 'search-modal__container' }}
|
|
221
|
+
slotProps={{
|
|
222
|
+
paper: { classes: { root: 'search-modal__inner-container' } },
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
<Modal darkMode={darkMode} className="dataSpace-editor__ai-review">
|
|
226
|
+
<ModalHeader>
|
|
227
|
+
<ModalTitle icon={<SparkleIcon />} title="Review AI Suggestions" />
|
|
228
|
+
</ModalHeader>
|
|
229
|
+
<PanelLoadingIndicator isLoading={isRegenerating} />
|
|
230
|
+
<ModalBody className="dataSpace-editor__ai-review__body">
|
|
231
|
+
{rows.length === 0 ? (
|
|
232
|
+
<div className="dataSpace-editor__ai-review__empty">
|
|
233
|
+
{overwrite
|
|
234
|
+
? 'LegendAI did not suggest any changes for this data space.'
|
|
235
|
+
: 'LegendAI kept all existing titles and descriptions, so there is nothing new to fill in. Use Regenerate All to get fresh suggestions for every field.'}
|
|
236
|
+
</div>
|
|
237
|
+
) : (
|
|
238
|
+
<>
|
|
239
|
+
<div className="dataSpace-editor__ai-review__toolbar">
|
|
240
|
+
<DataSpaceAISuggestionCheckbox
|
|
241
|
+
state={getCheckboxState(selectedCount, rows.length)}
|
|
242
|
+
onToggle={(): void =>
|
|
243
|
+
setSelected(
|
|
244
|
+
rows.map((row) => row.key),
|
|
245
|
+
!allSelected,
|
|
246
|
+
)
|
|
247
|
+
}
|
|
248
|
+
title={allSelected ? 'Deselect all' : 'Select all'}
|
|
249
|
+
/>
|
|
250
|
+
<span>
|
|
251
|
+
{selectedCount} of {rows.length} suggestion
|
|
252
|
+
{rows.length === 1 ? '' : 's'} selected
|
|
253
|
+
</span>
|
|
254
|
+
</div>
|
|
255
|
+
{Array.from(groups.entries()).map(([groupKey, group]) => {
|
|
256
|
+
const groupKeys = group.rows.map((row) => row.key);
|
|
257
|
+
const groupSelectedCount = groupKeys.filter((key) =>
|
|
258
|
+
selectedKeys.has(key),
|
|
259
|
+
).length;
|
|
260
|
+
const groupAllSelected =
|
|
261
|
+
groupSelectedCount === groupKeys.length;
|
|
262
|
+
return (
|
|
263
|
+
<div
|
|
264
|
+
key={groupKey}
|
|
265
|
+
className="dataSpace-editor__ai-review__group"
|
|
266
|
+
>
|
|
267
|
+
<div className="dataSpace-editor__ai-review__group__header">
|
|
268
|
+
<DataSpaceAISuggestionCheckbox
|
|
269
|
+
state={getCheckboxState(
|
|
270
|
+
groupSelectedCount,
|
|
271
|
+
groupKeys.length,
|
|
272
|
+
)}
|
|
273
|
+
onToggle={(): void =>
|
|
274
|
+
setSelected(groupKeys, !groupAllSelected)
|
|
275
|
+
}
|
|
276
|
+
title={
|
|
277
|
+
groupAllSelected ? 'Deselect group' : 'Select group'
|
|
278
|
+
}
|
|
279
|
+
/>
|
|
280
|
+
<span className="dataSpace-editor__ai-review__group__label">
|
|
281
|
+
{group.label}
|
|
282
|
+
</span>
|
|
283
|
+
</div>
|
|
284
|
+
{group.rows.map((row) => (
|
|
285
|
+
<DataSpaceAISuggestionRowEditor
|
|
286
|
+
key={row.key}
|
|
287
|
+
row={row}
|
|
288
|
+
value={valueOf(row)}
|
|
289
|
+
isSelected={selectedKeys.has(row.key)}
|
|
290
|
+
setSelected={(selected): void =>
|
|
291
|
+
setSelected([row.key], selected)
|
|
292
|
+
}
|
|
293
|
+
setValue={(value): void => {
|
|
294
|
+
setEditedValues((prev) =>
|
|
295
|
+
new Map(prev).set(row.key, value),
|
|
296
|
+
);
|
|
297
|
+
setSelected([row.key], true);
|
|
298
|
+
}}
|
|
299
|
+
/>
|
|
300
|
+
))}
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
})}
|
|
304
|
+
</>
|
|
305
|
+
)}
|
|
306
|
+
</ModalBody>
|
|
307
|
+
<ModalFooter>
|
|
308
|
+
<ModalFooterStatus className="dataSpace-editor__ai-review__footer-status">
|
|
309
|
+
Applied values are filled into the form and can still be edited.
|
|
310
|
+
</ModalFooterStatus>
|
|
311
|
+
<ModalFooterButton
|
|
312
|
+
darkMode={darkMode}
|
|
313
|
+
type="secondary"
|
|
314
|
+
text="Regenerate All"
|
|
315
|
+
title="Ask LegendAI for fresh suggestions for every field, including ones that already have a value"
|
|
316
|
+
inProgressText={isRegenerating ? 'Regenerating...' : undefined}
|
|
317
|
+
onClick={onRegenerate}
|
|
318
|
+
formatText={false}
|
|
319
|
+
/>
|
|
320
|
+
<ModalFooterButton
|
|
321
|
+
darkMode={darkMode}
|
|
322
|
+
type="secondary"
|
|
323
|
+
text="Dismiss"
|
|
324
|
+
onClick={onDismiss}
|
|
325
|
+
formatText={false}
|
|
326
|
+
/>
|
|
327
|
+
<ModalFooterButton
|
|
328
|
+
darkMode={darkMode}
|
|
329
|
+
text={`Apply ${selectedCount} Selected`}
|
|
330
|
+
disabled={selectedCount === 0 || isRegenerating}
|
|
331
|
+
onClick={apply}
|
|
332
|
+
formatText={false}
|
|
333
|
+
/>
|
|
334
|
+
</ModalFooter>
|
|
335
|
+
</Modal>
|
|
336
|
+
</Dialog>
|
|
337
|
+
);
|
|
338
|
+
},
|
|
339
|
+
);
|