Commit 4b730f2b authored by Simon Knox's avatar Simon Knox

add readonly check of !canAdminBoard is false

parent 7d293b9f
...@@ -148,12 +148,19 @@ $(() => { ...@@ -148,12 +148,19 @@ $(() => {
gl.boardConfigToggle = new Vue({ gl.boardConfigToggle = new Vue({
el: document.querySelector('.js-board-config'), el: document.querySelector('.js-board-config'),
data() {
return {
canAdminList: convertPermissionToBoolean(
this.$options.el.dataset.canAdminList,
),
};
},
methods: { methods: {
showPage: page => gl.issueBoards.BoardsStore.showPage(page), showPage: page => gl.issueBoards.BoardsStore.showPage(page),
}, },
computed: { computed: {
buttonText() { buttonText() {
return Math.random > 0.5 ? 'Edit board' : 'View scope'; return this.canAdminList ? 'Edit board' : 'View scope';
}, },
}, },
template: ` template: `
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
v-show="currentPage" v-show="currentPage"
:title="title" :title="title"
:primaryButtonLabel="buttonText" :primaryButtonLabel="buttonText"
:kind="buttonKind"
@toggle="cancel" @toggle="cancel"
@submit="submit" @submit="submit"
> >
...@@ -13,7 +14,10 @@ ...@@ -13,7 +14,10 @@
<form <form
v-else v-else
> >
<div class="append-bottom-20"> <div
v-if="!readonly"
class="append-bottom-20"
>
<label class="label-light" for="board-new-name"> <label class="label-light" for="board-new-name">
Board name Board name
</label> </label>
...@@ -24,19 +28,23 @@ ...@@ -24,19 +28,23 @@
v-model="board.name" v-model="board.name"
> >
</div> </div>
<div class="media append-bottom-10"> <div
v-if="canAdminBoard"
class="media append-bottom-10"
>
<label class="label-light media-body"> <label class="label-light media-body">
Board scope Board scope
</label> </label>
<button <button
type="button" type="button"
class="btn" class="btn"
@click="expand = !expand" @click="expanded = !expanded"
v-if="collapseScope"
> >
Expand {{ expandButtonText }}
</button> </button>
</div> </div>
<div v-if="expand"> <div v-if="!collapseScope || expanded">
<p class="light append-bottom-10"> <p class="light append-bottom-10">
Board scope affects which issues are displayed for anyone who visits this board Board scope affects which issues are displayed for anyone who visits this board
</p> </p>
...@@ -45,6 +53,7 @@ ...@@ -45,6 +53,7 @@
<form-block <form-block
title="Milestone" title="Milestone"
defaultText="Any milestone" defaultText="Any milestone"
:canEdit="canAdminBoard"
> >
<input <input
type="hidden" type="hidden"
...@@ -61,31 +70,39 @@ ...@@ -61,31 +70,39 @@
<form-block <form-block
title="Labels" title="Labels"
defaultText="Any label" defaultText="Any label"
:canEdit="canAdminBoard"
> >
</form-block> </form-block>
<form-block <form-block
title="Assignee" title="Assignee"
defaultText="Any assignee" defaultText="Any assignee"
:fieldName="'filter[assignee]'" :fieldName="'board_filter[assignee]'"
:canEdit="canAdminBoard"
> >
</form-block> </form-block>
<form-block <form-block
title="Author" title="Author"
defaultText="Any author" defaultText="Any author"
:fieldName="'filter[author]'" :fieldName="'board_filter[author]'"
:canEdit="canAdminBoard"
> >
</form-block> </form-block>
<form-block <form-block
title="Weight" title="Weight"
defaultText="Any weight" defaultText="Any weight"
:fieldName="'filter[weight]'" :fieldName="'board_filter[weight]'"
:canEdit="canAdminBoard"
> >
</form-block> </form-block>
</div> </div>
</form> </form>
<div
slot="footer"
v-if="readonly"
></div>
</popup-dialog> </popup-dialog>
</template> </template>
...@@ -108,6 +125,10 @@ export default Vue.extend({ ...@@ -108,6 +125,10 @@ export default Vue.extend({
type: String, type: String,
required: true, required: true,
}, },
canAdminBoard: {
type: Boolean,
required: true,
},
}, },
data() { data() {
return { return {
...@@ -115,7 +136,7 @@ export default Vue.extend({ ...@@ -115,7 +136,7 @@ export default Vue.extend({
id: false, id: false,
name: '', name: '',
}, },
expand: false, expanded: false,
issue: {}, issue: {},
currentBoard: Store.state.currentBoard, currentBoard: Store.state.currentBoard,
currentPage: Store.state.currentPage, currentPage: Store.state.currentPage,
...@@ -139,14 +160,31 @@ export default Vue.extend({ ...@@ -139,14 +160,31 @@ export default Vue.extend({
return 'Create'; return 'Create';
} }
if (this.currentPage === 'delete') {
return 'Delete';
}
return 'Save'; return 'Save';
}, },
buttonKind() {
if (this.currentPage === 'delete') {
return 'danger';
}
return 'info';
},
title() { title() {
if (this.currentPage === 'new') { if (this.currentPage === 'new') {
return 'Create new board'; return 'Create new board';
} }
// TODO check for readonly if (this.currentPage === 'delete') {
return 'Delete board';
}
if (this.readonly) {
return 'Board scope';
}
return 'Edit board'; return 'Edit board';
}, },
milestoneToggleText() { milestoneToggleText() {
...@@ -155,6 +193,15 @@ export default Vue.extend({ ...@@ -155,6 +193,15 @@ export default Vue.extend({
submitDisabled() { submitDisabled() {
return false; return false;
}, },
expandButtonText() {
return this.expanded ? 'Collapse' : 'Expand'
},
collapseScope() {
return this.currentPage === 'new';
},
readonly() {
return !this.canAdminBoard;
},
}, },
methods: { methods: {
refreshPage() { refreshPage() {
......
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
<div class="board-inner-container"> <div class="board-inner-container">
<div class="media"> <div class="media">
<label class="media-body">{{ title }}</label> <label class="media-body">{{ title }}</label>
<a href="#" @click.prevent="toggleEditing"> <a
v-if="canEdit"
href="#"
@click.prevent="toggleEditing"
>
Edit Edit
</a> </a>
</div> </div>
...@@ -36,6 +40,11 @@ ...@@ -36,6 +40,11 @@
type: String, type: String,
required: false, required: false,
}, },
canEdit: {
type: Boolean,
required: false,
default: false,
}
}, },
data() { data() {
return { return {
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
= icon('times') = icon('times')
.filter-dropdown-container .filter-dropdown-container
- if type == :boards - if type == :boards
.js-board-config .js-board-config{ data: { can_admin_list: can?(current_user, :admin_list, board.parent).to_s } }
- if can?(current_user, :admin_list, board.parent) - if can?(current_user, :admin_list, board.parent)
.dropdown.prepend-left-10#js-add-list .dropdown.prepend-left-10#js-add-list
%button.btn.btn-create.btn-inverted.js-new-board-list{ type: "button", data: board_list_data } %button.btn.btn-create.btn-inverted.js-new-board-list{ type: "button", data: board_list_data }
......
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