-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow plugins to hide write controls in the dashboard app #11537
Merged
stacey-gammon
merged 14 commits into
elastic:master
from
stacey-gammon:dashboard-only-mode
May 25, 2017
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b75c53f
Implement a way to hide write controls from dashboard
stacey-gammon b3fd130
Add roles definition to the saved dashboard object
stacey-gammon 03ba3d3
Remove roles from dashboard
stacey-gammon 208e915
Use an angular provider to control the hideWriteControls flag
stacey-gammon 106c3da
Add an api to chrome to show only a single app by id
stacey-gammon 1d0226e
Refactor injectVars logic
stacey-gammon d05f3bb
Fix tests
stacey-gammon bd73941
Refactor kibana root controller
stacey-gammon 842edac
add additional test functionality
stacey-gammon 186b242
Missed a couple spots for hiding edit controls
stacey-gammon d565754
add retry and help text for dash only mode failures
stacey-gammon a0431c0
Move element into screen when clicking
stacey-gammon d46fb27
use shorthand for object creation
stacey-gammon aa56dd5
Hide checkboxes, show 'no dashboard' message with the button
stacey-gammon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export function injectVars(server) { | ||
const serverConfig = server.config(); | ||
|
||
//DEPRECATED SETTINGS | ||
//if the url is set, the old settings must be used. | ||
//keeping this logic for backward compatibilty. | ||
const configuredUrl = server.config().get('tilemap.url'); | ||
const isOverridden = typeof configuredUrl === 'string' && configuredUrl !== ''; | ||
const tilemapConfig = serverConfig.get('tilemap'); | ||
|
||
return { | ||
kbnDefaultAppId: serverConfig.get('kibana.defaultAppId'), | ||
tilemapsConfig: { | ||
deprecated: { | ||
isOverridden, | ||
config: tilemapConfig, | ||
}, | ||
manifestServiceUrl: serverConfig.get('tilemap.manifestServiceUrl') | ||
} | ||
}; | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/core_plugins/kibana/public/dashboard/dashboard_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,22 @@ | ||
import { uiModules } from 'ui/modules'; | ||
uiModules.get('kibana') | ||
.provider('dashboardConfig', () => { | ||
let hideWriteControls = false; | ||
|
||
return { | ||
/** | ||
* Part of the exposed plugin API - do not remove without careful consideration. | ||
* @type {boolean} | ||
*/ | ||
turnHideWriteControlsOn() { | ||
hideWriteControls = true; | ||
}, | ||
$get() { | ||
return { | ||
getHideWriteControls() { | ||
return hideWriteControls; | ||
} | ||
}; | ||
} | ||
}; | ||
}); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import moment from 'moment-timezone'; | ||
|
||
export function KibanaRootController($scope, courier, config) { | ||
// wait for the application to finish loading | ||
$scope.$on('application.load', function () { | ||
courier.start(); | ||
}); | ||
|
||
config.watch('dateFormat:tz', setDefaultTimezone, $scope); | ||
config.watch('dateFormat:dow', setStartDayOfWeek, $scope); | ||
|
||
function setDefaultTimezone(tz) { | ||
moment.tz.setDefault(tz); | ||
} | ||
|
||
function setStartDayOfWeek(day) { | ||
const dow = moment.weekdays().indexOf(day); | ||
moment.updateLocale(moment.locale(), { week: { dow } }); | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More of a general question, for getters that return booleans, should the getter be named
shouldHide...
orcanHide...
? It seems more expressive when calling it within conditionals.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the
get
prefix because I think it makes it clear that it's not a setter. e.g. you can't immediately tell ifshouldHide..
would take a boolean and set the value of shouldHide, or is getting the shouldHide variable. Though I agree it reads nicer when it'sif (shouldHide)...
.I suppose I wouldn't be opposed to calling it
getShouldHideWriteControls
, but I'm not sure theshould
really adds anything.I'd prefer not to hold up the PR on this but it might be worthwhile to create another issue to come to a team conclusion on the best way to name getters and then add it to the style guide. I've had reviews in the past with @cjcenizal that touch on this issue as well, and I don't think we ever settled on something concrete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, my opinion is that
can
andshould
are pretty ambiguous because whether something "can" be or "should" be is pretty relative and open to interpretation.getIs
also feels a little strange to me when I read it. I generally just stick withis
andare
where possible, e.g.areWriteControlsVisible
orwriteControls.isVisible
. But I don't think we have an agreed-upon convention, so until we have that I think the most efficient way forward is if we each just write names in ways that we're comfortable with and, to Stacey's point, not get too hung up on nitpicking the way other people write them.