Skip to content

Commit

Permalink
fix: Migrate chart config in getConfig to also include embed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Oct 4, 2022
1 parent e622aae commit 49bec03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
16 changes: 15 additions & 1 deletion app/db/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { migrateChartConfig } from "@/utils/chart-config/versioning";

import { createChartId } from "../utils/create-chart-id";

import { pool } from "./pg-pool";
Expand Down Expand Up @@ -37,7 +39,19 @@ export const getConfig = async (
[key]
);

return result.rows[0];
const config = result.rows[0];

if (config && config.data) {
return {
...config,
data: {
...config.data,
chartConfig: migrateChartConfig(config.data.chartConfig),
},
};
}

return config;
};

/**
Expand Down
14 changes: 1 addition & 13 deletions app/pages/v/[chartId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { PublishActions } from "@/components/publish-actions";
import { Config } from "@/configurator";
import { getConfig } from "@/db/config";
import { useLocale } from "@/locales/use-locale";
import { migrateChartConfig } from "@/utils/chart-config/versioning";

type PageProps =
| {
Expand All @@ -37,18 +36,7 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async ({

if (config && config.data) {
// TODO validate configuration
return {
props: {
status: "found",
config: {
...config,
data: {
...config.data,
chartConfig: migrateChartConfig(config.data.chartConfig),
},
},
},
};
return { props: { status: "found", config } };
}

res.statusCode = 404;
Expand Down

0 comments on commit 49bec03

Please sign in to comment.