Remove option to delete/create root table database (#236)

This commit is contained in:
Steve Faulkner 2020-09-28 17:03:47 -05:00 committed by GitHub
parent 23c5d2d7e0
commit aa369760ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 27 deletions

View File

@ -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);

View File

@ -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()

View File

@ -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[] { iconSrc: AddCollectionIcon,
const newCollectionMenuItem: TreeNodeMenuItem = { onClick: () => container.onNewCollectionClicked(),
iconSrc: AddCollectionIcon, label: container.addCollectionText()
onClick: () => container.onNewCollectionClicked(), }
label: container.addCollectionText() ];
};
const deleteDatabaseMenuItem = { if (userContext.defaultExperience !== DefaultAccountExperienceType.Table) {
iconSrc: DeleteDatabaseIcon, items.push({
onClick: () => container.deleteDatabaseConfirmationPane.open(), iconSrc: DeleteDatabaseIcon,
label: container.deleteDatabaseText(), onClick: () => container.deleteDatabaseConfirmationPane.open(),
styleClass: "deleteDatabaseMenuItem" label: container.deleteDatabaseText(),
}; styleClass: "deleteDatabaseMenuItem"
return [newCollectionMenuItem, deleteDatabaseMenuItem]; });
}
return items;
} }
public static createCollectionContextMenuButton( public static createCollectionContextMenuButton(

View File

@ -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) {