Skip to content

refactor(site): refactor workspace notifications #11520

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

Merged
merged 27 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0b28628
Refactor outdated warning
BrunoQuaresma Jan 9, 2024
ab96aab
Move unhealthy warning
BrunoQuaresma Jan 9, 2024
38f213e
Move dormant notification
BrunoQuaresma Jan 9, 2024
9ec5952
Remove mutation errors from alerts
BrunoQuaresma Jan 9, 2024
17ecf0e
Move pending in queue notification
BrunoQuaresma Jan 9, 2024
c969df5
Move deprecated notification
BrunoQuaresma Jan 9, 2024
8f6040d
Move outdated to notifications array
BrunoQuaresma Jan 9, 2024
691c028
Move unhealthy to notifications array
BrunoQuaresma Jan 9, 2024
706bbd5
Fix permissions for restart workspace
BrunoQuaresma Jan 9, 2024
d3e68fb
Move dormant notifications to notifications array
BrunoQuaresma Jan 9, 2024
2f1ac83
Structure notification pills
BrunoQuaresma Jan 9, 2024
c334031
Minor style adjustments
BrunoQuaresma Jan 9, 2024
a78d4cf
Remove bottom bar from workspace page
BrunoQuaresma Jan 9, 2024
24c7552
Display notifications under the pills
BrunoQuaresma Jan 9, 2024
b711018
Improve canAutoStart check
BrunoQuaresma Jan 11, 2024
121005c
Move css into a style
BrunoQuaresma Jan 11, 2024
3234d49
Move css into a style
BrunoQuaresma Jan 11, 2024
b30dc44
Remove unecessary boolean
BrunoQuaresma Jan 11, 2024
04994a4
Refactor props
BrunoQuaresma Jan 11, 2024
5ba0765
Improve semantics
BrunoQuaresma Jan 11, 2024
3d0d70b
Merge branch 'bq/move-alert' of https://github.com/coder/coder into b…
BrunoQuaresma Jan 11, 2024
9299c68
Merge branch 'main' of https://github.com/coder/coder into bq/move-alert
BrunoQuaresma Jan 11, 2024
6d3148b
Merge branch 'main' of https://github.com/coder/coder into bq/move-alert
BrunoQuaresma Jan 12, 2024
45be26c
Add tests
BrunoQuaresma Jan 12, 2024
d21be38
Merge branch 'main' of https://github.com/coder/coder into bq/move-alert
BrunoQuaresma Jan 12, 2024
478a333
Fix storybook
BrunoQuaresma Jan 12, 2024
d62833c
Merge branch 'main' of https://github.com/coder/coder into bq/move-alert
BrunoQuaresma Jan 12, 2024
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
Prev Previous commit
Next Next commit
Move dormant notification
  • Loading branch information
BrunoQuaresma committed Jan 9, 2024
commit 38f213e6ce822d205010e27ae6ef41b077dd575c
2 changes: 0 additions & 2 deletions site/src/components/WorkspaceDeletion/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type FC, type ReactNode } from "react";
import type { Workspace } from "api/typesGenerated";
import { Pill } from "components/Pill/Pill";
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
import { DormantDeletionText } from "components/WorkspaceDeletion";
import { DormantDeletionText } from "./DormantDeletionText";
import { getDisplayWorkspaceStatus } from "utils/workspace";
import { useClassName } from "hooks/useClassName";
import { formatDistanceToNow } from "date-fns";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ import { ReactNode, type FC } from "react";
import type { Workspace } from "api/typesGenerated";
import { useIsWorkspaceActionsEnabled } from "components/Dashboard/DashboardProvider";
import { Alert } from "components/Alert/Alert";

export enum Count {
Singular,
Multiple,
}
import { useLocalStorage } from "hooks";

interface DormantWorkspaceBannerProps {
workspace: Workspace;
onDismiss: () => void;
shouldRedisplayBanner: boolean;
}

export const DormantWorkspaceBanner: FC<DormantWorkspaceBannerProps> = ({
workspace,
onDismiss,
shouldRedisplayBanner,
}) => {
const experimentEnabled = useIsWorkspaceActionsEnabled();
const { saveLocal, getLocal } = useLocalStorage();
const shouldRedisplayBanner = getLocal("dismissedWorkspace") !== workspace.id;

if (
// Only show this if the experiment is included.
Expand Down Expand Up @@ -69,7 +63,13 @@ export const DormantWorkspaceBanner: FC<DormantWorkspaceBannerProps> = ({
};

return (
<Alert severity="warning" onDismiss={onDismiss} dismissible>
<Alert
severity="warning"
onDismiss={() => {
saveLocal("dismissedWorkspace", workspace.id);
}}
dismissible
>
{alertText()}
</Alert>
);
Expand Down
13 changes: 1 addition & 12 deletions site/src/pages/WorkspacePage/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import type * as TypesGen from "api/typesGenerated";
import { Alert, AlertDetail } from "components/Alert/Alert";
import { Stack } from "components/Stack/Stack";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { DormantWorkspaceBanner } from "components/WorkspaceDeletion";
import { AgentRow } from "components/Resources/AgentRow";
import { useLocalStorage, useTab } from "hooks";
import { useTab } from "hooks";
import {
ActiveTransition,
WorkspaceBuildProgress,
Expand Down Expand Up @@ -95,7 +94,6 @@ export const Workspace: FC<WorkspaceProps> = ({
permissions,
}) => {
const navigate = useNavigate();
const { saveLocal, getLocal } = useLocalStorage();
const theme = useTheme();

const [showAlertPendingInQueue, setShowAlertPendingInQueue] = useState(false);
Expand Down Expand Up @@ -261,15 +259,6 @@ export const Workspace: FC<WorkspaceProps> = ({
/>
)}

{/* <DormantWorkspaceBanner/> determines its own visibility */}
<DormantWorkspaceBanner
workspace={workspace}
shouldRedisplayBanner={
getLocal("dismissedWorkspace") !== workspace.id
}
onDismiss={() => saveLocal("dismissedWorkspace", workspace.id)}
/>

{showAlertPendingInQueue && (
<Alert severity="info">
<AlertTitle>Workspace build is pending</AlertTitle>
Expand Down
3 changes: 3 additions & 0 deletions site/src/pages/WorkspacePage/WorkspaceNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Alert, AlertDetail } from "components/Alert/Alert";
import { FC } from "react";
import { useQuery } from "react-query";
import { WorkspacePermissions } from "./permissions";
import { DormantWorkspaceBanner } from "./DormantWorkspaceBanner";

type WorkspaceNotificationsProps = {
workspace: Workspace;
Expand Down Expand Up @@ -78,6 +79,8 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = (
</AlertDetail>
</Alert>
)}

<DormantWorkspaceBanner workspace={workspace} />
</>
);
};