Skip to content

Commit

Permalink
Merge pull request rancher#10601 from richard-cox/fix-legacy-project-…
Browse files Browse the repository at this point in the history
…menu-item

Fix Legacy / Project group
  • Loading branch information
richard-cox authored Mar 26, 2024
2 parents 64e3e92 + 5129a7e commit 513ba0c
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 23 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/po/lists/management.cattle.io.feature.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export default class MgmtFeatureFlagListPo extends BaseResourceList {
}

clickRowActionMenuItem(name: string, itemLabel:string) {
return this.resourceTable().sortableTable().rowActionMenuOpen(name, 4).getMenuItem(itemLabel)
return this.resourceTable().sortableTable().rowActionMenuOpen(name).getMenuItem(itemLabel)
.click();
}

getRowActionMenuItem(name: string, itemLabel:string) {
return this.resourceTable().sortableTable().rowActionMenuOpen(name, 4).getMenuItem(itemLabel);
return this.resourceTable().sortableTable().rowActionMenuOpen(name).getMenuItem(itemLabel);
}
}
15 changes: 15 additions & 0 deletions cypress/e2e/po/pages/global-settings/feature-flags.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,19 @@ export class FeatureFlagsPagePo extends RootClusterPage {
expect(response?.body.spec).to.have.property('value', value);
});
}

getFeatureFlag(featureFlag: string): Cypress.Chainable<Object> {
return cy.getRancherResource('v1', 'management.cattle.io.features', featureFlag).then((r) => r.body);
}

setFeatureFlag(featureFlag: string, value: boolean) {
return this.getFeatureFlag(featureFlag).then((res) => {
const obj = {
...res,
spec: { value }
};

cy.setRancherResource('v1', 'management.cattle.io.features', featureFlag, JSON.stringify(obj));
});
}
}
4 changes: 4 additions & 0 deletions cypress/e2e/po/pages/page.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export default class PagePo extends ComponentPo {
nav.navToSideMenuEntryByLabel(label);
}

productNav(): ProductNavPo {
return new ProductNavPo();
}

header() {
return new HeaderPo();
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/po/side-bars/product-side-nav.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default class ProductNavPo extends ComponentPo {
}

/**
* Check existance of menu group by label
* Check existence of menu group by label
*/
navToSideMenuGroupByLabelExistance(label: string, assertion: string): Cypress.Chainable {
navToSideMenuGroupByLabelExistence(label: string, assertion: string): Cypress.Chainable {
return this.self().should('exist').contains('.accordion.has-children', label).should(assertion);
}

Expand Down
50 changes: 50 additions & 0 deletions cypress/e2e/tests/pages/explorer/legacy/projects.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

import { FeatureFlagsPagePo } from '@/cypress/e2e/po/pages/global-settings/feature-flags.po';
import { ConfigMapPagePo } from '@/cypress/e2e/po/pages/explorer/config-map.po';
import { NamespaceFilterPo } from '@/cypress/e2e/po/components/namespace-filter.po';

const featureFlagsPage = new FeatureFlagsPagePo();
const namespacePicker = new NamespaceFilterPo();

let disableLegacyFlag = false;

describe('Legacy: Projects', { tags: ['@explorer', '@adminUser'], testIsolation: 'off' }, () => {
before(() => {
cy.login();

featureFlagsPage.getFeatureFlag('legacy').then((body: any) => {
if (!body.spec.value) {
return featureFlagsPage.setFeatureFlag('legacy', true).then(() => {
disableLegacyFlag = true;
});
}
});
});

it('Ensure legacy: projects is visible and can nav to child entry', () => {
const configMapPage = new ConfigMapPagePo('local');

configMapPage.goTo();

namespacePicker.toggle();
namespacePicker.clickOptionByLabel('All Namespaces');
namespacePicker.clickOptionByLabel('Project: Default');
namespacePicker.closeDropdown();

configMapPage.navToSideMenuGroupByLabel('Legacy');
configMapPage.productNav().navToSideMenuGroupByLabelExistence('Project', 'exist');
configMapPage.navToSideMenuGroupByLabel('Project');
configMapPage.navToSideMenuEntryByLabel('Config Maps');

cy.iFrame().contains('.header h1', 'Config Maps');
});

after(() => {
if (disableLegacyFlag) {
featureFlagsPage.setFeatureFlag('legacy', false);
}

namespacePicker.toggle();
namespacePicker.clickOptionByLabel('Only User Namespaces'); // This is the default
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/tests/pages/manager/cluster-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs
const sideNav = new ProductNavPo();

// check that the nav group isn't visible anymore
sideNav.navToSideMenuGroupByLabelExistance('RKE1 Configuration', 'not.exist');
sideNav.navToSideMenuGroupByLabelExistence('RKE1 Configuration', 'not.exist');
});

describe('All providers', () => {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Cluster Manager', { testIsolation: 'off', tags: ['@manager', '@adminUs

const sideNav = new ProductNavPo();

sideNav.navToSideMenuGroupByLabelExistance('RKE1 Configuration', 'exist');
sideNav.navToSideMenuGroupByLabelExistence('RKE1 Configuration', 'exist');
// EO test for https://github.com/rancher/dashboard/issues/9823

createRKE2ClusterPage.rkeToggle().set('RKE2/K3s');
Expand Down
1 change: 1 addition & 0 deletions shell/assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ nav:
RBAC: RBAC
Scheduling: Scheduling
Storage: Storage
Project: Project
ns:
all: All Namespaces
clusterLevel: Only Cluster Resources
Expand Down
13 changes: 8 additions & 5 deletions shell/components/nav/Type.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
},
showCount() {
return this.count !== undefined;
return this.count !== undefined && this.count !== null;
},
namespaceIcon() {
Expand Down Expand Up @@ -170,7 +170,7 @@ export default {
:class="{'no-icon': !type.icon}"
/>
<span
v-if="showFavorite || showCount"
v-if="showFavorite || namespaceIcon || showCount"
class="count"
>
<Favorite
Expand All @@ -179,9 +179,12 @@ export default {
/>
<i
v-if="namespaceIcon"
class="icon icon-namespace namespaced"
class="icon icon-namespace"
:class="{'ns-and-icon': showCount}"
/>
{{ count }}
<span
v-if="showCount"
>{{ count }}</span>
</span>
</a>
</n-link>
Expand All @@ -206,7 +209,7 @@ export default {
</template>
<style lang="scss" scoped>
.namespaced {
.ns-and-icon {
margin-right: 4px;
}
Expand Down
13 changes: 2 additions & 11 deletions shell/config/product/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export function init(store) {
product,
basicType,
virtualType,
setGroupDefaultType,
} = DSL(store, NAME);

product({
Expand All @@ -16,17 +17,6 @@ export function init(store) {
showNamespaceFilter: true,
});

virtualType({
ifHave: IF_HAVE.PROJECT,
labelKey: 'legacy.project.label',
namespaced: true,
name: 'v1-project',
weight: 105,
route: { name: 'c-cluster-project-apps' },
exact: true,
overview: false,
});

virtualType({
ifHave: IF_HAVE.NO_PROJECT,
labelKey: 'legacy.project.label',
Expand Down Expand Up @@ -68,4 +58,5 @@ export function init(store) {
'project-config-maps',
'project-secrets',
], 'Project');
setGroupDefaultType('project-config-maps', 'Project');
}
2 changes: 1 addition & 1 deletion shell/store/type-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,11 +937,11 @@ export const getters = {
const virtualTypes = state.virtualTypes[product] || [];
const spoofedTypes = state.spoofedTypes[product] || [];
const allTypes = [...virtualTypes, ...spoofedTypes];
const virtSpoofedModes = [...nonUsedModes];

for ( const type of allTypes ) {
const item = clone(type);
const id = item.name;
const virtSpoofedModes = [...nonUsedModes];

// Is there a virtual/spoofed type override for schema type?
// Currently used by harvester, this should be investigated and removed if possible
Expand Down

0 comments on commit 513ba0c

Please sign in to comment.