From c31707751b3dceb3a206eac043cf3c2df2425f0e Mon Sep 17 00:00:00 2001 From: Mike Burgess Date: Thu, 10 Nov 2022 19:00:27 +0000 Subject: [PATCH] Dashboard UI should inform users when they are running a different UI version to the CLI. Closes #2728. (#2734) --- .github/workflows/release_cli_and_assets.yml | 1 + CHANGELOG.md | 8 ++ pkg/dashboard/dashboardserver/payload.go | 4 + pkg/dashboard/dashboardserver/types.go | 5 ++ ui/dashboard/package.json | 1 + .../src/components/ErrorMessage/index.tsx | 4 +- .../src/components/Modal/ErrorModal.js | 19 ---- .../src/components/Modal/ErrorModal.tsx | 17 ++++ ui/dashboard/src/components/Modal/index.js | 83 ------------------ ui/dashboard/src/components/Modal/index.tsx | 86 +++++++++++++++++++ .../components/VersionErrorMismatch/index.tsx | 35 ++++++++ ui/dashboard/src/hooks/useDashboard.tsx | 24 ++++++ ui/dashboard/src/hooks/useTheme.tsx | 13 +++ ui/dashboard/src/types/index.ts | 6 ++ ui/dashboard/src/utils/storybook.tsx | 1 + ui/dashboard/yarn.lock | 7 ++ 16 files changed, 211 insertions(+), 103 deletions(-) delete mode 100644 ui/dashboard/src/components/Modal/ErrorModal.js create mode 100644 ui/dashboard/src/components/Modal/ErrorModal.tsx delete mode 100644 ui/dashboard/src/components/Modal/index.js create mode 100644 ui/dashboard/src/components/Modal/index.tsx create mode 100644 ui/dashboard/src/components/VersionErrorMismatch/index.tsx diff --git a/.github/workflows/release_cli_and_assets.yml b/.github/workflows/release_cli_and_assets.yml index e6f0fcb92..fd4ef7dc2 100644 --- a/.github/workflows/release_cli_and_assets.yml +++ b/.github/workflows/release_cli_and_assets.yml @@ -156,6 +156,7 @@ jobs: yarn build env: REACT_APP_HEAP_ID: ${{ secrets.HEAP_ANALYTICS_PRODUCTION_ID }} + REACT_APP_VERSION: ${{ env.VERSION }} - name: Move Build Assets run: |- diff --git a/CHANGELOG.md b/CHANGELOG.md index 336e9fd45..76cfb3c89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ _What's new?_ * Add support for visualisations of your data with graphs, with easily composable data structures using nodes and edges. ([tbd]) * Improved dashboard UI panel controls for quicker access to common tasks such as downloading panel data. ([#2510](https://github.com/turbot/steampipe/issues/2510), [#2663](https://github.com/turbot/steampipe/issues/2663)) +## v0.17.1 [tbd] +_Bug fixes_ +* Fix query command `--export` flag raising an error that it cannot be used in interactive mode, even when not in interactive mode. ([#2707](https://github.com/turbot/steampipe/issues/2707)) +* Fix RefreshConnections sometimes storing an unset plugin ModTime property in the connection state file. This leads to failure to refresh connections when plugin has been rebuilt or updated. ([#2721](https://github.com/turbot/steampipe/issues/2721)) +* Fix dashboard text inputs being editable in snapshot mode. ([#2717](https://github.com/turbot/steampipe/issues/2717)) +* Fix dashboard JSONB columns in CSV data downloads not serialising correctly. ([#2733](https://github.com/turbot/steampipe/issues/2733)) +* Add dashboard error modal when users are running a different UI and CLI version ([#2728](https://github.com/turbot/steampipe/issues/2728)) + ## v0.17.0 [2022-11-08] _What's new?_ diff --git a/pkg/dashboard/dashboardserver/payload.go b/pkg/dashboard/dashboardserver/payload.go index f40a03a8a..4c714d38e 100644 --- a/pkg/dashboard/dashboardserver/payload.go +++ b/pkg/dashboard/dashboardserver/payload.go @@ -10,6 +10,7 @@ import ( "github.com/turbot/steampipe/pkg/dashboard/dashboardexecute" "github.com/turbot/steampipe/pkg/steampipeconfig" "github.com/turbot/steampipe/pkg/steampipeconfig/modconfig" + "github.com/turbot/steampipe/pkg/version" ) func buildDashboardMetadataPayload(workspaceResources *modconfig.ResourceMaps, cloudMetadata *steampipeconfig.CloudMetadata) ([]byte, error) { @@ -29,6 +30,9 @@ func buildDashboardMetadataPayload(workspaceResources *modconfig.ResourceMaps, c payload := DashboardMetadataPayload{ Action: "dashboard_metadata", Metadata: DashboardMetadata{ + CLI: DashboardCLIMetadata{ + Version: version.VersionString, + }, InstalledMods: installedMods, Telemetry: viper.GetString(constants.ArgTelemetry), }, diff --git a/pkg/dashboard/dashboardserver/types.go b/pkg/dashboard/dashboardserver/types.go index dac72b51f..93d29777b 100644 --- a/pkg/dashboard/dashboardserver/types.go +++ b/pkg/dashboard/dashboardserver/types.go @@ -147,9 +147,14 @@ type ModDashboardMetadata struct { ShortName string `json:"short_name"` } +type DashboardCLIMetadata struct { + Version string `json:"version,omitempty"` +} + type DashboardMetadata struct { Mod *ModDashboardMetadata `json:"mod,omitempty"` InstalledMods map[string]ModDashboardMetadata `json:"installed_mods,omitempty"` + CLI DashboardCLIMetadata `json:"cli"` Cloud *steampipeconfig.CloudMetadata `json:"cloud,omitempty"` Telemetry string `json:"telemetry"` } diff --git a/ui/dashboard/package.json b/ui/dashboard/package.json index 798c6fa05..86b94c7fe 100644 --- a/ui/dashboard/package.json +++ b/ui/dashboard/package.json @@ -45,6 +45,7 @@ "react-use-websocket": "4.2.0", "reactflow": "11.2.0", "remark-gfm": "3.0.1", + "semver": "7.3.8", "use-deep-compare-effect": "1.8.1", "uuid": "9.0.0", "web-vitals": "3.0.4" diff --git a/ui/dashboard/src/components/ErrorMessage/index.tsx b/ui/dashboard/src/components/ErrorMessage/index.tsx index b432bd8ee..42aa1dcfb 100644 --- a/ui/dashboard/src/components/ErrorMessage/index.tsx +++ b/ui/dashboard/src/components/ErrorMessage/index.tsx @@ -1,8 +1,10 @@ +import { isValidElement } from "react"; + const getErrorMessage = (error: any, fallbackMessage: string) => { if (!error) { return fallbackMessage; } - if (typeof error === "string") { + if (isValidElement(error)) { return error; } if (error.message) { diff --git a/ui/dashboard/src/components/Modal/ErrorModal.js b/ui/dashboard/src/components/Modal/ErrorModal.js deleted file mode 100644 index c4366f035..000000000 --- a/ui/dashboard/src/components/Modal/ErrorModal.js +++ /dev/null @@ -1,19 +0,0 @@ -import ErrorMessage from "../ErrorMessage"; -import Modal from "./index"; -import { ErrorIcon } from "../../constants/icons"; - -const ErrorModal = ({ error, title }) => { - return ( -