Skip to content

Commit

Permalink
Merge pull request RocketChat#275 from assistify/feature/RocketChat#209
Browse files Browse the repository at this point in the history
…-enable-guest-to-create-requests

Enable guest user to create requests
  • Loading branch information
mrsimpson authored Mar 19, 2018
2 parents 4bdc997 + 98e9d2c commit 22719d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/rocketchat-ui-sidenav/client/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const getFromServerDebounced = _.debounce(getFromServer, 500);

Template.toolbar.helpers({
canCreate() {
return RocketChat.authz.hasAtLeastOnePermission(['create-c', 'create-p']);
return RocketChat.authz.hasAtLeastOnePermission(RocketChat.roomTypes.roomTypesOrder.map((type) => `create-${ type.identifier }`));
},
results() {
return Template.instance().resultsList.get();
Expand Down Expand Up @@ -231,7 +231,7 @@ Template.toolbar.events({
},

'click [role="search"] button, touchend [role="search"] button'(e) {
if (RocketChat.authz.hasAtLeastOnePermission(['create-c', 'create-p'])) {
if (RocketChat.authz.hasAtLeastOnePermission(RocketChat.roomTypes.roomTypesOrder.map((type) => `create-${ type.identifier }`))) {
// TODO: resolve this name menu/sidebar/sidebav/flex...
menu.close();
FlowRouter.go('create-channel');
Expand Down
16 changes: 12 additions & 4 deletions packages/rocketchat-ui/client/views/app/createRooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ const roomTypesAfterStandard = function() {
).filter((roomType) => roomType.creationTemplate && roomType.canBeCreated());
};

const allTemplatesOrdered = function() {
return roomTypesBeforeStandard()
.concat([{
const standardRoomType = function() {
if (RocketChat.authz.hasAtLeastOnePermission(['create-c', 'create-p'])) {
return [{
creationLabel: 'Create_A_New_Channel',
creationTemplate: 'createChannel'
}])
}];
} else {
return [];
}
};

const allTemplatesOrdered = function() {
return roomTypesBeforeStandard()
.concat(standardRoomType())
.concat(roomTypesAfterStandard())
.map((roomtype) => {
return {
Expand Down

0 comments on commit 22719d4

Please sign in to comment.