Skip to content

Commit

Permalink
feat(images): moved GenericTable.tsx and subcomponents to base/compon…
Browse files Browse the repository at this point in the history
…ents, fixed th-td alignment for SMImagesTable.tsx
  • Loading branch information
abuyukyi101198 committed Jan 10, 2025
1 parent 03740f9 commit 8fbfc7c
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const GenericTable = <T,>({
))}
</thead>
{table.getRowModel().rows.length < 1 ? (
<div data-testid="no-data">{noData}</div>
noData
) : (
<DynamicTable.Body>
{table.getRowModel().rows.map((row) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import type { Row } from "@tanstack/react-table";
import type { Mock } from "vitest";
import { describe } from "vitest";

import TableCheckbox from "@/app/images/components/GenericTable/TableCheckbox/TableCheckbox";
import TableCheckbox from "./TableCheckbox";

import type { Image } from "@/app/images/types";
import * as factory from "@/testing/factories";
import { render, userEvent, screen } from "@/testing/utils";
Expand Down
11 changes: 11 additions & 0 deletions src/app/base/components/GenericTable/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.generic-table {
table-layout: auto;
th:not(th:nth-of-type(1), th:nth-of-type(2), th:last-of-type) {
padding-left: 1.5rem;
}

.individual-row {
width: calc(100% - 1rem);
margin-left: 1rem;
}
}
22 changes: 0 additions & 22 deletions src/app/images/components/GenericTable/_index.scss

This file was deleted.

4 changes: 3 additions & 1 deletion src/app/images/components/SMImagesTable/SMImagesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import useImageTableColumns, {
filterHeaders,
} from "./useImageTableColumns/useImageTableColumns";

import GenericTable from "@/app/base/components/GenericTable";
import { useSidePanel } from "@/app/base/side-panel-context";
import GenericTable from "@/app/images/components/GenericTable";
import { ImageSidePanelViews } from "@/app/images/constants";
import type { Image } from "@/app/images/types";
import bootResourceSelectors from "@/app/store/bootresource/selectors";
import type { BootResource } from "@/app/store/bootresource/types";
import { splitResourceName } from "@/app/store/bootresource/utils";
import configSelectors from "@/app/store/config/selectors";

import "./_index.scss";

const getImages = (resources: BootResource[]): Image[] => {
return resources.map((resource) => {
const { os } = splitResourceName(resource.name);
Expand Down
5 changes: 5 additions & 0 deletions src/app/images/components/SMImagesTable/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.generic-table {
.status {
width: 13rem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ it("returns the correct number of columns", () => {
"release",
"architecture",
"size",
"status",
"canDeployToMemory",
"status",
"action",
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type {
import pluralize from "pluralize";

import DoubleRow from "@/app/base/components/DoubleRow";
import GroupRowActions from "@/app/base/components/GenericTable/GroupRowActions";
import TableCheckbox from "@/app/base/components/GenericTable/TableCheckbox";
import TableActions from "@/app/base/components/TableActions";
import TooltipButton from "@/app/base/components/TooltipButton";
import GroupRowActions from "@/app/images/components/GenericTable/GroupRowActions";
import TableCheckbox from "@/app/images/components/GenericTable/TableCheckbox";
import type { Image } from "@/app/images/types";

export type ImageColumnDef = ColumnDef<Image, Partial<Image>>;
Expand Down Expand Up @@ -101,6 +101,30 @@ const useImageTableColumns = ({
enableSorting: false,
header: () => "Size",
},
{
id: "canDeployToMemory",
accessorKey: "canDeployToMemory",
enableSorting: false,
header: () => "Deployable",
cell: ({
getValue,
}: {
getValue: Getter<Image["canDeployToMemory"]>;
}) =>
getValue() ? (
<TooltipButton
iconName="task-outstanding"
iconProps={{ "aria-label": "supported" }}
message="This image can be deployed in memory."
/>
) : (
<TooltipButton
iconName="close"
iconProps={{ "aria-label": "not supported" }}
message="This image cannot be deployed in memory."
/>
),
},
{
id: "status",
accessorKey: "status",
Expand All @@ -126,30 +150,6 @@ const useImageTableColumns = ({
);
},
},
{
id: "canDeployToMemory",
accessorKey: "canDeployToMemory",
enableSorting: false,
header: () => "Deployable",
cell: ({
getValue,
}: {
getValue: Getter<Image["canDeployToMemory"]>;
}) =>
getValue() ? (
<TooltipButton
iconName="task-outstanding"
iconProps={{ "aria-label": "supported" }}
message="This image can be deployed in memory."
/>
) : (
<TooltipButton
iconName="close"
iconProps={{ "aria-label": "not supported" }}
message="This image cannot be deployed in memory."
/>
),
},
{
id: "action",
accessorKey: "id",
Expand Down

0 comments on commit 8fbfc7c

Please sign in to comment.