Skip to content
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

Combine: owner and access columns, fixes #404 #405 #428 #430 #876

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions horreum-web/src/components/AccessIconOnly.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<LockedIcon style={{ fill: "var(" + color + ")" }} />
{"\u00A0"}
<Tooltip content={explanation} />
</>
)
}
22 changes: 14 additions & 8 deletions horreum-web/src/domain/runs/TestDatasets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<DatasetSummary> &
UseTableOptions<DatasetSummary> &
Expand Down Expand Up @@ -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) => <AccessIcon access={arg.cell.value} />,
id: "owner",
accessor: (row: DatasetSummary) => ({
owner: row.owner,
access: row.access,
}),
Cell: (arg: C) => (
<>
{teamToName(arg.cell.value.owner)}
<span style={{ marginLeft: '8px' }}>
<AccessIconOnly access={arg.cell.value.access} />
</span>
</>
),
},
]

Expand Down
22 changes: 14 additions & 8 deletions horreum-web/src/domain/runs/TestRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<RunSummary> &
UseTableOptions<RunSummary> &
Expand Down Expand Up @@ -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) => <AccessIcon access={arg.cell.value} />,
id: "owner",
accessor: (row: RunSummary) => ({
owner: row.owner,
access: row.access,
}),
Cell: (arg: C) => (
<>
{teamToName(arg.cell.value.owner)}
<span style={{ marginLeft: '8px' }}>
<AccessIconOnly access={arg.cell.value.access} />
</span>
</>
),
},
{
Header: "Actions",
Expand Down
23 changes: 15 additions & 8 deletions horreum-web/src/domain/schemas/AllSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Schema>

Expand Down Expand Up @@ -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) => <AccessIcon access={arg.cell.value} />,
id: "owner",
accessor: (row: Schema) => ({
owner: row.owner,
access: row.access,
}),
Cell: (arg: C) => (
<>
{teamToName(arg.cell.value.owner)}
<span style={{ marginLeft: '8px' }}>
<AccessIconOnly access={arg.cell.value.access} />
</span>
</>
),
},
{
Header: "Actions",
Expand Down
22 changes: 16 additions & 6 deletions horreum-web/src/domain/tests/AllTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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) => <AccessIcon access={arg.cell.value} />,
Header: "Owner",
id: "owner",
accessor: (row: TestStorage) => ({
owner: row.owner,
access: row.access,
}),
Cell: (arg: C) => (
<>
{teamToName(arg.cell.value.owner)}
<span style={{ marginLeft: '8px' }}>
<AccessIconOnly access={arg.cell.value.access} />
</span>
</>
),
},
{
Header: "Actions",
Expand Down