Commit 3987423c authored by Phil Hughes's avatar Phil Hughes Committed by Bob Van Landuyt

Added permissions check to design management

parent 39d2f9bc
......@@ -11,6 +11,10 @@ export default {
type: Boolean,
required: true,
},
canUploadDesign: {
type: Boolean,
required: true,
},
},
methods: {
openFileUpload() {
......@@ -27,6 +31,7 @@ export default {
<header class="row-content-block border-top-0 p-2 d-flex">
<div>
<gl-button
v-if="canUploadDesign"
:disabled="isSaving"
variant="primary"
class="btn-inverted"
......
......@@ -30,6 +30,7 @@ const designsStore = [
const defaultClient = createDefaultClient({
defaults: {
designs: designsStore,
canUploadDesign: true,
},
resolvers: {
Query: {
......
......@@ -6,6 +6,7 @@ import DesignList from '../components/list/index.vue';
import UploadForm from '../components/upload/form.vue';
import allDesignsQuery from '../queries/allDesigns.graphql';
import uploadDesignQuery from '../queries/uploadDesign.graphql';
import canUploadDesignPermission from '../queries/canUploadDesignPermission.graphql';
export default {
components: {
......@@ -20,10 +21,14 @@ export default {
this.error = true;
},
},
canUploadDesign: {
query: canUploadDesignPermission,
},
},
data() {
return {
designs: [],
canUploadDesign: false,
error: false,
isSaving: false,
};
......@@ -35,6 +40,8 @@ export default {
},
methods: {
onUploadDesign(files) {
if (!this.canUploadDesign) return null;
const optimisticResponse = [...files].map(file => ({
__typename: 'Design',
id: -1,
......@@ -80,7 +87,12 @@ export default {
<template>
<div>
<upload-form :is-saving="isSaving" @upload="onUploadDesign" />
<upload-form
v-if="canUploadDesign"
:can-upload-design="canUploadDesign"
:is-saving="isSaving"
@upload="onUploadDesign"
/>
<div class="mt-4">
<gl-loading-icon v-if="isLoading" size="md" />
<div v-else-if="error" class="alert alert-danger">
......
......@@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
initSidebarBundle();
initRelatedIssues();
if (gon.features.versionedDesigns) {
if (document.getElementById('js-design-management')) {
import(/* webpackChunkName: 'design_management' */ 'ee/design_management')
.then(module => module.default())
.catch(() => {});
......
......@@ -16,9 +16,6 @@ module EE
before_action :check_export_issues_available!, only: [:export_csv]
before_action :check_service_desk_available!, only: [:service_desk]
before_action :whitelist_query_limiting_ee, only: [:update]
before_action only: :show do
push_frontend_feature_flag(:versioned_designs)
end
end
override :issue_except_actions
......
......@@ -75,6 +75,7 @@ class License < ApplicationRecord
batch_comments
issues_analytics
merge_pipelines
design_management
]
EEP_FEATURES.freeze
......
- if Feature.enabled?(:versioned_designs)
- if @project.feature_available?(:design_management, current_user) && Feature.enabled?(:design_management)
%ul.nav-tabs.nav.nav-links{ role: 'tablist' }
%li
= link_to '#discussion-tab', class: 'active js-issue-tabs', id: 'discussion', role: 'tab', 'aria-controls': 'js-discussion', 'aria-selected': 'true', data: { toggle: 'tab', target: '#discussion-tab' } do
......
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