-
Notifications
You must be signed in to change notification settings - Fork 44
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
✨ Archetypes management: Add navigation and placeholder page component #1308
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed25b21
Archetypes: Add navigation and placeholder page component
sjd78 f9746a5
Base Archetype model, rest functions, queries
sjd78 ef0d3f5
stub-new-work for archetypes with basic mock data
sjd78 27e81ed
Basic archetypes management table
sjd78 53aeb3b
PR review fix
sjd78 0c1db05
Breakout table column components to their own files
sjd78 5303609
PR review fix - remove unnecessary table options
sjd78 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useHistory } from "react-router-dom"; | ||
import { | ||
Button, | ||
ButtonVariant, | ||
EmptyState, | ||
EmptyStateBody, | ||
EmptyStateFooter, | ||
EmptyStateHeader, | ||
EmptyStateIcon, | ||
PageSection, | ||
PageSectionVariants, | ||
Text, | ||
TextContent, | ||
Toolbar, | ||
ToolbarContent, | ||
ToolbarGroup, | ||
ToolbarItem, | ||
} from "@patternfly/react-core"; | ||
import { Table, Tbody, Th, Thead, Tr, Td } from "@patternfly/react-table"; | ||
import { CubesIcon } from "@patternfly/react-icons"; | ||
|
||
import { AppPlaceholder } from "@app/components/AppPlaceholder"; | ||
import { ConditionalRender } from "@app/components/ConditionalRender"; | ||
import { FilterToolbar, FilterType } from "@app/components/FilterToolbar"; | ||
import { NotificationsContext } from "@app/components/NotificationsContext"; | ||
import { | ||
ConditionalTableBody, | ||
TableHeaderContentWithControls, | ||
TableRowContentWithControls, | ||
} from "@app/components/TableControls"; | ||
import { useLocalTableControls } from "@app/hooks/table-controls"; | ||
import { useFetchArchetypes } from "@app/queries/archetypes"; | ||
|
||
import ArchetypeApplicationsColumn from "./components/archetype-applications-column"; | ||
import ArchetypeDescriptionColumn from "./components/archetype-description-column"; | ||
import ArchetypeMaintainersColumn from "./components/archetype-maintainers-column"; | ||
import ArchetypeTagsColumn from "./components/archetype-tags-column"; | ||
|
||
const Archetypes: React.FC = () => { | ||
const { t } = useTranslation(); | ||
const history = useHistory(); | ||
const { pushNotification } = React.useContext(NotificationsContext); | ||
|
||
const { archetypes, isFetching, error: fetchError } = useFetchArchetypes(); | ||
|
||
const tableControls = useLocalTableControls({ | ||
idProperty: "id", | ||
items: archetypes, | ||
isLoading: isFetching, | ||
hasActionsColumn: true, | ||
|
||
columnNames: { | ||
name: t("terms.name"), | ||
description: t("terms.description"), | ||
tags: t("terms.tags"), | ||
maintainers: t("terms.maintainers"), | ||
applications: t("terms.applications"), | ||
}, | ||
|
||
filterCategories: [ | ||
{ | ||
key: "name", | ||
title: t("terms.name"), | ||
type: FilterType.search, | ||
placeholderText: | ||
t("actions.filterBy", { | ||
what: t("terms.name").toLowerCase(), | ||
}) + "...", | ||
getItemValue: (archetype) => { | ||
return archetype?.name ?? ""; | ||
}, | ||
}, | ||
// TODO: Add filter for archetype tags | ||
], | ||
|
||
sortableColumns: ["name"], | ||
getSortValues: (archetype) => ({ | ||
name: archetype.name ?? "", | ||
}), | ||
initialSort: { columnKey: "name", direction: "asc" }, | ||
|
||
hasPagination: false, // TODO: Add pagination | ||
}); | ||
const { | ||
currentPageItems, | ||
numRenderedColumns, | ||
propHelpers: { | ||
toolbarProps, | ||
filterToolbarProps, | ||
paginationToolbarItemProps, | ||
paginationProps, | ||
tableProps, | ||
getThProps, | ||
getTdProps, | ||
}, | ||
} = tableControls; | ||
|
||
// TODO: RBAC access checks need to be added. Only Architect (and Administrator) personas | ||
// TODO: should be able to create/edit archetypes. Every persona should be able to view | ||
// TODO: the archetypes. | ||
|
||
const CreateButton = () => ( | ||
<Button | ||
type="button" | ||
id="create-new-archetype" | ||
aria-label="Create new archetype" | ||
variant={ButtonVariant.primary} | ||
onClick={() => {}} // TODO: Add create archetype modal | ||
> | ||
{t("dialog.title.newArchetype")} | ||
</Button> | ||
); | ||
|
||
return ( | ||
<> | ||
<PageSection variant={PageSectionVariants.light}> | ||
<TextContent> | ||
<Text component="h1">{t("terms.archetypes")}</Text> | ||
</TextContent> | ||
</PageSection> | ||
<PageSection> | ||
<ConditionalRender | ||
when={isFetching && !(archetypes || fetchError)} | ||
then={<AppPlaceholder />} | ||
> | ||
<div | ||
style={{ | ||
backgroundColor: "var(--pf-v5-global--BackgroundColor--100)", | ||
}} | ||
> | ||
<Toolbar {...toolbarProps}> | ||
<ToolbarContent> | ||
<FilterToolbar {...filterToolbarProps} /> | ||
<ToolbarGroup variant="button-group"> | ||
<ToolbarItem> | ||
<CreateButton /> | ||
</ToolbarItem> | ||
</ToolbarGroup> | ||
{/* TODO: Add pagination */} | ||
</ToolbarContent> | ||
</Toolbar> | ||
|
||
<Table | ||
{...tableProps} | ||
id="archetype-table" | ||
aria-label="Archetype table" | ||
> | ||
<Thead> | ||
<Tr> | ||
<TableHeaderContentWithControls {...tableControls}> | ||
<Th {...getThProps({ columnKey: "name" })} /> | ||
<Th {...getThProps({ columnKey: "description" })} /> | ||
<Th {...getThProps({ columnKey: "tags" })} /> | ||
<Th {...getThProps({ columnKey: "maintainers" })} /> | ||
<Th {...getThProps({ columnKey: "applications" })} /> | ||
</TableHeaderContentWithControls> | ||
</Tr> | ||
</Thead> | ||
<ConditionalTableBody | ||
isLoading={isFetching} | ||
isError={!!fetchError} | ||
isNoData={currentPageItems.length === 0} | ||
noDataEmptyState={ | ||
<EmptyState variant="sm"> | ||
<EmptyStateHeader | ||
titleText="No archetypes have been created" | ||
headingLevel="h2" | ||
icon={<EmptyStateIcon icon={CubesIcon} />} | ||
/> | ||
<EmptyStateBody> | ||
Create a new archetype to get started. | ||
</EmptyStateBody> | ||
<EmptyStateFooter> | ||
<CreateButton /> | ||
</EmptyStateFooter> | ||
</EmptyState> | ||
} | ||
numRenderedColumns={numRenderedColumns} | ||
> | ||
{currentPageItems?.map((archetype, rowIndex) => ( | ||
<Tbody key={archetype.id}> | ||
<Tr> | ||
<TableRowContentWithControls | ||
{...tableControls} | ||
item={archetype} | ||
rowIndex={rowIndex} | ||
> | ||
<Td {...getTdProps({ columnKey: "name" })}> | ||
{archetype.name} | ||
</Td> | ||
<Td {...getTdProps({ columnKey: "description" })}> | ||
<ArchetypeDescriptionColumn archetype={archetype} /> | ||
</Td> | ||
<Td {...getTdProps({ columnKey: "tags" })}> | ||
<ArchetypeTagsColumn archetype={archetype} /> | ||
</Td> | ||
<Td {...getTdProps({ columnKey: "maintainers" })}> | ||
<ArchetypeMaintainersColumn archetype={archetype} /> | ||
</Td> | ||
<Td {...getTdProps({ columnKey: "applications" })}> | ||
<ArchetypeApplicationsColumn archetype={archetype} /> | ||
</Td> | ||
<Td>{/* TODO: Add kebab action menu */}</Td> | ||
</TableRowContentWithControls> | ||
</Tr> | ||
</Tbody> | ||
))} | ||
</ConditionalTableBody> | ||
</Table> | ||
|
||
{/* TODO: Add pagination */} | ||
</div> | ||
</ConditionalRender> | ||
</PageSection> | ||
|
||
{/* TODO: Add create/edit modal */} | ||
{/* TODO: Add duplicate confirm modal */} | ||
{/* TODO: Add delete confirm modal */} | ||
</> | ||
); | ||
}; | ||
|
||
export default Archetypes; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are going to be CategorizedTag but probably TBD what that data model will look like in its final form.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure there will be a bunch of those kinds of mismatches, but if we make some good guesses, we shouldn't be far off. I just named it after this mockup:
![image](https://private-user-images.githubusercontent.com/3985964/265065277-a9d0e410-cab5-4a90-a2a2-4588eff8a895.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNTM4NzksIm5iZiI6MTczOTA1MzU3OSwicGF0aCI6Ii8zOTg1OTY0LzI2NTA2NTI3Ny1hOWQwZTQxMC1jYWI1LTRhOTAtYTJhMi00NTg4ZWZmOGE4OTUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDhUMjIyNjE5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDZkMzg2OTNkNDRhZmU0NDk1NTNiZjkxZjkxZGZmYjFkYjA3MGE3YWVjZjIxNDcxYjE1NmMxOGZiYjdmOWU1MSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.R3AoYRVkW1bHUobYRGYmDsHaQ-hOcJYXhcPxxE7IPmk)