Skip to content

Commit 33f0bab

Browse files
authored
Merge branch 'main' into locale-cleanup
2 parents 5774a2c + 851bd18 commit 33f0bab

File tree

2 files changed

+53
-23
lines changed

2 files changed

+53
-23
lines changed

web_src/css/repo.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,7 @@
14201420

14211421
.repository .data-table tr {
14221422
border-top: 0;
1423+
background: none !important;
14231424
}
14241425

14251426
.repository .data-table td,
@@ -1432,6 +1433,21 @@
14321433
border: 1px solid var(--color-secondary);
14331434
}
14341435

1436+
/* the border css competes with .markup where all tables have outer border which would add a double
1437+
border here, remove only the outer borders from this table */
1438+
.repository .data-table tr:first-child :is(td,th) {
1439+
border-top: none !important;
1440+
}
1441+
.repository .data-table tr:last-child :is(td,th) {
1442+
border-bottom: none !important;
1443+
}
1444+
.repository .data-table tr :is(td,th):first-child {
1445+
border-left: none !important;
1446+
}
1447+
.repository .data-table tr :is(td,th):last-child {
1448+
border-right: none !important;
1449+
}
1450+
14351451
.repository .data-table td {
14361452
white-space: pre-line;
14371453
}
@@ -1469,7 +1485,7 @@
14691485
min-width: 50px;
14701486
font-family: monospace;
14711487
line-height: 20px;
1472-
color: var(--color-secondary-dark-2);
1488+
color: var(--color-text-light-1);
14731489
white-space: nowrap;
14741490
vertical-align: top;
14751491
cursor: pointer;

web_src/js/features/repo-issue-content.js

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import $ from 'jquery';
22
import {svg} from '../svg.js';
33
import {showErrorToast} from '../modules/toast.js';
4+
import {GET, POST} from '../modules/fetch.js';
45

5-
const {appSubUrl, csrfToken} = window.config;
6+
const {appSubUrl} = window.config;
67
let i18nTextEdited;
78
let i18nTextOptions;
89
let i18nTextDeleteFromHistory;
@@ -31,19 +32,27 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
3132
$dialog.find('.dialog-header-options').dropdown({
3233
showOnFocus: false,
3334
allowReselection: true,
34-
onChange(_value, _text, $item) {
35+
async onChange(_value, _text, $item) {
3536
const optionItem = $item.data('option-item');
3637
if (optionItem === 'delete') {
3738
if (window.confirm(i18nTextDeleteFromHistoryConfirm)) {
38-
$.post(`${issueBaseUrl}/content-history/soft-delete?comment_id=${commentId}&history_id=${historyId}`, {
39-
_csrf: csrfToken,
40-
}).done((resp) => {
39+
try {
40+
const params = new URLSearchParams();
41+
params.append('comment_id', commentId);
42+
params.append('history_id', historyId);
43+
44+
const response = await POST(`${issueBaseUrl}/content-history/soft-delete?${params.toString()}`);
45+
const resp = await response.json();
46+
4147
if (resp.ok) {
4248
$dialog.modal('hide');
4349
} else {
4450
showErrorToast(resp.message);
4551
}
46-
});
52+
} catch (error) {
53+
console.error('Error:', error);
54+
showErrorToast('An error occurred while deleting the history.');
55+
}
4756
}
4857
} else { // required by eslint
4958
showErrorToast(`unknown option item: ${optionItem}`);
@@ -54,19 +63,24 @@ function showContentHistoryDetail(issueBaseUrl, commentId, historyId, itemTitleH
5463
}
5564
});
5665
$dialog.modal({
57-
onShow() {
58-
$.ajax({
59-
url: `${issueBaseUrl}/content-history/detail?comment_id=${commentId}&history_id=${historyId}`,
60-
data: {
61-
_csrf: csrfToken,
62-
},
63-
}).done((resp) => {
66+
async onShow() {
67+
try {
68+
const params = new URLSearchParams();
69+
params.append('comment_id', commentId);
70+
params.append('history_id', historyId);
71+
72+
const url = `${issueBaseUrl}/content-history/detail?${params.toString()}`;
73+
const response = await GET(url);
74+
const resp = await response.json();
75+
6476
$dialog.find('.comment-diff-data').removeClass('is-loading').html(resp.diffHtml);
6577
// there is only one option "item[data-option-item=delete]", so the dropdown can be entirely shown/hidden.
6678
if (resp.canSoftDelete) {
6779
$dialog.find('.dialog-header-options').removeClass('gt-hidden');
6880
}
69-
});
81+
} catch (error) {
82+
console.error('Error:', error);
83+
}
7084
},
7185
onHidden() {
7286
$dialog.remove();
@@ -103,7 +117,7 @@ function showContentHistoryMenu(issueBaseUrl, $item, commentId) {
103117
});
104118
}
105119

106-
export function initRepoIssueContentHistory() {
120+
export async function initRepoIssueContentHistory() {
107121
const issueIndex = $('#issueIndex').val();
108122
if (!issueIndex) return;
109123

@@ -114,12 +128,10 @@ export function initRepoIssueContentHistory() {
114128
const repoLink = $('#repolink').val();
115129
const issueBaseUrl = `${appSubUrl}/${repoLink}/issues/${issueIndex}`;
116130

117-
$.ajax({
118-
url: `${issueBaseUrl}/content-history/overview`,
119-
data: {
120-
_csrf: csrfToken,
121-
},
122-
}).done((resp) => {
131+
try {
132+
const response = await GET(`${issueBaseUrl}/content-history/overview`);
133+
const resp = await response.json();
134+
123135
i18nTextEdited = resp.i18n.textEdited;
124136
i18nTextDeleteFromHistory = resp.i18n.textDeleteFromHistory;
125137
i18nTextDeleteFromHistoryConfirm = resp.i18n.textDeleteFromHistoryConfirm;
@@ -133,5 +145,7 @@ export function initRepoIssueContentHistory() {
133145
const $itemComment = $(`#issuecomment-${commentId}`);
134146
showContentHistoryMenu(issueBaseUrl, $itemComment, commentId);
135147
}
136-
});
148+
} catch (error) {
149+
console.error('Error:', error);
150+
}
137151
}

0 commit comments

Comments
 (0)