diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-07 15:10:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-07 15:10:47 +0300 |
commit | bf57aa76628654e15c2035e21fb29ab39fdea131 (patch) | |
tree | feb486f23361470e6b3360472b96afc7525d184e /app/assets/javascripts/groups | |
parent | d480c97736a444636eeb05266041a6e51649685d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/groups')
-rw-r--r-- | app/assets/javascripts/groups/groups_list.js | 18 | ||||
-rw-r--r-- | app/assets/javascripts/groups/landing.js | 38 | ||||
-rw-r--r-- | app/assets/javascripts/groups/transfer_edit.js | 11 |
3 files changed, 67 insertions, 0 deletions
diff --git a/app/assets/javascripts/groups/groups_list.js b/app/assets/javascripts/groups/groups_list.js new file mode 100644 index 00000000000..866dd7a61ff --- /dev/null +++ b/app/assets/javascripts/groups/groups_list.js @@ -0,0 +1,18 @@ +import FilterableList from '~/filterable_list'; + +/** + * Makes search request for groups when user types a value in the search input. + * Updates the html content of the page with the received one. + */ +export default class GroupsList { + constructor() { + const form = document.querySelector('form#group-filter-form'); + const filter = document.querySelector('.js-groups-list-filter'); + const holder = document.querySelector('.js-groups-list-holder'); + + if (form && filter && holder) { + const list = new FilterableList(form, filter, holder); + list.initSearch(); + } + } +} diff --git a/app/assets/javascripts/groups/landing.js b/app/assets/javascripts/groups/landing.js new file mode 100644 index 00000000000..bfb4d9ce67b --- /dev/null +++ b/app/assets/javascripts/groups/landing.js @@ -0,0 +1,38 @@ +import Cookies from 'js-cookie'; +import { parseBoolean } from '~/lib/utils/common_utils'; + +class Landing { + constructor(landingElement, dismissButton, cookieName) { + this.landingElement = landingElement; + this.cookieName = cookieName; + this.dismissButton = dismissButton; + this.eventWrapper = {}; + } + + toggle() { + const isDismissed = this.isDismissed(); + + this.landingElement.classList.toggle('hidden', isDismissed); + if (!isDismissed) this.addEvents(); + } + + addEvents() { + this.eventWrapper.dismissLanding = this.dismissLanding.bind(this); + this.dismissButton.addEventListener('click', this.eventWrapper.dismissLanding); + } + + removeEvents() { + this.dismissButton.removeEventListener('click', this.eventWrapper.dismissLanding); + } + + dismissLanding() { + this.landingElement.classList.add('hidden'); + Cookies.set(this.cookieName, 'true', { expires: 365 }); + } + + isDismissed() { + return parseBoolean(Cookies.get(this.cookieName)); + } +} + +export default Landing; diff --git a/app/assets/javascripts/groups/transfer_edit.js b/app/assets/javascripts/groups/transfer_edit.js new file mode 100644 index 00000000000..bb15e11fd4c --- /dev/null +++ b/app/assets/javascripts/groups/transfer_edit.js @@ -0,0 +1,11 @@ +import $ from 'jquery'; + +export default function setupTransferEdit(formSelector, targetSelector) { + const $transferForm = $(formSelector); + const $selectNamespace = $transferForm.find(targetSelector); + + $selectNamespace.on('change', () => { + $transferForm.find(':submit').prop('disabled', !$selectNamespace.val()); + }); + $selectNamespace.trigger('change'); +} |