Gitter migration: Point people to app.gitter.im (rollout pt. 1)
[gitter.git] / public / js / routes / room-routes.js
blob6ac454aa6fcb3218a8b6c6701c50bb522c7d7d10
1 'use strict';
3 var Backbone = require('backbone');
4 var context = require('gitter-web-client-context');
5 var apiClient = require('../components/api-client');
6 var presentPermissionsDialog = require('../ensured/present-permissions-dialog');
7 const presentExportRoomDataDialog = require('../ensured/present-export-room-data-dialog');
9 function showWelcomeMessage() {
10   var dialogRegion = this.dialogRegion;
12   require.ensure(['../views/modals/welcome-message'], function(require) {
13     var WelcomeMessageView = require('../views/modals/welcome-message');
14     dialogRegion.show(new WelcomeMessageView.Modal());
15   });
18 function createRoutes(options) {
19   var rosterCollection = options.rosterCollection;
21   return {
22     autojoin: function() {
23       if (context.roomHasWelcomeMessage()) {
24         showWelcomeMessage.call(this);
25         return;
26       }
28       apiClient.user
29         .post('/rooms', { id: context.troupe().id })
30         .bind(this)
31         .then(function(body) {
32           context.setTroupe(body);
33         });
34     },
36     people: function() {
37       var dialogRegion = this.dialogRegion;
38       require.ensure(['../views/modals/people-modal'], function(require) {
39         var PeopleModal = require('../views/modals/people-modal');
41         dialogRegion.show(
42           new PeopleModal({
43             rosterCollection: rosterCollection
44           })
45         );
46       });
47     },
49     notifications: function() {
50       var dialogRegion = this.dialogRegion;
52       require.ensure(['../views/modals/notification-settings-view'], function(require) {
53         var NotificationSettingsView = require('../views/modals/notification-settings-view');
54         dialogRegion.show(new NotificationSettingsView({ model: new Backbone.Model() }));
55       });
56     },
58     markdown: function() {
59       var dialogRegion = this.dialogRegion;
61       require.ensure(['../views/modals/markdown-view'], function(require) {
62         var MarkdownView = require('../views/modals/markdown-view');
63         dialogRegion.show(new MarkdownView({}));
64       });
65     },
67     keys: function() {
68       var dialogRegion = this.dialogRegion;
70       require.ensure(['../views/modals/keyboard-view'], function(require) {
71         var KeyboardView = require('../views/modals/keyboard-view');
72         dialogRegion.show(new KeyboardView({}));
73       });
74     },
76     add: function() {
77       var dialogRegion = this.dialogRegion;
79       require.ensure(['../views/app/addPeopleView'], function(require) {
80         var AddPeopleViewModal = require('../views/app/addPeopleView');
81         dialogRegion.show(new AddPeopleViewModal({}));
82       });
83     },
85     settings: function() {
86       var dialogRegion = this.dialogRegion;
88       require.ensure(['../views/modals/room-settings-view'], function(require) {
89         var RoomSettingsModal = require('../views/modals/room-settings-view');
90         dialogRegion.show(new RoomSettingsModal({ model: context.troupe() }));
91       });
92     },
94     permissions: function() {
95       presentPermissionsDialog({
96         dialogRegion: this.dialogRegion
97       });
98     },
100     tags: function() {
101       var dialogRegion = this.dialogRegion;
103       require.ensure(['../views/modals/edit-tags-view'], function(require) {
104         var EditTagsView = require('../views/modals/edit-tags-view');
105         dialogRegion.show(new EditTagsView({ roomId: context.troupe().get('id') }));
106       });
107     },
109     integrations: function() {
110       var dialogRegion = this.dialogRegion;
112       if (context.isTroupeAdmin()) {
113         require.ensure(['../views/modals/integration-settings-view'], function(require) {
114           var IntegrationSettingsModal = require('../views/modals/integration-settings-view');
116           dialogRegion.show(new IntegrationSettingsModal({}));
117         });
118       } else {
119         window.location = '#';
120       }
121     },
123     share: function() {
124       var dialogRegion = this.dialogRegion;
126       require.ensure(['../views/modals/share-view'], function(require) {
127         var shareView = require('../views/modals/share-view');
129         dialogRegion.show(new shareView.Modal({}));
130       });
131     },
133     'export-room-data': () => {
134       presentExportRoomDataDialog(context.troupe());
135     },
137     delete: function() {
138       var dialogRegion = this.dialogRegion;
140       require.ensure(['../views/modals/delete-room-view'], function(require) {
141         var DeleteModal = require('../views/modals/delete-room-view');
143         dialogRegion.show(new DeleteModal({}));
144       });
145     },
147     'notification-defaults': function() {
148       var dialogRegion = this.dialogRegion;
150       require.ensure(['../views/modals/notification-defaults-view'], function(require) {
151         var NotificationDefaultsView = require('../views/modals/notification-defaults-view');
153         dialogRegion.show(
154           new NotificationDefaultsView({
155             model: new Backbone.Model()
156           })
157         );
158       });
159     },
161     'welcome-message': showWelcomeMessage
162   };
165 module.exports = createRoutes;