Skip to content

Commit aa72037

Browse files
committed
Add property accessors, types.
1 parent ac191d7 commit aa72037

25 files changed

Lines changed: 121 additions & 105 deletions

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"#tests/*": "./tests/*.js",
7373
"#e2e": "./e2e/index.ts",
7474
"#e2e/*": "./e2e/*.ts",
75+
"#types/*": "./types/*/index.d.ts",
7576
"#*/browser": {
7677
"types": "./out/*/browser.d.ts",
7778
"import": "./*/browser.js"

web/src/admin/applications/ApplicationCheckAccessForm.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList
2424
@customElement("ak-application-check-access-form")
2525
export class ApplicationCheckAccessForm extends Form<{ forUser: number }> {
2626
@property({ attribute: false })
27-
application!: Application;
27+
public application!: Application;
2828

2929
@property({ attribute: false })
30-
result: PolicyTestResult | null = null;
30+
public result: PolicyTestResult | null = null;
3131

3232
@property({ attribute: false })
33-
request?: number;
33+
public request?: number;
3434

3535
getSuccessMessage(): string {
3636
return msg("Successfully sent test-request.");
@@ -45,7 +45,7 @@ export class ApplicationCheckAccessForm extends Form<{ forUser: number }> {
4545
return (this.result = result);
4646
}
4747

48-
reset(): void {
48+
public override reset(): void {
4949
super.reset();
5050
this.result = null;
5151
}

web/src/admin/applications/ApplicationForm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class ApplicationForm extends WithCapabilitiesConfig(ModelForm<Applicatio
5757
@state()
5858
protected backchannelProviders: Provider[] = [];
5959

60-
reset(): void {
60+
public override reset(): void {
6161
super.reset();
6262
this.backchannelProviders = [];
6363
}

web/src/admin/blueprints/BlueprintForm.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,32 @@ import { ifDefined } from "lit/directives/if-defined.js";
2222

2323
import PFContent from "@patternfly/patternfly/components/Content/content.css";
2424

25-
enum blueprintSource {
26-
file = "file",
27-
oci = "oci",
28-
internal = "internal",
25+
enum BlueprintSource {
26+
File = "file",
27+
OCI = "oci",
28+
Internal = "internal",
2929
}
3030

3131
@customElement("ak-blueprint-form")
3232
export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
3333
@state()
34-
source: blueprintSource = blueprintSource.file;
34+
protected source: BlueprintSource = BlueprintSource.File;
3535

36-
reset(): void {
36+
public override reset(): void {
3737
super.reset();
38-
this.source = blueprintSource.file;
38+
39+
this.source = BlueprintSource.File;
3940
}
4041

4142
async loadInstance(pk: string): Promise<BlueprintInstance> {
4243
const inst = await new ManagedApi(DEFAULT_CONFIG).managedBlueprintsRetrieve({
4344
instanceUuid: pk,
4445
});
4546
if (inst.path?.startsWith("oci://")) {
46-
this.source = blueprintSource.oci;
47+
this.source = BlueprintSource.OCI;
4748
}
4849
if (inst.content !== "") {
49-
this.source = blueprintSource.internal;
50+
this.source = BlueprintSource.Internal;
5051
}
5152
return inst;
5253
}
@@ -91,17 +92,17 @@ export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
9192
<div class="pf-c-card__body">
9293
<ak-toggle-group
9394
value=${this.source}
94-
@ak-toggle=${(ev: CustomEvent<{ value: blueprintSource }>) => {
95+
@ak-toggle=${(ev: CustomEvent<{ value: BlueprintSource }>) => {
9596
this.source = ev.detail.value;
9697
}}
9798
>
98-
<option value=${blueprintSource.file}>${msg("Local path")}</option>
99-
<option value=${blueprintSource.oci}>${msg("OCI Registry")}</option>
100-
<option value=${blueprintSource.internal}>${msg("Internal")}</option>
99+
<option value=${BlueprintSource.File}>${msg("Local path")}</option>
100+
<option value=${BlueprintSource.OCI}>${msg("OCI Registry")}</option>
101+
<option value=${BlueprintSource.Internal}>${msg("Internal")}</option>
101102
</ak-toggle-group>
102103
</div>
103104
<div class="pf-c-card__footer">
104-
${this.source === blueprintSource.file
105+
${this.source === BlueprintSource.File
105106
? html`<ak-form-element-horizontal label=${msg("Path")} name="path">
106107
<ak-search-select
107108
.fetchObjects=${async (
@@ -132,7 +133,7 @@ export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
132133
</ak-search-select>
133134
</ak-form-element-horizontal>`
134135
: nothing}
135-
${this.source === blueprintSource.oci
136+
${this.source === BlueprintSource.OCI
136137
? html` <ak-text-input
137138
name="path"
138139
label=${msg("OCI URL")}
@@ -164,7 +165,7 @@ export class BlueprintForm extends ModelForm<BlueprintInstance, string> {
164165
>
165166
</ak-text-input>`
166167
: nothing}
167-
${this.source === blueprintSource.internal
168+
${this.source === BlueprintSource.Internal
168169
? html`<ak-form-element-horizontal label=${msg("Blueprint")} name="content">
169170
<ak-codemirror
170171
mode="yaml"

web/src/admin/endpoints/connectors/agent/EnrollmentTokenForm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ export class EnrollmentTokenForm extends WithBrandConfig(ModelForm<EnrollmentTok
3737
@property({ type: String, attribute: "connector-id" })
3838
public connectorID?: string;
3939

40-
reset(): void {
40+
public override reset(): void {
4141
super.reset();
42+
4243
this.expiresAt = new Date(Date.now() + EXPIRATION_DURATION);
4344
}
4445

web/src/admin/enterprise/EnterpriseLicenseForm.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,23 @@ import { DEFAULT_CONFIG } from "#common/api/config";
66
import { EVENT_REFRESH_ENTERPRISE } from "#common/constants";
77

88
import { ModelForm } from "#elements/forms/ModelForm";
9+
import { ifPresent } from "#elements/utils/attributes";
910

1011
import { EnterpriseApi, License } from "@goauthentik/api";
1112

1213
import { msg } from "@lit/localize";
1314
import { html, TemplateResult } from "lit";
1415
import { customElement, state } from "lit/decorators.js";
15-
import { ifDefined } from "lit/directives/if-defined.js";
1616

1717
@customElement("ak-enterprise-license-form")
1818
export class EnterpriseLicenseForm extends ModelForm<License, string> {
1919
@state()
20-
installID?: string;
20+
protected installID: string | null = null;
2121

22-
reset(): void {
22+
public override reset(): void {
2323
super.reset();
24-
this.installID = undefined;
24+
25+
this.installID = null;
2526
}
2627

2728
loadInstance(pk: string): Promise<License> {
@@ -66,7 +67,7 @@ export class EnterpriseLicenseForm extends ModelForm<License, string> {
6667
spellcheck="false"
6768
readonly
6869
type="text"
69-
value="${ifDefined(this.installID)}"
70+
value="${ifPresent(this.installID)}"
7071
/>
7172
</ak-form-element-horizontal>
7273
<ak-secret-textarea-input

web/src/admin/files/FileUploadForm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ export class FileUploadForm extends Form<Record<string, unknown>> {
6161

6262
#formRef = createRef<HTMLFormElement>();
6363

64-
reset(): void {
64+
public override reset(): void {
6565
super.reset();
66+
6667
this.selectedFile = null;
6768
}
6869

web/src/admin/flows/FlowImportForm.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList
2020

2121
@customElement("ak-flow-import-form")
2222
export class FlowImportForm extends Form<Flow> {
23+
static styles: CSSResult[] = [...super.styles, PFDescriptionList];
24+
2325
@state()
24-
result?: FlowImportResult;
26+
protected result: FlowImportResult | null = null;
2527

26-
reset(): void {
28+
public override reset(): void {
2729
super.reset();
28-
this.result = undefined;
30+
31+
this.result = null;
2932
}
3033

3134
getSuccessMessage(): string {
3235
return msg("Successfully imported flow.");
3336
}
3437

35-
static styles: CSSResult[] = [...super.styles, PFDescriptionList];
36-
3738
async send(): Promise<FlowImportResult> {
3839
const file = this.files().get("flow");
3940
if (!file) {

web/src/admin/flows/StageBindingForm.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ export class StageBindingForm extends ModelForm<FlowStageBinding, string> {
6161
}
6262

6363
@property()
64-
targetPk?: string;
64+
public targetPk?: string;
6565

6666
@state()
67-
defaultOrder = 0;
67+
protected defaultOrder = 0;
6868

69-
reset(): void {
69+
public override reset(): void {
7070
super.reset();
71+
7172
this.defaultOrder = 0;
7273
}
7374

web/src/admin/outposts/OutpostForm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ export class OutpostForm extends ModelForm<Outpost, string> {
106106

107107
defaultConfig?: OutpostDefaultConfig;
108108

109-
reset(): void {
109+
public override reset(): void {
110110
super.reset();
111+
111112
this.type = OutpostTypeEnum.Proxy;
112113
this.providers = providerProvider(this.type);
113114
}

0 commit comments

Comments
 (0)