mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-02 07:06:41 +03:00
Omnibox: conditionally show channel create on permissions
Fixes urbit/landscape#386
This commit is contained in:
parent
22da150305
commit
1f251667cb
@ -1,4 +1,5 @@
|
||||
import { cite } from '~/logic/lib/util';
|
||||
import { isChannelAdmin } from '~/logic/lib/group';
|
||||
|
||||
const indexes = new Map([
|
||||
['ships', []],
|
||||
@ -27,13 +28,21 @@ const shipIndex = function(contacts) {
|
||||
return ships;
|
||||
};
|
||||
|
||||
const commandIndex = function (currentGroup) {
|
||||
const commandIndex = function (currentGroup, groups, associations) {
|
||||
// commands are special cased for default suite
|
||||
const commands = [];
|
||||
const group = currentGroup ? groups[currentGroup] : null;
|
||||
const association = currentGroup ? associations?.groups?.[currentGroup] : null;
|
||||
const canAdd =
|
||||
(group && association)
|
||||
? (association.metadata.vip === 'member-metadata' || isChannelAdmin(group, currentGroup))
|
||||
: !currentGroup; // home workspace or hasn't loaded
|
||||
const workspace = currentGroup || '/home';
|
||||
commands.push(result(`Groups: Create`, `/~landscape/new`, 'Groups', null));
|
||||
commands.push(result(`Groups: Join`, `/~landscape/join`, 'Groups', null));
|
||||
commands.push(result(`Channel: Create`, `/~landscape${workspace}/new`, 'Groups', null));
|
||||
if(canAdd) {
|
||||
commands.push(result(`Channel: Create`, `/~landscape${workspace}/new`, 'Groups', null));
|
||||
}
|
||||
|
||||
return commands;
|
||||
};
|
||||
@ -127,7 +136,7 @@ export default function index(contacts, associations, apps, currentGroup, groups
|
||||
});
|
||||
});
|
||||
|
||||
indexes.set('commands', commandIndex(currentGroup));
|
||||
indexes.set('commands', commandIndex(currentGroup, groups, associations));
|
||||
indexes.set('subscriptions', subscriptions);
|
||||
indexes.set('groups', landscape);
|
||||
indexes.set('apps', appIndex(apps));
|
||||
|
Loading…
Reference in New Issue
Block a user