mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Fix validateCollectionId for new tables account (#958)
This commit is contained in:
parent
fecac5625a
commit
1394aae944
@ -2,6 +2,7 @@ import _ from "underscore";
|
||||
import create, { UseStore } from "zustand";
|
||||
import * as Constants from "../Common/Constants";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import { userContext } from "../UserContext";
|
||||
import { useSelectedNode } from "./useSelectedNode";
|
||||
|
||||
interface DatabasesState {
|
||||
@ -136,6 +137,11 @@ export const useDatabases: UseStore<DatabasesState> = create((set, get) => ({
|
||||
},
|
||||
validateCollectionId: async (databaseId: string, collectionId: string): Promise<boolean> => {
|
||||
const database = get().databases.find((db) => db.id() === databaseId);
|
||||
// For a new tables account, database is undefined when creating the first table
|
||||
if (!database && userContext.apiType === "Tables") {
|
||||
return true;
|
||||
}
|
||||
|
||||
await database.loadCollections();
|
||||
return !database.collections().some((collection) => collection.id() === collectionId);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user