summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/members.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-16 18:18:33 +0000
commitf64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch)
treea2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /app/assets/javascripts/members.js
parentbfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff)
downloadgitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'app/assets/javascripts/members.js')
-rw-r--r--app/assets/javascripts/members.js111
1 files changed, 0 insertions, 111 deletions
diff --git a/app/assets/javascripts/members.js b/app/assets/javascripts/members.js
deleted file mode 100644
index a8edeaf5176..00000000000
--- a/app/assets/javascripts/members.js
+++ /dev/null
@@ -1,111 +0,0 @@
-import $ from 'jquery';
-import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
-import { disableButtonIfEmptyField } from '~/lib/utils/common_utils';
-import { Rails } from '~/lib/utils/rails_ujs';
-import { __, sprintf } from '~/locale';
-
-export default class Members {
- constructor() {
- this.addListeners();
- this.initGLDropdown();
- }
-
- addListeners() {
- // eslint-disable-next-line @gitlab/no-global-event-off
- $('.js-member-update-control').off('change').on('change', this.formSubmit.bind(this));
- // eslint-disable-next-line @gitlab/no-global-event-off
- $('.js-edit-member-form').off('ajax:success').on('ajax:success', this.formSuccess.bind(this));
- disableButtonIfEmptyField('#user_ids', 'input[name=commit]', 'change');
- }
-
- dropdownClicked(options) {
- options.e.preventDefault();
-
- this.formSubmit(null, options.$el);
- }
-
- // eslint-disable-next-line class-methods-use-this
- dropdownToggleLabel(selected, $el) {
- return $el.text();
- }
-
- // eslint-disable-next-line class-methods-use-this
- dropdownIsSelectable(selected, $el) {
- return !$el.hasClass('is-active');
- }
-
- initGLDropdown() {
- $('.js-member-permissions-dropdown').each((i, btn) => {
- const $btn = $(btn);
-
- initDeprecatedJQueryDropdown($btn, {
- selectable: true,
- isSelectable: (selected, $el) => this.dropdownIsSelectable(selected, $el),
- fieldName: $btn.data('fieldName'),
- id(selected, $el) {
- return $el.data('id');
- },
- toggleLabel: (selected, $el) => this.dropdownToggleLabel(selected, $el, $btn),
- clicked: (options) => this.dropdownClicked(options),
- });
- });
- }
-
- formSubmit(e, $el = null) {
- const $this = e ? $(e.currentTarget) : $el;
- const { $toggle, $dateInput } = this.getMemberListItems($this);
- const formEl = $this.closest('form').get(0);
-
- Rails.fire(formEl, 'submit');
-
- $toggle.disable();
- $dateInput.disable();
- }
-
- formSuccess(e) {
- const { $toggle, $dateInput, $expiresIn, $expiresInText } = this.getMemberListItems(
- $(e.currentTarget).closest('.js-member'),
- );
-
- const [data] = e.detail;
- const expiresIn = data?.expires_in;
-
- if (expiresIn) {
- $expiresIn.removeClass('gl-display-none');
-
- $expiresInText.text(sprintf(__('Expires in %{expires_at}'), { expires_at: expiresIn }));
-
- const { expires_soon: expiresSoon, expires_at_formatted: expiresAtFormatted } = data;
-
- if (expiresSoon) {
- $expiresInText.addClass('text-warning');
- } else {
- $expiresInText.removeClass('text-warning');
- }
-
- // Update tooltip
- if (expiresAtFormatted) {
- $expiresInText.attr('title', expiresAtFormatted);
- $expiresInText.attr('data-original-title', expiresAtFormatted);
- }
- } else {
- $expiresIn.addClass('gl-display-none');
- }
-
- $toggle.enable();
- $dateInput.enable();
- }
-
- // eslint-disable-next-line class-methods-use-this
- getMemberListItems($el) {
- const $memberListItem = $el.is('.js-member') ? $el : $(`#${$el.data('elId')}`);
-
- return {
- $memberListItem,
- $expiresIn: $memberListItem.find('.js-expires-in'),
- $expiresInText: $memberListItem.find('.js-expires-in-text'),
- $toggle: $memberListItem.find('.dropdown-menu-toggle'),
- $dateInput: $memberListItem.find('.js-access-expiration-date'),
- };
- }
-}