Skip to content

Commit 1dfb66c

Browse files
committed
Merge branch 'main' into lunny/add_comment_move_issue_column
2 parents 48150ab + 4e3d81e commit 1dfb66c

File tree

5 files changed

+22
-30
lines changed

5 files changed

+22
-30
lines changed

templates/repo/diff/blob_excerpt.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}">
66
<div class="gt-df">
77
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
8-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
8+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
99
{{svg "octicon-fold-down"}}
1010
</button>
1111
{{end}}
1212
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
13-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
13+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
1414
{{svg "octicon-fold-up"}}
1515
</button>
1616
{{end}}
1717
{{if eq $line.GetExpandDirection 2}}
18-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
18+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
1919
{{svg "octicon-fold"}}
2020
</button>
2121
{{end}}
@@ -51,17 +51,17 @@
5151
<td colspan="2" class="lines-num">
5252
<div class="gt-df">
5353
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
54-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
54+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
5555
{{svg "octicon-fold-down"}}
5656
</button>
5757
{{end}}
5858
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
59-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
59+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
6060
{{svg "octicon-fold-up"}}
6161
</button>
6262
{{end}}
6363
{{if eq $line.GetExpandDirection 2}}
64-
<button class="code-expander-button" data-url="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}" data-anchor="{{$.Anchor}}">
64+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?data-query={{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}">
6565
{{svg "octicon-fold"}}
6666
</button>
6767
{{end}}

templates/repo/diff/section_split.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
<td class="lines-num lines-num-old">
1919
<div class="gt-df">
2020
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
21-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
21+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2222
{{svg "octicon-fold-down"}}
2323
</button>
2424
{{end}}
2525
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
26-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
26+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2727
{{svg "octicon-fold-up"}}
2828
</button>
2929
{{end}}
3030
{{if eq $line.GetExpandDirection 2}}
31-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
31+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
3232
{{svg "octicon-fold"}}
3333
</button>
3434
{{end}}

templates/repo/diff/section_unified.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
<td colspan="2" class="lines-num">
1515
<div class="gt-df">
1616
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}}
17-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
17+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
1818
{{svg "octicon-fold-down"}}
1919
</button>
2020
{{end}}
2121
{{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}}
22-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
22+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2323
{{svg "octicon-fold-up"}}
2424
</button>
2525
{{end}}
2626
{{if eq $line.GetExpandDirection 2}}
27-
<button class="code-expander-button" data-url="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}" data-query="{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}" data-anchor="diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
27+
<button class="code-expander-button" hx-target="closest tr" hx-get="{{$.root.RepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}">
2828
{{svg "octicon-fold"}}
2929
</button>
3030
{{end}}

web_src/js/features/comp/ComboMarkdownEditor.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {renderPreviewPanelContent} from '../repo-editor.js';
99
import {easyMDEToolbarActions} from './EasyMDEToolbarActions.js';
1010
import {initTextExpander} from './TextExpander.js';
1111
import {showErrorToast} from '../../modules/toast.js';
12+
import {POST} from '../../modules/fetch.js';
1213

1314
let elementIdCounter = 0;
1415

@@ -147,16 +148,15 @@ class ComboMarkdownEditor {
147148
this.previewContext = $tabPreviewer.attr('data-preview-context');
148149
this.previewMode = this.options.previewMode ?? 'comment';
149150
this.previewWiki = this.options.previewWiki ?? false;
150-
$tabPreviewer.on('click', () => {
151-
$.post(this.previewUrl, {
152-
_csrf: window.config.csrfToken,
153-
mode: this.previewMode,
154-
context: this.previewContext,
155-
text: this.value(),
156-
wiki: this.previewWiki,
157-
}, (data) => {
158-
renderPreviewPanelContent($panelPreviewer, data);
159-
});
151+
$tabPreviewer.on('click', async () => {
152+
const formData = new FormData();
153+
formData.append('mode', this.previewMode);
154+
formData.append('context', this.previewContext);
155+
formData.append('text', this.value());
156+
formData.append('wiki', this.previewWiki);
157+
const response = await POST(this.previewUrl, {data: formData});
158+
const data = await response.text();
159+
renderPreviewPanelContent($panelPreviewer, data);
160160
});
161161
}
162162

web_src/js/features/repo-code.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,6 @@ export function initRepoCodeView() {
186186
$(document).on('click', '.fold-file', ({currentTarget}) => {
187187
invertFileFolding(currentTarget.closest('.file-content'), currentTarget);
188188
});
189-
$(document).on('click', '.code-expander-button', async ({currentTarget}) => {
190-
const url = currentTarget.getAttribute('data-url');
191-
const query = currentTarget.getAttribute('data-query');
192-
const anchor = currentTarget.getAttribute('data-anchor');
193-
if (!url) return;
194-
const blob = await $.get(`${url}?${query}&anchor=${anchor}`);
195-
currentTarget.closest('tr').outerHTML = blob;
196-
});
197189
$(document).on('click', '.copy-line-permalink', async ({currentTarget}) => {
198190
await clippie(toAbsoluteUrl(currentTarget.getAttribute('data-url')));
199191
});

0 commit comments

Comments
 (0)