Merge branch 'hotfix/21.56.9' into master
[gitter.git] / public / js / views / righttoolbar / repoInfo.js
blobacc6c5a81eb613f648f55421985c3f19a65e16d8
1 'use strict';
3 var repoInfoTemplate = require('./tmpl/repoInfo.hbs');
4 var Marionette = require('backbone.marionette');
5 const { getBackendForRoom } = require('gitter-web-shared/backend-utils');
7 module.exports = Marionette.ItemView.extend({
8   template: repoInfoTemplate,
10   modelEvents: {
11     change: 'render'
12   },
14   initialize: function(options) {
15     this.roomModel = options.roomModel;
16     this.onRoomChange();
18     this.listenTo(this.roomModel, 'change:backend', this.onRoomChange, this);
19   },
21   onRoomChange: function() {
22     const backend = getBackendForRoom(this.roomModel);
24     const shouldShowRepoInfo = backend && backend.type === 'GH_REPO';
25     this.triggerMethod('repoInfo:changeVisible', shouldShowRepoInfo);
26     if (!shouldShowRepoInfo) {
27       this.model.clear();
28       return;
29     }
31     this.model.fetch({
32       data: {
33         type: backend.type,
34         linkPath: backend.linkPath
35       }
36     });
37   }
38 });