DashboardScene: Activate refresh picker manually when time controls are hidden (#89952)

---------

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
Sergej-Vlasov 2024-07-03 18:43:44 +03:00 committed by GitHub
parent 0bbaed187c
commit acf5c7c6ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 95 additions and 45 deletions

View File

@ -261,7 +261,7 @@
"@grafana/prometheus": "workspace:*",
"@grafana/runtime": "workspace:*",
"@grafana/saga-icons": "workspace:*",
"@grafana/scenes": "^5.3.4",
"@grafana/scenes": "5.3.5",
"@grafana/schema": "workspace:*",
"@grafana/sql": "workspace:*",
"@grafana/ui": "workspace:*",

View File

@ -14,6 +14,7 @@ import {
sceneGraph,
SceneObjectUrlSyncConfig,
SceneObjectUrlValues,
CancelActivationHandler,
} from '@grafana/scenes';
import { Box, Stack, useStyles2 } from '@grafana/ui';
@ -74,6 +75,20 @@ export class DashboardControls extends SceneObjectBase<DashboardControlsState> {
refreshPicker: state.refreshPicker ?? new SceneRefreshPicker({}),
...state,
});
this.addActivationHandler(() => {
let refreshPickerDeactivation: CancelActivationHandler | undefined;
if (this.state.hideTimeControls) {
refreshPickerDeactivation = this.state.refreshPicker.activate();
}
return () => {
if (refreshPickerDeactivation) {
refreshPickerDeactivation();
}
};
});
}
/**

View File

@ -68,7 +68,7 @@ export function DashboardSceneRenderer({ model }: SceneComponentProps<DashboardS
>
{scopes && !meta.dashboardNotFound && <scopes.Component model={scopes} />}
<NavToolbarActions dashboard={model} />
{controls && hasControls && (
{controls && (
<div
className={cx(styles.controlsWrapper, scopes && !isScopesExpanded && styles.controlsWrapperWithScopes)}
>

121
yarn.lock
View File

@ -285,7 +285,14 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.18.9, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.24.5, @babel/helper-plugin-utils@npm:^7.24.7, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3":
"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.18.9, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.24.5, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3":
version: 7.24.5
resolution: "@babel/helper-plugin-utils@npm:7.24.5"
checksum: 10/6e11ca5da73e6bd366848236568c311ac10e433fc2034a6fe6243af28419b07c93b4386f87bbc940aa058b7c83f370ef58f3b0fd598106be040d21a3d1c14276
languageName: node
linkType: hard
"@babel/helper-plugin-utils@npm:^7.24.7":
version: 7.24.7
resolution: "@babel/helper-plugin-utils@npm:7.24.7"
checksum: 10/dad51622f0123fdba4e2d40a81a6b7d6ef4b1491b2f92fd9749447a36bde809106cf117358705057a2adc8fd73d5dc090222e0561b1213dae8601c8367f5aac8
@ -2450,7 +2457,16 @@ __metadata:
languageName: node
linkType: hard
"@floating-ui/dom@npm:^1.0.0, @floating-ui/dom@npm:^1.0.1":
"@floating-ui/core@npm:^1.6.0":
version: 1.6.0
resolution: "@floating-ui/core@npm:1.6.0"
dependencies:
"@floating-ui/utils": "npm:^0.2.1"
checksum: 10/d6a47cacde193cd8ccb4c268b91ccc4ca254dffaec6242b07fd9bcde526044cc976d27933a7917f9a671de0a0e27f8d358f46400677dbd0c8199de293e9746e1
languageName: node
linkType: hard
"@floating-ui/dom@npm:^1.0.0":
version: 1.6.5
resolution: "@floating-ui/dom@npm:1.6.5"
dependencies:
@ -2460,6 +2476,16 @@ __metadata:
languageName: node
linkType: hard
"@floating-ui/dom@npm:^1.0.1":
version: 1.6.1
resolution: "@floating-ui/dom@npm:1.6.1"
dependencies:
"@floating-ui/core": "npm:^1.6.0"
"@floating-ui/utils": "npm:^0.2.1"
checksum: 10/c010feb55be37662eb4cc8d0a22e21359c25247bbdcd9557617fd305cf08c8f020435b17e4b4f410201ba9abe3a0dd96b5c42d56e85f7a5e11e7d30b85afc116
languageName: node
linkType: hard
"@floating-ui/react-dom@npm:^2.1.0":
version: 2.1.0
resolution: "@floating-ui/react-dom@npm:2.1.0"
@ -2486,7 +2512,7 @@ __metadata:
languageName: node
linkType: hard
"@floating-ui/utils@npm:^0.2.0":
"@floating-ui/utils@npm:^0.2.0, @floating-ui/utils@npm:^0.2.1":
version: 0.2.1
resolution: "@floating-ui/utils@npm:0.2.1"
checksum: 10/33c9ab346e7b05c5a1e6a95bc902aafcfc2c9d513a147e2491468843bd5607531b06d0b9aa56aa491cbf22a6c2495c18ccfc4c0344baec54a689a7bb8e4898d6
@ -3100,13 +3126,13 @@ __metadata:
linkType: soft
"@grafana/e2e-selectors@npm:^11.0.0":
version: 11.0.0
resolution: "@grafana/e2e-selectors@npm:11.0.0"
version: 11.1.0
resolution: "@grafana/e2e-selectors@npm:11.1.0"
dependencies:
"@grafana/tsconfig": "npm:^1.3.0-rc1"
tslib: "npm:2.6.2"
typescript: "npm:5.3.3"
checksum: 10/0e327c5afc342bca9be46b0b3fb7b55d69e8b7b6e9912be3255ce52abcb8832265246a0e6b2f877112a752b6e44f6f7edf5c4d2a32b5edc84800d19c880dfc6c
tslib: "npm:2.6.3"
typescript: "npm:5.4.5"
checksum: 10/010a32e8b562d0da83b008646b9928a96a79957096eed713aa67b227d8ad6055d22cc0ec26f87fd9839cfb28344d0012f49c3c823defc6e91f4ab05ed7d8c465
languageName: node
linkType: hard
@ -3554,9 +3580,9 @@ __metadata:
languageName: unknown
linkType: soft
"@grafana/scenes@npm:^5.3.4":
version: 5.3.6
resolution: "@grafana/scenes@npm:5.3.6"
"@grafana/scenes@npm:5.3.5":
version: 5.3.5
resolution: "@grafana/scenes@npm:5.3.5"
dependencies:
"@grafana/e2e-selectors": "npm:^11.0.0"
"@leeoniya/ufuzzy": "npm:^1.0.14"
@ -3571,7 +3597,7 @@ __metadata:
"@grafana/ui": ^10.4.1
react: ^18.0.0
react-dom: ^18.0.0
checksum: 10/d487f6f1c53f4dba1562925f4d69c75b5882ce0cdb5cdf95eb6998c3f4fcf13e597200e44e47ff9105bee1e1be23007e568bbe52c5049f92e27f9a14abe00178
checksum: 10/2ffbbda4a90e9b0f17c6a4d9b210b97321cc531427c1b11c75b32c72631c4122950bc310bb103cb29f17a50a98844fd91ae689872625614b0284befc61081eb5
languageName: node
linkType: hard
@ -5719,7 +5745,7 @@ __metadata:
languageName: node
linkType: hard
"@radix-ui/react-portal@npm:1.0.4, @radix-ui/react-portal@npm:^1.0.1":
"@radix-ui/react-portal@npm:1.0.4":
version: 1.0.4
resolution: "@radix-ui/react-portal@npm:1.0.4"
dependencies:
@ -5739,6 +5765,26 @@ __metadata:
languageName: node
linkType: hard
"@radix-ui/react-portal@npm:^1.0.1":
version: 1.0.3
resolution: "@radix-ui/react-portal@npm:1.0.3"
dependencies:
"@babel/runtime": "npm:^7.13.10"
"@radix-ui/react-primitive": "npm:1.0.3"
peerDependencies:
"@types/react": "*"
"@types/react-dom": "*"
react: ^16.8 || ^17.0 || ^18.0
react-dom: ^16.8 || ^17.0 || ^18.0
peerDependenciesMeta:
"@types/react":
optional: true
"@types/react-dom":
optional: true
checksum: 10/d352bcd6ad65eb43c9e0d72d0755c2aae85e03fb287770866262be3a2d5302b2885aee3cd99f2bbf62ecd14fcb1460703f1dcdc40351f77ad887b931c6f0012a
languageName: node
linkType: hard
"@radix-ui/react-presence@npm:1.0.1":
version: 1.0.1
resolution: "@radix-ui/react-presence@npm:1.0.1"
@ -17099,7 +17145,7 @@ __metadata:
"@grafana/prometheus": "workspace:*"
"@grafana/runtime": "workspace:*"
"@grafana/saga-icons": "workspace:*"
"@grafana/scenes": "npm:^5.3.4"
"@grafana/scenes": "npm:5.3.5"
"@grafana/schema": "workspace:*"
"@grafana/sql": "workspace:*"
"@grafana/tsconfig": "npm:^1.3.0-rc1"
@ -18148,7 +18194,16 @@ __metadata:
languageName: node
linkType: hard
"i18next@npm:^23.0.0, i18next@npm:^23.11.5, i18next@npm:^23.5.1":
"i18next@npm:^23.0.0, i18next@npm:^23.5.1":
version: 23.11.3
resolution: "i18next@npm:23.11.3"
dependencies:
"@babel/runtime": "npm:^7.23.2"
checksum: 10/9d562ade19d0beba16683ff94967a6dedc0a32ce335d203c5a160f075ac5a9a7a9adb164085a6b7b69328568bc932a65b92664834c2bf3e15d8f3bff90f15353
languageName: node
linkType: hard
"i18next@npm:^23.11.5":
version: 23.11.5
resolution: "i18next@npm:23.11.5"
dependencies:
@ -29377,13 +29432,6 @@ __metadata:
languageName: node
linkType: hard
"tslib@npm:2.6.2":
version: 2.6.2
resolution: "tslib@npm:2.6.2"
checksum: 10/bd26c22d36736513980091a1e356378e8b662ded04204453d353a7f34a4c21ed0afc59b5f90719d4ba756e581a162ecbf93118dc9c6be5acf70aa309188166ca
languageName: node
linkType: hard
"tslib@npm:2.6.3, tslib@npm:^2.0.0, tslib@npm:^2.0.1, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.4.1, tslib@npm:^2.6.2":
version: 2.6.3
resolution: "tslib@npm:2.6.3"
@ -29522,13 +29570,20 @@ __metadata:
languageName: node
linkType: hard
"type-fest@npm:^4.18.2, type-fest@npm:^4.9.0":
"type-fest@npm:^4.18.2":
version: 4.18.3
resolution: "type-fest@npm:4.18.3"
checksum: 10/eb750920d0ef3639177f581edd6489d972c5c5827abb602a9c9662889aad148a7d558257e36c563f1beb81a2e417faec52ecec9799b28531d8335856f91e6dff
languageName: node
linkType: hard
"type-fest@npm:^4.9.0":
version: 4.10.2
resolution: "type-fest@npm:4.10.2"
checksum: 10/2b1ad1270d9fabeeb506ba831d513caeb05bfc852e5e012511d785ce9dc68d773fe0a42bddf857a362c7f3406244809c5b8a698b743bb7617d4a8c470672087f
languageName: node
linkType: hard
"type-is@npm:~1.6.18":
version: 1.6.18
resolution: "type-is@npm:1.6.18"
@ -29622,16 +29677,6 @@ __metadata:
languageName: node
linkType: hard
"typescript@npm:5.3.3":
version: 5.3.3
resolution: "typescript@npm:5.3.3"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10/6e4e6a14a50c222b3d14d4ea2f729e79f972fa536ac1522b91202a9a65af3605c2928c4a790a4a50aa13694d461c479ba92cedaeb1e7b190aadaa4e4b96b8e18
languageName: node
linkType: hard
"typescript@npm:5.4.5, typescript@npm:>=2.7, typescript@npm:>=3 < 6, typescript@npm:^5.0.0, typescript@npm:^5.0.4, typescript@npm:^5.2.2":
version: 5.4.5
resolution: "typescript@npm:5.4.5"
@ -29652,16 +29697,6 @@ __metadata:
languageName: node
linkType: hard
"typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>":
version: 5.3.3
resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10/c93786fcc9a70718ba1e3819bab56064ead5817004d1b8186f8ca66165f3a2d0100fee91fa64c840dcd45f994ca5d615d8e1f566d39a7470fc1e014dbb4cf15d
languageName: node
linkType: hard
"typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A>=2.7#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A>=3 < 6#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A^5.0.0#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A^5.0.4#optional!builtin<compat/typescript>, typescript@patch:typescript@npm%3A^5.2.2#optional!builtin<compat/typescript>":
version: 5.4.5
resolution: "typescript@patch:typescript@npm%3A5.4.5#optional!builtin<compat/typescript>::version=5.4.5&hash=5adc0c"