techdocsmith commented on code in PR #16191: URL: https://github.com/apache/druid/pull/16191#discussion_r1536335958
########## web-console/src/components/header-bar/restricted-mode/__snapshots__/restricted-mode.spec.tsx.snap: ########## @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RestrictedMode matches snapshot 1`] = ` +<Blueprint4.Popover2 + boundary="clippingParents" + captureDismiss={false} + content={ + <Memo(PopoverText)> + <p> + The console is running in restricted mode. + </p> + <p> + 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. + </p> + <p> + For more info check out the + + <Memo(ExternalLink) + href="https://druid.apache.org/docs/latest/operations/web-console.html" + > + web console documentation + </Memo(ExternalLink)> + . + </p> + <p> + 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. Review Comment: ```suggestion It is possible that the console is experiencing 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. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'coordinator': + label = 'Coordinator mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'overlord': + label = 'Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + default: + label = 'Restricted mode'; + message = ( + <p> + 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. + </p> + ); + break; + } + + return ( + <Popover2 + content={ + <PopoverText> + <p>The console is running in restricted mode.</p> + {message} + <p> + For more info check out the{' '} + <ExternalLink href={`${getLink('DOCS')}/operations/web-console.html`}> + web console documentation + </ExternalLink> + . + </p> + <p> + 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. Review Comment: ```suggestion There is an issue with the console capability detection. You can enable the unrestricted console but certain features might not work if the underlying APIs are not available. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. Review Comment: ```suggestion The SQL endpoint and management proxy are disabled. You can only use the console to make queries. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited Review Comment: ```suggestion The management proxy is not enabled, the console will operate with limited ``` ########## web-console/src/components/header-bar/restricted-mode/__snapshots__/restricted-mode.spec.tsx.snap: ########## @@ -0,0 +1,69 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RestrictedMode matches snapshot 1`] = ` +<Blueprint4.Popover2 + boundary="clippingParents" + captureDismiss={false} + content={ + <Memo(PopoverText)> + <p> + The console is running in restricted mode. + </p> + <p> + 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. Review Comment: ```suggestion You are accessing the console on the Coordinator/Overlord shared service. Because this service lacks access to some APIs, the console will operate in a limited mode. You can access the unrestricted version of the console on the Router service. ``` Are we able to provide a link to the Router service? ########## web-console/src/components/header-bar/header-bar.tsx: ########## @@ -496,6 +358,38 @@ export const HeaderBar = React.memo(function HeaderBar(props: HeaderBarProps) { </NavbarGroup> <NavbarGroup align={Alignment.RIGHT}> <RestrictedMode capabilities={capabilities} onUnrestrict={onUnrestrict} /> + {capabilitiesOverride && ( + <Popover2 + content={ + <PopoverText> + <p> + The console is running in a specific forced mode. Instead of detecting the + capabilities of the cluster it is assuming a certain defined set of capabilities. + </p> + <p> + This is an advanced feature used for testing and for working around issues in the + capability detecting logic. If you are not sure why you are in this mode then + clear it. Review Comment: ```suggestion Forced mode is an advanced feature used for testing and for working around issues with the capability detecting logic. If you are unsure why the console is in forced mode, clear it. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. Review Comment: ```suggestion The SQL endpoint is disabled. The console will fall back to{' '} <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will operate with limited functionality. Refer to {' '} <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> for instructions to enable the SQL endpoint. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'coordinator': + label = 'Coordinator mode'; + message = ( + <p> + It appears that you are accessing the console on the Coordinator service. Due to the lack Review Comment: see line 81 ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> Review Comment: ```suggestion You are accessing the console on the Coordinator/Overlord shared service. Because this service lacks access to some APIs, the console will operate in a limited mode. You can access the unrestricted version of the console on the Router service. </p> ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'coordinator': + label = 'Coordinator mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'overlord': + label = 'Overlord mode'; + message = ( + <p> + It appears that you are accessing the console on the Overlord service. Due to the lack of Review Comment: see line 81 ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'coordinator': + label = 'Coordinator mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'overlord': + label = 'Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + default: + label = 'Restricted mode'; + message = ( + <p> + 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. Review Comment: ```suggestion Due to the lack of access to some APIs on this service, the console will operate in a limited mode. You can access the unrestricted version of the console on the Router service. ``` ########## web-console/src/components/header-bar/restricted-mode/restricted-mode.tsx: ########## @@ -0,0 +1,164 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Button, Intent, Position } from '@blueprintjs/core'; +import { IconNames } from '@blueprintjs/icons'; +import { Popover2 } from '@blueprintjs/popover2'; +import React, { type JSX } from 'react'; + +import { Capabilities } from '../../../helpers'; +import { getLink } from '../../../links'; +import { ExternalLink } from '../../external-link/external-link'; +import { PopoverText } from '../../popover-text/popover-text'; + +export interface RestrictedModeProps { + capabilities: Capabilities; + onUnrestrict(capabilities: Capabilities): void; +} + +export 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 = ( + <p> + It appears that the SQL endpoint is disabled. The console will fall back to{' '} + <ExternalLink href={getLink('DOCS_API')}>native Druid APIs</ExternalLink> and will be + limited in functionality. Look at{' '} + <ExternalLink href={getLink('DOCS_SQL')}>the SQL docs</ExternalLink> to enable the SQL + endpoint. + </p> + ); + break; + + case 'no-proxy': + label = 'No management proxy mode'; + message = ( + <p> + It appears that the management proxy is not enabled, the console will operate with limited + functionality. + </p> + ); + break; + + case 'no-sql-no-proxy': + label = 'No SQL mode'; + message = ( + <p> + It appears that the SQL endpoint and management proxy are disabled. The console can only + be used to make queries. + </p> + ); + break; + + case 'coordinator-overlord': + label = 'Coordinator/Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'coordinator': + label = 'Coordinator mode'; + message = ( + <p> + 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. + </p> + ); + break; + + case 'overlord': + label = 'Overlord mode'; + message = ( + <p> + 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. + </p> + ); + break; + + default: + label = 'Restricted mode'; + message = ( + <p> + 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. + </p> + ); + break; + } + + return ( + <Popover2 + content={ + <PopoverText> + <p>The console is running in restricted mode.</p> + {message} + <p> + For more info check out the{' '} Review Comment: ```suggestion For more info refer to the{' '} ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
