leap: update for new groups routing

This commit is contained in:
Liam Fitzgerald 2020-10-02 16:55:50 +10:00
parent aa41b85d4b
commit bddd1557b8
3 changed files with 16 additions and 28 deletions

View File

@ -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 // commands are special cased for default suite
const commands = []; const commands = [];
defaultApps const workspace = currentGroup || '/home';
.filter((e) => { commands.push(result(`Groups: Create`, `/~groups/new`, 'Groups', null));
return e !== 'dojo'; commands.push(result(`Groups: Join`, `/~groups/join`, 'Groups', null));
}) commands.push(result(`Channel: Create`, `/~groups${workspace}/new`, 'Groups', null));
.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);
}
});
return commands; return commands;
}; };
@ -70,6 +54,7 @@ const appIndex = function (apps) {
applications.push( applications.push(
result('Groups', '/~groups', 'groups', null) result('Groups', '/~groups', 'groups', null)
); );
return [];
return applications; return applications;
}; };
@ -81,7 +66,7 @@ const otherIndex = function() {
return other; return other;
}; };
export default function index(associations, apps) { export default function index(associations, apps, currentGroup) {
// all metadata from all apps is indexed // all metadata from all apps is indexed
// into subscriptions and groups // into subscriptions and groups
const subscriptions = []; const subscriptions = [];
@ -112,16 +97,16 @@ export default function index(associations, apps) {
if (app === 'groups') { if (app === 'groups') {
const obj = result( const obj = result(
title, title,
`/~${app}${each['app-path']}`, `/~groups${each['app-path']}`,
app.charAt(0).toUpperCase() + app.slice(1), app.charAt(0).toUpperCase() + app.slice(1),
cite(shipStart.slice(0, shipStart.indexOf('/'))) cite(shipStart.slice(0, shipStart.indexOf('/')))
); );
groups.push(obj); groups.push(obj);
} else { } else {
const app = each.metadata.module || each['app-name'];
const obj = result( const obj = result(
title, title,
`/~${each['app-name']}/join${each['app-path']}${ `/~groups${each['group-path']}/join/${app}${each['app-path']}`,
(each.metadata.module && '/' + each.metadata.module) || ''}`,
app.charAt(0).toUpperCase() + app.slice(1), app.charAt(0).toUpperCase() + app.slice(1),
(associations?.contacts?.[each['group-path']]?.metadata?.title || null) (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('subscriptions', subscriptions);
indexes.set('groups', groups); indexes.set('groups', groups);
indexes.set('apps', appIndex(apps)); indexes.set('apps', appIndex(apps));

View File

@ -130,7 +130,7 @@ export function NewChannel(props: NewChannelProps & RouteComponentProps) {
gridTemplateColumns="300px" gridTemplateColumns="300px"
> >
<Col gapY="2"> <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="Chat" id="chat" name="type" />
<Radio label="Notebook" id="publish" name="type" /> <Radio label="Notebook" id="publish" name="type" />
<Radio label="Collection" id="links" name="type" /> <Radio label="Collection" id="links" name="type" />

View File

@ -28,7 +28,10 @@ export class Omnibox extends Component {
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (prevProps !== this.props) { 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 === '')) { if (prevProps && (prevProps.apps !== this.props.apps) && (this.state.query === '')) {