aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/quality-gate/router.coffee
blob: f21161a97bfc9c7a42ac6fc2efb3108dba404d41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
define [
  'backbone',
  'quality-gate/models/quality-gate',
  'quality-gate/views/quality-gate-detail-view',
  'quality-gate/views/quality-gate-detail-header-view',
], (
  Backbone,
  QualityGate,
  QualityGateDetailView,
  QualityGateDetailHeaderView
) ->

  class QualityGateRouter extends Backbone.Router

    routes:
      'show/:id': 'show'


    initialize: (options) ->
      @app = options.app


    show: (id) ->
      qualityGate = @app.qualityGates.get id
      if qualityGate
        @app.qualityGateSidebarListView.highlight id

        qualityGateDetailHeaderView = new QualityGateDetailHeaderView
          app: @app
          model: qualityGate
        @app.layout.headerRegion.show qualityGateDetailHeaderView

        qualityGateDetailView = new QualityGateDetailView
          app: @app
          model: qualityGate
        @app.layout.detailsRegion.show qualityGateDetailView
        qualityGateDetailView.$el.hide()

        qualityGateDetailHeaderView.showSpinner()
        qualityGate.fetch().done ->
          qualityGateDetailView.$el.show()
          qualityGateDetailHeaderView.hideSpinner()