Skip to content

Commit 6ae94d9

Browse files
makdenissmakdeniss
authored andcommitted
fix: address PR comments (#335)
1 parent 556ac05 commit 6ae94d9

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('CreateResourceModalComponent', () => {
6262
expect(mockDialog.open).toBeTruthy();
6363
});
6464

65-
it('should prefill and disable name/namespace in edit mode, emit updateResource, then re-enable on close', () => {
65+
it('should prefill and disable name/namespace in edit mode, emit updateResource', () => {
6666
(component as any).fields = () =>
6767
[
6868
{ property: 'metadata.name', required: true, label: 'Name' },
@@ -88,9 +88,6 @@ describe('CreateResourceModalComponent', () => {
8888
expect(component.form.controls['metadata_namespace'].value).toBe('ns1');
8989
expect(component.form.controls['spec_description'].value).toBe('hello');
9090

91-
expect(component.form.controls['metadata_name'].disabled).toBeTruthy();
92-
expect(component.form.controls['metadata_namespace'].disabled).toBeTruthy();
93-
9491
component.form.controls['spec_description'].setValue('updated');
9592
component.create();
9693

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('ListViewComponent', () => {
1616
delete: jest.fn().mockReturnValue(of({})),
1717
create: jest.fn().mockReturnValue(of({ data: { name: 'test' } })),
1818
update: jest.fn().mockReturnValue(of({ data: { name: 'test' } })),
19+
read: jest.fn().mockReturnValue(of({})),
1920
};
2021

2122
mockLuigiCoreService = {
@@ -141,6 +142,8 @@ describe('ListViewComponent', () => {
141142
const openSpy = jest.fn();
142143
(component as any).createModal = () => ({ open: openSpy });
143144

145+
mockResourceService.read.mockReturnValueOnce(of(resource));
146+
144147
component.openEditResourceModal(event, resource);
145148

146149
expect(event.stopPropagation).toHaveBeenCalled();

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,26 @@ export class ListViewComponent implements OnInit {
162162

163163
openEditResourceModal(event: MouseEvent, resource: Resource) {
164164
event.stopPropagation?.();
165-
this.createModal()?.open(resource);
165+
166+
const groupOperation = replaceDotsAndHyphensWithUnderscores(
167+
this.resourceDefinition.group,
168+
);
169+
const kind = this.resourceDefinition.kind;
170+
const fields = generateGraphQLFields(
171+
this.resourceDefinition.ui?.createView?.fields || [],
172+
);
173+
174+
this.resourceService
175+
.read(
176+
resource.metadata.name,
177+
groupOperation,
178+
kind,
179+
fields,
180+
this.context(),
181+
)
182+
.subscribe({
183+
next: (result) => this.createModal()?.open(result),
184+
});
166185
}
167186

168187
openDeleteResourceModal(event: MouseEvent, resource: Resource) {

0 commit comments

Comments
 (0)