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

Create hardware routes in frontend #488

Merged
merged 2 commits into from
Nov 4, 2024
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
34 changes: 19 additions & 15 deletions dashboard/src/hooks/useToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ function genId(): string {
return count.toString();
}

type ActionType = {
ADD_TOAST: 'ADD_TOAST';
UPDATE_TOAST: 'UPDATE_TOAST';
DISMISS_TOAST: 'DISMISS_TOAST';
REMOVE_TOAST: 'REMOVE_TOAST';
};
enum ActionType {
ADD_TOAST = 'ADD_TOAST',
UPDATE_TOAST = 'UPDATE_TOAST',
DISMISS_TOAST = 'DISMISS_TOAST',
REMOVE_TOAST = 'REMOVE_TOAST',
}

type Action =
| {
type: ActionType['ADD_TOAST'];
type: ActionType.ADD_TOAST;
toast: ToasterToast;
}
| {
type: ActionType['UPDATE_TOAST'];
type: ActionType.UPDATE_TOAST;
toast: Partial<ToasterToast>;
}
| {
type: ActionType['DISMISS_TOAST'];
type: ActionType.DISMISS_TOAST;
toastId?: ToasterToast['id'];
}
| {
type: ActionType['REMOVE_TOAST'];
type: ActionType.REMOVE_TOAST;
toastId?: ToasterToast['id'];
};

Expand All @@ -58,7 +58,7 @@ const addToRemoveQueue = (toastId: string): void => {
const timeout = setTimeout(() => {
toastTimeouts.delete(toastId);
dispatch({
type: 'REMOVE_TOAST',
type: ActionType.REMOVE_TOAST,
toastId: toastId,
});
}, TOAST_REMOVE_DELAY);
Expand Down Expand Up @@ -118,6 +118,8 @@ export const reducer = (state: State, action: Action): State => {
...state,
toasts: state.toasts.filter(t => t.id !== action.toastId),
};
default:
return state;
}
};

Expand Down Expand Up @@ -145,13 +147,14 @@ function toast({ ...props }: Toast): ToastStateProps {

const update = (toastProps: ToasterToast): void =>
dispatch({
type: 'UPDATE_TOAST',
type: ActionType.UPDATE_TOAST,
toast: { ...toastProps, id },
});
const dismiss = (): void => dispatch({ type: 'DISMISS_TOAST', toastId: id });
const dismiss = (): void =>
dispatch({ type: ActionType.DISMISS_TOAST, toastId: id });

dispatch({
type: 'ADD_TOAST',
type: ActionType.ADD_TOAST,
toast: {
...props,
id,
Expand Down Expand Up @@ -191,7 +194,8 @@ function useToast(): UseToastType {
return {
...state,
toast,
dismiss: (toastId?: string) => dispatch({ type: 'DISMISS_TOAST', toastId }),
dismiss: (toastId?: string) =>
dispatch({ type: ActionType.DISMISS_TOAST, toastId }),
};
}

Expand Down
14 changes: 7 additions & 7 deletions dashboard/src/pages/TreeDetails/Tabs/CommitNavigationGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ const CommitNavigationGraph = (): JSX.Element => {

const messagesId: MessagesID = useMemo(() => {
switch (currentTreeDetailsTab) {
case 'treeDetails.builds':
return {
graphName: 'treeDetails.buildsHistory',
good: 'treeDetails.validBuilds',
bad: 'treeDetails.invalidBuilds',
mid: 'treeDetails.inconclusiveBuilds',
} as MessagesID;
case 'treeDetails.boots':
return {
graphName: 'treeDetails.bootsHistory',
Expand All @@ -82,6 +75,13 @@ const CommitNavigationGraph = (): JSX.Element => {
bad: 'treeDetails.testsFailed',
mid: 'treeDetails.testsInconclusive',
} as MessagesID;
default:
return {
graphName: 'treeDetails.buildsHistory',
good: 'treeDetails.validBuilds',
bad: 'treeDetails.invalidBuilds',
mid: 'treeDetails.inconclusiveBuilds',
} as MessagesID;
}
}, [currentTreeDetailsTab]);

Expand Down
Loading
Loading