Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wire up new tags API to settings page #3340

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/api/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,18 @@ export const enum SettingsType {
awsCategoryKeys = 'awsCategoryKeys',
awsCategoryKeysEnable = 'awsCategoryKeysEnable',
awsCategoryKeysDisable = 'awsCategoryKeysDisable',
tags = 'tags',
tagsEnable = 'tagsEnable',
tagsDisable = 'tagsDisable',
}

export const SettingsTypePaths: Partial<Record<SettingsType, string>> = {
[SettingsType.awsCategoryKeys]: 'settings/aws_category_keys/',
[SettingsType.awsCategoryKeysEnable]: 'settings/aws_category_keys/enable/',
[SettingsType.awsCategoryKeysDisable]: 'settings/aws_category_keys/disable/',
[SettingsType.tags]: 'settings/tags',
[SettingsType.tagsEnable]: 'settings/tags/enable/',
[SettingsType.tagsDisable]: 'settings/tags/disable/',
};

export function fetchSettings(settingsType: SettingsType, query: string) {
Expand Down
7 changes: 3 additions & 4 deletions src/routes/settings/costCategory/costCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const CostCategory: React.FC<CostCategoryProps> = ({ canWrite }) => {

const getPagination = (isDisabled = false, isBottom = false) => {
const count = settings?.meta ? settings.meta.count : 0;
const limit = settings?.meta?.limit ? settings.meta.limit : baseQuery.limit; // Todo: API doesn't provide limit
const offset = settings?.meta?.offset ? settings.meta.offset : baseQuery.offset; // Todo: API doesn't provide offset
const limit = settings?.meta ? settings.meta.limit : baseQuery.limit;
const offset = settings?.meta ? settings.meta.offset : baseQuery.offset;
const page = Math.trunc(offset / limit + 1);

return (
Expand Down Expand Up @@ -180,7 +180,7 @@ const CostCategory: React.FC<CostCategoryProps> = ({ canWrite }) => {
};

const handleOnSetPage = pageNumber => {
const newQuery = queryUtils.handleOnSetPage(query, settings, pageNumber);
const newQuery = queryUtils.handleOnSetPage(query, settings, pageNumber, true);
setQuery(newQuery);
};

Expand All @@ -206,7 +206,6 @@ const CostCategory: React.FC<CostCategoryProps> = ({ canWrite }) => {
const categories = getCategories();
const isDisabled = categories.length === 0;

// Note: Providers are fetched via the AccountSettings component used by all routes
if (settingsError) {
return <NotAvailable />;
}
Expand Down
11 changes: 4 additions & 7 deletions src/routes/settings/costCategory/costCategoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React from 'react';
import type { WrappedComponentProps } from 'react-intl';
import { injectIntl } from 'react-intl';
import { DataTable } from 'routes/components/dataTable';
import { styles } from 'routes/components/dataTable/dataTable.styles';
import type { RouterComponentProps } from 'utils/router';
import { withRouter } from 'utils/router';

Expand All @@ -28,12 +29,6 @@ interface CostCategoryState {

type CostCategoryProps = CostCategoryOwnProps;

export const CostCategoryColumnIds = {
infrastructure: 'infrastructure',
monthOverMonth: 'monthOverMonth',
supplementary: 'supplementary',
};

class CostCategoryBase extends React.Component<CostCategoryProps, CostCategoryState> {
public state: CostCategoryState = {
columns: [],
Expand Down Expand Up @@ -68,14 +63,15 @@ class CostCategoryBase extends React.Component<CostCategoryProps, CostCategorySt
name: '', // Selection column
},
{
orderBy: 'key', // Todo: update sort name
orderBy: 'key',
name: intl.formatMessage(messages.detailsResourceNames, { value: 'name' }),
...(categories.length && { isSortable: true }),
},
{
orderBy: 'enabled',
name: intl.formatMessage(messages.detailsResourceNames, { value: 'status' }),
...(categories.length && { isSortable: true }),
style: styles.lastItemColumn,
},
];

Expand All @@ -92,6 +88,7 @@ class CostCategoryBase extends React.Component<CostCategoryProps, CostCategorySt
) : (
<Label>{intl.formatMessage(messages.disabled)}</Label>
),
style: styles.lastItem,
},
],
item,
Expand Down
Loading
Loading