From 86891ca0fadf415f63d11dea3e2e2e0230afa0c5 Mon Sep 17 00:00:00 2001 From: Ian Edwards Date: Tue, 21 May 2024 16:16:43 -0400 Subject: [PATCH] first half of deletions --- .../cluster-dashboard/DashboardRouter.tsx | 185 ---------- dashboard/src/assets/GithubIcon.tsx | 24 -- dashboard/src/assets/code-branch-icon.tsx | 15 - dashboard/src/assets/command-line-icon.tsx | 35 -- dashboard/src/components/CheckboxList.tsx | 126 ------- dashboard/src/components/Dropdown.tsx | 157 --------- dashboard/src/components/Helper.tsx | 0 dashboard/src/components/InfoTooltip.tsx | 45 --- dashboard/src/components/LineGraph.tsx | 0 .../src/components/NoClusterPlaceHolder.tsx | 54 --- dashboard/src/components/OptionsDropdown.tsx | 97 ------ dashboard/src/components/PageNotFound.tsx | 188 ---------- dashboard/src/components/RadioFilter.tsx | 257 -------------- dashboard/src/components/SearchSelector.tsx | 247 ------------- dashboard/src/components/StatusIndicator.tsx | 130 ------- dashboard/src/components/StatusSection.tsx | 86 ----- dashboard/src/components/Table.tsx | 101 ------ .../src/components/TitleSectionStacks.tsx | 117 ------- dashboard/src/components/TooltipParent.tsx | 70 ---- .../src/components/porter/ConfirmOverlay.tsx | 113 ------ dashboard/src/legacy/assets/GoogleIcon.tsx | 123 ------- .../src/legacy/assets/code-branch-icon.tsx | 15 - .../src/legacy/components/CheckboxList.tsx | 126 ------- dashboard/src/legacy/components/Helper.tsx | 0 .../src/legacy/components/InfoTooltip.tsx | 45 --- dashboard/src/legacy/components/LineGraph.tsx | 0 .../legacy/components/MultiSelectFilter.tsx | 201 ----------- .../src/legacy/components/PageNotFound.tsx | 187 ---------- .../legacy/components/TitleSectionStacks.tsx | 117 ------- .../src/legacy/components/TooltipParent.tsx | 70 ---- .../legacy/components/UnauthorizedPage.tsx | 59 ---- dashboard/src/legacy/main/CurrentError.tsx | 244 ------------- dashboard/src/legacy/main/Main.tsx | 94 ----- dashboard/src/legacy/main/MainWrapper.tsx | 39 --- dashboard/src/legacy/shared/Context.tsx | 265 -------------- .../legacy/shared/DeploymentTargetContext.tsx | 153 -------- dashboard/src/legacy/shared/ansiparser.tsx | 134 ------- dashboard/src/legacy/shared/regex.tsx | 1 - dashboard/src/legacy/utils/ip.ts | 17 - dashboard/src/shared/ansiparser.tsx | 134 ------- dashboard/src/shared/array_utils.ts | 10 - dashboard/src/shared/hooks/useChart.ts | 326 ------------------ .../src/shared/hooks/useEffectDebugger.ts | 34 -- dashboard/src/shared/hooks/usePagination.ts | 103 ------ dashboard/src/shared/hooks/usePods.ts | 143 -------- dashboard/src/shared/hooks/usePrevious.ts | 9 - dashboard/src/shared/icons/MoonBase.tsx | 24 -- dashboard/src/shared/release/utils.ts | 7 - dashboard/src/shared/themes/opal.ts | 18 - 49 files changed, 4745 deletions(-) delete mode 100644 dashboard/legacy/main/home/cluster-dashboard/DashboardRouter.tsx delete mode 100644 dashboard/src/assets/GithubIcon.tsx delete mode 100644 dashboard/src/assets/code-branch-icon.tsx delete mode 100644 dashboard/src/assets/command-line-icon.tsx delete mode 100644 dashboard/src/components/CheckboxList.tsx delete mode 100644 dashboard/src/components/Dropdown.tsx delete mode 100644 dashboard/src/components/Helper.tsx delete mode 100644 dashboard/src/components/InfoTooltip.tsx delete mode 100644 dashboard/src/components/LineGraph.tsx delete mode 100644 dashboard/src/components/NoClusterPlaceHolder.tsx delete mode 100644 dashboard/src/components/OptionsDropdown.tsx delete mode 100644 dashboard/src/components/PageNotFound.tsx delete mode 100644 dashboard/src/components/RadioFilter.tsx delete mode 100644 dashboard/src/components/SearchSelector.tsx delete mode 100644 dashboard/src/components/StatusIndicator.tsx delete mode 100644 dashboard/src/components/StatusSection.tsx delete mode 100644 dashboard/src/components/Table.tsx delete mode 100644 dashboard/src/components/TitleSectionStacks.tsx delete mode 100644 dashboard/src/components/TooltipParent.tsx delete mode 100644 dashboard/src/components/porter/ConfirmOverlay.tsx delete mode 100644 dashboard/src/legacy/assets/GoogleIcon.tsx delete mode 100644 dashboard/src/legacy/assets/code-branch-icon.tsx delete mode 100644 dashboard/src/legacy/components/CheckboxList.tsx delete mode 100644 dashboard/src/legacy/components/Helper.tsx delete mode 100644 dashboard/src/legacy/components/InfoTooltip.tsx delete mode 100644 dashboard/src/legacy/components/LineGraph.tsx delete mode 100644 dashboard/src/legacy/components/MultiSelectFilter.tsx delete mode 100644 dashboard/src/legacy/components/PageNotFound.tsx delete mode 100644 dashboard/src/legacy/components/TitleSectionStacks.tsx delete mode 100644 dashboard/src/legacy/components/TooltipParent.tsx delete mode 100644 dashboard/src/legacy/components/UnauthorizedPage.tsx delete mode 100644 dashboard/src/legacy/main/CurrentError.tsx delete mode 100644 dashboard/src/legacy/main/Main.tsx delete mode 100644 dashboard/src/legacy/main/MainWrapper.tsx delete mode 100644 dashboard/src/legacy/shared/Context.tsx delete mode 100644 dashboard/src/legacy/shared/DeploymentTargetContext.tsx delete mode 100644 dashboard/src/legacy/shared/ansiparser.tsx delete mode 100644 dashboard/src/legacy/shared/regex.tsx delete mode 100644 dashboard/src/legacy/utils/ip.ts delete mode 100644 dashboard/src/shared/ansiparser.tsx delete mode 100644 dashboard/src/shared/array_utils.ts delete mode 100644 dashboard/src/shared/hooks/useChart.ts delete mode 100644 dashboard/src/shared/hooks/useEffectDebugger.ts delete mode 100644 dashboard/src/shared/hooks/usePagination.ts delete mode 100644 dashboard/src/shared/hooks/usePods.ts delete mode 100644 dashboard/src/shared/hooks/usePrevious.ts delete mode 100644 dashboard/src/shared/icons/MoonBase.tsx delete mode 100644 dashboard/src/shared/release/utils.ts delete mode 100644 dashboard/src/shared/themes/opal.ts diff --git a/dashboard/legacy/main/home/cluster-dashboard/DashboardRouter.tsx b/dashboard/legacy/main/home/cluster-dashboard/DashboardRouter.tsx deleted file mode 100644 index 9ef3a949e4..0000000000 --- a/dashboard/legacy/main/home/cluster-dashboard/DashboardRouter.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import React, { useContext, useEffect, useState } from "react"; -import loadable from "@loadable/component"; -import { RouteComponentProps, withRouter } from "react-router"; -import { Route, Switch } from "react-router-dom"; -import styled from "styled-components"; - -import Loading from "components/Loading"; - -import api from "shared/api"; -import { withAuth, WithAuthProps } from "shared/auth/AuthorizationHoc"; -import GuardedRoute from "shared/auth/RouteGuard"; -import { Context } from "shared/Context"; -import { getQueryParam, PorterUrl, pushQueryParams } from "shared/routing"; -import { ClusterType } from "shared/types"; - -import AppDashboard from "./apps/AppDashboard.ts"; -import DashboardRoutes from "./dashboard/Routes.ts"; -import EnvGroupDashboard from "./env-groups/EnvGroupDashboard.ts"; -import ExpandedEnvGroupDashboard from "./env-groups/ExpandedEnvGroupDashboard.ts"; -import ExpandedChartWrapper from "./expanded-chart/ExpandedChartWrapper.ts"; -import JobDashboard from "./jobs/JobDashboard.ts"; - -const LazyPreviewEnvironmentsRoutes = loadable( - // @ts-ignore - () => import("./preview-environments/routes.tsx"), - { - fallback: , - } -); - -const LazyStackRoutes = loadable( - // @ts-ignore - () => import("./stacks/routes.tsx"), - { - fallback: , - } -); - -type Props = RouteComponentProps & - WithAuthProps & { - currentCluster: ClusterType; - setSidebar: (x: boolean) => void; - currentView: PorterUrl; - }; - -// TODO: should try to maintain single source of truth b/w router and context/state (ex: namespace -> being managed in parallel right now so highly inextensible and routing is fragile) -const DashboardRouter: React.FC = ({ - setSidebar, - currentView, - ...props -}) => { - const { currentProject, currentCluster } = useContext(Context); - const [namespace, setNamespace] = useState(null); - const [sortType, setSortType] = useState( - localStorage.getItem("SortType") || "Newest" - ); - const [currentChart, setCurrentChart] = useState(null); - const [isMetricsInstalled, setIsMetricsInstalled] = useState(false); - - useEffect(() => { - // Don't add cluster as query param if present in path - const { cluster } = props.match?.params as any; - if (!cluster) { - pushQueryParams(props, { cluster: currentCluster.name }); - } - api - .getPrometheusIsInstalled( - "", - {}, - { - id: currentProject.id, - cluster_id: currentCluster.id, - } - ) - .then((res) => { - setIsMetricsInstalled(true); - }) - .catch(() => { - setIsMetricsInstalled(false); - }); - }, []); - - // Reset namespace filter and close expanded chart on cluster change - useEffect(() => { - let namespace = "default"; - let localStorageNamespace = localStorage.getItem( - `${currentProject.id}-${currentCluster.id}-namespace` - ); - if (localStorageNamespace) { - namespace = localStorageNamespace; - } - setNamespace(namespace); - setSortType(localStorage.getItem("SortType") || "Newest"); - setCurrentChart(null); - - // ret2 - pushQueryParams(props, { namespace }); - }, [currentCluster]); - - useEffect(() => { - let { currentNamespace } = - currentProject?.simplified_view_enabled && - currentProject?.capi_provisioner_enabled - ? "porter-env-group" - : (props.match?.params as any); - if (!currentNamespace) { - currentNamespace = - currentProject?.simplified_view_enabled && - currentProject?.capi_provisioner_enabled - ? "porter-env-group" - : getQueryParam(props, "namespace"); - } - setSortType("Newest"); - setCurrentChart(null); - setNamespace(currentNamespace || "default"); - pushQueryParams(props, { namespace: currentNamespace || "default" }); - }, [currentView]); - - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -}; - -export default withRouter(withAuth(DashboardRouter)); - -const StyledTemplateComponent = styled.div``; diff --git a/dashboard/src/assets/GithubIcon.tsx b/dashboard/src/assets/GithubIcon.tsx deleted file mode 100644 index e5739e1d54..0000000000 --- a/dashboard/src/assets/GithubIcon.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React, { Component } from "react"; -import styled from "styled-components"; - -type PropsType = {}; - -type StateType = {}; - -export default class GHIcon extends Component { - render() { - return ( - - - - ); - } -} - -const Svg = styled.svg` - fill: white; - margin-right: 6px; -`; diff --git a/dashboard/src/assets/code-branch-icon.tsx b/dashboard/src/assets/code-branch-icon.tsx deleted file mode 100644 index 088daf7b9f..0000000000 --- a/dashboard/src/assets/code-branch-icon.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React, { SVGProps } from "react"; - -function Icon(props: SVGProps) { - return ( - - - - ); -} - -export default Icon; diff --git a/dashboard/src/assets/command-line-icon.tsx b/dashboard/src/assets/command-line-icon.tsx deleted file mode 100644 index 1cac5e78a0..0000000000 --- a/dashboard/src/assets/command-line-icon.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React, { SVGProps } from "react"; -import styled from "styled-components"; - -function CommandLineIcon(props: SVGProps) { - return ( - - - - - - - - - - ); -} - -export default CommandLineIcon; - -const SVG = styled.svg``; diff --git a/dashboard/src/components/CheckboxList.tsx b/dashboard/src/components/CheckboxList.tsx deleted file mode 100644 index 39c125d816..0000000000 --- a/dashboard/src/components/CheckboxList.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import React, { useEffect } from "react"; -import styled from "styled-components"; - -type PropsType = { - label?: string; - options: { disabled?: boolean; value: any; label: string }[]; - selected: { value: any; label: string }[]; - setSelected: (x: { value: any; label: string }[]) => void; -}; - -const arraysEqual = (a: any, b: any) => { - if (a === b) return true; - if (a == null || b == null) return false; - if (a.length !== b.length) return false; - - // If you don't care about the order of the elements inside - // the array, you should sort both arrays here. - // Please note that calling sort on an array will modify that array. - // you might want to clone your array first. - - for (var i = 0; i < a.length; ++i) { - if (a[i] !== b[i]) return false; - } - return true; -}; - -const CheckboxList = ({ label, options, selected, setSelected }: PropsType) => { - let onSelectOption = (option: { value: any; label: string }) => { - const tmp = [...selected]; - if ( - tmp.filter( - (e) => e.value === option.value || arraysEqual(e.value, option.value) - ).length === 0 - ) { - setSelected([...tmp, option]); - } else { - tmp.forEach((x, i) => { - if (x.value === option.value || arraysEqual(x.value, option.value)) { - tmp.splice(i, 1); - } - }); - setSelected(tmp); - } - }; - - return ( - - {label && } - {options.map((option: { value: any; label: string }, i: number) => { - return ( - onSelectOption(option)} - key={i} - > - - e.value === option.value || - arraysEqual(e.value, option.value) - ).length > 0 - } - > - done - - {option.label} - - ); - })} - - ); -}; -export default CheckboxList; - -const Text = styled.div` - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - word-break: anywhere; - margin-right: 10px; -`; - -const Checkbox = styled.div` - width: 14px; - height: 14px; - min-width: 14px; - border: 1px solid #ffffff55; - margin: 1px 10px 0px 1px; - border-radius: 3px; - background: ${(props: { checked: boolean }) => - props.checked ? "#ffffff22" : "#ffffff11"}; - display: flex; - align-items: center; - justify-content: center; - - > i { - font-size: 12px; - padding-left: 0px; - display: ${(props: { checked: boolean }) => (props.checked ? "" : "none")}; - } -`; - -const CheckboxOption = styled.div<{ isLast: boolean }>` - width: 100%; - height: 35px; - padding-left: 10px; - display: flex; - cursor: pointer; - align-items: center; - font-size: 13px; - - :hover { - background: #ffffff18; - } -`; - -const Label = styled.div` - color: #ffffff; - margin-bottom: 10px; -`; - -const StyledCheckboxList = styled.div` - border-radius: 3px; - padding: 0; -`; diff --git a/dashboard/src/components/Dropdown.tsx b/dashboard/src/components/Dropdown.tsx deleted file mode 100644 index 8503928132..0000000000 --- a/dashboard/src/components/Dropdown.tsx +++ /dev/null @@ -1,157 +0,0 @@ -import React, { useState } from "react"; -import styled from "styled-components"; - -type Option = { - value: unknown; - label: string; -}; - -type DropdownProps = { - options: Array