Skip to content

Commit

Permalink
Allow for showing internal topics from the empty state when no topics…
Browse files Browse the repository at this point in the history
… exist

Fixes #672
  • Loading branch information
riccardo-forina authored and hemahg committed May 22, 2024
1 parent 4e1d49e commit 67c7f37
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions ui/components/TopicsTable/TopicsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function TopicsTable({
<EmptyStateNoTopics
canCreate={isReadOnly === false}
createHref={`${baseurl}/create`}
onShowHiddenTopics={() => onInternalTopicsChange(true)}
/>
}
emptyStateNoResults={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ export default {
} as Meta<typeof Comp>;
type Story = StoryObj<typeof Comp>;

export const EmptyStateNoTopics: Story = {};
export const Default: Story = {};

export const CanCreate: Story = {
args: {
canCreate: true,
createHref: "#/sample",
},
};
20 changes: 13 additions & 7 deletions ui/components/TopicsTable/components/EmptyStateNoTopics.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { ButtonLink } from "@/components/Navigation/ButtonLink";
import {
Button,
EmptyState,
EmptyStateActions,
EmptyStateBody,
EmptyStateFooter,
EmptyStateHeader,
EmptyStateIcon,
} from "@/libs/patternfly/react-core";
import { PlusCircleIcon } from "@patternfly/react-icons";
import { PlusCircleIcon } from "@/libs/patternfly/react-icons";
import { useTranslations } from "next-intl";

export function EmptyStateNoTopics({
canCreate,
createHref,
onShowHiddenTopics,
}: {
canCreate: boolean;
createHref: string;
onShowHiddenTopics: () => void;
}) {
const t = useTranslations();
return (
Expand All @@ -28,15 +31,18 @@ export function EmptyStateNoTopics({
<EmptyStateBody>
{t("EmptyStateNoTopics.to_get_started_create_your_first_topic")}{" "}
</EmptyStateBody>
{canCreate && (
<EmptyStateFooter>
<EmptyStateActions>
<EmptyStateFooter>
<EmptyStateActions>
{canCreate && (
<ButtonLink variant="primary" href={createHref}>
{t("EmptyStateNoTopics.create_a_topic")}
</ButtonLink>
</EmptyStateActions>
</EmptyStateFooter>
)}
)}
<Button variant="secondary" onClick={onShowHiddenTopics}>
{t("EmptyStateNoTopics.show_hidden_topics")}
</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
);
}
3 changes: 2 additions & 1 deletion ui/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@
},
"EmptyStateNoTopics": {
"to_get_started_create_your_first_topic": "To get started, create your first topic",
"create_a_topic": "Create a topic"
"create_a_topic": "Create a topic",
"show_hidden_topics": "Show hidden topics"
},
"ApplicationError": {
"body": "Try clicking the button below, or refreshing the page. If the problem persists, contact your organization administrator.",
Expand Down

0 comments on commit 67c7f37

Please sign in to comment.