Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Adding a new patch shows it in overlays tree on /kustomize (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob0h authored Aug 16, 2018
1 parent 5157bd7 commit e248b83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export default class KustomizeOverlay extends React.Component {
}

componentDidUpdate(lastProps, lastState) {
const { currentStep } = this.props;
this.rebuildTooltip();
if (this.props.currentStep !== lastProps.currentStep && !isEmpty(this.props.currentStep)) {
this.setFileTree();
this.setFileTree(currentStep);
}
if (this.props.fileContents !== lastProps.fileContents && !isEmpty(this.props.fileContents)) {
this.setState({ fileContents: keyBy(this.props.fileContents, "key") });
Expand All @@ -60,8 +61,9 @@ export default class KustomizeOverlay extends React.Component {
}

componentDidMount() {
if (this.props.currentStep && !isEmpty(this.props.currentStep)) {
this.setFileTree();
const { currentStep } = this.props;
if (currentStep && !isEmpty(currentStep)) {
this.setFileTree(currentStep);
}
if (this.props.fileContents && !isEmpty(this.props.fileContents)) {
this.setState({ fileContents: keyBy(this.props.fileContents, "key") });
Expand Down Expand Up @@ -157,6 +159,8 @@ export default class KustomizeOverlay extends React.Component {
};

await this.props.saveKustomizeOverlay(payload).catch();
const { currentStep } = await this.props.getCurrentStep(this.props.routeId);
this.setFileTree(currentStep);
await this.props.applyPatch(applyPayload).catch();

if (closeOverlay) {
Expand All @@ -183,8 +187,7 @@ export default class KustomizeOverlay extends React.Component {
ReactTooltip.hide();
}

setFileTree() {
const { kustomize } = this.props.currentStep;
setFileTree({ kustomize }) {
if (!kustomize.tree) return;
const sortedTree = sortBy(kustomize.tree.children, (dir) => {
dir.children ? dir.children.length : 0
Expand All @@ -210,7 +213,6 @@ export default class KustomizeOverlay extends React.Component {
const fileToView = find(this.state.fileContents, ["key", selectedFile]);
const showOverlay = patch.length;

console.log("this.props.modified", this.props);
return (
<div className="flex flex1">
<div className="u-minHeight--full u-minWidth--full flex-column flex1 u-position--relative">
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/shared/DetermineComponentForRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ class DetermineComponentForRoute extends React.Component {
return (
<KustomizeOverlay
startPoll={() => this.startPoll(this.props.routeId, this.gotoRoute)}
getCurrentStep={this.getCurrentStep}
routeId={this.props.routeId}
finished={this.state.finished}
location={location}
actions={actions}
Expand Down
2 changes: 0 additions & 2 deletions web/src/containers/KustomizeOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { connect } from "react-redux";
import realKustomizeOverlay from "../components/kustomize/kustomize_overlay/KustomizeOverlay";

import { loadingData } from "../redux/ui/main/actions";
import { getCurrentStep } from "../redux/data/determineSteps/actions";
import { getHelmChartMetadata } from "../redux/data/kustomizeSettings/actions";
import {
getFileContent,
Expand All @@ -24,7 +23,6 @@ const KustomizeOverlay = connect(
modified: state.data.kustomizeOverlay.kustomizeData.modified,
}),
dispatch => ({
getCurrentStep(loaderType) { return dispatch(getCurrentStep(loaderType)); },
getFileContent(payload) { return dispatch(getFileContent(payload)); },
getHelmChartMetadata() { return dispatch(getHelmChartMetadata()) },
saveKustomizeOverlay(payload) { return dispatch(saveKustomizeOverlay(payload)); },
Expand Down

0 comments on commit e248b83

Please sign in to comment.