mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Refactor "delete-button" to "link-action" (#34962)
This commit is contained in:
		| @@ -408,7 +408,10 @@ | ||||
|  | ||||
| 				<div class="field"> | ||||
| 					<button class="ui primary button">{{ctx.Locale.Tr "admin.auths.update"}}</button> | ||||
| 					<button class="ui red button delete-button" data-url="{{$.Link}}/delete" data-id="{{.Source.ID}}">{{ctx.Locale.Tr "admin.auths.delete"}}</button> | ||||
| 					<button class="ui red button link-action" data-url="{{$.Link}}/delete?id={{.Source.ID}}" | ||||
| 						data-modal-confirm-header="{{ctx.Locale.Tr "admin.auths.delete_auth_title"}}" | ||||
| 						data-modal-confirm-content="{{ctx.Locale.Tr "admin.auths.delete_auth_desc"}}" | ||||
| 					>{{ctx.Locale.Tr "admin.auths.delete"}}</button> | ||||
| 				</div> | ||||
| 			</form> | ||||
| 		</div> | ||||
| @@ -424,16 +427,4 @@ | ||||
| 			<p class="oauth2">{{ctx.Locale.Tr "admin.auths.tips.oauth2.general.tip"}} <b id="oauth2-callback-url"></b></p> | ||||
| 		</div> | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "admin.auths.delete_auth_title"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "admin.auths.delete_auth_desc"}}</p> | ||||
| 	</div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
|  | ||||
| {{template "admin/layout_footer" .}} | ||||
|   | ||||
| @@ -72,7 +72,12 @@ | ||||
| 							</td> | ||||
| 							<td>{{FileSize .CalculateBlobSize}}</td> | ||||
| 							<td>{{DateUtils.AbsoluteShort .Version.CreatedUnix}}</td> | ||||
| 							<td><a class="delete-button" href="" data-url="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}" data-id="{{.Version.ID}}" data-name="{{.Package.Name}}" data-data-version="{{.Version.Version}}">{{svg "octicon-trash"}}</a></td> | ||||
| 							<td> | ||||
| 								<a class="text red show-modal" href data-modal="#admin-package-delete-modal" | ||||
| 									data-modal-form.action="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}&id={{.Version.ID}}" | ||||
| 									data-modal-package-name="{{.Package.Name}}" data-modal-package-version="{{.Version.Version}}" | ||||
| 								>{{svg "octicon-trash"}}</a> | ||||
| 							</td> | ||||
| 						</tr> | ||||
| 					{{else}} | ||||
| 						<tr><td class="tw-text-center" colspan="10">{{ctx.Locale.Tr "no_results_found"}}</td></tr> | ||||
| @@ -84,15 +89,13 @@ | ||||
| 		{{template "base/paginate" .}} | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "packages.settings.delete"}} | ||||
| 	</div> | ||||
| <form class="ui small modal form-fetch-action" method="post" id="admin-package-delete-modal"> | ||||
| 	{{.CsrfTokenHtml}} | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "packages.settings.delete"}}</div> | ||||
| 	<div class="content"> | ||||
| 		{{ctx.Locale.Tr "packages.settings.delete.notice" (HTMLFormat `<span class="%s"></span>` "name") (HTMLFormat `<span class="%s"></span>` "dataVersion")}} | ||||
| 		{{ctx.Locale.Tr "packages.settings.delete.notice" (HTMLFormat `<span class="%s"></span>` "package-name") (HTMLFormat `<span class="%s"></span>` "package-version")}} | ||||
| 	</div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
| </form> | ||||
|  | ||||
| {{template "admin/layout_footer" .}} | ||||
|   | ||||
| @@ -84,7 +84,12 @@ | ||||
| 							<td>{{FileSize .LFSSize}}</td> | ||||
| 							<td>{{DateUtils.AbsoluteShort .UpdatedUnix}}</td> | ||||
| 							<td>{{DateUtils.AbsoluteShort .CreatedUnix}}</td> | ||||
| 							<td><a class="delete-button" href="" data-url="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}" data-id="{{.ID}}" data-name="{{.Name}}">{{svg "octicon-trash"}}</a></td> | ||||
| 							<td> | ||||
| 								<a class="text red show-modal" href data-modal="#admin-repo-delete-modal" | ||||
| 									data-modal-form.action="{{$.Link}}/delete?page={{$.Page.Paginater.Current}}&sort={{$.SortType}}&id={{.ID}}" | ||||
| 									data-modal-repo-name="{{.Name}}" | ||||
| 								>{{svg "octicon-trash"}}</a> | ||||
| 							</td> | ||||
| 						</tr> | ||||
| 					{{else}} | ||||
| 						<tr><td class="tw-text-center" colspan="12">{{ctx.Locale.Tr "no_results_found"}}</td></tr> | ||||
| @@ -96,17 +101,15 @@ | ||||
| 		{{template "base/paginate" .}} | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.settings.delete"}} | ||||
| 	</div> | ||||
| <form class="ui small modal form-fetch-action" id="admin-repo-delete-modal" method="post"> | ||||
| 	{{.CsrfTokenHtml}} | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.settings.delete"}}</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.settings.delete_desc"}}</p> | ||||
| 		{{ctx.Locale.Tr "repo.settings.delete_notices_2" (HTMLFormat `<span class="%s"></span>` "name")}}<br> | ||||
| 		{{ctx.Locale.Tr "repo.settings.delete_notices_2" (HTMLFormat `<span class="%s"></span>` "repo-name")}}<br> | ||||
| 		{{ctx.Locale.Tr "repo.settings.delete_notices_fork_1"}}<br> | ||||
| 	</div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
| </form> | ||||
|  | ||||
| {{template "admin/layout_footer" .}} | ||||
|   | ||||
| @@ -67,7 +67,7 @@ | ||||
| 					{{else}} | ||||
| 						<a class="link-action flex-text-inline" href data-url="{{.Link ctx}}/close">{{svg "octicon-skip" 14}}{{ctx.Locale.Tr "repo.projects.close"}}</a> | ||||
| 					{{end}} | ||||
| 					<a class="delete-button flex-text-inline" href="#" data-url="{{.Link ctx}}/delete">{{svg "octicon-trash" 14}}{{ctx.Locale.Tr "repo.issues.label_delete"}}</a> | ||||
| 					<a class="link-action flex-text-inline text red" href data-modal-confirm="#repo-project-delete-modal" data-url="{{.Link ctx}}/delete">{{svg "octicon-trash" 14}}{{ctx.Locale.Tr "repo.issues.label_delete"}}</a> | ||||
| 				</div> | ||||
| 				{{end}} | ||||
| 			</div> | ||||
| @@ -81,14 +81,9 @@ | ||||
| </div> | ||||
|  | ||||
| {{if and $.CanWriteProjects (not $.Repository.IsArchived)}} | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.projects.deletion"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.projects.deletion_desc"}}</p> | ||||
| 	</div> | ||||
| <div class="ui small modal" id="repo-project-delete-modal"> | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.projects.deletion"}}</div> | ||||
| 	<div class="content"><p>{{ctx.Locale.Tr "repo.projects.deletion_desc"}}</p></div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
| {{end}} | ||||
|   | ||||
| @@ -76,7 +76,7 @@ | ||||
| 								{{else}} | ||||
| 									<a class="link-action flex-text-inline" href data-url="{{$.Link}}/{{.ID}}/close">{{svg "octicon-x" 14}}{{ctx.Locale.Tr "repo.milestones.close"}}</a> | ||||
| 								{{end}} | ||||
| 								<a class="delete-button flex-text-inline" href="#" data-url="{{$.RepoLink}}/milestones/delete" data-id="{{.ID}}">{{svg "octicon-trash" 14}}{{ctx.Locale.Tr "repo.issues.label_delete"}}</a> | ||||
| 								<a class="link-action flex-text-inline text red" href data-modal-confirm="#repo-milestone-delete-modal" data-url="{{$.RepoLink}}/milestones/delete?id={{.ID}}">{{svg "octicon-trash" 14}}{{ctx.Locale.Tr "repo.issues.label_delete"}}</a> | ||||
| 							</div> | ||||
| 						{{end}} | ||||
| 					</div> | ||||
| @@ -92,15 +92,11 @@ | ||||
| </div> | ||||
|  | ||||
| {{if or .CanWriteIssues .CanWritePulls}} | ||||
| 	<div class="ui g-modal-confirm delete modal"> | ||||
| 		<div class="header"> | ||||
| 			{{svg "octicon-trash"}} | ||||
| 			{{ctx.Locale.Tr "repo.milestones.deletion"}} | ||||
| 		</div> | ||||
| 		<div class="content"> | ||||
| 			<p>{{ctx.Locale.Tr "repo.milestones.deletion_desc"}}</p> | ||||
| 		</div> | ||||
| 	<div class="ui small modal" id="repo-milestone-delete-modal"> | ||||
| 		<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.milestones.deletion"}}</div> | ||||
| 		<div class="content"><p>{{ctx.Locale.Tr "repo.milestones.deletion_desc"}}</p></div> | ||||
| 		{{template "base/modal_actions_confirm" .}} | ||||
| 	</div> | ||||
| {{end}} | ||||
|  | ||||
| {{template "base/footer" .}} | ||||
|   | ||||
| @@ -105,7 +105,7 @@ | ||||
| 							<a class="ui small button" href="{{.RepoLink}}/releases"> | ||||
| 								{{ctx.Locale.Tr "repo.release.cancel"}} | ||||
| 							</a> | ||||
| 							<a class="ui small red button delete-button" data-url="{{$.RepoLink}}/releases/delete" data-id="{{.ID}}"> | ||||
| 							<a class="ui small red button link-action" data-modal-confirm="#repo-release-delete-modal" data-url="{{$.RepoLink}}/releases/delete?id={{.ID}}"> | ||||
| 								{{ctx.Locale.Tr "repo.release.delete_release"}} | ||||
| 							</a> | ||||
| 							{{if .IsDraft}} | ||||
| @@ -129,15 +129,11 @@ | ||||
| </div> | ||||
|  | ||||
| {{if .PageIsEditRelease}} | ||||
| 	<div class="ui g-modal-confirm delete modal"> | ||||
| 		<div class="header"> | ||||
| 			{{svg "octicon-trash"}} | ||||
| 			{{ctx.Locale.Tr "repo.release.deletion"}} | ||||
| 		</div> | ||||
| 		<div class="content"> | ||||
| 			<p>{{ctx.Locale.Tr "repo.release.deletion_desc"}}</p> | ||||
| 		</div> | ||||
| 	<div class="ui small modal" id="repo-release-delete-modal"> | ||||
| 		<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.release.deletion"}}</div> | ||||
| 		<div class="content"><p>{{ctx.Locale.Tr "repo.release.deletion_desc"}}</p></div> | ||||
| 		{{template "base/modal_actions_confirm" .}} | ||||
| 	</div> | ||||
| {{end}} | ||||
|  | ||||
| {{template "base/footer" .}} | ||||
|   | ||||
| @@ -49,8 +49,8 @@ | ||||
| 								</div> | ||||
| 							</div> | ||||
| 							<div class="flex-item-trailing"> | ||||
| 								<a class="rm ui tiny button" href="{{$.Repository.Link}}/settings/branches/edit?rule_name={{.RuleName}}">{{ctx.Locale.Tr "repo.settings.edit_protected_branch"}}</a> | ||||
| 								<button class="ui red tiny button delete-button" data-url="{{$.Repository.Link}}/settings/branches/{{.ID}}/delete" data-id="{{.ID}}"> | ||||
| 								<a class="ui tiny button" href="{{$.Repository.Link}}/settings/branches/edit?rule_name={{.RuleName}}">{{ctx.Locale.Tr "repo.settings.edit_protected_branch"}}</a> | ||||
| 								<button class="ui red tiny button link-action" data-modal-confirm="#repo-branch-protection-delete-modal" data-url="{{$.Repository.Link}}/settings/branches/{{.ID}}/delete?id={{.ID}}"> | ||||
| 									{{ctx.Locale.Tr "repo.settings.protected_branch.delete_rule"}} | ||||
| 								</button> | ||||
| 							</div> | ||||
| @@ -65,14 +65,9 @@ | ||||
| 		{{end}} | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.settings.protected_branch_deletion"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.settings.protected_branch_deletion_desc"}}</p> | ||||
| 	</div> | ||||
| <div class="ui small modal" id="repo-branch-protection-delete-modal"> | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.settings.protected_branch_deletion"}}</div> | ||||
| 	<div class="content"><p>{{ctx.Locale.Tr "repo.settings.protected_branch_deletion_desc"}}</p></div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
|  | ||||
|   | ||||
| @@ -29,7 +29,7 @@ | ||||
| 									</div> | ||||
| 								</div> | ||||
| 							</div> | ||||
| 							<button class="ui red tiny button inline delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}"> | ||||
| 							<button class="ui red tiny button link-action" data-modal-confirm="#repo-collaborator-delete-modal" data-url="{{$.Link}}/delete?id={{.ID}}"> | ||||
| 								{{ctx.Locale.Tr "repo.settings.delete_collaborator"}} | ||||
| 							</button> | ||||
| 						</div> | ||||
| @@ -95,7 +95,7 @@ | ||||
| 							</div> | ||||
| 							{{if $allowedToChangeTeams}} | ||||
| 								<div class="flex-item-trailing" {{if .IncludesAllRepositories}} data-tooltip-content="{{ctx.Locale.Tr "repo.settings.delete_team_tip"}}"{{end}}> | ||||
| 									<button class="ui red tiny button inline delete-button {{if .IncludesAllRepositories}}disabled{{end}}" data-url="{{$.Link}}/team/delete" data-id="{{.ID}}"> | ||||
| 									<button class="ui red tiny button link-action {{if .IncludesAllRepositories}}disabled{{end}}" data-modal-confirm="#repo-collaborator-delete-modal" data-url="{{$.Link}}/team/delete?id={{.ID}}"> | ||||
| 											{{ctx.Locale.Tr "repo.settings.delete_collaborator"}} | ||||
| 									</button> | ||||
| 								</div> | ||||
| @@ -123,14 +123,9 @@ | ||||
| 		{{end}} | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.settings.collaborator_deletion"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.settings.collaborator_deletion_desc"}}</p> | ||||
| 	</div> | ||||
| <div class="ui small modal" id="repo-collaborator-delete-modal"> | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.settings.collaborator_deletion"}}</div> | ||||
| 	<div class="content"><p>{{ctx.Locale.Tr "repo.settings.collaborator_deletion_desc"}}</p></div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
|  | ||||
|   | ||||
| @@ -59,7 +59,7 @@ | ||||
| 								</div> | ||||
| 							</div> | ||||
| 							<div class="flex-item-trailing"> | ||||
| 								<button class="ui red tiny button delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}"> | ||||
| 								<button class="ui red tiny button link-action" data-modal-confirm="#repo-deploy-key-delete-modal" data-url="{{$.Link}}/delete?id={{.ID}}"> | ||||
| 									{{ctx.Locale.Tr "settings.delete_key"}} | ||||
| 								</button> | ||||
| 							</div> | ||||
| @@ -72,14 +72,9 @@ | ||||
| 		</div> | ||||
| 	</div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.settings.deploy_key_deletion"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.settings.deploy_key_deletion_desc"}}</p> | ||||
| 	</div> | ||||
| <div class="ui small modal" id="repo-deploy-key-delete-modal"> | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.settings.deploy_key_deletion"}}</div> | ||||
| 	<div class="content"><p>{{ctx.Locale.Tr "repo.settings.deploy_key_deletion_desc"}}</p></div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
|  | ||||
|   | ||||
| @@ -50,7 +50,7 @@ | ||||
| 					{{if and .CanWriteWiki (not .Repository.IsMirror)}} | ||||
| 						<a class="ui small button" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_edit">{{ctx.Locale.Tr "repo.wiki.edit_page_button"}}</a> | ||||
| 						<a class="ui small primary button" href="{{.RepoLink}}/wiki?action=_new">{{ctx.Locale.Tr "repo.wiki.new_page_button"}}</a> | ||||
| 						<a class="ui small red button delete-button" href="" data-url="{{.RepoLink}}/wiki/{{.PageURL}}?action=_delete" data-id="{{.PageURL}}">{{ctx.Locale.Tr "repo.wiki.delete_page_button"}}</a> | ||||
| 						<a class="ui small red button link-action" href data-modal-confirm="#repo-wiki-delete-page-modal" data-url="{{.RepoLink}}/wiki/{{.PageURL}}?action=_delete">{{ctx.Locale.Tr "repo.wiki.delete_page_button"}}</a> | ||||
| 					{{end}} | ||||
| 				</div> | ||||
| 			</div> | ||||
| @@ -96,14 +96,9 @@ | ||||
| 	</div> | ||||
| </div> | ||||
|  | ||||
| <div class="ui g-modal-confirm delete modal"> | ||||
| 	<div class="header"> | ||||
| 		{{svg "octicon-trash"}} | ||||
| 		{{ctx.Locale.Tr "repo.wiki.delete_page_button"}} | ||||
| 	</div> | ||||
| 	<div class="content"> | ||||
| 		<p>{{ctx.Locale.Tr "repo.wiki.delete_page_notice_1" $title}}</p> | ||||
| 	</div> | ||||
| <div class="ui small modal" id="repo-wiki-delete-page-modal"> | ||||
| 	<div class="header">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.wiki.delete_page_button"}}</div> | ||||
| 	<div class="content"><p>{{ctx.Locale.Tr "repo.wiki.delete_page_notice_1" $title}}</p></div> | ||||
| 	{{template "base/modal_actions_confirm" .}} | ||||
| </div> | ||||
|  | ||||
|   | ||||
| @@ -145,11 +145,12 @@ function onShowModalClick(el: HTMLElement, e: MouseEvent) { | ||||
|  | ||||
|     const attrTargetCombo = attrib.name.substring(modalAttrPrefix.length); | ||||
|     const [attrTargetName, attrTargetProp] = attrTargetCombo.split('.'); | ||||
|     // try to find target by: "#target" -> "[name=target]" -> ".target" -> "<target> tag" | ||||
|     // try to find target by: "#target" -> "[name=target]" -> ".target" -> "<target> tag", and then try the modal itself | ||||
|     const attrTarget = elModal.querySelector(`#${attrTargetName}`) || | ||||
|       elModal.querySelector(`[name=${attrTargetName}]`) || | ||||
|       elModal.querySelector(`.${attrTargetName}`) || | ||||
|       elModal.querySelector(`${attrTargetName}`); | ||||
|       elModal.querySelector(`${attrTargetName}`) || | ||||
|       (elModal.matches(`${attrTargetName}`) || elModal.matches(`#${attrTargetName}`) || elModal.matches(`.${attrTargetName}`) ? elModal : null); | ||||
|     if (!attrTarget) { | ||||
|       if (!window.config.runModeIsProd) throw new Error(`attr target "${attrTargetCombo}" not found for modal`); | ||||
|       continue; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 wxiaoguang
					wxiaoguang