Skip to content

Commit 802a590

Browse files
authored
Clean up default columns (#123)
* feat: cleanup default columns * fix: fix tests
1 parent be0b5b6 commit 802a590

File tree

5 files changed

+10
-109
lines changed

5 files changed

+10
-109
lines changed

projects/lib/portal-options/services/custom-global-nodes.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class CustomGlobalNodesServiceImpl implements CustomGlobalNodesService {
4444
children: [
4545
{
4646
pathSegment: 'overview',
47+
context: {} as PortalNodeContext,
4748
hideSideNav: true,
4849
hideFromNav: true,
4950
defineEntity: {

projects/wc/src/app/components/generic-ui/detail-view/detail-view.component.spec.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -138,55 +138,6 @@ describe('DetailViewComponent', () => {
138138
expect(mockAnchorElement.click).toHaveBeenCalled();
139139
});
140140

141-
it('should return default fields when ui.detailView.fields is undefined', () => {
142-
// Reset mocks and create new component instance
143-
jest.clearAllMocks();
144-
const newFixture = TestBed.createComponent(DetailViewComponent);
145-
const newComponent = newFixture.componentInstance;
146-
147-
newComponent.context = (() => ({
148-
resourceId: 'cluster-1',
149-
token: 'abc123',
150-
resourceDefinition: {
151-
kind: 'Cluster',
152-
group: 'core.k8s.io',
153-
ui: {
154-
detailView: {
155-
// fields is undefined
156-
},
157-
},
158-
},
159-
entity: {
160-
metadata: { name: 'test-resource' },
161-
},
162-
parentNavigationContexts: ['project'],
163-
})) as any;
164-
165-
newComponent.LuigiClient = (() => ({
166-
linkManager: () => ({
167-
fromContext: jest.fn().mockReturnThis(),
168-
navigate: jest.fn(),
169-
withParams: jest.fn().mockReturnThis(),
170-
}),
171-
uxManager: () => ({
172-
showAlert: jest.fn(),
173-
}),
174-
getNodeParams: jest.fn(),
175-
})) as any;
176-
177-
newFixture.detectChanges();
178-
179-
const defaultFields = [
180-
{
181-
label: 'Workspace Status',
182-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
183-
property: ['status.conditions.status', 'status.conditions.type'],
184-
},
185-
];
186-
187-
expect(newComponent.resourceFields()).toEqual(defaultFields);
188-
});
189-
190141
it('should call resource service with correct parameters for account kind', () => {
191142
jest.clearAllMocks();
192143
const newFixture = TestBed.createComponent(DetailViewComponent);

projects/wc/src/app/components/generic-ui/detail-view/detail-view.component.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { processFields } from '../../../utils/proccess-fields';
2+
import { validateKubeconfigProps } from '../../../utils/ts-guargs/validate-kubeconfig-props';
3+
import { ValueCellComponent } from '../value-cell/value-cell.component';
4+
import { kubeConfigTemplate } from './kubeconfig-template';
15
import {
26
ChangeDetectionStrategy,
37
Component,
@@ -10,7 +14,7 @@ import {
1014
} from '@angular/core';
1115
import { LuigiClient } from '@luigi-project/client/luigi-element';
1216
import { EnvConfigService } from '@openmfp/portal-ui-lib';
13-
import { FieldDefinition, Resource } from '@platform-mesh/portal-ui-lib/models';
17+
import { Resource } from '@platform-mesh/portal-ui-lib/models';
1418
import {
1519
GatewayService,
1620
ResourceNodeContext,
@@ -31,18 +35,6 @@ import {
3135
ToolbarButtonComponent,
3236
ToolbarComponent,
3337
} from '@ui5/webcomponents-ngx';
34-
import { processFields } from '../../../utils/proccess-fields';
35-
import { ValueCellComponent } from '../value-cell/value-cell.component';
36-
import { kubeConfigTemplate } from './kubeconfig-template';
37-
import { validateKubeconfigProps } from '../../../utils/ts-guargs/validate-kubeconfig-props';
38-
39-
const defaultFields: FieldDefinition[] = [
40-
{
41-
label: 'Workspace Status',
42-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
43-
property: ['status.conditions.status', 'status.conditions.type'],
44-
},
45-
];
4638

4739
@Component({
4840
selector: 'detail-view',
@@ -75,7 +67,7 @@ export class DetailViewComponent {
7567

7668
resourceDefinition = computed(() => this.context().resourceDefinition);
7769
resourceFields = computed(
78-
() => this.resourceDefinition()?.ui?.detailView?.fields || defaultFields,
70+
() => this.resourceDefinition()?.ui?.detailView?.fields ?? [],
7971
);
8072
resourceId = computed(() => this.context().entity?.metadata.name);
8173
workspacePath = computed(() =>
@@ -193,4 +185,4 @@ export class DetailViewComponent {
193185

194186
return resourceDefinition;
195187
}
196-
}
188+
}

projects/wc/src/app/components/generic-ui/list-view/list-view.component.spec.ts

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -197,37 +197,6 @@ describe('ListViewComponent', () => {
197197
expect(newComponent.hasUiCreateViewFields()).toBe(true);
198198
});
199199

200-
it('should use default columns when no listView fields are defined', () => {
201-
// Create a new component instance with different context
202-
const newFixture = TestBed.createComponent(ListViewComponent);
203-
const newComponent = newFixture.componentInstance;
204-
205-
newComponent.context = (() => ({
206-
resourceDefinition: {
207-
plural: 'clusters',
208-
kind: 'Cluster',
209-
group: 'core.k8s.io',
210-
ui: {
211-
// No listView fields defined
212-
},
213-
},
214-
})) as any;
215-
216-
newComponent.LuigiClient = (() => ({
217-
linkManager: () => ({
218-
fromContext: jest.fn().mockReturnThis(),
219-
navigate: jest.fn(),
220-
withParams: jest.fn().mockReturnThis(),
221-
}),
222-
getNodeParams: jest.fn(),
223-
})) as any;
224-
225-
newFixture.detectChanges();
226-
227-
expect(newComponent.columns().length).toBeGreaterThan(0);
228-
expect(newComponent.columns()[0].label).toBe('Name');
229-
});
230-
231200
it('should compute heading correctly with capitalized plural', () => {
232201
const newFixture = TestBed.createComponent(ListViewComponent);
233202
const newComponent = newFixture.componentInstance;

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1919
import { LuigiClient } from '@luigi-project/client/luigi-element';
2020
import { LuigiCoreService } from '@openmfp/portal-ui-lib';
21-
import { FieldDefinition, Resource } from '@platform-mesh/portal-ui-lib/models';
21+
import { Resource } from '@platform-mesh/portal-ui-lib/models';
2222
import {
2323
ResourceNodeContext,
2424
ResourceService,
@@ -44,18 +44,6 @@ import {
4444
ToolbarComponent,
4545
} from '@ui5/webcomponents-ngx';
4646

47-
const defaultColumns: FieldDefinition[] = [
48-
{
49-
label: 'Name',
50-
property: 'metadata.name',
51-
},
52-
{
53-
label: 'Workspace Status',
54-
jsonPathExpression: 'status.conditions[?(@.type=="Ready")].status',
55-
property: ['status.conditions.status', 'status.conditions.type'],
56-
},
57-
];
58-
5947
@Component({
6048
selector: 'list-view',
6149
standalone: true,
@@ -98,7 +86,7 @@ export class ListViewComponent implements OnInit {
9886
);
9987
resourceDefinition = computed(() => this.context().resourceDefinition);
10088
columns = computed(
101-
() => this.resourceDefinition()?.ui?.listView?.fields || defaultColumns,
89+
() => this.resourceDefinition()?.ui?.listView?.fields ?? [],
10290
);
10391
viewColomns = computed(() => processFields(this.columns()));
10492
readyCondition = computed(() => this.resourceDefinition()?.readyCondition);

0 commit comments

Comments
 (0)