diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index 873a0e86..348116a4 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -11,11 +11,10 @@ "opensearchDashboardsUtils" ], "optionalPlugins": [ - "securityDashboards", "dataSource", "dataSourceManagement" ], "configPath": [ - "assistant" + "assistant" ] } \ No newline at end of file diff --git a/public/chat_header_button.test.tsx b/public/chat_header_button.test.tsx index b5aa5254..3fd367b9 100644 --- a/public/chat_header_button.test.tsx +++ b/public/chat_header_button.test.tsx @@ -92,7 +92,6 @@ describe('', () => { render( ', () => { render( ', () => { render( ', () => { render( ', () => { render( ; actionExecutors: Record; assistantActions: AssistantActions; @@ -74,7 +73,6 @@ export const HeaderChatButton = (props: HeaderChatButtonProps) => { flyoutFullScreen, setFlyoutVisible, setFlyoutComponent, - userHasAccess: props.userHasAccess, messageRenderers: props.messageRenderers, actionExecutors: props.actionExecutors, currentAccount: props.currentAccount, @@ -92,7 +90,6 @@ export const HeaderChatButton = (props: HeaderChatButtonProps) => { flyoutFullScreen, selectedTabId, preSelectedTabId, - props.userHasAccess, props.messageRenderers, props.actionExecutors, props.currentAccount, @@ -157,9 +154,6 @@ export const HeaderChatButton = (props: HeaderChatButtonProps) => { }, []); useEffect(() => { - if (!props.userHasAccess) { - return; - } const onGlobalMouseUp = (e: KeyboardEvent) => { if (e.ctrlKey && e.key === '/') { inputRef.current?.focus(); @@ -170,7 +164,7 @@ export const HeaderChatButton = (props: HeaderChatButtonProps) => { return () => { document.removeEventListener('keydown', onGlobalMouseUp); }; - }, [props.userHasAccess]); + }, []); useEffect(() => { const handleSuggestion = (event: { suggestion: string }) => { @@ -235,7 +229,6 @@ export const HeaderChatButton = (props: HeaderChatButtonProps) => { )} } - disabled={!props.userHasAccess} /> diff --git a/public/contexts/__tests__/chat_context.test.tsx b/public/contexts/__tests__/chat_context.test.tsx index 2500c5ca..06f5d6dd 100644 --- a/public/contexts/__tests__/chat_context.test.tsx +++ b/public/contexts/__tests__/chat_context.test.tsx @@ -17,7 +17,6 @@ describe('useChatContext', () => { flyoutFullScreen: true, setFlyoutVisible: jest.fn(), setFlyoutComponent: jest.fn(), - userHasAccess: true, messageRenderers: {}, actionExecutors: {}, currentAccount: { username: 'foo', tenant: '' }, diff --git a/public/contexts/chat_context.tsx b/public/contexts/chat_context.tsx index f7bc516c..747f6484 100644 --- a/public/contexts/chat_context.tsx +++ b/public/contexts/chat_context.tsx @@ -18,7 +18,6 @@ export interface IChatContext { flyoutFullScreen: boolean; setFlyoutVisible: React.Dispatch>; setFlyoutComponent: React.Dispatch>; - userHasAccess: boolean; messageRenderers: Record; actionExecutors: Record; currentAccount?: UserAccount; diff --git a/public/hooks/use_chat_actions.test.tsx b/public/hooks/use_chat_actions.test.tsx index 6418ae31..6dc18290 100644 --- a/public/hooks/use_chat_actions.test.tsx +++ b/public/hooks/use_chat_actions.test.tsx @@ -76,7 +76,6 @@ describe('useChatActions hook', () => { setInteractionId: setInteractionIdMock, flyoutVisible: false, flyoutFullScreen: false, - userHasAccess: false, messageRenderers: {}, currentAccount: { username: '', diff --git a/public/plugin.tsx b/public/plugin.tsx index a42449e5..7677d5ea 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -75,28 +75,6 @@ export class AssistantPlugin const messageRenderers: Record = {}; const actionExecutors: Record = {}; const assistantActions: AssistantActions = {} as AssistantActions; - /** - * Returns {@link UserAccountResponse}. Provides default roles and user - * name if security plugin call fails. - */ - const getAccount: () => Promise = (() => { - let account: UserAccountResponse; - return async () => { - if (setupDeps.securityDashboards === undefined) - return { data: { roles: ['all_access'], user_name: 'dashboards_user' } }; - if (account === undefined) { - account = await core.http - .get('/api/v1/configuration/account') - .catch((e) => { - console.error(`Failed to request user account information: ${String(e.body || e)}`); - return { data: { roles: [], user_name: '' } }; - }); - } - return account; - }; - })(); - const checkAccess = (account: Awaited>) => - account.data.roles.some((role) => ['all_access', 'assistant_user'].includes(role)); const dataSourceSetupResult = this.dataSourceService.setup({ uiSettings: core.uiSettings, @@ -115,7 +93,7 @@ export class AssistantPlugin conversations: new ConversationsService(coreStart.http, this.dataSourceService), dataSource: this.dataSourceService, }); - const account = await getAccount(); + const account = { data: { user_name: '', user_requested_tenant: '' } }; const username = account.data.user_name; const tenant = account.data.user_requested_tenant ?? ''; this.incontextInsightRegistry?.setIsEnabled(this.config.incontextInsight.enabled); @@ -126,7 +104,6 @@ export class AssistantPlugin this.config.chat.enabled, - userHasAccess: async () => await getAccount().then(checkAccess), assistantActions, registerIncontextInsight: this.incontextInsightRegistry.register.bind( this.incontextInsightRegistry diff --git a/public/tabs/chat/chat_page.tsx b/public/tabs/chat/chat_page.tsx index 97da71db..b74f86cd 100644 --- a/public/tabs/chat/chat_page.tsx +++ b/public/tabs/chat/chat_page.tsx @@ -60,7 +60,7 @@ export const ChatPage: React.FC = (props) => { diff --git a/public/types.ts b/public/types.ts index 02101e14..56abf4d2 100644 --- a/public/types.ts +++ b/public/types.ts @@ -42,7 +42,6 @@ export interface AssistantPluginStartDependencies { export interface AssistantPluginSetupDependencies { embeddable: EmbeddableSetup; - securityDashboards?: {}; dataSourceManagement?: DataSourceManagementPluginSetup; } @@ -54,10 +53,6 @@ export interface AssistantSetup { * Returns true if chat UI is enabled. */ chatEnabled: () => boolean; - /** - * Returns true if current user has permission to use assistant features. - */ - userHasAccess: () => Promise; assistantActions: Omit; registerIncontextInsight: IncontextInsightRegistry['register']; renderIncontextInsight: (component: React.ReactNode) => React.ReactNode;