Skip to content

Commit

Permalink
web/admin: fix error when prompt previewing fails when loading the pa…
Browse files Browse the repository at this point in the history
…ge (#5290)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Apr 18, 2023
1 parent f441753 commit 6a554ef
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions web/src/admin/stages/prompt/PromptForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
return;
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) {
Expand Down

0 comments on commit 6a554ef

Please sign in to comment.