Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project_variables.js « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5688ed7ebb39fe84ebbfee0c5bad0eb5f54e01bd (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
const HIDDEN_VALUE_TEXT = '******';

class ProjectVariables {
  constructor() {
    this.$revealBtn = $('.js-btn-toggle-reveal-values');
    this.$revealBtn.on('click', this.toggleRevealState.bind(this));
  }

  toggleRevealState(e) {
    e.preventDefault();

    const oldStatus = this.$revealBtn.attr('data-status');
    let newStatus = 'hidden';
    let newAction = 'Reveal Values';

    if (oldStatus === 'hidden') {
      newStatus = 'revealed';
      newAction = 'Hide Values';
    }

    this.$revealBtn.attr('data-status', newStatus);

    const $variables = $('.variable-value');

    $variables.each((_, variable) => {
      const $variable = $(variable);
      let newText = HIDDEN_VALUE_TEXT;

      if (newStatus === 'revealed') {
        newText = $variable.attr('data-value');
      }

      $variable.text(newText);
    });

    this.$revealBtn.text(newAction);
  }
}

window.gl = window.gl || {};
window.gl.ProjectVariables = ProjectVariables;