-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
218 additions
and
67 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
src/core_plugins/kibana/public/dashboard/components/panel/panel.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/core_plugins/kibana/public/dashboard/dashboard_view_mode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* A dashboard mode. | ||
* @typedef {string} DashboardMode | ||
*/ | ||
|
||
/** | ||
* Dashboard view modes. | ||
* @type {{EDIT: DashboardMode, VIEW: DashboardMode}} | ||
*/ | ||
export const DashboardViewMode = { | ||
EDIT: 'edit', | ||
VIEW: 'view' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/core_plugins/kibana/public/dashboard/get_top_nav_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { DashboardViewMode } from './dashboard_view_mode'; | ||
import { createTopNavExecuteConfig, createTopNavTemplateConfig } from 'ui/kbn_top_nav/kbn_top_nav_config'; | ||
|
||
/** | ||
* @param {DashboardMode} dashboardMode. | ||
* @param kbnUrl - used to change the url. | ||
* @param {(DashboardMode) => void} modeChange - a function to trigger a dashboard mode change. | ||
* @return {Array} - Returns an array of objects for a top nav configuration, based on the | ||
* mode. | ||
*/ | ||
export function getTopNavConfig(dashboardMode, kbnUrl, modeChange) { | ||
switch (dashboardMode) { | ||
case DashboardViewMode.VIEW: | ||
return [getNewConfig(kbnUrl), getOpenConfig(), getShareConfig(), getEditConfig(modeChange)]; | ||
case DashboardViewMode.EDIT: | ||
return [getNewConfig(kbnUrl), getOpenConfig(), getAddConfig(), getSaveConfig(), getOptionsConfig(), getViewConfig(modeChange)]; | ||
default: | ||
return []; | ||
} | ||
} | ||
|
||
function getEditConfig(modeChange) { | ||
return createTopNavExecuteConfig( | ||
'edit', | ||
'Switch to edit mode', | ||
'dashboardEditMode', | ||
() => { modeChange(DashboardViewMode.EDIT); }); | ||
} | ||
|
||
function getViewConfig(modeChange) { | ||
return createTopNavExecuteConfig( | ||
'preview', | ||
'Switch to preview mode', | ||
'dashboardViewOnlyMode', | ||
() => { modeChange(DashboardViewMode.VIEW); }); | ||
} | ||
|
||
function getNewConfig(kbnUrl) { | ||
return createTopNavExecuteConfig( | ||
'new', | ||
'New Dashboard', | ||
'dashboardNewButton', | ||
() => { kbnUrl.change('/dashboard', {}); }); | ||
} | ||
|
||
function getAddConfig() { | ||
return createTopNavTemplateConfig( | ||
'add', | ||
'Add a panel to the dashboard', | ||
'dashboardAddPanelButton', | ||
require('plugins/kibana/dashboard/partials/pick_visualization.html')); | ||
} | ||
|
||
function getSaveConfig() { | ||
return createTopNavTemplateConfig( | ||
'save', | ||
'Save Dashboard', | ||
'dashboardSaveButton', | ||
require('plugins/kibana/dashboard/partials/save_dashboard.html')); | ||
} | ||
|
||
function getOpenConfig() { | ||
return createTopNavTemplateConfig( | ||
'open', | ||
'Open Saved Dashboard', | ||
'dashboardOpenButton', | ||
require('plugins/kibana/dashboard/partials/load_dashboard.html')); | ||
} | ||
|
||
function getShareConfig() { | ||
return createTopNavTemplateConfig( | ||
'share', | ||
'Share Dashboard', | ||
'dashboardShareButton', | ||
require('plugins/kibana/dashboard/partials/share.html')); | ||
} | ||
|
||
function getOptionsConfig() { | ||
return createTopNavTemplateConfig( | ||
'options', | ||
'Options', | ||
'dashboardOptionsButton', | ||
require('plugins/kibana/dashboard/partials/options.html')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.