Skip to content

Commit 2e97a77

Browse files
authored
First step to refactor the .hide to .gt-hidden (#22916)
A separate PR from #22884 (without touching the jQuery methods)
1 parent 6c90f5e commit 2e97a77

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

templates/repo/issue/view_content/comments.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,15 @@
485485
</div>
486486
<div>
487487
{{if or $invalid $resolved}}
488-
<button id="show-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="{{if not $resolved}}hide {{end}}ui compact right labeled button show-outdated gt-df gt-ac">
488+
<button id="show-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="{{if not $resolved}}gt-hidden {{end}}ui compact right labeled button show-outdated gt-df gt-ac">
489489
{{svg "octicon-unfold" 16 "gt-mr-3"}}
490490
{{if $resolved}}
491491
{{$.locale.Tr "repo.issues.review.show_resolved"}}
492492
{{else}}
493493
{{$.locale.Tr "repo.issues.review.show_outdated"}}
494494
{{end}}
495495
</button>
496-
<button id="hide-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="{{if $resolved}}hide {{end}}ui compact right labeled button hide-outdated gt-df gt-ac">
496+
<button id="hide-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="{{if $resolved}}gt-hidden {{end}}ui compact right labeled button hide-outdated gt-df gt-ac">
497497
{{svg "octicon-fold" 16 "gt-mr-3"}}
498498
{{if $resolved}}
499499
{{$.locale.Tr "repo.issues.review.hide_resolved"}}
@@ -507,7 +507,7 @@
507507
{{$diff := (CommentMustAsDiff (index $comms 0))}}
508508
{{if $diff}}
509509
{{$file := (index $diff.Files 0)}}
510-
<div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if $resolved}} hide{{end}}">
510+
<div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if $resolved}} gt-hidden{{end}}">
511511
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}">
512512
<div class="file-body file-code code-view code-diff code-diff-unified unicode-escaped">
513513
<table>
@@ -519,7 +519,7 @@
519519
</div>
520520
</div>
521521
{{end}}
522-
<div id="code-comments-{{(index $comms 0).ID}}" class="comment-code-cloud ui segment{{if $resolved}} hide{{end}}">
522+
<div id="code-comments-{{(index $comms 0).ID}}" class="comment-code-cloud ui segment{{if $resolved}} gt-hidden{{end}}">
523523
<div class="ui comments gt-mb-0">
524524
{{range $comms}}
525525
{{$createdSubStr:= TimeSinceUnix .CreatedUnix $.locale}}

web_src/js/features/repo-issue.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,10 @@ export function initRepoPullRequestReview() {
425425
const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id');
426426
if (groupID && groupID.startsWith('code-comments-')) {
427427
const id = groupID.slice(14);
428-
$(`#show-outdated-${id}`).addClass('hide');
429-
$(`#code-comments-${id}`).removeClass('hide');
430-
$(`#code-preview-${id}`).removeClass('hide');
431-
$(`#hide-outdated-${id}`).removeClass('hide');
428+
$(`#show-outdated-${id}`).addClass('gt-hidden');
429+
$(`#code-comments-${id}`).removeClass('gt-hidden');
430+
$(`#code-preview-${id}`).removeClass('gt-hidden');
431+
$(`#hide-outdated-${id}`).removeClass('gt-hidden');
432432
commentDiv[0].scrollIntoView();
433433
}
434434
}
@@ -437,19 +437,19 @@ export function initRepoPullRequestReview() {
437437
$(document).on('click', '.show-outdated', function (e) {
438438
e.preventDefault();
439439
const id = $(this).data('comment');
440-
$(this).addClass('hide');
441-
$(`#code-comments-${id}`).removeClass('hide');
442-
$(`#code-preview-${id}`).removeClass('hide');
443-
$(`#hide-outdated-${id}`).removeClass('hide');
440+
$(this).addClass('gt-hidden');
441+
$(`#code-comments-${id}`).removeClass('gt-hidden');
442+
$(`#code-preview-${id}`).removeClass('gt-hidden');
443+
$(`#hide-outdated-${id}`).removeClass('gt-hidden');
444444
});
445445

446446
$(document).on('click', '.hide-outdated', function (e) {
447447
e.preventDefault();
448448
const id = $(this).data('comment');
449-
$(this).addClass('hide');
450-
$(`#code-comments-${id}`).addClass('hide');
451-
$(`#code-preview-${id}`).addClass('hide');
452-
$(`#show-outdated-${id}`).removeClass('hide');
449+
$(this).addClass('gt-hidden');
450+
$(`#code-comments-${id}`).addClass('gt-hidden');
451+
$(`#code-preview-${id}`).addClass('gt-hidden');
452+
$(`#show-outdated-${id}`).removeClass('gt-hidden');
453453
});
454454

455455
$(document).on('click', 'button.comment-form-reply', async function (e) {

web_src/less/_base.less

+1-8
Original file line numberDiff line numberDiff line change
@@ -1807,16 +1807,9 @@ footer {
18071807
}
18081808
}
18091809

1810+
// TODO: refactor to use ".gt-hidden" instead (a simple search&replace should do the trick)
18101811
.hide {
18111812
display: none;
1812-
1813-
&.show-outdated {
1814-
display: none !important;
1815-
}
1816-
1817-
&.hide-outdated {
1818-
display: none !important;
1819-
}
18201813
}
18211814

18221815
.center:not(.popup) {

web_src/less/_review.less

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
.show-outdated,
5858
.hide-outdated {
5959
&:extend(.unselectable);
60-
display: block !important;
6160

6261
&:hover {
6362
text-decoration: underline;

web_src/less/helpers.less

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
/* below class names match Tailwind CSS */
2323
.gt-pointer-events-none { pointer-events: none !important; }
2424
.gt-relative { position: relative !important; }
25-
.gt-hidden { display: none !important; }
2625

2726
.gt-mono {
2827
font-family: var(--fonts-monospace) !important;
@@ -181,3 +180,6 @@
181180
.gt-w-100-small { width: 100% !important; }
182181
.gt-js-small { justify-content: flex-start !important; }
183182
}
183+
184+
// gt-hidden must be placed after all other "display: xxx !important" classes to win the hidden chance
185+
.gt-hidden { display: none !important; }

0 commit comments

Comments
 (0)