diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 08:27:35 +0000 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/assets/javascripts/groups | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) | |
download | gitlab-ce-7e9c479f7de77702622631cff2628a9c8dcbc627.tar.gz |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/groups')
-rw-r--r-- | app/assets/javascripts/groups/components/app.vue | 58 | ||||
-rw-r--r-- | app/assets/javascripts/groups/components/group_item.vue | 8 | ||||
-rw-r--r-- | app/assets/javascripts/groups/components/item_actions.vue | 40 | ||||
-rw-r--r-- | app/assets/javascripts/groups/constants.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/groups/index.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/groups/members/index.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/groups/new_group_child.js | 65 |
7 files changed, 66 insertions, 121 deletions
diff --git a/app/assets/javascripts/groups/components/app.vue b/app/assets/javascripts/groups/components/app.vue index 871f5c9a845..e057012a246 100644 --- a/app/assets/javascripts/groups/components/app.vue +++ b/app/assets/javascripts/groups/components/app.vue @@ -3,9 +3,8 @@ import $ from 'jquery'; import 'vendor/jquery.scrollTo'; -import { GlLoadingIcon } from '@gitlab/ui'; -import { s__, sprintf } from '~/locale'; -import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue'; +import { GlLoadingIcon, GlModal } from '@gitlab/ui'; +import { __, s__, sprintf } from '~/locale'; import { HIDDEN_CLASS } from '~/lib/utils/constants'; import { getParameterByName } from '~/lib/utils/common_utils'; import { mergeUrlParams } from '~/lib/utils/url_utility'; @@ -16,8 +15,8 @@ import groupsComponent from './groups.vue'; export default { components: { - DeprecatedModal, groupsComponent, + GlModal, GlLoadingIcon, }, props: { @@ -49,13 +48,30 @@ export default { isLoading: true, isSearchEmpty: false, searchEmptyMessage: '', - showModal: false, - groupLeaveConfirmationMessage: '', targetGroup: null, targetParentGroup: null, }; }, computed: { + primaryProps() { + return { + text: __('Leave group'), + attributes: [{ variant: 'warning' }, { category: 'primary' }], + }; + }, + cancelProps() { + return { + text: __('Cancel'), + }; + }, + groupLeaveConfirmationMessage() { + if (!this.targetGroup) { + return ''; + } + return sprintf(s__('GroupsTree|Are you sure you want to leave the "%{fullName}" group?'), { + fullName: this.targetGroup.fullName, + }); + }, groups() { return this.store.getGroups(); }, @@ -171,27 +187,17 @@ export default { } }, showLeaveGroupModal(group, parentGroup) { - const { fullName } = group; this.targetGroup = group; this.targetParentGroup = parentGroup; - this.showModal = true; - this.groupLeaveConfirmationMessage = sprintf( - s__('GroupsTree|Are you sure you want to leave the "%{fullName}" group?'), - { fullName }, - ); - }, - hideLeaveGroupModal() { - this.showModal = false; }, leaveGroup() { - this.showModal = false; this.targetGroup.isBeingRemoved = true; this.service .leaveGroup(this.targetGroup.leavePath) .then(res => { $.scrollTo(0); this.store.removeGroup(this.targetGroup, this.targetParentGroup); - Flash(res.data.notice, 'notice'); + this.$toast.show(res.data.notice); }) .catch(err => { let message = COMMON_STR.FAILURE; @@ -245,21 +251,21 @@ export default { class="loading-animation prepend-top-20" /> <groups-component - v-if="!isLoading" + v-else :groups="groups" :search-empty="isSearchEmpty" :search-empty-message="searchEmptyMessage" :page-info="pageInfo" :action="action" /> - <deprecated-modal - v-show="showModal" - :primary-button-label="__('Leave')" + <gl-modal + modal-id="leave-group-modal" :title="__('Are you sure?')" - :text="groupLeaveConfirmationMessage" - kind="warning" - @cancel="hideLeaveGroupModal" - @submit="leaveGroup" - /> + :action-primary="primaryProps" + :action-cancel="cancelProps" + @primary="leaveGroup" + > + {{ groupLeaveConfirmationMessage }} + </gl-modal> </div> </template> diff --git a/app/assets/javascripts/groups/components/group_item.vue b/app/assets/javascripts/groups/components/group_item.vue index 44349b33386..6e99b6ad4fa 100644 --- a/app/assets/javascripts/groups/components/group_item.vue +++ b/app/assets/javascripts/groups/components/group_item.vue @@ -1,8 +1,7 @@ <script> /* eslint-disable vue/no-v-html */ -import { GlLoadingIcon, GlBadge } from '@gitlab/ui'; +import { GlLoadingIcon, GlBadge, GlTooltipDirective } from '@gitlab/ui'; import { visitUrl } from '../../lib/utils/url_utility'; -import tooltip from '../../vue_shared/directives/tooltip'; import identicon from '../../vue_shared/components/identicon.vue'; import eventHub from '../event_hub'; import { VISIBILITY_TYPE_ICON, GROUP_VISIBILITY_TYPE } from '../constants'; @@ -17,7 +16,7 @@ import { showLearnGitLabGroupItemPopover } from '~/onboarding_issues'; export default { directives: { - tooltip, + GlTooltip: GlTooltipDirective, }, components: { GlBadge, @@ -127,11 +126,10 @@ export default { <div class="group-text flex-grow-1 flex-shrink-1"> <div class="d-flex align-items-center flex-wrap title namespace-title gl-mr-3"> <a - v-tooltip + v-gl-tooltip.bottom :href="group.relativePath" :title="group.fullName" class="no-expand gl-mt-3 gl-mr-3 gl-text-gray-900!" - data-placement="bottom" >{{ // ending bracket must be by closing tag to prevent // link hover text-decoration from over-extending diff --git a/app/assets/javascripts/groups/components/item_actions.vue b/app/assets/javascripts/groups/components/item_actions.vue index 2e92a608f76..ff52f5ef51c 100644 --- a/app/assets/javascripts/groups/components/item_actions.vue +++ b/app/assets/javascripts/groups/components/item_actions.vue @@ -1,15 +1,15 @@ <script> -import { GlIcon } from '@gitlab/ui'; -import tooltip from '~/vue_shared/directives/tooltip'; +import { GlTooltipDirective, GlButton, GlModalDirective } from '@gitlab/ui'; import eventHub from '../event_hub'; import { COMMON_STR } from '../constants'; export default { components: { - GlIcon, + GlButton, }, directives: { - tooltip, + GlTooltip: GlTooltipDirective, + GlModal: GlModalDirective, }, props: { parentGroup: { @@ -45,32 +45,28 @@ export default { <template> <div class="controls d-flex justify-content-end"> - <a + <gl-button v-if="group.canLeave" - v-tooltip - :href="group.leavePath" + v-gl-tooltip.top + v-gl-modal.leave-group-modal :title="leaveBtnTitle" :aria-label="leaveBtnTitle" - data-container="body" - data-placement="bottom" data-testid="leave-group-btn" - class="leave-group btn btn-xs no-expand gl-text-gray-500 gl-ml-5" - @click.prevent="onLeaveGroup" - > - <gl-icon name="leave" class="position-top-0" /> - </a> - <a + size="small" + icon="leave" + class="leave-group gl-ml-3" + @click.stop="onLeaveGroup" + /> + <gl-button v-if="group.canEdit" - v-tooltip + v-gl-tooltip.top :href="group.editPath" :title="editBtnTitle" :aria-label="editBtnTitle" - data-container="body" - data-placement="bottom" data-testid="edit-group-btn" - class="edit-group btn btn-xs no-expand gl-text-gray-500 gl-ml-5" - > - <gl-icon name="settings" class="position-top-0 align-middle" /> - </a> + size="small" + icon="pencil" + class="edit-group gl-ml-3" + /> </div> </template> diff --git a/app/assets/javascripts/groups/constants.js b/app/assets/javascripts/groups/constants.js index c538934a37d..e2722d780dc 100644 --- a/app/assets/javascripts/groups/constants.js +++ b/app/assets/javascripts/groups/constants.js @@ -31,14 +31,16 @@ export const GROUP_VISIBILITY_TYPE = { 'Public - The group and any public projects can be viewed without any authentication.', ), internal: __( - 'Internal - The group and any internal projects can be viewed by any logged in user.', + 'Internal - The group and any internal projects can be viewed by any logged in user except external users.', ), private: __('Private - The group and its projects can only be viewed by members.'), }; export const PROJECT_VISIBILITY_TYPE = { public: __('Public - The project can be accessed without any authentication.'), - internal: __('Internal - The project can be accessed by any logged in user.'), + internal: __( + 'Internal - The project can be accessed by any logged in user except external users.', + ), private: __( 'Private - Project access must be granted explicitly to each user. If this project is part of a group, access will be granted to members of the group.', ), diff --git a/app/assets/javascripts/groups/index.js b/app/assets/javascripts/groups/index.js index 928f1fe409f..522f1d16df2 100644 --- a/app/assets/javascripts/groups/index.js +++ b/app/assets/javascripts/groups/index.js @@ -1,4 +1,6 @@ import Vue from 'vue'; +import { GlToast } from '@gitlab/ui'; +import UserCallout from '~/user_callout'; import { parseBoolean } from '~/lib/utils/common_utils'; import Translate from '../vue_shared/translate'; import GroupFilterableList from './groups_filterable_list'; @@ -16,6 +18,9 @@ export default (containerId = 'js-groups-tree', endpoint, action = '') => { const containerEl = document.getElementById(containerId); let dataEl; + // eslint-disable-next-line no-new + new UserCallout(); + // Don't do anything if element doesn't exist (No groups) // This is for when the user enters directly to the page via URL if (!containerEl) { @@ -31,6 +36,8 @@ export default (containerId = 'js-groups-tree', endpoint, action = '') => { Vue.component('group-folder', groupFolderComponent); Vue.component('group-item', groupItemComponent); + Vue.use(GlToast); + // eslint-disable-next-line no-new new Vue({ el, diff --git a/app/assets/javascripts/groups/members/index.js b/app/assets/javascripts/groups/members/index.js index 3bbef14d199..cb28fb057c9 100644 --- a/app/assets/javascripts/groups/members/index.js +++ b/app/assets/javascripts/groups/members/index.js @@ -5,7 +5,7 @@ import { parseDataAttributes } from 'ee_else_ce/groups/members/utils'; import App from './components/app.vue'; import membersModule from '~/vuex_shared/modules/members'; -export const initGroupMembersApp = (el, tableFields, requestFormatter) => { +export const initGroupMembersApp = (el, tableFields, tableAttrs, requestFormatter) => { if (!el) { return () => {}; } @@ -18,6 +18,7 @@ export const initGroupMembersApp = (el, tableFields, requestFormatter) => { ...parseDataAttributes(el), currentUserId: gon.current_user_id || null, tableFields, + tableAttrs, requestFormatter, }), }); diff --git a/app/assets/javascripts/groups/new_group_child.js b/app/assets/javascripts/groups/new_group_child.js deleted file mode 100644 index bb2aea3ea76..00000000000 --- a/app/assets/javascripts/groups/new_group_child.js +++ /dev/null @@ -1,65 +0,0 @@ -import { visitUrl } from '../lib/utils/url_utility'; -import DropLab from '../droplab/drop_lab'; -import ISetter from '../droplab/plugins/input_setter'; - -const InputSetter = { ...ISetter }; - -const NEW_PROJECT = 'new-project'; -const NEW_SUBGROUP = 'new-subgroup'; - -export default class NewGroupChild { - constructor(buttonWrapper) { - this.buttonWrapper = buttonWrapper; - this.newGroupChildButton = this.buttonWrapper.querySelector('.js-new-group-child'); - this.dropdownToggle = this.buttonWrapper.querySelector('.js-dropdown-toggle'); - this.dropdownList = this.buttonWrapper.querySelector('.dropdown-menu'); - - this.newGroupPath = this.buttonWrapper.dataset.projectPath; - this.subgroupPath = this.buttonWrapper.dataset.subgroupPath; - - this.init(); - } - - init() { - this.initDroplab(); - this.bindEvents(); - } - - initDroplab() { - this.droplab = new DropLab(); - this.droplab.init( - this.dropdownToggle, - this.dropdownList, - [InputSetter], - this.getDroplabConfig(), - ); - } - - getDroplabConfig() { - return { - InputSetter: [ - { - input: this.newGroupChildButton, - valueAttribute: 'data-value', - inputAttribute: 'data-action', - }, - { - input: this.newGroupChildButton, - valueAttribute: 'data-text', - }, - ], - }; - } - - bindEvents() { - this.newGroupChildButton.addEventListener('click', this.onClickNewGroupChildButton.bind(this)); - } - - onClickNewGroupChildButton(e) { - if (e.target.dataset.action === NEW_PROJECT) { - visitUrl(this.newGroupPath); - } else if (e.target.dataset.action === NEW_SUBGROUP) { - visitUrl(this.subgroupPath); - } - } -} |