pgadmin4/web/pgadmin/static/js/alertify/dialog_factory.js
Joao De Almeida Pereira 7dd6372eeb Extract the tests and refactor some of the methods.
Extract some of the ACI Tree functionalities, and decouple it from the
main source. Also - create some abstractions from the repeated code
around the enable/disable the schema children object create/edit/delete
functionalities, and also created the dialog wrappers for backup and
restore dialogs.

Reviewed by: Khushboo and Ashesh
Refactored by: Ashesh
2018-06-05 16:42:59 +05:30

53 lines
1.6 KiB
JavaScript

/////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
// Copyright (C) 2013 - 2018, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////
import * as BackupDialog from '../../../tools/backup/static/js/backup_dialog_wrapper';
import {RestoreDialogWrapper} from '../../../tools/restore/static/js/restore_dialog_wrapper';
export class DialogFactory {
constructor(pgBrowser, $,
alertify, DialogModel,
backform, dialogContainerSelector) {
this.pgBrowser = pgBrowser;
this.jquery = $;
this.alertify = alertify;
this.dialogModel = DialogModel;
this.backform = backform;
this.dialogContainerSelector = dialogContainerSelector;
}
create(dialogTitle, typeOfDialog) {
if (typeOfDialog === 'restore') {
return this.createRestoreDialog(dialogTitle, typeOfDialog);
} else {
return this.createBackupDialog(dialogTitle, typeOfDialog);
}
}
createRestoreDialog(dialogTitle, typeOfDialog) {
return new RestoreDialogWrapper(
this.dialogContainerSelector, dialogTitle, typeOfDialog,
this.jquery,
this.pgBrowser,
this.alertify,
this.dialogModel,
this.backform);
}
createBackupDialog(dialogTitle, typeOfDialog) {
return new BackupDialog.BackupDialogWrapper(
this.dialogContainerSelector, dialogTitle, typeOfDialog,
this.jquery,
this.pgBrowser,
this.alertify,
this.dialogModel,
this.backform);
}
}