diff --git a/.gitignore b/.gitignore index 244b9b05..027ba14c 100644 --- a/.gitignore +++ b/.gitignore @@ -108,4 +108,5 @@ cypress/screenshots ## Helm gitignore -tmp/ \ No newline at end of file +tmp/ +.DS_Store \ No newline at end of file diff --git a/cypress/e2e/StatusList.spec.cy.ts b/cypress/e2e/StatusList.spec.cy.ts index c5a54287..6e9a4acd 100644 --- a/cypress/e2e/StatusList.spec.cy.ts +++ b/cypress/e2e/StatusList.spec.cy.ts @@ -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'; @@ -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(); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index ac3c7b81..39fba4c2 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -18,6 +18,7 @@ declare global { options?: Partial, ): Chainable; byLegacyTestID(selector: string): Chainable; + clickOutside(): Chainable; } } } @@ -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 +}); diff --git a/cypress/support/selectors.ts b/cypress/support/selectors.ts index 1c4c5113..3c241cf5 100644 --- a/cypress/support/selectors.ts +++ b/cypress/support/selectors.ts @@ -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"]'; diff --git a/plugin-manifest.ts b/plugin-manifest.ts index 079dd70b..0e7824ed 100644 --- a/plugin-manifest.ts +++ b/plugin-manifest.ts @@ -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', @@ -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, + ...PolicyExtensions, + ...StateExtensions, +]; diff --git a/src/utils/flags/consts.ts b/src/utils/flags/consts.ts new file mode 100644 index 00000000..0c817671 --- /dev/null +++ b/src/utils/flags/consts.ts @@ -0,0 +1 @@ +export const FLAG_NMSTATE_DYNAMIC = 'NMSTATE_DYNAMIC'; diff --git a/src/utils/flags/enableNMStateDynamicFlag.ts b/src/utils/flags/enableNMStateDynamicFlag.ts new file mode 100644 index 00000000..65a6399d --- /dev/null +++ b/src/utils/flags/enableNMStateDynamicFlag.ts @@ -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); diff --git a/src/utils/flags/index.ts b/src/utils/flags/index.ts new file mode 100644 index 00000000..1740344b --- /dev/null +++ b/src/utils/flags/index.ts @@ -0,0 +1 @@ +export { enableNMStateDynamicFlag } from './enableNMStateDynamicFlag';