mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Merge pull request #50174 from nextcloud/backport/50152/stable30
[stable30] fix(dashboard): don't initially load items of hidden api widgets
This commit is contained in:
commit
e315ca8fe8
4 changed files with 44 additions and 5 deletions
|
|
@ -288,7 +288,7 @@ export default {
|
|||
|
||||
const apiWidgetIdsToFetch = Object
|
||||
.values(this.apiWidgets)
|
||||
.filter(widget => this.isApiWidgetV2(widget.id))
|
||||
.filter(widget => this.isApiWidgetV2(widget.id) && this.layout.includes(widget.id))
|
||||
.map(widget => widget.id)
|
||||
await Promise.all(apiWidgetIdsToFetch.map(id => this.fetchApiWidgetItems([id], true)))
|
||||
|
||||
|
|
@ -382,9 +382,11 @@ export default {
|
|||
const index = this.layout.indexOf(panel.id)
|
||||
if (!currentValue && index > -1) {
|
||||
this.layout.splice(index, 1)
|
||||
|
||||
} else {
|
||||
this.layout.push(panel.id)
|
||||
if (this.isApiWidgetV2(panel.id)) {
|
||||
this.fetchApiWidgetItems([panel.id], true)
|
||||
}
|
||||
}
|
||||
Vue.set(this.panels[panel.id], 'mounted', false)
|
||||
this.saveLayout()
|
||||
|
|
|
|||
37
cypress/e2e/dashboard/widget-performance.cy.ts
Normal file
37
cypress/e2e/dashboard/widget-performance.cy.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*!
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Regression test of https://github.com/nextcloud/server/issues/48403
|
||||
* Ensure that only visible widget data is loaded
|
||||
*/
|
||||
describe('dashboard: performance', () => {
|
||||
before(() => {
|
||||
cy.createRandomUser().then((user) => {
|
||||
cy.login(user)
|
||||
})
|
||||
})
|
||||
|
||||
it('Only load needed widgets', () => {
|
||||
cy.intercept('**/dashboard/api/v2/widget-items?widgets%5B%5D=user_status').as('loadedWidgets')
|
||||
|
||||
const now = new Date(2025, 0, 14, 15)
|
||||
cy.clock(now)
|
||||
|
||||
// The dashboard is loaded
|
||||
cy.visit('/apps/dashboard')
|
||||
cy.get('#app-dashboard')
|
||||
.should('be.visible')
|
||||
.contains('Good afternoon')
|
||||
.should('be.visible')
|
||||
|
||||
// Wait and check no requests are made
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(4000, { timeout: 8000 })
|
||||
cy.get('@loadedWidgets.all').then((interceptions) => {
|
||||
expect(interceptions).to.have.length(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
4
dist/dashboard-main.js
vendored
4
dist/dashboard-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/dashboard-main.js.map
vendored
2
dist/dashboard-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue