Skip to content

Commit

Permalink
CNV-48259: add flag for reference into other plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
upalatucci committed Sep 11, 2024
1 parent 84abc5b commit 105a8a6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,5 @@ cypress/screenshots

## Helm gitignore

tmp/
tmp/
.DS_Store
7 changes: 3 additions & 4 deletions cypress/e2e/StatusList.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
INTERFACE_DRAWER_TEST_ID,
LLDP_DRAWER_DETAILS_SECTION_TEST_ID,
LLDP_ENABLED_FILTER,
ROW_FILTERS_BUTTON,
SEARCH_FILTER_DROPDOWN,
} from '../support/selectors';

Expand Down Expand Up @@ -106,12 +105,12 @@ describe('NodeNetworkState list', () => {
cy.get('table').should('contain', nns.metadata.name);

// open filter toolbar
cy.get(ROW_FILTERS_BUTTON).click();
cy.get('button').contains('Filter').click();

cy.get(LLDP_ENABLED_FILTER).check();

// close filter toolbar
cy.get(ROW_FILTERS_BUTTON).click();
// close filter toolbar by clicking outside
cy.clickOutside();

cy.get('table').should('contain', nns.metadata.name);
cy.get(EXPAND_INTERFACES_LIST_TEST_ID).click();
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ declare global {
options?: Partial<Loggable & Timeoutable & Withinable & Shadow>,
): Chainable;
byLegacyTestID(selector: string): Chainable;
clickOutside(): Chainable;
}
}
}
Expand Down Expand Up @@ -83,3 +84,7 @@ Cypress.Commands.add('byTestID', (selector, options) =>
);

Cypress.Commands.add('byLegacyTestID', (selector) => cy.get(`[data-test-id="${selector}"]`));

Cypress.Commands.add('clickOutside', () => {
return cy.get('body').click(0, 0); //0,0 here are the x and y coordinates
});
4 changes: 1 addition & 3 deletions cypress/support/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ export const EXPAND_INTERFACE_INFO = 'ethernet-expandable-section-toggle';
export const INTERFACE_DRAWER_TEST_ID = 'interface-drawer';
export const LLDP_DRAWER_DETAILS_SECTION_TEST_ID = 'lldp-section';

export const ROW_FILTERS_BUTTON = 'button.pf-v5-c-select__toggle';

export const LLDP_ENABLED_FILTER = '#enabled[type="checkbox"]';
export const LLDP_ENABLED_FILTER = '#enabled [type="checkbox"]';

export const SEARCH_FILTER_DROPDOWN =
'button.pf-v5-c-dropdown__toggle[data-test-id="dropdown-button"]';
19 changes: 15 additions & 4 deletions plugin-manifest.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { EncodedExtension } from '@openshift/dynamic-plugin-sdk';
import type { ConsolePluginMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack/lib/schema/plugin-package';
import { FeatureFlag } from '@openshift-console/dynamic-plugin-sdk';
import type { ConsolePluginBuildMetadata } from '@openshift-console/dynamic-plugin-sdk-webpack';

import { PolicyExposedModules, PolicyExtensions } from './src/views/policies/manifest';
import { StateExposedModules, StateExtensions } from './src/views/states/manifest';

export const pluginMetadata = {
export const pluginMetadata: ConsolePluginBuildMetadata = {
name: 'nmstate-console-plugin',
version: '0.0.1',
displayName: 'OpenShift Console Plugin For NMState',
Expand All @@ -13,10 +14,20 @@ export const pluginMetadata = {
exposedModules: {
...PolicyExposedModules,
...StateExposedModules,
nmstateFlags: './utils/flags',
},
dependencies: {
'@console/pluginAPI': '*',
},
} as ConsolePluginMetadata;
};

export const extensions: EncodedExtension[] = [...PolicyExtensions, ...StateExtensions];
export const extensions: EncodedExtension[] = [
{
properties: {
handler: { $codeRef: 'nmstateFlags.enableNMStateDynamicFlag' },
},
type: 'console.flag',
} as EncodedExtension<FeatureFlag>,
...PolicyExtensions,
...StateExtensions,
];
1 change: 1 addition & 0 deletions src/utils/flags/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const FLAG_NMSTATE_DYNAMIC = 'NMSTATE_DYNAMIC';
6 changes: 6 additions & 0 deletions src/utils/flags/enableNMStateDynamicFlag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { SetFeatureFlag } from '@openshift-console/dynamic-plugin-sdk';

import { FLAG_NMSTATE_DYNAMIC } from './consts';

export const enableNMStateDynamicFlag = (setFeatureFlag: SetFeatureFlag) =>
setFeatureFlag(FLAG_NMSTATE_DYNAMIC, true);
1 change: 1 addition & 0 deletions src/utils/flags/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { enableNMStateDynamicFlag } from './enableNMStateDynamicFlag';

0 comments on commit 105a8a6

Please sign in to comment.