From 4ff7e2c6c9c0048bb65913e6aad0199c6d68dad1 Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Mon, 8 Apr 2024 10:07:21 -0700 Subject: [PATCH] Web console: Better manual capabilities detection indication (#16191) * Better forced mode indication * more robust * Update web-console/src/components/header-bar/header-bar.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/header-bar.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/__snapshots__/restricted-mode.spec.tsx.snap Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/__snapshots__/restricted-mode.spec.tsx.snap Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * Update web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx Co-authored-by: Charles Smith * reformat * forced => manual capability detection * typo * typo2 --------- Co-authored-by: Charles Smith --- .../__snapshots__/header-bar.spec.tsx.snap | 86 +++--- .../src/components/header-bar/header-bar.tsx | 251 ++++++------------ .../restricted-mode.spec.tsx.snap | 143 ++++++++++ .../restricted-mode/restricted-mode.spec.tsx | 44 +++ .../restricted-mode/restricted-mode.tsx | 184 +++++++++++++ web-console/src/console-application.tsx | 3 +- web-console/src/helpers/capabilities.ts | 10 +- web-console/src/helpers/capacity.ts | 1 - web-console/src/singletons/api.ts | 12 +- 9 files changed, 509 insertions(+), 225 deletions(-) create mode 100644 web-console/src/components/header-bar/restricted-mode/__snapshots__/restricted-mode.spec.tsx.snap create mode 100644 web-console/src/components/header-bar/restricted-mode/restricted-mode.spec.tsx create mode 100644 web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx diff --git a/web-console/src/components/header-bar/__snapshots__/header-bar.spec.tsx.snap b/web-console/src/components/header-bar/__snapshots__/header-bar.spec.tsx.snap index 18a352dbbc6..6c7cf34cb70 100644 --- a/web-console/src/components/header-bar/__snapshots__/header-bar.spec.tsx.snap +++ b/web-console/src/components/header-bar/__snapshots__/header-bar.spec.tsx.snap @@ -267,55 +267,53 @@ exports[`HeaderBar matches snapshot 1`] = ` - - - - - - + + + + } diff --git a/web-console/src/components/header-bar/header-bar.tsx b/web-console/src/components/header-bar/header-bar.tsx index d3c58db6bb5..9a66dbaeace 100644 --- a/web-console/src/components/header-bar/header-bar.tsx +++ b/web-console/src/components/header-bar/header-bar.tsx @@ -32,7 +32,6 @@ import { } from '@blueprintjs/core'; import { IconNames } from '@blueprintjs/icons'; import { Popover2 } from '@blueprintjs/popover2'; -import type { JSX } from 'react'; import React, { useState } from 'react'; import { @@ -51,9 +50,10 @@ import { localStorageSetJson, oneOf, } from '../../utils'; -import { ExternalLink } from '../external-link/external-link'; import { PopoverText } from '../popover-text/popover-text'; +import { RestrictedMode } from './restricted-mode/restricted-mode'; + import './header-bar.scss'; const capabilitiesOverride = localStorageGetJson(LocalStorageKeys.CAPABILITIES_OVERRIDE); @@ -92,143 +92,6 @@ const DruidLogo = React.memo(function DruidLogo() { ); }); -interface RestrictedModeProps { - capabilities: Capabilities; - onUnrestrict(capabilities: Capabilities): void; -} - -const RestrictedMode = React.memo(function RestrictedMode(props: RestrictedModeProps) { - const { capabilities, onUnrestrict } = props; - const mode = capabilities.getModeExtended(); - - let label: string; - let message: JSX.Element; - switch (mode) { - case 'full': - return null; // Do not show anything - - case 'no-sql': - label = 'No SQL mode'; - message = ( -

- It appears that the SQL endpoint is disabled. The console will fall back to{' '} - native Druid APIs and will be - limited in functionality. Look at{' '} - the SQL docs to enable the SQL - endpoint. -

- ); - break; - - case 'no-proxy': - label = 'No management proxy mode'; - message = ( -

- It appears that the management proxy is not enabled, the console will operate with limited - functionality. -

- ); - break; - - case 'no-sql-no-proxy': - label = 'No SQL mode'; - message = ( -

- It appears that the SQL endpoint and management proxy are disabled. The console can only - be used to make queries. -

- ); - break; - - case 'coordinator-overlord': - label = 'Coordinator/Overlord mode'; - message = ( -

- It appears that you are accessing the console on the Coordinator/Overlord shared service. - Due to the lack of access to some APIs on this service the console will operate in a - limited mode. The unrestricted version of the console can be accessed on the Router - service. -

- ); - break; - - case 'coordinator': - label = 'Coordinator mode'; - message = ( -

- It appears that you are accessing the console on the Coordinator service. Due to the lack - of access to some APIs on this service the console will operate in a limited mode. The - full version of the console can be accessed on the Router service. -

- ); - break; - - case 'overlord': - label = 'Overlord mode'; - message = ( -

- It appears that you are accessing the console on the Overlord service. Due to the lack of - access to some APIs on this service the console will operate in a limited mode. The - unrestricted version of the console can be accessed on the Router service. -

- ); - break; - - default: - label = 'Restricted mode'; - message = ( -

- Due to the lack of access to some APIs on this service the console will operate in a - limited mode. The unrestricted version of the console can be accessed on the Router - service. -

- ); - break; - } - - return ( - -

The console is running in restricted mode.

- {message} -

- For more info check out the{' '} - - web console documentation - - . -

-

- It is possible that there is an issue with the capability detection. You can enable the - unrestricted console but certain features might not work if the underlying APIs are not - available. -

-

-