Skip to content

Commit d21ed73

Browse files
committed
fix
1 parent 10cf202 commit d21ed73

File tree

3 files changed

+45
-33
lines changed

3 files changed

+45
-33
lines changed

templates/repo/tag/list.tmpl

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
{{template "base/alert" .}}
66
{{template "repo/release_tag_header" .}}
77
<h4 class="ui top attached header">
8-
<div class="five wide column tw-flex tw-items-center">
9-
{{.TagCount}} {{ctx.Locale.Tr "repo.release.tags"}}
10-
</div>
8+
{{.TagCount}} {{ctx.Locale.Tr "repo.release.tags"}}
119
</h4>
1210
{{$canReadReleases := $.Permission.CanRead ctx.Consts.RepoUnitTypeReleases}}
1311
<div class="ui attached segment">
@@ -24,36 +22,36 @@
2422
<td class="tag-list-row">
2523
<h3 class="tag-list-row-title tw-mb-2">
2624
{{if $canReadReleases}}
27-
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
25+
<a class="tag-list-row-link" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
2826
{{else}}
29-
<a class="tag-list-row-link tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
27+
<a class="tag-list-row-link" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a>
3028
{{end}}
3129
</h3>
32-
<div class="download tw-flex tw-items-center">
30+
<div class="flex-text-block muted-links tw-gap-4 tw-flex-wrap">
3331
{{if $.Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
3432
{{if .CreatedUnix}}
35-
<span class="tw-mr-2">{{svg "octicon-clock" 16 "tw-mr-1"}}{{DateUtils.TimeSince .CreatedUnix}}</span>
33+
<span class="flex-text-inline">{{svg "octicon-clock"}}{{DateUtils.TimeSince .CreatedUnix}}</span>
3634
{{end}}
3735

38-
<a class="tw-mr-2 tw-font-mono muted" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .Sha1}}</a>
36+
<a class="flex-text-inline tw-font-mono" href="{{$.RepoLink}}/src/commit/{{.Sha1}}" rel="nofollow">{{svg "octicon-git-commit"}}{{ShortSha .Sha1}}</a>
3937

4038
{{if not $.DisableDownloadSourceArchives}}
41-
<a class="archive-link tw-mr-2 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-1"}}ZIP</a>
42-
<a class="archive-link tw-mr-2 muted" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-1"}}TAR.GZ</a>
39+
<a class="archive-link flex-text-inline" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.zip" rel="nofollow">{{svg "octicon-file-zip"}}ZIP</a>
40+
<a class="archive-link flex-text-inline" href="{{$.RepoLink}}/archive/{{.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}}TAR.GZ</a>
4341
{{end}}
4442

4543
{{if (and $canReadReleases $.CanCreateRelease $release.IsTag)}}
46-
<a class="tw-mr-2 muted" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.new_release"}}</a>
44+
<a class="flex-text-inline" href="{{$.RepoLink}}/releases/new?tag={{.TagName}}">{{svg "octicon-tag"}}{{ctx.Locale.Tr "repo.release.new_release"}}</a>
4745
{{end}}
4846

4947
{{if (and ($.Permission.CanWrite ctx.Consts.RepoUnitTypeCode) $release.IsTag)}}
50-
<a class="ui delete-button tw-mr-2 muted" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}">
51-
{{svg "octicon-trash" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.delete_tag"}}
48+
<a class="flex-text-inline link-action" data-url="{{$.RepoLink}}/tags/delete?id={{.ID}}" data-modal-confirm="#confirm-delete-tag-modal">
49+
{{svg "octicon-trash"}}{{ctx.Locale.Tr "repo.release.delete_tag"}}
5250
</a>
5351
{{end}}
5452

5553
{{if and $canReadReleases (not $release.IsTag)}}
56-
<a class="tw-mr-2 muted" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.detail"}}</a>
54+
<a class="flex-text-inline" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{svg "octicon-tag"}}{{ctx.Locale.Tr "repo.release.detail"}}</a>
5755
{{end}}
5856
{{end}}
5957
</div>
@@ -73,9 +71,8 @@
7371
</div>
7472

7573
{{if $.Permission.CanWrite ctx.Consts.RepoUnitTypeCode}}
76-
<div class="ui g-modal-confirm delete modal">
74+
<div id="confirm-delete-tag-modal" class="ui small modal">
7775
<div class="header">
78-
{{svg "octicon-trash"}}
7976
{{ctx.Locale.Tr "repo.release.delete_tag"}}
8077
</div>
8178
<div class="content">

web_src/js/features/common-fetch-action.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {request} from '../modules/fetch.ts';
22
import {hideToastsAll, showErrorToast} from '../modules/toast.ts';
33
import {addDelegatedEventListener, submitEventSubmitter} from '../utils/dom.ts';
4-
import {confirmModal} from './comp/ConfirmModal.ts';
4+
import {confirmModal, createConfirmModal} from './comp/ConfirmModal.ts';
55
import type {RequestOpts} from '../types.ts';
66
import {ignoreAreYouSure} from '../vendor/jquery.are-you-sure.ts';
77

@@ -111,28 +111,39 @@ export async function submitFormFetchAction(formEl: HTMLFormElement, formSubmitt
111111
async function onLinkActionClick(el: HTMLElement, e: Event) {
112112
// A "link-action" can post AJAX request to its "data-url"
113113
// Then the browser is redirected to: the "redirect" in response, or "data-redirect" attribute, or current URL by reloading.
114-
// If the "link-action" has "data-modal-confirm" attribute, a confirm modal dialog will be shown before taking action.
114+
// If the "link-action" has "data-modal-confirm" attribute, a "confirm modal dialog" will be shown before taking action.
115115
e.preventDefault();
116116
const url = el.getAttribute('data-url');
117117
const doRequest = async () => {
118-
if ('disabled' in el) el.disabled = true; // el could be A or BUTTON, but A doesn't have disabled attribute
118+
if ('disabled' in el) el.disabled = true; // el could be A or BUTTON, but "A" doesn't have the "disabled" attribute
119119
await fetchActionDoRequest(el, url, {method: el.getAttribute('data-link-action-method') || 'POST'});
120120
if ('disabled' in el) el.disabled = false;
121121
};
122122

123-
const modalConfirmContent = el.getAttribute('data-modal-confirm') ||
124-
el.getAttribute('data-modal-confirm-content') || '';
125-
if (!modalConfirmContent) {
123+
let elModal: HTMLElement | null = null;
124+
const dataModalConfirm = el.getAttribute('data-modal-confirm') || '';
125+
if (dataModalConfirm.startsWith('#')) {
126+
// eslint-disable-next-line unicorn/prefer-query-selector
127+
elModal = document.getElementById(dataModalConfirm.substring(1));
128+
}
129+
if (!elModal) {
130+
const modalConfirmContent = dataModalConfirm || el.getAttribute('data-modal-confirm-content') || '';
131+
if (modalConfirmContent) {
132+
const isRisky = el.classList.contains('red') || el.classList.contains('negative');
133+
elModal = createConfirmModal({
134+
header: el.getAttribute('data-modal-confirm-header') || '',
135+
content: modalConfirmContent,
136+
confirmButtonColor: isRisky ? 'red' : 'primary',
137+
});
138+
}
139+
}
140+
141+
if (!elModal) {
126142
await doRequest();
127143
return;
128144
}
129145

130-
const isRisky = el.classList.contains('red') || el.classList.contains('negative');
131-
if (await confirmModal({
132-
header: el.getAttribute('data-modal-confirm-header') || '',
133-
content: modalConfirmContent,
134-
confirmButtonColor: isRisky ? 'red' : 'primary',
135-
})) {
146+
if (await confirmModal(elModal)) {
136147
await doRequest();
137148
}
138149
}

web_src/js/features/comp/ConfirmModal.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {fomanticQuery} from '../../modules/fomantic/base.ts';
55

66
const {i18n} = window.config;
77

8-
export function confirmModal({header = '', content = '', confirmButtonColor = 'primary'} = {}): Promise<boolean> {
9-
return new Promise((resolve) => {
10-
const headerHtml = header ? `<div class="header">${htmlEscape(header)}</div>` : '';
11-
const modal = createElementFromHTML(`
8+
export function createConfirmModal({header = '', content = '', confirmButtonColor = 'primary'} = {}): HTMLElement {
9+
const headerHtml = header ? `<div class="header">${htmlEscape(header)}</div>` : '';
10+
const modal = createElementFromHTML(`
1211
<div class="ui g-modal-confirm modal">
1312
${headerHtml}
1413
<div class="content">${htmlEscape(content)}</div>
@@ -18,7 +17,12 @@ export function confirmModal({header = '', content = '', confirmButtonColor = 'p
1817
</div>
1918
</div>
2019
`);
21-
document.body.append(modal);
20+
document.body.append(modal);
21+
return modal;
22+
}
23+
24+
export function confirmModal(modal: HTMLElement): Promise<boolean> {
25+
return new Promise((resolve) => {
2226
const $modal = fomanticQuery(modal);
2327
$modal.modal({
2428
onApprove() {

0 commit comments

Comments
 (0)