Skip to content

Commit 075c722

Browse files
committed
ux(dashboard): worked on single row edit mode, grafana#6442
1 parent e23f898 commit 075c722

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

public/app/features/dashboard/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export class DashboardModel {
192192

193193
this.editMode = !this.editMode;
194194
this.updateSubmenuVisibility();
195+
this.events.emit('edit-mode-changed', this.editMode);
195196
}
196197

197198
setPanelFocus(id) {

public/app/features/dashboard/row/add_panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class AddPanelCtrl {
9393
isNew: true,
9494
};
9595

96-
this.rowCtrl.dropView = 0;
96+
this.rowCtrl.closeDropView();
9797
this.dashboard.addPanel(panel, this.row);
9898
this.$timeout(() => {
9999
this.$rootScope.$broadcast('render');

public/app/features/dashboard/row/row.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div ng-if="ctrl.dashboard.editMode">
1+
<div ng-if="ctrl.editMode">
22
<div class="dash-row-header">
33
<a class="dash-row-header-title" ng-click="ctrl.toggleCollapse()">
44
<span class="dash-row-collapse-toggle pointer">
@@ -40,7 +40,7 @@
4040
</div>
4141
</div>
4242

43-
<div ng-if="!ctrl.dashboard.editMode">
43+
<div ng-if="!ctrl.editMode">
4444
<div class="row-open">
4545
<div class='row-tab dropdown' ng-show="dashboardMeta.canEdit" ng-hide="dashboard.meta.fullscreen">
4646
<span class="row-tab-button dropdown-toggle" data-toggle="dropdown">

public/app/features/dashboard/row/row_ctrl.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class DashRowCtrl {
1212
dashboard: any;
1313
row: any;
1414
dropView: number;
15+
editMode: boolean;
1516

1617
/** @ngInject */
1718
constructor(private $scope, private $rootScope, private $timeout, private uiSegmentSrv, private $q) {
@@ -21,6 +22,12 @@ export class DashRowCtrl {
2122
this.dropView = 1;
2223
delete this.row.isNew;
2324
}
25+
26+
this.dashboard.events.on('edit-mode-changed', this.editModeChanged.bind(this), $scope);
27+
}
28+
29+
editModeChanged() {
30+
this.editMode = this.dashboard.editMode;
2431
}
2532

2633
onDrop(panelId, dropTarget) {
@@ -107,15 +114,20 @@ export class DashRowCtrl {
107114
}
108115

109116
onMenuAddPanel() {
110-
this.dashboard.toggleEditMode();
117+
this.editMode = true;
111118
this.dropView = 1;
112119
}
113120

114121
onMenuRowOptions() {
115-
this.dashboard.toggleEditMode();
122+
this.editMode = true;
116123
this.dropView = 2;
117124
}
118125

126+
closeDropView() {
127+
this.dropView = 0;
128+
this.editMode = this.dashboard.editMode;
129+
}
130+
119131
onMenuDeleteRow() {
120132
this.dashboard.removeRow(this.row);
121133
}
@@ -208,7 +220,7 @@ coreModule.directive('panelDropZone', function($timeout) {
208220
}
209221

210222
function updateState() {
211-
if (scope.ctrl.dashboard.editMode) {
223+
if (scope.ctrl.editMode) {
212224
if (row.panels.length === 0 && indrag === false) {
213225
return showPanel(12, 'Empty Space');
214226
}
@@ -234,8 +246,7 @@ coreModule.directive('panelDropZone', function($timeout) {
234246
}
235247

236248
row.events.on('span-changed', updateState, scope);
237-
238-
scope.$watchGroup(['ctrl.dashboard.editMode'], updateState);
249+
scope.$watchGroup(['ctrl.editMode'], updateState);
239250

240251
scope.$on("ANGULAR_DRAG_START", function() {
241252
indrag = true;

0 commit comments

Comments
 (0)