Skip to content
代码片段 群组 项目
未验证 提交 19bfe822 编辑于 作者: Ankit Panchal's avatar Ankit Panchal 提交者: GitLab
浏览文件

Merge branch '452518-follow-up-from-create-organization-behind-feature-flag' into 'master'

Check `allow_organization_creation` feature flag on a few more views

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/148347



Merged-by: default avatarAnkit Panchal <apanchal@gitlab.com>
Approved-by: default avatarBojan Marjanovic <bmarjanovic@gitlab.com>
Approved-by: default avatarGeorge Koltsov <gkoltsov@gitlab.com>
Approved-by: default avatarAnkit Panchal <apanchal@gitlab.com>
Reviewed-by: default avatarAnkit Panchal <apanchal@gitlab.com>
Co-authored-by: default avatarPeter Hegman <phegman@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -46,6 +46,9 @@ export default {
showHeader() {
return this.loading || this.organizations.nodes?.length;
},
showNewOrganizationButton() {
return gon.features?.allowOrganizationCreation;
},
loading() {
return this.$apollo.queries.organizations.loading;
},
......@@ -78,7 +81,7 @@ export default {
class="gl-display-flex gl-align-items-center gl-justify-content-space-between gl-mb-5"
>
<h1 class="gl-m-0 gl-font-size-h-display">{{ $options.i18n.pageTitle }}</h1>
<gl-button :href="newOrganizationUrl" variant="confirm">{{
<gl-button v-if="showNewOrganizationButton" :href="newOrganizationUrl" variant="confirm">{{
$options.i18n.newOrganization
}}</gl-button>
</div>
......
......@@ -34,6 +34,24 @@ export default {
nodes() {
return this.organizations.nodes || [];
},
emptyStateProps() {
const baseProps = {
svgHeight: 144,
svgPath: this.organizationsEmptyStateSvgPath,
title: this.$options.i18n.emptyStateTitle,
description: this.$options.i18n.emptyStateDescription,
};
if (gon.features?.allowOrganizationCreation) {
return {
...baseProps,
primaryButtonLink: this.newOrganizationUrl,
primaryButtonText: this.$options.i18n.emptyStateButtonText,
};
}
return baseProps;
},
},
};
</script>
......@@ -47,13 +65,5 @@ export default {
@prev="$emit('prev', $event)"
@next="$emit('next', $event)"
/>
<gl-empty-state
v-else
:svg-height="144"
:svg-path="organizationsEmptyStateSvgPath"
:title="$options.i18n.emptyStateTitle"
:description="$options.i18n.emptyStateDescription"
:primary-button-link="newOrganizationUrl"
:primary-button-text="$options.i18n.emptyStateButtonText"
/>
<gl-empty-state v-else v-bind="emptyStateProps" />
</template>
......@@ -5,6 +5,9 @@ class OrganizationsController < ApplicationController
feature_category :cell
before_action :check_feature_flag!
before_action only: [:index] do
push_frontend_feature_flag(:allow_organization_creation, current_user)
end
def index; end
......
......@@ -21,6 +21,7 @@ def check_feature_flag!
end
def authorize_create_organization!
access_denied! unless Feature.enabled?(:allow_organization_creation, current_user)
access_denied! unless can?(current_user, :create_organization)
end
......
......@@ -47,6 +47,10 @@ describe('AdminOrganizationsIndexApp', () => {
});
};
beforeEach(() => {
gon.features = { allowOrganizationCreation: true };
});
afterEach(() => {
mockApollo = null;
});
......@@ -119,6 +123,17 @@ describe('AdminOrganizationsIndexApp', () => {
});
});
describe('when `allowOrganizationCreation` feature flag is disabled', () => {
beforeEach(() => {
gon.features = { allowOrganizationCreation: false };
createComponent();
return waitForPromises();
});
itDoesNotRenderNewOrganizationButton();
});
describe('when API call is successful and returns no organizations', () => {
beforeEach(async () => {
createComponent(
......
......@@ -24,6 +24,10 @@ describe('OrganizationsView', () => {
const findOrganizationsList = () => wrapper.findComponent(OrganizationsList);
const findGlEmptyState = () => wrapper.findComponent(GlEmptyState);
beforeEach(() => {
gon.features = { allowOrganizationCreation: true };
});
describe.each`
description | loading | orgsData | emptyStateSvg | emptyStateUrl
${'when loading'} | ${true} | ${[]} | ${false} | ${false}
......@@ -55,6 +59,18 @@ describe('OrganizationsView', () => {
});
});
describe('when `allowOrganizationCreation` feature flag is disabled', () => {
beforeEach(() => {
gon.features = { allowOrganizationCreation: false };
createComponent({ loading: false, organizations: { nodes: [], pageInfo: {} } });
});
it('does not render `New organization` button in empty state', () => {
expect(findGlEmptyState().attributes('primarybuttonlink')).toBeUndefined();
expect(findGlEmptyState().attributes('primarybuttontext')).toBeUndefined();
});
});
describe('when `OrganizationsList` emits `next` event', () => {
const endCursor = 'mockEndCursor';
......
......@@ -153,6 +153,17 @@
subject(:gitlab_request) { get new_organization_path }
it_behaves_like 'controller action that requires authentication by any user'
context 'when user is signed in and `allow_organization_creation` feature flag is disabled' do
let_it_be(:user) { create(:user) }
before do
stub_feature_flags(allow_organization_creation: false)
sign_in(user)
end
it_behaves_like 'organization - not found response'
end
end
describe 'GET #index' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册