Commit 25fa18d5 authored by Ivanq's avatar Ivanq

Don't show 'Comment and close' for non-owners

parent 356e4a3a
......@@ -283,13 +283,20 @@ class Repository {
});
}
getIssue(id, jsonId) {
return this.zeroDB.query("SELECT issues.*, json.cert_user_id FROM issues, json WHERE issues.json_id = json.json_id AND issues.json_id = :jsonId AND issues.id = :id AND json.site = :address", {
let issue;
return this.zeroDB.query("SELECT issues.*, json.directory, json.cert_user_id FROM issues, json WHERE issues.json_id = json.json_id AND issues.json_id = :jsonId AND issues.id = :id AND json.site = :address", {
jsonId: jsonId,
id: id,
address: this.address
})
.then(issue => {
return issue[0];
.then(i => {
issue = i[0];
return this.zeroPage.isSignable("merged-GitCenter/" + this.address + "/" + issue.directory + "/content.json");
})
.then(signable => {
issue.owned = signable;
return issue;
});
}
getIssueComments(id, jsonId) {
......@@ -443,13 +450,20 @@ class Repository {
});
}
getPullRequest(id, jsonId) {
return this.zeroDB.query("SELECT pull_requests.*, json.cert_user_id FROM pull_requests, json WHERE pull_requests.json_id = json.json_id AND pull_requests.json_id = :jsonId AND pull_requests.id = :id AND json.site = :address", {
let pullRequest;
return this.zeroDB.query("SELECT pull_requests.*, json.directory, json.cert_user_id FROM pull_requests, json WHERE pull_requests.json_id = json.json_id AND pull_requests.json_id = :jsonId AND pull_requests.id = :id AND json.site = :address", {
jsonId: jsonId,
id: id,
address: this.address
})
.then(pullRequest => {
return pullRequest[0];
.then(p => {
pullRequest = p[0];
return this.zeroPage.isSignable("merged-GitCenter/" + this.address + "/" + pullRequest.directory + "/content.json");
})
.then(signable => {
pullRequest.owned = signable;
return pullRequest;
});
}
getPullRequestComments(id, jsonId) {
......
......@@ -87,6 +87,7 @@
float: right;
}
.comment-submit-close {
display: none;
float: right;
margin-right: 16px;
}
\ No newline at end of file
......@@ -88,39 +88,42 @@ repo.addMerger()
});
};
document.getElementById("comment_submit_close").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
return;
}
contentNode.disabled = true;
let promise;
if(contentNode.value == "") {
promise = Promise.resolve();
} else {
promise = repo.addIssueComment(id, jsonId, contentNode.value)
.then(comment => {
showComment(comment);
if(issue.owned) {
document.getElementById("comment_submit_close").style.display = "inline-block";
document.getElementById("comment_submit_close").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
return;
}
contentNode.disabled = true;
let promise;
if(contentNode.value == "") {
promise = Promise.resolve();
} else {
promise = repo.addIssueComment(id, jsonId, contentNode.value)
.then(comment => {
showComment(comment);
});
}
promise
.then(() => {
return repo.changeIssueStatus(id, jsonId, !issue.open);
})
.then(() => {
if(issue.open) {
issue.open = false;
} else {
issue.open = true;
issue.reopened = true;
}
drawIssueStatus();
contentNode.value = "";
contentNode.disabled = false;
});
}
promise
.then(() => {
return repo.changeIssueStatus(id, jsonId, !issue.open);
})
.then(() => {
if(issue.open) {
issue.open = false;
} else {
issue.open = true;
issue.reopened = true;
}
drawIssueStatus();
contentNode.value = "";
contentNode.disabled = false;
});
};
};
}
});
\ No newline at end of file
......@@ -89,34 +89,37 @@ repo.addMerger()
});
};
document.getElementById("comment_submit_close").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
return;
}
contentNode.disabled = true;
let promise;
if(contentNode.value == "") {
promise = Promise.resolve();
} else {
promise = repo.addPullRequestComment(id, jsonId, contentNode.value)
.then(comment => {
showComment(comment);
if(pullRequest.owned) {
document.getElementById("comment_submit_close").style.display = "inline-block";
document.getElementById("comment_submit_close").onclick = () => {
let contentNode = document.getElementById("comment_content");
if(contentNode.disabled) {
return;
}
contentNode.disabled = true;
let promise;
if(contentNode.value == "") {
promise = Promise.resolve();
} else {
promise = repo.addPullRequestComment(id, jsonId, contentNode.value)
.then(comment => {
showComment(comment);
});
}
promise
.then(() => {
return repo.changePullRequestStatus(id, jsonId, !pullRequest.open);
})
.then(() => {
pullRequest.merged = !pullRequest.merged;
drawPullRequestStatus();
contentNode.value = "";
contentNode.disabled = false;
});
}
promise
.then(() => {
return repo.changePullRequestStatus(id, jsonId, !pullRequest.open);
})
.then(() => {
pullRequest.merged = !pullRequest.merged;
drawPullRequestStatus();
contentNode.value = "";
contentNode.disabled = false;
});
};
};
}
});
\ No newline at end of file
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