@backstage/plugin-scaffolder 1.15.1 → 1.16.0-next.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/CHANGELOG.md +32 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +36 -10
- package/dist/alpha.esm.js +87 -11
- package/dist/alpha.esm.js.map +1 -1
- package/dist/esm/{ListTasksPage-b7beed35.esm.js → DryRunResults-a4d44358.esm.js} +1132 -829
- package/dist/esm/DryRunResults-a4d44358.esm.js.map +1 -0
- package/dist/esm/{plugin-76d8b756.esm.js → OngoingTask-8acb140b.esm.js} +292 -11
- package/dist/esm/OngoingTask-8acb140b.esm.js.map +1 -0
- package/dist/esm/{Router-f5f81642.esm.js → Router-b60d8000.esm.js} +172 -168
- package/dist/esm/Router-b60d8000.esm.js.map +1 -0
- package/dist/esm/{index-e1da2925.esm.js → index-52e5acc5.esm.js} +79 -279
- package/dist/esm/index-52e5acc5.esm.js.map +1 -0
- package/dist/index.d.ts +17 -14
- package/dist/index.esm.js +9 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/types/{plugin.d-2d1240f7.d.ts → plugin.d-63255bd3.d.ts} +43 -76
- package/package.json +19 -20
- package/dist/esm/ListTasksPage-b7beed35.esm.js.map +0 -1
- package/dist/esm/Router-f5f81642.esm.js.map +0 -1
- package/dist/esm/TaskPage-d1a669e0.esm.js +0 -322
- package/dist/esm/TaskPage-d1a669e0.esm.js.map +0 -1
- package/dist/esm/TemplateTypePicker-efec8c34.esm.js +0 -66
- package/dist/esm/TemplateTypePicker-efec8c34.esm.js.map +0 -1
- package/dist/esm/index-e1da2925.esm.js.map +0 -1
- package/dist/esm/plugin-76d8b756.esm.js.map +0 -1
|
@@ -9,8 +9,7 @@ import { makeStyles, useTheme, Card, CardMedia, CardContent, Box, Typography, Ch
|
|
|
9
9
|
import { scmIntegrationsApiRef, ScmIntegrationIcon } from '@backstage/integration-react';
|
|
10
10
|
import LanguageIcon from '@material-ui/icons/Language';
|
|
11
11
|
import WarningIcon from '@material-ui/icons/Warning';
|
|
12
|
-
import {
|
|
13
|
-
import { T as TemplateTypePicker } from './TemplateTypePicker-efec8c34.esm.js';
|
|
12
|
+
import { o as selectedTemplateRouteRef, v as viewTechDocRouteRef, p as editRouteRef, q as actionsRouteRef, t as scaffolderListTaskRouteRef, u as registerComponentRouteRef, T as TemplateTypePicker, w as scaffolderTaskRouteRef, r as rootRouteRef, x as legacySelectedTemplateRouteRef } from './OngoingTask-8acb140b.esm.js';
|
|
14
13
|
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
|
|
15
14
|
import { usePermission } from '@backstage/plugin-permission-react';
|
|
16
15
|
import IconButton$1 from '@material-ui/core/IconButton';
|
|
@@ -24,21 +23,22 @@ import Description from '@material-ui/icons/Description';
|
|
|
24
23
|
import Edit from '@material-ui/icons/Edit';
|
|
25
24
|
import List from '@material-ui/icons/List';
|
|
26
25
|
import MoreVert from '@material-ui/icons/MoreVert';
|
|
26
|
+
import 'zod-to-json-schema';
|
|
27
27
|
import qs from 'qs';
|
|
28
28
|
import useAsync from 'react-use/lib/useAsync';
|
|
29
29
|
import { useTemplateSecrets, scaffolderApiRef, useCustomFieldExtensions, useCustomLayouts, SecretsContextProvider } from '@backstage/plugin-scaffolder-react';
|
|
30
30
|
import { withTheme } from '@rjsf/core';
|
|
31
31
|
import { Theme } from '@rjsf/material-ui';
|
|
32
32
|
import cloneDeep from 'lodash/cloneDeep';
|
|
33
|
-
import
|
|
34
|
-
import {
|
|
35
|
-
import { u as useDryRun, a as useDirectoryEditor, D as DirectoryEditorProvider, b as DryRunProvider, T as TemplateEditorBrowser, c as TemplateEditorTextArea, d as DryRunResults, e as TemplateEditorIntro, W as WebFileSystemAccess, f as DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS, L as ListTasksPage, A as ActionsPage } from './
|
|
33
|
+
import validator from '@rjsf/validator-ajv8';
|
|
34
|
+
import { extractSchemaFromStep, Form as Form$1 } from '@backstage/plugin-scaffolder-react/alpha';
|
|
35
|
+
import { u as useDryRun, a as useDirectoryEditor, D as DirectoryEditorProvider, b as DryRunProvider, T as TemplateEditorBrowser, c as TemplateEditorTextArea, d as DryRunResults, e as TemplateEditorIntro, W as WebFileSystemAccess, f as DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS, L as ListTasksPage, A as ActionsPage, g as TaskPage } from './DryRunResults-a4d44358.esm.js';
|
|
36
|
+
import useDebounce from 'react-use/lib/useDebounce';
|
|
37
|
+
import yaml from 'yaml';
|
|
38
|
+
import CloseIcon from '@material-ui/icons/Close';
|
|
36
39
|
import { StreamLanguage } from '@codemirror/language';
|
|
37
40
|
import { yaml as yaml$1 } from '@codemirror/legacy-modes/mode/yaml';
|
|
38
|
-
import CloseIcon from '@material-ui/icons/Close';
|
|
39
41
|
import CodeMirror from '@uiw/react-codemirror';
|
|
40
|
-
import yaml from 'yaml';
|
|
41
|
-
import useDebounce from 'react-use/lib/useDebounce';
|
|
42
42
|
import '@backstage/errors';
|
|
43
43
|
import 'zen-observable';
|
|
44
44
|
import 'event-source-polyfill';
|
|
@@ -46,7 +46,6 @@ import '@backstage/catalog-client';
|
|
|
46
46
|
import '@material-ui/core/FormControl';
|
|
47
47
|
import '@material-ui/lab/Autocomplete';
|
|
48
48
|
import 'zod';
|
|
49
|
-
import 'zod-to-json-schema';
|
|
50
49
|
import '@material-ui/core/FormHelperText';
|
|
51
50
|
import '@material-ui/core/Input';
|
|
52
51
|
import '@material-ui/core/InputLabel';
|
|
@@ -56,46 +55,49 @@ import 'lodash/capitalize';
|
|
|
56
55
|
import '@material-ui/icons/CheckBox';
|
|
57
56
|
import '@material-ui/icons/CheckBoxOutlineBlank';
|
|
58
57
|
import '@material-ui/icons/ExpandMore';
|
|
59
|
-
import '@
|
|
60
|
-
import '@material-ui/core/Step';
|
|
61
|
-
import '@material-ui/core/StepLabel';
|
|
62
|
-
import '@material-ui/core/Stepper';
|
|
63
|
-
import '@material-ui/core/Typography';
|
|
58
|
+
import '@react-hookz/web';
|
|
64
59
|
import '@material-ui/icons/Cancel';
|
|
65
|
-
import '@material-ui/icons/
|
|
66
|
-
import '@material-ui/icons/
|
|
60
|
+
import '@material-ui/icons/Repeat';
|
|
61
|
+
import '@material-ui/icons/Toc';
|
|
62
|
+
import '@material-ui/icons/ControlPoint';
|
|
67
63
|
import 'classnames';
|
|
68
|
-
import 'luxon';
|
|
69
|
-
import 'react-use/lib/useInterval';
|
|
70
64
|
import '@material-ui/icons/ExpandLess';
|
|
71
65
|
import '@material-ui/core/Chip';
|
|
66
|
+
import '@material-ui/icons/Settings';
|
|
67
|
+
import '@material-ui/icons/FontDownload';
|
|
68
|
+
import 'luxon';
|
|
69
|
+
import 'humanize-duration';
|
|
70
|
+
import '@material-ui/core/Typography';
|
|
72
71
|
import '@material-ui/core/Card';
|
|
73
72
|
import '@material-ui/core/CardActionArea';
|
|
74
73
|
import '@material-ui/core/CardContent';
|
|
75
74
|
import '@material-ui/core/Tooltip';
|
|
76
75
|
import '@material-ui/icons/InfoOutlined';
|
|
76
|
+
import '@material-ui/icons/Refresh';
|
|
77
|
+
import '@material-ui/icons/Save';
|
|
78
|
+
import '@codemirror/view';
|
|
77
79
|
import '@material-ui/core/Accordion';
|
|
78
80
|
import '@material-ui/core/AccordionDetails';
|
|
79
81
|
import '@material-ui/core/AccordionSummary';
|
|
80
82
|
import '@material-ui/core/Divider';
|
|
81
|
-
import '@react-hookz/web';
|
|
82
83
|
import '@material-ui/core/List';
|
|
83
84
|
import '@material-ui/core/ListItem';
|
|
84
85
|
import '@material-ui/core/ListItemSecondaryAction';
|
|
86
|
+
import '@material-ui/icons/Check';
|
|
85
87
|
import '@material-ui/icons/Delete';
|
|
86
88
|
import '@material-ui/icons/GetApp';
|
|
87
89
|
import '@material-ui/core/Box';
|
|
88
90
|
import '@material-ui/core/Tab';
|
|
89
91
|
import '@material-ui/core/Tabs';
|
|
90
|
-
import '@material-ui/icons/Refresh';
|
|
91
|
-
import '@material-ui/icons/Save';
|
|
92
92
|
import '@material-ui/lab/TreeView';
|
|
93
93
|
import '@material-ui/icons/ChevronRight';
|
|
94
94
|
import '@material-ui/lab/TreeItem';
|
|
95
|
-
import '@
|
|
96
|
-
import '@material-ui/
|
|
97
|
-
import '@material-ui/
|
|
98
|
-
import '
|
|
95
|
+
import '@material-ui/core/Grid';
|
|
96
|
+
import '@material-ui/core/Step';
|
|
97
|
+
import '@material-ui/core/StepLabel';
|
|
98
|
+
import '@material-ui/core/Stepper';
|
|
99
|
+
import '@material-ui/icons/FiberManualRecord';
|
|
100
|
+
import 'react-use/lib/useInterval';
|
|
99
101
|
|
|
100
102
|
const useStyles$5 = makeStyles((theme) => ({
|
|
101
103
|
cardHeader: {
|
|
@@ -605,7 +607,7 @@ const ReviewStep = (props) => {
|
|
|
605
607
|
)));
|
|
606
608
|
};
|
|
607
609
|
|
|
608
|
-
const Form
|
|
610
|
+
const Form = withTheme(Theme);
|
|
609
611
|
function getSchemasFromSteps(steps) {
|
|
610
612
|
return steps.map(({ schema }) => ({
|
|
611
613
|
mergedSchema: schema,
|
|
@@ -694,8 +696,9 @@ const MultistepJsonForm = (props) => {
|
|
|
694
696
|
},
|
|
695
697
|
/* @__PURE__ */ React.createElement(Typography, { variant: "h6", component: "h2" }, title)
|
|
696
698
|
), /* @__PURE__ */ React.createElement(StepContent, { key: title }, /* @__PURE__ */ React.createElement(
|
|
697
|
-
Form
|
|
699
|
+
Form,
|
|
698
700
|
{
|
|
701
|
+
validator,
|
|
699
702
|
showErrorList: false,
|
|
700
703
|
fields: { ...fieldOverrides, ...fields },
|
|
701
704
|
widgets,
|
|
@@ -1077,138 +1080,7 @@ function TemplateEditorFormDirectoryEditorDryRun(props) {
|
|
|
1077
1080
|
}
|
|
1078
1081
|
TemplateEditorForm.DirectoryEditorDryRun = TemplateEditorFormDirectoryEditorDryRun;
|
|
1079
1082
|
|
|
1080
|
-
const
|
|
1081
|
-
const useStyles$2 = makeStyles((theme) => ({
|
|
1082
|
-
root: {
|
|
1083
|
-
gridArea: "pageContent",
|
|
1084
|
-
display: "grid",
|
|
1085
|
-
gridTemplateAreas: `
|
|
1086
|
-
"controls controls"
|
|
1087
|
-
"fieldForm preview"
|
|
1088
|
-
`,
|
|
1089
|
-
gridTemplateRows: "auto 1fr",
|
|
1090
|
-
gridTemplateColumns: "1fr 1fr"
|
|
1091
|
-
},
|
|
1092
|
-
controls: {
|
|
1093
|
-
gridArea: "controls",
|
|
1094
|
-
display: "flex",
|
|
1095
|
-
flexFlow: "row nowrap",
|
|
1096
|
-
alignItems: "center",
|
|
1097
|
-
margin: theme.spacing(1)
|
|
1098
|
-
},
|
|
1099
|
-
fieldForm: {
|
|
1100
|
-
gridArea: "fieldForm"
|
|
1101
|
-
},
|
|
1102
|
-
preview: {
|
|
1103
|
-
gridArea: "preview"
|
|
1104
|
-
}
|
|
1105
|
-
}));
|
|
1106
|
-
const CustomFieldExplorer = ({
|
|
1107
|
-
customFieldExtensions = [],
|
|
1108
|
-
onClose
|
|
1109
|
-
}) => {
|
|
1110
|
-
var _a, _b;
|
|
1111
|
-
const classes = useStyles$2();
|
|
1112
|
-
const fieldOptions = customFieldExtensions.filter((field) => !!field.schema);
|
|
1113
|
-
const [selectedField, setSelectedField] = useState(fieldOptions[0]);
|
|
1114
|
-
const [fieldFormState, setFieldFormState] = useState({});
|
|
1115
|
-
const [formState, setFormState] = useState({});
|
|
1116
|
-
const [refreshKey, setRefreshKey] = useState(Date.now());
|
|
1117
|
-
const sampleFieldTemplate = useMemo(
|
|
1118
|
-
() => {
|
|
1119
|
-
var _a2, _b2;
|
|
1120
|
-
return yaml.stringify({
|
|
1121
|
-
parameters: [
|
|
1122
|
-
{
|
|
1123
|
-
title: `${selectedField.name} Example`,
|
|
1124
|
-
properties: {
|
|
1125
|
-
[selectedField.name]: {
|
|
1126
|
-
type: (_b2 = (_a2 = selectedField.schema) == null ? void 0 : _a2.returnValue) == null ? void 0 : _b2.type,
|
|
1127
|
-
"ui:field": selectedField.name,
|
|
1128
|
-
"ui:options": fieldFormState
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
]
|
|
1133
|
-
});
|
|
1134
|
-
},
|
|
1135
|
-
[fieldFormState, selectedField]
|
|
1136
|
-
);
|
|
1137
|
-
const fieldComponents = useMemo(() => {
|
|
1138
|
-
return Object.fromEntries(
|
|
1139
|
-
customFieldExtensions.map(({ name, component }) => [name, component])
|
|
1140
|
-
);
|
|
1141
|
-
}, [customFieldExtensions]);
|
|
1142
|
-
const handleSelectionChange = useCallback(
|
|
1143
|
-
(selection) => {
|
|
1144
|
-
setSelectedField(selection);
|
|
1145
|
-
setFieldFormState({});
|
|
1146
|
-
setFormState({});
|
|
1147
|
-
},
|
|
1148
|
-
[setFieldFormState, setFormState, setSelectedField]
|
|
1149
|
-
);
|
|
1150
|
-
const handleFieldConfigChange = useCallback(
|
|
1151
|
-
(state) => {
|
|
1152
|
-
setFieldFormState(state);
|
|
1153
|
-
setFormState({});
|
|
1154
|
-
setRefreshKey(Date.now());
|
|
1155
|
-
},
|
|
1156
|
-
[setFieldFormState, setRefreshKey]
|
|
1157
|
-
);
|
|
1158
|
-
return /* @__PURE__ */ React.createElement("main", { className: classes.root }, /* @__PURE__ */ React.createElement("div", { className: classes.controls }, /* @__PURE__ */ React.createElement(FormControl, { variant: "outlined", size: "small", fullWidth: true }, /* @__PURE__ */ React.createElement(InputLabel, { id: "select-field-label" }, "Choose Custom Field Extension"), /* @__PURE__ */ React.createElement(
|
|
1159
|
-
Select,
|
|
1160
|
-
{
|
|
1161
|
-
value: selectedField,
|
|
1162
|
-
label: "Choose Custom Field Extension",
|
|
1163
|
-
labelId: "select-field-label",
|
|
1164
|
-
onChange: (e) => handleSelectionChange(e.target.value)
|
|
1165
|
-
},
|
|
1166
|
-
fieldOptions.map((option, idx) => /* @__PURE__ */ React.createElement(MenuItem$1, { key: idx, value: option }, option.name))
|
|
1167
|
-
)), /* @__PURE__ */ React.createElement(IconButton, { size: "medium", onClick: onClose, "aria-label": "Close" }, /* @__PURE__ */ React.createElement(CloseIcon, null))), /* @__PURE__ */ React.createElement("div", { className: classes.fieldForm }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, { title: "Field Options" }), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(
|
|
1168
|
-
Form,
|
|
1169
|
-
{
|
|
1170
|
-
showErrorList: false,
|
|
1171
|
-
fields: { ...fieldOverrides, ...fieldComponents },
|
|
1172
|
-
noHtml5Validate: true,
|
|
1173
|
-
formData: fieldFormState,
|
|
1174
|
-
formContext: { fieldFormState },
|
|
1175
|
-
onSubmit: (e) => handleFieldConfigChange(e.formData),
|
|
1176
|
-
schema: ((_a = selectedField.schema) == null ? void 0 : _a.uiOptions) || {}
|
|
1177
|
-
},
|
|
1178
|
-
/* @__PURE__ */ React.createElement(
|
|
1179
|
-
Button,
|
|
1180
|
-
{
|
|
1181
|
-
variant: "contained",
|
|
1182
|
-
color: "primary",
|
|
1183
|
-
type: "submit",
|
|
1184
|
-
disabled: !((_b = selectedField.schema) == null ? void 0 : _b.uiOptions)
|
|
1185
|
-
},
|
|
1186
|
-
"Apply"
|
|
1187
|
-
)
|
|
1188
|
-
)))), /* @__PURE__ */ React.createElement("div", { className: classes.preview }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, { title: "Example Template Spec" }), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(
|
|
1189
|
-
CodeMirror,
|
|
1190
|
-
{
|
|
1191
|
-
readOnly: true,
|
|
1192
|
-
theme: "dark",
|
|
1193
|
-
height: "100%",
|
|
1194
|
-
extensions: [StreamLanguage.define(yaml$1)],
|
|
1195
|
-
value: sampleFieldTemplate
|
|
1196
|
-
}
|
|
1197
|
-
))), /* @__PURE__ */ React.createElement(
|
|
1198
|
-
TemplateEditorForm,
|
|
1199
|
-
{
|
|
1200
|
-
key: refreshKey,
|
|
1201
|
-
content: sampleFieldTemplate,
|
|
1202
|
-
contentIsSpec: true,
|
|
1203
|
-
fieldExtensions: customFieldExtensions,
|
|
1204
|
-
data: formState,
|
|
1205
|
-
onUpdate: setFormState,
|
|
1206
|
-
setErrorText: () => null
|
|
1207
|
-
}
|
|
1208
|
-
)));
|
|
1209
|
-
};
|
|
1210
|
-
|
|
1211
|
-
const useStyles$1 = makeStyles({
|
|
1083
|
+
const useStyles$2 = makeStyles({
|
|
1212
1084
|
// Reset and fix sizing to make sure scrolling behaves correctly
|
|
1213
1085
|
root: {
|
|
1214
1086
|
gridArea: "pageContent",
|
|
@@ -1237,7 +1109,7 @@ const useStyles$1 = makeStyles({
|
|
|
1237
1109
|
}
|
|
1238
1110
|
});
|
|
1239
1111
|
const TemplateEditor = (props) => {
|
|
1240
|
-
const classes = useStyles$
|
|
1112
|
+
const classes = useStyles$2();
|
|
1241
1113
|
const [errorText, setErrorText] = useState();
|
|
1242
1114
|
return /* @__PURE__ */ React.createElement(DirectoryEditorProvider, { directory: props.directory }, /* @__PURE__ */ React.createElement(DryRunProvider, null, /* @__PURE__ */ React.createElement("main", { className: classes.root }, /* @__PURE__ */ React.createElement("section", { className: classes.browser }, /* @__PURE__ */ React.createElement(TemplateEditorBrowser, { onClose: props.onClose })), /* @__PURE__ */ React.createElement("section", { className: classes.editor }, /* @__PURE__ */ React.createElement(TemplateEditorTextArea.DirectoryEditor, { errorText })), /* @__PURE__ */ React.createElement("section", { className: classes.preview }, /* @__PURE__ */ React.createElement(
|
|
1243
1115
|
TemplateEditorForm.DirectoryEditorDryRun,
|
|
@@ -1287,7 +1159,7 @@ steps:
|
|
|
1287
1159
|
values:
|
|
1288
1160
|
name: \${{parameters.name}}
|
|
1289
1161
|
`;
|
|
1290
|
-
const useStyles = makeStyles((theme) => ({
|
|
1162
|
+
const useStyles$1 = makeStyles((theme) => ({
|
|
1291
1163
|
root: {
|
|
1292
1164
|
gridArea: "pageContent",
|
|
1293
1165
|
display: "grid",
|
|
@@ -1318,7 +1190,7 @@ const TemplateFormPreviewer = ({
|
|
|
1318
1190
|
onClose,
|
|
1319
1191
|
layouts = []
|
|
1320
1192
|
}) => {
|
|
1321
|
-
const classes = useStyles();
|
|
1193
|
+
const classes = useStyles$1();
|
|
1322
1194
|
const alertApi = useApi(alertApiRef);
|
|
1323
1195
|
const catalogApi = useApi(catalogApiRef);
|
|
1324
1196
|
const [selectedTemplate, setSelectedTemplate] = useState("");
|
|
@@ -1373,7 +1245,7 @@ const TemplateFormPreviewer = ({
|
|
|
1373
1245
|
onChange: (e) => handleSelectChange(e.target.value)
|
|
1374
1246
|
},
|
|
1375
1247
|
templateOptions.map((option, idx) => /* @__PURE__ */ React.createElement(MenuItem$1, { key: idx, value: option.value }, option.label))
|
|
1376
|
-
)), /* @__PURE__ */ React.createElement(IconButton, { size: "medium", onClick: onClose
|
|
1248
|
+
)), /* @__PURE__ */ React.createElement(IconButton, { size: "medium", onClick: onClose }, /* @__PURE__ */ React.createElement(CloseIcon, null))), /* @__PURE__ */ React.createElement("div", { className: classes.textArea }, /* @__PURE__ */ React.createElement(
|
|
1377
1249
|
TemplateEditorTextArea,
|
|
1378
1250
|
{
|
|
1379
1251
|
content: templateYaml,
|
|
@@ -1383,17 +1255,149 @@ const TemplateFormPreviewer = ({
|
|
|
1383
1255
|
)), /* @__PURE__ */ React.createElement("div", { className: classes.preview }, /* @__PURE__ */ React.createElement(
|
|
1384
1256
|
TemplateEditorForm,
|
|
1385
1257
|
{
|
|
1258
|
+
data: formState,
|
|
1259
|
+
onUpdate: setFormState,
|
|
1386
1260
|
content: templateYaml,
|
|
1387
1261
|
contentIsSpec: true,
|
|
1388
1262
|
fieldExtensions: customFieldExtensions,
|
|
1389
|
-
data: formState,
|
|
1390
|
-
onUpdate: setFormState,
|
|
1391
1263
|
setErrorText,
|
|
1392
1264
|
layouts
|
|
1393
1265
|
}
|
|
1394
1266
|
))));
|
|
1395
1267
|
};
|
|
1396
1268
|
|
|
1269
|
+
const useStyles = makeStyles((theme) => ({
|
|
1270
|
+
root: {
|
|
1271
|
+
gridArea: "pageContent",
|
|
1272
|
+
display: "grid",
|
|
1273
|
+
gridTemplateAreas: `
|
|
1274
|
+
"controls controls"
|
|
1275
|
+
"fieldForm preview"
|
|
1276
|
+
`,
|
|
1277
|
+
gridTemplateRows: "auto 1fr",
|
|
1278
|
+
gridTemplateColumns: "1fr 1fr"
|
|
1279
|
+
},
|
|
1280
|
+
controls: {
|
|
1281
|
+
gridArea: "controls",
|
|
1282
|
+
display: "flex",
|
|
1283
|
+
flexFlow: "row nowrap",
|
|
1284
|
+
alignItems: "center",
|
|
1285
|
+
margin: theme.spacing(1)
|
|
1286
|
+
},
|
|
1287
|
+
fieldForm: {
|
|
1288
|
+
gridArea: "fieldForm"
|
|
1289
|
+
},
|
|
1290
|
+
preview: {
|
|
1291
|
+
gridArea: "preview"
|
|
1292
|
+
}
|
|
1293
|
+
}));
|
|
1294
|
+
const CustomFieldExplorer = ({
|
|
1295
|
+
customFieldExtensions = [],
|
|
1296
|
+
onClose
|
|
1297
|
+
}) => {
|
|
1298
|
+
var _a, _b;
|
|
1299
|
+
const classes = useStyles();
|
|
1300
|
+
const fieldOptions = customFieldExtensions.filter((field) => !!field.schema);
|
|
1301
|
+
const [selectedField, setSelectedField] = useState(fieldOptions[0]);
|
|
1302
|
+
const [fieldFormState, setFieldFormState] = useState({});
|
|
1303
|
+
const [refreshKey, setRefreshKey] = useState(Date.now());
|
|
1304
|
+
const [formState, setFormState] = useState({});
|
|
1305
|
+
const sampleFieldTemplate = useMemo(
|
|
1306
|
+
() => {
|
|
1307
|
+
var _a2, _b2;
|
|
1308
|
+
return yaml.stringify({
|
|
1309
|
+
parameters: [
|
|
1310
|
+
{
|
|
1311
|
+
title: `${selectedField.name} Example`,
|
|
1312
|
+
properties: {
|
|
1313
|
+
[selectedField.name]: {
|
|
1314
|
+
type: (_b2 = (_a2 = selectedField.schema) == null ? void 0 : _a2.returnValue) == null ? void 0 : _b2.type,
|
|
1315
|
+
"ui:field": selectedField.name,
|
|
1316
|
+
"ui:options": fieldFormState
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
]
|
|
1321
|
+
});
|
|
1322
|
+
},
|
|
1323
|
+
[fieldFormState, selectedField]
|
|
1324
|
+
);
|
|
1325
|
+
const fieldComponents = useMemo(() => {
|
|
1326
|
+
return Object.fromEntries(
|
|
1327
|
+
customFieldExtensions.map(({ name, component }) => [name, component])
|
|
1328
|
+
);
|
|
1329
|
+
}, [customFieldExtensions]);
|
|
1330
|
+
const handleSelectionChange = useCallback(
|
|
1331
|
+
(selection) => {
|
|
1332
|
+
setSelectedField(selection);
|
|
1333
|
+
setFieldFormState({});
|
|
1334
|
+
setFormState({});
|
|
1335
|
+
},
|
|
1336
|
+
[setFieldFormState, setSelectedField, setFormState]
|
|
1337
|
+
);
|
|
1338
|
+
const handleFieldConfigChange = useCallback(
|
|
1339
|
+
(state) => {
|
|
1340
|
+
setFieldFormState(state);
|
|
1341
|
+
setRefreshKey(Date.now());
|
|
1342
|
+
},
|
|
1343
|
+
[setFieldFormState, setRefreshKey]
|
|
1344
|
+
);
|
|
1345
|
+
return /* @__PURE__ */ React.createElement("main", { className: classes.root }, /* @__PURE__ */ React.createElement("div", { className: classes.controls }, /* @__PURE__ */ React.createElement(FormControl, { variant: "outlined", size: "small", fullWidth: true }, /* @__PURE__ */ React.createElement(InputLabel, { id: "select-field-label" }, "Choose Custom Field Extension"), /* @__PURE__ */ React.createElement(
|
|
1346
|
+
Select,
|
|
1347
|
+
{
|
|
1348
|
+
value: selectedField,
|
|
1349
|
+
label: "Choose Custom Field Extension",
|
|
1350
|
+
labelId: "select-field-label",
|
|
1351
|
+
onChange: (e) => handleSelectionChange(
|
|
1352
|
+
e.target.value
|
|
1353
|
+
)
|
|
1354
|
+
},
|
|
1355
|
+
fieldOptions.map((option, idx) => /* @__PURE__ */ React.createElement(MenuItem$1, { key: idx, value: option }, option.name))
|
|
1356
|
+
)), /* @__PURE__ */ React.createElement(IconButton, { size: "medium", onClick: onClose, "aria-label": "Close" }, /* @__PURE__ */ React.createElement(CloseIcon, null))), /* @__PURE__ */ React.createElement("div", { className: classes.fieldForm }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, { title: "Field Options" }), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(
|
|
1357
|
+
Form$1,
|
|
1358
|
+
{
|
|
1359
|
+
showErrorList: false,
|
|
1360
|
+
fields: { ...fieldComponents },
|
|
1361
|
+
noHtml5Validate: true,
|
|
1362
|
+
formData: fieldFormState,
|
|
1363
|
+
formContext: { fieldFormState },
|
|
1364
|
+
onSubmit: (e) => handleFieldConfigChange(e.formData),
|
|
1365
|
+
validator,
|
|
1366
|
+
schema: ((_a = selectedField.schema) == null ? void 0 : _a.uiOptions) || {}
|
|
1367
|
+
},
|
|
1368
|
+
/* @__PURE__ */ React.createElement(
|
|
1369
|
+
Button,
|
|
1370
|
+
{
|
|
1371
|
+
variant: "contained",
|
|
1372
|
+
color: "primary",
|
|
1373
|
+
type: "submit",
|
|
1374
|
+
disabled: !((_b = selectedField.schema) == null ? void 0 : _b.uiOptions)
|
|
1375
|
+
},
|
|
1376
|
+
"Apply"
|
|
1377
|
+
)
|
|
1378
|
+
)))), /* @__PURE__ */ React.createElement("div", { className: classes.preview }, /* @__PURE__ */ React.createElement(Card, null, /* @__PURE__ */ React.createElement(CardHeader, { title: "Example Template Spec" }), /* @__PURE__ */ React.createElement(CardContent, null, /* @__PURE__ */ React.createElement(
|
|
1379
|
+
CodeMirror,
|
|
1380
|
+
{
|
|
1381
|
+
readOnly: true,
|
|
1382
|
+
theme: "dark",
|
|
1383
|
+
height: "100%",
|
|
1384
|
+
extensions: [StreamLanguage.define(yaml$1)],
|
|
1385
|
+
value: sampleFieldTemplate
|
|
1386
|
+
}
|
|
1387
|
+
))), /* @__PURE__ */ React.createElement(
|
|
1388
|
+
TemplateEditorForm,
|
|
1389
|
+
{
|
|
1390
|
+
data: formState,
|
|
1391
|
+
onUpdate: setFormState,
|
|
1392
|
+
key: refreshKey,
|
|
1393
|
+
content: sampleFieldTemplate,
|
|
1394
|
+
contentIsSpec: true,
|
|
1395
|
+
fieldExtensions: customFieldExtensions,
|
|
1396
|
+
setErrorText: () => null
|
|
1397
|
+
}
|
|
1398
|
+
)));
|
|
1399
|
+
};
|
|
1400
|
+
|
|
1397
1401
|
function TemplateEditorPage(props) {
|
|
1398
1402
|
const [selection, setSelection] = useState();
|
|
1399
1403
|
let content = null;
|
|
@@ -1451,7 +1455,7 @@ function TemplateEditorPage(props) {
|
|
|
1451
1455
|
), content);
|
|
1452
1456
|
}
|
|
1453
1457
|
|
|
1454
|
-
const
|
|
1458
|
+
const LegacyRouter = (props) => {
|
|
1455
1459
|
const {
|
|
1456
1460
|
groups,
|
|
1457
1461
|
templateFilter,
|
|
@@ -1542,5 +1546,5 @@ const Router = (props) => {
|
|
|
1542
1546
|
), /* @__PURE__ */ React.createElement(Route, { path: "preview", element: /* @__PURE__ */ React.createElement(Navigate, { to: "../edit" }) }));
|
|
1543
1547
|
};
|
|
1544
1548
|
|
|
1545
|
-
export {
|
|
1546
|
-
//# sourceMappingURL=Router-
|
|
1549
|
+
export { LegacyRouter };
|
|
1550
|
+
//# sourceMappingURL=Router-b60d8000.esm.js.map
|