Skip to content

Commit 98cfbd9

Browse files
authored
Stop sending hidden parameters (#21)
1 parent d5323ad commit 98cfbd9

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/app/screens/product-action-screen/product-action-screen.component.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,4 +972,29 @@ describe('ProductActionScreenComponent', () => {
972972
expect(toastServiceSpy.showToast).not.toHaveBeenCalled();
973973
expect(routerSpy.navigate).toHaveBeenCalledWith(['/project 1/components']);
974974
});
975+
976+
it('should not include parameters with visible set to false in actionParams', () => {
977+
catalogServiceSpy.getProjectProduct.and.returnValue(of({
978+
title: 'fakeProduct',
979+
actions: [
980+
{
981+
id: 'fakeAction',
982+
label: 'Fake Action',
983+
requestable: true,
984+
parameters: [
985+
{ name: 'visible_param', required: true, type: 'string', visible: true },
986+
{ name: 'hidden_param', required: false, type: 'string', visible: false },
987+
{ name: 'another_visible_param', required: false, type: 'string' }
988+
]
989+
}
990+
]
991+
} as AppProduct));
992+
993+
activatedRouteSubject.next({ 'id': 'fakeId', 'catalogSlug': 'catalog', 'action': 'fakeAction' });
994+
995+
const paramNames = component.actionParams.map(p => p.name);
996+
expect(paramNames).not.toContain('hidden_param');
997+
expect(paramNames).toContain('visible_param');
998+
expect(paramNames).toContain('another_visible_param');
999+
});
9751000
});

src/app/screens/product-action-screen/product-action-screen.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export class ProductActionScreenComponent implements OnInit, OnDestroy {
194194
}
195195

196196
private setupActionParameters(productAction: ProductAction): void {
197-
const productActionParams = productAction.parameters?.filter(param => param.name !== 'project_key') || [];
197+
const productActionParams = productAction.parameters?.filter(param => param.name !== 'project_key' && param.visible !== false) || [];
198198

199199
if (productActionParams.length > 0) {
200200
this.addProjectKeyParameter(productActionParams);

0 commit comments

Comments
 (0)