Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(UI): Fix details tiles local storage #10312

Merged
merged 2 commits into from
Oct 19, 2021
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
4 changes: 2 additions & 2 deletions www/front_src/src/Resources/Details/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1506,8 +1506,8 @@ describe(Details, () => {
expect(getByText(labelMonitoringServer)).toBeInTheDocument();
expect(getByText(labelStatusInformation)).toBeInTheDocument();

expect(queryByText(labelLastCheck)).not.toBeInTheDocument();
expect(queryByText(labelCommand)).not.toBeInTheDocument();
expect(queryByText(labelLastCheck)).toBeInTheDocument();
expect(queryByText(labelCommand)).toBeInTheDocument();
});

it('queries the performance graphs with the time period selected in the "Timeline" tab when the "Graph" tab is selected and the "Timeline" tab was selected', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
pluck,
propEq,
remove,
difference,
uniq,
} from 'ramda';

import { Box, Grid } from '@material-ui/core';
Expand All @@ -40,6 +42,23 @@ interface Props {
panelWidth: number;
}

interface MergeDefaultAndStoredCardsProps {
defaultCards: Array<string>;
storedCards: Array<string>;
}

const mergeDefaultAndStoredCards = ({
defaultCards,
storedCards,
}: MergeDefaultAndStoredCardsProps): Array<string> => {
const differenceBetweenDefaultAndStoredCards = difference(
defaultCards,
storedCards,
);

return uniq([...storedCards, ...differenceBetweenDefaultAndStoredCards]);
};

const SortableCards = ({ panelWidth, details }: Props): JSX.Element => {
const { toDateTime } = useLocaleDateTimeFormat();
const { t } = useTranslation();
Expand Down Expand Up @@ -69,9 +88,14 @@ const SortableCards = ({ panelWidth, details }: Props): JSX.Element => {
toDateTime,
});

const allDetailsCardsTitle = pluck('title', allDetailsCards);

const defaultDetailsCardsLayout = isEmpty(storedDetailsCards)
? pluck('title', allDetailsCards)
: storedDetailsCards;
? allDetailsCardsTitle
: mergeDefaultAndStoredCards({
defaultCards: allDetailsCardsTitle,
storedCards: storedDetailsCards,
});

const cards = map<string, CardsLayout>(
(title) => ({
Expand Down