web: expressing success (#7830)
* web: expressing success Ever see an idiom that just, I dunno, *annoyed* you? Automated tools for the win. * web: repetition, repetition, repetition! [throws chair] * web: giving the de-duplication treatment to policy mappings. * Created a BaseStageForm with success message and canonical primary key type for for Providers, Sources, and Stages.
This commit is contained in:
11
web/src/admin/sources/BaseSourceForm.ts
Normal file
11
web/src/admin/sources/BaseSourceForm.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
|
||||
import { msg } from "@lit/localize";
|
||||
|
||||
export abstract class BaseSourceForm<T> extends ModelForm<T, string> {
|
||||
getSuccessMessage(): string {
|
||||
return this.instance
|
||||
? msg("Successfully updated source.")
|
||||
: msg("Successfully created source.");
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
import "@goauthentik/admin/common/ak-crypto-certificate-search";
|
||||
import { placeholderHelperText } from "@goauthentik/admin/helperText";
|
||||
import { BaseSourceForm } from "@goauthentik/admin/sources/BaseSourceForm";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { first } from "@goauthentik/common/utils";
|
||||
import "@goauthentik/elements/forms/FormGroup";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
import "@goauthentik/elements/forms/SearchSelect";
|
||||
|
||||
import { msg } from "@lit/localize";
|
||||
@ -24,7 +24,7 @@ import {
|
||||
} from "@goauthentik/api";
|
||||
|
||||
@customElement("ak-source-ldap-form")
|
||||
export class LDAPSourceForm extends ModelForm<LDAPSource, string> {
|
||||
export class LDAPSourceForm extends BaseSourceForm<LDAPSource> {
|
||||
loadInstance(pk: string): Promise<LDAPSource> {
|
||||
return new SourcesApi(DEFAULT_CONFIG).sourcesLdapRetrieve({
|
||||
slug: pk,
|
||||
@ -41,14 +41,6 @@ export class LDAPSourceForm extends ModelForm<LDAPSource, string> {
|
||||
|
||||
propertyMappings?: PaginatedLDAPPropertyMappingList;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.instance) {
|
||||
return msg("Successfully updated source.");
|
||||
} else {
|
||||
return msg("Successfully created source.");
|
||||
}
|
||||
}
|
||||
|
||||
async send(data: LDAPSource): Promise<LDAPSource> {
|
||||
if (this.instance) {
|
||||
return new SourcesApi(DEFAULT_CONFIG).sourcesLdapPartialUpdate({
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import "@goauthentik/admin/common/ak-flow-search/ak-source-flow-search";
|
||||
import { iconHelperText, placeholderHelperText } from "@goauthentik/admin/helperText";
|
||||
import { BaseSourceForm } from "@goauthentik/admin/sources/BaseSourceForm";
|
||||
import { UserMatchingModeToLabel } from "@goauthentik/admin/sources/oauth/utils";
|
||||
import { DEFAULT_CONFIG, config } from "@goauthentik/common/api/config";
|
||||
import { first } from "@goauthentik/common/utils";
|
||||
@ -8,7 +9,6 @@ import "@goauthentik/elements/CodeMirror";
|
||||
import { CodeMirrorMode } from "@goauthentik/elements/CodeMirror";
|
||||
import "@goauthentik/elements/forms/FormGroup";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
import "@goauthentik/elements/forms/SearchSelect";
|
||||
|
||||
import { msg } from "@lit/localize";
|
||||
@ -28,7 +28,7 @@ import {
|
||||
} from "@goauthentik/api";
|
||||
|
||||
@customElement("ak-source-oauth-form")
|
||||
export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
|
||||
export class OAuthSourceForm extends BaseSourceForm<OAuthSource> {
|
||||
async loadInstance(pk: string): Promise<OAuthSource> {
|
||||
const source = await new SourcesApi(DEFAULT_CONFIG).sourcesOauthRetrieve({
|
||||
slug: pk,
|
||||
@ -61,14 +61,6 @@ export class OAuthSourceForm extends ModelForm<OAuthSource, string> {
|
||||
@state()
|
||||
clearIcon = false;
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.instance) {
|
||||
return msg("Successfully updated source.");
|
||||
} else {
|
||||
return msg("Successfully created source.");
|
||||
}
|
||||
}
|
||||
|
||||
async send(data: OAuthSource): Promise<OAuthSource> {
|
||||
data.providerType = (this.providerType?.slug || "") as ProviderTypeEnum;
|
||||
let source: OAuthSource;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import "@goauthentik/admin/common/ak-flow-search/ak-source-flow-search";
|
||||
import { iconHelperText, placeholderHelperText } from "@goauthentik/admin/helperText";
|
||||
import { BaseSourceForm } from "@goauthentik/admin/sources/BaseSourceForm";
|
||||
import { UserMatchingModeToLabel } from "@goauthentik/admin/sources/oauth/utils";
|
||||
import { DEFAULT_CONFIG, config } from "@goauthentik/common/api/config";
|
||||
import { PlexAPIClient, PlexResource, popupCenterScreen } from "@goauthentik/common/helpers/plex";
|
||||
@ -7,7 +8,6 @@ import { ascii_letters, digits, first, randomString } from "@goauthentik/common/
|
||||
import { rootInterface } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/forms/FormGroup";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
import "@goauthentik/elements/forms/SearchSelect";
|
||||
|
||||
import { msg } from "@lit/localize";
|
||||
@ -24,7 +24,7 @@ import {
|
||||
} from "@goauthentik/api";
|
||||
|
||||
@customElement("ak-source-plex-form")
|
||||
export class PlexSourceForm extends ModelForm<PlexSource, string> {
|
||||
export class PlexSourceForm extends BaseSourceForm<PlexSource> {
|
||||
async loadInstance(pk: string): Promise<PlexSource> {
|
||||
const source = await new SourcesApi(DEFAULT_CONFIG).sourcesPlexRetrieve({
|
||||
slug: pk,
|
||||
@ -50,14 +50,6 @@ export class PlexSourceForm extends ModelForm<PlexSource, string> {
|
||||
} as PlexSource;
|
||||
}
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.instance) {
|
||||
return msg("Successfully updated source.");
|
||||
} else {
|
||||
return msg("Successfully created source.");
|
||||
}
|
||||
}
|
||||
|
||||
async send(data: PlexSource): Promise<PlexSource> {
|
||||
data.plexToken = this.plexToken || "";
|
||||
let source: PlexSource;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
import "@goauthentik/admin/common/ak-crypto-certificate-search";
|
||||
import "@goauthentik/admin/common/ak-flow-search/ak-source-flow-search";
|
||||
import { iconHelperText, placeholderHelperText } from "@goauthentik/admin/helperText";
|
||||
import { BaseSourceForm } from "@goauthentik/admin/sources/BaseSourceForm";
|
||||
import { UserMatchingModeToLabel } from "@goauthentik/admin/sources/oauth/utils";
|
||||
import { DEFAULT_CONFIG, config } from "@goauthentik/common/api/config";
|
||||
import { first } from "@goauthentik/common/utils";
|
||||
import { rootInterface } from "@goauthentik/elements/Base";
|
||||
import "@goauthentik/elements/forms/FormGroup";
|
||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||
import "@goauthentik/elements/forms/Radio";
|
||||
import "@goauthentik/elements/utils/TimeDeltaHelp";
|
||||
|
||||
@ -29,7 +29,7 @@ import {
|
||||
} from "@goauthentik/api";
|
||||
|
||||
@customElement("ak-source-saml-form")
|
||||
export class SAMLSourceForm extends ModelForm<SAMLSource, string> {
|
||||
export class SAMLSourceForm extends BaseSourceForm<SAMLSource> {
|
||||
@state()
|
||||
clearIcon = false;
|
||||
|
||||
@ -41,14 +41,6 @@ export class SAMLSourceForm extends ModelForm<SAMLSource, string> {
|
||||
return source;
|
||||
}
|
||||
|
||||
getSuccessMessage(): string {
|
||||
if (this.instance) {
|
||||
return msg("Successfully updated source.");
|
||||
} else {
|
||||
return msg("Successfully created source.");
|
||||
}
|
||||
}
|
||||
|
||||
async send(data: SAMLSource): Promise<SAMLSource> {
|
||||
let source: SAMLSource;
|
||||
if (this.instance) {
|
||||
|
||||
Reference in New Issue
Block a user