in gui/frontend/src/data-models/ConnectionDataModel.ts [830:1014]
public async removeEntry(entry: ConnectionDataModelEntry): Promise<void> {
const actions: Array<{ action: SubscriberAction, entry?: ConnectionDataModelEntry; }> = [];
switch (entry.type) {
case CdmEntityType.Connection: {
const index = this.connections.indexOf(entry);
if (index >= 0) {
await entry.close();
const removed = this.connections.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.Schema: {
const index = entry.parent.schemaEntries.indexOf(entry);
if (index >= 0) {
if (entry.parent.currentSchema === entry.caption) {
entry.parent.currentSchema = "";
}
const removed = entry.parent.schemaEntries.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.Table:
case CdmEntityType.View:
case CdmEntityType.StoredFunction:
case CdmEntityType.StoredProcedure:
case CdmEntityType.Event:
case CdmEntityType.Trigger:
case CdmEntityType.Index:
case CdmEntityType.ForeignKey: {
const index = entry.parent.members.indexOf(entry as never);
if (index >= 0) {
const removed = entry.parent.members.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.Column: {
if (entry.parent.type === CdmEntityType.View) {
const index = entry.parent.columns.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.columns.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
} else {
const index = entry.parent.members.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.members.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
}
break;
}
/* TODO: should we allow to remove the admin entry?
case CdmEntityType.Admin: {
delete entry.parent.adminEntry;
break;
}*/
case CdmEntityType.AdminPage: {
const index = entry.parent.pages.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.pages.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
/* TODO: should we allow to remove the MRS root entry?
case CdmEntityType.MrsRoot: {
delete entry.parent.mrsEntry;
break;
}*/
case CdmEntityType.MrsService: {
const index = entry.parent.services.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.services.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsSchema: {
const index = entry.parent.schemas.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.schemas.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsContentSet: {
const index = entry.parent.contentSets.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.contentSets.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsUser: {
const index = entry.parent.users.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.users.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsAuthApp: {
const index = entry.parent.authApps.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.authApps.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsServiceAuthApp: {
const index = entry.parent.authApps.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.authApps.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsContentFile: {
const index = entry.parent.files.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.files.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsDbObject: {
const index = entry.parent.dbObjects.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.dbObjects.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
case CdmEntityType.MrsRouter: {
const index = entry.parent.routers.indexOf(entry);
if (index >= 0) {
const removed = entry.parent.routers.splice(index, 1);
actions.push({ action: "remove", entry: removed[0] });
}
break;
}
default: {
throw new Error(`Invalid entry ${entry.caption} given for removal.`);
}
}
this.notifySubscribers(actions);
}