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:
Jens L 2023-04-18 14:53:13 +02:00 committed by GitHub
parent f44175303b
commit 6a554ef45a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions

View File

@ -65,20 +65,20 @@ export class PromptForm extends ModelForm<Prompt, string> {
const prompt = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsRetrieve({
promptUuid: pk,
});
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
promptRequest: prompt,
});
await this.refreshPreview(prompt);
return prompt;
}
async refreshPreview(): Promise<void> {
const data = this.serializeForm();
if (!data) {
async refreshPreview(prompt?: Prompt): Promise<void> {
if (!prompt) {
prompt = this.serializeForm();
if (!prompt) {
return;
}
}
try {
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
promptRequest: data,
promptRequest: prompt,
});
this.previewError = undefined;
} catch (exc) {