web/admin: fix state issue after clearIcon/Background is used and for… (#5423)

web/admin: fix state issue after clearIcon/Background is used and form is re-used

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-04-30 14:25:18 +03:00 committed by GitHub
parent 0b0e08446d
commit cc8f52b502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 25 deletions

View File

@ -27,10 +27,12 @@ import {
@customElement("ak-application-form")
export class ApplicationForm extends ModelForm<Application, string> {
loadInstance(pk: string): Promise<Application> {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsRetrieve({
async loadInstance(pk: string): Promise<Application> {
const app = await new CoreApi(DEFAULT_CONFIG).coreApplicationsRetrieve({
slug: pk,
});
this.clearIcon = false;
return app;
}
@property({ attribute: false })

View File

@ -26,10 +26,12 @@ import {
@customElement("ak-flow-form")
export class FlowForm extends ModelForm<Flow, string> {
loadInstance(pk: string): Promise<Flow> {
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesRetrieve({
async loadInstance(pk: string): Promise<Flow> {
const flow = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesRetrieve({
slug: pk,
});
this.clearBackground = false;
return flow;
}
getSuccessMessage(): string {

View File

@ -31,15 +31,13 @@ import {
@customElement("ak-source-oauth-form")
export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
loadInstance(pk: string): Promise<OAuthSource> {
return new SourcesApi(DEFAULT_CONFIG)
.sourcesOauthRetrieve({
async loadInstance(pk: string): Promise<OAuthSource> {
const source = await new SourcesApi(DEFAULT_CONFIG).sourcesOauthRetrieve({
slug: pk,
})
.then((source) => {
this.providerType = source.type;
return source;
});
this.providerType = source.type;
this.clearIcon = false;
return source;
}
_modelName?: string;

View File

@ -28,16 +28,14 @@ import {
@customElement("ak-source-plex-form")
export class PlexSourceForm extends ModelForm<PlexSource, string> {
loadInstance(pk: string): Promise<PlexSource> {
return new SourcesApi(DEFAULT_CONFIG)
.sourcesPlexRetrieve({
async loadInstance(pk: string): Promise<PlexSource> {
const source = await new SourcesApi(DEFAULT_CONFIG).sourcesPlexRetrieve({
slug: pk,
})
.then((source) => {
});
this.plexToken = source.plexToken;
this.loadServers();
this.clearIcon = false;
return source;
});
}
@state()

View File

@ -38,10 +38,12 @@ export class SAMLSourceForm extends ModelForm<SAMLSource, string> {
@state()
clearIcon = false;
loadInstance(pk: string): Promise<SAMLSource> {
return new SourcesApi(DEFAULT_CONFIG).sourcesSamlRetrieve({
async loadInstance(pk: string): Promise<SAMLSource> {
const source = await new SourcesApi(DEFAULT_CONFIG).sourcesSamlRetrieve({
slug: pk,
});
this.clearIcon = false;
return source;
}
getSuccessMessage(): string {