Skip to content

Commit 373bab9

Browse files
Properly truncate system notices (go-gitea#11714)
Backport go-gitea#11714 * Properly truncate system notices As noted in go-gitea#11658 the system notifications list will always suffix system notices with ... even when the notice is longer than 120 characters. Instead we should use .text.truncate to auto truncate and make the notices clickable to view their details. Signed-off-by: Andrew Thornton <[email protected]> * As per @CirnoT make table cell clickable * ensure that pre wraps Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent a34826b commit 373bab9

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

templates/admin/notice.tmpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{{.i18n.Tr "admin.notices.system_notice_list"}} ({{.i18n.Tr "admin.total" .Total}})
88
</h4>
99
<div class="ui attached table segment">
10-
<table class="ui very basic select selectable table">
10+
<table id="notice-table" class="ui very basic select selectable table">
1111
<thead>
1212
<tr>
1313
<th></th>
@@ -28,9 +28,9 @@
2828
</td>
2929
<td>{{.ID}}</td>
3030
<td>{{$.i18n.Tr .TrStr}}</td>
31-
<td>{{SubStr .Description 0 120}}...</td>
32-
<td><span class="poping up" data-content="{{.CreatedUnix.AsTime}}" data-variation="inverted tiny">{{.CreatedUnix.FormatShort}}</span></td>
33-
<td><a href="#"><i class="browser icon view-detail" data-content="{{.Description}}"></i></a></td>
31+
<td class="view-detail"><span class="notice-description text truncate">{{.Description}}</span></td>
32+
<td><span class="notice-created-time poping up" data-content="{{.CreatedUnix.AsTime}}" data-variation="inverted tiny">{{.CreatedUnix.FormatShort}}</span></td>
33+
<td><a href="#"><i class="browser icon view-detail"></i></a></td>
3434
</tr>
3535
{{end}}
3636
</tbody>
@@ -73,10 +73,11 @@
7373
</div>
7474
</div>
7575

76-
<div class="ui modal" id="detail-modal">
76+
<div class="ui modal admin" id="detail-modal">
7777
<i class="close icon"></i>
7878
<div class="header">{{$.i18n.Tr "admin.notices.view_detail_header"}}</div>
7979
<div class="content">
80+
<div class="sub header"></div>
8081
<pre></pre>
8182
</div>
8283
</div>

web_src/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,8 @@ function initAdmin() {
18641864

18651865
// Attach view detail modals
18661866
$('.view-detail').on('click', function () {
1867-
$detailModal.find('.content pre').text($(this).data('content'));
1867+
$detailModal.find('.content pre').text($(this).parents('tr').find('.notice-description').text());
1868+
$detailModal.find('.sub.header').text($(this).parents('tr').find('.notice-created-time').text());
18681869
$detailModal.modal('show');
18691870
return false;
18701871
});

web_src/less/_admin.less

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,21 @@
7575
white-space: pre-wrap;
7676
word-wrap: break-word;
7777
}
78+
79+
#notice-table {
80+
.notice-description {
81+
@media only screen and (max-width: 767px) {
82+
max-width: 80vw;
83+
}
84+
@media only screen and (max-width: 991px) and (min-width: 768px) {
85+
max-width: 360px;
86+
}
87+
@media only screen and (min-width: 992px) and (max-width: 1199.98px) {
88+
max-width: 510px;
89+
}
90+
@media only screen and (min-width: 1200px) {
91+
max-width: 640px;
92+
}
93+
}
94+
}
7895
}

0 commit comments

Comments
 (0)