Przeglądaj źródła

fix type errors on preview addons (#4594)

ianedwards 2 lat temu
rodzic
commit
245c985ad8

+ 3 - 1
dashboard/src/lib/addons/index.ts

@@ -168,7 +168,9 @@ function addonTypeEnumProto(type: ClientAddon["config"]["type"]): AddonType {
     .exhaustive();
 }
 
-export function clientAddonToProto(addon: ClientAddon): Addon {
+export function clientAddonToProto(
+  addon: Omit<ClientAddon, "template">
+): Addon {
   const config = match(addon.config)
     .returnType<Addon["config"]>()
     .with({ type: "postgres" }, (data) => ({

+ 3 - 2
dashboard/src/main/home/cluster-dashboard/preview-environments/v2/setup-app/PreviewAppDataContainer.tsx

@@ -159,13 +159,14 @@ export const PreviewAppDataContainer: React.FC<Props> = ({
 
       const addons = data.addons.map((addon) => {
         const variables = match(addon.config)
+          .returnType<Record<string, string>>()
           .with({ type: "postgres" }, (conf) => ({
             POSTGRESQL_USERNAME: conf.username,
           }))
           .with({ type: "redis" }, (conf) => ({
             REDIS_PASSWORD: conf.password,
           }))
-          .exhaustive();
+          .otherwise(() => ({}));
         const secrets = match(addon.config)
           .with({ type: "postgres" }, (conf) => ({
             POSTGRESQL_PASSWORD: conf.password,
@@ -173,7 +174,7 @@ export const PreviewAppDataContainer: React.FC<Props> = ({
           .with({ type: "redis" }, (conf) => ({
             REDIS_PASSWORD: conf.password,
           }))
-          .exhaustive();
+          .otherwise(() => ({}));
 
         const proto = clientAddonToProto(addon);