|
@@ -2,7 +2,7 @@ import Loading from "components/Loading";
|
|
|
import Placeholder from "components/Placeholder";
|
|
import Placeholder from "components/Placeholder";
|
|
|
import TabSelector from "components/TabSelector";
|
|
import TabSelector from "components/TabSelector";
|
|
|
import TitleSection from "components/TitleSection";
|
|
import TitleSection from "components/TitleSection";
|
|
|
-import React, { useContext, useEffect, useState } from "react";
|
|
|
|
|
|
|
+import React, { useContext, useState } from "react";
|
|
|
import backArrow from "assets/back_arrow.png";
|
|
import backArrow from "assets/back_arrow.png";
|
|
|
import { useParams } from "react-router";
|
|
import { useParams } from "react-router";
|
|
|
import api from "shared/api";
|
|
import api from "shared/api";
|
|
@@ -11,13 +11,11 @@ import { useRouting } from "shared/routing";
|
|
|
import { readableDate } from "shared/string_utils";
|
|
import { readableDate } from "shared/string_utils";
|
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
|
import ChartList from "../../chart/ChartList";
|
|
import ChartList from "../../chart/ChartList";
|
|
|
-import SortSelector from "../../SortSelector";
|
|
|
|
|
import Status from "../components/Status";
|
|
import Status from "../components/Status";
|
|
|
import {
|
|
import {
|
|
|
Br,
|
|
Br,
|
|
|
InfoWrapper,
|
|
InfoWrapper,
|
|
|
LastDeployed,
|
|
LastDeployed,
|
|
|
- LineBreak,
|
|
|
|
|
NamespaceTag,
|
|
NamespaceTag,
|
|
|
SepDot,
|
|
SepDot,
|
|
|
Text,
|
|
Text,
|
|
@@ -29,50 +27,29 @@ import RevisionList from "./_RevisionList";
|
|
|
import SourceConfig from "./_SourceConfig";
|
|
import SourceConfig from "./_SourceConfig";
|
|
|
import { NavLink } from "react-router-dom";
|
|
import { NavLink } from "react-router-dom";
|
|
|
import Settings from "./components/Settings";
|
|
import Settings from "./components/Settings";
|
|
|
|
|
+import { ExpandedStackStore } from "./Store";
|
|
|
|
|
+import DynamicLink from "components/DynamicLink";
|
|
|
|
|
|
|
|
const ExpandedStack = () => {
|
|
const ExpandedStack = () => {
|
|
|
- const { namespace, stack_id } = useParams<{
|
|
|
|
|
|
|
+ const { namespace } = useParams<{
|
|
|
namespace: string;
|
|
namespace: string;
|
|
|
stack_id: string;
|
|
stack_id: string;
|
|
|
}>();
|
|
}>();
|
|
|
|
|
|
|
|
|
|
+ const { stack, refreshStack } = useContext(ExpandedStackStore);
|
|
|
|
|
+
|
|
|
const { pushFiltered } = useRouting();
|
|
const { pushFiltered } = useRouting();
|
|
|
|
|
|
|
|
const { currentProject, currentCluster, setCurrentError } = useContext(
|
|
const { currentProject, currentCluster, setCurrentError } = useContext(
|
|
|
Context
|
|
Context
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- const [stack, setStack] = useState<Stack>();
|
|
|
|
|
- const [isLoading, setIsLoading] = useState(true);
|
|
|
|
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
|
const [currentTab, setCurrentTab] = useState("apps");
|
|
const [currentTab, setCurrentTab] = useState("apps");
|
|
|
|
|
|
|
|
- const [currentRevision, setCurrentRevision] = useState<FullStackRevision>();
|
|
|
|
|
-
|
|
|
|
|
- const getStack = async () => {
|
|
|
|
|
- setIsLoading(true);
|
|
|
|
|
- try {
|
|
|
|
|
- const newStack = await api
|
|
|
|
|
- .getStack<Stack>(
|
|
|
|
|
- "<token>",
|
|
|
|
|
- {},
|
|
|
|
|
- {
|
|
|
|
|
- project_id: currentProject.id,
|
|
|
|
|
- cluster_id: currentCluster.id,
|
|
|
|
|
- stack_id: stack_id,
|
|
|
|
|
- namespace,
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- .then((res) => res.data);
|
|
|
|
|
-
|
|
|
|
|
- setStack(newStack);
|
|
|
|
|
- setCurrentRevision(newStack.latest_revision);
|
|
|
|
|
- setIsLoading(false);
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- setCurrentError(error);
|
|
|
|
|
- pushFiltered("/stacks", []);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ const [currentRevision, setCurrentRevision] = useState<FullStackRevision>(
|
|
|
|
|
+ () => stack.latest_revision
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
const handleDelete = () => {
|
|
const handleDelete = () => {
|
|
|
setIsDeleting(true);
|
|
setIsDeleting(true);
|
|
@@ -96,12 +73,8 @@ const ExpandedStack = () => {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- getStack();
|
|
|
|
|
- }, [stack_id]);
|
|
|
|
|
-
|
|
|
|
|
- if (isLoading) {
|
|
|
|
|
- return <Loading />;
|
|
|
|
|
|
|
+ if (stack === null) {
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isDeleting) {
|
|
if (isDeleting) {
|
|
@@ -163,7 +136,7 @@ const ExpandedStack = () => {
|
|
|
stackId={stack.id}
|
|
stackId={stack.id}
|
|
|
stackNamespace={namespace}
|
|
stackNamespace={namespace}
|
|
|
onRevisionClick={(revision) => setCurrentRevision(revision)}
|
|
onRevisionClick={(revision) => setCurrentRevision(revision)}
|
|
|
- onRollback={() => getStack()}
|
|
|
|
|
|
|
+ onRollback={() => refreshStack()}
|
|
|
></RevisionList>
|
|
></RevisionList>
|
|
|
<Br />
|
|
<Br />
|
|
|
<TabSelector
|
|
<TabSelector
|
|
@@ -175,6 +148,7 @@ const ExpandedStack = () => {
|
|
|
component: (
|
|
component: (
|
|
|
<>
|
|
<>
|
|
|
<Gap></Gap>
|
|
<Gap></Gap>
|
|
|
|
|
+ <DynamicLink to={`new-app-resource`}>Add new app</DynamicLink>
|
|
|
{currentRevision.id !== stack.latest_revision.id ? (
|
|
{currentRevision.id !== stack.latest_revision.id ? (
|
|
|
<ChartListWrapper>
|
|
<ChartListWrapper>
|
|
|
<Placeholder>
|
|
<Placeholder>
|
|
@@ -209,7 +183,7 @@ const ExpandedStack = () => {
|
|
|
namespace={namespace}
|
|
namespace={namespace}
|
|
|
revision={currentRevision}
|
|
revision={currentRevision}
|
|
|
readOnly={stack.latest_revision.id !== currentRevision.id}
|
|
readOnly={stack.latest_revision.id !== currentRevision.id}
|
|
|
- onSourceConfigUpdate={() => getStack()}
|
|
|
|
|
|
|
+ onSourceConfigUpdate={() => refreshStack()}
|
|
|
></SourceConfig>
|
|
></SourceConfig>
|
|
|
</>
|
|
</>
|
|
|
),
|
|
),
|