Commit 81482ff7 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Render alert in haml

Returns the paid group alert to haml but keeps
the `is_paid_group` data-* attribute.

Address minor review comments
parent 7165629a
<script> <script>
import { GlAlert, GlFormGroup, GlLink, GlSprintf } from '@gitlab/ui'; import { GlFormGroup } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
import ConfirmDanger from '~/vue_shared/components/confirm_danger/confirm_danger.vue'; import ConfirmDanger from '~/vue_shared/components/confirm_danger/confirm_danger.vue';
import NamespaceSelect from '~/vue_shared/components/namespace_select/namespace_select.vue'; import NamespaceSelect from '~/vue_shared/components/namespace_select/namespace_select.vue';
export const i18n = { export const i18n = {
confirmationMessage: __(
'You are going to transfer %{group_name} to another namespace. Are you ABSOLUTELY sure?',
),
emptyNamespaceTitle: __('No parent group'), emptyNamespaceTitle: __('No parent group'),
dropdownTitle: s__('GroupSettings|Select parent group'), dropdownTitle: s__('GroupSettings|Select parent group'),
paidGroupMessage: s__(
"GroupSettings|This group can't be transferred because it is linked to a subscription. To transfer this group, %{linkStart}link the subscription%{linkEnd} with a different group.",
),
}; };
export default { export default {
name: 'TransferGroupForm', name: 'TransferGroupForm',
components: { components: {
ConfirmDanger, ConfirmDanger,
GlAlert,
GlFormGroup, GlFormGroup,
GlLink,
GlSprintf,
NamespaceSelect, NamespaceSelect,
}, },
props: { props: {
...@@ -31,10 +28,6 @@ export default { ...@@ -31,10 +28,6 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
paidGroupHelpLink: {
type: String,
required: true,
},
confirmationPhrase: { confirmationPhrase: {
type: String, type: String,
required: true, required: true,
...@@ -78,13 +71,6 @@ export default { ...@@ -78,13 +71,6 @@ export default {
/> />
<input type="hidden" name="new_parent_group_id" :value="selectedId" /> <input type="hidden" name="new_parent_group_id" :value="selectedId" />
</gl-form-group> </gl-form-group>
<gl-alert v-if="isPaidGroup" class="gl-mb-5" variant="warning" :dismissible="false">
<gl-sprintf :message="$options.i18n.paidGroupMessage">
<template #link="{ content }">
<gl-link :href="paidGroupHelpLink">{{ content }}</gl-link>
</template>
</gl-sprintf>
</gl-alert>
<confirm-danger <confirm-danger
button-class="qa-transfer-button" button-class="qa-transfer-button"
:disabled="disableSubmitButton" :disabled="disableSubmitButton"
......
import Vue from 'vue'; import Vue from 'vue';
import { sprintf } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import TransferGroupForm from './components/transfer_group_form.vue'; import TransferGroupForm, { i18n } from './components/transfer_group_form.vue';
const prepareGroups = (rawGroups) => { const prepareGroups = (rawGroups) => {
const group = JSON.parse(rawGroups).map(({ id, text: humanName }) => ({ const group = JSON.parse(rawGroups).map(({ id, text: humanName }) => ({
...@@ -20,26 +21,23 @@ export default () => { ...@@ -20,26 +21,23 @@ export default () => {
const { const {
targetFormId = null, targetFormId = null,
buttonText: confirmButtonText = '', buttonText: confirmButtonText = '',
phrase: confirmationPhrase = '', groupName = '',
confirmDangerMessage = '',
parentGroups = [], parentGroups = [],
isPaidGroup, isPaidGroup,
paidGroupHelpLink,
} = el.dataset; } = el.dataset;
return new Vue({ return new Vue({
el, el,
provide: { provide: {
confirmDangerMessage, confirmDangerMessage: sprintf(i18n.confirmationMessage, { groupName }),
}, },
render(createElement) { render(createElement) {
return createElement(TransferGroupForm, { return createElement(TransferGroupForm, {
props: { props: {
parentGroups: prepareGroups(parentGroups), parentGroups: prepareGroups(parentGroups),
isPaidGroup: parseBoolean(isPaidGroup), isPaidGroup: parseBoolean(isPaidGroup),
paidGroupHelpLink,
confirmButtonText, confirmButtonText,
confirmationPhrase, confirmationPhrase: groupName,
}, },
on: { on: {
confirm: () => { confirm: () => {
......
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
defaultText: { defaultText: {
type: String, type: String,
required: false, required: false,
default: null, default: i18n.DEFAULT_TEXT,
}, },
includeHeaders: { includeHeaders: {
type: Boolean, type: Boolean,
...@@ -51,7 +51,7 @@ export default { ...@@ -51,7 +51,7 @@ export default {
emptyNamespaceTitle: { emptyNamespaceTitle: {
type: String, type: String,
required: false, required: false,
default: null, default: i18n.DEFAULT_EMPTY_NAMESPACE_TEXT,
}, },
includeEmptyNamespace: { includeEmptyNamespace: {
type: Boolean, type: Boolean,
...@@ -66,12 +66,6 @@ export default { ...@@ -66,12 +66,6 @@ export default {
}; };
}, },
computed: { computed: {
defaultTextDisplay() {
return this.defaultText || this.$options.i18n.DEFAULT_TEXT;
},
emptyNamespace() {
return this.emptyNamespaceTitle || this.$options.i18n.DEFAULT_EMPTY_NAMESPACE_TEXT;
},
hasUserNamespaces() { hasUserNamespaces() {
return this.data.user?.length; return this.data.user?.length;
}, },
...@@ -87,7 +81,7 @@ export default { ...@@ -87,7 +81,7 @@ export default {
return filterByName(this.data.user, this.searchTerm); return filterByName(this.data.user, this.searchTerm);
}, },
selectedNamespaceText() { selectedNamespaceText() {
return this.selectedNamespace?.humanName || this.defaultTextDisplay; return this.selectedNamespace?.humanName || this.defaultText;
}, },
}, },
methods: { methods: {
...@@ -96,7 +90,7 @@ export default { ...@@ -96,7 +90,7 @@ export default {
this.$emit('select', item); this.$emit('select', item);
}, },
handleSelectEmptyNamespace() { handleSelectEmptyNamespace() {
this.handleSelect({ id: EMPTY_NAMESPACE_ID, humanName: this.emptyNamespace }); this.handleSelect({ id: EMPTY_NAMESPACE_ID, humanName: this.emptyNamespaceTitle });
}, },
}, },
i18n, i18n,
...@@ -112,7 +106,7 @@ export default { ...@@ -112,7 +106,7 @@ export default {
data-qa-selector="namespaces_list_item" data-qa-selector="namespaces_list_item"
@click="handleSelectEmptyNamespace()" @click="handleSelectEmptyNamespace()"
> >
{{ emptyNamespace }} {{ emptyNamespaceTitle }}
</gl-dropdown-item> </gl-dropdown-item>
<gl-dropdown-divider /> <gl-dropdown-divider />
</div> </div>
......
...@@ -90,11 +90,6 @@ module GroupsHelper ...@@ -90,11 +90,6 @@ module GroupsHelper
{ group_name: group.name } { group_name: group.name }
end end
def transfer_group_message(group)
_("You are going to transfer %{group_name} to another namespace. Are you ABSOLUTELY sure?") %
{ group_name: group.name }
end
def share_with_group_lock_help_text(group) def share_with_group_lock_help_text(group)
return default_help unless group.parent&.share_with_group_lock? return default_help unless group.parent&.share_with_group_lock?
......
- form_id = "transfer-group-form" - form_id = "transfer-group-form"
- initial_data = { button_text: s_('GroupSettings|Transfer group'), confirm_danger_message: transfer_group_message(@group), phrase: @group.name, target_form_id: form_id, qa_selector: "transfer_group_button", parent_groups: parent_group_options(group), is_paid_group: group.paid?.to_s, paid_group_help_link: help_page_path('subscriptions/index', anchor: 'change-the-linked-namespace') } - initial_data = { button_text: s_('GroupSettings|Transfer group'), group_name: @group.name, target_form_id: form_id, parent_groups: parent_group_options(group), is_paid_group: group.paid?.to_s }
.sub-section .sub-section
%h4.warning-title= s_('GroupSettings|Transfer group') %h4.warning-title= s_('GroupSettings|Transfer group')
...@@ -12,4 +12,9 @@ ...@@ -12,4 +12,9 @@
%li= s_('GroupSettings|You can only transfer the group to a group you manage.') %li= s_('GroupSettings|You can only transfer the group to a group you manage.')
%li= s_('GroupSettings|You will need to update your local repositories to point to the new location.') %li= s_('GroupSettings|You will need to update your local repositories to point to the new location.')
%li= s_("GroupSettings|If the parent group's visibility is lower than the group current visibility, visibility levels for subgroups and projects will be changed to match the new parent group's visibility.") %li= s_("GroupSettings|If the parent group's visibility is lower than the group current visibility, visibility levels for subgroups and projects will be changed to match the new parent group's visibility.")
- if group.paid?
.gl-alert.gl-alert-info.gl-mb-5
= sprite_icon('information-o', size: 16, css_class: 'gl-icon gl-alert-icon gl-alert-icon-no-title')
.gl-alert-body
= html_escape(_("This group can't be transfered because it is linked to a subscription. To transfer this group, %{linkStart}link the subscription%{linkEnd} with a different group.")) % { linkStart: "<a href=\"#{help_page_path('subscriptions/index', anchor: 'change-the-linked-namespace')}\">".html_safe, linkEnd: '</a>'.html_safe }
.js-transfer-group-form{ data: initial_data } .js-transfer-group-form{ data: initial_data }
...@@ -56,14 +56,14 @@ describe('Transfer group form', () => { ...@@ -56,14 +56,14 @@ describe('Transfer group form', () => {
}); });
it('sets the namespace select properties', () => { it('sets the namespace select properties', () => {
const attrs = findNamespaceSelect().attributes(); expect(findNamespaceSelect().props()).toMatchObject({
expect(attrs).toMatchObject({ defaultText: 'Select parent group',
defaulttext: 'Select parent group', fullWidth: false,
emptynamespacetitle: 'No parent group', includeHeaders: false,
includeemptynamespace: 'true', emptyNamespaceTitle: 'No parent group',
includeEmptyNamespace: true,
data: { groups },
}); });
expect(findNamespaceSelect().props('data')).toEqual({ groups });
}); });
it('renders the hidden input field', () => { it('renders the hidden input field', () => {
......
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