Commit 75036954 authored by Filipa Lacerda's avatar Filipa Lacerda Committed by Phil Hughes

Exports a couple of project related code as es6 modules

parent 46a45e65
/* eslint-disable class-methods-use-this, no-unneeded-ternary, quote-props, no-new */ /* eslint-disable class-methods-use-this, no-unneeded-ternary, quote-props, no-new */
/* global ProjectSelect */
import UsersSelect from './users_select'; import UsersSelect from './users_select';
import groupsSelect from './groups_select'; import groupsSelect from './groups_select';
import './project_select'; import projectSelect from './project_select';
class AuditLogs { class AuditLogs {
constructor() { constructor() {
...@@ -11,7 +10,7 @@ class AuditLogs { ...@@ -11,7 +10,7 @@ class AuditLogs {
} }
initFilters() { initFilters() {
new ProjectSelect(); projectSelect();
groupsSelect(); groupsSelect();
new UsersSelect(); new UsersSelect();
......
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
import { s__ } from './locale'; import { s__ } from './locale';
/* global ProjectSelect */ import projectSelect from './project_select';
import IssuableIndex from './issuable_index'; import IssuableIndex from './issuable_index';
/* global Milestone */ /* global Milestone */
import IssuableForm from './issuable_form'; import IssuableForm from './issuable_form';
...@@ -27,8 +27,7 @@ import projectAvatar from './project_avatar'; ...@@ -27,8 +27,7 @@ import projectAvatar from './project_avatar';
/* global CompareAutocomplete */ /* global CompareAutocomplete */
/* global PathLocks */ /* global PathLocks */
/* global ProjectFindFile */ /* global ProjectFindFile */
/* global ProjectNew */ import ProjectNew from './project_new';
/* global ProjectShow */
import projectImport from './project_import'; import projectImport from './project_import';
import Labels from './labels'; import Labels from './labels';
import LabelManager from './label_manager'; import LabelManager from './label_manager';
...@@ -95,6 +94,8 @@ import Members from './members'; ...@@ -95,6 +94,8 @@ import Members from './members';
import memberExpirationDate from './member_expiration_date'; import memberExpirationDate from './member_expiration_date';
import DueDateSelectors from './due_date_select'; import DueDateSelectors from './due_date_select';
import Diff from './diff'; import Diff from './diff';
import ProjectLabelSubscription from './project_label_subscription';
import ProjectVariables from './project_variables';
// EE-only // EE-only
import ApproversSelect from './approvers_select'; import ApproversSelect from './approvers_select';
...@@ -212,7 +213,7 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -212,7 +213,7 @@ import initGroupAnalytics from './init_group_analytics';
initIssuableSidebar(); initIssuableSidebar();
break; break;
case 'dashboard:milestones:index': case 'dashboard:milestones:index':
new ProjectSelect(); projectSelect();
break; break;
case 'projects:milestones:show': case 'projects:milestones:show':
new UserCallout(); new UserCallout();
...@@ -223,7 +224,7 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -223,7 +224,7 @@ import initGroupAnalytics from './init_group_analytics';
break; break;
case 'dashboard:issues': case 'dashboard:issues':
case 'dashboard:merge_requests': case 'dashboard:merge_requests':
new ProjectSelect(); projectSelect();
initLegacyFilters(); initLegacyFilters();
break; break;
case 'groups:issues': case 'groups:issues':
...@@ -232,7 +233,7 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -232,7 +233,7 @@ import initGroupAnalytics from './init_group_analytics';
const filteredSearchManager = new gl.FilteredSearchManager(page === 'groups:issues' ? 'issues' : 'merge_requests'); const filteredSearchManager = new gl.FilteredSearchManager(page === 'groups:issues' ? 'issues' : 'merge_requests');
filteredSearchManager.setup(); filteredSearchManager.setup();
} }
new ProjectSelect(); projectSelect();
break; break;
case 'dashboard:todos:index': case 'dashboard:todos:index':
new Todos(); new Todos();
...@@ -530,7 +531,7 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -530,7 +531,7 @@ import initGroupAnalytics from './init_group_analytics';
if ($el.find('.dropdown-group-label').length) { if ($el.find('.dropdown-group-label').length) {
new GroupLabelSubscription($el); new GroupLabelSubscription($el);
} else { } else {
new gl.ProjectLabelSubscription($el); new ProjectLabelSubscription($el);
} }
}); });
break; break;
...@@ -579,7 +580,7 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -579,7 +580,7 @@ import initGroupAnalytics from './init_group_analytics';
// Initialize expandable settings panels // Initialize expandable settings panels
initSettingsPanels(); initSettingsPanels();
case 'groups:settings:ci_cd:show': case 'groups:settings:ci_cd:show':
new gl.ProjectVariables(); new ProjectVariables();
break; break;
case 'ci:lints:create': case 'ci:lints:create':
case 'ci:lints:show': case 'ci:lints:show':
...@@ -706,7 +707,6 @@ import initGroupAnalytics from './init_group_analytics'; ...@@ -706,7 +707,6 @@ import initGroupAnalytics from './init_group_analytics';
case 'show': case 'show':
new Star(); new Star();
new ProjectNew(); new ProjectNew();
new ProjectShow();
new NotificationsDropdown(); new NotificationsDropdown();
break; break;
case 'wikis': case 'wikis':
......
...@@ -73,11 +73,6 @@ import './pager'; ...@@ -73,11 +73,6 @@ import './pager';
import './preview_markdown'; import './preview_markdown';
import './project_find_file'; import './project_find_file';
import './project_import'; import './project_import';
import './project_label_subscription';
import './project_new';
import './project_select';
import './project_show';
import './project_variables';
import './projects_dropdown'; import './projects_dropdown';
import './projects_list'; import './projects_list';
import './syntax_highlight'; import './syntax_highlight';
......
/* eslint-disable func-names, space-before-function-paren, no-var, consistent-return, no-new, prefer-arrow-callback, no-return-assign, one-var, one-var-declaration-per-line, object-shorthand, no-else-return, newline-per-chained-call, no-shadow, vars-on-top, prefer-template, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, consistent-return, no-new, prefer-arrow-callback, no-return-assign, one-var, one-var-declaration-per-line, object-shorthand, no-else-return, newline-per-chained-call, no-shadow, vars-on-top, prefer-template, max-len */
/* global ProjectSelect */
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import projectSelect from './project_select';
export default class Project { export default class Project {
constructor() { constructor() {
...@@ -58,7 +58,7 @@ export default class Project { ...@@ -58,7 +58,7 @@ export default class Project {
} }
static projectSelectDropdown() { static projectSelectDropdown() {
new ProjectSelect(); projectSelect();
$('.project-item-select').on('click', e => Project.changeProject($(e.currentTarget).val())); $('.project-item-select').on('click', e => Project.changeProject($(e.currentTarget).val()));
} }
......
/* eslint-disable wrap-iife, func-names, space-before-function-paren, object-shorthand, comma-dangle, one-var, one-var-declaration-per-line, no-restricted-syntax, max-len, no-param-reassign */ export default class ProjectLabelSubscription {
constructor(container) {
this.$container = $(container);
this.$buttons = this.$container.find('.js-subscribe-button');
(function(global) { this.$buttons.on('click', this.toggleSubscription.bind(this));
class ProjectLabelSubscription { }
constructor(container) {
this.$container = $(container);
this.$buttons = this.$container.find('.js-subscribe-button');
this.$buttons.on('click', this.toggleSubscription.bind(this));
}
toggleSubscription(event) { toggleSubscription(event) {
event.preventDefault(); event.preventDefault();
const $btn = $(event.currentTarget); const $btn = $(event.currentTarget);
const $span = $btn.find('span'); const $span = $btn.find('span');
const url = $btn.attr('data-url'); const url = $btn.attr('data-url');
const oldStatus = $btn.attr('data-status'); const oldStatus = $btn.attr('data-status');
$btn.addClass('disabled'); $btn.addClass('disabled');
$span.toggleClass('hidden'); $span.toggleClass('hidden');
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: url url,
}).done(() => { }).done(() => {
let newStatus, newAction; let newStatus;
let newAction;
if (oldStatus === 'unsubscribed') { if (oldStatus === 'unsubscribed') {
[newStatus, newAction] = ['subscribed', 'Unsubscribe']; [newStatus, newAction] = ['subscribed', 'Unsubscribe'];
} else { } else {
[newStatus, newAction] = ['unsubscribed', 'Subscribe']; [newStatus, newAction] = ['unsubscribed', 'Subscribe'];
} }
$span.toggleClass('hidden'); $span.toggleClass('hidden');
$btn.removeClass('disabled'); $btn.removeClass('disabled');
this.$buttons.attr('data-status', newStatus); this.$buttons.attr('data-status', newStatus);
this.$buttons.find('> span').text(newAction); this.$buttons.find('> span').text(newAction);
this.$buttons.map((button) => { this.$buttons.map((button) => {
const $button = $(button); const $button = $(button);
if ($button.attr('data-original-title')) { if ($button.attr('data-original-title')) {
$button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle'); $button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle');
} }
return button; return button;
});
}); });
} });
} }
}
global.ProjectLabelSubscription = ProjectLabelSubscription;
})(window.gl || (window.gl = {}));
...@@ -7,164 +7,158 @@ function highlightChanges($elm) { ...@@ -7,164 +7,158 @@ function highlightChanges($elm) {
setTimeout(() => $elm.removeClass('highlight-changes'), 10); setTimeout(() => $elm.removeClass('highlight-changes'), 10);
} }
(function() { export default class ProjectNew {
this.ProjectNew = (function() { constructor() {
function ProjectNew() { this.toggleSettings = this.toggleSettings.bind(this);
this.toggleSettings = this.toggleSettings.bind(this); this.$selects = $('.features select');
this.$selects = $('.features select'); this.$repoSelects = this.$selects.filter('.js-repo-select');
this.$repoSelects = this.$selects.filter('.js-repo-select'); this.$enableApprovers = $('.js-require-approvals-toggle');
this.$enableApprovers = $('.js-require-approvals-toggle'); this.$projectSelects = this.$selects.not('.js-repo-select');
this.$projectSelects = this.$selects.not('.js-repo-select');
$('.project-edit-container').on('ajax:before', (function(_this) {
$('.project-edit-container').on('ajax:before', (function(_this) { return function() {
return function() { $('.project-edit-container').hide();
$('.project-edit-container').hide(); return $('.save-project-loader').show();
return $('.save-project-loader').show(); };
}; })(this));
})(this));
this.initVisibilitySelect();
this.initVisibilitySelect();
this.toggleSettings();
this.toggleSettings(); this.bindEvents();
this.bindEvents(); this.toggleRepoVisibility();
this.toggleRepoVisibility(); }
}
bindEvents () {
ProjectNew.prototype.bindEvents = function() { this.$selects.on('change', () => this.toggleSettings());
this.$selects.on('change', () => this.toggleSettings()); $('#require_approvals').on('change', e => this.toggleApproverSettingsVisibility(e));
$('#require_approvals').on('change', e => this.toggleApproverSettingsVisibility(e)); }
};
initVisibilitySelect() {
ProjectNew.prototype.initVisibilitySelect = function() { const visibilityContainer = document.querySelector('.js-visibility-select');
const visibilityContainer = document.querySelector('.js-visibility-select'); if (!visibilityContainer) return;
if (!visibilityContainer) return; const visibilitySelect = new VisibilitySelect(visibilityContainer);
const visibilitySelect = new VisibilitySelect(visibilityContainer); visibilitySelect.init();
visibilitySelect.init();
const $visibilitySelect = $(visibilityContainer).find('select');
const $visibilitySelect = $(visibilityContainer).find('select'); let projectVisibility = $visibilitySelect.val();
let projectVisibility = $visibilitySelect.val(); const PROJECT_VISIBILITY_PRIVATE = '0';
const PROJECT_VISIBILITY_PRIVATE = '0';
$visibilitySelect.on('change', () => {
$visibilitySelect.on('change', () => { const newProjectVisibility = $visibilitySelect.val();
const newProjectVisibility = $visibilitySelect.val();
if (projectVisibility !== newProjectVisibility) {
if (projectVisibility !== newProjectVisibility) { this.$projectSelects.each((idx, select) => {
this.$projectSelects.each((idx, select) => { const $select = $(select);
const $select = $(select); const $options = $select.find('option');
const $options = $select.find('option'); const values = $.map($options, e => e.value);
const values = $.map($options, e => e.value);
// if switched to "private", limit visibility options
// if switched to "private", limit visibility options if (newProjectVisibility === PROJECT_VISIBILITY_PRIVATE) {
if (newProjectVisibility === PROJECT_VISIBILITY_PRIVATE) { if ($select.val() !== values[0] && $select.val() !== values[1]) {
if ($select.val() !== values[0] && $select.val() !== values[1]) { $select.val(values[1]).trigger('change');
$select.val(values[1]).trigger('change'); highlightChanges($select);
highlightChanges($select);
}
$options.slice(2).disable();
} }
$options.slice(2).disable();
}
// if switched from "private", increase visibility for non-disabled options // if switched from "private", increase visibility for non-disabled options
if (projectVisibility === PROJECT_VISIBILITY_PRIVATE) { if (projectVisibility === PROJECT_VISIBILITY_PRIVATE) {
$options.enable(); $options.enable();
if ($select.val() !== values[0] && $select.val() !== values[values.length - 1]) { if ($select.val() !== values[0] && $select.val() !== values[values.length - 1]) {
$select.val(values[values.length - 1]).trigger('change'); $select.val(values[values.length - 1]).trigger('change');
highlightChanges($select); highlightChanges($select);
}
} }
}); }
});
projectVisibility = newProjectVisibility; projectVisibility = newProjectVisibility;
}
});
};
ProjectNew.prototype.toggleApproverSettingsVisibility = function(e) {
this.$requiredApprovals = $('#project_approvals_before_merge');
const enabled = $(e.target).prop('checked');
const val = enabled ? 1 : 0;
this.$requiredApprovals.val(val);
this.$requiredApprovals.prop('min', val);
$('.nested-settings').toggleClass('hidden', !enabled);
};
ProjectNew.prototype.toggleSettings = function() {
var self = this;
this.$selects.each(function () {
var $select = $(this);
var className = $select.data('field')
.replace(/_/g, '-')
.replace('access-level', 'feature');
self._showOrHide($select, '.' + className);
});
};
ProjectNew.prototype._showOrHide = function(checkElement, container) {
var $container = $(container);
if ($(checkElement).val() !== '0') {
return $container.show();
} else {
return $container.hide();
} }
}; });
}
ProjectNew.prototype.toggleRepoVisibility = function () {
var $repoAccessLevel = $('.js-repo-access-level select'); toggleApproverSettingsVisibility(e) {
var $lfsEnabledOption = $('.js-lfs-enabled select'); this.$requiredApprovals = $('#project_approvals_before_merge');
var containerRegistry = document.querySelectorAll('.js-container-registry')[0]; const enabled = $(e.target).prop('checked');
var containerRegistryCheckbox = document.getElementById('project_container_registry_enabled'); const val = enabled ? 1 : 0;
var prevSelectedVal = parseInt($repoAccessLevel.val(), 10); this.$requiredApprovals.val(val);
this.$requiredApprovals.prop('min', val);
$('.nested-settings').toggleClass('hidden', !enabled);
}
toggleSettings() {
this.$selects.each(function () {
var $select = $(this);
var className = $select.data('field')
.replace(/_/g, '-')
.replace('access-level', 'feature');
ProjectNew._showOrHide($select, '.' + className);
});
}
static _showOrHide(checkElement, container) {
var $container = $(container);
if ($(checkElement).val() !== '0') {
return $container.show();
} else {
return $container.hide();
}
}
this.$repoSelects.find("option[value='" + $repoAccessLevel.val() + "']") toggleRepoVisibility () {
.nextAll() var $repoAccessLevel = $('.js-repo-access-level select');
.hide(); var $lfsEnabledOption = $('.js-lfs-enabled select');
var containerRegistry = document.querySelectorAll('.js-container-registry')[0];
var containerRegistryCheckbox = document.getElementById('project_container_registry_enabled');
var prevSelectedVal = parseInt($repoAccessLevel.val(), 10);
$repoAccessLevel.off('change') this.$repoSelects.find("option[value='" + $repoAccessLevel.val() + "']")
.on('change', function () { .nextAll()
var selectedVal = parseInt($repoAccessLevel.val(), 10); .hide();
this.$repoSelects.each(function () { $repoAccessLevel.off('change')
var $this = $(this); .on('change', function () {
var repoSelectVal = parseInt($this.val(), 10); var selectedVal = parseInt($repoAccessLevel.val(), 10);
$this.find('option').enable(); this.$repoSelects.each(function () {
var $this = $(this);
var repoSelectVal = parseInt($this.val(), 10);
if (selectedVal < repoSelectVal || repoSelectVal === prevSelectedVal) { $this.find('option').enable();
$this.val(selectedVal).trigger('change');
highlightChanges($this);
}
$this.find("option[value='" + selectedVal + "']").nextAll().disable(); if (selectedVal < repoSelectVal || repoSelectVal === prevSelectedVal) {
}); $this.val(selectedVal).trigger('change');
highlightChanges($this);
}
if (selectedVal) { $this.find("option[value='" + selectedVal + "']").nextAll().disable();
this.$repoSelects.removeClass('disabled'); });
if ($lfsEnabledOption.length) { if (selectedVal) {
$lfsEnabledOption.removeClass('disabled'); this.$repoSelects.removeClass('disabled');
highlightChanges($lfsEnabledOption);
}
if (containerRegistry) {
containerRegistry.style.display = '';
}
} else {
this.$repoSelects.addClass('disabled');
if ($lfsEnabledOption.length) { if ($lfsEnabledOption.length) {
$lfsEnabledOption.val('false').addClass('disabled'); $lfsEnabledOption.removeClass('disabled');
highlightChanges($lfsEnabledOption); highlightChanges($lfsEnabledOption);
} }
if (containerRegistry) { if (containerRegistry) {
containerRegistry.style.display = 'none'; containerRegistry.style.display = '';
containerRegistryCheckbox.checked = false;
}
} }
} else {
this.$repoSelects.addClass('disabled');
prevSelectedVal = selectedVal; if ($lfsEnabledOption.length) {
}.bind(this)); $lfsEnabledOption.val('false').addClass('disabled');
}; highlightChanges($lfsEnabledOption);
}
if (containerRegistry) {
containerRegistry.style.display = 'none';
containerRegistryCheckbox.checked = false;
}
}
return ProjectNew; prevSelectedVal = selectedVal;
})(); }.bind(this));
}).call(window); }
}
...@@ -2,79 +2,73 @@ ...@@ -2,79 +2,73 @@
import Api from './api'; import Api from './api';
import ProjectSelectComboButton from './project_select_combo_button'; import ProjectSelectComboButton from './project_select_combo_button';
(function () { export default function projectSelect() {
this.ProjectSelect = (function () { $('.ajax-project-select').each(function(i, select) {
function ProjectSelect() { var placeholder;
$('.ajax-project-select').each(function(i, select) { const simpleFilter = $(select).data('simple-filter') || false;
var placeholder; this.groupId = $(select).data('group-id');
const simpleFilter = $(select).data('simple-filter') || false; this.includeGroups = $(select).data('include-groups');
this.groupId = $(select).data('group-id'); this.allProjects = $(select).data('all-projects') || false;
this.includeGroups = $(select).data('include-groups'); this.orderBy = $(select).data('order-by') || 'id';
this.allProjects = $(select).data('all-projects') || false; this.withIssuesEnabled = $(select).data('with-issues-enabled');
this.orderBy = $(select).data('order-by') || 'id'; this.withMergeRequestsEnabled = $(select).data('with-merge-requests-enabled');
this.withIssuesEnabled = $(select).data('with-issues-enabled');
this.withMergeRequestsEnabled = $(select).data('with-merge-requests-enabled');
placeholder = "Search for project"; placeholder = "Search for project";
if (this.includeGroups) { if (this.includeGroups) {
placeholder += " or group"; placeholder += " or group";
} }
$(select).select2({ $(select).select2({
placeholder: placeholder, placeholder: placeholder,
minimumInputLength: 0, minimumInputLength: 0,
query: (function (_this) { query: (function (_this) {
return function (query) { return function (query) {
var finalCallback, projectsCallback; var finalCallback, projectsCallback;
finalCallback = function (projects) { finalCallback = function (projects) {
var data;
data = {
results: projects
};
return query.callback(data);
};
if (_this.includeGroups) {
projectsCallback = function (projects) {
var groupsCallback;
groupsCallback = function (groups) {
var data; var data;
data = { data = groups.concat(projects);
results: projects return finalCallback(data);
};
return query.callback(data);
}; };
if (_this.includeGroups) { return Api.groups(query.term, {}, groupsCallback);
projectsCallback = function (projects) {
var groupsCallback;
groupsCallback = function (groups) {
var data;
data = groups.concat(projects);
return finalCallback(data);
};
return Api.groups(query.term, {}, groupsCallback);
};
} else {
projectsCallback = finalCallback;
}
if (_this.groupId) {
return Api.groupProjects(_this.groupId, query.term, projectsCallback);
} else {
return Api.projects(query.term, {
order_by: _this.orderBy,
with_issues_enabled: _this.withIssuesEnabled,
with_merge_requests_enabled: _this.withMergeRequestsEnabled,
membership: !_this.allProjects,
}, projectsCallback);
}
}; };
})(this), } else {
id: function(project) { projectsCallback = finalCallback;
if (simpleFilter) return project.id; }
return JSON.stringify({ if (_this.groupId) {
name: project.name, return Api.groupProjects(_this.groupId, query.term, projectsCallback);
url: project.web_url, } else {
}); return Api.projects(query.term, {
}, order_by: _this.orderBy,
text: function (project) { with_issues_enabled: _this.withIssuesEnabled,
return project.name_with_namespace || project.name; with_merge_requests_enabled: _this.withMergeRequestsEnabled,
}, membership: !_this.allProjects,
dropdownCssClass: "ajax-project-dropdown" }, projectsCallback);
}
};
})(this),
id: function(project) {
if (simpleFilter) return project.id;
return JSON.stringify({
name: project.name,
url: project.web_url,
}); });
if (simpleFilter) return select; },
return new ProjectSelectComboButton(select); text: function (project) {
}); return project.name_with_namespace || project.name;
} },
dropdownCssClass: "ajax-project-dropdown"
return ProjectSelect; });
})(); if (simpleFilter) return select;
}).call(window); return new ProjectSelectComboButton(select);
});
}
/* eslint-disable func-names, space-before-function-paren, wrap-iife */
(function() {
this.ProjectShow = (function() {
function ProjectShow() {}
return ProjectShow;
})();
}).call(window);
// I kept class for future
(() => {
const HIDDEN_VALUE_TEXT = '******';
class ProjectVariables { const HIDDEN_VALUE_TEXT = '******';
constructor() {
this.$revealBtn = $('.js-btn-toggle-reveal-values'); export default class ProjectVariables {
this.$revealBtn.on('click', this.toggleRevealState.bind(this)); constructor() {
} this.$revealBtn = $('.js-btn-toggle-reveal-values');
this.$revealBtn.on('click', this.toggleRevealState.bind(this));
}
toggleRevealState(e) { toggleRevealState(e) {
e.preventDefault(); e.preventDefault();
const oldStatus = this.$revealBtn.attr('data-status'); const oldStatus = this.$revealBtn.attr('data-status');
let newStatus = 'hidden'; let newStatus = 'hidden';
let newAction = 'Reveal Values'; let newAction = 'Reveal Values';
if (oldStatus === 'hidden') { if (oldStatus === 'hidden') {
newStatus = 'revealed'; newStatus = 'revealed';
newAction = 'Hide Values'; newAction = 'Hide Values';
} }
this.$revealBtn.attr('data-status', newStatus); this.$revealBtn.attr('data-status', newStatus);
const $variables = $('.variable-value'); const $variables = $('.variable-value');
$variables.each((_, variable) => { $variables.each((_, variable) => {
const $variable = $(variable); const $variable = $(variable);
let newText = HIDDEN_VALUE_TEXT; let newText = HIDDEN_VALUE_TEXT;
if (newStatus === 'revealed') { if (newStatus === 'revealed') {
newText = $variable.attr('data-value'); newText = $variable.attr('data-value');
} }
$variable.text(newText); $variable.text(newText);
}); });
this.$revealBtn.text(newAction); this.$revealBtn.text(newAction);
}
} }
}
window.gl = window.gl || {};
window.gl.ProjectVariables = ProjectVariables;
})();
import '~/project_new'; import ProjectNew from '~/project_new';
describe('ApproversSelect', function () { describe('ApproversSelect', function () {
const projectSettingsTemplate = 'projects/edit.html.raw'; const projectSettingsTemplate = 'projects/edit.html.raw';
...@@ -7,7 +7,7 @@ describe('ApproversSelect', function () { ...@@ -7,7 +7,7 @@ describe('ApproversSelect', function () {
beforeEach(() => { beforeEach(() => {
loadFixtures(projectSettingsTemplate); loadFixtures(projectSettingsTemplate);
this.$requireApprovalsToggle = $('.js-require-approvals-toggle'); this.$requireApprovalsToggle = $('.js-require-approvals-toggle');
this.project = new window.ProjectNew(); this.project = new ProjectNew();
}); });
it('shows approver settings if enabled', () => { it('shows approver settings if enabled', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment