mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DashboardScene: Add rows keyboard shortcuts (#90275)
* DashboardScene: Add rows keyboard shortcuts * e2e test
This commit is contained in:
parent
3a51260ef9
commit
2d35b11323
24
e2e/scenes/dashboards-suite/dashboard-keybindings.spec.ts
Normal file
24
e2e/scenes/dashboards-suite/dashboard-keybindings.spec.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { e2e } from '../utils';
|
||||
|
||||
describe('Dashboard keybindings', () => {
|
||||
beforeEach(() => {
|
||||
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
||||
});
|
||||
|
||||
it('should collapse and expand all rows', () => {
|
||||
e2e.flows.openDashboard({ uid: 'Repeating-rows-uid/repeating-rows' });
|
||||
e2e.components.Panels.Panel.content().should('have.length', 5);
|
||||
e2e.components.Panels.Panel.title('server = A, pod = Bob').should('be.visible');
|
||||
e2e.components.Panels.Panel.title('server = B, pod = Bob').should('be.visible');
|
||||
|
||||
cy.get('body').type('d').type('{shift}c');
|
||||
e2e.components.Panels.Panel.content().should('have.length', 0);
|
||||
e2e.components.Panels.Panel.title('server = A, pod = Bob').should('not.exist');
|
||||
e2e.components.Panels.Panel.title('server = B, pod = Bob').should('not.exist');
|
||||
|
||||
cy.get('body').type('d').type('{shift}e');
|
||||
e2e.components.Panels.Panel.content().should('have.length', 6);
|
||||
e2e.components.Panels.Panel.title('server = A, pod = Bob').should('be.visible');
|
||||
e2e.components.Panels.Panel.title('server = B, pod = Bob').should('be.visible');
|
||||
});
|
||||
});
|
@ -877,6 +877,40 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
||||
this.setState({ isDirty: false });
|
||||
locationService.replace('/');
|
||||
}
|
||||
|
||||
public collapseAllRows() {
|
||||
if (!(this.state.body instanceof SceneGridLayout)) {
|
||||
throw new Error('Dashboard scene layout is not SceneGridLayout');
|
||||
}
|
||||
|
||||
const sceneGridLayout = this.state.body;
|
||||
|
||||
sceneGridLayout.state.children.forEach((child) => {
|
||||
if (!(child instanceof SceneGridRow)) {
|
||||
return;
|
||||
}
|
||||
if (!child.state.isCollapsed) {
|
||||
sceneGridLayout.toggleRow(child);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public expandAllRows() {
|
||||
if (!(this.state.body instanceof SceneGridLayout)) {
|
||||
throw new Error('Dashboard scene layout is not SceneGridLayout');
|
||||
}
|
||||
|
||||
const sceneGridLayout = this.state.body;
|
||||
|
||||
sceneGridLayout.state.children.forEach((child) => {
|
||||
if (!(child instanceof SceneGridRow)) {
|
||||
return;
|
||||
}
|
||||
if (child.state.isCollapsed) {
|
||||
sceneGridLayout.toggleRow(child);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DashboardVariableDependency implements SceneVariableDependencyConfigLike {
|
||||
|
@ -167,12 +167,26 @@ export function setupKeyboardShortcuts(scene: DashboardScene) {
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
// collapse all rows
|
||||
keybindings.addBinding({
|
||||
key: 'd shift+c',
|
||||
onTrigger: () => {
|
||||
scene.collapseAllRows();
|
||||
},
|
||||
});
|
||||
|
||||
// expand all rows
|
||||
keybindings.addBinding({
|
||||
key: 'd shift+e',
|
||||
onTrigger: () => {
|
||||
scene.expandAllRows();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// toggle all panel legends (TODO)
|
||||
// toggle all exemplars (TODO)
|
||||
// collapse all rows (TODO)
|
||||
// expand all rows (TODO)
|
||||
|
||||
return () => {
|
||||
keybindings.removeAll();
|
||||
|
Loading…
Reference in New Issue
Block a user