Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[104] Fixes API auth if REST API is enabled and disable _CONF_CHECK_ISSUE_UPDATE_CONFLICT otherwise #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions assets/javascripts/issue_dynamic_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var _CONF_LISTENER_TYPE_VALUE = _CONF_LISTENER_TYPE_VALUE || "click";
var _CONF_LISTENER_TYPE_ICON = _CONF_LISTENER_TYPE_ICON || "none";
var _CONF_LISTENER_TARGET = _CONF_LISTENER_TARGET || "value";
var _CONF_EXCLUDED_FIELD_ID = _CONF_EXCLUDED_FIELD_ID || [];
var _CONF_CHECK_ISSUE_UPDATE_CONFLICT = _CONF_CHECK_ISSUE_UPDATE_CONFLICT || false;
var __hasKey = (typeof _REDMINE_API_KEY !== 'undefined') && _REDMINE_API_KEY.length;
var _CONF_CHECK_ISSUE_UPDATE_CONFLICT = (_CONF_CHECK_ISSUE_UPDATE_CONFLICT && __hasKey) || false;

_CONF_LISTENER_TARGET = _CONF_LISTENER_TARGET === "all" ? "*" : _CONF_LISTENER_TARGET;

Expand Down Expand Up @@ -299,10 +300,12 @@ const getVersion = function(callback){

let loadedDate = new Date();
const checkVersion = function(callback){

fetch(LOCATION_HREF + ".json", {
method: 'GET',
crossDomain: true,
headers: {
'X-Redmine-API-Key': _REDMINE_API_KEY
},
}).then(res => res.text()).then(data => {
try {
const parsedData = JSON.parse(data);
Expand Down
6 changes: 6 additions & 0 deletions lib/details_issue_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ def view_layouts_base_body_bottom(context)
end

def view_issues_show_details_bottom(context)
api_key = if Setting.rest_api_enabled?
User.current.api_key || ""
else
""
end
content = "<script>\n"
content << " const _ISSUE_ID = \"#{context[:request].path_parameters[:id]}\";\n"
content << " const _PROJECT_ID = \"#{Issue.find(context[:request].path_parameters[:id]).project_id}\";\n"
content << " const _TXT_CONFLICT_TITLE = \"" + l(:ide_txt_notice_conflict_title) + "\";\n"
content << " const _TXT_CONFLICT_TXT = \"" + l(:ide_txt_notice_conflict_text) + "\";\n"
content << " const _TXT_CONFLICT_LINK = \"" + l(:ide_txt_notice_conflict_link) + "\";\n"
content << " const _REDMINE_API_KEY = \"" + api_key + "\";\n" if api_key.present?
content << "</script>\n"
content << "<style>/* PRINT MEDIAQUERY */\n"
content << "@media print {\n"
Expand Down