From 26385dea8f1101b579bc21e756c7d54a8f8f369e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 22 Jan 2019 21:36:36 +0100 Subject: [PATCH] Began work on improving structure and organization of components under features/dashboard, #14062 --- public/app/features/dashboard/all.ts | 19 ++++---------- .../DashExportModal/DashExportCtrl.ts} | 4 +-- .../DashboardExporter.test.ts} | 4 +-- .../DashExportModal/DashboardExporter.ts} | 2 +- .../components/DashExportModal/index.ts | 2 ++ .../DashExportModal/template.html} | 0 .../DashLinks/DashLinksContainerCtrl.ts} | 2 +- .../DashLinks/DashLinksEditorCtrl.ts} | 6 ++--- .../DashLinks}/editor.html | 0 .../dashboard/components/DashLinks/index.ts | 2 ++ .../DashNav/DashNavCtrl.ts} | 4 +-- .../dashboard/components/DashNav/index.ts | 1 + .../DashNav/template.html} | 0 .../ExportDataModal/ExportDataModalCtrl.ts} | 2 +- .../components/ExportDataModal/index.ts | 1 + .../ExportDataModal/template.html} | 0 .../FolderPicker/FolderPickerCtrl.ts} | 2 +- .../components/FolderPicker/index.ts | 1 + .../FolderPicker/template.html} | 0 .../dashboard/folder_permissions_ctrl.ts | 25 ------------------- .../CreateFolderCtrl.ts} | 0 .../DashboardImportCtrl.test.ts} | 4 +-- .../DashboardImportCtrl.ts} | 0 .../FolderDashboardsCtrl.ts} | 2 +- .../MoveToFolderModal/MoveToFolderCtrl.ts} | 2 +- .../components/MoveToFolderModal/index.ts | 1 + .../MoveToFolderModal/template.html} | 0 .../app/features/manage-dashboards/index.ts | 10 +++++++- .../services/FolderPageLoader.ts} | 0 29 files changed, 39 insertions(+), 57 deletions(-) rename public/app/features/dashboard/{export/export_modal.ts => components/DashExportModal/DashExportCtrl.ts} (92%) rename public/app/features/dashboard/{specs/exporter.test.ts => components/DashExportModal/DashboardExporter.test.ts} (98%) rename public/app/features/dashboard/{export/exporter.ts => components/DashExportModal/DashboardExporter.ts} (98%) create mode 100644 public/app/features/dashboard/components/DashExportModal/index.ts rename public/app/features/dashboard/{export/export_modal.html => components/DashExportModal/template.html} (100%) rename public/app/features/dashboard/{dashlinks/module.ts => components/DashLinks/DashLinksContainerCtrl.ts} (99%) rename public/app/features/dashboard/{dashlinks/editor.ts => components/DashLinks/DashLinksEditorCtrl.ts} (90%) rename public/app/features/dashboard/{dashlinks => components/DashLinks}/editor.html (100%) create mode 100644 public/app/features/dashboard/components/DashLinks/index.ts rename public/app/features/dashboard/{dashnav/dashnav.ts => components/DashNav/DashNavCtrl.ts} (95%) create mode 100644 public/app/features/dashboard/components/DashNav/index.ts rename public/app/features/dashboard/{dashnav/dashnav.html => components/DashNav/template.html} (100%) rename public/app/features/dashboard/{export_data/export_data_modal.ts => components/ExportDataModal/ExportDataModalCtrl.ts} (92%) create mode 100644 public/app/features/dashboard/components/ExportDataModal/index.ts rename public/app/features/dashboard/{export_data/export_data_modal.html => components/ExportDataModal/template.html} (100%) rename public/app/features/dashboard/{folder_picker/folder_picker.ts => components/FolderPicker/FolderPickerCtrl.ts} (98%) create mode 100644 public/app/features/dashboard/components/FolderPicker/index.ts rename public/app/features/dashboard/{folder_picker/folder_picker.html => components/FolderPicker/template.html} (100%) delete mode 100644 public/app/features/dashboard/folder_permissions_ctrl.ts rename public/app/features/{dashboard/create_folder_ctrl.ts => manage-dashboards/CreateFolderCtrl.ts} (100%) rename public/app/features/{dashboard/specs/dashboard_import_ctrl.test.ts => manage-dashboards/DashboardImportCtrl.test.ts} (95%) rename public/app/features/{dashboard/dashboard_import_ctrl.ts => manage-dashboards/DashboardImportCtrl.ts} (100%) rename public/app/features/{dashboard/folder_dashboards_ctrl.ts => manage-dashboards/FolderDashboardsCtrl.ts} (90%) rename public/app/features/{dashboard/move_to_folder_modal/move_to_folder.ts => manage-dashboards/components/MoveToFolderModal/MoveToFolderCtrl.ts} (93%) create mode 100644 public/app/features/manage-dashboards/components/MoveToFolderModal/index.ts rename public/app/features/{dashboard/move_to_folder_modal/move_to_folder.html => manage-dashboards/components/MoveToFolderModal/template.html} (100%) rename public/app/features/{dashboard/folder_page_loader.ts => manage-dashboards/services/FolderPageLoader.ts} (100%) diff --git a/public/app/features/dashboard/all.ts b/public/app/features/dashboard/all.ts index 5ec4e5e3929..01570ae4744 100644 --- a/public/app/features/dashboard/all.ts +++ b/public/app/features/dashboard/all.ts @@ -2,7 +2,6 @@ import './dashboard_ctrl'; import './alerting_srv'; import './history/history'; import './dashboard_loader_srv'; -import './dashnav/dashnav'; import './submenu/submenu'; import './save_as_modal'; import './save_modal'; @@ -17,17 +16,17 @@ import './unsaved_changes_srv'; import './unsaved_changes_modal'; import './timepicker/timepicker'; import './upload'; -import './export/export_modal'; -import './export_data/export_data_modal'; import './ad_hoc_filters'; import './repeat_option/repeat_option'; import './dashgrid/DashboardGridDirective'; import './dashgrid/RowOptions'; -import './folder_picker/folder_picker'; -import './move_to_folder_modal/move_to_folder'; import './settings/settings'; import './panellinks/module'; -import './dashlinks/module'; +import './components/DashLinks'; +import './components/DashExportModal'; +import './components/DashNav'; +import './components/ExportDataModal'; +import './components/FolderPicker'; // angular wrappers import { react2AngularDirective } from 'app/core/utils/react2angular'; @@ -35,11 +34,3 @@ import DashboardPermissions from './permissions/DashboardPermissions'; react2AngularDirective('dashboardPermissions', DashboardPermissions, ['dashboardId', 'folder']); -import coreModule from 'app/core/core_module'; -import { FolderDashboardsCtrl } from './folder_dashboards_ctrl'; -import { DashboardImportCtrl } from './dashboard_import_ctrl'; -import { CreateFolderCtrl } from './create_folder_ctrl'; - -coreModule.controller('FolderDashboardsCtrl', FolderDashboardsCtrl); -coreModule.controller('DashboardImportCtrl', DashboardImportCtrl); -coreModule.controller('CreateFolderCtrl', CreateFolderCtrl); diff --git a/public/app/features/dashboard/export/export_modal.ts b/public/app/features/dashboard/components/DashExportModal/DashExportCtrl.ts similarity index 92% rename from public/app/features/dashboard/export/export_modal.ts rename to public/app/features/dashboard/components/DashExportModal/DashExportCtrl.ts index 8136c77cd8f..7769bdf114a 100644 --- a/public/app/features/dashboard/export/export_modal.ts +++ b/public/app/features/dashboard/components/DashExportModal/DashExportCtrl.ts @@ -2,7 +2,7 @@ import angular from 'angular'; import { saveAs } from 'file-saver'; import coreModule from 'app/core/core_module'; -import { DashboardExporter } from './exporter'; +import { DashboardExporter } from './DashboardExporter'; export class DashExportCtrl { dash: any; @@ -66,7 +66,7 @@ export class DashExportCtrl { export function dashExportDirective() { return { restrict: 'E', - templateUrl: 'public/app/features/dashboard/export/export_modal.html', + templateUrl: 'public/app/features/dashboard/components/DashExportModal/template.html', controller: DashExportCtrl, bindToController: true, controllerAs: 'ctrl', diff --git a/public/app/features/dashboard/specs/exporter.test.ts b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts similarity index 98% rename from public/app/features/dashboard/specs/exporter.test.ts rename to public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts index eac6b0b272a..20ab21541a5 100644 --- a/public/app/features/dashboard/specs/exporter.test.ts +++ b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.test.ts @@ -6,8 +6,8 @@ jest.mock('app/core/store', () => { import _ from 'lodash'; import config from 'app/core/config'; -import { DashboardExporter } from '../export/exporter'; -import { DashboardModel } from '../dashboard_model'; +import { DashboardExporter } from './DashboardExporter'; +import { DashboardModel } from '../../dashboard_model'; describe('given dashboard with repeated panels', () => { let dash, exported; diff --git a/public/app/features/dashboard/export/exporter.ts b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.ts similarity index 98% rename from public/app/features/dashboard/export/exporter.ts rename to public/app/features/dashboard/components/DashExportModal/DashboardExporter.ts index 7aecb5c384f..22b93b767d6 100644 --- a/public/app/features/dashboard/export/exporter.ts +++ b/public/app/features/dashboard/components/DashExportModal/DashboardExporter.ts @@ -1,6 +1,6 @@ import config from 'app/core/config'; import _ from 'lodash'; -import { DashboardModel } from '../dashboard_model'; +import { DashboardModel } from '../../dashboard_model'; export class DashboardExporter { constructor(private datasourceSrv) {} diff --git a/public/app/features/dashboard/components/DashExportModal/index.ts b/public/app/features/dashboard/components/DashExportModal/index.ts new file mode 100644 index 00000000000..6529cf07ad9 --- /dev/null +++ b/public/app/features/dashboard/components/DashExportModal/index.ts @@ -0,0 +1,2 @@ +export { DashboardExporter } from './DashboardExporter'; +export { DashExportCtrl } from './DashExportCtrl'; diff --git a/public/app/features/dashboard/export/export_modal.html b/public/app/features/dashboard/components/DashExportModal/template.html similarity index 100% rename from public/app/features/dashboard/export/export_modal.html rename to public/app/features/dashboard/components/DashExportModal/template.html diff --git a/public/app/features/dashboard/dashlinks/module.ts b/public/app/features/dashboard/components/DashLinks/DashLinksContainerCtrl.ts similarity index 99% rename from public/app/features/dashboard/dashlinks/module.ts rename to public/app/features/dashboard/components/DashLinks/DashLinksContainerCtrl.ts index c951538d45d..a08e438a46c 100644 --- a/public/app/features/dashboard/dashlinks/module.ts +++ b/public/app/features/dashboard/components/DashLinks/DashLinksContainerCtrl.ts @@ -1,6 +1,6 @@ import angular from 'angular'; import _ from 'lodash'; -import { iconMap } from './editor'; +import { iconMap } from './DashLinksEditorCtrl'; function dashLinksContainer() { return { diff --git a/public/app/features/dashboard/dashlinks/editor.ts b/public/app/features/dashboard/components/DashLinks/DashLinksEditorCtrl.ts similarity index 90% rename from public/app/features/dashboard/dashlinks/editor.ts rename to public/app/features/dashboard/components/DashLinks/DashLinksEditorCtrl.ts index 482052469db..398ad757bf3 100644 --- a/public/app/features/dashboard/dashlinks/editor.ts +++ b/public/app/features/dashboard/components/DashLinks/DashLinksEditorCtrl.ts @@ -11,7 +11,7 @@ export let iconMap = { cloud: 'fa-cloud', }; -export class DashLinkEditorCtrl { +export class DashLinksEditorCtrl { dashboard: any; iconMap: any; mode: any; @@ -65,8 +65,8 @@ export class DashLinkEditorCtrl { function dashLinksEditor() { return { restrict: 'E', - controller: DashLinkEditorCtrl, - templateUrl: 'public/app/features/dashboard/dashlinks/editor.html', + controller: DashLinksEditorCtrl, + templateUrl: 'public/app/features/dashboard/components/DashLinks/editor.html', bindToController: true, controllerAs: 'ctrl', scope: { diff --git a/public/app/features/dashboard/dashlinks/editor.html b/public/app/features/dashboard/components/DashLinks/editor.html similarity index 100% rename from public/app/features/dashboard/dashlinks/editor.html rename to public/app/features/dashboard/components/DashLinks/editor.html diff --git a/public/app/features/dashboard/components/DashLinks/index.ts b/public/app/features/dashboard/components/DashLinks/index.ts new file mode 100644 index 00000000000..ef118d4a84c --- /dev/null +++ b/public/app/features/dashboard/components/DashLinks/index.ts @@ -0,0 +1,2 @@ +export { DashLinksContainerCtrl } from './DashLinksContainerCtrl'; +export { DashLinksEditorCtrl } from './DashLinksEditorCtrl'; diff --git a/public/app/features/dashboard/dashnav/dashnav.ts b/public/app/features/dashboard/components/DashNav/DashNavCtrl.ts similarity index 95% rename from public/app/features/dashboard/dashnav/dashnav.ts rename to public/app/features/dashboard/components/DashNav/DashNavCtrl.ts index 1c83b2d0bdb..0f28bb0afdb 100644 --- a/public/app/features/dashboard/dashnav/dashnav.ts +++ b/public/app/features/dashboard/components/DashNav/DashNavCtrl.ts @@ -1,7 +1,7 @@ import moment from 'moment'; import angular from 'angular'; import { appEvents, NavModel } from 'app/core/core'; -import { DashboardModel } from '../dashboard_model'; +import { DashboardModel } from '../../dashboard_model'; export class DashNavCtrl { dashboard: DashboardModel; @@ -107,7 +107,7 @@ export class DashNavCtrl { export function dashNavDirective() { return { restrict: 'E', - templateUrl: 'public/app/features/dashboard/dashnav/dashnav.html', + templateUrl: 'public/app/features/dashboard/components/DashNav/template.html', controller: DashNavCtrl, bindToController: true, controllerAs: 'ctrl', diff --git a/public/app/features/dashboard/components/DashNav/index.ts b/public/app/features/dashboard/components/DashNav/index.ts new file mode 100644 index 00000000000..854e32b24d2 --- /dev/null +++ b/public/app/features/dashboard/components/DashNav/index.ts @@ -0,0 +1 @@ +export { DashNavCtrl } from './DashNavCtrl'; diff --git a/public/app/features/dashboard/dashnav/dashnav.html b/public/app/features/dashboard/components/DashNav/template.html similarity index 100% rename from public/app/features/dashboard/dashnav/dashnav.html rename to public/app/features/dashboard/components/DashNav/template.html diff --git a/public/app/features/dashboard/export_data/export_data_modal.ts b/public/app/features/dashboard/components/ExportDataModal/ExportDataModalCtrl.ts similarity index 92% rename from public/app/features/dashboard/export_data/export_data_modal.ts rename to public/app/features/dashboard/components/ExportDataModal/ExportDataModalCtrl.ts index 460f80079d9..f87daa94ee7 100644 --- a/public/app/features/dashboard/export_data/export_data_modal.ts +++ b/public/app/features/dashboard/components/ExportDataModal/ExportDataModalCtrl.ts @@ -31,7 +31,7 @@ export class ExportDataModalCtrl { export function exportDataModal() { return { restrict: 'E', - templateUrl: 'public/app/features/dashboard/export_data/export_data_modal.html', + templateUrl: 'public/app/features/dashboard/components/ExportDataModal/template.html', controller: ExportDataModalCtrl, controllerAs: 'ctrl', scope: { diff --git a/public/app/features/dashboard/components/ExportDataModal/index.ts b/public/app/features/dashboard/components/ExportDataModal/index.ts new file mode 100644 index 00000000000..6df4fd00434 --- /dev/null +++ b/public/app/features/dashboard/components/ExportDataModal/index.ts @@ -0,0 +1 @@ +export { ExportDataModalCtrl } from './ExportDataModalCtrl'; diff --git a/public/app/features/dashboard/export_data/export_data_modal.html b/public/app/features/dashboard/components/ExportDataModal/template.html similarity index 100% rename from public/app/features/dashboard/export_data/export_data_modal.html rename to public/app/features/dashboard/components/ExportDataModal/template.html diff --git a/public/app/features/dashboard/folder_picker/folder_picker.ts b/public/app/features/dashboard/components/FolderPicker/FolderPickerCtrl.ts similarity index 98% rename from public/app/features/dashboard/folder_picker/folder_picker.ts rename to public/app/features/dashboard/components/FolderPicker/FolderPickerCtrl.ts index 0896b3c793c..93d43d36038 100644 --- a/public/app/features/dashboard/folder_picker/folder_picker.ts +++ b/public/app/features/dashboard/components/FolderPicker/FolderPickerCtrl.ts @@ -168,7 +168,7 @@ export class FolderPickerCtrl { export function folderPicker() { return { restrict: 'E', - templateUrl: 'public/app/features/dashboard/folder_picker/folder_picker.html', + templateUrl: 'public/app/features/dashboard/components/FolderPicker/template.html', controller: FolderPickerCtrl, bindToController: true, controllerAs: 'ctrl', diff --git a/public/app/features/dashboard/components/FolderPicker/index.ts b/public/app/features/dashboard/components/FolderPicker/index.ts new file mode 100644 index 00000000000..7550f7fd573 --- /dev/null +++ b/public/app/features/dashboard/components/FolderPicker/index.ts @@ -0,0 +1 @@ +export { FolderPickerCtrl } from './FolderPickerCtrl'; diff --git a/public/app/features/dashboard/folder_picker/folder_picker.html b/public/app/features/dashboard/components/FolderPicker/template.html similarity index 100% rename from public/app/features/dashboard/folder_picker/folder_picker.html rename to public/app/features/dashboard/components/FolderPicker/template.html diff --git a/public/app/features/dashboard/folder_permissions_ctrl.ts b/public/app/features/dashboard/folder_permissions_ctrl.ts deleted file mode 100644 index 4ab91acb3d9..00000000000 --- a/public/app/features/dashboard/folder_permissions_ctrl.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { FolderPageLoader } from './folder_page_loader'; - -export class FolderPermissionsCtrl { - navModel: any; - folderId: number; - uid: string; - dashboard: any; - meta: any; - - /** @ngInject */ - constructor(private backendSrv, navModelSrv, private $routeParams, $location) { - if (this.$routeParams.uid) { - this.uid = $routeParams.uid; - - new FolderPageLoader(this.backendSrv).load(this, this.uid, 'manage-folder-permissions').then(folder => { - if ($location.path() !== folder.meta.url) { - $location.path(`${folder.meta.url}/permissions`).replace(); - } - - this.dashboard = folder.dashboard; - this.meta = folder.meta; - }); - } - } -} diff --git a/public/app/features/dashboard/create_folder_ctrl.ts b/public/app/features/manage-dashboards/CreateFolderCtrl.ts similarity index 100% rename from public/app/features/dashboard/create_folder_ctrl.ts rename to public/app/features/manage-dashboards/CreateFolderCtrl.ts diff --git a/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts b/public/app/features/manage-dashboards/DashboardImportCtrl.test.ts similarity index 95% rename from public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts rename to public/app/features/manage-dashboards/DashboardImportCtrl.test.ts index bcde009cb3a..c9037c0a62d 100644 --- a/public/app/features/dashboard/specs/dashboard_import_ctrl.test.ts +++ b/public/app/features/manage-dashboards/DashboardImportCtrl.test.ts @@ -1,5 +1,5 @@ -import { DashboardImportCtrl } from '../dashboard_import_ctrl'; -import config from '../../../core/config'; +import { DashboardImportCtrl } from './DashboardImportCtrl'; +import config from 'app/core/config'; describe('DashboardImportCtrl', () => { const ctx: any = {}; diff --git a/public/app/features/dashboard/dashboard_import_ctrl.ts b/public/app/features/manage-dashboards/DashboardImportCtrl.ts similarity index 100% rename from public/app/features/dashboard/dashboard_import_ctrl.ts rename to public/app/features/manage-dashboards/DashboardImportCtrl.ts diff --git a/public/app/features/dashboard/folder_dashboards_ctrl.ts b/public/app/features/manage-dashboards/FolderDashboardsCtrl.ts similarity index 90% rename from public/app/features/dashboard/folder_dashboards_ctrl.ts rename to public/app/features/manage-dashboards/FolderDashboardsCtrl.ts index 05cc420c489..6241472432c 100644 --- a/public/app/features/dashboard/folder_dashboards_ctrl.ts +++ b/public/app/features/manage-dashboards/FolderDashboardsCtrl.ts @@ -1,4 +1,4 @@ -import { FolderPageLoader } from './folder_page_loader'; +import { FolderPageLoader } from './services/FolderPageLoader'; import locationUtil from 'app/core/utils/location_util'; export class FolderDashboardsCtrl { diff --git a/public/app/features/dashboard/move_to_folder_modal/move_to_folder.ts b/public/app/features/manage-dashboards/components/MoveToFolderModal/MoveToFolderCtrl.ts similarity index 93% rename from public/app/features/dashboard/move_to_folder_modal/move_to_folder.ts rename to public/app/features/manage-dashboards/components/MoveToFolderModal/MoveToFolderCtrl.ts index 075583b971b..c183f38d92a 100644 --- a/public/app/features/dashboard/move_to_folder_modal/move_to_folder.ts +++ b/public/app/features/manage-dashboards/components/MoveToFolderModal/MoveToFolderCtrl.ts @@ -46,7 +46,7 @@ export class MoveToFolderCtrl { export function moveToFolderModal() { return { restrict: 'E', - templateUrl: 'public/app/features/dashboard/move_to_folder_modal/move_to_folder.html', + templateUrl: 'public/app/features/manage-dashboards/components/MoveToFolderModal/template.html', controller: MoveToFolderCtrl, bindToController: true, controllerAs: 'ctrl', diff --git a/public/app/features/manage-dashboards/components/MoveToFolderModal/index.ts b/public/app/features/manage-dashboards/components/MoveToFolderModal/index.ts new file mode 100644 index 00000000000..df0553aedb9 --- /dev/null +++ b/public/app/features/manage-dashboards/components/MoveToFolderModal/index.ts @@ -0,0 +1 @@ +export { MoveToFolderCtrl } from './MoveToFolderCtrl'; diff --git a/public/app/features/dashboard/move_to_folder_modal/move_to_folder.html b/public/app/features/manage-dashboards/components/MoveToFolderModal/template.html similarity index 100% rename from public/app/features/dashboard/move_to_folder_modal/move_to_folder.html rename to public/app/features/manage-dashboards/components/MoveToFolderModal/template.html diff --git a/public/app/features/manage-dashboards/index.ts b/public/app/features/manage-dashboards/index.ts index 046740904e1..b8c53b3137b 100644 --- a/public/app/features/manage-dashboards/index.ts +++ b/public/app/features/manage-dashboards/index.ts @@ -1,7 +1,15 @@ -import coreModule from 'app/core/core_module'; +export * from './components/MoveToFolderModal'; import { DashboardListCtrl } from './DashboardListCtrl'; import { SnapshotListCtrl } from './SnapshotListCtrl'; +import { FolderDashboardsCtrl } from './FolderDashboardsCtrl'; +import { DashboardImportCtrl } from './DashboardImportCtrl'; +import { CreateFolderCtrl } from './CreateFolderCtrl'; + +import coreModule from 'app/core/core_module'; coreModule.controller('DashboardListCtrl', DashboardListCtrl); coreModule.controller('SnapshotListCtrl', SnapshotListCtrl); +coreModule.controller('FolderDashboardsCtrl', FolderDashboardsCtrl); +coreModule.controller('DashboardImportCtrl', DashboardImportCtrl); +coreModule.controller('CreateFolderCtrl', CreateFolderCtrl); diff --git a/public/app/features/dashboard/folder_page_loader.ts b/public/app/features/manage-dashboards/services/FolderPageLoader.ts similarity index 100% rename from public/app/features/dashboard/folder_page_loader.ts rename to public/app/features/manage-dashboards/services/FolderPageLoader.ts