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

Austenem/CAT-767 update workspace toast #3514

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions CHANGELOG-update-workspace-toast.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Update language and add an action button to toasts for successful workspace creation.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';

function WorkspaceToastSuccessMessage(id: number) {
austenem marked this conversation as resolved.
Show resolved Hide resolved
return (
<Stack sx={{ maxWidth: '22rem' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this maxWidth in particular?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was from the designs - without a maxWidth, the toast stretches across the bottom of the screen and is hard to read. Is there a better method for setting width options like these?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit better than the 100% width - it still stretches out further than the designs, because I think the max-content is higher than 20rem. The <length-percentage> parameter doesn't seem to change anything, which is a bit odd:

Screenshot 2024-08-23 at 2 05 08 PM

<Typography>
Workspace successfully launched in a new tab. If the tab didn&apos;t open, please check your pop-up blocker
settings and relaunch your workspace.
</Typography>
<Stack direction="row" justifyContent="flex-end" marginTop={1}>
austenem marked this conversation as resolved.
Show resolved Hide resolved
<Button
href={`/workspaces/${id}`}
variant="contained"
austenem marked this conversation as resolved.
Show resolved Hide resolved
sx={{
backgroundColor: 'transparent',
boxShadow: 'none',
':hover': { backgroundColor: 'transparent', boxShadow: 'none' },
}}
>
<Typography variant="button">View Workspace Detail Page</Typography>
austenem marked this conversation as resolved.
Show resolved Hide resolved
</Button>
austenem marked this conversation as resolved.
Show resolved Hide resolved
</Stack>
</Stack>
);
}

export default WorkspaceToastSuccessMessage;
5 changes: 4 additions & 1 deletion context/app/static/js/components/workspaces/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo } from 'react';
import { KeyedMutator, useSWRConfig } from 'swr';

import { useSnackbarActions } from 'js/shared-styles/snackbars';
import { useLaunchWorkspaceStore } from 'js/stores/useWorkspaceModalStore';
import { useAppContext } from 'js/components/Contexts';
Expand Down Expand Up @@ -28,6 +29,7 @@ import {
} from './api';
import { MergedWorkspace, Workspace, CreateTemplatesResponse } from './types';
import { useWorkspaceTemplates } from './NewWorkspaceDialog/hooks';
import WorkspaceToastSuccessMessage from './WorkspaceToastSuccessMessage';

interface UseWorkspacesListTypes<T> {
workspaces: Workspace[];
Expand Down Expand Up @@ -271,7 +273,8 @@ export function useCreateAndLaunchWorkspace() {
toastError('Failed to create workspace.');
return;
}
toastSuccess('Workspace successfully created.');

toastSuccess(WorkspaceToastSuccessMessage(workspace.id));

try {
await startNewWorkspace({ workspace, jobTypeId: body.default_job_type, templatePath });
Expand Down
Loading