Compare commits

..

No commits in common. "ef8209a953e7af14c1ee5c68678c2da959f511fb" and "5d5f907e7fcf1dee4eaca205f8e43f50e5884a58" have entirely different histories.

10 changed files with 137 additions and 91 deletions

View File

@ -272,7 +272,6 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to create tmp file: %v", err) fatal("Failed to create tmp file: %v", err)
} }
defer func() { defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil { if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err) log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
} }

View File

@ -111,7 +111,6 @@ func GetUnmergedPullRequestsByBaseInfo(repoID int64, branch string) ([]*PullRequ
return prs, db.GetEngine(db.DefaultContext). return prs, db.GetEngine(db.DefaultContext).
Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?", Where("base_repo_id=? AND base_branch=? AND has_merged=? AND issue.is_closed=?",
repoID, branch, false, false). repoID, branch, false, false).
OrderBy("issue.updated_unix DESC").
Join("INNER", "issue", "issue.id=pull_request.issue_id"). Join("INNER", "issue", "issue.id=pull_request.issue_id").
Find(&prs) Find(&prs)
} }

View File

@ -132,8 +132,6 @@ func createDefaultPolicy() *bluemonday.Policy {
policy.AllowAttrs(generalSafeAttrs...).OnElements(generalSafeElements...) policy.AllowAttrs(generalSafeAttrs...).OnElements(generalSafeElements...)
policy.AllowAttrs("src", "autoplay", "controls").OnElements("video")
policy.AllowAttrs("itemscope", "itemtype").OnElements("div") policy.AllowAttrs("itemscope", "itemtype").OnElements("div")
// FIXME: Need to handle longdesc in img but there is no easy way to do it // FIXME: Need to handle longdesc in img but there is no easy way to do it

View File

@ -50,7 +50,7 @@
</div> </div>
</div> </div>
<div class="required non-local field {{if .Err_LoginName}}error{{end}} {{if eq .login_type "0-0"}}gt-hidden{{end}}"> <div class="required non-local field {{if .Err_LoginName}}error{{end}} {{if eq .login_type "0-0"}}hide{{end}}">
<label for="login_name">{{.locale.Tr "admin.users.auth_login_name"}}</label> <label for="login_name">{{.locale.Tr "admin.users.auth_login_name"}}</label>
<input id="login_name" name="login_name" value="{{.login_name}}"> <input id="login_name" name="login_name" value="{{.login_name}}">
</div> </div>
@ -62,12 +62,12 @@
<label for="email">{{.locale.Tr "email"}}</label> <label for="email">{{.locale.Tr "email"}}</label>
<input id="email" name="email" type="email" value="{{.email}}" required> <input id="email" name="email" type="email" value="{{.email}}" required>
</div> </div>
<div class="required local field {{if .Err_Password}}error{{end}} {{if not (eq .login_type "0-0")}}gt-hidden{{end}}"> <div class="required local field {{if .Err_Password}}error{{end}} {{if not (eq .login_type "0-0")}}hide{{end}}">
<label for="password">{{.locale.Tr "password"}}</label> <label for="password">{{.locale.Tr "password"}}</label>
<input id="password" name="password" type="password" autocomplete="new-password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}> <input id="password" name="password" type="password" autocomplete="new-password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
</div> </div>
<div class="inline field local {{if ne .login_type "0-0"}}gt-hidden{{end}}"> <div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}">
<div class="ui checkbox"> <div class="ui checkbox">
<label><strong>{{.locale.Tr "auth.allow_password_change"}}</strong></label> <label><strong>{{.locale.Tr "auth.allow_password_change"}}</strong></label>
<input name="must_change_password" type="checkbox" checked> <input name="must_change_password" type="checkbox" checked>

View File

@ -58,7 +58,7 @@
</label> </label>
</div> </div>
</div> </div>
<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}gt-hidden{{end}}"> <div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}hide{{end}}">
<div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}"> <div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}">
{{svg "octicon-git-branch"}} {{svg "octicon-git-branch"}}
<input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="input-contrast gt-mr-2 js-quick-pull-new-branch-name" placeholder="{{.locale.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}} title="{{.locale.Tr "repo.editor.new_branch_name"}}"> <input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="input-contrast gt-mr-2 js-quick-pull-new-branch-name" placeholder="{{.locale.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}} title="{{.locale.Tr "repo.editor.new_branch_name"}}">

View File

@ -46,32 +46,49 @@
<div class="ui dropdown icon button" title="{{.locale.Tr "home.filter"}}"> <div class="ui dropdown icon button" title="{{.locale.Tr "home.filter"}}">
<i class="icon gt-df gt-ac gt-jc gt-m-0">{{svg "octicon-filter" 16}}</i> <i class="icon gt-df gt-ac gt-jc gt-m-0">{{svg "octicon-filter" 16}}</i>
<div class="menu"> <div class="menu">
<a class="item" @click="toggleArchivedFilter()"> <div class="item">
<div class="ui checkbox" <a @click="toggleArchivedFilter()">
ref="checkboxArchivedFilter" <div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_both_archived_unarchived"}}" v-if="archivedFilter === 'both'">
data-title-both="{{.locale.Tr "home.show_both_archived_unarchived"}}" <input type="checkbox">
data-title-unarchived="{{.locale.Tr "home.show_only_unarchived"}}" <label>
data-title-archived="{{.locale.Tr "home.show_only_archived"}}" {{svg "octicon-archive" 16 "gt-mr-2"}}
:title="checkboxArchivedFilterTitle" {{.locale.Tr "home.show_archived"}}
> </label>
<!--the "hidden" is necessary to make the checkbox work without Fomantic UI js, </div>
otherwise if the "input" handles click event for intermediate status, it breaks the internal state--> <div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_unarchived"}}" v-if="archivedFilter === 'unarchived'">
<input type="checkbox" class="hidden" v-bind.prop="checkboxArchivedFilterProps"> <input type="checkbox">
<label>
{{svg "octicon-archive" 16 "gt-mr-2"}}
{{.locale.Tr "home.show_archived"}}
</label>
</div>
<div class="ui checkbox" id="archivedFilterCheckbox" title="{{.locale.Tr "home.show_only_archived"}}" v-if="archivedFilter === 'archived'">
<input type="checkbox">
<label> <label>
{{svg "octicon-archive" 16 "gt-mr-2"}} {{svg "octicon-archive" 16 "gt-mr-2"}}
{{.locale.Tr "home.show_archived"}} {{.locale.Tr "home.show_archived"}}
</label> </label>
</div> </div>
</a> </a>
<a class="item" @click="togglePrivateFilter()"> </div>
<div class="ui checkbox" <div class="item">
ref="checkboxPrivateFilter" <a @click="togglePrivateFilter()">
data-title-both="{{.locale.Tr "home.show_both_private_public"}}" <div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_both_private_public"}}" v-if="privateFilter === 'both'">
data-title-public="{{.locale.Tr "home.show_only_public"}}" <input type="checkbox">
data-title-private="{{.locale.Tr "home.show_only_private"}}" <label>
:title="checkboxPrivateFilterTitle" {{svg "octicon-lock" 16 "gt-mr-2"}}
> {{.locale.Tr "home.show_private"}}
<input type="checkbox" class="hidden" v-bind.prop="checkboxPrivateFilterProps"> </label>
</div>
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_public"}}" v-if="privateFilter === 'public'">
<input type="checkbox">
<label>
{{svg "octicon-lock" 16 "gt-mr-2"}}
{{.locale.Tr "home.show_private"}}
</label>
</div>
<div class="ui checkbox" id="privateFilterCheckbox" title="{{.locale.Tr "home.show_only_private"}}" v-if="privateFilter === 'private'">
<input type="checkbox">
<label> <label>
{{svg "octicon-lock" 16 "gt-mr-2"}} {{svg "octicon-lock" 16 "gt-mr-2"}}
{{.locale.Tr "home.show_private"}} {{.locale.Tr "home.show_private"}}
@ -81,6 +98,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="ui secondary tiny pointing borderless menu center grid repos-filter"> <div class="ui secondary tiny pointing borderless menu center grid repos-filter">
<a class="item" :class="{active: reposFilter === 'all'}" @click="changeReposFilter('all')"> <a class="item" :class="{active: reposFilter === 'all'}" @click="changeReposFilter('all')">
{{.locale.Tr "all"}} {{.locale.Tr "all"}}

View File

@ -87,7 +87,6 @@ function initVueComponents(app) {
} }
return { return {
hasMounted: false, // accessing $refs in computed() need to wait for mounted
tab, tab,
repos: [], repos: [],
reposTotalCount: 0, reposTotalCount: 0,
@ -135,19 +134,7 @@ function initVueComponents(app) {
}, },
repoTypeCount() { repoTypeCount() {
return this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`]; return this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`];
}, }
checkboxArchivedFilterTitle() {
return this.hasMounted && this.$refs.checkboxArchivedFilter?.getAttribute(`data-title-${this.archivedFilter}`);
},
checkboxArchivedFilterProps() {
return {checked: this.archivedFilter === 'archived', indeterminate: this.archivedFilter === 'both'};
},
checkboxPrivateFilterTitle() {
return this.hasMounted && this.$refs.checkboxPrivateFilter?.getAttribute(`data-title-${this.privateFilter}`);
},
checkboxPrivateFilterProps() {
return {checked: this.privateFilter === 'private', indeterminate: this.privateFilter === 'both'};
},
}, },
mounted() { mounted() {
@ -157,11 +144,10 @@ function initVueComponents(app) {
initTooltip(elTooltip); initTooltip(elTooltip);
} }
$(el).find('.dropdown').dropdown(); $(el).find('.dropdown').dropdown();
this.setCheckboxes();
nextTick(() => { nextTick(() => {
this.$refs.search.focus(); this.$refs.search.focus();
}); });
this.hasMounted = true;
}, },
methods: { methods: {
@ -170,6 +156,39 @@ function initVueComponents(app) {
this.updateHistory(); this.updateHistory();
}, },
setCheckboxes() {
switch (this.archivedFilter) {
case 'unarchived':
$('#archivedFilterCheckbox').checkbox('set unchecked');
break;
case 'archived':
$('#archivedFilterCheckbox').checkbox('set checked');
break;
case 'both':
$('#archivedFilterCheckbox').checkbox('set indeterminate');
break;
default:
this.archivedFilter = 'unarchived';
$('#archivedFilterCheckbox').checkbox('set unchecked');
break;
}
switch (this.privateFilter) {
case 'public':
$('#privateFilterCheckbox').checkbox('set unchecked');
break;
case 'private':
$('#privateFilterCheckbox').checkbox('set checked');
break;
case 'both':
$('#privateFilterCheckbox').checkbox('set indeterminate');
break;
default:
this.privateFilter = 'both';
$('#privateFilterCheckbox').checkbox('set indeterminate');
break;
}
},
changeReposFilter(filter) { changeReposFilter(filter) {
this.reposFilter = filter; this.reposFilter = filter;
this.repos = []; this.repos = [];
@ -226,29 +245,45 @@ function initVueComponents(app) {
}, },
toggleArchivedFilter() { toggleArchivedFilter() {
if (this.archivedFilter === 'unarchived') { switch (this.archivedFilter) {
this.archivedFilter = 'archived'; case 'both':
} else if (this.archivedFilter === 'archived') {
this.archivedFilter = 'both';
} else { // including both
this.archivedFilter = 'unarchived'; this.archivedFilter = 'unarchived';
break;
case 'unarchived':
this.archivedFilter = 'archived';
break;
case 'archived':
this.archivedFilter = 'both';
break;
default:
this.archivedFilter = 'unarchived';
break;
} }
this.page = 1; this.page = 1;
this.repos = []; this.repos = [];
this.setCheckboxes();
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0; this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
this.searchRepos(); this.searchRepos();
}, },
togglePrivateFilter() { togglePrivateFilter() {
if (this.privateFilter === 'both') { switch (this.privateFilter) {
case 'both':
this.privateFilter = 'public'; this.privateFilter = 'public';
} else if (this.privateFilter === 'public') { break;
case 'public':
this.privateFilter = 'private'; this.privateFilter = 'private';
} else { // including private break;
case 'private':
this.privateFilter = 'both'; this.privateFilter = 'both';
break;
default:
this.privateFilter = 'both';
break;
} }
this.page = 1; this.page = 1;
this.repos = []; this.repos = [];
this.setCheckboxes();
this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0; this.counts[`${this.reposFilter}:${this.archivedFilter}:${this.privateFilter}`] = 0;
this.searchRepos(); this.searchRepos();
}, },

View File

@ -2,7 +2,7 @@ import $ from 'jquery';
const {pageData} = window.config; const {pageData} = window.config;
const initInputCitationValue = async ($citationCopyApa, $citationCopyBibtex) => { const initInputCitationValue = async ($citationCopyBibtex, $citationCopyApa) => {
const [{Cite, plugins}] = await Promise.all([ const [{Cite, plugins}] = await Promise.all([
import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'), import(/* webpackChunkName: "citation-js-core" */'@citation-js/core'),
import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'), import(/* webpackChunkName: "citation-js-formats" */'@citation-js/plugin-software-formats'),

View File

@ -418,22 +418,6 @@ function assignMenuAttributes(menu) {
return id; return id;
} }
export async function handleReply($el) {
hideElem($el);
const form = $el.closest('.comment-code-cloud').find('.comment-form');
form.removeClass('gt-hidden');
const $textarea = form.find('textarea');
let easyMDE = getAttachedEasyMDE($textarea);
if (!easyMDE) {
await attachTribute($textarea.get(), {mentions: true, emoji: true});
easyMDE = await createCommentEasyMDE($textarea);
}
$textarea.focus();
easyMDE.codemirror.focus();
assignMenuAttributes(form.find('.menu'));
return easyMDE;
}
export function initRepoPullRequestReview() { export function initRepoPullRequestReview() {
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) { if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
const commentDiv = $(window.location.hash); const commentDiv = $(window.location.hash);
@ -471,7 +455,19 @@ export function initRepoPullRequestReview() {
$(document).on('click', 'button.comment-form-reply', async function (e) { $(document).on('click', 'button.comment-form-reply', async function (e) {
e.preventDefault(); e.preventDefault();
await handleReply($(this));
hideElem($(this));
const form = $(this).closest('.comment-code-cloud').find('.comment-form');
form.removeClass('gt-hidden');
const $textarea = form.find('textarea');
let easyMDE = getAttachedEasyMDE($textarea);
if (!easyMDE) {
await attachTribute($textarea.get(), {mentions: true, emoji: true});
easyMDE = await createCommentEasyMDE($textarea);
}
$textarea.focus();
easyMDE.codemirror.focus();
assignMenuAttributes(form.find('.menu'));
}); });
const $reviewBox = $('.review-box-panel'); const $reviewBox = $('.review-box-panel');

View File

@ -6,7 +6,7 @@ import {
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete, initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete,
initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssueReferenceIssue, initRepoIssueComments, initRepoIssueDependencyDelete, initRepoIssueReferenceIssue,
initRepoIssueStatusButton, initRepoIssueTitleEdit, initRepoIssueWipToggle, initRepoIssueStatusButton, initRepoIssueTitleEdit, initRepoIssueWipToggle,
initRepoPullRequestUpdate, updateIssuesMeta, handleReply initRepoPullRequestUpdate, updateIssuesMeta,
} from './repo-issue.js'; } from './repo-issue.js';
import {initUnicodeEscapeButton} from './repo-unicode-escape.js'; import {initUnicodeEscapeButton} from './repo-unicode-escape.js';
import {svg} from '../svg.js'; import {svg} from '../svg.js';
@ -613,15 +613,15 @@ function initRepoIssueCommentEdit() {
$(document).on('click', '.edit-content', onEditContent); $(document).on('click', '.edit-content', onEditContent);
// Quote reply // Quote reply
$(document).on('click', '.quote-reply', async function (event) { $(document).on('click', '.quote-reply', function (event) {
event.preventDefault();
const target = $(this).data('target'); const target = $(this).data('target');
const quote = $(`#${target}`).text().replace(/\n/g, '\n> '); const quote = $(`#${target}`).text().replace(/\n/g, '\n> ');
const content = `> ${quote}\n\n`; const content = `> ${quote}\n\n`;
let easyMDE; let easyMDE;
if ($(this).hasClass('quote-reply-diff')) { if ($(this).hasClass('quote-reply-diff')) {
const $replyBtn = $(this).closest('.comment-code-cloud').find('button.comment-form-reply'); const $parent = $(this).closest('.comment-code-cloud');
easyMDE = await handleReply($replyBtn); $parent.find('button.comment-form-reply').trigger('click');
easyMDE = getAttachedEasyMDE($parent.find('[name="content"]'));
} else { } else {
// for normal issue/comment page // for normal issue/comment page
easyMDE = getAttachedEasyMDE($('#comment-form .edit_area')); easyMDE = getAttachedEasyMDE($('#comment-form .edit_area'));
@ -637,5 +637,6 @@ function initRepoIssueCommentEdit() {
easyMDE.codemirror.setCursor(easyMDE.codemirror.lineCount(), 0); easyMDE.codemirror.setCursor(easyMDE.codemirror.lineCount(), 0);
}); });
} }
event.preventDefault();
}); });
} }