From 405ce378bc461ae719ea4c0d5532123495828d34 Mon Sep 17 00:00:00 2001 From: minnakt Date: Fri, 15 Sep 2023 12:58:23 -0400 Subject: [PATCH] Address comments --- .../integration/distroSettings/provider_section.ts | 14 ++++++++++++++ .../tabs/ProviderTab/ProviderTab.tsx | 6 +----- .../tabs/ProviderTab/transformers.test.ts | 2 ++ .../tabs/ProviderTab/transformers.ts | 1 + src/pages/distroSettings/tabs/ProviderTab/types.ts | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cypress/integration/distroSettings/provider_section.ts b/cypress/integration/distroSettings/provider_section.ts index 9bb11ac57e..14a4f8ab82 100644 --- a/cypress/integration/distroSettings/provider_section.ts +++ b/cypress/integration/distroSettings/provider_section.ts @@ -38,6 +38,20 @@ describe("provider section", () => { cy.visit("/distro/ubuntu1604-container-test/settings/provider"); }); + it("shows pool mapping information based on container pool id", () => { + cy.getInputByLabel("Container Pool ID").should( + "contain.text", + "test-pool-1" + ); + cy.getInputByLabel("Pool Mapping Information") + .should("have.attr", "placeholder") + .and("match", /test-pool-1/); + cy.selectLGOption("Container Pool ID", "test-pool-2"); + cy.getInputByLabel("Pool Mapping Information") + .should("have.attr", "placeholder") + .and("match", /test-pool-2/); + }); + it("successfully updates docker provider fields", () => { cy.dataCy("provider-select").contains("Docker"); diff --git a/src/pages/distroSettings/tabs/ProviderTab/ProviderTab.tsx b/src/pages/distroSettings/tabs/ProviderTab/ProviderTab.tsx index 7ed8152e67..8e6d9940d7 100644 --- a/src/pages/distroSettings/tabs/ProviderTab/ProviderTab.tsx +++ b/src/pages/distroSettings/tabs/ProviderTab/ProviderTab.tsx @@ -8,8 +8,6 @@ import { getFormSchema } from "./getFormSchema"; import { TabProps, ProviderFormState } from "./types"; export const ProviderTab: React.FC = ({ distroData }) => { - const initialFormState = distroData; - const { getTab } = useDistroSettingsContext(); // @ts-expect-error - see TabState for details. const { formData }: { formData: ProviderFormState } = getTab( @@ -30,7 +28,5 @@ export const ProviderTab: React.FC = ({ distroData }) => { [pools, poolMappingInfo] ); - return ( - - ); + return ; }; diff --git a/src/pages/distroSettings/tabs/ProviderTab/transformers.test.ts b/src/pages/distroSettings/tabs/ProviderTab/transformers.test.ts index e61914bebe..e52984de11 100644 --- a/src/pages/distroSettings/tabs/ProviderTab/transformers.test.ts +++ b/src/pages/distroSettings/tabs/ProviderTab/transformers.test.ts @@ -33,6 +33,7 @@ describe("provider tab", () => { registryUsername: "", registryPassword: "", containerPoolId: "", + poolMappingInfo: "", userData: "", mergeUserData: false, securityGroups: ["1"], @@ -93,6 +94,7 @@ describe("provider tab", () => { registryUsername: "testuser", registryPassword: "abc-123", containerPoolId: "pool-1", + poolMappingInfo: "", userData: "", mergeUserData: false, securityGroups: ["1"], diff --git a/src/pages/distroSettings/tabs/ProviderTab/transformers.ts b/src/pages/distroSettings/tabs/ProviderTab/transformers.ts index 51c219d223..304ebbbd62 100644 --- a/src/pages/distroSettings/tabs/ProviderTab/transformers.ts +++ b/src/pages/distroSettings/tabs/ProviderTab/transformers.ts @@ -23,6 +23,7 @@ export const gqlToForm = ((data) => { dockerProviderSettings: { ...dockerProviderSettings(providerSettingsList[0]).form, containerPoolId: containerPool, + poolMappingInfo: "", }, }; }) satisfies GqlToFormFunction; diff --git a/src/pages/distroSettings/tabs/ProviderTab/types.ts b/src/pages/distroSettings/tabs/ProviderTab/types.ts index 42178bcfc7..c62c083215 100644 --- a/src/pages/distroSettings/tabs/ProviderTab/types.ts +++ b/src/pages/distroSettings/tabs/ProviderTab/types.ts @@ -5,7 +5,6 @@ export enum BuildType { Pull = "pull", } -// TODO: Append type with additional provider options, e.g. type ProviderFormState = StaticProviderFormState | DockerProviderFormState export type ProviderFormState = { provider: { providerName: Provider; @@ -21,6 +20,7 @@ export type ProviderFormState = { registryUsername: string; registryPassword: string; containerPoolId: string; + poolMappingInfo: string; userData: string; mergeUserData: boolean; securityGroups: string[];