|
@@ -31,12 +31,13 @@ type PropsType = {
|
|
|
namespace: string;
|
|
namespace: string;
|
|
|
currentChart: ChartType;
|
|
currentChart: ChartType;
|
|
|
currentCluster: ClusterType;
|
|
currentCluster: ClusterType;
|
|
|
- setCurrentChart: (x: ChartType | null) => void;
|
|
|
|
|
|
|
+ closeChart: () => void;
|
|
|
setSidebar: (x: boolean) => void;
|
|
setSidebar: (x: boolean) => void;
|
|
|
isMetricsInstalled: boolean;
|
|
isMetricsInstalled: boolean;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
type StateType = {
|
|
type StateType = {
|
|
|
|
|
+ currentChart: ChartType;
|
|
|
loading: boolean;
|
|
loading: boolean;
|
|
|
showRevisions: boolean;
|
|
showRevisions: boolean;
|
|
|
components: ResourceType[];
|
|
components: ResourceType[];
|
|
@@ -57,6 +58,7 @@ type StateType = {
|
|
|
|
|
|
|
|
export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
state = {
|
|
state = {
|
|
|
|
|
+ currentChart: this.props.currentChart,
|
|
|
loading: true,
|
|
loading: true,
|
|
|
showRevisions: false,
|
|
showRevisions: false,
|
|
|
components: [] as ResourceType[],
|
|
components: [] as ResourceType[],
|
|
@@ -78,7 +80,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
// Retrieve full chart data (includes form and values)
|
|
// Retrieve full chart data (includes form and values)
|
|
|
getChartData = (chart: ChartType) => {
|
|
getChartData = (chart: ChartType) => {
|
|
|
let { currentProject } = this.context;
|
|
let { currentProject } = this.context;
|
|
|
- let { currentCluster, currentChart, setCurrentChart } = this.props;
|
|
|
|
|
|
|
+ let { currentCluster, currentChart } = this.props;
|
|
|
|
|
|
|
|
this.setState({ loading: true });
|
|
this.setState({ loading: true });
|
|
|
api
|
|
api
|
|
@@ -96,8 +98,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- setCurrentChart(res.data);
|
|
|
|
|
- this.setState({ loading: false });
|
|
|
|
|
|
|
+ this.setState({ currentChart: res.data, loading: false });
|
|
|
})
|
|
})
|
|
|
.catch(console.log);
|
|
.catch(console.log);
|
|
|
};
|
|
};
|
|
@@ -125,7 +126,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
- res.data.forEach(async (c: any) => {
|
|
|
|
|
|
|
+ res.data?.forEach(async (c: any) => {
|
|
|
await new Promise((nextController: (res?: any) => void) => {
|
|
await new Promise((nextController: (res?: any) => void) => {
|
|
|
c.metadata.kind = c.kind;
|
|
c.metadata.kind = c.kind;
|
|
|
this.setState(
|
|
this.setState(
|
|
@@ -159,17 +160,20 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
ws.onmessage = (evt: MessageEvent) => {
|
|
ws.onmessage = (evt: MessageEvent) => {
|
|
|
let event = JSON.parse(evt.data);
|
|
let event = JSON.parse(evt.data);
|
|
|
- let object = event.Object;
|
|
|
|
|
- object.metadata.kind = event.Kind;
|
|
|
|
|
|
|
|
|
|
- if (!this.state.controllers[object.metadata.uid]) return;
|
|
|
|
|
|
|
+ if (event.event_type == "UPDATE") {
|
|
|
|
|
+ let object = event.Object;
|
|
|
|
|
+ object.metadata.kind = event.Kind;
|
|
|
|
|
|
|
|
- this.setState({
|
|
|
|
|
- controllers: {
|
|
|
|
|
- ...this.state.controllers,
|
|
|
|
|
- [object.metadata.uid]: object,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (!this.state.controllers[object.metadata.uid]) return;
|
|
|
|
|
+
|
|
|
|
|
+ this.setState({
|
|
|
|
|
+ controllers: {
|
|
|
|
|
+ ...this.state.controllers,
|
|
|
|
|
+ [object.metadata.uid]: object,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
ws.onclose = () => {
|
|
ws.onclose = () => {
|
|
@@ -193,7 +197,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
updateResources = () => {
|
|
updateResources = () => {
|
|
|
let { currentCluster, currentProject } = this.context;
|
|
let { currentCluster, currentProject } = this.context;
|
|
|
- let { currentChart } = this.props;
|
|
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
|
|
|
|
|
api
|
|
api
|
|
|
.getChartComponents(
|
|
.getChartComponents(
|
|
@@ -218,7 +222,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
.catch(console.log);
|
|
.catch(console.log);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- refreshChart = () => this.getChartData(this.props.currentChart);
|
|
|
|
|
|
|
+ refreshChart = () => this.getChartData(this.state.currentChart);
|
|
|
|
|
|
|
|
onSubmit = (rawValues: any) => {
|
|
onSubmit = (rawValues: any) => {
|
|
|
let { currentProject, currentCluster, setCurrentError } = this.context;
|
|
let { currentProject, currentCluster, setCurrentError } = this.context;
|
|
@@ -232,7 +236,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
// Weave in preexisting values and convert to yaml
|
|
// Weave in preexisting values and convert to yaml
|
|
|
let valuesYaml = yaml.dump({
|
|
let valuesYaml = yaml.dump({
|
|
|
- ...(this.props.currentChart.config as Object),
|
|
|
|
|
|
|
+ ...(this.state.currentChart.config as Object),
|
|
|
...values,
|
|
...values,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -242,13 +246,13 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
.upgradeChartValues(
|
|
.upgradeChartValues(
|
|
|
"<token>",
|
|
"<token>",
|
|
|
{
|
|
{
|
|
|
- namespace: this.props.currentChart.namespace,
|
|
|
|
|
|
|
+ namespace: this.state.currentChart.namespace,
|
|
|
storage: StorageType.Secret,
|
|
storage: StorageType.Secret,
|
|
|
values: valuesYaml,
|
|
values: valuesYaml,
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
id: currentProject.id,
|
|
id: currentProject.id,
|
|
|
- name: this.props.currentChart.name,
|
|
|
|
|
|
|
+ name: this.state.currentChart.name,
|
|
|
cluster_id: currentCluster.id,
|
|
cluster_id: currentCluster.id,
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
@@ -259,14 +263,14 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
window.analytics.track("Chart Upgraded", {
|
|
window.analytics.track("Chart Upgraded", {
|
|
|
- chart: this.props.currentChart.name,
|
|
|
|
|
|
|
+ chart: this.state.currentChart.name,
|
|
|
values: valuesYaml,
|
|
values: valuesYaml,
|
|
|
});
|
|
});
|
|
|
})
|
|
})
|
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
|
this.setState({ saveValuesStatus: "error" });
|
|
this.setState({ saveValuesStatus: "error" });
|
|
|
window.analytics.track("Failed to Upgrade Chart", {
|
|
window.analytics.track("Failed to Upgrade Chart", {
|
|
|
- chart: this.props.currentChart.name,
|
|
|
|
|
|
|
+ chart: this.state.currentChart.name,
|
|
|
values: valuesYaml,
|
|
values: valuesYaml,
|
|
|
error: err,
|
|
error: err,
|
|
|
});
|
|
});
|
|
@@ -282,22 +286,14 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
saveValuesStatus,
|
|
saveValuesStatus,
|
|
|
tabOptions,
|
|
tabOptions,
|
|
|
} = this.state;
|
|
} = this.state;
|
|
|
- let { currentChart, setSidebar } = this.props;
|
|
|
|
|
|
|
+ let { setSidebar } = this.props;
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
let chart = currentChart;
|
|
let chart = currentChart;
|
|
|
|
|
|
|
|
switch (currentTab) {
|
|
switch (currentTab) {
|
|
|
case "metrics":
|
|
case "metrics":
|
|
|
return <MetricsSection currentChart={chart} />;
|
|
return <MetricsSection currentChart={chart} />;
|
|
|
case "status":
|
|
case "status":
|
|
|
- let activeJobs = Object.values(this.state.controllers)[0]?.status
|
|
|
|
|
- .active;
|
|
|
|
|
- let selectors = activeJobs?.map((job: any) => {
|
|
|
|
|
- return `job-name=${job.name},controller-uid=${job.uid}`;
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- if (chart.chart.metadata.name == "job") {
|
|
|
|
|
- return <StatusSection currentChart={chart} selectors={selectors} />;
|
|
|
|
|
- }
|
|
|
|
|
return <StatusSection currentChart={chart} />;
|
|
return <StatusSection currentChart={chart} />;
|
|
|
case "settings":
|
|
case "settings":
|
|
|
return (
|
|
return (
|
|
@@ -341,6 +337,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
saveValuesStatus={this.state.saveValuesStatus}
|
|
saveValuesStatus={this.state.saveValuesStatus}
|
|
|
isInModal={true}
|
|
isInModal={true}
|
|
|
currentTab={currentTab}
|
|
currentTab={currentTab}
|
|
|
|
|
+ renderSaveButton={true}
|
|
|
>
|
|
>
|
|
|
{(metaState: any, setMetaState: any) => {
|
|
{(metaState: any, setMetaState: any) => {
|
|
|
return tabOptions.map((tab: any, i: number) => {
|
|
return tabOptions.map((tab: any, i: number) => {
|
|
@@ -364,7 +361,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
updateTabs() {
|
|
updateTabs() {
|
|
|
- let formData = this.props.currentChart.form;
|
|
|
|
|
|
|
+ let formData = this.state.currentChart.form;
|
|
|
let tabOptions = [] as any[];
|
|
let tabOptions = [] as any[];
|
|
|
|
|
|
|
|
// Generate form tabs if form.yaml exists
|
|
// Generate form tabs if form.yaml exists
|
|
@@ -430,7 +427,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
renderIcon = () => {
|
|
renderIcon = () => {
|
|
|
- let { currentChart } = this.props;
|
|
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
|
|
|
|
|
if (
|
|
if (
|
|
|
currentChart.chart.metadata.icon &&
|
|
currentChart.chart.metadata.icon &&
|
|
@@ -496,7 +493,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
|
let { currentCluster, currentProject } = this.context;
|
|
let { currentCluster, currentProject } = this.context;
|
|
|
- let { currentChart } = this.props;
|
|
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
|
|
|
|
|
window.analytics.track("Opened Chart", {
|
|
window.analytics.track("Opened Chart", {
|
|
|
chart: currentChart.name,
|
|
chart: currentChart.name,
|
|
@@ -541,7 +538,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
{
|
|
{
|
|
|
id: currentProject.id,
|
|
id: currentProject.id,
|
|
|
name: ingressName,
|
|
name: ingressName,
|
|
|
- namespace: `${this.props.currentChart.namespace}`,
|
|
|
|
|
|
|
+ namespace: `${this.state.currentChart.namespace}`,
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
@@ -575,8 +572,8 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
|
- if (this.state.websockets) {
|
|
|
|
|
- this.state.websockets.forEach((ws: WebSocket) => {
|
|
|
|
|
|
|
+ if (this.state.websockets?.length > 0) {
|
|
|
|
|
+ this.state.websockets?.forEach((ws: WebSocket) => {
|
|
|
ws.close();
|
|
ws.close();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -594,7 +591,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
let serviceName = null as string;
|
|
let serviceName = null as string;
|
|
|
let serviceNamespace = null as string;
|
|
let serviceNamespace = null as string;
|
|
|
|
|
|
|
|
- this.state.components.forEach((c: any) => {
|
|
|
|
|
|
|
+ this.state.components?.forEach((c: any) => {
|
|
|
if (c.Kind == "Service") {
|
|
if (c.Kind == "Service") {
|
|
|
serviceName = c.Name;
|
|
serviceName = c.Name;
|
|
|
serviceNamespace = c.Namespace;
|
|
serviceNamespace = c.Namespace;
|
|
@@ -612,7 +609,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
|
|
|
|
|
handleUninstallChart = () => {
|
|
handleUninstallChart = () => {
|
|
|
let { currentProject, currentCluster } = this.context;
|
|
let { currentProject, currentCluster } = this.context;
|
|
|
- let { currentChart } = this.props;
|
|
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
this.setState({ deleting: true });
|
|
this.setState({ deleting: true });
|
|
|
api
|
|
api
|
|
|
.uninstallTemplate(
|
|
.uninstallTemplate(
|
|
@@ -628,7 +625,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
)
|
|
)
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
this.setState({ showDeleteOverlay: false });
|
|
this.setState({ showDeleteOverlay: false });
|
|
|
- this.props.setCurrentChart(null);
|
|
|
|
|
|
|
+ this.props.closeChart();
|
|
|
})
|
|
})
|
|
|
.catch(console.log);
|
|
.catch(console.log);
|
|
|
};
|
|
};
|
|
@@ -644,13 +641,14 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
- let { currentChart, setCurrentChart } = this.props;
|
|
|
|
|
|
|
+ let { closeChart } = this.props;
|
|
|
|
|
+ let { currentChart } = this.state;
|
|
|
let chart = currentChart;
|
|
let chart = currentChart;
|
|
|
let status = this.getChartStatus(chart.info.status);
|
|
let status = this.getChartStatus(chart.info.status);
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- <CloseOverlay onClick={() => setCurrentChart(null)} />
|
|
|
|
|
|
|
+ <CloseOverlay onClick={closeChart} />
|
|
|
<StyledExpandedChart>
|
|
<StyledExpandedChart>
|
|
|
<ConfirmOverlay
|
|
<ConfirmOverlay
|
|
|
show={this.state.showDeleteOverlay}
|
|
show={this.state.showDeleteOverlay}
|
|
@@ -686,7 +684,7 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
|
|
|
</TagWrapper>
|
|
</TagWrapper>
|
|
|
</TitleSection>
|
|
</TitleSection>
|
|
|
|
|
|
|
|
- <CloseButton onClick={() => setCurrentChart(null)}>
|
|
|
|
|
|
|
+ <CloseButton onClick={closeChart}>
|
|
|
<CloseButtonImg src={close} />
|
|
<CloseButtonImg src={close} />
|
|
|
</CloseButton>
|
|
</CloseButton>
|
|
|
|
|
|
|
@@ -944,7 +942,6 @@ const CloseButtonImg = styled.img`
|
|
|
const StyledExpandedChart = styled.div`
|
|
const StyledExpandedChart = styled.div`
|
|
|
width: calc(100% - 50px);
|
|
width: calc(100% - 50px);
|
|
|
height: calc(100% - 50px);
|
|
height: calc(100% - 50px);
|
|
|
- background: red;
|
|
|
|
|
z-index: 0;
|
|
z-index: 0;
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
top: 25px;
|
|
top: 25px;
|