Commit 25504e84 by Alexander Zobnin

dashboard import to folder: minor fixes

parent 8fd3015e
...@@ -95,14 +95,14 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) { ...@@ -95,14 +95,14 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
if hasEditPermissionInFoldersQuery.Result { if hasEditPermissionInFoldersQuery.Result {
children := []*dtos.NavLink{ children := []*dtos.NavLink{
{Text: "Dashboard", Icon: "gicon gicon-dashboard-new", Url: setting.AppSubUrl + "/dashboard/new"}, {Text: "Dashboard", Icon: "gicon gicon-dashboard-new", Url: setting.AppSubUrl + "/dashboard/new"},
{Text: "Import", SubTitle: "Import dashboard from file or Grafana.com", Id: "import", Icon: "gicon gicon-dashboard-import", Url: setting.AppSubUrl + "/dashboard/import"},
} }
if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR { if c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR {
children = append(children, &dtos.NavLink{Text: "Folder", SubTitle: "Create a new folder to organize your dashboards", Id: "folder", Icon: "gicon gicon-folder-new", Url: setting.AppSubUrl + "/dashboards/folder/new"}) children = append(children, &dtos.NavLink{Text: "Folder", SubTitle: "Create a new folder to organize your dashboards", Id: "folder", Icon: "gicon gicon-folder-new", Url: setting.AppSubUrl + "/dashboards/folder/new"})
children = append(children, &dtos.NavLink{Text: "Import", SubTitle: "Import dashboard from file or Grafana.com", Id: "import", Icon: "gicon gicon-dashboard-import", Url: setting.AppSubUrl + "/dashboard/import"})
} }
children = append(children, &dtos.NavLink{Text: "Import", SubTitle: "Import dashboard from file or Grafana.com", Id: "import", Icon: "gicon gicon-dashboard-import", Url: setting.AppSubUrl + "/dashboard/import"})
data.NavTree = append(data.NavTree, &dtos.NavLink{ data.NavTree = append(data.NavTree, &dtos.NavLink{
Text: "Create", Text: "Create",
Id: "create", Id: "create",
......
...@@ -154,11 +154,11 @@ export class DashboardImportCtrl { ...@@ -154,11 +154,11 @@ export class DashboardImportCtrl {
} }
onExitFolderCreation() { onExitFolderCreation() {
this.inputsValid = true; this.inputValueChanged();
} }
isValid() { isValid() {
return this.inputsValid && !this.hasNameValidationError && this.folderId !== null; return this.inputsValid && this.folderId !== null;
} }
saveDashboard() { saveDashboard() {
......
...@@ -132,24 +132,24 @@ export class FolderPickerCtrl { ...@@ -132,24 +132,24 @@ export class FolderPickerCtrl {
} }
private loadInitialValue() { private loadInitialValue() {
const resetFolder = { text: this.initialTitle, value: null };
const rootFolder = { text: this.rootName, value: 0 };
this.getOptions('').then(result => { this.getOptions('').then(result => {
if (!_.isNil(this.initialFolderId)) { let folder;
// If initialFolderId is set, try to find it in result or return null if (this.initialFolderId) {
this.folder = _.find(result, { value: this.initialFolderId }); folder = _.find(result, { value: this.initialFolderId });
if (!this.folder) { } else if (this.enableReset && this.initialTitle && this.initialFolderId === null) {
this.folder = { text: this.initialTitle, value: null }; folder = resetFolder;
} }
} else {
// If initialFolderId isn't set, return General folder for Editor if (!folder) {
// or first available for user, otherwise return null
if (this.isEditor) { if (this.isEditor) {
this.folder = { text: this.rootName, value: 0 }; folder = rootFolder;
} else if (result.length > 0) {
this.folder = result[0];
} else { } else {
this.folder = { text: this.initialTitle, value: null }; folder = result.length > 0 ? result[0] : resetFolder;
} }
} }
this.folder = folder;
this.onFolderLoad(); this.onFolderLoad();
}); });
} }
......
...@@ -82,14 +82,14 @@ ...@@ -82,14 +82,14 @@
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form gf-form--grow"> <div class="gf-form gf-form--grow">
<folder-picker initial-folder-id="ctrl.folderId" <folder-picker label-class="width-15"
initial-title="ctrl.initialFolderTitle" initial-folder-id="ctrl.folderId"
on-change="ctrl.onFolderChange($folder)" initial-title="ctrl.initialFolderTitle"
on-load="ctrl.onFolderChange($folder)" on-change="ctrl.onFolderChange($folder)"
enter-folder-creation="ctrl.onEnterFolderCreation()" on-load="ctrl.onFolderChange($folder)"
exit-folder-creation="ctrl.onExitFolderCreation()" enter-folder-creation="ctrl.onEnterFolderCreation()"
enable-create-new="true" exit-folder-creation="ctrl.onExitFolderCreation()"
label-class="width-15"> enable-create-new="true">
</folder-picker> </folder-picker>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment