mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
dashboard import to folder: minor fixes
This commit is contained in:
@@ -95,14 +95,14 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
|
||||
if hasEditPermissionInFoldersQuery.Result {
|
||||
children := []*dtos.NavLink{
|
||||
{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 {
|
||||
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{
|
||||
Text: "Create",
|
||||
Id: "create",
|
||||
|
||||
@@ -154,11 +154,11 @@ export class DashboardImportCtrl {
|
||||
}
|
||||
|
||||
onExitFolderCreation() {
|
||||
this.inputsValid = true;
|
||||
this.inputValueChanged();
|
||||
}
|
||||
|
||||
isValid() {
|
||||
return this.inputsValid && !this.hasNameValidationError && this.folderId !== null;
|
||||
return this.inputsValid && this.folderId !== null;
|
||||
}
|
||||
|
||||
saveDashboard() {
|
||||
|
||||
@@ -132,24 +132,24 @@ export class FolderPickerCtrl {
|
||||
}
|
||||
|
||||
private loadInitialValue() {
|
||||
const resetFolder = { text: this.initialTitle, value: null };
|
||||
const rootFolder = { text: this.rootName, value: 0 };
|
||||
this.getOptions('').then(result => {
|
||||
if (!_.isNil(this.initialFolderId)) {
|
||||
// If initialFolderId is set, try to find it in result or return null
|
||||
this.folder = _.find(result, { value: this.initialFolderId });
|
||||
if (!this.folder) {
|
||||
this.folder = { text: this.initialTitle, value: null };
|
||||
}
|
||||
} else {
|
||||
// If initialFolderId isn't set, return General folder for Editor
|
||||
// or first available for user, otherwise return null
|
||||
let folder;
|
||||
if (this.initialFolderId) {
|
||||
folder = _.find(result, { value: this.initialFolderId });
|
||||
} else if (this.enableReset && this.initialTitle && this.initialFolderId === null) {
|
||||
folder = resetFolder;
|
||||
}
|
||||
|
||||
if (!folder) {
|
||||
if (this.isEditor) {
|
||||
this.folder = { text: this.rootName, value: 0 };
|
||||
} else if (result.length > 0) {
|
||||
this.folder = result[0];
|
||||
folder = rootFolder;
|
||||
} else {
|
||||
this.folder = { text: this.initialTitle, value: null };
|
||||
folder = result.length > 0 ? result[0] : resetFolder;
|
||||
}
|
||||
}
|
||||
this.folder = folder;
|
||||
this.onFolderLoad();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,14 +82,14 @@
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form gf-form--grow">
|
||||
<folder-picker initial-folder-id="ctrl.folderId"
|
||||
initial-title="ctrl.initialFolderTitle"
|
||||
on-change="ctrl.onFolderChange($folder)"
|
||||
on-load="ctrl.onFolderChange($folder)"
|
||||
enter-folder-creation="ctrl.onEnterFolderCreation()"
|
||||
exit-folder-creation="ctrl.onExitFolderCreation()"
|
||||
enable-create-new="true"
|
||||
label-class="width-15">
|
||||
<folder-picker label-class="width-15"
|
||||
initial-folder-id="ctrl.folderId"
|
||||
initial-title="ctrl.initialFolderTitle"
|
||||
on-change="ctrl.onFolderChange($folder)"
|
||||
on-load="ctrl.onFolderChange($folder)"
|
||||
enter-folder-creation="ctrl.onEnterFolderCreation()"
|
||||
exit-folder-creation="ctrl.onExitFolderCreation()"
|
||||
enable-create-new="true">
|
||||
</folder-picker>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user