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

Add Tooltip explaining that an app must be deployed before accessing it #582

Merged
merged 1 commit into from
Jun 20, 2022
Merged
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
30 changes: 22 additions & 8 deletions packages/toolpad-app/src/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Toolbar,
Typography,
Box,
Tooltip,
} from '@mui/material';
import * as React from 'react';
import { LoadingButton } from '@mui/lab';
Expand Down Expand Up @@ -228,6 +229,26 @@ function AppCard({ app, activeDeployment, onDelete }: AppCardProps) {
}
}, [appTitleInput, editingTitle]);

const openDisabled = !app || !activeDeployment;
let openButton = (
<Button
disabled={!app || !activeDeployment}
size="small"
component="a"
href={app ? `deploy/${app.id}` : ''}
>
Open
</Button>
);

if (openDisabled) {
openButton = (
<Tooltip title="The app hasn't been deployed yet">
<span>{openButton}</span>
</Tooltip>
);
}

return (
<React.Fragment>
<Card sx={{ gridColumn: 'span 1' }}>
Expand Down Expand Up @@ -278,14 +299,7 @@ function AppCard({ app, activeDeployment, onDelete }: AppCardProps) {
>
Edit
</Button>
<Button
disabled={!app || !activeDeployment}
size="small"
component="a"
href={app ? `deploy/${app.id}` : ''}
>
View
</Button>
{openButton}
</CardActions>
</Card>
<Menu
Expand Down