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; name?: string;
value?: string; value?: string;
placeholder?: string; placeholder?: string;
onInput?: () => void;
onChange?: () => void; onChange?: () => void;
required?: boolean; required?: boolean;
checked?: boolean; checked?: boolean;

View file

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

View file

@ -115,7 +115,7 @@ export class KVKeysList extends Component<KVKeysListProps, KVKeysListState> {
inputRef={this.searchBarRef} inputRef={this.searchBarRef}
name="path" name="path"
placeholder={i18next.t("kv_view_search_input_text")} placeholder={i18next.t("kv_view_search_input_text")}
onChange={async () => { onInput={async () => {
this.setState({ this.setState({
searchQuery: this.searchBarRef.current.value, 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); await this.props.api.createOrUpdateSecret(baseMount, secretPath, path, keyData);
if (path.includes("/")) {
const split = path.split("/");
const secret = split.pop();
route(kvViewURL(baseMount, [...secretPath, ...split], secret));
} else {
route(kvViewURL(baseMount, secretPath, path)); route(kvViewURL(baseMount, secretPath, path));
}
} catch (e: unknown) { } catch (e: unknown) {
const error = e as Error; const error = e as Error;
this.errorMessageRef.current.setErrorMessage(error.message); this.errorMessageRef.current.setErrorMessage(error.message);