From 5de600389ecd14527bbe760dc39a187f52c6b37d Mon Sep 17 00:00:00 2001
From: Imre Toth <imre.toth@ess.eu>
Date: Fri, 18 Aug 2023 07:58:30 +0000
Subject: [PATCH] CE-1969: Remove landing page

---
 src/App.js                                    |   8 +-
 src/__tests__/login.test.js                   |   2 +-
 src/api/SwaggerApi.js                         |  35 ----
 .../auth/AccessDenied/AccessDenied.js         |   2 +-
 src/mocks/fixtures/ccce-api.json              | 186 +-----------------
 .../components/common/IOC/IOCTable.stories.js |   2 +-
 src/stories/views/Home/HomeView.stories.js    |  13 --
 src/views/home/HomeAccessControl.js           |  20 --
 src/views/home/HomeView.js                    |  95 ---------
 src/views/home/HomeVisitorView.js             |  11 --
 src/views/home/index.js                       |   5 -
 src/views/login/LoginView.js                  |   2 +-
 12 files changed, 6 insertions(+), 375 deletions(-)
 delete mode 100644 src/stories/views/Home/HomeView.stories.js
 delete mode 100644 src/views/home/HomeAccessControl.js
 delete mode 100644 src/views/home/HomeView.js
 delete mode 100644 src/views/home/HomeVisitorView.js
 delete mode 100644 src/views/home/index.js

diff --git a/src/App.js b/src/App.js
index a8347f00..fc9d901f 100644
--- a/src/App.js
+++ b/src/App.js
@@ -6,7 +6,6 @@ import { ThemeProvider } from "@mui/material/styles";
 import { CssBaseline } from "@mui/material";
 import { theme } from "./style/Theme";
 import { IOCListView } from "./views/IOC/IOCListView";
-import { HomeAccessControl } from "./views/home/HomeAccessControl";
 import NavigationMenu from "./components/navigation/NavigationMenu";
 import { IOCDetailsAccessControl } from "./views/IOC/IOCDetailsAccessControl";
 import { JobDetailsAccessControl } from "./views/jobs/JobDetailsAccessControl";
@@ -53,12 +52,7 @@ function App() {
                       <Routes>
                         <Route
                           path="/"
-                          element={<Navigate to="/home" />}
-                          exact
-                        />
-                        <Route
-                          path="/home"
-                          element={<HomeAccessControl />}
+                          element={<Navigate to="/iocs" />}
                           exact
                         />
                         <Route
diff --git a/src/__tests__/login.test.js b/src/__tests__/login.test.js
index a4ed3d80..d8c61ada 100644
--- a/src/__tests__/login.test.js
+++ b/src/__tests__/login.test.js
@@ -36,7 +36,7 @@ defineFeature(feature, (test) => {
 
     when("the user opens the application", async () => {
       const history = createMemoryHistory();
-      history.push("/home");
+      history.push("/iocs");
       render(
         <Router history={history}>
           <App />
diff --git a/src/api/SwaggerApi.js b/src/api/SwaggerApi.js
index fc121c5e..f01456a9 100644
--- a/src/api/SwaggerApi.js
+++ b/src/api/SwaggerApi.js
@@ -912,41 +912,6 @@ export function useUpdateActiveDeploymentHost(id, onError) {
   return useAsync({ fcn: method, call: false, onError: onError });
 }
 
-export function useAnnouncements() {
-  const api = useContext(apiContext);
-  const method = useCallAndUnpack(
-    api.apis.Broadcasts.fetchAnnouncements,
-    unpackAnnouncement
-  );
-
-  return useAsync({ fcn: method, call: true });
-}
-
-export function unpackAnnouncement(announcements) {
-  return { ...announcements };
-}
-
-export function usePersonalStatistics() {
-  const api = useContext(apiContext);
-  const method = useCallAndUnpack(
-    api.apis.Statistics.personalStatistics,
-    unpackPersonalStatistics
-  );
-
-  return useAsync({ fcn: method, call: true });
-}
-
-export function unpackPersonalStatistics(statistics) {
-  return { ...statistics };
-}
-
-export function useOwnIocsWithAlarms() {
-  const api = useContext(apiContext);
-  const method = useCallAndUnpack(api.apis.IOCs.listOwnIocsWithAlarms);
-
-  return useAsync({ fcn: method, call: true, init: [] });
-}
-
 export function unpackStatistics(statistics) {
   return { ...statistics };
 }
diff --git a/src/components/auth/AccessDenied/AccessDenied.js b/src/components/auth/AccessDenied/AccessDenied.js
index 2c317aa3..493b24b2 100644
--- a/src/components/auth/AccessDenied/AccessDenied.js
+++ b/src/components/auth/AccessDenied/AccessDenied.js
@@ -21,7 +21,7 @@ export default function AccessDenied() {
   const redirect = useRedirect();
 
   const goHome = () => {
-    redirect("/home");
+    redirect("/iocs");
   };
 
   return (
diff --git a/src/mocks/fixtures/ccce-api.json b/src/mocks/fixtures/ccce-api.json
index 21fe6ab8..f4f19b60 100644
--- a/src/mocks/fixtures/ccce-api.json
+++ b/src/mocks/fixtures/ccce-api.json
@@ -3,7 +3,7 @@
   "info": {
     "title": "CE deploy & monitor API",
     "description": "CE deploy & monitor backend",
-    "version": "1.0.0"
+    "version": "2.0.0"
   },
   "servers": [
     {
@@ -12,9 +12,6 @@
     }
   ],
   "tags": [
-    {
-      "name": "Broadcasts"
-    },
     {
       "name": "IOCs"
     },
@@ -1375,50 +1372,6 @@
         ]
       }
     },
-    "/api/v1/statistics/my_iocs": {
-      "get": {
-        "tags": ["Statistics"],
-        "summary": "Own IOCs' statistics",
-        "operationId": "personalStatistics",
-        "responses": {
-          "200": {
-            "description": "Personal statistics",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/PersonalStatisticsResponse"
-                }
-              }
-            }
-          },
-          "401": {
-            "description": "Unauthorized",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/GeneralException"
-                }
-              }
-            }
-          },
-          "500": {
-            "description": "Service exception",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/GeneralException"
-                }
-              }
-            }
-          }
-        },
-        "security": [
-          {
-            "bearerAuth": []
-          }
-        ]
-      }
-    },
     "/api/v1/statistics/general": {
       "get": {
         "tags": ["Statistics"],
@@ -2203,53 +2156,6 @@
         ]
       }
     },
-    "/api/v1/iocs/my_iocs_with_alarms": {
-      "get": {
-        "tags": ["IOCs"],
-        "summary": "List own IOCs with alarms",
-        "operationId": "listOwnIocsWithAlarms",
-        "responses": {
-          "200": {
-            "description": "Array of own IOC with alarms",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "type": "array",
-                  "items": {
-                    "$ref": "#/components/schemas/IocWithAlarm"
-                  }
-                }
-              }
-            }
-          },
-          "401": {
-            "description": "Unauthorized",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/GeneralException"
-                }
-              }
-            }
-          },
-          "500": {
-            "description": "Service exception",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/GeneralException"
-                }
-              }
-            }
-          }
-        },
-        "security": [
-          {
-            "bearerAuth": []
-          }
-        ]
-      }
-    },
     "/api/v1/hosts": {
       "get": {
         "tags": ["Hosts"],
@@ -3305,35 +3211,6 @@
         ]
       }
     },
-    "/api/v1/broadcasts/announcements": {
-      "get": {
-        "tags": ["Broadcasts"],
-        "summary": "Get announcements",
-        "operationId": "fetchAnnouncements",
-        "responses": {
-          "200": {
-            "description": "Announcements text",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/Announcements"
-                }
-              }
-            }
-          },
-          "401": {
-            "description": "Unauthorized",
-            "content": {
-              "application/json": {
-                "schema": {
-                  "$ref": "#/components/schemas/GeneralException"
-                }
-              }
-            }
-          }
-        }
-      }
-    },
     "/api/v1/authentication/users": {
       "get": {
         "tags": ["Authentication"],
@@ -3829,15 +3706,6 @@
           }
         }
       },
-      "PersonalStatisticsResponse": {
-        "type": "object",
-        "properties": {
-          "numberOfActiveIocs": {
-            "type": "integer",
-            "format": "int64"
-          }
-        }
-      },
       "DbStatistics": {
         "type": "object",
         "properties": {
@@ -4268,50 +4136,6 @@
           }
         }
       },
-      "IocWithAlarm": {
-        "type": "object",
-        "properties": {
-          "id": {
-            "type": "integer",
-            "format": "int64"
-          },
-          "description": {
-            "type": "string"
-          },
-          "createdBy": {
-            "type": "string"
-          },
-          "namingName": {
-            "type": "string"
-          },
-          "namingUuid": {
-            "type": "string"
-          },
-          "gitProjectId": {
-            "type": "integer",
-            "format": "int64"
-          },
-          "sourceUrl": {
-            "type": "string"
-          },
-          "activeDeployment": {
-            "$ref": "#/components/schemas/Deployment"
-          },
-          "alerts": {
-            "type": "array",
-            "items": {
-              "$ref": "#/components/schemas/Alert"
-            }
-          },
-          "alertSeverity": {
-            "type": "string",
-            "enum": ["ERROR", "WARNING", "INFO"]
-          },
-          "active": {
-            "type": "boolean"
-          }
-        }
-      },
       "HostInfo": {
         "type": "object",
         "properties": {
@@ -4817,14 +4641,6 @@
             "format": "double"
           }
         }
-      },
-      "Announcements": {
-        "type": "object",
-        "properties": {
-          "announcementsText": {
-            "type": "string"
-          }
-        }
       }
     },
     "securitySchemes": {
diff --git a/src/stories/components/common/IOC/IOCTable.stories.js b/src/stories/components/common/IOC/IOCTable.stories.js
index 4066059a..de1eb20d 100644
--- a/src/stories/components/common/IOC/IOCTable.stories.js
+++ b/src/stories/components/common/IOC/IOCTable.stories.js
@@ -10,7 +10,7 @@ export default {
   title: "IOC/IOCTable",
   argTypes: {
     rowType: {
-      options: ["explore", "own", "host"],
+      options: ["explore", "host"],
       control: { type: "radio" }
     },
     iocs: disabledTable,
diff --git a/src/stories/views/Home/HomeView.stories.js b/src/stories/views/Home/HomeView.stories.js
deleted file mode 100644
index 460a2e37..00000000
--- a/src/stories/views/Home/HomeView.stories.js
+++ /dev/null
@@ -1,13 +0,0 @@
-import React from "react";
-import { AppHarness } from "../../../mocks/AppHarness";
-import { HomeView } from "../../../views/home/HomeView";
-
-export default {
-  title: "Views/Home/HomeView"
-};
-
-export const Default = () => (
-  <AppHarness>
-    <HomeView />
-  </AppHarness>
-);
diff --git a/src/views/home/HomeAccessControl.js b/src/views/home/HomeAccessControl.js
deleted file mode 100644
index 3f48d052..00000000
--- a/src/views/home/HomeAccessControl.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import React, { useContext, useEffect } from "react";
-import AccessControl from "../../components/auth/AccessControl";
-import { HomeVisitorView } from "./HomeVisitorView";
-import { HomeView } from "./HomeView";
-import { GlobalAppBarContext } from "@ess-ics/ce-ui-common";
-import { applicationTitle } from "../../components/common/Helper";
-
-export function HomeAccessControl() {
-  const { setTitle } = useContext(GlobalAppBarContext);
-  useEffect(() => setTitle(applicationTitle("Home")), [setTitle]);
-
-  return (
-    <AccessControl
-      allowedRoles={["DeploymentToolAdmin", "DeploymentToolIntegrator"]}
-      renderNoAccess={() => <HomeVisitorView />}
-    >
-      <HomeView />
-    </AccessControl>
-  );
-}
diff --git a/src/views/home/HomeView.js b/src/views/home/HomeView.js
deleted file mode 100644
index 95952f78..00000000
--- a/src/views/home/HomeView.js
+++ /dev/null
@@ -1,95 +0,0 @@
-import { Grid, Box, Typography } from "@mui/material";
-import React, { useContext, useEffect } from "react";
-import { KeyValueTable } from "../../components/common/KeyValueTable/KeyValueTable";
-import { IOCAsyncList } from "../../components/IOC/IOCAsyncList";
-import { SimpleAccordion } from "../../components/common/Accordion/SimpleAccordion";
-import {
-  useAnnouncements,
-  usePersonalStatistics,
-  useOwnIocsWithAlarms
-} from "../../api/SwaggerApi";
-import ReactMarkdown from "react-markdown";
-import { GlobalAppBarContext } from "@ess-ics/ce-ui-common";
-import { applicationTitle } from "../../components/common/Helper";
-import { RootPaper } from "@ess-ics/ce-ui-common";
-
-export function HomeView() {
-  const [announcements] = useAnnouncements();
-  const [statistics] = usePersonalStatistics();
-  const [
-    iocsWithAlarms /* getIocsWithAlarms*/ /* resetResponse*/,
-    ,
-    ,
-    loading
-  ] = useOwnIocsWithAlarms();
-
-  const { setTitle } = useContext(GlobalAppBarContext);
-  useEffect(() => setTitle(applicationTitle("Home")), [setTitle]);
-
-  return (
-    <RootPaper>
-      <Grid
-        container
-        spacing={1}
-      >
-        <Grid
-          item
-          xs={10}
-        >
-          <Box
-            display="flex"
-            flexDirection="row"
-            p={2}
-            m={1}
-          >
-            <Typography variant="h2">Account overview</Typography>
-          </Box>
-        </Grid>
-        {statistics && (
-          <Grid
-            item
-            xs={12}
-          >
-            <KeyValueTable
-              obj={{
-                "IOCs registered": statistics.numberOfActiveIocs,
-                "IOCs with issues": iocsWithAlarms.length
-              }}
-              variant="table"
-            />
-          </Grid>
-        )}
-        <Grid
-          item
-          xs={12}
-        >
-          <SimpleAccordion
-            summary="IOCs with issues"
-            defaultExpanded
-          >
-            <IOCAsyncList
-              iocs={iocsWithAlarms}
-              asyncDetails={false}
-              rowType="own"
-              loading={loading}
-            />
-          </SimpleAccordion>
-        </Grid>
-      </Grid>
-      {announcements?.announcementsText && (
-        <Grid
-          container
-          justifyContent="flex-start"
-          sx={{ paddingX: 2 }}
-        >
-          <Grid
-            item
-            xs={12}
-          >
-            <ReactMarkdown>{announcements.announcementsText}</ReactMarkdown>
-          </Grid>
-        </Grid>
-      )}
-    </RootPaper>
-  );
-}
diff --git a/src/views/home/HomeVisitorView.js b/src/views/home/HomeVisitorView.js
deleted file mode 100644
index 38fff802..00000000
--- a/src/views/home/HomeVisitorView.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useRedirect } from "../../hooks/Redirect";
-import { useEffect } from "react";
-
-export function HomeVisitorView() {
-  const redirect = useRedirect();
-
-  useEffect(() => {
-    redirect("/iocs", {}, true);
-  }, [redirect]);
-  return null;
-}
diff --git a/src/views/home/index.js b/src/views/home/index.js
deleted file mode 100644
index b9240444..00000000
--- a/src/views/home/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { HomeView } from "./HomeView";
-import { HomeVisitorView } from "./HomeVisitorView";
-import { HomeAccessControl } from "./HomeAccessControl";
-
-export { HomeView, HomeVisitorView, HomeAccessControl };
diff --git a/src/views/login/LoginView.js b/src/views/login/LoginView.js
index 9a59f667..2fc21f3f 100644
--- a/src/views/login/LoginView.js
+++ b/src/views/login/LoginView.js
@@ -18,7 +18,7 @@ export function LoginView() {
 
   useEffect(() => {
     if (user) {
-      const goTo = location.state?.from ?? "/home";
+      const goTo = location.state?.from ?? "/iocs";
       redirect(goTo, {}, true);
     }
   }, [location.state?.from, redirect, user]);
-- 
GitLab