mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-28 04:29:13 +00:00
Delete Cassandra tables/keyspaces via ARM (#436)
This commit is contained in:
parent
81fd442fad
commit
b217d4be1b
@ -1,9 +1,7 @@
|
||||
import * as ko from "knockout";
|
||||
import Q from "q";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as Constants from "../../Common/Constants";
|
||||
import { Action, ActionModifiers } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { CassandraAPIDataClient } from "../Tables/TableDataClient";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { DefaultExperienceUtility } from "../../Shared/DefaultExperienceUtility";
|
||||
@ -50,18 +48,7 @@ export default class DeleteCollectionConfirmationPane extends ContextualPaneBase
|
||||
dataExplorerArea: Constants.Areas.ContextualPane,
|
||||
paneTitle: this.title(),
|
||||
});
|
||||
let promise: Promise<any>;
|
||||
if (this.container.isPreferredApiCassandra()) {
|
||||
promise = ((<CassandraAPIDataClient>this.container.tableDataClient).deleteTableOrKeyspace(
|
||||
this.container.databaseAccount().properties.cassandraEndpoint,
|
||||
this.container.databaseAccount().id,
|
||||
`DROP TABLE ${selectedCollection.databaseId}.${selectedCollection.id()};`,
|
||||
this.container
|
||||
) as unknown) as Promise<any>;
|
||||
} else {
|
||||
promise = deleteCollection(selectedCollection.databaseId, selectedCollection.id());
|
||||
}
|
||||
return promise.then(
|
||||
return deleteCollection(selectedCollection.databaseId, selectedCollection.id()).then(
|
||||
() => {
|
||||
this.isExecuting(false);
|
||||
this.close();
|
||||
|
@ -52,19 +52,8 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
||||
dataExplorerArea: Constants.Areas.ContextualPane,
|
||||
paneTitle: this.title(),
|
||||
});
|
||||
// TODO: Should not be a Q promise anymore, but the Cassandra code requires it
|
||||
let promise: Q.Promise<any>;
|
||||
if (this.container.isPreferredApiCassandra()) {
|
||||
promise = (<CassandraAPIDataClient>this.container.tableDataClient).deleteTableOrKeyspace(
|
||||
this.container.databaseAccount().properties.cassandraEndpoint,
|
||||
this.container.databaseAccount().id,
|
||||
`DROP KEYSPACE ${selectedDatabase.id()};`,
|
||||
this.container
|
||||
);
|
||||
} else {
|
||||
promise = Q(deleteDatabase(selectedDatabase.id()));
|
||||
}
|
||||
return promise.then(
|
||||
return Q(
|
||||
deleteDatabase(selectedDatabase.id()).then(
|
||||
() => {
|
||||
this.isExecuting(false);
|
||||
this.close();
|
||||
@ -127,6 +116,7 @@ export default class DeleteDatabaseConfirmationPane extends ContextualPaneBase {
|
||||
startKey
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -416,41 +416,6 @@ export class CassandraAPIDataClient extends TableDataClient {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
public deleteTableOrKeyspace(
|
||||
cassandraEndpoint: string,
|
||||
resourceId: string,
|
||||
deleteQuery: string,
|
||||
explorer: Explorer
|
||||
): Q.Promise<any> {
|
||||
const deferred = Q.defer<any>();
|
||||
const notificationId = NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.InProgress,
|
||||
`Deleting resource with query ${deleteQuery}`
|
||||
);
|
||||
this.createOrDeleteQuery(cassandraEndpoint, resourceId, deleteQuery, explorer)
|
||||
.then(
|
||||
() => {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Info,
|
||||
`Successfully deleted resource with query ${deleteQuery}`
|
||||
);
|
||||
deferred.resolve();
|
||||
},
|
||||
(error) => {
|
||||
handleError(
|
||||
error,
|
||||
"DeleteKeyspaceOrTableCassandra",
|
||||
`Error while deleting resource with query ${deleteQuery}`
|
||||
);
|
||||
deferred.reject(error);
|
||||
}
|
||||
)
|
||||
.finally(() => {
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(notificationId);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
public getTableKeys(collection: ViewModels.Collection): Q.Promise<CassandraTableKeys> {
|
||||
if (!!collection.cassandraKeys) {
|
||||
return Q.resolve(collection.cassandraKeys);
|
||||
|
Loading…
x
Reference in New Issue
Block a user