Skip to content

Commit

Permalink
DEVPROD-6883: Create input for image on distro settings page (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt authored May 10, 2024
1 parent 92b82c2 commit 72c4b83
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/spruce/src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5774,6 +5774,7 @@ export type DistroQuery = {
containerPool: string;
disabled: boolean;
disableShallowClone: boolean;
imageId?: string | null;
isCluster: boolean;
isVirtualWorkStation: boolean;
mountpoints?: Array<string | null> | null;
Expand Down
1 change: 1 addition & 0 deletions apps/spruce/src/gql/queries/distro.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ query Distro($distroId: String!) {
configPath
schedulerHost
}
imageId
isCluster
isVirtualWorkStation
mountpoints
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@ export const getFormSchema = (
type: "object" as "object",
title: "",
properties: {
identifier: {
name: {
type: "string" as "string",
title: "Identifier",
readOnly: true,
},
},
},
distroImage: {
type: "object" as "object",
title: "",
properties: {
image: {
type: "string" as "string",
title: "Image",
default: "",
},
},
},
distroAliases: {
type: "object" as "object",
title: "Aliases",
Expand Down Expand Up @@ -76,14 +87,20 @@ export const getFormSchema = (
uiSchema: {
distroName: {
"ui:ObjectFieldTemplate": CardFieldTemplate,
identifier: {
name: {
...(isContainerDistro && {
"ui:warnings": [
"Distro is a container pool, so it cannot be spawned for tasks.",
],
}),
},
},
distroImage: {
"ui:ObjectFieldTemplate": CardFieldTemplate,
image: {
"ui:description": "The image from which this distro inherits.",
},
},
distroAliases: {
"ui:rootFieldId": "aliases",
"ui:ObjectFieldTemplate": CardFieldTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ describe("general tab", () => {

const generalForm: GeneralFormState = {
distroName: {
identifier: "rhel71-power8-large",
name: "rhel71-power8-large",
},
distroImage: {
image: "rhel71-power8",
},
distroAliases: {
aliases: ["rhel71-power8", "rhel71-power8-build"],
Expand All @@ -33,6 +36,7 @@ const generalForm: GeneralFormState = {
const generalGql: DistroInput = {
...distroData,
name: "rhel71-power8-large",
imageId: "rhel71-power8",
adminOnly: false,
aliases: ["rhel71-power8", "rhel71-power8-build"],
isCluster: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const gqlToForm = ((data) => {
aliases,
disableShallowClone,
disabled,
imageId,
isCluster,
name,
note,
Expand All @@ -19,7 +20,10 @@ export const gqlToForm = ((data) => {

return {
distroName: {
identifier: name,
name,
},
distroImage: {
image: imageId,
},
distroAliases: {
aliases,
Expand All @@ -36,11 +40,12 @@ export const gqlToForm = ((data) => {
}) satisfies GqlToFormFunction<Tab>;

export const formToGql = ((
{ distroAliases, distroName, distroOptions },
{ distroAliases, distroImage, distroName, distroOptions },
distro,
) => ({
...distro,
name: distroName.identifier,
name: distroName.name,
imageId: distroImage.image,
adminOnly: distroOptions.adminOnly,
aliases: distroAliases.aliases,
note: distroOptions.note,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export interface GeneralFormState {
distroName: {
identifier: string;
name: string;
};
distroImage: {
image: string;
};
distroAliases: {
aliases: string[];
Expand Down
1 change: 1 addition & 0 deletions apps/spruce/src/pages/distroSettings/tabs/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const distroData: DistroQuery["distro"] = {
aliases: ["rhel71-power8", "rhel71-power8-build"],
arch: Arch.Linux_64Bit,
authorizedKeysFile: "",
imageId: "rhel71-power8",
bootstrapSettings: {
clientDir: "/home/evg/client",
communication: CommunicationMethod.LegacySsh,
Expand Down

0 comments on commit 72c4b83

Please sign in to comment.