Skip to content

Commit

Permalink
chore: Adjusted detail page titles for better ux consistency
Browse files Browse the repository at this point in the history
- Addressed "lag" in loading time by only rendering the title when the instance has loaded.
- Added breadcrumb header to invalid instance page.
- Minor logic alterations to provide reasoning as to why invalid instances cannot be renamed.

Signed-off-by: Nkeiruka <[email protected]>
  • Loading branch information
Kxiru committed Jun 21, 2024
1 parent 4e6a3be commit c6a61a4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 35 deletions.
16 changes: 10 additions & 6 deletions src/components/RenameHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const RenameHeader: FC<Props> = ({
return (
<div className="p-panel__header rename-header">
<h1 className="u-off-screen">{name}</h1>
{isLoaded ? (
{/* {isLoaded ? ( */}
<div className={classnames("p-panel__title", titleClassName)}>
<nav
key="breadcrumbs"
Expand All @@ -57,7 +57,10 @@ const RenameHeader: FC<Props> = ({
>
<ol className="p-breadcrumbs__items">
{parentItems.map((item, key) => (
<li className="p-breadcrumbs__item" key={key}>
<li
className="p-heading--4 u-no-margin--bottom continuous-breadcrumb"
key={key}
>
{item}
</li>
))}
Expand Down Expand Up @@ -99,7 +102,7 @@ const RenameHeader: FC<Props> = ({
</li>
) : (
<li
className="p-breadcrumbs__item name u-truncate"
className="p-heading--4 u-no-margin--bottom name continuous-breadcrumb"
onClick={enableRename}
title={`Rename ${name}`}
>
Expand All @@ -115,9 +118,10 @@ const RenameHeader: FC<Props> = ({
</nav>
{!formik?.values.isRenaming && centerControls}
</div>
) : (
<h4 className="p-panel__title">{name}</h4>
)}
{/* // )
// : (
// <h4 className="p-panel__title">{name}</h4>
// )} */}
{isLoaded && !formik?.values.isRenaming && (
<div className="p-panel__controls">{controls}</div>
)}
Expand Down
1 change: 1 addition & 0 deletions src/pages/instances/InstanceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const InstanceDetail: FC = () => {
name={name}
instance={instance}
project={project}
isLoading = {isLoading}
/>
}
contentClassName="detail-page"
Expand Down
68 changes: 40 additions & 28 deletions src/pages/instances/InstanceDetailHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ interface Props {
name: string;
instance?: LxdInstance;
project: string;
isLoading: boolean;
}

const InstanceDetailHeader: FC<Props> = ({ name, instance, project }) => {
const InstanceDetailHeader: FC<Props> = ({
name,
instance,
project,
isLoading,
}) => {
const eventQueue = useEventQueue();
const navigate = useNavigate();
const toastNotify = useToastNotification();
Expand Down Expand Up @@ -87,33 +93,39 @@ const InstanceDetailHeader: FC<Props> = ({ name, instance, project }) => {
});

return (
<RenameHeader
name={name}
titleClassName="instance-detail-title"
parentItems={[
<Link to={`/ui/project/${project}/instances`} key={1}>
Instances
</Link>,
]}
renameDisabledReason={
instance?.status !== "Stopped"
? "Stop the instance to rename"
: undefined
}
centerControls={
instance ? (
<div>
<i className="status u-text--muted">{instance.status}</i>
<InstanceStateActions key="state" instance={instance} />
</div>
) : null
}
controls={
instance ? <DeleteInstanceBtn key="delete" instance={instance} /> : null
}
isLoaded={Boolean(instance)}
formik={formik}
/>
!isLoading && (
<RenameHeader
name={name}
titleClassName="instance-detail-title"
parentItems={[
<Link to={`/ui/project/${project}/instances`} key={1}>
Instances
</Link>,
]}
renameDisabledReason={
!Boolean(instance)
? "Invalid Instance: Cannot be renamed"
: instance?.status !== "Stopped"
? "Stop the instance to rename"
: undefined
}
centerControls={
instance ? (
<div>
<i className="status u-text--muted">{instance.status}</i>
<InstanceStateActions key="state" instance={instance} />
</div>
) : null
}
controls={
instance ? (
<DeleteInstanceBtn key="delete" instance={instance} />
) : null
}
isLoaded={Boolean(instance)}
formik={formik}
/>
)
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/sass/_rename_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$colors--light-theme--background-hover,
$colors--light-theme--background-hover
)
no-repeat 1rem;
no-repeat;
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/sass/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ body {

.p-breadcrumbs__items {
margin-bottom: 0;

.continuous-breadcrumb {
display: inline;
}
}

.p-breadcrumbs__item {
Expand All @@ -213,6 +217,19 @@ body {
padding-top: 0;
}

.continuous-breadcrumb::after {
content: "/";
padding: 0 5px; // Adjust spacing as needed
}

.continuous-breadcrumb:last-child::after {
content: ""; // Remove the slash from the last item
}

.p-breadcrumbs__item::before {
content: "";
}

.p-breadcrumbs__item:first-of-type {
margin-right: $sph--x-small;
}
Expand Down

0 comments on commit c6a61a4

Please sign in to comment.