1
0
Fork 0

fix creating secrets with path redirecting to the right page

This commit is contained in:
ChaotiCryptidz 2022-01-23 12:25:19 +00:00
parent 2cdf5a3c60
commit 540c1b4b66
4 changed files with 15 additions and 7 deletions

View file

@ -2,6 +2,7 @@ export type InputProps = {
name?: string;
value?: string;
placeholder?: string;
onInput?: () => void;
onChange?: () => void;
required?: boolean;
checked?: boolean;

View file

@ -66,7 +66,7 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
this.setState({
dataLoaded: true,
kvData: kvData,
code: this.getStringKVData(kvData),
code: this.getStringKVData(kvData, this.state.syntax),
});
}
@ -95,11 +95,11 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
}
}
getStringKVData(data: Record<string, unknown>): string {
getStringKVData(data: Record<string, unknown>, syntax: string): string {
return dumpData(
Object.fromEntries(sortedObjectMap(data)),
this.props.settings.kvEditorIndent,
this.state.syntax,
syntax,
);
}
@ -115,7 +115,8 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
<InputWithTitle title={i18next.t("kv_sec_edit_syntax")}>
<Select
selectRef={this.syntaxSelectRef}
onChange={() => {
onInput={() => {
console.log(this.syntaxSelectRef.current.value);
this.setState({ syntax: this.syntaxSelectRef.current.value });
}}
>
@ -138,7 +139,7 @@ export class KVEditor extends Component<KVEditProps, KVEditState> {
<CodeEditor
language={toPrismCode(this.state.syntax)}
tabSize={this.props.settings.kvEditorIndent}
code={this.getStringKVData(this.state.kvData)}
code={this.getStringKVData(this.state.kvData, this.state.syntax)}
onUpdate={(code) => {
this.setState({ code });
}}

View file

@ -115,7 +115,7 @@ export class KVKeysList extends Component<KVKeysListProps, KVKeysListState> {
inputRef={this.searchBarRef}
name="path"
placeholder={i18next.t("kv_view_search_input_text")}
onChange={async () => {
onInput={async () => {
this.setState({
searchQuery: this.searchBarRef.current.value,
});

View file

@ -31,7 +31,13 @@ export class KeyValueNew extends Component<DefaultPageProps> {
}
await this.props.api.createOrUpdateSecret(baseMount, secretPath, path, keyData);
route(kvViewURL(baseMount, secretPath, path));
if (path.includes("/")) {
const split = path.split("/");
const secret = split.pop();
route(kvViewURL(baseMount, [...secretPath, ...split], secret));
} else {
route(kvViewURL(baseMount, secretPath, path));
}
} catch (e: unknown) {
const error = e as Error;
this.errorMessageRef.current.setErrorMessage(error.message);