Skip to content

Commit 2725067

Browse files
committed
feat: support for extra field in registry type
1 parent 297abe0 commit 2725067

24 files changed

+181
-49
lines changed

react/data/schema.graphql

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ type Queries {
131131

132132
"""Added in 24.03.4."""
133133
vfolder_nodes(
134+
"""Added in 24.12.0."""
135+
scope_id: ScopeField
136+
134137
"""Added in 24.09.0."""
135-
project_id: UUID!
138+
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")
136139

137140
"""Added in 24.09.0."""
138141
permission: VFolderPermissionValueField
@@ -155,17 +158,23 @@ type Queries {
155158
compute_session_node(
156159
id: GlobalIDField!
157160

161+
"""Added in 24.12.0."""
162+
scope_id: ScopeField
163+
158164
"""Added in 24.09.0."""
159-
project_id: UUID!
165+
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")
160166

161167
"""Added in 24.09.0. Default is read_attribute."""
162168
permission: SessionPermissionValueField = "read_attribute"
163169
): ComputeSessionNode
164170

165171
"""Added in 24.09.0."""
166172
compute_session_nodes(
173+
"""Added in 24.12.0."""
174+
scope_id: ScopeField
175+
167176
"""Added in 24.09.0."""
168-
project_id: UUID!
177+
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")
169178

170179
"""Added in 24.09.0. Default is read_attribute."""
171180
permission: SessionPermissionValueField = "read_attribute"
@@ -411,7 +420,7 @@ type DomainNode implements Node {
411420
scaling_groups(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): ScalinGroupConnection
412421
}
413422

414-
"""Added in 24.12.0."""
423+
"""Added in 24.09.1."""
415424
scalar Bytes
416425

417426
"""Added in 24.12.0."""
@@ -1493,6 +1502,9 @@ type ContainerRegistryNode implements Node {
14931502

14941503
"""Added in 24.09.0."""
14951504
ssl_verify: Boolean
1505+
1506+
"""Added in 24.09.3."""
1507+
extra: JSONString
14961508
}
14971509

14981510
"""Added in 24.09.0."""
@@ -1710,6 +1722,9 @@ type Mutations {
17101722

17111723
"""Added in 24.09.0."""
17121724
create_container_registry_node(
1725+
"""Added in 24.09.3."""
1726+
extra: JSONString
1727+
17131728
"""Added in 24.09.0."""
17141729
is_global: Boolean
17151730

@@ -1739,6 +1754,9 @@ type Mutations {
17391754

17401755
"""Added in 24.09.0."""
17411756
modify_container_registry_node(
1757+
"""Added in 24.09.3."""
1758+
extra: JSONString
1759+
17421760
"""Object id. Can be either global id or object id. Added in 24.09.0."""
17431761
id: String!
17441762

react/src/components/BAICodeEditor.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';
44
import { EditorView } from '@uiw/react-codemirror';
55

66
interface BAICodeEditorProps extends Omit<ReactCodeMirrorProps, 'language'> {
7-
value: string;
8-
onChange: (value: string) => void;
7+
value?: string;
8+
onChange?: (value: string) => void;
99
language: LanguageName;
1010
editable?: boolean;
1111
showLineNumbers?: boolean;
@@ -39,9 +39,9 @@ const BAICodeEditor: React.FC<BAICodeEditorProps> = ({
3939
basicSetup={{
4040
lineNumbers: showLineNumbers,
4141
}}
42-
{...CodeMirrorProps}
4342
value={script}
4443
onChange={(value, viewUpdate) => setScript(value)}
44+
{...CodeMirrorProps}
4545
/>
4646
);
4747
};

react/src/components/ContainerRegistryEditorModal.tsx

Lines changed: 93 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1+
import { useThemeMode } from '../hooks/useThemeMode';
2+
import BAICodeEditor from './BAICodeEditor';
13
import BAIModal, { BAIModalProps } from './BAIModal';
4+
import Flex from './Flex';
25
import HiddenFormItem from './HiddenFormItem';
3-
import { ContainerRegistryEditorModalCreateMutation } from './__generated__/ContainerRegistryEditorModalCreateMutation.graphql';
6+
import {
7+
ContainerRegistryEditorModalCreateMutation,
8+
ContainerRegistryEditorModalCreateMutation$variables,
9+
} from './__generated__/ContainerRegistryEditorModalCreateMutation.graphql';
410
import { ContainerRegistryEditorModalFragment$key } from './__generated__/ContainerRegistryEditorModalFragment.graphql';
5-
import { ContainerRegistryEditorModalModifyMutation } from './__generated__/ContainerRegistryEditorModalModifyMutation.graphql';
6-
import { ContainerRegistryEditorModalModifyWithoutPasswordMutation } from './__generated__/ContainerRegistryEditorModalModifyWithoutPasswordMutation.graphql';
7-
import { Form, Input, Select, Checkbox, FormInstance, App } from 'antd';
11+
import {
12+
ContainerRegistryEditorModalModifyMutation,
13+
ContainerRegistryEditorModalModifyMutation$variables,
14+
} from './__generated__/ContainerRegistryEditorModalModifyMutation.graphql';
15+
import {
16+
ContainerRegistryEditorModalModifyWithoutPasswordMutation,
17+
ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables,
18+
} from './__generated__/ContainerRegistryEditorModalModifyWithoutPasswordMutation.graphql';
19+
import { Form, Input, Select, Checkbox, FormInstance, App, theme } from 'antd';
820
import graphql from 'babel-plugin-relay/macro';
921
import _ from 'lodash';
1022
import React, { useRef } from 'react';
@@ -20,6 +32,8 @@ const ContainerRegistryEditorModal: React.FC<
2032
ContainerRegistryEditorModalProps
2133
> = ({ containerRegistryFrgmt = null, onOk, ...modalProps }) => {
2234
const { t } = useTranslation();
35+
const { token } = theme.useToken();
36+
const { isDarkMode } = useThemeMode();
2337
const formRef = useRef<FormInstance>(null);
2438

2539
const { message, modal } = App.useApp();
@@ -36,6 +50,7 @@ const ContainerRegistryEditorModal: React.FC<
3650
project
3751
username
3852
ssl_verify
53+
extra
3954
}
4055
`,
4156
containerRegistryFrgmt,
@@ -51,6 +66,7 @@ const ContainerRegistryEditorModal: React.FC<
5166
$project: String
5267
$ssl_verify: Boolean
5368
$username: String
69+
$extra: JSONString
5470
) {
5571
create_container_registry_node(
5672
registry_name: $registry_name
@@ -61,6 +77,7 @@ const ContainerRegistryEditorModal: React.FC<
6177
project: $project
6278
ssl_verify: $ssl_verify
6379
username: $username
80+
extra: $extra
6481
) {
6582
container_registry {
6683
id
@@ -81,6 +98,7 @@ const ContainerRegistryEditorModal: React.FC<
8198
$project: String
8299
$ssl_verify: Boolean
83100
$username: String
101+
$extra: JSONString
84102
) {
85103
modify_container_registry_node(
86104
id: $id
@@ -92,6 +110,7 @@ const ContainerRegistryEditorModal: React.FC<
92110
project: $project
93111
ssl_verify: $ssl_verify
94112
username: $username
113+
extra: $extra
95114
) {
96115
container_registry {
97116
id
@@ -114,6 +133,7 @@ const ContainerRegistryEditorModal: React.FC<
114133
$project: String
115134
$ssl_verify: Boolean
116135
$username: String
136+
$extra: JSONString
117137
) {
118138
modify_container_registry_node(
119139
id: $id
@@ -124,6 +144,7 @@ const ContainerRegistryEditorModal: React.FC<
124144
project: $project
125145
ssl_verify: $ssl_verify
126146
username: $username
147+
extra: $extra
127148
) {
128149
container_registry {
129150
id
@@ -137,25 +158,34 @@ const ContainerRegistryEditorModal: React.FC<
137158
return formRef.current
138159
?.validateFields()
139160
.then((values) => {
140-
let mutationVariables = {
141-
id: _.isEmpty(values.row_id) ? undefined : values.row_id,
142-
registry_name: values.registry_name,
143-
url: values.url,
144-
type: values.type,
145-
project: values.project,
146-
username: _.isEmpty(values.username) ? null : values.username,
147-
password:
148-
values.isChangedPassword || !containerRegistry
149-
? _.isEmpty(values.password)
150-
? null // unset
151-
: values.password
152-
: undefined, // no change
153-
};
161+
let mutationVariables:
162+
| ContainerRegistryEditorModalCreateMutation$variables
163+
| ContainerRegistryEditorModalModifyMutation$variables
164+
| ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables =
165+
{
166+
id: _.isEmpty(values.row_id) ? undefined : values.row_id,
167+
registry_name: values.registry_name,
168+
url: values.url,
169+
type: values.type,
170+
project: values.project,
171+
username: _.isEmpty(values.username) ? null : values.username,
172+
password:
173+
values.isChangedPassword || !containerRegistry
174+
? _.isEmpty(values.password)
175+
? null // unset
176+
: values.password
177+
: undefined, // no change
178+
extra: _.isEmpty(values.extra)
179+
? null
180+
: JSON.stringify(values.extra),
181+
};
182+
154183
if (containerRegistry) {
155184
if (!values.isChangedPassword) {
156185
delete mutationVariables.password;
157186
commitModifyRegistryWithoutPassword({
158-
variables: mutationVariables,
187+
variables:
188+
mutationVariables as ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables,
159189
onCompleted: (res, errors) => {
160190
if (
161191
_.isEmpty(
@@ -180,7 +210,8 @@ const ContainerRegistryEditorModal: React.FC<
180210
});
181211
} else {
182212
commitModifyRegistry({
183-
variables: mutationVariables,
213+
variables:
214+
mutationVariables as ContainerRegistryEditorModalModifyMutation$variables,
184215
onCompleted: (res, errors) => {
185216
if (
186217
_.isEmpty(
@@ -209,7 +240,8 @@ const ContainerRegistryEditorModal: React.FC<
209240
typeof mutationVariables
210241
>;
211242
commitCreateRegistry({
212-
variables: mutationVariables,
243+
variables:
244+
mutationVariables as ContainerRegistryEditorModalCreateMutation$variables,
213245
onCompleted: (res, errors) => {
214246
if (
215247
_.isEmpty(
@@ -284,6 +316,9 @@ const ContainerRegistryEditorModal: React.FC<
284316
containerRegistry
285317
? {
286318
...containerRegistry,
319+
extra: containerRegistry?.extra
320+
? JSON.parse(containerRegistry.extra ?? '{}')
321+
: '',
287322
}
288323
: {}
289324
}
@@ -474,6 +509,43 @@ const ContainerRegistryEditorModal: React.FC<
474509
);
475510
}}
476511
</Form.Item>
512+
<Form.Item label={t('registry.ExtraInformation')}>
513+
<Flex
514+
style={{
515+
border: `1px solid ${token.colorBorder}`,
516+
borderRadius: token.borderRadius,
517+
overflow: 'hidden',
518+
}}
519+
>
520+
<Form.Item
521+
name="extra"
522+
noStyle
523+
rules={[
524+
{
525+
validator: (_, value) => {
526+
if (value) {
527+
try {
528+
JSON.parse(value);
529+
} catch (e) {
530+
return Promise.reject(
531+
t('registry.DescExtraJsonFormat'),
532+
);
533+
}
534+
}
535+
return Promise.resolve();
536+
},
537+
},
538+
]}
539+
>
540+
<BAICodeEditor
541+
editable
542+
language="json"
543+
theme={isDarkMode ? 'dark' : 'light'}
544+
style={{ width: '100%' }}
545+
/>
546+
</Form.Item>
547+
</Flex>
548+
</Form.Item>
477549
</Form>
478550
</BAIModal>
479551
);

resources/i18n/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@
11101110
"RegistryName": "Registrierungsname",
11111111
"DescRegistryNameIsEmpty": "Der Registrierungsname ist leer",
11121112
"RegistryNameAlreadyExists": "Der Registrierungsname ist bereits vorhanden. \nBitte ändern Sie den hinzuzufügenden Registrierungsnamen.",
1113-
"Project": "Projekt"
1113+
"Project": "Projekt",
1114+
"DescExtraJsonFormat": "Bitte geben Sie gültig formatiertes JSON ein",
1115+
"ExtraInformation": "Zusätzliche Informationen"
11141116
},
11151117
"resourceGroup": {
11161118
"ResourceGroups": "Ressourcengruppen",

resources/i18n/el.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@
11101110
"RegistryName": "Όνομα Μητρώου",
11111111
"DescRegistryNameIsEmpty": "Το όνομα μητρώου είναι κενό",
11121112
"RegistryNameAlreadyExists": "Το όνομα μητρώου υπάρχει ήδη. \nΑλλάξτε το όνομα μητρώου για προσθήκη.",
1113-
"Project": "Σχέδιο"
1113+
"Project": "Σχέδιο",
1114+
"DescExtraJsonFormat": "Εισαγάγετε JSON με έγκυρη μορφή",
1115+
"ExtraInformation": "Επιπλέον Πληροφορίες"
11141116
},
11151117
"resourceGroup": {
11161118
"ResourceGroups": "Ομάδες πόρων",

resources/i18n/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,9 @@
12391239
"RegistryName": "Registry Name",
12401240
"DescRegistryNameIsEmpty": "Registry name is empty",
12411241
"RegistryNameAlreadyExists": "Registry name already exists. Please change the registry name to add.",
1242-
"Project": "Project"
1242+
"Project": "Project",
1243+
"DescExtraJsonFormat": "Please enter validly formatted JSON",
1244+
"ExtraInformation": "Extra Information"
12431245
},
12441246
"resourceGroup": {
12451247
"ResourceGroups": "Resource Groups",

resources/i18n/es.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,9 @@
901901
"RegistryName": "Nombre de registro",
902902
"DescRegistryNameIsEmpty": "El nombre del registro está vacío",
903903
"RegistryNameAlreadyExists": "El nombre del registro ya existe. \nCambie el nombre del registro para agregar.",
904-
"Project": "Proyecto"
904+
"Project": "Proyecto",
905+
"DescExtraJsonFormat": "Por favor ingrese JSON con formato válido",
906+
"ExtraInformation": "Información adicional"
905907
},
906908
"resourceGroup": {
907909
"Active": "Activo",

resources/i18n/fi.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,9 @@
898898
"RegistryName": "Rekisterin nimi",
899899
"DescRegistryNameIsEmpty": "Rekisterin nimi on tyhjä",
900900
"RegistryNameAlreadyExists": "Rekisterin nimi on jo olemassa. \nMuuta lisättävä rekisterinimi.",
901-
"Project": "Projekti"
901+
"Project": "Projekti",
902+
"DescExtraJsonFormat": "Anna kelvollisesti muotoiltu JSON",
903+
"ExtraInformation": "Lisätiedot"
902904
},
903905
"resourceGroup": {
904906
"Active": "Aktiivinen",

resources/i18n/fr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,9 @@
11101110
"RegistryName": "Nom du registre",
11111111
"DescRegistryNameIsEmpty": "Le nom du registre est vide",
11121112
"RegistryNameAlreadyExists": "Le nom du registre existe déjà. \nVeuillez modifier le nom du registre à ajouter.",
1113-
"Project": "Projet"
1113+
"Project": "Projet",
1114+
"DescExtraJsonFormat": "Veuillez saisir un JSON au format valide",
1115+
"ExtraInformation": "Informations supplémentaires"
11141116
},
11151117
"resourceGroup": {
11161118
"ResourceGroups": "Groupes de ressources",

resources/i18n/id.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,9 @@
11111111
"RegistryName": "Nama Registri",
11121112
"DescRegistryNameIsEmpty": "Nama registri kosong",
11131113
"RegistryNameAlreadyExists": "Nama registri sudah ada. \nSilakan ubah nama registri untuk ditambahkan.",
1114-
"Project": "Proyek"
1114+
"Project": "Proyek",
1115+
"DescExtraJsonFormat": "Silakan masukkan JSON yang diformat secara valid",
1116+
"ExtraInformation": "Informasi Tambahan"
11151117
},
11161118
"resourceGroup": {
11171119
"ResourceGroups": "Grup Sumber Daya",

0 commit comments

Comments
 (0)