mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 01:11:25 +00:00
[Query Copilot] Disable command bar buttons when sample container is used (#1514)
* Disable command bar buttons when sample container is used and point only to copilot tab * Make disabled assignement for buttons simmpler
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { ConnectionStatusType } from "Common/Constants";
|
||||
import { ConnectionStatusType, QueryCopilotSampleContainerId, QueryCopilotSampleDatabaseId } from "Common/Constants";
|
||||
import { useNotebook } from "Explorer/Notebook/useNotebook";
|
||||
import create, { UseStore } from "zustand";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { useTabs } from "../hooks/useTabs";
|
||||
|
||||
export interface SelectedNodeState {
|
||||
selectedNode: ViewModels.TreeNode;
|
||||
setSelectedNode: (node: ViewModels.TreeNode) => void;
|
||||
@@ -15,6 +14,7 @@ export interface SelectedNodeState {
|
||||
subnodeKinds?: ViewModels.CollectionTabKind[]
|
||||
) => boolean;
|
||||
isConnectedToContainer: () => boolean;
|
||||
isQueryCopilotCollectionSelected: () => boolean;
|
||||
}
|
||||
|
||||
export const useSelectedNode: UseStore<SelectedNodeState> = create((set, get) => ({
|
||||
@@ -65,4 +65,15 @@ export const useSelectedNode: UseStore<SelectedNodeState> = create((set, get) =>
|
||||
isConnectedToContainer: (): boolean => {
|
||||
return useNotebook.getState().connectionInfo?.status === ConnectionStatusType.Connected;
|
||||
},
|
||||
isQueryCopilotCollectionSelected: (): boolean => {
|
||||
const selectedNode = get().selectedNode;
|
||||
if (
|
||||
selectedNode &&
|
||||
selectedNode.id() === QueryCopilotSampleContainerId &&
|
||||
(selectedNode as ViewModels.Collection)?.databaseId === QueryCopilotSampleDatabaseId
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user