Skip to content

Commit

Permalink
hide notebook feature when mds enabled
Browse files Browse the repository at this point in the history
Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao committed May 31, 2024
1 parent 0d6ce86 commit 8c45d5a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions public/components/chat_window_header_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiButtonIcon,
EuiToolTip,
} from '@elastic/eui';
import React, { useCallback, useState } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { useChatContext } from '../contexts';
import { useChatActions, useChatState, useSaveChat } from '../hooks';
import { NotebookNameModal } from './notebook/notebook_name_modal';
Expand Down Expand Up @@ -57,6 +57,11 @@ export const ChatWindowHeaderTitle = React.memo(() => {
[chatContext, core.services.conversations]
);

const displayNotebookFeature = useMemo(() => {
// Notebook dashboard API doesn't support MDS for now, so we hide saving to notebook feature when MDS enabled.
return !core.services.dataSource.isMDSEnabled();
}, [core.services.dataSource.isMDSEnabled]);

const handleSaveNotebookModalClose = () => {
setSaveNotebookModalOpen(false);
};
Expand Down Expand Up @@ -87,17 +92,19 @@ export const ChatWindowHeaderTitle = React.memo(() => {
>
New conversation
</EuiContextMenuItem>,
<EuiContextMenuItem
key="save-as-notebook"
onClick={() => {
closePopover();
setSaveNotebookModalOpen(true);
}}
// User only can save conversation when he send a message at least.
disabled={chatState.messages.every((item) => item.type !== 'input')}
>
Save to notebook
</EuiContextMenuItem>,
displayNotebookFeature && (
<EuiContextMenuItem
key="save-as-notebook"
onClick={() => {
closePopover();
setSaveNotebookModalOpen(true);
}}
// User only can save conversation when he send a message at least.
disabled={chatState.messages.every((item) => item.type !== 'input')}
>
Save to notebook
</EuiContextMenuItem>
),
];

return (
Expand Down

0 comments on commit 8c45d5a

Please sign in to comment.