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

Commit

Permalink
add action to fetch the applied overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
GraysonNull committed Aug 21, 2018
1 parent f2f959a commit 35da86f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ export default class KustomizeOverlay extends React.Component {
this.setState({ toastDetails });
}

async fetchAppliedOverlay() {
const payload = {
patch: this.state.patch
};
await this.props.fetchAppliedOverlay(payload)
}

async handleKustomizeSave(closeOverlay) {
const { selectedFile } = this.state;
const contents = this.aceEditorOverlay.editor.getValue();
Expand Down
2 changes: 2 additions & 0 deletions web/src/containers/KustomizeOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getHelmChartMetadata } from "../redux/data/kustomizeSettings/actions";
import {
getFileContent,
saveKustomizeOverlay,
fetchAppliedOverlay,
finalizeKustomizeOverlay,
generatePatch,
applyPatch,
Expand All @@ -26,6 +27,7 @@ const KustomizeOverlay = connect(
getFileContent(payload) { return dispatch(getFileContent(payload)); },
getHelmChartMetadata() { return dispatch(getHelmChartMetadata()) },
saveKustomizeOverlay(payload) { return dispatch(saveKustomizeOverlay(payload)); },
fetchAppliedOverlay(payload) { return dispatch(fetchAppliedOverlay(payload)); },
finalizeKustomizeOverlay() { return dispatch(finalizeKustomizeOverlay()); },
loadingData(key, isLoading) { return dispatch(loadingData(key, isLoading)); },
generatePatch(payload) { return dispatch(generatePatch(payload)); },
Expand Down
29 changes: 29 additions & 0 deletions web/src/redux/data/kustomizeOverlay/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@ export function saveKustomizeOverlay(payload) {
};
}

export function fetchAppliedOverlay(payload) {
return async (dispatch) => {
let response;
dispatch(loadingData("fetchAppliedOverlay", true));
try {
const url = `${apiEndpoint}/kustomize/apply`;
response = await fetch(url, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
if (!response.ok) {
dispatch(loadingData("fetchAppliedOverlay", false));
return;
}
await response.json();
dispatch(loadingData("fetchAppliedOverlay", false));
console.log(response)
} catch (error) {
dispatch(loadingData("fetchAppliedOverlay", false));
console.log(error)
return;
}
};
}

export function finalizeKustomizeOverlay() {
return async (dispatch) => {
let response;
Expand Down
1 change: 1 addition & 0 deletions web/src/redux/ui/main/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const loadingState = {
submitActionLoading: false,
fileContentLoading: false,
saveKustomizeLoading: false,
fetchAppliedOverlayLoading: false,
};

export function loading(state = loadingState, action = {}) {
Expand Down

0 comments on commit 35da86f

Please sign in to comment.