Skip to content

Commit

Permalink
feat(domains): use MainToolbar on domains list header MAASENG-2523 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ndv99 authored Jan 10, 2024
1 parent ed5cb56 commit 50cc175
Showing 1 changed file with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Button } from "@canonical/react-components";
import pluralize from "pluralize";
import { MainToolbar } from "@canonical/maas-react-components";
import { Button, Spinner } from "@canonical/react-components";
import { useSelector } from "react-redux";

import { DomainListSidePanelViews } from "../constants";

import SectionHeader from "app/base/components/SectionHeader";
import ModelListSubtitle from "app/base/components/ModelListSubtitle";
import { useFetchActions } from "app/base/hooks";
import type { SetSidePanelContent } from "app/base/side-panel-context";
import { actions as domainActions } from "app/store/domain";
Expand All @@ -24,25 +24,26 @@ const DomainListHeader = ({

useFetchActions([domainActions.fetch]);

let buttons: JSX.Element[] | null = [
<Button
data-testid="add-domain"
key="add-domain"
onClick={() =>
setSidePanelContent({ view: DomainListSidePanelViews.ADD_DOMAIN })
}
>
{Labels.AddDomains}
</Button>,
];

return (
<SectionHeader
buttons={buttons}
subtitle={`${pluralize("domain", domainCount, true)} available`}
subtitleLoading={!domainsLoaded}
title="DNS"
/>
<MainToolbar>
<MainToolbar.Title>DNS</MainToolbar.Title>
{domainsLoaded ? (
<ModelListSubtitle available={domainCount} modelName="domain" />
) : (
<Spinner text="Loading..." />
)}
<MainToolbar.Controls>
<Button
data-testid="add-domain"
key="add-domain"
onClick={() =>
setSidePanelContent({ view: DomainListSidePanelViews.ADD_DOMAIN })
}
>
{Labels.AddDomains}
</Button>
</MainToolbar.Controls>
</MainToolbar>
);
};

Expand Down

0 comments on commit 50cc175

Please sign in to comment.