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