diff --git a/cypress/e2e/tests/pages/manager/kontainer-drivers.spec.ts b/cypress/e2e/tests/pages/manager/kontainer-drivers.spec.ts index 1b5999f1442..75d2fcc1139 100644 --- a/cypress/e2e/tests/pages/manager/kontainer-drivers.spec.ts +++ b/cypress/e2e/tests/pages/manager/kontainer-drivers.spec.ts @@ -19,6 +19,7 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin let driverId = ''; const oracleDriver = 'Oracle OKE'; const linodeDriver = 'Linode LKE'; + const exampleDriver = 'Example'; before(() => { cy.login(); @@ -64,12 +65,8 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin driverId = response?.body.id; }); - // Will use the below assertions until this issue is resolved https://github.com/rancher/dashboard/issues/11046. - // Using 'downloadUrl' instead of driver name - // driversPage.list().details('Example', 1).should('contain', 'Activating'); - // driversPage.list().details('Example', 1).contains('Active', { timeout: 60000 }); - driversPage.list().details(downloadUrl, 1).should('contain', 'Activating'); - driversPage.list().details(downloadUrl, 1).contains('Active', { timeout: 60000 }); + driversPage.list().details(exampleDriver, 1).should('contain', 'Activating'); + driversPage.list().details(exampleDriver, 1).contains('Active', { timeout: 60000 }); ClusterManagerListPagePo.navTo(); clusterList.waitForPage(); @@ -87,15 +84,13 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin KontainerDriversPagePo.navTo(); driversPage.waitForPage(); - driversPage.list().details(downloadUrl, 2).find('span').invoke('text') - .then((t) => { - cy.intercept('POST', `/v3/kontainerDrivers/${ t }?action=deactivate`).as('deactivateDriver'); - driversPage.list().actionMenu(downloadUrl).getMenuItem('Deactivate').click(); - const deactivateDialog = new DeactivateDriverDialogPo(); + cy.intercept('POST', `/v3/kontainerDrivers/*?action=deactivate`).as('deactivateDriver'); - deactivateDialog.deactivate(); - }); + driversPage.list().actionMenu(downloadUrl).getMenuItem('Deactivate').click(); + const deactivateDialog = new DeactivateDriverDialogPo(); + + deactivateDialog.deactivate(); cy.wait('@deactivateDriver').then(({ request, response }) => { expect(response?.statusCode).to.eq(200); @@ -115,12 +110,11 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin KontainerDriversPagePo.navTo(); driversPage.waitForPage(); - driversPage.list().details(downloadUrl, 2).find('span').invoke('text') - .then((t) => { - cy.intercept('POST', `/v3/kontainerDrivers/${ t }?action=activate`).as('activateDriver'); - driversPage.list().actionMenu(downloadUrl).getMenuItem('Activate').click(); - }); + cy.intercept('POST', `/v3/kontainerDrivers/*?action=activate`).as('activateDriver'); + + driversPage.list().actionMenu(downloadUrl).getMenuItem('Activate').click(); + cy.wait('@activateDriver').then(({ request, response }) => { expect(response?.statusCode).to.eq(200); expect(isMatch(request.body, requestData)).to.equal(true); @@ -180,8 +174,7 @@ describe('Kontainer Drivers', { testIsolation: 'off', tags: ['@manager', '@admin createCluster.gridElementExistanceByName(linodeDriver, 'exist'); }); - it.skip('can deactivate drivers in bulk', () => { - // Skipping this test until issue is resolved https://github.com/rancher/dashboard/issues/10718 + it('can deactivate drivers in bulk', () => { KontainerDriversPagePo.navTo(); driversPage.waitForPage(); driversPage.list().details(oracleDriver, 1).should('contain', 'Active'); diff --git a/cypress/e2e/tests/pages/manager/node-drivers.spec.ts b/cypress/e2e/tests/pages/manager/node-drivers.spec.ts index 55ee27f23e2..1b38a5e0211 100644 --- a/cypress/e2e/tests/pages/manager/node-drivers.spec.ts +++ b/cypress/e2e/tests/pages/manager/node-drivers.spec.ts @@ -112,12 +112,8 @@ describe.skip('Node Drivers', { testIsolation: 'off', tags: ['@manager', '@admin expect(isMatch(request.body, requestData)).to.equal(true); }); - // Will use the below assertions until this issue is resolved https://github.com/rancher/dashboard/issues/11046. - // Using 'downloadUrl' instead of driver name - // driversPage.list().details(cloudCaDriver, 1).should('contain', 'Downloading'); - // driversPage.list().details(cloudCaDriver, 1).contains('Active', { timeout: 15000 }); - driversPage.list().details(downloadUrl2, 1).should('contain', 'Downloading'); - driversPage.list().details(downloadUrl2, 1).contains('Active', { timeout: 60000 }); + driversPage.list().details(cloudCaDriver, 1).should('contain', 'Downloading'); + driversPage.list().details(cloudCaDriver, 1).contains('Active', { timeout: 15000 }); ClusterManagerListPagePo.navTo(); clusterList.waitForPage(); @@ -246,8 +242,7 @@ describe.skip('Node Drivers', { testIsolation: 'off', tags: ['@manager', '@admin createCluster.gridElementExistanceByName(openStackDriver, 'not.exist'); }); - it.skip('can delete drivers in bulk', () => { - // Skipping this test until issue is resolved https://github.com/rancher/dashboard/issues/10718 + it('can delete drivers in bulk', () => { NodeDriversPagePo.navTo(); driversPage.waitForPage(); driversPage.list().resourceTable().sortableTable().rowSelectCtlWithName(oracleDriver) diff --git a/shell/assets/translations/en-us.yaml b/shell/assets/translations/en-us.yaml index 7a19ee3a20a..2e869b2fbc4 100644 --- a/shell/assets/translations/en-us.yaml +++ b/shell/assets/translations/en-us.yaml @@ -2225,7 +2225,22 @@ drivers: refresh: Refresh Kubernetes Metadata deactivate: title: Are you sure? - warning: You will no longer be able to edit the configuration of clusters using {name} driver. Resources in the provider will not be automatically removed. + andOthers: |- + {count, plural, + =0 {} + =1 { and one other } + other { and {count} other } + } + warningDrivers: |- + {count, plural, + =1 { You will no longer be able to edit the configuration of clusters using {names} driver.} + other { You will no longer be able to edit the configuration of clusters using {names} drivers.} + } + warning: |- + {count, plural, + =1 { {warningDrivers} Resources in the corresponding provider will not be automatically removed.} + other { {warningDrivers} Resources in the corresponding providers will not be automatically removed.} + } detailText: collapse: Hide diff --git a/shell/dialog/DeactivateDriverDialog.vue b/shell/dialog/DeactivateDriverDialog.vue index 305ce9108d2..143d323129a 100644 --- a/shell/dialog/DeactivateDriverDialog.vue +++ b/shell/dialog/DeactivateDriverDialog.vue @@ -3,6 +3,8 @@ import AsyncButton from '@shell/components/AsyncButton'; import { Card } from '@components/Card'; import { Banner } from '@components/Banner'; import { exceptionToErrorsArray } from '@shell/utils/error'; +import { resourceNames } from '@shell/utils/string'; +import { mapGetters } from 'vuex'; export default { components: { @@ -12,20 +14,35 @@ export default { }, props: { - url: { - type: String, - default: null, + drivers: { + type: Array, + required: true }, - name: { - type: String, - default: null, + driverType: { + type: String, + required: true } }, data() { return { errors: [] }; }, + computed: { + formattedText() { + const namesSliced = this.drivers.map((obj) => obj.nameDisplay).slice(0, 5); + const remaining = this.drivers.length - namesSliced.length; + + const plusMore = this.t('drivers.deactivate.andOthers', { count: remaining }); + const names = resourceNames(namesSliced, plusMore, this.t); + const count = remaining || namesSliced.length; + const warningDrivers = this.t('drivers.deactivate.warningDrivers', { names, count }); + + return this.t('drivers.deactivate.warning', { warningDrivers, count: namesSliced.length }); + }, + ...mapGetters({ t: 'i18n/t' }), + }, methods: { + resourceNames, close(buttonDone) { if (buttonDone && typeof buttonDone === 'function') { buttonDone(true); @@ -34,10 +51,12 @@ export default { }, async apply(buttonDone) { try { - await this.$store.dispatch('rancher/request', { - url: this.url, - method: 'post' - }); + await Promise.all(this.drivers.map( + (driver) => this.$store.dispatch('rancher/request', { + url: `v3/${ this.driverType }/${ escape(driver.id) }?action=deactivate`, + method: 'POST' + }) + )); this.close(buttonDone); } catch (err) { @@ -64,7 +83,7 @@ export default {