From e1f84436ab103f91ea0afc6301c900a288815580 Mon Sep 17 00:00:00 2001
From: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
Date: Mon, 21 Mar 2022 12:34:36 -0400
Subject: [PATCH] Device user cannot view all hosts software (#4710)
---
.../pages/hosts/DeviceUserPage/DeviceUserPage.tsx | 8 +++++++-
frontend/pages/hosts/SoftwareTab/SoftwareTab.tsx | 4 +++-
.../pages/hosts/SoftwareTab/SoftwareTableConfig.tsx | 11 +++++++++--
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/frontend/pages/hosts/DeviceUserPage/DeviceUserPage.tsx b/frontend/pages/hosts/DeviceUserPage/DeviceUserPage.tsx
index 9661c05f9b..4e63e72ff4 100644
--- a/frontend/pages/hosts/DeviceUserPage/DeviceUserPage.tsx
+++ b/frontend/pages/hosts/DeviceUserPage/DeviceUserPage.tsx
@@ -255,7 +255,13 @@ const DeviceUserPage = ({
};
const renderSoftware = () => {
- return ;
+ return (
+
+ );
};
const renderRefetch = () => {
diff --git a/frontend/pages/hosts/SoftwareTab/SoftwareTab.tsx b/frontend/pages/hosts/SoftwareTab/SoftwareTab.tsx
index 2e5b59a78c..9a1bc8d987 100644
--- a/frontend/pages/hosts/SoftwareTab/SoftwareTab.tsx
+++ b/frontend/pages/hosts/SoftwareTab/SoftwareTab.tsx
@@ -18,11 +18,13 @@ const baseClass = "host-details";
interface ISoftwareTableProps {
isLoading: boolean;
software: ISoftware[];
+ deviceUser?: boolean;
}
const SoftwareTable = ({
isLoading,
software,
+ deviceUser,
}: ISoftwareTableProps): JSX.Element => {
const [filterName, setFilterName] = useState("");
const [filterVuln, setFilterVuln] = useState(false);
@@ -58,7 +60,7 @@ const SoftwareTable = ({
);
};
- const tableHeaders = generateSoftwareTableHeaders();
+ const tableHeaders = generateSoftwareTableHeaders(deviceUser);
return (
diff --git a/frontend/pages/hosts/SoftwareTab/SoftwareTableConfig.tsx b/frontend/pages/hosts/SoftwareTab/SoftwareTableConfig.tsx
index 499d9a41ff..02492d0e23 100644
--- a/frontend/pages/hosts/SoftwareTab/SoftwareTableConfig.tsx
+++ b/frontend/pages/hosts/SoftwareTab/SoftwareTableConfig.tsx
@@ -72,8 +72,8 @@ const formatSoftwareType = (source: string) => {
// NOTE: cellProps come from react-table
// more info here https://react-table.tanstack.com/docs/api/useTable#cell-properties
-const generateSoftwareTableHeaders = (): IDataColumn[] => {
- return [
+const generateSoftwareTableHeaders = (deviceUser = false): IDataColumn[] => {
+ const tableHeaders: IDataColumn[] = [
{
title: "Vulnerabilities",
Header: "",
@@ -218,6 +218,13 @@ const generateSoftwareTableHeaders = (): IDataColumn[] => {
disableHidden: true,
},
];
+
+ // Device user cannot view all hosts software
+ if (deviceUser) {
+ tableHeaders.pop();
+ }
+
+ return tableHeaders;
};
export default generateSoftwareTableHeaders;