-
Notifications
You must be signed in to change notification settings - Fork 20
Frontend: upstreamable: Add placeholder buttons to prevent layout shift during project loading #393
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
base: headlamp-downstream
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,20 @@ interface ProjectDeleteButtonProps { | |
| export function ProjectDeleteButton({ project, buttonStyle }: ProjectDeleteButtonProps) { | ||
| const { t } = useTranslation(); | ||
| const [openDialog, setOpenDialog] = useState(false); | ||
| const [namespaces] = Namespace.useList({ clusters: project.clusters }); | ||
| const [authResolved, setAuthResolved] = useState(false); | ||
| const [namespaces, error] = Namespace.useList({ clusters: project.clusters }); | ||
|
|
||
| // While namespaces are loading, show a placeholder to avoid layout shift mid-load | ||
| if (!namespaces && !error) { | ||
| return ( | ||
| <ActionButton | ||
| description={t('Delete project')} | ||
| buttonStyle={buttonStyle} | ||
| onClick={() => {}} | ||
| icon="mdi:delete" | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| const projectNamespaces = | ||
| namespaces?.filter(ns => project.namespaces.includes(ns.metadata.name)) ?? []; | ||
|
|
@@ -41,19 +54,38 @@ export function ProjectDeleteButton({ project, buttonStyle }: ProjectDeleteButto | |
| } | ||
|
|
||
| return ( | ||
| <AuthVisible item={projectNamespaces[0]} authVerb="update"> | ||
| <ActionButton | ||
| description={t('Delete project')} | ||
| buttonStyle={buttonStyle} | ||
| onClick={() => setOpenDialog(true)} | ||
| icon="mdi:delete" | ||
| /> | ||
| <ProjectDeleteDialog | ||
| open={openDialog} | ||
| project={project} | ||
| onClose={() => setOpenDialog(false)} | ||
| namespaces={projectNamespaces} | ||
| /> | ||
| </AuthVisible> | ||
| <> | ||
| {!authResolved && ( | ||
| <ActionButton | ||
| description={t('Delete project')} | ||
| buttonStyle={buttonStyle} | ||
| onClick={() => {}} | ||
| icon="mdi:delete" | ||
| /> | ||
| )} | ||
|
tejhan marked this conversation as resolved.
|
||
| <AuthVisible | ||
| item={projectNamespaces[0]} | ||
| authVerb="update" | ||
| onAuthResult={() => setAuthResolved(true)} | ||
| onError={() => setAuthResolved(true)} | ||
| > | ||
| {authResolved && ( | ||
| <> | ||
| <ActionButton | ||
| description={t('Delete project')} | ||
| buttonStyle={buttonStyle} | ||
| onClick={() => setOpenDialog(true)} | ||
| icon="mdi:delete" | ||
| /> | ||
| <ProjectDeleteDialog | ||
| open={openDialog} | ||
| project={project} | ||
| onClose={() => setOpenDialog(false)} | ||
| namespaces={projectNamespaces} | ||
| /> | ||
| </> | ||
| )} | ||
| </AuthVisible> | ||
|
Comment on lines
+58
to
+88
|
||
| </> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.