web/admin: fix error when prompt previewing fails when loading the page (#5290)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
f44175303b
commit
6a554ef45a
|
@ -65,20 +65,20 @@ export class PromptForm extends ModelForm<Prompt, string> {
|
||||||
const prompt = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsRetrieve({
|
const prompt = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsRetrieve({
|
||||||
promptUuid: pk,
|
promptUuid: pk,
|
||||||
});
|
});
|
||||||
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
|
await this.refreshPreview(prompt);
|
||||||
promptRequest: prompt,
|
|
||||||
});
|
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshPreview(): Promise<void> {
|
async refreshPreview(prompt?: Prompt): Promise<void> {
|
||||||
const data = this.serializeForm();
|
if (!prompt) {
|
||||||
if (!data) {
|
prompt = this.serializeForm();
|
||||||
|
if (!prompt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
|
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
|
||||||
promptRequest: data,
|
promptRequest: prompt,
|
||||||
});
|
});
|
||||||
this.previewError = undefined;
|
this.previewError = undefined;
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
|
|
Reference in a new issue