You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2013/09/27 11:31:40 UTC
[1/3] git commit: updated refs/heads/master to 221ada7
Updated Branches:
refs/heads/master c7249d028 -> 221ada71f
Fauxton: Permissions settings for databases
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/724b3f2c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/724b3f2c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/724b3f2c
Branch: refs/heads/master
Commit: 724b3f2c1e162ddf8c40a1748a4c5b49cd163c85
Parents: c7249d0
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Sep 24 13:31:01 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Sep 27 11:27:26 2013 +0200
----------------------------------------------------------------------
.gitignore | 1 +
src/fauxton/app/addons/permissions/base.js | 25 +++
src/fauxton/app/addons/permissions/resources.js | 70 +++++++
src/fauxton/app/addons/permissions/routes.js | 64 ++++++
.../app/addons/permissions/templates/item.html | 17 ++
.../permissions/templates/permissions.html | 15 ++
.../addons/permissions/templates/section.html | 37 ++++
.../addons/permissions/tests/resourceSpec.js | 51 +++++
.../app/addons/permissions/tests/viewsSpec.js | 159 +++++++++++++++
src/fauxton/app/addons/permissions/views.js | 199 +++++++++++++++++++
src/fauxton/settings.json.default | 1 +
11 files changed, 639 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index a4798c9..58f992e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,6 +95,7 @@ src/fauxton/app/addons/*
!src/fauxton/app/addons/contribute
!src/fauxton/app/addons/auth
!src/fauxton/app/addons/exampleAuth
+!src/fauxton/app/addons/permissions
src/fauxton/settings.json*
!src/fauxton/settings.json.default
share/www/fauxton
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/base.js b/src/fauxton/app/addons/permissions/base.js
new file mode 100644
index 0000000..016ba1c
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/base.js
@@ -0,0 +1,25 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api",
+ "addons/permissions/routes"
+],
+
+function(app, FauxtonAPI, Permissions) {
+
+ Permissions.initialize = function() {};
+
+ return Permissions;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/resources.js b/src/fauxton/app/addons/permissions/resources.js
new file mode 100644
index 0000000..66eaffd
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/resources.js
@@ -0,0 +1,70 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api"
+],
+function (app, FauxtonAPI ) {
+ var Permissions = FauxtonAPI.addon();
+
+ Permissions.Security = Backbone.Model.extend({
+ defaults: {
+ admins: {
+ names: [],
+ roles: []
+ },
+
+ members: {
+ names: [],
+ roles: []
+ }
+ },
+
+ isNew: function () {
+ return false;
+ },
+
+ initialize: function (attrs, options) {
+ this.database = options.database;
+ },
+
+ url: function () {
+ return this.database.id + '/_security';
+ },
+
+ addItem: function (value, type, section) {
+ var sectionValues = this.get(section);
+
+ if (!sectionValues || !sectionValues[type]) {
+ return {
+ error: true,
+ msg: 'Section ' + section + 'does not exist'
+ };
+ }
+
+ if (sectionValues[type].indexOf(value) > -1) {
+ return {
+ error: true,
+ msg: 'Role/Name has already been added'
+ };
+ }
+
+ sectionValues[type].push(value);
+ return this.set(section, sectionValues);
+ }
+
+ });
+
+ return Permissions;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/routes.js b/src/fauxton/app/addons/permissions/routes.js
new file mode 100644
index 0000000..f6c6587
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/routes.js
@@ -0,0 +1,64 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api",
+ "modules/databases/base",
+ "addons/permissions/views"
+],
+function (app, FauxtonAPI, Databases, Permissions) {
+
+ var PermissionsRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: 'one_pane',
+ selectedHeader: 'Databases',
+
+ routes: {
+ 'database/:database/permissions': 'permissions'
+ },
+
+ initialize: function (route, masterLayout, options) {
+ var docOptions = app.getParams();
+ docOptions.include_docs = true;
+
+ this.databaseName = options[0];
+ this.database = new Databases.Model({id:this.databaseName});
+ this.security = new Permissions.Security(null, {
+ database: this.database
+ });
+ },
+
+ establish: function () {
+ return [this.database.fetch(), this.security.fetch()];
+ },
+
+ permissions: function () {
+ this.setView('#dashboard-content', new Permissions.Permissions({
+ database: this.database,
+ model: this.security
+ }));
+
+ },
+
+ crumbs: function () {
+ return [
+ {"name": "Databases", "link": "/_all_dbs"},
+ {"name": this.database.id, "link": Databases.databaseUrl(this.database)},
+ {"name": "Permissions", "link": "/permissions"}
+ ];
+ },
+
+ });
+
+ Permissions.RouteObjects = [PermissionsRouteObject];
+ return Permissions;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/item.html b/src/fauxton/app/addons/permissions/templates/item.html
new file mode 100644
index 0000000..aa01d0b
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/templates/item.html
@@ -0,0 +1,17 @@
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<li>
+<span> <%= item %> </span>
+<button type="button" style="float:none; margin-bottom:6px" class="close">×</button>
+</li>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/templates/permissions.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/permissions.html b/src/fauxton/app/addons/permissions/templates/permissions.html
new file mode 100644
index 0000000..d247425
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/templates/permissions.html
@@ -0,0 +1,15 @@
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<p>Each database contains lists of admins and members. Admins and members are each defined by names and roles, which are lists of strings.</p>
+<div id="sections"> </div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/templates/section.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/section.html b/src/fauxton/app/addons/permissions/templates/section.html
new file mode 100644
index 0000000..102d857
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/templates/section.html
@@ -0,0 +1,37 @@
+<!--
+Licensed under the Apache License, Version 2.0 (the "License"); you may not
+use this file except in compliance with the License. You may obtain a copy of
+the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+License for the specific language governing permissions and limitations under
+the License.
+-->
+<h1> <%= section %> </h1>
+<p id="help"> <%= help %> </p>
+
+<div class="row">
+ <div class="span6">
+ <h3> Names </h3>
+ <ul id="items-names"></ul>
+
+ <form class="permission-item-form form-inline">
+ <input data-section="<%= section %>" data-type="names" type="text" class="item input-small" placeholder="Add Name">
+ <input type="submit" class="btn" value="Add Name" >
+ </form>
+
+ </div>
+ <div class="span6">
+ <h3> Roles </h3>
+ <ul id="items-roles"></ul>
+
+ <form class="permission-item-form form-inline">
+ <input data-section="<%= section %>" data-type="roles" type="text" class="item input-small" placeholder="Add Role">
+ <input type="submit" class="btn" value="Add Role" >
+ </form>
+ </div>
+</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/tests/resourceSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/tests/resourceSpec.js b/src/fauxton/app/addons/permissions/tests/resourceSpec.js
new file mode 100644
index 0000000..f73687a
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/tests/resourceSpec.js
@@ -0,0 +1,51 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+ 'api',
+ 'addons/permissions/resources',
+ 'testUtils'
+], function (FauxtonAPI, Models, testUtils) {
+ var assert = testUtils.assert;
+
+ describe('Permissions', function () {
+
+ describe('#addItem', function () {
+ var security;
+
+ beforeEach(function () {
+ security = new Models.Security(null, {database: 'fakedb'});
+ });
+
+ it('Should add value to section', function () {
+
+ security.addItem('_user', 'names', 'admins');
+ assert.equal(security.get('admins').names[0], '_user');
+ });
+
+ it('Should handle incorrect type', function () {
+ security.addItem('_user', 'asdasd', 'admins');
+ });
+
+ it('Should handle incorrect section', function () {
+ security.addItem('_user', 'names', 'Asdasd');
+ });
+
+ it('Should reject duplicates', function () {
+ security.addItem('_user', 'names', 'admins');
+ security.addItem('_user', 'names', 'admins');
+ assert.equal(security.get('admins').names.length, 1);
+ });
+ });
+
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/tests/viewsSpec.js b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
new file mode 100644
index 0000000..e5330c0
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
@@ -0,0 +1,159 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+define([
+ 'api',
+ 'addons/permissions/views',
+ 'addons/permissions/resources',
+ 'testUtils'
+], function (FauxtonAPI, Views, Models, testUtils) {
+ var assert = testUtils.assert,
+ ViewSandbox = testUtils.ViewSandbox;
+
+ describe('Permission View', function () {
+
+ beforeEach(function () {
+ security = new Models.Security({'admins': {
+ 'names': ['_user'],
+ 'roles': []
+ }
+ }, {database: 'fakedb'});
+
+ section = new Views.Permissions({
+ database: 'fakedb',
+ model: security
+ });
+
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(section);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
+ });
+
+ describe('itemRemoved', function () {
+
+ it('Should set model', function () {
+ var saveMock = sinon.spy(security, 'set');
+ Views.events.trigger('itemRemoved');
+
+ assert.ok(saveMock.calledOnce);
+ var args = saveMock.args;
+ assert.deepEqual(args[0][0], {"admins":{"names":["_user"],"roles":[]},"members":{"names":[],"roles":[]}});
+ });
+
+ it('Should save model', function () {
+ var saveMock = sinon.spy(security, 'save');
+ Views.events.trigger('itemRemoved');
+
+ assert.ok(saveMock.calledOnce);
+ });
+ });
+
+ });
+
+ describe('PermissionsSection', function () {
+ var section, security;
+
+ beforeEach(function () {
+ security = new Models.Security({'admins': {
+ 'names': ['_user'],
+ 'roles': []
+ }
+ }, {database: 'fakedb'});
+
+ section = new Views.PermissionSection({
+ section: 'admins',
+ model: security
+ });
+
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(section);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
+ });
+
+ describe('#discardRemovedViews', function () {
+ it('Should not filter out active views', function () {
+ section.discardRemovedViews();
+
+ assert.equal(section.nameViews.length, 1);
+
+ });
+
+ it('Should filter out removed views', function () {
+ section.nameViews[0].removed = true;
+ section.discardRemovedViews();
+
+ assert.equal(section.nameViews.length, 0);
+
+ });
+
+ });
+
+ describe('#getItemFromView', function () {
+
+ it('Should return item list', function () {
+ var items = section.getItemFromView(section.nameViews);
+
+ assert.deepEqual(items, ['_user']);
+ });
+
+ });
+
+ describe('#addItems', function () {
+
+ it('Should add item to model', function () {
+ //todo add a test here
+
+ });
+
+ });
+
+ });
+
+ describe('PermissionItem', function () {
+ var item;
+
+ beforeEach(function () {
+ item = new Views.PermissionItem({
+ item: '_user'
+ });
+
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(item);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
+ });
+
+ it('should trigger event on remove item', function () {
+ var eventSpy = sinon.spy();
+
+ Views.events.on('itemRemoved', eventSpy);
+
+ item.$('.close').click();
+
+ assert.ok(eventSpy.calledOnce);
+ });
+
+ it('should set removed to true', function () {
+ item.$('.close').click();
+
+ assert.ok(item.removed);
+ });
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/app/addons/permissions/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/views.js b/src/fauxton/app/addons/permissions/views.js
new file mode 100644
index 0000000..4c2987b
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/views.js
@@ -0,0 +1,199 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+define([
+ "app",
+ "api",
+ "addons/permissions/resources"
+],
+function (app, FauxtonAPI, Permissions ) {
+ var events = {};
+ Permissions.events = _.extend(events, Backbone.Events);
+
+ Permissions.Permissions = FauxtonAPI.View.extend({
+ template: "addons/permissions/templates/permissions",
+
+ initialize: function (options) {
+ this.database = options.database;
+ this.listenTo(Permissions.events, 'itemRemoved', this.itemRemoved);
+ },
+
+ itemRemoved: function (event) {
+ this.model.set({
+ admins: this.adminsView.items(),
+ members: this.membersView.items()
+ });
+
+ this.model.save().then(function () {
+ FauxtonAPI.addNotification({
+ msg: 'Database permissions has been updated.'
+ });
+ }, function (xhr) {
+ FauxtonAPI.addNotification({
+ msg: 'Could not update permissions - reason: ' + xhr.responseText,
+ type: 'error'
+ });
+ });
+ },
+
+ beforeRender: function () {
+ this.adminsView = this.insertView('#sections', new Permissions.PermissionSection({
+ model: this.model,
+ section: 'admins',
+ help: 'Database admins can update design documents and edit the admin and member lists.'
+ }));
+
+ this.membersView = this.insertView('#sections', new Permissions.PermissionSection({
+ model: this.model,
+ section: 'members',
+ help: 'Database members can access the database. If no members are defined, the database is public.'
+ }));
+ },
+
+ serialize: function () {
+ return {
+ databaseName: this.database.id,
+ };
+ }
+ });
+
+ Permissions.PermissionSection = FauxtonAPI.View.extend({
+ template: "addons/permissions/templates/section",
+ initialize: function (options) {
+ this.section = options.section;
+ this.help = options.help;
+ },
+
+ events: {
+ "submit .permission-item-form": "addItem",
+ 'click .close': "removeItem"
+ },
+
+ beforeRender: function () {
+ var section = this.model.get(this.section);
+
+ this.nameViews = [];
+ this.roleViews = [];
+
+ _.each(section.names, function (name) {
+ var nameView = this.insertView('#items-names', new Permissions.PermissionItem({
+ item: name,
+ }));
+ this.nameViews.push(nameView);
+ }, this);
+
+ _.each(section.roles, function (role) {
+ var roleView = this.insertView('#items-roles', new Permissions.PermissionItem({
+ item: role,
+ }));
+ this.roleViews.push(roleView);
+ }, this);
+ },
+
+ getItemFromView: function (viewList) {
+ return _.map(viewList, function (view) {
+ return view.item;
+ });
+ },
+
+ discardRemovedViews: function () {
+ this.nameViews = _.filter(this.nameViews, function (view) {
+ return !view.removed;
+ });
+
+ this.roleViews = _.filter(this.roleViews, function (view) {
+ return !view.removed;
+ });
+ },
+
+ items: function () {
+ this.discardRemovedViews();
+
+ return {
+ names: this.getItemFromView(this.nameViews),
+ roles: this.getItemFromView(this.roleViews)
+ };
+ },
+
+ addItem: function (event) {
+ event.preventDefault();
+ var $item = this.$(event.currentTarget).find('.item'),
+ value = $item.val(),
+ section = $item.data('section'),
+ type = $item.data('type'),
+ that = this;
+
+ var resp = this.model.addItem(value, type, section);
+
+ if (resp && resp.error) {
+ return FauxtonAPI.addNotification({
+ msg: resp.msg,
+ type: 'error'
+ });
+ }
+
+ this.model.save().then(function () {
+ that.render();
+ FauxtonAPI.addNotification({
+ msg: 'Database permissions has been updated.'
+ });
+ }, function (xhr) {
+ FauxtonAPI.addNotification({
+ msg: 'Could not update permissions - reason: ' + xhr.responseText,
+ type: 'error'
+ });
+ });
+ },
+
+ serialize: function () {
+ return {
+ section: this.section,
+ help: this.help
+ };
+ }
+
+ });
+
+ Permissions.PermissionItem = FauxtonAPI.View.extend({
+ template: "addons/permissions/templates/item",
+ initialize: function (options) {
+ this.item = options.item;
+ this.viewsList = options.viewsList;
+ },
+
+ events: {
+ 'click .close': "removeItem"
+ },
+
+ removeItem: function (event) {
+ var that = this;
+ event.preventDefault();
+
+ this.removed = true;
+ Permissions.events.trigger('itemRemoved');
+
+ this.$el.hide('fast', function () {
+ that.remove();
+ });
+ },
+
+
+ serialize: function () {
+ return {
+ item: this.item
+ };
+ }
+
+ });
+
+ return Permissions;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/724b3f2c/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index 81cb4cb..30088f0 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -6,6 +6,7 @@
{ "name": "stats" },
{ "name": "replication" },
{ "name": "contribute" },
+ { "name": "permissions" },
{ "name": "auth" }
],
"template": {
[2/3] git commit: updated refs/heads/master to 221ada7
Posted by ga...@apache.org.
Styling the Permissions area. Fixed some of the BB views. Removed inline styles.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6b55be3a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6b55be3a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6b55be3a
Branch: refs/heads/master
Commit: 6b55be3af8823974f1ac35f65786918290f12de5
Parents: 724b3f2
Author: suelockwood <de...@gmail.com>
Authored: Wed Sep 25 15:32:21 2013 -0400
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Sep 27 11:28:04 2013 +0200
----------------------------------------------------------------------
.../permissions/assets/less/permissions.less | 32 ++++++++++++++++++++
.../app/addons/permissions/templates/item.html | 6 ++--
.../permissions/templates/permissions.html | 2 +-
.../addons/permissions/templates/section.html | 27 +++++++++++------
src/fauxton/app/addons/permissions/views.js | 7 +++--
src/fauxton/assets/less/database.less | 6 ++--
src/fauxton/assets/less/fauxton.less | 1 +
7 files changed, 62 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/app/addons/permissions/assets/less/permissions.less
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/assets/less/permissions.less b/src/fauxton/app/addons/permissions/assets/less/permissions.less
new file mode 100644
index 0000000..5f5a0db
--- /dev/null
+++ b/src/fauxton/app/addons/permissions/assets/less/permissions.less
@@ -0,0 +1,32 @@
+.border-hdr {
+ border-bottom: 1px solid #E3E3E3;
+ margin-bottom: 10px;
+ .help{
+
+ }
+ h3{
+ text-transform: capitalize;
+ margin-bottom: 0;
+ }
+}
+
+
+.permission-items.unstyled{
+ margin-left: 0px;
+ li {
+ padding: 5px;
+ border-bottom: 1px solid #E3E3E3;
+ border-right: 1px solid #E3E3E3;
+ border-left: 3px solid #E3E3E3;
+ &:first-child{
+ border-top: 1px solid #E3E3E3;
+ }
+ &:nth-child(odd){
+ border-left: 3px solid red;
+ }
+ button {
+ float: right;
+ margin-bottom: 6px;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/app/addons/permissions/templates/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/item.html b/src/fauxton/app/addons/permissions/templates/item.html
index aa01d0b..616ffd6 100644
--- a/src/fauxton/app/addons/permissions/templates/item.html
+++ b/src/fauxton/app/addons/permissions/templates/item.html
@@ -11,7 +11,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
-<li>
+
<span> <%= item %> </span>
-<button type="button" style="float:none; margin-bottom:6px" class="close">×</button>
-</li>
+<button type="button" class="close">×</button>
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/app/addons/permissions/templates/permissions.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/permissions.html b/src/fauxton/app/addons/permissions/templates/permissions.html
index d247425..99c9ff5 100644
--- a/src/fauxton/app/addons/permissions/templates/permissions.html
+++ b/src/fauxton/app/addons/permissions/templates/permissions.html
@@ -11,5 +11,5 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
-<p>Each database contains lists of admins and members. Admins and members are each defined by names and roles, which are lists of strings.</p>
+
<div id="sections"> </div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/app/addons/permissions/templates/section.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/section.html b/src/fauxton/app/addons/permissions/templates/section.html
index 102d857..09acbf2 100644
--- a/src/fauxton/app/addons/permissions/templates/section.html
+++ b/src/fauxton/app/addons/permissions/templates/section.html
@@ -11,27 +11,36 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
-<h1> <%= section %> </h1>
+<header class="border-hdr">
+<h3> <%= (section) %> </h3>
<p id="help"> <%= help %> </p>
+</header>
<div class="row">
<div class="span6">
- <h3> Names </h3>
- <ul id="items-names"></ul>
-
+ <header>
+ <h4> Users </h4>
+ <p>Specify users who will have <%= section %> access to this database.</p>
+ </header>
<form class="permission-item-form form-inline">
<input data-section="<%= section %>" data-type="names" type="text" class="item input-small" placeholder="Add Name">
- <input type="submit" class="btn" value="Add Name" >
+ <button type="submit" class="button btn green fonticon-circle-plus">Add Name</button>
</form>
-
+ <ul class="clearfix unstyled permission-items span10" id="<%= (section) %>-items-names">
+ </ul>
</div>
<div class="span6">
- <h3> Roles </h3>
- <ul id="items-roles"></ul>
+ <header>
+ <h4> Roles </h4>
+ <p>All users under the following role(s) will have <%= section %> access.</p>
+ </header>
+
<form class="permission-item-form form-inline">
<input data-section="<%= section %>" data-type="roles" type="text" class="item input-small" placeholder="Add Role">
- <input type="submit" class="btn" value="Add Role" >
+ <button type="submit" class="button btn green fonticon-circle-plus">Add Role</button>
</form>
+ <ul class="unstyled permission-items span10" id="<%= (section) %>-items-roles">
+ </ul>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/app/addons/permissions/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/views.js b/src/fauxton/app/addons/permissions/views.js
index 4c2987b..eb5a378 100644
--- a/src/fauxton/app/addons/permissions/views.js
+++ b/src/fauxton/app/addons/permissions/views.js
@@ -75,7 +75,7 @@ function (app, FauxtonAPI, Permissions ) {
events: {
"submit .permission-item-form": "addItem",
- 'click .close': "removeItem"
+ 'click button.close': "removeItem"
},
beforeRender: function () {
@@ -85,14 +85,14 @@ function (app, FauxtonAPI, Permissions ) {
this.roleViews = [];
_.each(section.names, function (name) {
- var nameView = this.insertView('#items-names', new Permissions.PermissionItem({
+ var nameView = this.insertView('#'+this.section+'-items-names', new Permissions.PermissionItem({
item: name,
}));
this.nameViews.push(nameView);
}, this);
_.each(section.roles, function (role) {
- var roleView = this.insertView('#items-roles', new Permissions.PermissionItem({
+ var roleView = this.insertView('#'+this.section+'-items-roles', new Permissions.PermissionItem({
item: role,
}));
this.roleViews.push(roleView);
@@ -164,6 +164,7 @@ function (app, FauxtonAPI, Permissions ) {
});
Permissions.PermissionItem = FauxtonAPI.View.extend({
+ tagName: "li",
template: "addons/permissions/templates/item",
initialize: function (options) {
this.item = options.item;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/assets/less/database.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/database.less b/src/fauxton/assets/less/database.less
index 4b11427..6f2ae92 100644
--- a/src/fauxton/assets/less/database.less
+++ b/src/fauxton/assets/less/database.less
@@ -193,9 +193,9 @@ table.active-tasks{
width: auto;
}
}
-#tabs {
- height: 40px;
-}
+// #tabs {
+// height: 40px;
+// }
.databases{
a.db-actions,
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6b55be3a/src/fauxton/assets/less/fauxton.less
----------------------------------------------------------------------
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index ddf66f6..42b7836 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -979,3 +979,4 @@ div.spinner {
margin-top: -4px;
}
}
+
[3/3] git commit: updated refs/heads/master to 221ada7
Posted by ga...@apache.org.
Fauxton: add documentation links for permissions
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/221ada71
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/221ada71
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/221ada71
Branch: refs/heads/master
Commit: 221ada71fa29691ff62969769eb15adce0ff566d
Parents: 6b55be3
Author: Garren Smith <ga...@gmail.com>
Authored: Fri Sep 27 11:26:21 2013 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Sep 27 11:28:04 2013 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/permissions/templates/section.html | 2 +-
src/fauxton/app/helpers.js | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/221ada71/src/fauxton/app/addons/permissions/templates/section.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/templates/section.html b/src/fauxton/app/addons/permissions/templates/section.html
index 09acbf2..3360308 100644
--- a/src/fauxton/app/addons/permissions/templates/section.html
+++ b/src/fauxton/app/addons/permissions/templates/section.html
@@ -13,7 +13,7 @@ the License.
-->
<header class="border-hdr">
<h3> <%= (section) %> </h3>
-<p id="help"> <%= help %> </p>
+<p id="help"> <%= help %> <a href="<%=getDocUrl('database_permission')%>" target="_blank"><i class="icon-question-sign"> </i> </a></p>
</header>
<div class="row">
http://git-wip-us.apache.org/repos/asf/couchdb/blob/221ada71/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
index 0cb90ae..d6ea966 100644
--- a/src/fauxton/app/helpers.js
+++ b/src/fauxton/app/helpers.js
@@ -41,7 +41,8 @@ function() {
"view_functions": "http://docs.couchdb.org/en/latest/ddocs.html#view-functions",
"map_functions": "http://docs.couchdb.org/en/latest/ddocs.html#map-functions",
"reduce_functions": "http://docs.couchdb.org/en/latest/ddocs.html#reduce-and-rereduce-functions",
- "api_reference": "http://docs.couchdb.org/en/latest/api-basics.html?highlight=api"
+ "api_reference": "http://docs.couchdb.org/en/latest/api-basics.html?highlight=api",
+ "database_permission": "http://docs.couchdb.org/en/latest/api/database.html#get-db-security"
};
Helpers.getDocUrl = function(doc){