Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgruica committed May 22, 2020
1 parent f0fe30e commit f0b37cc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
51 changes: 50 additions & 1 deletion kotsadm/web/src/components/redactors/EditRedactor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,58 @@ class EditRedactor extends Component {
redactorEnabled: false,
redactorYaml: "",
isEditingRedactorName: false,
redactorName: ""
redactorName: "",
creatingRedactor: false,
createErrMsg: ""
};

createRedactor = () => {
this.setState({ creatingRedactor: true, createErrMsg: "" });

fetch(`${window.env.API_ENDPOINT}/redact/metadata/${name}`, {
method: "POST",
headers: {
"Authorization": Utilities.getToken(),
"Content-Type": "application/json",
},
body: JSON.stringify(payload)
})
.then(async (res) => {

const createResponse = await res.json();
if (!res.ok) {
this.setState({
creatingRedactor: false,
createErrMsg: createResponse.error
})
return;
}

if (createResponse.success) {
this.setState({
snapshotSettings: settingsResponse,
creatingRedactor: false,
createConfirm: true,
createErrMsg: ""
});
setTimeout(() => {
this.setState({ createConfirm: false })
}, 3000);
} else {
this.setState({
creatingRedactor: false,
createErrMsg: settingsResponse.error
})
}
})
.catch((err) => {
this.setState({
creatingRedactor: false,
createErrMsg: err.message ? err.message : "Something went wrong, please try again!"
});
});
}

handleEnableRedactor = () => {
this.setState({
redactorEnabled: !this.state.redactorEnabled,
Expand Down
9 changes: 7 additions & 2 deletions kotsadm/web/src/components/redactors/Redactors.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Redactors extends Component {
.then(res => res.json())
.then(result => {
if (result.success) {
console.log(result)
this.setState({
redactors: result.redactors,
isLoadingRedactors: false,
Expand Down Expand Up @@ -115,8 +116,12 @@ class Redactors extends Component {

render() {
const { sortedRedactors, selectedOption, deleteRedactorModal } = this.state;

console.log(1111)
// Name string `json:"name"`
// Slug string `json:"slug"`
// Created time.Time `json:"createdAt"`
// Updated time.Time `json:"updatedAt"`
// Enabled bool `json:"enabled"`
// Description string `json:"description"`

const selectOptions = [
{
Expand Down

0 comments on commit f0b37cc

Please sign in to comment.