-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
feat(platform): getIssue #10453
feat(platform): getIssue #10453
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about other platforms like gitea
?
Does gitea have checkbox support now? |
Yes, will be official supported in v1.15.0, PR merged. I've a custom javascript to support clickable checkboxes for older versions: /* eslint-env browser,es2020,greasemonkey */
/* global $,config */
(function () {
'use strict';
const prefix = '[VO] ';
console.log(`${prefix}starting`);
const cbRe = /^\s*- \[( |x)\] (.+)$/gm;
try {
const { owner, repo, type, id } = location.pathname?.match(/(?<owner>[^/]+)\/(?<repo>[^/]+)\/(?<type>pulls|issues)\/(?<id>\d+)/)?.groups ?? {};
if (!owner) {
console.log(`${prefix}issue / pr not found`);
return;
}
if ($('#edit-title').length === 0) {
console.log(`${prefix}no rights`);
return;
}
/**
*
* @param {number} idx
*/
async function process(idx) {
/**
* @type {{body:string}}
*/
let { body } = await fetch(`/api/v1/repos/${owner}/${repo}/issues/${id}`).then((response) => response.json());
const m = [...body.matchAll(cbRe)];
if (!m[idx]) {
console.log(`${prefix}not found: ${idx}`);
return;
}
const line = m[idx];
console.log(`${prefix}match:`, line[0]);
body = body.replace(
line[0],
line[0].replace(/\[( |x)\]/, (_, val) => (val == ' ' ? '[x]' : '[ ]'))
);
body = JSON.stringify({ body });
const headers = {
'content-type': 'application/json',
'X-Csrf-Token': config.csrf,
};
const resp = await fetch(`/api/v1/repos/${owner}/${repo}/issues/${id}`, {
method: 'PATCH',
headers,
body,
});
if (!resp.ok) {
return;
}
location.reload();
}
console.log(`${prefix}${owner}/${repo}/${type}#${id}`);
$(document).on('click', '.timeline-item.comment.first .render-content .task-list-item > input', (e) => {
if ($(e.target).closest('a').length > 0) return true;
// disable checkboxes
$('.timeline-item.comment.first .render-content .task-list-item > input').prop('disabled', true);
const idx = $('.timeline-item.comment.first .render-content .task-list-item').index($(e.target).closest('.task-list-item'));
console.log(`${prefix}click:`, idx);
process(idx).catch((e) => console.error(`${prefix}unexpected error`, e));
});
// enable checkboxes
$('.timeline-item.comment.first .render-content .task-list-item > input').prop('disabled', false);
} catch (e) {
console.error(`${prefix}unexpected error`, e);
}
})(); 😏 |
Added gitea but code inspection only. @viceice please double check it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added same implementation to gitea like github
🎉 This PR is included in version 25.43.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Changes:
Adds optional
getIssue()
function toplatform
withuseCache
exposed. Only needed for platforms which support interactive checkboxes.Context:
This will be used for upcoming Dashboard race condition fix.
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: