Skip to content

Commit

Permalink
feat: support for extra field in registry type
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Dec 9, 2024
1 parent 297abe0 commit 2725067
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 49 deletions.
26 changes: 22 additions & 4 deletions react/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ type Queries {

"""Added in 24.03.4."""
vfolder_nodes(
"""Added in 24.12.0."""
scope_id: ScopeField

"""Added in 24.09.0."""
project_id: UUID!
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")

"""Added in 24.09.0."""
permission: VFolderPermissionValueField
Expand All @@ -155,17 +158,23 @@ type Queries {
compute_session_node(
id: GlobalIDField!

"""Added in 24.12.0."""
scope_id: ScopeField

"""Added in 24.09.0."""
project_id: UUID!
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")

"""Added in 24.09.0. Default is read_attribute."""
permission: SessionPermissionValueField = "read_attribute"
): ComputeSessionNode

"""Added in 24.09.0."""
compute_session_nodes(
"""Added in 24.12.0."""
scope_id: ScopeField

"""Added in 24.09.0."""
project_id: UUID!
project_id: UUID @deprecated(reason: "Deprecated since 24.12.0. use `scope_id` instead.")

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

"""Added in 24.12.0."""
"""Added in 24.09.1."""
scalar Bytes

"""Added in 24.12.0."""
Expand Down Expand Up @@ -1493,6 +1502,9 @@ type ContainerRegistryNode implements Node {

"""Added in 24.09.0."""
ssl_verify: Boolean

"""Added in 24.09.3."""
extra: JSONString
}

"""Added in 24.09.0."""
Expand Down Expand Up @@ -1710,6 +1722,9 @@ type Mutations {

"""Added in 24.09.0."""
create_container_registry_node(
"""Added in 24.09.3."""
extra: JSONString

"""Added in 24.09.0."""
is_global: Boolean

Expand Down Expand Up @@ -1739,6 +1754,9 @@ type Mutations {

"""Added in 24.09.0."""
modify_container_registry_node(
"""Added in 24.09.3."""
extra: JSONString

"""Object id. Can be either global id or object id. Added in 24.09.0."""
id: String!

Expand Down
6 changes: 3 additions & 3 deletions react/src/components/BAICodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';
import { EditorView } from '@uiw/react-codemirror';

interface BAICodeEditorProps extends Omit<ReactCodeMirrorProps, 'language'> {
value: string;
onChange: (value: string) => void;
value?: string;
onChange?: (value: string) => void;
language: LanguageName;
editable?: boolean;
showLineNumbers?: boolean;
Expand Down Expand Up @@ -39,9 +39,9 @@ const BAICodeEditor: React.FC<BAICodeEditorProps> = ({
basicSetup={{
lineNumbers: showLineNumbers,
}}
{...CodeMirrorProps}
value={script}
onChange={(value, viewUpdate) => setScript(value)}
{...CodeMirrorProps}
/>
);
};
Expand Down
114 changes: 93 additions & 21 deletions react/src/components/ContainerRegistryEditorModal.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import { useThemeMode } from '../hooks/useThemeMode';
import BAICodeEditor from './BAICodeEditor';
import BAIModal, { BAIModalProps } from './BAIModal';
import Flex from './Flex';
import HiddenFormItem from './HiddenFormItem';
import { ContainerRegistryEditorModalCreateMutation } from './__generated__/ContainerRegistryEditorModalCreateMutation.graphql';
import {
ContainerRegistryEditorModalCreateMutation,
ContainerRegistryEditorModalCreateMutation$variables,
} from './__generated__/ContainerRegistryEditorModalCreateMutation.graphql';
import { ContainerRegistryEditorModalFragment$key } from './__generated__/ContainerRegistryEditorModalFragment.graphql';
import { ContainerRegistryEditorModalModifyMutation } from './__generated__/ContainerRegistryEditorModalModifyMutation.graphql';
import { ContainerRegistryEditorModalModifyWithoutPasswordMutation } from './__generated__/ContainerRegistryEditorModalModifyWithoutPasswordMutation.graphql';
import { Form, Input, Select, Checkbox, FormInstance, App } from 'antd';
import {
ContainerRegistryEditorModalModifyMutation,
ContainerRegistryEditorModalModifyMutation$variables,
} from './__generated__/ContainerRegistryEditorModalModifyMutation.graphql';
import {
ContainerRegistryEditorModalModifyWithoutPasswordMutation,
ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables,
} from './__generated__/ContainerRegistryEditorModalModifyWithoutPasswordMutation.graphql';
import { Form, Input, Select, Checkbox, FormInstance, App, theme } from 'antd';
import graphql from 'babel-plugin-relay/macro';
import _ from 'lodash';
import React, { useRef } from 'react';
Expand All @@ -20,6 +32,8 @@ const ContainerRegistryEditorModal: React.FC<
ContainerRegistryEditorModalProps
> = ({ containerRegistryFrgmt = null, onOk, ...modalProps }) => {
const { t } = useTranslation();
const { token } = theme.useToken();
const { isDarkMode } = useThemeMode();
const formRef = useRef<FormInstance>(null);

const { message, modal } = App.useApp();
Expand All @@ -36,6 +50,7 @@ const ContainerRegistryEditorModal: React.FC<
project
username
ssl_verify
extra
}
`,
containerRegistryFrgmt,
Expand All @@ -51,6 +66,7 @@ const ContainerRegistryEditorModal: React.FC<
$project: String
$ssl_verify: Boolean
$username: String
$extra: JSONString
) {
create_container_registry_node(
registry_name: $registry_name
Expand All @@ -61,6 +77,7 @@ const ContainerRegistryEditorModal: React.FC<
project: $project
ssl_verify: $ssl_verify
username: $username
extra: $extra
) {
container_registry {
id
Expand All @@ -81,6 +98,7 @@ const ContainerRegistryEditorModal: React.FC<
$project: String
$ssl_verify: Boolean
$username: String
$extra: JSONString
) {
modify_container_registry_node(
id: $id
Expand All @@ -92,6 +110,7 @@ const ContainerRegistryEditorModal: React.FC<
project: $project
ssl_verify: $ssl_verify
username: $username
extra: $extra
) {
container_registry {
id
Expand All @@ -114,6 +133,7 @@ const ContainerRegistryEditorModal: React.FC<
$project: String
$ssl_verify: Boolean
$username: String
$extra: JSONString
) {
modify_container_registry_node(
id: $id
Expand All @@ -124,6 +144,7 @@ const ContainerRegistryEditorModal: React.FC<
project: $project
ssl_verify: $ssl_verify
username: $username
extra: $extra
) {
container_registry {
id
Expand All @@ -137,25 +158,34 @@ const ContainerRegistryEditorModal: React.FC<
return formRef.current
?.validateFields()
.then((values) => {
let mutationVariables = {
id: _.isEmpty(values.row_id) ? undefined : values.row_id,
registry_name: values.registry_name,
url: values.url,
type: values.type,
project: values.project,
username: _.isEmpty(values.username) ? null : values.username,
password:
values.isChangedPassword || !containerRegistry
? _.isEmpty(values.password)
? null // unset
: values.password
: undefined, // no change
};
let mutationVariables:
| ContainerRegistryEditorModalCreateMutation$variables
| ContainerRegistryEditorModalModifyMutation$variables
| ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables =
{
id: _.isEmpty(values.row_id) ? undefined : values.row_id,
registry_name: values.registry_name,
url: values.url,
type: values.type,
project: values.project,
username: _.isEmpty(values.username) ? null : values.username,
password:
values.isChangedPassword || !containerRegistry
? _.isEmpty(values.password)
? null // unset
: values.password
: undefined, // no change
extra: _.isEmpty(values.extra)
? null
: JSON.stringify(values.extra),
};

if (containerRegistry) {
if (!values.isChangedPassword) {
delete mutationVariables.password;
commitModifyRegistryWithoutPassword({
variables: mutationVariables,
variables:
mutationVariables as ContainerRegistryEditorModalModifyWithoutPasswordMutation$variables,
onCompleted: (res, errors) => {
if (
_.isEmpty(
Expand All @@ -180,7 +210,8 @@ const ContainerRegistryEditorModal: React.FC<
});
} else {
commitModifyRegistry({
variables: mutationVariables,
variables:
mutationVariables as ContainerRegistryEditorModalModifyMutation$variables,
onCompleted: (res, errors) => {
if (
_.isEmpty(
Expand Down Expand Up @@ -209,7 +240,8 @@ const ContainerRegistryEditorModal: React.FC<
typeof mutationVariables
>;
commitCreateRegistry({
variables: mutationVariables,
variables:
mutationVariables as ContainerRegistryEditorModalCreateMutation$variables,
onCompleted: (res, errors) => {
if (
_.isEmpty(
Expand Down Expand Up @@ -284,6 +316,9 @@ const ContainerRegistryEditorModal: React.FC<
containerRegistry
? {
...containerRegistry,
extra: containerRegistry?.extra
? JSON.parse(containerRegistry.extra ?? '{}')
: '',
}
: {}
}
Expand Down Expand Up @@ -474,6 +509,43 @@ const ContainerRegistryEditorModal: React.FC<
);
}}
</Form.Item>
<Form.Item label={t('registry.ExtraInformation')}>
<Flex
style={{
border: `1px solid ${token.colorBorder}`,
borderRadius: token.borderRadius,
overflow: 'hidden',
}}
>
<Form.Item
name="extra"
noStyle
rules={[
{
validator: (_, value) => {
if (value) {
try {
JSON.parse(value);
} catch (e) {
return Promise.reject(
t('registry.DescExtraJsonFormat'),
);
}
}
return Promise.resolve();
},
},
]}
>
<BAICodeEditor
editable
language="json"
theme={isDarkMode ? 'dark' : 'light'}
style={{ width: '100%' }}
/>
</Form.Item>
</Flex>
</Form.Item>
</Form>
</BAIModal>
);
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@
"RegistryName": "Registrierungsname",
"DescRegistryNameIsEmpty": "Der Registrierungsname ist leer",
"RegistryNameAlreadyExists": "Der Registrierungsname ist bereits vorhanden. \nBitte ändern Sie den hinzuzufügenden Registrierungsnamen.",
"Project": "Projekt"
"Project": "Projekt",
"DescExtraJsonFormat": "Bitte geben Sie gültig formatiertes JSON ein",
"ExtraInformation": "Zusätzliche Informationen"
},
"resourceGroup": {
"ResourceGroups": "Ressourcengruppen",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@
"RegistryName": "Όνομα Μητρώου",
"DescRegistryNameIsEmpty": "Το όνομα μητρώου είναι κενό",
"RegistryNameAlreadyExists": "Το όνομα μητρώου υπάρχει ήδη. \nΑλλάξτε το όνομα μητρώου για προσθήκη.",
"Project": "Σχέδιο"
"Project": "Σχέδιο",
"DescExtraJsonFormat": "Εισαγάγετε JSON με έγκυρη μορφή",
"ExtraInformation": "Επιπλέον Πληροφορίες"
},
"resourceGroup": {
"ResourceGroups": "Ομάδες πόρων",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,9 @@
"RegistryName": "Registry Name",
"DescRegistryNameIsEmpty": "Registry name is empty",
"RegistryNameAlreadyExists": "Registry name already exists. Please change the registry name to add.",
"Project": "Project"
"Project": "Project",
"DescExtraJsonFormat": "Please enter validly formatted JSON",
"ExtraInformation": "Extra Information"
},
"resourceGroup": {
"ResourceGroups": "Resource Groups",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,9 @@
"RegistryName": "Nombre de registro",
"DescRegistryNameIsEmpty": "El nombre del registro está vacío",
"RegistryNameAlreadyExists": "El nombre del registro ya existe. \nCambie el nombre del registro para agregar.",
"Project": "Proyecto"
"Project": "Proyecto",
"DescExtraJsonFormat": "Por favor ingrese JSON con formato válido",
"ExtraInformation": "Información adicional"
},
"resourceGroup": {
"Active": "Activo",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,9 @@
"RegistryName": "Rekisterin nimi",
"DescRegistryNameIsEmpty": "Rekisterin nimi on tyhjä",
"RegistryNameAlreadyExists": "Rekisterin nimi on jo olemassa. \nMuuta lisättävä rekisterinimi.",
"Project": "Projekti"
"Project": "Projekti",
"DescExtraJsonFormat": "Anna kelvollisesti muotoiltu JSON",
"ExtraInformation": "Lisätiedot"
},
"resourceGroup": {
"Active": "Aktiivinen",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,9 @@
"RegistryName": "Nom du registre",
"DescRegistryNameIsEmpty": "Le nom du registre est vide",
"RegistryNameAlreadyExists": "Le nom du registre existe déjà. \nVeuillez modifier le nom du registre à ajouter.",
"Project": "Projet"
"Project": "Projet",
"DescExtraJsonFormat": "Veuillez saisir un JSON au format valide",
"ExtraInformation": "Informations supplémentaires"
},
"resourceGroup": {
"ResourceGroups": "Groupes de ressources",
Expand Down
4 changes: 3 additions & 1 deletion resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,9 @@
"RegistryName": "Nama Registri",
"DescRegistryNameIsEmpty": "Nama registri kosong",
"RegistryNameAlreadyExists": "Nama registri sudah ada. \nSilakan ubah nama registri untuk ditambahkan.",
"Project": "Proyek"
"Project": "Proyek",
"DescExtraJsonFormat": "Silakan masukkan JSON yang diformat secara valid",
"ExtraInformation": "Informasi Tambahan"
},
"resourceGroup": {
"ResourceGroups": "Grup Sumber Daya",
Expand Down
Loading

0 comments on commit 2725067

Please sign in to comment.