fix saving a KV secret when no changes have been made.
This commit is contained in:
parent
7a43686676
commit
44c17988e8
|
@ -34,6 +34,7 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
|
|||
async editorSave(): Promise<void> {
|
||||
if (!this.state.dataLoaded) return;
|
||||
const editorContent = this.state.code;
|
||||
|
||||
if (!verifyJSONString(editorContent)) {
|
||||
setErrorText(i18next.t("kv_sec_edit_invalid_json_err"));
|
||||
return;
|
||||
|
@ -65,6 +66,7 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
|
|||
this.setState({
|
||||
dataLoaded: true,
|
||||
kvData: kvData,
|
||||
code: this.getStringKVData(kvData),
|
||||
});
|
||||
});
|
||||
return;
|
||||
|
@ -76,24 +78,27 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
|
|||
}
|
||||
}
|
||||
|
||||
getStringKVData(data: Record<string, unknown>): string {
|
||||
return JSON.stringify(
|
||||
Object.fromEntries(sortedObjectMap(data)),
|
||||
null,
|
||||
4,
|
||||
);
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
if (!this.state.dataLoaded) {
|
||||
return <p>{i18next.t("kv_sec_edit_loading")}</p>;
|
||||
}
|
||||
|
||||
const secretsJSON = JSON.stringify(
|
||||
Object.fromEntries(sortedObjectMap(this.state.kvData)),
|
||||
null,
|
||||
4,
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p class="uk-text-danger" id="errorText" />
|
||||
<CodeJarEditor
|
||||
highlight={() => { }}
|
||||
code={secretsJSON}
|
||||
code={this.getStringKVData(this.state.kvData)}
|
||||
onUpdate={(code) => this.onCodeUpdate(code)}
|
||||
options={{ tab: " ".repeat(4) }}
|
||||
/>
|
||||
<button class="uk-button uk-button-primary" onClick={() => this.editorSave()}>
|
||||
{i18next.t("kv_sec_edit_btn")}
|
||||
|
|
Loading…
Reference in a new issue