mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-29 00:47:01 +00:00
Remove option to delete/create root table database (#236)
This commit is contained in:
parent
23c5d2d7e0
commit
aa369760ad
@ -34,11 +34,10 @@ export async function createDatabase(params: DataModels.CreateDatabaseParams): P
|
|||||||
let database: DataModels.Database;
|
let database: DataModels.Database;
|
||||||
const clearMessage = logConsoleProgress(`Creating a new database ${params.databaseId}`);
|
const clearMessage = logConsoleProgress(`Creating a new database ${params.databaseId}`);
|
||||||
try {
|
try {
|
||||||
if (
|
if (userContext.defaultExperience === DefaultAccountExperienceType.Table) {
|
||||||
window.authType === AuthType.AAD &&
|
throw new Error("Creating database resources is not allowed for tables accounts");
|
||||||
!userContext.useSDKOperations &&
|
}
|
||||||
userContext.defaultExperience !== DefaultAccountExperienceType.Table
|
if (window.authType === AuthType.AAD && !userContext.useSDKOperations) {
|
||||||
) {
|
|
||||||
database = await createDatabaseWithARM(params);
|
database = await createDatabaseWithARM(params);
|
||||||
} else {
|
} else {
|
||||||
database = await createDatabaseWithSDK(params);
|
database = await createDatabaseWithSDK(params);
|
||||||
|
@ -15,11 +15,10 @@ export async function deleteDatabase(databaseId: string): Promise<void> {
|
|||||||
const clearMessage = logConsoleProgress(`Deleting database ${databaseId}`);
|
const clearMessage = logConsoleProgress(`Deleting database ${databaseId}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (
|
if (userContext.defaultExperience === DefaultAccountExperienceType.Table) {
|
||||||
window.authType === AuthType.AAD &&
|
throw new Error("Deleting database resources is not allowed for tables accounts");
|
||||||
userContext.defaultExperience !== DefaultAccountExperienceType.Table &&
|
}
|
||||||
!userContext.useSDKOperations
|
if (window.authType === AuthType.AAD && !userContext.useSDKOperations) {
|
||||||
) {
|
|
||||||
await deleteDatabaseWithARM(databaseId);
|
await deleteDatabaseWithARM(databaseId);
|
||||||
} else {
|
} else {
|
||||||
await client()
|
await client()
|
||||||
|
@ -16,6 +16,8 @@ import Explorer from "./Explorer";
|
|||||||
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
import UserDefinedFunction from "./Tree/UserDefinedFunction";
|
||||||
import StoredProcedure from "./Tree/StoredProcedure";
|
import StoredProcedure from "./Tree/StoredProcedure";
|
||||||
import Trigger from "./Tree/Trigger";
|
import Trigger from "./Tree/Trigger";
|
||||||
|
import { userContext } from "../UserContext";
|
||||||
|
import { DefaultAccountExperienceType } from "../DefaultAccountExperienceType";
|
||||||
|
|
||||||
export interface CollectionContextMenuButtonParams {
|
export interface CollectionContextMenuButtonParams {
|
||||||
databaseId: string;
|
databaseId: string;
|
||||||
@ -29,23 +31,24 @@ export interface DatabaseContextMenuButtonParams {
|
|||||||
* New resource tree (in ReactJS)
|
* New resource tree (in ReactJS)
|
||||||
*/
|
*/
|
||||||
export class ResourceTreeContextMenuButtonFactory {
|
export class ResourceTreeContextMenuButtonFactory {
|
||||||
public static createDatabaseContextMenu(
|
public static createDatabaseContextMenu(container: Explorer): TreeNodeMenuItem[] {
|
||||||
container: Explorer,
|
const items: TreeNodeMenuItem[] = [
|
||||||
selectedDatabase: ViewModels.Database
|
{
|
||||||
): TreeNodeMenuItem[] {
|
|
||||||
const newCollectionMenuItem: TreeNodeMenuItem = {
|
|
||||||
iconSrc: AddCollectionIcon,
|
iconSrc: AddCollectionIcon,
|
||||||
onClick: () => container.onNewCollectionClicked(),
|
onClick: () => container.onNewCollectionClicked(),
|
||||||
label: container.addCollectionText()
|
label: container.addCollectionText()
|
||||||
};
|
}
|
||||||
|
];
|
||||||
|
|
||||||
const deleteDatabaseMenuItem = {
|
if (userContext.defaultExperience !== DefaultAccountExperienceType.Table) {
|
||||||
|
items.push({
|
||||||
iconSrc: DeleteDatabaseIcon,
|
iconSrc: DeleteDatabaseIcon,
|
||||||
onClick: () => container.deleteDatabaseConfirmationPane.open(),
|
onClick: () => container.deleteDatabaseConfirmationPane.open(),
|
||||||
label: container.deleteDatabaseText(),
|
label: container.deleteDatabaseText(),
|
||||||
styleClass: "deleteDatabaseMenuItem"
|
styleClass: "deleteDatabaseMenuItem"
|
||||||
};
|
});
|
||||||
return [newCollectionMenuItem, deleteDatabaseMenuItem];
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createCollectionContextMenuButton(
|
public static createCollectionContextMenuButton(
|
||||||
|
@ -169,7 +169,7 @@ export class ResourceTreeAdapter implements ReactAdapter {
|
|||||||
className: "databaseHeader",
|
className: "databaseHeader",
|
||||||
children: [],
|
children: [],
|
||||||
isSelected: () => this.isDataNodeSelected(database.rid, "Database", undefined),
|
isSelected: () => this.isDataNodeSelected(database.rid, "Database", undefined),
|
||||||
contextMenu: ResourceTreeContextMenuButtonFactory.createDatabaseContextMenu(this.container, database),
|
contextMenu: ResourceTreeContextMenuButtonFactory.createDatabaseContextMenu(this.container),
|
||||||
onClick: async isExpanded => {
|
onClick: async isExpanded => {
|
||||||
// Rewritten version of expandCollapseDatabase():
|
// Rewritten version of expandCollapseDatabase():
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
|
Loading…
Reference in New Issue
Block a user