Skip to content
Snippets Groups Projects
Commit f970d819 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #852 from metabase/dash_world_writable

Ability to collaborate on public Dashboards
parents 51f1aa57 5aa9a2ed
Branches
Tags
No related merge requests found
......@@ -18,7 +18,16 @@ DashboardDirectives.directive('mbDashboardSaver', ['CorvusCore', 'Dashboard', '$
controller: ['$scope', '$modalInstance',
function($scope, $modalInstance) {
$scope.dashboard = angular.copy(scope.dashboard);
$scope.permOptions = CorvusCore.perms;
// TODO: hard coding this is wack, but right now there is little choice.
// we need to cleanup these definitions and ideally get them from the api.
$scope.permOptions = this.perms = [{
'id': 0,
'name': 'Private'
}, {
'id': 2,
'name': 'Public'
}];
$scope.save = function(dash) {
$scope.$broadcast("form:reset");
......
'use strict';
/*global _*/
import OnClickOutside from 'react-onclickoutside';
......@@ -32,10 +33,15 @@ export default React.createClass({
loadDashboardList: function() {
var component = this;
this.props.dashboardApi.list({
'filterMode': 'mine'
'filterMode': 'all'
}, function(result) {
// filter down to dashboards we can modify
var editableDashes = _.filter(result, function(dash) {
return dash.can_write;
});
component.setState({
dashboards: result
dashboards: editableDashes
});
}, function(error) {
// TODO: do something relevant here
......@@ -88,13 +94,13 @@ export default React.createClass({
var name = this.refs.name.getDOMNode().value.trim();
var description = this.refs.description.getDOMNode().value.trim();
var perms = this.refs.public_perms.getDOMNode().value;
var perms = parseInt(this.refs.public_perms.state.value);
// populate a new Dash object
var newDash = {
'name': (name && name.length > 0) ? name : null,
'description': (description && description.length > 0) ? name : null,
'public_perms': 0
'public_perms': perms
};
// create a new dashboard, then add the card to that
......@@ -144,7 +150,7 @@ export default React.createClass({
// TODO: hard coding values :(
var privacyOptions = [
(<option key="0" value={0}>Private</option>),
(<option key="1" value={1}>Public (Others can read)</option>)
(<option key="2" value={2}>Public</option>)
];
var formError;
......@@ -219,7 +225,7 @@ export default React.createClass({
showCharm={false}
errors={this.state.errors}>
<label className="Select Form-offset">
<select className="mt1" ref="public_perms">
<select className="mt1" ref="public_perms" defaultValue="2">
{privacyOptions}
</select>
</label>
......
databaseChangeLog:
- changeSet:
id: 11
author: agilliland
changes:
- sql:
sql: update report_dashboard set public_perms = 2 where public_perms = 1
......@@ -8,6 +8,7 @@
{"include": {"file": "migrations/007_add_field_parent_id.json"}},
{"include": {"file": "migrations/008_add_display_name_columns.json"}},
{"include": {"file": "migrations/009_add_table_visibility_type_column.json"}},
{"include": {"file": "migrations/010_add_revision_table.yaml"}}
{"include": {"file": "migrations/010_add_revision_table.yaml"}},
{"include": {"file": "migrations/011_cleanup_dashboard_perms.yaml"}}
]
}
......@@ -22,7 +22,7 @@
:all (sel :many Dashboard (k/where (or {:creator_id *current-user-id*}
{:public_perms [> common/perms-none]})))
:mine (sel :many Dashboard :creator_id *current-user-id*))
(hydrate :creator)))
(hydrate :creator :can_read :can_write)))
(defendpoint POST "/"
"Create a new `Dashboard`."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment