Skip to content

Commit

Permalink
fix: [UIE-8157] - DBaaS type call requires X-Filter (#11010)
Browse files Browse the repository at this point in the history
  • Loading branch information
corya-akamai authored Sep 26, 2024
1 parent 75e00f1 commit 66265ea
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 18 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11010-fixed-1727359551617.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

Include platform header in DBaaS types call ([#11010](https://github.com/linode/manager/pull/11010))
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ interface NodePricing {
const DatabaseCreate = () => {
const { classes } = useStyles();
const history = useHistory();
const { isDatabasesV2Beta, isDatabasesV2Enabled } = useIsDatabasesEnabled();

const {
data: regionsData,
Expand All @@ -213,9 +214,9 @@ const DatabaseCreate = () => {
data: dbtypes,
error: typesError,
isLoading: typesLoading,
} = useDatabaseTypesQuery();

const { isDatabasesV2Beta, isDatabasesV2Enabled } = useIsDatabasesEnabled();
} = useDatabaseTypesQuery({
platform: isDatabasesV2Enabled ? 'rdbms-default' : 'rdbms-legacy',
});

const formRef = React.useRef<HTMLFormElement>(null);
const { mutateAsync: createDatabase } = useCreateDatabaseMutation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const DatabaseResize = ({ database, disabled = false }: Props) => {
data: dbTypes,
error: typesError,
isLoading: typesLoading,
} = useDatabaseTypesQuery();
} = useDatabaseTypesQuery({ platform: database.platform });

const { enqueueSnackbar } = useSnackbar();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DatabaseResizeCurrentConfiguration = ({ database }: Props) => {
data: types,
error: typesError,
isLoading: typesLoading,
} = useDatabaseTypesQuery();
} = useDatabaseTypesQuery({ platform: database.platform });
const theme = useTheme();
const { data: regions } = useRegionsQuery();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ export const DatabaseSummaryClusterConfiguration = (props: Props) => {

const { database } = props;

const { data: types } = useDatabaseTypesQuery();
const { data: types } = useDatabaseTypesQuery({
platform: database.platform,
});

const type = types?.find((type: DatabaseType) => type.id === database?.type);

const { data: regions } = useRegionsQuery();

const region = regions?.find((r: Region) => r.id === database.region);

const type = types?.find((type: DatabaseType) => type.id === database?.type);

const { data: events } = useInProgressEvents();

if (!database || !type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const DatabaseDetail = () => {
const id = Number(databaseId);

const { data: database, error, isLoading } = useDatabaseQuery(engine, id);
const { isLoading: isTypesLoading } = useDatabaseTypesQuery();
const { isLoading: isTypesLoading } = useDatabaseTypesQuery({
platform: database?.platform,
});

const { mutateAsync: updateDatabase } = useDatabaseMutation(engine, id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ const DatabaseLanding = () => {
globalGrantType: 'add_databases',
});

const { isLoading: isTypeLoading } = useDatabaseTypesQuery();
const { isDatabasesV2Enabled } = useIsDatabasesEnabled();
const { isLoading: isTypeLoading } = useDatabaseTypesQuery({
platform: isDatabasesV2Enabled ? 'rdbms-default' : 'rdbms-legacy',
});

const {
handleOrderChange: newDatabaseHandleOrderChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export const DatabaseRow = ({ database, events, isNewDatabase }: Props) => {

const { data: regions } = useRegionsQuery();
const { data: profile } = useProfile();
const { data: types } = useDatabaseTypesQuery();
const { data: types } = useDatabaseTypesQuery({
platform: database.platform,
});
const plan = types?.find((t: DatabaseType) => t.id === type);
const formattedPlan = plan && formatStorageUnits(plan.label);
const actualRegion = regions?.find((r) => r.id === region);
Expand Down
13 changes: 10 additions & 3 deletions packages/manager/src/queries/databases/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export const databaseQueries = createQueryKeys('databases', {
queryKey: null,
},
types: {
queryFn: getAllDatabaseTypes,
contextQueries: {
all: (filter: Filter = {}) => ({
queryFn: () => getAllDatabaseTypes(filter),
queryKey: [filter],
}),
},
queryKey: null,
},
});
Expand Down Expand Up @@ -176,8 +181,10 @@ export const useDatabaseEnginesQuery = (enabled: boolean = false) =>
enabled,
});

export const useDatabaseTypesQuery = () =>
useQuery<DatabaseType[], APIError[]>(databaseQueries.types);
export const useDatabaseTypesQuery = (filter: Filter = {}) =>
useQuery<DatabaseType[], APIError[]>({
...databaseQueries.types._ctx.all(filter),
});

export const useDatabaseCredentialsQuery = (
engine: Engine,
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/src/queries/databases/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getAllDatabaseEngines = () =>
(data) => data.data
);

export const getAllDatabaseTypes = () =>
getAll<DatabaseType>((params) => getDatabaseTypes(params))().then(
(data) => data.data
);
export const getAllDatabaseTypes = (passedFilter: Filter = {}) =>
getAll<DatabaseType>((params, filter) =>
getDatabaseTypes(params, { ...filter, ...passedFilter })
)().then((data) => data.data);

0 comments on commit 66265ea

Please sign in to comment.