Skip to content

Commit

Permalink
In schema viewer, updated open list view check to be menu agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalabbad committed Oct 25, 2024
1 parent 0a875a4 commit 52933d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions frontend/app/src/config/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const MENU_EXCLUDELIST = [
"CoreDataValidator",
"CoreRepositoryValidator",
"CoreArtifactValidator",
"LineageOwner",
"LineageSource",
];

export const NODE_PATH_EXCLUDELIST = ["property"];
Expand Down
8 changes: 6 additions & 2 deletions frontend/app/src/screens/schema/schema-help-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { INFRAHUB_DOC_LOCAL } from "@/config/config";
import { MENU_EXCLUDELIST } from "@/config/constants";
import { IModelSchema, menuFlatAtom } from "@/state/atoms/schema.atom";
import { constructPath } from "@/utils/fetch";
import { getObjectDetailsUrl2 } from "@/utils/objects";
import { Icon } from "@iconify-icon/react";
import { useAtomValue } from "jotai/index";
import { Link } from "react-router-dom";
Expand All @@ -20,6 +22,8 @@ export const SchemaHelpMenu = ({ schema }: SchemaHelpMenuProps) => {
const menuItems = useAtomValue(menuFlatAtom);
const schemaInMenu = menuItems.find(({ label }) => label === schema.label);

const isListViewDisabled = MENU_EXCLUDELIST.includes(schema.kind as string);

const documentationUrl = schema.documentation
? `${INFRAHUB_DOC_LOCAL}${schema.documentation}`
: INFRAHUB_DOC_LOCAL;
Expand All @@ -42,8 +46,8 @@ export const SchemaHelpMenu = ({ schema }: SchemaHelpMenuProps) => {
</Link>
</DropdownMenuItem>

<DropdownMenuItem disabled={!schemaInMenu} asChild>
<Link to={objectListUrl} className="flex gap-2">
<DropdownMenuItem disabled={isListViewDisabled} asChild>
<Link to={getObjectDetailsUrl2(schema.kind as string)} className="flex gap-2">
<Icon icon="mdi:table-eye" className="text-lg text-custom-blue-700" />
Open list view
</Link>
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/src/utils/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export const getObjectDetailsUrl2 = (
overrideParams?: overrideQueryParams[]
) => {
if (objectKind === IP_PREFIX_GENERIC) {
return constructPathForIpam(`${IPAM_ROUTE.PREFIXES}/${objectId}`, overrideParams);
return constructPathForIpam(`${IPAM_ROUTE.PREFIXES}/${objectId ?? ""}`, overrideParams);
}

if (objectKind === IP_ADDRESS_GENERIC) {
return constructPathForIpam(`${IPAM_ROUTE.ADDRESSES}/${objectId}`, [
return constructPathForIpam(`${IPAM_ROUTE.ADDRESSES}/${objectId ?? ""}`, [
{ name: IPAM_QSP.TAB, value: "ip-details" },
...(overrideParams ?? []),
]);
Expand All @@ -45,11 +45,11 @@ export const getObjectDetailsUrl2 = (
const inheritFrom = schema.inherit_from;

if (inheritFrom?.includes(IP_PREFIX_GENERIC)) {
return constructPathForIpam(`${IPAM_ROUTE.PREFIXES}/${objectId}`, overrideParams);
return constructPathForIpam(`${IPAM_ROUTE.PREFIXES}/${objectId ?? ""}`, overrideParams);
}

if (inheritFrom?.includes(IP_ADDRESS_GENERIC)) {
return constructPathForIpam(`${IPAM_ROUTE.ADDRESSES}/${objectId}`, [
return constructPathForIpam(`${IPAM_ROUTE.ADDRESSES}/${objectId ?? ""}`, [
{ name: IPAM_QSP.TAB, value: "ip-details" },
...(overrideParams ?? []),
]);
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/tests/e2e/role-management/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.describe("Role management - READ", () => {

await test.step("check groups view", async () => {
await page.getByRole("link", { name: "Groups 2" }).click();
await expect(page.getByRole("cell", { name: "Administrators" })).toBeVisible();
await expect(page.getByRole("cell", { name: "Super Administrators" }).first()).toBeVisible();
await expect(page.getByRole("button", { name: "+4" })).toBeVisible();
});

Expand Down

0 comments on commit 52933d7

Please sign in to comment.