Skip to content

Commit 53fefec

Browse files
committed
refactor: address pr comments
1 parent 1797c68 commit 53fefec

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
>
5858
@if (form.controls[fieldProperty].errors?.k8sNameInvalid) {
5959
<div slot="valueStateMessage">
60-
Invalid resource name <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names" target="_blank">RFC 1035</a>
60+
<a href="{{ k8sMessages.RFC_1035.href }}" target="_blank">{{ k8sMessages.RFC_1035.message }}</a>
6161
</div>
6262
}
6363
</ui5-input>

projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.component.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { k8sMessages } from '../../../../consts/k8s-messages';
12
import { k8sNameValidator } from '../../../../validators/k8s-name-validator';
23
import { DynamicSelectComponent } from '../../../dynamic-select/dynamic-select.component';
3-
import { CreateOnlyResourceFieldNames } from './create-resource-modal.enums';
4+
import { ResourceFieldNames } from './create-resource-modal.enums';
45
import {
56
Component,
67
OnInit,
@@ -66,6 +67,8 @@ export class CreateResourceModalComponent implements OnInit {
6667

6768
private originalResource = signal<Resource | null>(null);
6869

70+
protected readonly k8sMessages = k8sMessages;
71+
6972
ngOnInit(): void {
7073
this.form = this.fb.group(this.createControls());
7174
}
@@ -132,9 +135,9 @@ export class CreateResourceModalComponent implements OnInit {
132135

133136
isCreateFieldOnly(field: FieldDefinition): boolean {
134137
return (
135-
field.property === CreateOnlyResourceFieldNames.MetadataName ||
136-
field.property === CreateOnlyResourceFieldNames.SpecType ||
137-
field.property === CreateOnlyResourceFieldNames.MetadataNamespace
138+
field.property === ResourceFieldNames.MetadataName ||
139+
field.property === ResourceFieldNames.SpecType ||
140+
field.property === ResourceFieldNames.MetadataNamespace
138141
);
139142
}
140143

@@ -161,9 +164,7 @@ export class CreateResourceModalComponent implements OnInit {
161164
validators.push(Validators.required);
162165
}
163166

164-
if (
165-
fieldDefinition.property === CreateOnlyResourceFieldNames.MetadataName
166-
) {
167+
if (fieldDefinition.property === ResourceFieldNames.MetadataName) {
167168
validators.push(k8sNameValidator);
168169
}
169170

projects/wc/src/app/components/generic-ui/list-view/create-resource-modal/create-resource-modal.enums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export enum CreateOnlyResourceFieldNames {
1+
export enum ResourceFieldNames {
22
MetadataName = 'metadata.name',
33
SpecType = 'spec.type',
44
MetadataNamespace = 'metadata.namespace',

projects/wc/src/app/components/organization-management/organization-management.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
[valueState]="getValueState(newOrganization)"
4141
>
4242
<div slot="valueStateMessage">
43-
Invalid organization name <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names" target="_blank">RFC 1035</a>
43+
<a href="{{ k8sMessages.RFC_1035.href }}" target="_blank">{{ k8sMessages.RFC_1035.message }}</a>
4444
</div>
4545
</ui5-input>
4646
<ui5-button [disabled]="newOrganization.invalid" design="Emphasized" (ui5Click)="onboardOrganization()">{{

projects/wc/src/app/components/organization-management/organization-management.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { k8sMessages } from '../../consts/k8s-messages';
12
import { k8sNameValidator } from '../../validators/k8s-name-validator';
23
import {
34
ChangeDetectionStrategy,
@@ -60,6 +61,7 @@ export class OrganizationManagementComponent implements OnInit {
6061
private i18nService = inject(I18nService);
6162
private resourceService = inject(ResourceService);
6263
private envConfigService = inject(EnvConfigService);
64+
6365
context = input<ResourceNodeContext>();
6466
LuigiClient = input<LuigiClient>();
6567

@@ -71,6 +73,8 @@ export class OrganizationManagementComponent implements OnInit {
7173
nonNullable: true,
7274
});
7375

76+
protected readonly k8sMessages = k8sMessages;
77+
7478
constructor() {
7579
effect(() => {
7680
const ctx = this.context();
@@ -211,8 +215,8 @@ export class OrganizationManagementComponent implements OnInit {
211215

212216
if (!sanitizedOrg) {
213217
this.LuigiClient().uxManager().showAlert({
214-
text: 'Organization name is not valid for subdomain usage, accrording to RFC 1034/1123.',
215-
type: 'error',
218+
text: k8sMessages.RFC_1034_1123.message,
219+
type: k8sMessages.RFC_1034_1123.type,
216220
});
217221
return;
218222
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const k8sMessages = {
2+
RFC_1035: {
3+
href: 'https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names',
4+
message: 'Invalid resource name accrording to RFC 1035',
5+
type: 'error',
6+
},
7+
RFC_1034_1123: {
8+
href: 'https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names',
9+
message:
10+
'Organization name is not valid for subdomain usage, accrording to RFC 1034/1123.',
11+
type: 'error',
12+
},
13+
} as const;

0 commit comments

Comments
 (0)