diff --git a/app/assets/javascripts/shared/datatable/state.js b/app/assets/javascripts/shared/datatable/state.js
index 65dd0af8d..a682f2a8c 100644
--- a/app/assets/javascripts/shared/datatable/state.js
+++ b/app/assets/javascripts/shared/datatable/state.js
@@ -41,13 +41,29 @@ DradisDatatable.prototype.setupStateButtons = function () {
api = this;
states.forEach(function (state) {
+ const publishDisabled =
+ state[0] === 'Published' &&
+ $('[data-published-state]').data('published-state') === false;
+
+ let attrs;
+
+ if (publishDisabled) {
+ attrs = {
+ 'data-bs-toggle': 'tooltip',
+ 'data-bs-title': 'You are not a Reviewer for this project.',
+ };
+ }
+
stateButtons.push({
- text: $(
- `${state[0]}`
- ),
action: DradisDatatable.prototype.updateRecordState.call(
api,
- state[0].toLowerCase().replaceAll(' ', '_')
+ state[0].toLowerCase().replaceAll(' ', '_'),
+ $('[data-published-state]').data('published-state') != false
+ ),
+ attr: attrs,
+ className: publishDisabled ? 'disabled' : null,
+ text: $(
+ `${state[0]}`
),
});
});
@@ -55,7 +71,11 @@ DradisDatatable.prototype.setupStateButtons = function () {
return stateButtons;
};
-DradisDatatable.prototype.updateRecordState = function (newState) {
+DradisDatatable.prototype.updateRecordState = function (newState, canPublish) {
+ if (newState == 'Published' && canPublish) {
+ return;
+ }
+
var api = this;
return function () {
diff --git a/app/assets/stylesheets/shared/datatables.scss b/app/assets/stylesheets/shared/datatables.scss
index cc6ded335..7b5515fab 100644
--- a/app/assets/stylesheets/shared/datatables.scss
+++ b/app/assets/stylesheets/shared/datatables.scss
@@ -264,6 +264,12 @@ div.dataTables_wrapper {
}
}
+ &.disabled {
+ color: $text-muted;
+ cursor: not-allowed;
+ pointer-events: auto;
+ }
+
&:focus,
&:hover {
outline: none;
diff --git a/app/views/issues/_table.html.erb b/app/views/issues/_table.html.erb
index d3a84ff97..44bdcf07b 100644
--- a/app/views/issues/_table.html.erb
+++ b/app/views/issues/_table.html.erb
@@ -5,6 +5,7 @@
'item-name': 'issue',
'local-storage-key': local_storage_key,
'new-tag-path': new_project_tag_path(current_project),
+ 'published-state': can?(:publish, current_project),
'state-icons': local_assigns[:qa_state_icons] ? local_assigns[:qa_state_icons] : state_icons,
'tags-path': project_tags_path(current_project)
}%>