Browse Source

Initialized routes and types

jnfrati 4 năm trước cách đây
mục cha
commit
00c0a96b02

+ 12 - 3
dashboard/src/main/home/cluster-dashboard/ClusterDashboard.tsx

@@ -29,8 +29,6 @@ import LastRunStatusSelector from "./LastRunStatusSelector";
 import loadable from "@loadable/component";
 import Loading from "components/Loading";
 import JobRunTable from "./chart/JobRunTable";
-import SwitchBase from "@material-ui/core/internal/SwitchBase";
-import Selector from "components/Selector";
 import TabSelector from "components/TabSelector";
 import TagFilter from "./TagFilter";
 
@@ -47,6 +45,14 @@ const LazyPreviewEnvironmentsRoutes = loadable(
   }
 );
 
+const LazyStackRoutes = loadable(
+  // @ts-ignore
+  () => import("./stacks/routes.tsx"),
+  {
+    fallback: <Loading />,
+  }
+);
+
 type PropsType = RouteComponentProps &
   WithAuthProps & {
     currentCluster: ClusterType;
@@ -273,6 +279,9 @@ class ClusterDashboard extends Component<PropsType, StateType> {
     let { setSidebar } = this.props;
     return (
       <Switch>
+        <Route path={"/stacks"}>
+          <LazyStackRoutes />
+        </Route>
         <Route path={"/preview-environments"}>
           <LazyPreviewEnvironmentsRoutes />
         </Route>
@@ -499,4 +508,4 @@ const SortFilterWrapper = styled.div`
   > div:not(:first-child) {
     margin-left: 30px;
   }
-`;
+`;

+ 7 - 0
dashboard/src/main/home/cluster-dashboard/stacks/routes.tsx

@@ -0,0 +1,7 @@
+import React from "react";
+
+const routes = () => {
+  return <div>routes</div>;
+};
+
+export default routes;

+ 70 - 0
dashboard/src/main/home/cluster-dashboard/stacks/types.ts

@@ -0,0 +1,70 @@
+export type CreateStackBody = {
+  name: string;
+  app_resources: {
+    name: string;
+    source_config_name: string;
+    template_name: string;
+    template_version: string;
+    values: unknown;
+  }[];
+  source_configs: {
+    name: string;
+    image_repo_uri: string;
+    build: {
+      method: "pack" | "docker";
+      folder_path: string;
+      git?: unknown;
+      buildpack?: unknown;
+      dockerfile?: unknown;
+    };
+  }[];
+};
+
+export type CreateStackResponse = {
+  id: string;
+  name: string;
+  created_at: string;
+  updated_at: string;
+
+  revisions: {
+    id: number;
+    created_at: string;
+  }[];
+
+  latest_revision: {
+    id: number;
+    created_at: string;
+    resources: AppResource[];
+
+    source_configs: SourceConfig[];
+  };
+};
+
+export type SourceConfig = {
+  id: string;
+  name: string;
+  created_at: string;
+  updated_at: string;
+
+  image_repo_uri: string;
+  image_tag: string;
+
+  build?: {
+    method: "pack" | "docker";
+    folder_path: string;
+    git?: unknown;
+    buildpack?: unknown;
+    dockerfile?: unknown;
+  };
+};
+
+export type AppResource = {
+  id: string;
+  name: string;
+  created_at: string;
+  updated_at: string;
+
+  stack_id: string;
+
+  stack_source_config: SourceConfig;
+};

+ 3 - 1
dashboard/src/shared/routing.tsx

@@ -13,7 +13,8 @@ export type PorterUrl =
   | "jobs"
   | "onboarding"
   | "databases"
-  | "preview-environments";
+  | "preview-environments"
+  | "stacks";
 
 export const PorterUrls = [
   "dashboard",
@@ -29,6 +30,7 @@ export const PorterUrls = [
   "onboarding",
   "databases",
   "preview-environments",
+  "stacks",
 ];
 
 // TODO: consolidate with pushFiltered