Skip to content

Commit

Permalink
Fix UI cluster closing issues while using text based filtering (#1274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin authored Mar 14, 2024
1 parent 41c0089 commit 6d55a45
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
7 changes: 7 additions & 0 deletions cypress/e2e/clusters/cluster-filter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ describe('Testing cluster filters', () => {
() => {
cy.get('.q-virtual-scroll__content > :nth-child(2)').click({
force: true,
multiple: true,
})
cy.fixture('data').then((data) => {
cy.get('tbody').children().should('contain', data.cluster2)
})
}
)
it('Close all the clusters', () => {
cy.dataCy('cluster-btn-closeall').click()
cy.get('[data-test=Cluster').each(($row) => {
cy.wrap($row).should('have.class', 'q-expansion-item--collapsed')
})
})
})
6 changes: 6 additions & 0 deletions cypress/e2e/clusters/cluster-multiple-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ describe('Add multiple clusters and search', () => {
cy.get('tbody').children().should('contain', data.cluster2)
})
})
it('Close all the clusters', () => {
cy.dataCy('cluster-btn-closeall').click()
cy.get('[data-test=Cluster').each(($row) => {
cy.wrap($row).should('have.class', 'q-expansion-item--collapsed')
})
})
})
19 changes: 19 additions & 0 deletions cypress/e2e/clusters/cluster-search.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ describe('Testing cluster search', () => {
cy.get('tbody').children().should('contain', data.cluster2)
})
})
it('check individual cluster closing and opening', () => {
cy.get('[data-test=Cluster').each(($row) => {
cy.wrap($row).should('have.class', 'q-expansion-item--expanded')
})
cy.dataCy('cluster-general').children().children().eq(0).click()
cy.dataCy('cluster-general').should(
'have.class',
'q-expansion-item--collapsed'
)
cy.dataCy('cluster-general').children().children().eq(0).click()
cy.dataCy('cluster-general').should(
'have.class',
'q-expansion-item--expanded'
)
cy.dataCy('cluster-btn-closeall').click()
cy.get('[data-test=Cluster').each(($row) => {
cy.wrap($row).should('have.class', 'q-expansion-item--collapsed')
})
})
})
11 changes: 9 additions & 2 deletions src/components/ZclClusterManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ limitations under the License.
dense
@update:model-value="changeDomainFilter($event)"
data-test="filter-input"
data-cy="cluster-domain-filter"
/>
</div>

Expand All @@ -70,6 +71,7 @@ limitations under the License.
@clear="changeFilterString('')"
:model-value="filterString"
data-test="search-clusters"
data-cy="cluster-text-filter"
>
<template v-slot:prepend>
<q-icon name="search" />
Expand All @@ -83,7 +85,11 @@ limitations under the License.
rounded
@click="doActionFilter(actionOption)"
:label="actionOption.label"
color="primary"
color="secondary"
:data-cy="
'cluster-btn-' +
actionOption.label.replace(/\s/g, '').toLowerCase()
"
/>
</div>
</div>
Expand All @@ -99,6 +105,7 @@ limitations under the License.
@update:model-value="setOpenDomain(domainName, $event)"
:model-value="getDomainOpenState(domainName)"
data-test="Cluster"
:data-cy="'cluster-' + domainName.replace(/\s/g, '').toLowerCase()"
header-class="bg-white text-primary"
>
<q-card>
Expand Down Expand Up @@ -301,7 +308,7 @@ export default {
})
},
getDomainOpenState(domainName) {
return this.openDomains[domainName] || this.filterString != ''
return this.openDomains[domainName]
},
changeDomainFilter(filter) {
this.$store.dispatch('zap/setDomainFilter', {
Expand Down
15 changes: 7 additions & 8 deletions src/store/zap/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,23 +488,22 @@ export function setDomainFilter(state, filterEnabledClusterPair) {
let filter = filterEnabledClusterPair.filter
state.clusterManager.filter = filter
state.domains.map((domainName) => {
const openDomainValue =
state.clusterManager.filterString === ''
? filter.domainFilterFn(domainName, state.clusterManager.openDomains, {
enabledClusters: filterEnabledClusterPair.enabledClusters,
})
: true
setOpenDomain(state, {
domainName: domainName,
value: filter.domainFilterFn(
domainName,
state.clusterManager.openDomains,
{
enabledClusters: filterEnabledClusterPair.enabledClusters,
}
),
value: openDomainValue,
})
})
}

export function doActionFilter(state, filterEnabledClusterPair) {
let filter = filterEnabledClusterPair.filter
// When we close all, we also clear all filters.
resetFilters(state)
state.domains.map((domainName) => {
setOpenDomain(state, {
domainName: domainName,
Expand Down

0 comments on commit 6d55a45

Please sign in to comment.