From bddd1557b8b9cee9728af5878a5ca7967272d041 Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald <liam@urizen.co> Date: Fri, 2 Oct 2020 16:55:50 +1000 Subject: [PATCH] leap: update for new groups routing --- pkg/interface/src/logic/lib/omnibox.js | 37 ++++++------------- .../apps/groups/components/lib/NewChannel.tsx | 2 +- .../src/views/components/leap/Omnibox.js | 5 ++- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/pkg/interface/src/logic/lib/omnibox.js b/pkg/interface/src/logic/lib/omnibox.js index 94b23f177..11fdf3a1e 100644 --- a/pkg/interface/src/logic/lib/omnibox.js +++ b/pkg/interface/src/logic/lib/omnibox.js @@ -19,29 +19,13 @@ const result = function(title, link, app, host) { }; }; -const commandIndex = function () { +const commandIndex = function (currentGroup) { // commands are special cased for default suite const commands = []; - defaultApps - .filter((e) => { - return e !== 'dojo'; - }) - .map((e) => { - let title = e; - if (e === 'link') { - title = 'Links'; - } - - title = title.charAt(0).toUpperCase() + title.slice(1); - - let obj = result(`${title}: Create`, `/~${e}/new`, e, null); - commands.push(obj); - - if (title === 'Groups') { - obj = result(`${title}: Join Group`, `/~${e}/join`, title, null); - commands.push(obj); - } - }); + const workspace = currentGroup || '/home'; + commands.push(result(`Groups: Create`, `/~groups/new`, 'Groups', null)); + commands.push(result(`Groups: Join`, `/~groups/join`, 'Groups', null)); + commands.push(result(`Channel: Create`, `/~groups${workspace}/new`, 'Groups', null)); return commands; }; @@ -70,6 +54,7 @@ const appIndex = function (apps) { applications.push( result('Groups', '/~groups', 'groups', null) ); + return []; return applications; }; @@ -81,7 +66,7 @@ const otherIndex = function() { return other; }; -export default function index(associations, apps) { +export default function index(associations, apps, currentGroup) { // all metadata from all apps is indexed // into subscriptions and groups const subscriptions = []; @@ -112,16 +97,16 @@ export default function index(associations, apps) { if (app === 'groups') { const obj = result( title, - `/~${app}${each['app-path']}`, + `/~groups${each['app-path']}`, app.charAt(0).toUpperCase() + app.slice(1), cite(shipStart.slice(0, shipStart.indexOf('/'))) ); groups.push(obj); } else { + const app = each.metadata.module || each['app-name']; const obj = result( title, - `/~${each['app-name']}/join${each['app-path']}${ - (each.metadata.module && '/' + each.metadata.module) || ''}`, + `/~groups${each['group-path']}/join/${app}${each['app-path']}`, app.charAt(0).toUpperCase() + app.slice(1), (associations?.contacts?.[each['group-path']]?.metadata?.title || null) ); @@ -130,7 +115,7 @@ export default function index(associations, apps) { }); }); - indexes.set('commands', commandIndex()); + indexes.set('commands', commandIndex(currentGroup)); indexes.set('subscriptions', subscriptions); indexes.set('groups', groups); indexes.set('apps', appIndex(apps)); diff --git a/pkg/interface/src/views/apps/groups/components/lib/NewChannel.tsx b/pkg/interface/src/views/apps/groups/components/lib/NewChannel.tsx index 84f61bcbc..7bf1b373b 100644 --- a/pkg/interface/src/views/apps/groups/components/lib/NewChannel.tsx +++ b/pkg/interface/src/views/apps/groups/components/lib/NewChannel.tsx @@ -130,7 +130,7 @@ export function NewChannel(props: NewChannelProps & RouteComponentProps) { gridTemplateColumns="300px" > <Col gapY="2"> - <Box mb={2}>Channel Type</Box> + <Box color="black" mb={2}>Channel Type</Box> <Radio label="Chat" id="chat" name="type" /> <Radio label="Notebook" id="publish" name="type" /> <Radio label="Collection" id="links" name="type" /> diff --git a/pkg/interface/src/views/components/leap/Omnibox.js b/pkg/interface/src/views/components/leap/Omnibox.js index e428bde73..9ded83269 100644 --- a/pkg/interface/src/views/components/leap/Omnibox.js +++ b/pkg/interface/src/views/components/leap/Omnibox.js @@ -28,7 +28,10 @@ export class Omnibox extends Component { componentDidUpdate(prevProps, prevState) { if (prevProps !== this.props) { - this.setState({ index: index(this.props.associations, this.props.apps.tiles) }); + const { pathname } = this.props.location; + const selectedGroup = pathname.startsWith('/~groups/ship/') ? '/' + pathname.split('/').slice(2,5).join('/') : null; + + this.setState({ index: index(this.props.associations, this.props.apps.tiles, selectedGroup) }); } if (prevProps && (prevProps.apps !== this.props.apps) && (this.state.query === '')) {