From ade0f088630249f3712ee13923de01941e0cafda Mon Sep 17 00:00:00 2001 From: Shivam Sharma Date: Wed, 1 Nov 2023 14:46:14 +0530 Subject: [PATCH] Combine: owner and access columns, fixes #404 #405 #428 #430 Combine: owner and access columns, fixes #404 #405 #428 #430 --- horreum-web/src/components/AccessIconOnly.tsx | 37 +++++++++++++++++++ horreum-web/src/domain/runs/TestDatasets.tsx | 22 +++++++---- horreum-web/src/domain/runs/TestRuns.tsx | 22 +++++++---- horreum-web/src/domain/schemas/AllSchema.tsx | 23 ++++++++---- horreum-web/src/domain/tests/AllTests.tsx | 22 ++++++++--- 5 files changed, 96 insertions(+), 30 deletions(-) create mode 100644 horreum-web/src/components/AccessIconOnly.tsx diff --git a/horreum-web/src/components/AccessIconOnly.tsx b/horreum-web/src/components/AccessIconOnly.tsx new file mode 100644 index 000000000..13db6c23f --- /dev/null +++ b/horreum-web/src/components/AccessIconOnly.tsx @@ -0,0 +1,37 @@ +import { Tooltip } from "@patternfly/react-core" +import { LockedIcon } from "@patternfly/react-icons" +import { Access } from "../api" + +export default function AccessIcon({ access }: { access: Access }) { + let color + let explanation + switch (access) { + case Access.Public: { + color = "--pf-global--success-color--200" + explanation = "Anyone can view this." + break + } + case Access.Protected: { + color = "--pf-global--warning-color--100" + explanation = "Only authenticated (logged in) users can view this." + break + } + case Access.Private: { + color = "--pf-global--danger-color--100" + explanation = "Only users from the owning team can view this." + break + } + default: { + color = "--pf-global--icon--Color--light" + explanation = "Unknown" + break + } + } + return ( + <> + + {"\u00A0"} + + + ) +} diff --git a/horreum-web/src/domain/runs/TestDatasets.tsx b/horreum-web/src/domain/runs/TestDatasets.tsx index 00fc36450..8c7ffa4bd 100644 --- a/horreum-web/src/domain/runs/TestDatasets.tsx +++ b/horreum-web/src/domain/runs/TestDatasets.tsx @@ -33,7 +33,6 @@ import { teamsSelector, teamToName, tokenSelector } from "../../auth" import { fetchTest } from "../tests/actions" import { get } from "../tests/selectors" -import AccessIcon from "../../components/AccessIcon" import Table from "../../components/Table" import { CellProps, @@ -53,6 +52,7 @@ import LabelsSelect, { SelectedLabels } from "../../components/LabelsSelect" import ViewSelect from "../../components/ViewSelect" import {viewsSelector} from "./selectors"; import * as actions from "../tests/actions"; +import AccessIconOnly from "../../components/AccessIconOnly" type C = CellProps & UseTableOptions & @@ -112,13 +112,19 @@ const staticColumns: DatasetColumn[] = [ }, { Header: "Owner", - accessor: "owner", - Cell: (arg: C) => teamToName(arg.cell.value), - }, - { - Header: "Access", - accessor: "access", - Cell: (arg: C) => , + id: "owner", + accessor: (row: DatasetSummary) => ({ + owner: row.owner, + access: row.access, + }), + Cell: (arg: C) => ( + <> + {teamToName(arg.cell.value.owner)} + + + + + ), }, ] diff --git a/horreum-web/src/domain/runs/TestRuns.tsx b/horreum-web/src/domain/runs/TestRuns.tsx index 303e563f8..ee4d7093c 100644 --- a/horreum-web/src/domain/runs/TestRuns.tsx +++ b/horreum-web/src/domain/runs/TestRuns.tsx @@ -31,7 +31,6 @@ import { alertAction } from "../../alerts" import { fetchTest } from "../tests/actions" import { get } from "../tests/selectors" -import AccessIcon from "../../components/AccessIcon" import Table from "../../components/Table" import { CellProps, @@ -46,6 +45,7 @@ import { RunSummary } from "../../api" import { NoSchemaInRun } from "./NoSchema" import { Description, ExecutionTime, Menu } from "./components" import SchemaList from "./SchemaList" +import AccessIconOnly from "../../components/AccessIconOnly" type C = CellProps & UseTableOptions & @@ -125,13 +125,19 @@ const tableColumns: RunColumn[] = [ }, { Header: "Owner", - accessor: "owner", - Cell: (arg: C) => teamToName(arg.cell.value), - }, - { - Header: "Access", - accessor: "access", - Cell: (arg: C) => , + id: "owner", + accessor: (row: RunSummary) => ({ + owner: row.owner, + access: row.access, + }), + Cell: (arg: C) => ( + <> + {teamToName(arg.cell.value.owner)} + + + + + ), }, { Header: "Actions", diff --git a/horreum-web/src/domain/schemas/AllSchema.tsx b/horreum-web/src/domain/schemas/AllSchema.tsx index ceca324b7..355bf9972 100644 --- a/horreum-web/src/domain/schemas/AllSchema.tsx +++ b/horreum-web/src/domain/schemas/AllSchema.tsx @@ -9,13 +9,14 @@ import { alertAction } from "../../alerts" import { useTester, teamsSelector, teamToName } from "../../auth" import { noop } from "../../utils" import Table from "../../components/Table" -import AccessIcon from "../../components/AccessIcon" + import ActionMenu, { useShareLink, useChangeAccess, useDelete } from "../../components/ActionMenu" import ButtonLink from "../../components/ButtonLink" import { CellProps, Column } from "react-table" import { SchemaDispatch } from "./reducers" import {Access, SortDirection, SchemaQueryResult, Schema, schemaApi} from "../../api" import SchemaImportButton from "./SchemaImportButton" +import AccessIconOnly from "../../components/AccessIconOnly" type C = CellProps @@ -62,13 +63,19 @@ export default function AllSchema() { }, { Header: "Owner", - accessor: "owner", - Cell: (arg: C) => teamToName(arg.cell.value), - }, - { - Header: "Access", - accessor: "access", - Cell: (arg: C) => , + id: "owner", + accessor: (row: Schema) => ({ + owner: row.owner, + access: row.access, + }), + Cell: (arg: C) => ( + <> + {teamToName(arg.cell.value.owner)} + + + + + ), }, { Header: "Actions", diff --git a/horreum-web/src/domain/tests/AllTests.tsx b/horreum-web/src/domain/tests/AllTests.tsx index 9c795c93f..4a5d30c1d 100644 --- a/horreum-web/src/domain/tests/AllTests.tsx +++ b/horreum-web/src/domain/tests/AllTests.tsx @@ -32,7 +32,6 @@ import { import * as selectors from "./selectors" import Table from "../../components/Table" -import AccessIcon from "../../components/AccessIcon" import { alertAction } from "../../alerts" import ActionMenu, { MenuItem, ActionMenuProps, useChangeAccess } from "../../components/ActionMenu" import ButtonLink from "../../components/ButtonLink" @@ -47,7 +46,8 @@ import { isAuthenticatedSelector, useTester, teamToName, teamsSelector, userProf import { CellProps, Column, UseSortByColumnOptions } from "react-table" import { TestStorage, TestDispatch } from "./reducers" import { noop } from "../../utils" -import {SortDirection, testApi, TestQueryResult, Access } from "../../api" +import { SortDirection, testApi, TestQueryResult, Access } from "../../api" +import AccessIconOnly from "../../components/AccessIconOnly" type WatchDropdownProps = { id: number @@ -353,11 +353,21 @@ export default function AllTests() { ) }, }, - { Header: "Owner", accessor: "owner", Cell: (arg: C) => teamToName(arg.cell.value) }, { - Header: "Access", - accessor: "access", - Cell: (arg: C) => , + Header: "Owner", + id: "owner", + accessor: (row: TestStorage) => ({ + owner: row.owner, + access: row.access, + }), + Cell: (arg: C) => ( + <> + {teamToName(arg.cell.value.owner)} + + + + + ), }, { Header: "Actions",