summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/status/deployment/common.rb
blob: 10d9de000bce87c28732e64ff58d4c013981618a (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
module Gitlab
  module Ci
    module Status
      module Deployment
        module Common
          def has_details?
            can?(user, :read_environment, environment) &&
              can?(user, :read_deployment, subject)
          end

          def details_path
            project_job_path(project, deployable)
          end

          def environment_name
            environment.name
          end

          def environment_path
            project_environment_path(project, environment)
          end

          def deployment_path
            project_job_path(project, deployable)
          end

          def external_url
            environment.external_url
          end

          def external_url_formatted
            environment.formatted_external_url
          end

          def stop_url
            if can?(user, :stop_environment, environment)
              stop_project_environment_path(project, environment)
            end
          end

          def metrics_url
            if environment.has_metrics?
              metrics_project_environment_deployment_path(project, environment, subject)
            end
          end

          def metrics_monitoring_url
            # environment_metrics_path(environment)
            metrics_project_environment_path(project, environment)
          end

          def deployed_at
            subject.deployed_at
          end

          def deployed_at_formatted
            subject.formatted_deployment_time
          end

          def environment
            subject.environment
          end

          def project
            subject.project
          end

          def deployable
            subject.deployable
          end

          def has_deployment?
            true
          end
        end
      end
    end
  end
end