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