The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/client/routes.js

183 lines
4.3 KiB

import mem from 'mem';
import s from 'underscore.string';
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Session } from 'meteor/session';
import toastr from 'toastr';
import { KonchatNotification } from '../app/ui';
import { ChatSubscription } from '../app/models';
import { roomTypes, handleError } from '../app/utils';
import { call } from '../app/ui-utils';
import { renderRouteComponent } from './reactAdapters';
const getRoomById = mem((rid) => call('getRoomById', rid));
FlowRouter.goToRoomById = async (rid) => {
if (!rid) {
return;
}
const subscription = ChatSubscription.findOne({ rid });
if (subscription) {
return roomTypes.openRouteLink(subscription.t, subscription, FlowRouter.current().queryParams);
}
const room = await getRoomById(rid);
return roomTypes.openRouteLink(room.t, room, FlowRouter.current().queryParams);
};
BlazeLayout.setRoot('body');
FlowRouter.wait();
FlowRouter.route('/', {
name: 'index',
action() {
BlazeLayout.render('main', { center: 'loading' });
if (!Meteor.userId()) {
return FlowRouter.go('home');
}
Tracker.autorun(function(c) {
if (FlowRouter.subsReady() === true) {
Meteor.defer(function() {
9 years ago
if (Meteor.user() && Meteor.user().defaultRoom) {
const room = Meteor.user().defaultRoom.split('/');
FlowRouter.go(room[0], { name: room[1] }, FlowRouter.current().queryParams);
} else {
FlowRouter.go('home');
}
});
c.stop();
}
});
},
});
FlowRouter.route('/login', {
name: 'login',
action() {
FlowRouter.go('home');
},
});
FlowRouter.route('/home', {
name: 'home',
action(params, queryParams) {
KonchatNotification.getDesktopPermission();
if (queryParams.saml_idp_credentialToken !== undefined) {
Accounts.callLoginMethod({
methodArguments: [{
saml: true,
credentialToken: queryParams.saml_idp_credentialToken,
}],
userCallback(error) {
if (error) {
if (error.reason) {
toastr.error(error.reason);
} else {
handleError(error);
}
}
BlazeLayout.render('main', { center: 'home' });
},
});
} else {
BlazeLayout.render('main', { center: 'home' });
}
},
});
FlowRouter.route('/directory/:tab?', {
name: 'directory',
action: () => {
renderRouteComponent(() => import('../app/ui/client/views/app/components/Directory'), { template: 'main', region: 'center' });
8 years ago
},
triggersExit: [function() {
$('.main-content').addClass('rc-old');
}],
});
FlowRouter.route('/account/:group?', {
name: 'account',
action: (params) => {
if (!params.group) {
params.group = 'Profile';
}
params.group = s.capitalize(params.group, true);
BlazeLayout.render('main', { center: `account${ params.group }` });
},
triggersExit: [function() {
$('.main-content').addClass('rc-old');
}],
});
FlowRouter.route('/terms-of-service', {
name: 'terms-of-service',
action: () => {
Session.set('cmsPage', 'Layout_Terms_of_Service');
BlazeLayout.render('cmsPage');
},
});
FlowRouter.route('/privacy-policy', {
name: 'privacy-policy',
action: () => {
Session.set('cmsPage', 'Layout_Privacy_Policy');
BlazeLayout.render('cmsPage');
},
});
FlowRouter.route('/legal-notice', {
name: 'legal-notice',
action: () => {
Session.set('cmsPage', 'Layout_Legal_Notice');
BlazeLayout.render('cmsPage');
},
});
FlowRouter.route('/room-not-found/:type/:name', {
name: 'room-not-found',
action: ({ type, name }) => {
Session.set('roomNotFound', { type, name });
BlazeLayout.render('main', { center: 'roomNotFound' });
},
});
FlowRouter.route('/register/:hash', {
name: 'register-secret-url',
action: () => {
BlazeLayout.render('secretURL');
},
});
FlowRouter.route('/invite/:hash', {
name: 'invite',
action: () => {
BlazeLayout.render('invite');
},
});
FlowRouter.route('/setup-wizard/:step?', {
[NEW] Setup Wizard (#10523) * welcome * . * stylelint * new ilustration * new layout * . * implements dicts * added all setup wizard settings to wizard * fix some setup wizard css * fix setup wizard js linter errors * remove old setup wizard templaates * setup wizard has just one main tag now * setup wizard registration fields filter is more readable * add register server page to setup wizard * fix setup wizard progress bar on RTL * setup wizard is registering users * Add setup wizard tests, routes and fix batch * fix setup wizard tests * add api test back * comment rocketchat:google-natural-language package and remove logs * add some translation keys for setup wizard * remove old setup wizard template * fix sort code on setup wizard * fix getWizardSetting method * new migration for setupwizard * setup wizard setting migration * fix setupwizard migration * Update versions * fix some setup wizard code logic * fix setup wizard registerServer setting * rever package-lock.json * rever google-natural-language .npm folder * rever meteor packages file and add setup wizard * remove some default values from setup wizard settings * add advocacy option on setup wizard industry setting * change key name to setting to make the filter more readable on setup wizard * change key name to setting to make the filter more readable on setup wizard * add findWizardSettings on models Settings and handle errors of getWizardSettings method * change setting to key to make the filter more readable on setup wizard * fix setup wizard settings filter map * remove serverHasAdminUser method on setup wizard * fix setup wizard tests * fix setup wizard final step workspace link * fix setup wizard tests
8 years ago
name: 'setup-wizard',
action: () => {
renderRouteComponent(() => import('./components/setupWizard/SetupWizardRoute'));
},
[NEW] Setup Wizard (#10523) * welcome * . * stylelint * new ilustration * new layout * . * implements dicts * added all setup wizard settings to wizard * fix some setup wizard css * fix setup wizard js linter errors * remove old setup wizard templaates * setup wizard has just one main tag now * setup wizard registration fields filter is more readable * add register server page to setup wizard * fix setup wizard progress bar on RTL * setup wizard is registering users * Add setup wizard tests, routes and fix batch * fix setup wizard tests * add api test back * comment rocketchat:google-natural-language package and remove logs * add some translation keys for setup wizard * remove old setup wizard template * fix sort code on setup wizard * fix getWizardSetting method * new migration for setupwizard * setup wizard setting migration * fix setupwizard migration * Update versions * fix some setup wizard code logic * fix setup wizard registerServer setting * rever package-lock.json * rever google-natural-language .npm folder * rever meteor packages file and add setup wizard * remove some default values from setup wizard settings * add advocacy option on setup wizard industry setting * change key name to setting to make the filter more readable on setup wizard * change key name to setting to make the filter more readable on setup wizard * add findWizardSettings on models Settings and handle errors of getWizardSettings method * change setting to key to make the filter more readable on setup wizard * fix setup wizard settings filter map * remove serverHasAdminUser method on setup wizard * fix setup wizard tests * fix setup wizard final step workspace link * fix setup wizard tests
8 years ago
});
FlowRouter.notFound = {
action: () => {
renderRouteComponent(() => import('./components/pageNotFound/PageNotFound'));
},
};
Meteor.startup(() => {
FlowRouter.initialize();
});