From c0dd1b6d11a4076b82fba18efa989c04c952f7b5 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Tue, 19 Jan 2021 13:19:01 +0100 Subject: [PATCH] Dashboard: migrate version history list (#29970) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(dashboard): remove redundant directive code from SaveDashboardAsButton * feat(dashboard): initial commit of rendering version history with react * feat(dashboard): append versions, use historySrv, UI as functional components * feat(dashboard): initial commit of versions settings diff view * refactor(historylist): remove code related to listing versions * refactor(dashboard): use angular directive to render version comparison * refactor(dashboard): clean up versions settings * refactor(dashboard): move version history UI components into own files * refactor(dashboard): update typings for version history react components * feat(dashboard): initial commit of react revert dashboard modal * test(dashboardsettings): clean up historylistctrl tests * chore(dashboardsettings): remove unused state variable * test(dashboardsettings): initial commit of VersionSettings component tests * feat(grafana-ui): add className concatenation on Checkbox label * Apply suggestions from code review Co-authored-by: Dominik Prokop * test(dashboardsettings): add more tests for Versions Settings react component * test(dashboardsettings): add test to assert latest badge in Version history table * fix(dashboardsettings): pass string to getDiff instead of react event object * test(dashboardsettings): remove failing test from versions settings * Moved scroll area to content, and fixed colors * Update public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx Co-authored-by: Dominik Prokop * style(dashboardsettings): add new lines to versions settings tests Co-authored-by: Dominik Prokop Co-authored-by: Torkel Ödegaard --- .../src/components/Forms/Checkbox.tsx | 4 +- .../src/themes/_variables.dark.scss.tmpl.ts | 8 +- .../src/themes/_variables.light.scss.tmpl.ts | 8 +- public/app/core/angular_wrappers.ts | 14 -- .../DashboardSettings/DashboardSettings.tsx | 48 ++-- .../VersionsSettings.test.tsx | 142 ++++++++++++ .../DashboardSettings/VersionsSettings.tsx | 210 ++++++++++++++++-- .../DashboardSettings/__mocks__/versions.ts | 112 ++++++++++ .../SaveDashboard/SaveDashboardButton.tsx | 26 +-- .../VersionHistory/HistoryListCtrl.test.ts | 201 +++-------------- .../VersionHistory/HistoryListCtrl.ts | 126 +---------- .../components/VersionHistory/HistorySrv.ts | 3 + .../VersionHistory/RevertDashboardModal.tsx | 36 +++ .../VersionHistory/VersionHistoryButtons.tsx | 30 +++ .../VersionHistoryComparison.tsx | 47 ++++ .../VersionHistory/VersionHistoryHeader.tsx | 31 +++ .../VersionHistory/VersionHistoryTable.tsx | 66 ++++++ .../components/VersionHistory/template.html | 165 +++----------- .../VersionHistory/useDashboardRestore.tsx | 35 +++ public/sass/_variables.dark.generated.scss | 8 +- public/sass/_variables.light.generated.scss | 8 +- .../sass/components/_dashboard_settings.scss | 6 + 22 files changed, 820 insertions(+), 514 deletions(-) create mode 100644 public/app/features/dashboard/components/DashboardSettings/VersionsSettings.test.tsx create mode 100644 public/app/features/dashboard/components/DashboardSettings/__mocks__/versions.ts create mode 100644 public/app/features/dashboard/components/VersionHistory/RevertDashboardModal.tsx create mode 100644 public/app/features/dashboard/components/VersionHistory/VersionHistoryButtons.tsx create mode 100644 public/app/features/dashboard/components/VersionHistory/VersionHistoryComparison.tsx create mode 100644 public/app/features/dashboard/components/VersionHistory/VersionHistoryHeader.tsx create mode 100644 public/app/features/dashboard/components/VersionHistory/VersionHistoryTable.tsx create mode 100644 public/app/features/dashboard/components/VersionHistory/useDashboardRestore.tsx diff --git a/packages/grafana-ui/src/components/Forms/Checkbox.tsx b/packages/grafana-ui/src/components/Forms/Checkbox.tsx index ea704c4bced..b446b46e19e 100644 --- a/packages/grafana-ui/src/components/Forms/Checkbox.tsx +++ b/packages/grafana-ui/src/components/Forms/Checkbox.tsx @@ -93,7 +93,7 @@ export const getCheckboxStyles = stylesFactory((theme: GrafanaTheme) => { }); export const Checkbox = React.forwardRef( - ({ label, description, value, onChange, disabled, ...inputProps }, ref) => { + ({ label, description, value, onChange, disabled, className, ...inputProps }, ref) => { const theme = useTheme(); const handleOnChange = useCallback( (e: React.ChangeEvent) => { @@ -106,7 +106,7 @@ export const Checkbox = React.forwardRef( const styles = getCheckboxStyles(theme); return ( -