diff options
Diffstat (limited to 'templates/repo')
216 files changed, 13551 insertions, 0 deletions
diff --git a/templates/repo/actions/dispatch.tmpl b/templates/repo/actions/dispatch.tmpl new file mode 100644 index 0000000..48c2aa5 --- /dev/null +++ b/templates/repo/actions/dispatch.tmpl @@ -0,0 +1,101 @@ +<div class="ui info message tw-flex tw-items-center"> + <span> + {{ctx.Locale.Tr "actions.workflow.dispatch.trigger_found"}} + </span> + <div class="ui dropdown custom tw-ml-4" id="workflow_dispatch_dropdown"> + <button class="ui compact small basic button tw-flex"> + <span class="text">{{ctx.Locale.Tr "actions.workflow.dispatch.run"}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </button> + <div class="menu"> + <div class="message ui form"> + <div class="field"> + <label>{{ctx.Locale.Tr "actions.workflow.dispatch.use_from"}}</label> + {{template "repo/branch_dropdown" dict + "root" (dict + "IsViewBranch" true + "BranchName" .Repo.BranchName + "CommitID" .Repo.CommitID + "RepoLink" .Repo.RepoLink + "Repository" .Repo.Repository + ) + "disableCreateBranch" true + "branchForm" "branch-dropdown-form" + "setAction" false + "submitForm" false + }} + </div> + + <form method="post" action="{{.Repo.RepoLink}}/actions/manual" id="branch-dropdown-form"> + {{range $i, $key := .CurWorkflowDispatchInputKeys}} + {{$val := index $.CurWorkflowDispatch.Inputs $key}} + <div class="{{if $val.Required}}required {{end}}field"> + {{if eq $val.Type "boolean"}} + <div class="ui checkbox"> + <label><strong>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</strong></label> + {{/* These two inputs need to stay in exactly this order (checkbox first, hidden second) or boolean fields wont work correctly! */}} + <input type="checkbox" name="inputs[{{$key}}]" value="on" {{if eq $val.Default "true"}}checked{{end}}> + <input type="hidden" name="inputs[{{$key}}]" value="off" autocomplete="off"> + </div> + {{else}} + <label>{{if $val.Description}}{{$val.Description}}{{else}}{{$key}}{{end}}</label> + {{if eq $val.Type "number"}} + <input {{if $val.Required}}required{{end}} type="number" name="inputs[{{$key}}]" {{if $val.Default}}value="{{$val.Default}}"{{end}}> + {{else if eq $val.Type "string"}} + <input {{if $val.Required}}required{{end}} type="text" name="inputs[{{$key}}]" {{if $val.Default}}value="{{$val.Default}}"{{end}}> + {{else if eq $val.Type "choice"}} + <div class="ui selection dropdown"> + <input name="inputs[{{$key}}]" type="hidden" value="{{$val.Default}}"> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="text"></div> + <div class="menu"> + {{range $opt := $val.Options}} + <div data-value="{{$opt}}" class="{{if eq $val.Default $opt}}active selected {{end}}item">{{$opt}}</div> + {{end}} + </div> + </div> + {{else}} + <strong>{{ctx.Locale.Tr "actions.workflow.dispatch.invalid_input_type" $val.Type}}</strong> + {{end}} + {{end}} + </div> + {{end}} + + {{if .WarnDispatchInputsLimit}} + <div class="text yellow tw-mb-4"> + {{svg "octicon-alert"}} {{ctx.Locale.Tr "actions.workflow.dispatch.warn_input_limit" .DispatchInputsLimit}} + </div> + {{end}} + + {{.CsrfTokenHtml}} + <input type="hidden" name="ref" value="{{if $.Repo.BranchName}}{{$.Repo.BranchName}}{{else}}{{$.Repo.Repository.DefaultBranch}}{{end}}"> + <input type="hidden" name="workflow" value="{{$.CurWorkflow}}"> + <input type="hidden" name="actor" value="{{$.CurActor}}"> + <input type="hidden" name="status" value="{{$.CurStatus}}"> + <button type="submit" id="workflow-dispatch-submit" class="ui primary small compact button">{{ctx.Locale.Tr "actions.workflow.dispatch.run"}}</button> + </form> + </div> + </div> + </div> + <script> + window.addEventListener('load', () => { + const dropdown = $('#workflow_dispatch_dropdown'); + const menu = dropdown.find('> .menu'); + $(document.body).on('click', (ev) => { + if (!dropdown[0].contains(ev.target) && menu.hasClass('visible')) { + menu.transition({ animation: 'slide down out', duration: 200, queue: false }); + } + }); + dropdown.on('click', (ev) => { + const inMenu = $(ev.target).closest(menu).length !== 0; + if (inMenu) return; + ev.stopPropagation(); + if (menu.hasClass('visible')) { + menu.transition({ animation: 'slide down out', duration: 200, queue: false }); + } else { + menu.transition({ animation: 'slide down in', duration: 200, queue: true }); + } + }); + }); + </script> +</div> diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl new file mode 100644 index 0000000..263530f --- /dev/null +++ b/templates/repo/actions/list.tmpl @@ -0,0 +1,92 @@ +{{template "base/head" .}} +<div class="page-content repository actions"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + + {{if .HasWorkflowsOrRuns}} + <div class="ui stackable grid"> + <div class="four wide column"> + <div class="ui fluid vertical menu"> + <a class="item{{if not $.CurWorkflow}} active{{end}}" href="?actor={{$.CurActor}}&status={{$.CurStatus}}">{{ctx.Locale.Tr "actions.runs.all_workflows"}}</a> + {{range .workflows}} + <a class="item{{if eq .Entry.Name $.CurWorkflow}} active{{end}}" href="?workflow={{.Entry.Name}}&actor={{$.CurActor}}&status={{$.CurStatus}}">{{.Entry.Name}} + {{if .ErrMsg}} + <span data-tooltip-content="{{.ErrMsg}}"> + {{svg "octicon-alert" 16 "text red"}} + </span> + {{end}} + + {{if $.ActionsConfig.IsWorkflowDisabled .Entry.Name}} + <div class="ui red label">{{ctx.Locale.Tr "disabled"}}</div> + {{end}} + </a> + {{end}} + </div> + </div> + <div class="twelve wide column content"> + <div class="ui secondary filter menu tw-justify-end tw-flex tw-items-center"> + <!-- Actor --> + <div class="ui{{if not .Actors}} disabled{{end}} dropdown jump item"> + <span class="text">{{ctx.Locale.Tr "actions.runs.actor"}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search"}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "actions.runs.actor"}}"> + </div> + <a class="item{{if not $.CurActor}} active{{end}}" href="?workflow={{$.CurWorkflow}}&status={{$.CurStatus}}&actor=0"> + {{ctx.Locale.Tr "actions.runs.actors_no_select"}} + </a> + {{range .Actors}} + <a class="item{{if eq .ID $.CurActor}} active{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{.ID}}&status={{$.CurStatus}}"> + {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} + </a> + {{end}} + </div> + </div> + <!-- Status --> + <div class="ui dropdown jump item"> + <span class="text">{{ctx.Locale.Tr "actions.runs.status"}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search"}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "actions.runs.status"}}"> + </div> + <a class="item{{if not $.CurStatus}} active{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status=0"> + {{ctx.Locale.Tr "actions.runs.status_no_select"}} + </a> + {{range .StatusInfoList}} + <a class="item{{if eq .Status $.CurStatus}} active{{end}}" href="?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{.Status}}"> + {{.DisplayedStatus}} + </a> + {{end}} + </div> + </div> + + {{if .AllowDisableOrEnableWorkflow}} + <button class="ui jump dropdown btn interact-bg tw-p-2"> + {{svg "octicon-kebab-horizontal"}} + <div class="menu"> + <a class="item link-action" data-url="{{$.Link}}/{{if .CurWorkflowDisabled}}enable{{else}}disable{{end}}?workflow={{$.CurWorkflow}}&actor={{.CurActor}}&status={{$.CurStatus}}"> + {{if .CurWorkflowDisabled}}{{ctx.Locale.Tr "actions.workflow.enable"}}{{else}}{{ctx.Locale.Tr "actions.workflow.disable"}}{{end}} + </a> + </div> + </button> + {{end}} + </div> + + {{if $.CurWorkflowDispatch}} + {{template "repo/actions/dispatch" .}} + {{end}} + + {{template "repo/actions/runs_list" .}} + </div> + </div> + {{else}} + {{template "repo/actions/no_workflows" .}} + {{end}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/actions/no_workflows.tmpl b/templates/repo/actions/no_workflows.tmpl new file mode 100644 index 0000000..88d6e51 --- /dev/null +++ b/templates/repo/actions/no_workflows.tmpl @@ -0,0 +1,8 @@ +<div class="empty-placeholder"> + {{svg "octicon-no-entry" 48}} + <h2>{{ctx.Locale.Tr "actions.runs.no_workflows"}}</h2> + {{if and .CanWriteCode .CanWriteActions}} + <p>{{ctx.Locale.Tr "actions.runs.no_workflows.quick_start" "https://forgejo.org/docs/latest/admin/actions/"}}</p> + {{end}} + <p>{{ctx.Locale.Tr "actions.runs.no_workflows.documentation" "https://forgejo.org/docs/latest/admin/actions/"}}</p> +</div> diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl new file mode 100644 index 0000000..7bab492 --- /dev/null +++ b/templates/repo/actions/runs_list.tmpl @@ -0,0 +1,43 @@ +<div class="flex-list run-list"> + {{if not .Runs}} + <div class="empty-placeholder"> + {{svg "octicon-no-entry" 48}} + <h2>{{if $.IsFiltered}}{{ctx.Locale.Tr "actions.runs.no_results"}}{{else}}{{ctx.Locale.Tr "actions.runs.no_runs"}}{{end}}</h2> + </div> + {{end}} + {{range .Runs}} + <div class="flex-item tw-items-center"> + <div class="flex-item-leading"> + {{template "repo/actions/status" (dict "status" .Status.String)}} + </div> + <div class="flex-item-main"> + <a class="flex-item-title" title="{{.Title}}" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}"> + {{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}} + </a> + <div class="flex-item-body"> + <b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b> - + {{- if .ScheduleID -}} + {{ctx.Locale.Tr "actions.runs.scheduled"}} + {{- else -}} + {{ctx.Locale.Tr "actions.runs.commit"}} + <a href="{{$.RepoLink}}/commit/{{.CommitSHA}}">{{ShortSha .CommitSHA}}</a> + {{ctx.Locale.Tr "actions.runs.pushed_by"}} + <a href="{{.TriggerUser.HomeLink}}">{{.TriggerUser.GetDisplayName}}</a> + {{- end -}} + </div> + </div> + <div class="flex-item-trailing"> + {{if .RefLink}} + <a class="ui label run-list-ref gt-ellipsis" href="{{.RefLink}}">{{.PrettyRef}}</a> + {{else}} + <span class="ui label run-list-ref gt-ellipsis">{{.PrettyRef}}</span> + {{end}} + <div class="run-list-item-right"> + <div class="run-list-meta">{{svg "octicon-calendar" 16}}{{TimeSinceUnix .Updated ctx.Locale}}</div> + <div class="run-list-meta">{{svg "octicon-stopwatch" 16}}{{.Duration}}</div> + </div> + </div> + </div> + {{end}} +</div> +{{template "base/paginate" .}} diff --git a/templates/repo/actions/status.tmpl b/templates/repo/actions/status.tmpl new file mode 100644 index 0000000..a0e02cf --- /dev/null +++ b/templates/repo/actions/status.tmpl @@ -0,0 +1,29 @@ +<!-- This template should be kept the same as web_src/js/components/ActionRunStatus.vue + Please also update the vue file above if this template is modified. + action status accepted: success, skipped, waiting, blocked, running, failure, cancelled, unknown +--> +{{- $size := 16 -}} +{{- if .size -}} +{{- $size = .size -}} +{{- end -}} + +{{- $className := "" -}} +{{- if .className -}} +{{- $className = .className -}} +{{- end -}} + +<span class="tw-flex tw-items-center" data-tooltip-content="{{ctx.Locale.Tr (printf "actions.status.%s" .status)}}"> +{{if eq .status "success"}} + {{svg "octicon-check-circle-fill" $size (printf "text green %s" $className)}} +{{else if eq .status "skipped"}} + {{svg "octicon-skip" $size (printf "text grey %s" $className)}} +{{else if eq .status "waiting"}} + {{svg "octicon-clock" $size (printf "text yellow %s" $className)}} +{{else if eq .status "blocked"}} + {{svg "octicon-blocked" $size (printf "text yellow %s" $className)}} +{{else if eq .status "running"}} + {{svg "octicon-meter" $size (printf "text yellow job-status-rotate %s" $className)}} +{{else if or (eq .status "failure") or (eq .status "cancelled") or (eq .status "unknown")}} + {{svg "octicon-x-circle-fill" $size (printf "text red %s" $className)}} +{{end}} +</span> diff --git a/templates/repo/actions/view.tmpl b/templates/repo/actions/view.tmpl new file mode 100644 index 0000000..b787762 --- /dev/null +++ b/templates/repo/actions/view.tmpl @@ -0,0 +1,33 @@ +{{template "base/head" .}} + +<div class="page-content repository"> + {{template "repo/header" .}} + <div id="repo-action-view" + data-run-index="{{.RunIndex}}" + data-job-index="{{.JobIndex}}" + data-actions-url="{{.ActionsURL}}" + data-workflow-name="{{.WorkflowName}}" + data-workflow-url="{{.WorkflowURL}}" + data-locale-approve="{{ctx.Locale.Tr "repo.diff.review.approve"}}" + data-locale-cancel="{{ctx.Locale.Tr "cancel"}}" + data-locale-rerun="{{ctx.Locale.Tr "rerun"}}" + data-locale-rerun-all="{{ctx.Locale.Tr "rerun_all"}}" + data-locale-status-unknown="{{ctx.Locale.Tr "actions.status.unknown"}}" + data-locale-status-waiting="{{ctx.Locale.Tr "actions.status.waiting"}}" + data-locale-status-running="{{ctx.Locale.Tr "actions.status.running"}}" + data-locale-status-success="{{ctx.Locale.Tr "actions.status.success"}}" + data-locale-status-failure="{{ctx.Locale.Tr "actions.status.failure"}}" + data-locale-status-cancelled="{{ctx.Locale.Tr "actions.status.cancelled"}}" + data-locale-status-skipped="{{ctx.Locale.Tr "actions.status.skipped"}}" + data-locale-status-blocked="{{ctx.Locale.Tr "actions.status.blocked"}}" + data-locale-artifacts-title="{{ctx.Locale.Tr "artifacts"}}" + data-locale-confirm-delete-artifact="{{ctx.Locale.Tr "confirm_delete_artifact"}}" + data-locale-show-timestamps="{{ctx.Locale.Tr "show_timestamps"}}" + data-locale-show-log-seconds="{{ctx.Locale.Tr "show_log_seconds"}}" + data-locale-show-full-screen="{{ctx.Locale.Tr "show_full_screen"}}" + data-locale-download-logs="{{ctx.Locale.Tr "download_logs"}}" + > + </div> +</div> + +{{template "base/footer" .}} diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl new file mode 100644 index 0000000..19a09b9 --- /dev/null +++ b/templates/repo/activity.tmpl @@ -0,0 +1,19 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository commits"> + {{template "repo/header" .}} + <div class="ui container flex-container"> + {{if and (not .IsEmptyRepo) (.Permission.CanRead $.UnitTypeCode)}} + <div class="flex-container-nav"> + {{template "repo/navbar" .}} + </div> + {{end}} + <div class="flex-container-main"> + {{if .PageIsPulse}}{{template "repo/pulse" .}}{{end}} + {{if .PageIsContributors}}{{template "repo/contributors" .}}{{end}} + {{if .PageIsCodeFrequency}}{{template "repo/code_frequency" .}}{{end}} + {{if .PageIsRecentCommits}}{{template "repo/recent_commits" .}}{{end}} + </div> + </div> +</div> +{{template "base/footer" .}} + diff --git a/templates/repo/admin_flags.tmpl b/templates/repo/admin_flags.tmpl new file mode 100644 index 0000000..2a65c9c --- /dev/null +++ b/templates/repo/admin_flags.tmpl @@ -0,0 +1,8 @@ +{{if .Repository.IsFlagged $.Context}} + <div class="ui info message" style="text-align: left"> + <strong>{{ctx.Locale.Tr "repo.admin.enabled_flags"}}</strong> + {{range .Repository.ListFlags $.Context}} + <span class="ui label">{{.Name}}</span> + {{end}} + </div> +{{end}} diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl new file mode 100644 index 0000000..58be0b1 --- /dev/null +++ b/templates/repo/blame.tmpl @@ -0,0 +1,96 @@ +{{if or .UsesIgnoreRevs .FaultyIgnoreRevsFile}} + {{$revsFileLink := URLJoin .RepoLink "src" .BranchNameSubURL "/.git-blame-ignore-revs"}} + {{if .UsesIgnoreRevs}} + <div class="ui info message"> + <p>{{ctx.Locale.Tr "repo.blame.ignore_revs" $revsFileLink "?bypass-blame-ignore=true"}}</p> + </div> + {{else}} + <div class="ui error message"> + <p>{{ctx.Locale.Tr "repo.blame.ignore_revs.failed" $revsFileLink}}</p> + </div> + {{end}} +{{end}} +<div class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content"> + <h4 class="file-header ui top attached header tw-flex tw-items-center tw-justify-between tw-flex-wrap"> + <div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4"> + {{template "repo/file_info" .}} + </div> + <div class="file-header-right file-actions tw-flex tw-items-center tw-flex-wrap"> + <div class="ui buttons"> + <a class="ui tiny button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> + {{if not .IsViewCommit}} + <a class="ui tiny button" href="{{.RepoLink}}/src/commit/{{.CommitID | PathEscape}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> + {{end}} + <a class="ui tiny button" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.normal_view"}}</a> + <a class="ui tiny button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.file_history"}}</a> + <button class="ui tiny button unescape-button">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> + <button class="ui tiny button escape-button tw-hidden">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> + </div> + </div> + </h4> + <div class="ui bottom attached table unstackable segment"> + <div class="file-view code-view unicode-escaped"> + {{if .IsFileTooLarge}} + <table> + <tbody> + <tr> + <td class="gt-text-center tw-p-0.5"><strong>{{ctx.Locale.Tr "repo.file_too_large"}}</strong></td> + </tr> + </tbody> + </table> + {{else}} + <table> + <tbody> + {{range $row := .BlameRows}} + <tr class="{{if and (gt $.CommitCnt 1) ($row.CommitMessage)}}top-line-blame{{end}}"> + <td class="lines-commit"> + <div class="blame-info"> + <div class="blame-data"> + <div class="blame-avatar"> + {{$row.Avatar}} + </div> + <div class="blame-message"> + <a class="suppressed tw-text-text" href="{{$row.CommitURL}}" title="{{$row.CommitMessage}}"> + {{$row.CommitMessage}} + </a> + </div> + <div class="blame-time not-mobile"> + {{$row.CommitSince}} + </div> + </div> + </div> + </td> + <td class="lines-blame-btn"> + {{if $row.PreviousSha}} + <a role="button" class="muted" href="{{$row.PreviousShaURL}}" data-tooltip-content='{{ctx.Locale.Tr "repo.blame_prior"}}'> + {{svg "octicon-versions"}} + </a> + {{end}} + </td> + <td class="lines-num"> + <span id="L{{$row.RowNumber}}" data-line-number="{{$row.RowNumber}}"></span> + </td> + {{if $.EscapeStatus.Escaped}} + <td class="lines-escape"> + {{if $row.EscapeStatus.Escaped}} + <button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $row}}"></button> + {{end}} + </td> + {{end}} + <td rel="L{{$row.RowNumber}}" class="lines-code blame-code chroma"> + <code class="code-inner">{{$row.Code}}</code> + </td> + </tr> + {{end}} + </tbody> + </table> + <div class="code-line-menu tippy-target"> + {{if $.Permission.CanRead $.UnitTypeIssues}} + <a class="item ref-in-new-issue" role="menuitem" data-url-issue-new="{{.RepoLink}}/issues/new" data-url-param-body-link="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}" rel="nofollow noindex">{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}</a> + {{end}} + <a class="item copy-line-permalink" role="menuitem" data-url="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}">{{ctx.Locale.Tr "repo.file_copy_permalink"}}</a> + </div> + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl new file mode 100644 index 0000000..f5bffb0 --- /dev/null +++ b/templates/repo/branch/list.tmpl @@ -0,0 +1,262 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content ui repository branches"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + {{template "repo/sub_menu" .}} + {{if .DefaultBranchBranch}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.default_branch"}} + {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} + <a role="button" class="right" href="{{.RepoLink}}/settings/branches" data-tooltip-content="{{ctx.Locale.Tr "repo.settings.branches.switch_default_branch"}}"> + {{svg "octicon-arrow-switch"}} + </a> + {{end}} + </h4> + + <div class="ui attached table segment"> + <table class="ui very basic striped fixed table single line"> + <tbody> + <tr> + <td> + <div class="flex-text-block"> + <a class="gt-ellipsis" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a> + {{if .DefaultBranchBranch.IsProtected}} + <span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.protected_branch"}}">{{svg "octicon-shield-lock"}}</span> + {{end}} + <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button> + {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}} + </div> + <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated" (TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale)}} {{if .DefaultBranchBranch.DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p> + </td> + <td class="right aligned middle aligned overflow-visible"> + {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} + <button class="btn interact-bg show-create-branch-modal tw-p-2" + data-modal="#create-branch-modal" + data-branch-from="{{$.DefaultBranchBranch.DBBranch.Name}}" + data-branch-from-urlcomponent="{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}" + data-tooltip-content="{{ctx.Locale.Tr "repo.branch.new_branch_from" ($.DefaultBranchBranch.DBBranch.Name)}}" + > + {{svg "octicon-git-branch"}} + </button> + {{end}} + {{if .EnableFeed}} + <a role="button" class="btn interact-bg tw-p-2" href="{{$.FeedURL}}/rss/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">{{svg "octicon-rss"}}</a> + {{end}} + {{if not $.DisableDownloadSourceArchives}} + <div class="ui dropdown btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "repo.branch.download" ($.DefaultBranchBranch.DBBranch.Name)}}"> + {{svg "octicon-download"}} + <div class="menu"> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}.zip" rel="nofollow">{{svg "octicon-file-zip"}} ZIP</a> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}} TAR.GZ</a> + </div> + </div> + {{end}} + {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted) (not $.IsMirror)}} + <button class="btn interact-bg tw-p-2 show-modal show-rename-branch-modal" + data-is-default-branch="true" + data-modal="#rename-branch-modal" + data-old-branch-name="{{$.DefaultBranchBranch.DBBranch.Name}}" + data-tooltip-content="{{ctx.Locale.Tr "repo.branch.rename" ($.DefaultBranchBranch.DBBranch.Name)}}" + > + {{svg "octicon-pencil"}} + </button> + {{end}} + </td> + </tr> + </tbody> + </table> + </div> + {{end}} + + <h4 class="ui top attached header tw-flex tw-items-center tw-justify-between"> + <div class="tw-flex tw-items-center"> + {{ctx.Locale.Tr "repo.branches"}} + </div> + </h4> + + <div class="ui attached segment"> + <form class="ignore-dirty" method="get"> + {{template "shared/search/combo" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.branch_kind")}} + </form> + </div> + + <div class="ui attached table segment"> + <table class="ui very basic striped fixed table single line"> + <tbody> + {{range .Branches}} + <tr> + <td class="eight wide"> + {{if .DBBranch.IsDeleted}} + <div class="flex-text-block"> + <span class="gt-ellipsis">{{.DBBranch.Name}}</span> + <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button> + </div> + <p class="info">{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{TimeSinceUnix .DBBranch.DeletedUnix ctx.Locale}}</p> + {{else}} + <div class="flex-text-block"> + <a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a> + {{if .IsProtected}} + <span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.protected_branch"}}">{{svg "octicon-shield-lock"}}</span> + {{end}} + <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_branch"}}">{{svg "octicon-copy" 14}}</button> + {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}} + </div> + <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated" (TimeSince .DBBranch.CommitTime.AsTime ctx.Locale)}} {{if .DBBranch.Pusher}} {{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} {{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p> + {{end}} + </td> + <td class="two wide ui"> + {{if and (not .DBBranch.IsDeleted) $.DefaultBranchBranch}} + <div class="commit-divergence"> + <div class="bar-group"> + <div class="count count-behind">{{.CommitsBehind}}</div> + {{/* old code bears 0/0.0 = NaN output, so it might output invalid "width: NaNpx", it just works and doesn't cause any problem. */}} + <div class="bar bar-behind" style="width: {{Eval 100 "*" .CommitsBehind "/" "(" .CommitsBehind "+" .CommitsAhead "+" 0.0 ")"}}%"></div> + </div> + <div class="bar-group"> + <div class="count count-ahead">{{.CommitsAhead}}</div> + <div class="bar bar-ahead" style="width: {{Eval 100 "*" .CommitsAhead "/" "(" .CommitsBehind "+" .CommitsAhead "+" 0.0 ")"}}%"></div> + </div> + </div> + {{end}} + </td> + <td class="two wide right aligned"> + {{if not .LatestPullRequest}} + {{if .IsIncluded}} + <span class="ui orange large label" data-tooltip-content="{{ctx.Locale.Tr "repo.branch.included_desc"}}"> + {{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.branch.included"}} + </span> + {{else if and (not .DBBranch.IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}} + <a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}"> + <button id="new-pull-request" class="ui compact basic button tw-mr-0">{{if $.CanPull}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}</button> + </a> + {{end}} + {{else if and .LatestPullRequest.HasMerged .MergeMovedOn}} + {{if and (not .DBBranch.IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}} + <a href="{{$.RepoLink}}/compare/{{PathEscapeSegments $.DefaultBranchBranch.DBBranch.Name}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{PathEscape $.Owner.Name}}:{{end}}{{PathEscapeSegments .DBBranch.Name}}"> + <button id="new-pull-request" class="ui compact basic button tw-mr-0">{{if $.CanPull}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}</button> + </a> + {{end}} + {{else}} + <a href="{{.LatestPullRequest.Issue.Link}}" class="tw-align-middle ref-issue">{{if not .LatestPullRequest.IsSameRepo}}{{.LatestPullRequest.BaseRepo.FullName}}{{end}}#{{.LatestPullRequest.Issue.Index}}</a> + {{if .LatestPullRequest.HasMerged}} + <a href="{{.LatestPullRequest.Issue.Link}}" class="ui purple large label">{{svg "octicon-git-merge" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.pulls.merged"}}</a> + {{else if .LatestPullRequest.Issue.IsClosed}} + <a href="{{.LatestPullRequest.Issue.Link}}" class="ui red large label">{{svg "octicon-git-pull-request-closed" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.issues.closed_title"}}</a> + {{else if .LatestPullRequest.IsWorkInProgress ctx}} + <a href="{{.LatestPullRequest.Issue.Link}}" class="ui grey large label">{{svg "octicon-git-pull-request-draft" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.issues.draft_title"}}</a> + {{else}} + <a href="{{.LatestPullRequest.Issue.Link}}" class="ui green large label">{{svg "octicon-git-pull-request" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.issues.open_title"}}</a> + {{end}} + {{end}} + </td> + <td class="three wide right aligned overflow-visible"> + {{if and $.IsWriter (not $.Repository.IsArchived) (not .DBBranch.IsDeleted)}} + <button class="btn interact-bg tw-p-2 show-modal show-create-branch-modal" + data-branch-from="{{.DBBranch.Name}}" + data-branch-from-urlcomponent="{{PathEscapeSegments .DBBranch.Name}}" + data-tooltip-content="{{ctx.Locale.Tr "repo.branch.new_branch_from" .DBBranch.Name}}" + data-modal="#create-branch-modal" data-name="{{.DBBranch.Name}}" + > + {{svg "octicon-git-branch"}} + </button> + {{end}} + {{if $.EnableFeed}} + <a role="button" class="btn interact-bg tw-p-2" href="{{$.FeedURL}}/rss/branch/{{PathEscapeSegments .DBBranch.Name}}" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">{{svg "octicon-rss"}}</a> + {{end}} + {{if and (not .DBBranch.IsDeleted) (not $.DisableDownloadSourceArchives)}} + <div class="ui dropdown btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "repo.branch.download" (.DBBranch.Name)}}"> + {{svg "octicon-download"}} + <div class="menu"> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments .DBBranch.Name}}.zip" rel="nofollow">{{svg "octicon-file-zip"}} ZIP</a> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments .DBBranch.Name}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip"}} TAR.GZ</a> + </div> + </div> + {{end}} + {{if and $.IsWriter (not $.Repository.IsArchived) (not .DBBranch.IsDeleted) (not $.IsMirror)}} + <button class="btn interact-bg tw-p-2 show-modal show-rename-branch-modal" + data-is-default-branch="false" + data-old-branch-name="{{.DBBranch.Name}}" + data-modal="#rename-branch-modal" + data-tooltip-content="{{ctx.Locale.Tr "repo.branch.rename" (.DBBranch.Name)}}" + > + {{svg "octicon-pencil"}} + </button> + {{end}} + {{if and $.IsWriter (not $.IsMirror) (not $.Repository.IsArchived) (not .IsProtected)}} + {{if .DBBranch.IsDeleted}} + <button class="btn interact-bg tw-p-2 link-action restore-branch-button" data-url="{{$.Link}}/restore?branch_id={{.DBBranch.ID}}&name={{.DBBranch.Name}}&page={{$.Page.Paginater.Current}}" data-tooltip-content="{{ctx.Locale.Tr "repo.branch.restore" (.DBBranch.Name)}}"> + <span class="text blue"> + {{svg "octicon-reply"}} + </span> + </button> + {{else}} + <button class="btn interact-bg tw-p-2 delete-button delete-branch-button" data-url="{{$.Link}}/delete?name={{.DBBranch.Name}}&page={{$.Page.Paginater.Current}}" data-tooltip-content="{{ctx.Locale.Tr "repo.branch.delete" (.DBBranch.Name)}}" data-name="{{.DBBranch.Name}}"> + {{svg "octicon-trash"}} + </button> + {{end}} + {{end}} + </td> + </tr> + {{end}} + </tbody> + </table> + </div> + {{template "base/paginate" .}} + </div> +</div> + +<div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.branch.delete_html"}} <span class="name"></span> + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.branch.delete_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} +</div> + +<div class="ui mini modal" id="create-branch-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.branch.new_branch"}} + </div> + + <form class="ui form" id="create-branch-form" action="" data-base-action="{{.Link}}/_new/branch/" method="post"> + <div class="content"> + {{.CsrfTokenHtml}} + <div class="field"> + {{ctx.Locale.Tr "repo.branch.create_new_branch"}} + <span id="modal-create-branch-from-span"></span> + </div> + <div class="required field"> + <label for="new_branch_name">{{ctx.Locale.Tr "repo.branch.name"}}</label> + <input id="new_branch_name" name="new_branch_name" required> + </div> + </div> + {{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}} + </form> +</div> + +<div class="ui mini modal" id="rename-branch-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.rename_branch"}} + </div> + <form class="ui form" action="{{$.Repository.Link}}/settings/rename_branch" method="post"> + <div class="content"> + {{.CsrfTokenHtml}} + <div class="field default-branch-warning"> + <span class="text red">{{ctx.Locale.Tr "repo.branch.warning_rename_default_branch"}}</span> + </div> + <div class="field"> + <span class="text" data-rename-branch-to="{{ctx.Locale.Tr "repo.branch.rename_branch_to"}}"></span> + </div> + <input name="from" type="hidden" required> + <div class="required field"> + <input name="to" required> + </div> + </div> + {{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}} + </form> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/branch_dropdown.tmpl b/templates/repo/branch_dropdown.tmpl new file mode 100644 index 0000000..dcb1792 --- /dev/null +++ b/templates/repo/branch_dropdown.tmpl @@ -0,0 +1,89 @@ +{{/* Attributes: +* root +* ContainerClasses +* (TODO: search "branch_dropdown" in the template directory) +*/}} +{{$defaultSelectedRefName := $.root.BranchName}} +{{if and .root.IsViewTag (not .noTag)}} + {{$defaultSelectedRefName = .root.TagName}} +{{end}} +{{if eq $defaultSelectedRefName ""}} + {{$defaultSelectedRefName = $.root.Repository.DefaultBranch}} +{{end}} + +{{$type := ""}} +{{if and .root.IsViewTag (not .noTag)}} + {{$type = "tag"}} +{{else if .root.IsViewBranch}} + {{$type = "branch"}} +{{else}} + {{$type = "tree"}} +{{end}} + +{{$showBranchesInDropdown := not .root.HideBranchesInDropdown}} + +<script type="module"> + const data = { + 'textReleaseCompare': {{ctx.Locale.Tr "repo.release.compare"}}, + 'textCreateTag': {{ctx.Locale.Tr "repo.tag.create_tag"}}, + 'textCreateBranch': {{ctx.Locale.Tr "repo.branch.create_branch"}}, + 'textCreateBranchFrom': {{ctx.Locale.Tr "repo.branch.create_from"}}, + 'textBranches': {{ctx.Locale.Tr "repo.branches"}}, + 'textTags': {{ctx.Locale.Tr "repo.tags"}}, + 'textDefaultBranchLabel': {{ctx.Locale.Tr "repo.default_branch_label"}}, + + 'mode': '{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}', + 'showBranchesInDropdown': {{$showBranchesInDropdown}}, + 'searchFieldPlaceholder': '{{if $.noTag}}{{ctx.Locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{ctx.Locale.Tr "repo.find_tag"}}{{end}}...', + 'branchForm': {{$.branchForm}}, + 'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}}, + 'setAction': {{.setAction}}, + 'submitForm': {{.submitForm}}, + 'viewType': {{$type}}, + 'refName': {{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}, + 'commitIdShort': {{ShortSha .root.CommitID}}, + 'tagName': {{.root.TagName}}, + 'branchName': {{.root.BranchName}}, + 'noTag': {{.noTag}}, + 'defaultSelectedRefName': {{$defaultSelectedRefName}}, + 'repoDefaultBranch': {{.root.Repository.DefaultBranch}}, + 'enableFeed': {{.root.EnableFeed}}, + 'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/', + 'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}', + 'branchURLSuffix': '{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}', + 'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if .release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}', + 'tagURLSuffix': '{{if .tagURLSuffix}}{{.tagURLSuffix}}{{else if .release}}...{{if .release.IsDraft}}{{PathEscapeSegments .release.Target}}{{else}}{{if .release.TagName}}{{PathEscapeSegments .release.TagName}}{{else}}{{PathEscapeSegments .release.Sha1}}{{end}}{{end}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}', + 'repoLink': {{.root.RepoLink}}, + 'treePath': {{.root.TreePath}}, + 'branchNameSubURL': {{.root.BranchNameSubURL}}, + 'noResults': {{ctx.Locale.Tr "repo.pulls.no_results"}}, + }; + {{if .release}} + data.release = { + 'tagName': {{.release.TagName}}, + }; + {{end}} + window.config.pageData.branchDropdownDataList = window.config.pageData.branchDropdownDataList || []; + window.config.pageData.branchDropdownDataList.push(data); +</script> + +<div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}"> + {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}} + <div class="ui dropdown custom"> + <button class="branch-dropdown-button gt-ellipsis ui basic small compact button tw-flex tw-m-0"> + <span class="text tw-flex tw-items-center tw-mr-1 gt-ellipsis"> + {{if .release}} + {{ctx.Locale.Tr "repo.release.compare"}} + {{else}} + {{if eq $type "tag"}} + {{svg "octicon-tag"}} + {{else}} + {{svg "octicon-git-branch"}} + {{end}} + <strong ref="dropdownRefName" class="tw-ml-2 tw-inline-block gt-ellipsis">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong> + {{end}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </button> + </div> +</div> diff --git a/templates/repo/cite/cite_buttons.tmpl b/templates/repo/cite/cite_buttons.tmpl new file mode 100644 index 0000000..5a6de23 --- /dev/null +++ b/templates/repo/cite/cite_buttons.tmpl @@ -0,0 +1,8 @@ +<span class="ui citation label primary" id="citation-copy-bibtex" data-text=""> +BibTeX +</span> +<!-- the value will be updated by initCitationFileCopyContent, the code below is used to avoid UI flicking --> +<input id="citation-copy-content" value="" size="1" readonly> +<button class="ui icon button" id="citation-clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy"}}" data-clipboard-target="#citation-copy-content"> + {{svg "octicon-copy"}} +</button> diff --git a/templates/repo/cite/cite_modal.tmpl b/templates/repo/cite/cite_modal.tmpl new file mode 100644 index 0000000..1ce959a --- /dev/null +++ b/templates/repo/cite/cite_modal.tmpl @@ -0,0 +1,20 @@ +<div class="ui small modal" id="cite-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.cite_this_repo"}} + </div> + <div class="content"> + <div class="ui stackable secondary menu"> + <div class="ui action input" id="citation-panel"> + {{template "repo/cite/cite_buttons" .}} + <a id="goto-citation-btn" class="ui basic jump icon button" href="{{$.RepoLink}}/src/{{$.BranchName}}/{{$.CitationFile}}" data-tooltip-content="{{ctx.Locale.Tr "repo.find_file.go_to_file"}}"> + {{svg "octicon-file-moved"}} + </a> + </div> + </div> + </div> + <div class="actions"> + <button class="ui cancel button"> + {{ctx.Locale.Tr "cancel"}} + </button> + </div> +</div> diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl new file mode 100644 index 0000000..89daba9 --- /dev/null +++ b/templates/repo/clone_buttons.tmpl @@ -0,0 +1,15 @@ +<!-- there is always at least one button (by context/repo.go) --> +{{if $.CloneButtonShowHTTPS}} + <button class="ui small button" id="repo-clone-https" data-link="{{$.CloneButtonOriginLink.HTTPS}}"> + HTTPS + </button> +{{end}} +{{if $.CloneButtonShowSSH}} + <button class="ui small button" id="repo-clone-ssh" data-link="{{$.CloneButtonOriginLink.SSH}}"> + SSH + </button> +{{end}} +<input id="repo-clone-url" size="20" class="js-clone-url" value="{{$.CloneButtonOriginLink.HTTPS}}" readonly> +<button class="ui small icon button" id="clipboard-btn" data-tooltip-content="{{ctx.Locale.Tr "copy_url"}}" data-clipboard-target="#repo-clone-url" aria-label="{{ctx.Locale.Tr "copy_url"}}"> + {{svg "octicon-copy" 14}} +</button> diff --git a/templates/repo/clone_script.tmpl b/templates/repo/clone_script.tmpl new file mode 100644 index 0000000..40dae76 --- /dev/null +++ b/templates/repo/clone_script.tmpl @@ -0,0 +1,50 @@ +<script> + // synchronously set clone button states and urls here to avoid flickering + // on page load. initRepoCloneLink calls this when proto changes. + // this applies the protocol-dependant clone url to all elements with the + // `js-clone-url` and `js-clone-url-vsc` classes. + // TODO: This localStorage setting should be moved to backend user config + // so it's available during rendering, then this inline script can be removed. + (window.updateCloneStates = function() { + const httpsBtn = document.getElementById('repo-clone-https'); + const sshBtn = document.getElementById('repo-clone-ssh'); + const value = localStorage.getItem('repo-clone-protocol') || 'https'; + const isSSH = value === 'ssh' && sshBtn || value !== 'ssh' && !httpsBtn; + + if (httpsBtn) { + httpsBtn.textContent = window.origin.split(':')[0].toUpperCase(); + httpsBtn.classList.toggle('primary', !isSSH); + httpsBtn.classList.toggle('basic', isSSH); + } + if (sshBtn) { + sshBtn.classList.toggle('primary', isSSH); + sshBtn.classList.toggle('basic', !isSSH); + } + + const btn = isSSH ? sshBtn : httpsBtn; + if (!btn) return; + + // NOTE: Keep this function in sync with the one in the js folder + function toOriginUrl(urlStr) { + try { + if (urlStr.startsWith('http://') || urlStr.startsWith('https://') || urlStr.startsWith('/')) { + const {origin, protocol, hostname, port} = window.location; + const url = new URL(urlStr, origin); + url.protocol = protocol; + url.hostname = hostname; + url.port = port || (protocol === 'https:' ? '443' : '80'); + return url.toString(); + } + } catch {} + return urlStr; + } + const link = toOriginUrl(btn.getAttribute('data-link')); + + for (const el of document.getElementsByClassName('js-clone-url')) { + el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link; + } + for (const el of document.getElementsByClassName('js-clone-url-editor')) { + el.href = el.getAttribute('data-href-template').replace('{url}', encodeURIComponent(link)); + } + })(); +</script> diff --git a/templates/repo/code/recently_pushed_new_branches.tmpl b/templates/repo/code/recently_pushed_new_branches.tmpl new file mode 100644 index 0000000..d996acc --- /dev/null +++ b/templates/repo/code/recently_pushed_new_branches.tmpl @@ -0,0 +1,17 @@ +{{range .RecentlyPushedNewBranches}} + <div class="ui positive message tw-flex tw-items-center tw-gap-2"> + <div class="tw-flex-1 tw-break-anywhere"> + {{$timeSince := TimeSince .CommitTime.AsTime ctx.Locale}} + {{$repo := .GetRepo $.Context}} + {{$name := .Name}} + {{if ne $repo.ID $.Repository.ID}} + {{$name = (print $repo.FullName ":" .Name)}} + {{end}} + {{$branchLink := (print ($repo.Link) "/src/branch/" (PathEscapeSegments .Name))}} + {{ctx.Locale.Tr "repo.pulls.recently_pushed_new_branches" $name $timeSince $branchLink}} + </div> + <a role="button" class="ui compact positive button tw-m-0" href="{{$.Repository.ComposeBranchCompareURL $.Repository.BaseRepo $name}}"> + {{ctx.Locale.Tr "repo.pulls.compare_changes"}} + </a> + </div> +{{end}} diff --git a/templates/repo/code_frequency.tmpl b/templates/repo/code_frequency.tmpl new file mode 100644 index 0000000..50ec1be --- /dev/null +++ b/templates/repo/code_frequency.tmpl @@ -0,0 +1,9 @@ +{{if .Permission.CanRead $.UnitTypeCode}} + <div id="repo-code-frequency-chart" + data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.code_frequency.what")}}" + data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.code_frequency.what")}}" + data-locale-loading-info="{{ctx.Locale.Tr "graphs.component_loading_info"}}" + data-locale-component-failed-to-load="{{ctx.Locale.Tr "graphs.component_failed_to_load"}}" + > + </div> +{{end}} diff --git a/templates/repo/commit_load_branches_and_tags.tmpl b/templates/repo/commit_load_branches_and_tags.tmpl new file mode 100644 index 0000000..ffa0e53 --- /dev/null +++ b/templates/repo/commit_load_branches_and_tags.tmpl @@ -0,0 +1,20 @@ +{{if not .PageIsWiki}} +<div class="branch-and-tag-area" data-text-default-branch-tooltip="{{ctx.Locale.Tr "repo.commit.contained_in_default_branch"}}"> + <button class="ui button ellipsis-button load-branches-and-tags tw-mt-2" aria-expanded="false" + data-fetch-url="{{.RepoLink}}/commit/{{.CommitID}}/load-branches-and-tags" + data-tooltip-content="{{ctx.Locale.Tr "repo.commit.load_referencing_branches_and_tags"}}" + >...</button> + <div class="branch-and-tag-detail tw-hidden"> + <div class="divider"></div> + <div>{{ctx.Locale.Tr "repo.commit.contained_in"}}</div> + <div class="tw-flex tw-mt-2"> + <div class="tw-p-1">{{svg "octicon-git-branch"}}</div> + <div class="branch-area flex-text-block tw-flex-wrap tw-flex-1"></div> + </div> + <div class="tw-flex tw-mt-2"> + <div class="tw-p-1">{{svg "octicon-tag"}}</div> + <div class="tag-area flex-text-block tw-flex-wrap tw-flex-1"></div> + </div> + </div> +</div> +{{end}} diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl new file mode 100644 index 0000000..e376860 --- /dev/null +++ b/templates/repo/commit_page.tmpl @@ -0,0 +1,285 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository diff"> + {{template "repo/header" .}} + <div class="ui container fluid padded"> + {{$class := ""}} + {{if .Commit.Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + <div class="ui top attached header clearing segment tw-relative commit-header {{$class}}"> + <div class="tw-flex tw-mb-4 tw-gap-1"> + <h3 class="tw-mb-0 tw-flex-1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message ($.Repository.ComposeMetas ctx)}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses}}</h3> + {{if not $.PageIsWiki}} + <div class="commit-header-buttons"> + <a class="ui primary tiny button" href="{{.SourcePath}}"> + {{ctx.Locale.Tr "repo.diff.browse_source"}} + </a> + {{if and ($.Permission.CanWrite $.UnitTypeCode) (not $.Repository.IsArchived) (not .IsDeleted)}}{{- /* */ -}} + <div class="ui dropdown primary tiny button"> + {{ctx.Locale.Tr "repo.commit.operations"}} + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui header">{{ctx.Locale.Tr "repo.commit.operations"}}</div> + <div class="divider"></div> + <div class="item show-create-branch-modal" + data-content="{{ctx.Locale.Tr "repo.branch.new_branch_from" (.CommitID)}}" {{/* used by the form */}} + data-branch-from="{{ShortSha .CommitID}}" + data-branch-from-urlcomponent="{{.CommitID}}" + data-modal="#create-branch-modal"> + {{ctx.Locale.Tr "repo.branch.create_branch_operation"}} + </div> + <div class="item show-create-branch-modal" + data-content="{{ctx.Locale.Tr "repo.branch.new_branch_from" (.CommitID)}}" {{/* used by the form */}} + data-branch-from="{{ShortSha .CommitID}}" + data-branch-from-urlcomponent="{{.CommitID}}" + data-modal="#create-tag-modal" + data-modal-from-span="#modal-create-tag-from-span" + data-modal-form="#create-tag-form"> + {{ctx.Locale.Tr "repo.tag.create_tag_operation"}} + </div> + <div class="item show-modal revert-button" + data-modal="#cherry-pick-modal" + data-modal-cherry-pick-type="revert" + data-modal-cherry-pick-header="{{ctx.Locale.Tr "repo.commit.revert-header" (ShortSha .CommitID)}}" + data-modal-cherry-pick-content="{{ctx.Locale.Tr "repo.commit.revert-content"}}" + data-modal-cherry-pick-submit="{{ctx.Locale.Tr "repo.commit.revert"}}">{{ctx.Locale.Tr "repo.commit.revert"}}</div> + <div class="item cherry-pick-button show-modal" + data-modal="#cherry-pick-modal" + data-modal-cherry-pick-type="cherry-pick" + data-modal-cherry-pick-header="{{ctx.Locale.Tr "repo.commit.cherry-pick-header" (ShortSha .CommitID)}}" + data-modal-cherry-pick-content="{{ctx.Locale.Tr "repo.commit.cherry-pick-content"}}" + data-modal-cherry-pick-submit="{{ctx.Locale.Tr "repo.commit.cherry-pick"}}">{{ctx.Locale.Tr "repo.commit.cherry-pick"}}</div> + <div class="ui g-modal-confirm modal" id="cherry-pick-modal"> + <div class="header"> + <span id="cherry-pick-header"></span> + </div> + <div class="content"> + <p id="cherry-pick-content" class="branch-dropdown"></p> + {{template "repo/branch_dropdown" dict "root" . + "noTag" true "disableCreateBranch" true + "branchForm" "branch-dropdown-form" + "branchURLPrefix" (printf "%s/_cherrypick/%s/" $.RepoLink .CommitID) "branchURLSuffix" "" + "setAction" true "submitForm" true}} + <form method="get" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{PathEscapeSegments $.Repository.DefaultBranch}}" id="branch-dropdown-form"> + <input type="hidden" name="ref" value="{{$.Repository.DefaultBranch}}"> + <input type="hidden" name="refType" value="branch"> + <input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br> + <button type="submit" id="cherry-pick-submit" class="ui primary button"></button> + </form> + </div> + </div> + <div class="ui small modal" id="create-branch-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.branch.new_branch"}} + </div> + <div class="content"> + <form class="ui form" id="create-branch-form" action="" data-base-action="{{.RepoLink}}/branches/_new/commit/" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.branch.new_branch_from" (`<span class="text" id="modal-create-branch-from-span"></span>`|SafeHTML)}} + </label> + </div> + <div class="required field"> + <label for="new_branch_name">{{ctx.Locale.Tr "repo.branch.name"}}</label> + <input id="new_branch_name" name="new_branch_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui primary button">{{ctx.Locale.Tr "repo.branch.confirm_create_branch"}}</button> + </div> + </form> + </div> + </div> + <div class="ui small modal" id="create-tag-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.tag.create_tag_operation"}} + </div> + <div class="content"> + <form class="ui form" id="create-tag-form" action="" data-base-action="{{.RepoLink}}/branches/_new/commit/" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="create_tag" value="true"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.tag.create_tag_from" (`<span class="text" id="modal-create-tag-from-span"></span>`|SafeHTML)}} + </label> + </div> + <div class="required field"> + <label for="new_branch_name">{{ctx.Locale.Tr "repo.release.tag_name"}}</label> + <input id="new_branch_name" name="new_branch_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui primary button">{{ctx.Locale.Tr "repo.tag.confirm_create_tag"}}</button> + </div> + </form> + </div> + </div> + </div> + </div> + {{end}} + </div> + {{end}} + </div> + {{if IsMultilineCommitMessage .Commit.Message}} + <pre class="commit-body">{{RenderCommitBody $.Context .Commit.Message ($.Repository.ComposeMetas ctx)}}</pre> + {{end}} + {{template "repo/commit_load_branches_and_tags" .}} + </div> + <div class="ui attached segment tw-flex tw-items-center tw-justify-between tw-py-1 commit-header-row tw-flex-wrap {{$class}}"> + <div class="tw-flex tw-items-center author"> + {{if .Author}} + {{ctx.AvatarUtils.Avatar .Author 28 "tw-mr-2"}} + {{if .Author.FullName}} + <a href="{{.Author.HomeLink}}"><strong>{{.Author.FullName}}</strong></a> + {{else}} + <a href="{{.Author.HomeLink}}"><strong>{{.Commit.Author.Name}}</strong></a> + {{end}} + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Author.Email .Commit.Author.Email 28 "tw-mr-2"}} + <strong>{{.Commit.Author.Name}}</strong> + {{end}} + <span class="text grey tw-ml-2" id="authored-time">{{TimeSince .Commit.Author.When ctx.Locale}}</span> + {{if or (ne .Commit.Committer.Name .Commit.Author.Name) (ne .Commit.Committer.Email .Commit.Author.Email)}} + <span class="text grey tw-mx-2">{{ctx.Locale.Tr "repo.diff.committed_by"}}</span> + {{if ne .Verification.CommittingUser.ID 0}} + {{ctx.AvatarUtils.Avatar .Verification.CommittingUser 28 "tw-mx-2"}} + <a href="{{.Verification.CommittingUser.HomeLink}}"><strong>{{.Commit.Committer.Name}}</strong></a> + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Commit.Committer.Email .Commit.Committer.Name 28 "tw-mr-2"}} + <strong>{{.Commit.Committer.Name}}</strong> + {{end}} + {{end}} + </div> + <div class="tw-flex tw-items-center"> + {{if .Parents}} + <div> + <span>{{ctx.Locale.Tr "repo.diff.parent"}}</span> + {{range .Parents}} + {{if $.PageIsWiki}} + <a class="ui primary sha label" href="{{$.RepoLink}}/wiki/commit/{{PathEscape .}}">{{ShortSha .}}</a> + {{else}} + <a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{PathEscape .}}">{{ShortSha .}}</a> + {{end}} + {{end}} + </div> + {{end}} + <div class="item"> + <span>{{ctx.Locale.Tr "repo.diff.commit"}}</span> + <span class="ui primary sha label">{{ShortSha .CommitID}}</span> + </div> + </div> + </div> + {{if .Commit.Signature}} + <div class="ui bottom attached message tw-text-left tw-flex tw-items-center tw-justify-between commit-header-row tw-flex-wrap tw-mb-0 {{$class}}"> + <div class="tw-flex tw-items-center"> + {{if .Verification.Verified}} + {{if ne .Verification.SigningUser.ID 0}} + {{svg "gitea-lock" 16 "tw-mr-2"}} + {{if eq .Verification.TrustStatus "trusted"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}:</span> + {{else if eq .Verification.TrustStatus "untrusted"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user"}}:</span> + {{else}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span> + {{end}} + {{ctx.AvatarUtils.Avatar .Verification.SigningUser 28 "tw-mr-2"}} + <a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a> + {{else}} + <span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "tw-mr-2"}}</span> + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}:</span> + {{ctx.AvatarUtils.AvatarByEmail .Verification.SigningEmail "" 28 "tw-mr-2"}} + <strong>{{.Verification.SigningUser.GetDisplayName}}</strong> + {{end}} + {{else}} + {{svg "gitea-unlock" 16 "tw-mr-2"}} + <span class="ui text">{{ctx.Locale.Tr .Verification.Reason}}</span> + {{end}} + </div> + <div class="tw-flex tw-items-center"> + {{if .Verification.Verified}} + {{if ne .Verification.SigningUser.ID 0}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + {{if .Verification.SigningSSHKey}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{.Verification.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{.Verification.SigningKey.PaddedKeyID}} + {{end}} + {{else}} + {{svg "octicon-unverified" 16 "tw-mr-2"}} + {{if .Verification.SigningSSHKey}} + <span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{.Verification.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{.Verification.SigningKey.PaddedKeyID}} + {{end}} + {{end}} + {{else if .Verification.Warning}} + {{svg "octicon-unverified" 16 "tw-mr-2"}} + {{if .Verification.SigningSSHKey}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{.Verification.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{.Verification.SigningKey.PaddedKeyID}} + {{end}} + {{else}} + {{if .Verification.SigningKey}} + {{if ne .Verification.SigningKey.KeyID ""}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{.Verification.SigningKey.PaddedKeyID}} + {{end}} + {{end}} + {{if .Verification.SigningSSHKey}} + {{if ne .Verification.SigningSSHKey.Fingerprint ""}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{.Verification.SigningSSHKey.Fingerprint}} + {{end}} + {{end}} + {{end}} + </div> + </div> + {{end}} + {{if .NoteRendered}} + <div class="ui top attached header segment git-notes"> + {{svg "octicon-note" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.diff.git-notes"}}: + {{if .NoteAuthor}} + <a href="{{.NoteAuthor.HomeLink}}"> + {{if .NoteAuthor.FullName}} + <strong>{{.NoteAuthor.FullName}}</strong> + {{else}} + <strong>{{.NoteCommit.Author.Name}}</strong> + {{end}} + </a> + {{else}} + <strong>{{.NoteCommit.Author.Name}}</strong> + {{end}} + <span class="text grey" id="note-authored-time">{{TimeSince .NoteCommit.Author.When ctx.Locale}}</span> + </div> + <div class="ui bottom attached info segment git-notes"> + <pre class="commit-body">{{.NoteRendered | SanitizeHTML}}</pre> + </div> + {{end}} + {{template "repo/diff/box" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/commit_status.tmpl b/templates/repo/commit_status.tmpl new file mode 100644 index 0000000..eb700ab --- /dev/null +++ b/templates/repo/commit_status.tmpl @@ -0,0 +1,16 @@ +<!-- make sure this matches the color logic in web_src/js/components/DashboardRepoList.vue --> +{{if eq .State "pending"}} + {{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}} +{{end}} +{{if eq .State "success"}} + {{svg "octicon-check" 18 "commit-status icon text green"}} +{{end}} +{{if eq .State "error"}} + {{svg "gitea-exclamation" 18 "commit-status icon text red"}} +{{end}} +{{if eq .State "failure"}} + {{svg "octicon-x" 18 "commit-status icon text red"}} +{{end}} +{{if eq .State "warning"}} + {{svg "gitea-exclamation" 18 "commit-status icon text yellow"}} +{{end}} diff --git a/templates/repo/commit_statuses.tmpl b/templates/repo/commit_statuses.tmpl new file mode 100644 index 0000000..f451ac0 --- /dev/null +++ b/templates/repo/commit_statuses.tmpl @@ -0,0 +1,14 @@ +{{if .Statuses}} + {{if and (eq (len .Statuses) 1) .Status.TargetURL}} + <a class="tw-align-middle {{.AdditionalClasses}} tw-no-underline" data-tippy="commit-statuses" href="{{.Status.TargetURL}}"> + {{template "repo/commit_status" .Status}} + </a> + {{else}} + <span class="tw-align-middle {{.AdditionalClasses}}" data-tippy="commit-statuses" tabindex="0"> + {{template "repo/commit_status" .Status}} + </span> + {{end}} + <div class="tippy-target"> + {{template "repo/pulls/status" (dict "CommitStatuses" .Statuses "CommitStatus" .Status)}} + </div> +{{end}} diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl new file mode 100644 index 0000000..86df88f --- /dev/null +++ b/templates/repo/commits.tmpl @@ -0,0 +1,23 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository commits"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "repo/sub_menu" .}} + <div class="repo-button-row"> + <div class="tw-flex tw-items-center"> + {{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}} + <a href="{{.RepoLink}}/graph" class="ui basic small compact button"> + {{svg "octicon-git-branch"}} + {{ctx.Locale.Tr "repo.commit_graph"}} + </a> + </div> + </div> + {{template "repo/commits_table" .}} + {{if .OldFilename}} + <div class="ui bottom attached header"> + <span>{{ctx.Locale.Tr "repo.commits.renamed_from" .OldFilename}} (<a href="{{.OldFilenameHistory}}">{{ctx.Locale.Tr "repo.commits.browse_further"}}</a>)</span> + </div> + {{end}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl new file mode 100644 index 0000000..c8c695e --- /dev/null +++ b/templates/repo/commits_list.tmpl @@ -0,0 +1,96 @@ +<div class="ui attached table segment commit-table"> + <table class="ui very basic striped table unstackable" id="commits-table"> + <thead> + <tr> + <th class="three wide">{{ctx.Locale.Tr "repo.commits.author"}}</th> + <th class="two wide sha">{{StringUtils.ToUpper $.Repository.ObjectFormatName}}</th> + <th class="eight wide message">{{ctx.Locale.Tr "repo.commits.message"}}</th> + <th class="two wide right aligned">{{ctx.Locale.Tr "repo.commits.date"}}</th> + <th class="one wide"></th> + </tr> + </thead> + <tbody class="commit-list"> + {{$commitRepoLink := $.RepoLink}}{{if $.CommitRepoLink}}{{$commitRepoLink = $.CommitRepoLink}}{{end}} + {{range .Commits}} + <tr> + <td class="author"> + <div class="tw-flex"> + {{$userName := .Author.Name}} + {{if .User}} + {{if and .User.FullName DefaultShowFullName}} + {{$userName = .User.FullName}} + {{end}} + {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}<a class="muted author-wrapper" href="{{.User.HomeLink}}">{{$userName}}</a> + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 28 "tw-mr-2"}} + <span class="author-wrapper">{{$userName}}</span> + {{end}} + </div> + </td> + <td class="sha"> + {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + {{$commitShaLink := ""}} + {{if $.PageIsWiki}} + {{$commitShaLink = (printf "%s/wiki/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{else if $.PageIsPullCommits}} + {{$commitShaLink = (printf "%s/pulls/%d/commits/%s" $commitRepoLink $.Issue.Index (PathEscape .ID.String))}} + {{else if $.Reponame}} + {{$commitShaLink = (printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String))}} + {{end}} + <a {{if $commitShaLink}}href="{{$commitShaLink}}"{{end}} class="{{$class}}"> + <span class="shortsha">{{ShortSha .ID.String}}</span> + {{if .Signature}}{{template "repo/shabox_badge" dict "root" $ "verification" .Verification}}{{end}} + </a> + </td> + <td class="message"> + <span class="message-wrapper"> + {{if $.PageIsWiki}} + <span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary | RenderEmoji $.Context}}</span> + {{else}} + {{$commitLink:= printf "%s/commit/%s" $commitRepoLink (PathEscape .ID.String)}} + <span class="commit-summary {{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject $.Context .Message $commitLink ($.Repository.ComposeMetas ctx)}}</span> + {{end}} + </span> + {{if IsMultilineCommitMessage .Message}} + <button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button> + {{end}} + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} + {{if IsMultilineCommitMessage .Message}} + <pre class="commit-body tw-hidden">{{RenderCommitBody $.Context .Message ($.Repository.ComposeMetas ctx)}}</pre> + {{end}} + </td> + {{if .Committer}} + <td class="text right aligned">{{TimeSince .Committer.When ctx.Locale}}</td> + {{else}} + <td class="text right aligned">{{TimeSince .Author.When ctx.Locale}}</td> + {{end}} + <td class="text right aligned tw-py-0"> + <button class="btn interact-bg tw-p-2" data-tooltip-content="{{ctx.Locale.Tr "copy_hash"}}" data-clipboard-text="{{.ID}}">{{svg "octicon-copy"}}</button> + {{if not $.PageIsWiki}} + <a + class="btn interact-bg tw-p-2" + data-tooltip-content="{{ctx.Locale.Tr "repo.commits.view_path"}}" + href="{{if $.FileName}}{{printf "%s/src/commit/%s/%s" $commitRepoLink (PathEscape .ID.String) (PathEscapeSegments $.FileName)}}{{else}}{{printf "%s/src/commit/%s" $commitRepoLink (PathEscape .ID.String)}}{{end}}"> + {{svg "octicon-file-code"}} + </a> + {{end}} + </td> + </tr> + {{end}} + </tbody> + </table> + </div> diff --git a/templates/repo/commits_list_small.tmpl b/templates/repo/commits_list_small.tmpl new file mode 100644 index 0000000..4c67319 --- /dev/null +++ b/templates/repo/commits_list_small.tmpl @@ -0,0 +1,55 @@ +{{$index := 0}} +<div class="timeline-item commits-list"> +{{range .comment.Commits}} + {{$tag := printf "%s-%d" $.comment.HashTag $index}} + {{$index = Eval $index "+" 1}} + <div class="singular-commit" id="{{$tag}}"> + <span class="badge badge-commit">{{svg "octicon-git-commit"}}</span> + {{if .User}} + <a class="avatar" href="{{.User.HomeLink}}">{{ctx.AvatarUtils.Avatar .User 20}}</a> + {{else}} + {{ctx.AvatarUtils.AvatarByEmail .Author.Email .Author.Name 20}} + {{end}} + + {{$commitLink:= printf "%s/commit/%s" $.comment.Issue.PullRequest.BaseRepo.Link (PathEscape .ID.String)}} + + <span class="tw-flex-1 tw-font-mono gt-ellipsis" title="{{.Summary}}"> + {{- RenderCommitMessageLinkSubject $.root.Context .Message $commitLink ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx) -}} + </span> + + {{if IsMultilineCommitMessage .Message}} + <button class="ui button ellipsis-button show-panel toggle" data-panel="[data-singular-commit-body-for='{{$tag}}']">...</button> + {{end}} + + <span class="shabox tw-flex tw-items-center"> + {{template "repo/commit_statuses" dict "Status" .Status "Statuses" .Statuses}} + {{$class := "ui sha label"}} + {{if .Signature}} + {{$class = (print $class " isSigned")}} + {{if .Verification.Verified}} + {{if eq .Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq .Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if .Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + <a href="{{$commitLink}}" rel="nofollow" class="tw-ml-2 {{$class}}"> + <span class="shortsha">{{ShortSha .ID.String}}</span> + {{if .Signature}} + {{template "repo/shabox_badge" dict "root" $.root "verification" .Verification}} + {{end}} + </a> + </span> + </div> + {{if IsMultilineCommitMessage .Message}} + <pre class="commit-body tw-ml-[33px] tw-hidden" data-singular-commit-body-for="{{$tag}}"> + {{- RenderCommitBody $.root.Context .Message ($.comment.Issue.PullRequest.BaseRepo.ComposeMetas ctx) -}} + </pre> + {{end}} +{{end}} +</div> diff --git a/templates/repo/commits_search_dropdown.tmpl b/templates/repo/commits_search_dropdown.tmpl new file mode 100644 index 0000000..5aa3f4f --- /dev/null +++ b/templates/repo/commits_search_dropdown.tmpl @@ -0,0 +1,8 @@ +<div class="ui small dropdown selection"> + <input name="all" type="hidden" value="{{.All}}">{{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="text">{{if .All}}{{ctx.Locale.Tr "repo.commits.search_all"}}{{else}}{{ctx.Locale.Tr "repo.commits.search_branch"}}{{end}}</div> + <div class="menu"> + <div class="item" data-value="false">{{ctx.Locale.Tr "repo.commits.search_branch"}}</div> + <div class="item" data-value="true">{{ctx.Locale.Tr "repo.commits.search_all"}}</div> + </div> +</div> diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl new file mode 100644 index 0000000..7249bec --- /dev/null +++ b/templates/repo/commits_table.tmpl @@ -0,0 +1,36 @@ +<h4 class="ui top attached header commits-table tw-flex tw-items-center tw-justify-between"> + <div class="commits-table-left tw-flex tw-items-center"> + {{if or .PageIsCommits (gt .CommitCount 0)}} + {{ctx.Locale.TrN .CommitCount "repo.n_commit_one" "repo.n_commit_few" (StringUtils.ToString .CommitCount)}} + {{else if .IsNothingToCompare}} + {{ctx.Locale.Tr "repo.commits.nothing_to_compare"}} + {{else}} + {{ctx.Locale.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch}} + {{end}} + </div> + {{if .IsDiffCompare}} + <div class="commits-table-right tw-whitespace-nowrap"> + <a href="{{$.CommitRepoLink}}/commit/{{.BeforeCommitID | PathEscape}}" class="ui green sha label tw-mx-0">{{if not .BaseIsCommit}}{{if .BaseIsBranch}}{{svg "octicon-git-branch"}}{{else if .BaseIsTag}}{{svg "octicon-tag"}}{{end}}{{.BaseBranch}}{{else}}{{ShortSha .BaseBranch}}{{end}}</a> + ... + <a href="{{$.CommitRepoLink}}/commit/{{.AfterCommitID | PathEscape}}" class="ui green sha label tw-mx-0">{{if not .HeadIsCommit}}{{if .HeadIsBranch}}{{svg "octicon-git-branch"}}{{else if .HeadIsTag}}{{svg "octicon-tag"}}{{end}}{{.HeadBranch}}{{else}}{{ShortSha .HeadBranch}}{{end}}</a> + </div> + {{end}} +</h4> + +{{if .PageIsCommits}} + <div class="ui attached segment"> + <form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/search"> + <div class="ui small fluid action input"> + {{template "shared/search/input" dict "Value" .Keyword "Placeholder" (ctx.Locale.Tr "search.commit_kind")}} + {{template "repo/commits_search_dropdown" .}} + {{template "shared/search/button" dict "Tooltip" (ctx.Locale.Tr "repo.commits.search.tooltip")}} + </div> + </form> + </div> +{{end}} + +{{if and .Commits (gt .CommitCount 0)}} + {{template "repo/commits_list" .}} +{{end}} + +{{template "base/paginate" .}} diff --git a/templates/repo/contributors.tmpl b/templates/repo/contributors.tmpl new file mode 100644 index 0000000..f7f5d79 --- /dev/null +++ b/templates/repo/contributors.tmpl @@ -0,0 +1,14 @@ +{{if .Permission.CanRead $.UnitTypeCode}} + <div id="repo-contributors-chart" + data-repo-link="{{.RepoLink}}" + data-locale-filter-label="{{ctx.Locale.Tr "repo.contributors.contribution_type.filter_label"}}" + data-locale-contribution-type-commits="{{ctx.Locale.Tr "repo.contributors.contribution_type.commits"}}" + data-locale-contribution-type-additions="{{ctx.Locale.Tr "repo.contributors.contribution_type.additions"}}" + data-locale-contribution-type-deletions="{{ctx.Locale.Tr "repo.contributors.contribution_type.deletions"}}" + data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.contributors.what")}}" + data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.contributors.what")}}" + data-locale-loading-info="{{ctx.Locale.Tr "graphs.component_loading_info"}}" + data-locale-component-failed-to-load="{{ctx.Locale.Tr "graphs.component_failed_to_load"}}" + > + </div> +{{end}} diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl new file mode 100644 index 0000000..df4288a --- /dev/null +++ b/templates/repo/create.tmpl @@ -0,0 +1,224 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new repo"> + <div class="ui middle very relaxed page one column grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "new_repo.title"}} + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + {{template "repo/create_helper" .}} + + {{if not .CanCreateRepo}} + <div class="ui negative message"> + <p>{{ctx.Locale.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}</p> + </div> + {{end}} + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.owner_helper"}}</span> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" autofocus required maxlength="100"> + <span class="help">{{ctx.Locale.Tr "repo.repo_name_helper"}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" rows="2" name="description" placeholder="{{ctx.Locale.Tr "repo.repo_desc_helper"}}" maxlength="2048">{{.description}}</textarea> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.template"}}</label> + <div id="repo_template_search" class="ui search selection dropdown"> + <input type="hidden" id="repo_template" name="repo_template" value="{{if ne .repo_template 0}}{{.repo_template}}{{end}}"> + <div class="default text">{{.repo_template_name}}</div> + <div class="menu"> + </div> + </div> + </div> + + <div id="template_units" class="tw-hidden"> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.template.items"}}</label> + <div class="ui checkbox"> + <input name="git_content" type="checkbox" {{if .git_content}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.git_content"}}</label> + </div> + <div class="ui checkbox" {{if not .SignedUser.CanEditGitHook}}data-tooltip-content="{{ctx.Locale.Tr "repo.template.git_hooks_tooltip"}}"{{end}}> + <input name="git_hooks" type="checkbox" {{if .git_hooks}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.git_hooks"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="webhooks" type="checkbox" {{if .webhooks}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.webhooks"}}</label> + </div> + <div class="ui checkbox"> + <input name="topics" type="checkbox" {{if .topics}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.topics"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="avatar" type="checkbox" {{if .avatar}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.avatar"}}</label> + </div> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template.issue_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="protected_branch" type="checkbox" {{if .protected_branch}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.protected_branch"}}</label> + </div> + </div> + </div> + + <div id="non_template"> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.issue_labels"}}</label> + <div class="ui search selection dropdown"> + <input type="hidden" name="issue_labels" value="{{.issueLabels}}"> + <div class="default text">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div> + <div class="menu"> + <div class="item" data-value="">{{ctx.Locale.Tr "repo.issue_labels_helper"}}</div> + {{range .LabelTemplateFiles}} + <div class="item" data-value="{{.DisplayName}}">{{.DisplayName}}<br><p>({{.Description}})</p></div> + {{end}} + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline field"> + <label>.gitignore</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="gitignores" value="{{.gitignores}}"> + <div class="default text">{{ctx.Locale.Tr "repo.repo_gitignore_helper"}}</div> + <div class="menu"> + {{range .Gitignores}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.repo_gitignore_helper_desc"}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.license"}}</label> + <div class="ui search selection dropdown"> + <input type="hidden" name="license" value="{{.license}}"> + <div class="default text">{{ctx.Locale.Tr "repo.license_helper"}}</div> + <div class="menu"> + <div class="item" data-value="">{{ctx.Locale.Tr "repo.license_helper"}}</div> + {{range .Licenses}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.license_helper_desc" "https://choosealicense.com/"}}</span> + </div> + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.readme"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" name="readme" value="{{.readme}}"> + <div class="default text">{{ctx.Locale.Tr "repo.readme_helper"}}</div> + <div class="menu"> + {{range .Readmes}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.readme_helper_desc"}}</span> + </div> + <div class="inline field"> + <div class="ui checkbox" id="auto-init"> + <input name="auto_init" type="checkbox" {{if .auto_init}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.auto_init"}}</label> + </div> + </div> + <div class="inline field"> + <label for="default_branch">{{ctx.Locale.Tr "repo.default_branch"}}</label> + <input id="default_branch" name="default_branch" value="{{.default_branch}}" placeholder="{{.default_branch}}"> + <span class="help">{{ctx.Locale.Tr "repo.default_branch_helper"}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.object_format"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="object_format_name" name="object_format_name" value="{{.DefaultObjectFormat.Name}}" required> + <div class="default text">{{.DefaultObjectFormat.Name}}</div> + <div class="menu"> + {{range .SupportedObjectFormats}} + <div class="item" data-value="{{.Name}}">{{.Name}}</div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.object_format_helper"}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.template"}}</label> + <div class="ui checkbox"> + <input name="template" type="checkbox"> + <label>{{ctx.Locale.Tr "repo.template_helper"}}</label> + </div> + </div> + </div> + <br> + <div class="inline field"> + <label></label> + <button class="ui primary button{{if not .CanCreateRepo}} disabled{{end}}"> + {{ctx.Locale.Tr "repo.create_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/create_helper.tmpl b/templates/repo/create_helper.tmpl new file mode 100644 index 0000000..70c28b7 --- /dev/null +++ b/templates/repo/create_helper.tmpl @@ -0,0 +1,3 @@ +{{if not $.DisableMigrations}} + <p class="ui center">{{ctx.Locale.Tr "repo.new_repo_helper" (print AppSubUrl "/repo/migrate")}}</p> +{{end}} diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl new file mode 100644 index 0000000..d6ab87f --- /dev/null +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -0,0 +1,80 @@ +{{if $.IsSplitStyle}} + {{range $k, $line := $.section.Lines}} + <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}"> + {{if eq .GetType 4}} + <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"> + <div class="tw-flex"> + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold-down"}} + </button> + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold-up"}} + </button> + {{end}} + {{if eq $line.GetExpandDirection 2}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold"}} + </button> + {{end}} + </div> + </td> + <td colspan="7" class="lines-code lines-code-old ">{{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}</td> + {{else}} + {{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}} + <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$.FileNameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> + <td class="blob-excerpt lines-escape lines-escape-old">{{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td> + <td class="blob-excerpt lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="tw-font-mono" data-type-marker=""></span>{{end}}</td> + <td class="blob-excerpt lines-code lines-code-old">{{/* + */}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$.FileNameHash}}R{{$line.RightIdx}}{{end}}"></span></td> + <td class="blob-excerpt lines-escape lines-escape-new">{{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td> + <td class="blob-excerpt lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="tw-font-mono" data-type-marker=""></span>{{end}}</td> + <td class="blob-excerpt lines-code lines-code-new">{{/* + */}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + {{end}} + </tr> + {{end}} +{{else}} + {{range $k, $line := $.section.Lines}} + <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}"> + {{if eq .GetType 4}} + <td colspan="2" class="lines-num"> + <div class="tw-flex"> + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold-down"}} + </button> + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold-up"}} + </button> + {{end}} + {{if eq $line.GetExpandDirection 2}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$.RepoLink}}/blob_excerpt/{{PathEscape $.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.PageIsWiki}}&anchor={{$.Anchor}}"> + {{svg "octicon-fold"}} + </button> + {{end}} + </div> + </td> + {{else}} + <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$.FileNameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> + <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$.FileNameHash}}R{{$line.RightIdx}}{{end}}"></span></td> + {{end}} + {{$inlineDiff := $.section.GetComputedInlineDiffFor $line ctx.Locale}} + <td class="blob-excerpt lines-escape">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td> + <td class="blob-excerpt lines-type-marker"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> + <td class="blob-excerpt lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}"><code {{if $inlineDiff.EscapeStatus.Escaped}}class="code-inner has-escaped" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"{{else}}class="code-inner"{{end}}>{{$inlineDiff.Content}}</code></td> + </tr> + {{end}} +{{end}} diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl new file mode 100644 index 0000000..230e497 --- /dev/null +++ b/templates/repo/diff/box.tmpl @@ -0,0 +1,260 @@ +{{$showFileTree := (and (not .DiffNotAvailable) (gt .Diff.NumFiles 1))}} +<div> + <div class="diff-detail-box diff-box"> + <div class="tw-flex tw-items-center tw-flex-wrap tw-gap-2 tw-ml-0.5"> + {{if $showFileTree}} + <button class="diff-toggle-file-tree-button not-mobile btn interact-fg" data-show-text="{{ctx.Locale.Tr "repo.diff.show_file_tree"}}" data-hide-text="{{ctx.Locale.Tr "repo.diff.hide_file_tree"}}"> + {{/* the icon meaning is reversed here, "octicon-sidebar-collapse" means show the file tree */}} + {{svg "octicon-sidebar-collapse" 20 "icon tw-hidden"}} + {{svg "octicon-sidebar-expand" 20 "icon tw-hidden"}} + </button> + <script> + // Default to true if unset + const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') !== 'false'; + const diffTreeBtn = document.querySelector('.diff-toggle-file-tree-button'); + const diffTreeIcon = `.octicon-sidebar-${diffTreeVisible ? 'expand' : 'collapse'}`; + diffTreeBtn.querySelector(diffTreeIcon).classList.remove('tw-hidden'); + diffTreeBtn.setAttribute('data-tooltip-content', diffTreeBtn.getAttribute(diffTreeVisible ? 'data-hide-text' : 'data-show-text')); + </script> + {{end}} + {{if not .DiffNotAvailable}} + <div class="diff-detail-stats tw-flex tw-items-center tw-flex-wrap"> + {{svg "octicon-diff" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion}} + </div> + {{end}} + </div> + <div class="diff-detail-actions button-row"> + {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived) (not .DiffNotAvailable)}} + <div class="not-mobile tw-flex tw-items-center tw-flex-col tw-whitespace-nowrap tw-mr-1"> + <label for="viewed-files-summary" id="viewed-files-summary-label" data-text-changed-template="{{ctx.Locale.Tr "repo.pulls.viewed_files_label"}}"> + {{ctx.Locale.Tr "repo.pulls.viewed_files_label" .Diff.NumViewedFiles .Diff.NumFiles}} + </label> + <progress id="viewed-files-summary" value="{{.Diff.NumViewedFiles}}" max="{{.Diff.NumFiles}}"></progress> + </div> + {{end}} + {{template "repo/diff/whitespace_dropdown" .}} + {{template "repo/diff/options_dropdown" .}} + {{if .PageIsPullFiles}} + <div id="diff-commit-select" data-issuelink="{{$.Issue.Link}}" data-queryparams="?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}" data-filter_changes_by_commit="{{ctx.Locale.Tr "repo.pulls.filter_changes_by_commit"}}"> + {{/* + the following will be replaced by vue component + but this avoids any loading artifacts till the vue component is initialized + */}} + <div class="ui jump dropdown basic button custom"> + {{svg "octicon-git-commit"}} + </div> + </div> + {{end}} + {{if and .PageIsPullFiles $.SignedUserID (not .IsArchived)}} + {{template "repo/diff/new_review" .}} + {{end}} + </div> + </div> + {{if not .DiffNotAvailable}} + {{if and .IsShowingOnlySingleCommit .PageIsPullFiles}} + <div class="ui info message"> + <div>{{ctx.Locale.Tr "repo.pulls.showing_only_single_commit" (ShortSha .AfterCommitID)}} - <a href="{{$.Issue.Link}}/files?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}">{{ctx.Locale.Tr "repo.pulls.show_all_commits"}}</a></div> + </div> + {{else if and (not .IsShowingAllCommits) .PageIsPullFiles}} + <div class="ui info message"> + <div>{{ctx.Locale.Tr "repo.pulls.showing_specified_commit_range" (ShortSha .BeforeCommitID) (ShortSha .AfterCommitID)}} - <a href="{{$.Issue.Link}}/files?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}">{{ctx.Locale.Tr "repo.pulls.show_all_commits"}}</a></div> + </div> + {{end}} + <script id="diff-data-script" type="module"> + const diffDataFiles = [{{range $i, $file := .Diff.Files}}{Name:"{{$file.Name}}",NameHash:"{{$file.NameHash}}",Type:{{$file.Type}},IsBin:{{$file.IsBin}},Addition:{{$file.Addition}},Deletion:{{$file.Deletion}},IsViewed:{{$file.IsViewed}}},{{end}}]; + const diffData = { + isIncomplete: {{.Diff.IsIncomplete}}, + tooManyFilesMessage: "{{ctx.Locale.Tr "repo.diff.too_many_files"}}", + binaryFileMessage: "{{ctx.Locale.Tr "repo.diff.bin"}}", + showMoreMessage: "{{ctx.Locale.Tr "repo.diff.show_more"}}", + statisticsMessage: "{{ctx.Locale.Tr "repo.diff.stats_desc_file"}}", + linkLoadMore: "?skip-to={{.Diff.End}}&file-only=true", + }; + + // for first time loading, the diffFileInfo is a plain object + // after the Vue component is mounted, the diffFileInfo is a reactive object + // keep in mind that this script block would be executed many times when loading more files, by "loadMoreFiles" + let diffFileInfo = window.config.pageData.diffFileInfo || { + files:[], + fileTreeIsVisible: false, + fileListIsVisible: false, + isLoadingNewData: false, + selectedItem: '', + }; + diffFileInfo = Object.assign(diffFileInfo, diffData); + diffFileInfo.files.push(...diffDataFiles); + window.config.pageData.diffFileInfo = diffFileInfo; + </script> + <div id="diff-file-list"></div> + {{end}} + <div id="diff-container"> + {{if $showFileTree}} + <div id="diff-file-tree" class="tw-hidden not-mobile"></div> + <script> + if (diffTreeVisible) document.getElementById('diff-file-tree').classList.remove('tw-hidden'); + </script> + {{end}} + {{if .DiffNotAvailable}} + <h4>{{ctx.Locale.Tr "repo.diff.data_not_available"}}</h4> + {{else}} + <div id="diff-file-boxes" class="sixteen wide column"> + {{range $i, $file := .Diff.Files}} + {{/*notice: the index of Diff.Files should not be used for element ID, because the index will be restarted from 0 when doing load-more for PRs with a lot of files*/}} + {{$blobBase := call $.GetBlobByPathForCommit $.BeforeCommit $file.OldName}} + {{$blobHead := call $.GetBlobByPathForCommit $.HeadCommit $file.Name}} + {{$sniffedTypeBase := call $.GetSniffedTypeForBlob $blobBase}} + {{$sniffedTypeHead := call $.GetSniffedTypeForBlob $blobHead}} + {{$isImage:= or (call $.IsSniffedTypeAnImage $sniffedTypeBase) (call $.IsSniffedTypeAnImage $sniffedTypeHead)}} + {{$isCsv := (call $.IsCsvFile $file)}} + {{$showFileViewToggle := or $isImage (and (not $file.IsIncomplete) $isCsv)}} + {{$isExpandable := or (gt $file.Addition 0) (gt $file.Deletion 0) $file.IsBin}} + {{$isReviewFile := and $.IsSigned $.PageIsPullFiles (not $.IsArchived) $.IsShowingAllCommits}} + <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}} tw-mt-0" id="diff-{{$file.NameHash}}" data-old-filename="{{$file.OldName}}" data-new-filename="{{$file.Name}}" {{if or ($file.ShouldBeHidden) (not $isExpandable)}}data-folded="true"{{end}}> + <h4 class="diff-file-header sticky-2nd-row ui top attached header tw-font-normal tw-flex tw-items-center tw-justify-between tw-flex-wrap"> + <div class="diff-file-name tw-flex tw-flex-1 tw-items-center tw-gap-1 tw-flex-wrap"> + <button class="fold-file btn interact-bg tw-p-1{{if not $isExpandable}} tw-invisible{{end}}"> + {{if $file.ShouldBeHidden}} + {{svg "octicon-chevron-right" 18}} + {{else}} + {{svg "octicon-chevron-down" 18}} + {{end}} + </button> + <div class="tw-font-semibold tw-flex tw-items-center tw-font-mono"> + {{if $file.IsBin}} + <span class="tw-ml-0.5 tw-mr-2"> + {{ctx.Locale.Tr "repo.diff.bin"}} + </span> + {{else}} + {{template "repo/diff/stats" dict "file" . "root" $}} + {{end}} + </div> + <span class="file tw-flex tw-items-center tw-font-mono tw-flex-1"><a class="muted file-link" title="{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}" href="#diff-{{$file.NameHash}}">{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}</a> + {{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}} + <button class="btn interact-fg tw-p-2" data-clipboard-text="{{$file.Name}}" data-tooltip-content="{{ctx.Locale.Tr "copy_generic"}}" aria-label="{{ctx.Locale.Tr "copy_generic"}}">{{svg "octicon-copy" 14}}</button> + {{if $file.IsGenerated}} + <span class="ui label">{{ctx.Locale.Tr "repo.diff.generated"}}</span> + {{end}} + {{if $file.IsVendored}} + <span class="ui label">{{ctx.Locale.Tr "repo.diff.vendored"}}</span> + {{end}} + {{if and $file.Mode $file.OldMode}} + {{$old := ctx.Locale.Tr ($file.ModeTranslationKey $file.OldMode)}} + {{$new := ctx.Locale.Tr ($file.ModeTranslationKey $file.Mode)}} + <span class="tw-mx-2 tw-font-mono tw-whitespace-nowrap">{{ctx.Locale.Tr "git.filemode.changed_filemode" $old $new}}</span> + {{else if $file.Mode}} + <span class="tw-mx-2 tw-font-mono tw-whitespace-nowrap">{{ctx.Locale.Tr ($file.ModeTranslationKey $file.Mode)}}</span> + {{end}} + </span> + </div> + <div class="diff-file-header-actions tw-flex tw-items-center button-row tw-flex-wrap"> + {{if $showFileViewToggle}} + <div class="ui compact icon buttons"> + <button class="ui tiny basic button file-view-toggle" data-toggle-selector="#diff-source-{{$file.NameHash}}" data-tooltip-content="{{ctx.Locale.Tr "repo.file_view_source"}}">{{svg "octicon-code"}}</button> + <button class="ui tiny basic button file-view-toggle active" data-toggle-selector="#diff-rendered-{{$file.NameHash}}" data-tooltip-content="{{ctx.Locale.Tr "repo.file_view_rendered"}}">{{svg "octicon-file"}}</button> + </div> + {{end}} + {{if $file.IsProtected}} + <span class="ui basic label">{{ctx.Locale.Tr "repo.diff.protected"}}</span> + {{end}} + {{if and $isReviewFile $file.HasChangedSinceLastReview}} + <span class="changed-since-last-review unselectable not-mobile">{{ctx.Locale.Tr "repo.pulls.has_changed_since_last_review"}}</span> + {{end}} + {{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}} + <button class="ui basic tiny button unescape-button not-mobile">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> + <button class="ui basic tiny button escape-button tw-hidden">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> + {{end}} + {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} + {{if $file.IsDeleted}} + <a class="ui basic tiny button" rel="nofollow" href="{{$.BeforeSourcePath}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a> + {{else}} + <a class="ui basic tiny button" rel="nofollow" href="{{$.SourcePath}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.diff.view_file"}}</a> + {{if and $.HeadBranchIsEditable (not $file.IsLFSFile)}} + <a class="ui basic tiny button" rel="nofollow" href="{{$.SourceRepoLink}}/_edit/{{PathEscapeSegments $.HeadBranch}}/{{PathEscapeSegments .Name}}">{{ctx.Locale.Tr "repo.editor.edit_this_file"}}</a> + {{end}} + {{end}} + {{end}} + {{if $isReviewFile}} + <label data-link="{{$.Issue.Link}}/viewed-files" data-headcommit="{{$.AfterCommitID}}" class="viewed-file-form unselectable{{if $file.IsViewed}} viewed-file-checked-form{{end}}"> + <input type="checkbox" name="{{$file.GetDiffFileName}}" autocomplete="off"{{if $file.IsViewed}} checked{{end}}> {{ctx.Locale.Tr "repo.pulls.has_viewed_file"}} + </label> + {{end}} + </div> + </h4> + <div class="diff-file-body ui attached unstackable table segment" {{if and $file.IsViewed $.IsShowingAllCommits}}data-folded="true"{{end}}> + <div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} tw-hidden{{end}}"> + {{if or $file.IsIncomplete $file.IsBin}} + <div class="diff-file-body binary"> + {{if $file.IsIncomplete}} + {{if $file.IsIncompleteLineTooLong}} + {{ctx.Locale.Tr "repo.diff.file_suppressed_line_too_long"}} + {{else}} + {{ctx.Locale.Tr "repo.diff.file_suppressed"}} + <a class="ui basic tiny button diff-load-button" data-href="?file-only=true&files={{$file.Name}}&files={{$file.OldName}}">{{ctx.Locale.Tr "repo.diff.load"}}</a> + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.diff.bin_not_shown"}} + {{end}} + </div> + {{else}} + <table class="chroma" data-new-comment-url="{{$.Issue.Link}}/files/reviews/new_comment" data-path="{{$file.Name}}"> + {{if $.IsSplitStyle}} + {{template "repo/diff/section_split" dict "file" . "root" $}} + {{else}} + {{template "repo/diff/section_unified" dict "file" . "root" $}} + {{end}} + </table> + {{end}} + </div> + {{if $showFileViewToggle}} + {{/* for image or CSV, it can have a horizontal scroll bar, there won't be review comment context menu (position absolute) which would be clipped by "overflow" */}} + <div id="diff-rendered-{{$file.NameHash}}" class="file-body file-code {{if $.IsSplitStyle}}code-diff-split{{else}}code-diff-unified{{end}} tw-overflow-x-scroll"> + <table class="chroma tw-w-full"> + {{if $isImage}} + {{template "repo/diff/image_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead "sniffedTypeBase" $sniffedTypeBase "sniffedTypeHead" $sniffedTypeHead}} + {{else}} + {{template "repo/diff/csv_diff" dict "file" . "root" $ "blobBase" $blobBase "blobHead" $blobHead "sniffedTypeBase" $sniffedTypeBase "sniffedTypeHead" $sniffedTypeHead}} + {{end}} + </table> + </div> + {{end}} + </div> + </div> + {{end}} + + {{if .Diff.IsIncomplete}} + <div class="diff-file-box diff-box file-content tw-mt-2" id="diff-incomplete"> + <h4 class="ui top attached header tw-font-normal tw-flex tw-items-center tw-justify-between"> + {{ctx.Locale.Tr "repo.diff.too_many_files"}} + <a class="ui basic tiny button" id="diff-show-more-files" data-href="?skip-to={{.Diff.End}}&file-only=true">{{ctx.Locale.Tr "repo.diff.show_more"}}</a> + </h4> + </div> + {{end}} + </div> + {{end}} + </div> + + {{if and (not $.Repository.IsArchived) (not .DiffNotAvailable)}} + <template id="issue-comment-editor-template"> + <div class="ui comment form"> + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print $.Repository.Link "/markup") + "MarkdownPreviewContext" $.RepoLink + "TextareaName" "content" + "DropzoneParentContainer" ".ui.form" + )}} + {{if .IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" .}} + </div> + {{end}} + <div class="text right edit buttons"> + <button class="ui cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button> + <button class="ui primary save button">{{ctx.Locale.Tr "repo.issues.save"}}</button> + </div> + </div> + </template> + {{end}} + {{if (not .DiffNotAvailable)}} + {{template "repo/issue/view_content/reference_issue_dialog" .}} + {{end}} +</div> diff --git a/templates/repo/diff/comment_form.tmpl b/templates/repo/diff/comment_form.tmpl new file mode 100644 index 0000000..856b3da --- /dev/null +++ b/templates/repo/diff/comment_form.tmpl @@ -0,0 +1,49 @@ +{{if and $.root.SignedUserID (not $.Repository.IsArchived)}} + <form class="ui form {{if $.hidden}}tw-hidden comment-form{{end}}" action="{{$.root.Issue.Link}}/files/reviews/comments" method="post"> + {{$.root.CsrfTokenHtml}} + <input type="hidden" name="origin" value="{{if $.root.PageIsPullFiles}}diff{{else}}timeline{{end}}"> + <input type="hidden" name="latest_commit_id" value="{{$.root.AfterCommitID}}"> + <input type="hidden" name="side" value="{{if $.Side}}{{$.Side}}{{end}}"> + <input type="hidden" name="line" value="{{if $.Line}}{{$.Line}}{{end}}"> + <input type="hidden" name="path" value="{{if $.File}}{{$.File}}{{end}}"> + <input type="hidden" name="diff_start_cid"> + <input type="hidden" name="diff_end_cid"> + <input type="hidden" name="diff_base_cid"> + + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print $.root.Repository.Link "/markup") + "MarkdownPreviewContext" $.root.RepoLink + "TextareaName" "content" + "TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.comment.placeholder") + "DropzoneParentContainer" "form" + "DisableAutosize" "true" + )}} + + {{if $.root.IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" $.root}} + </div> + {{end}} + + <div class="field footer tw-mx-2"> + <span class="markup-info">{{svg "octicon-markdown"}} {{ctx.Locale.Tr "repo.diff.comment.markdown_info"}}</span> + <div class="tw-text-right"> + {{if $.reply}} + <button class="ui submit primary tiny button btn-reply" type="submit">{{ctx.Locale.Tr "repo.diff.comment.reply"}}</button> + <input type="hidden" name="reply" value="{{$.reply}}"> + <input type="hidden" name="single_review" value="true"> + {{else}} + {{if $.root.CurrentReview}} + <button name="pending_review" type="submit" class="ui submit primary tiny button btn-add-comment">{{ctx.Locale.Tr "repo.diff.comment.add_review_comment"}}</button> + {{else}} + <button name="pending_review" type="submit" class="ui submit primary tiny button btn-start-review">{{ctx.Locale.Tr "repo.diff.comment.start_review"}}</button> + <button name="single_review" value="true" type="submit" class="ui submit tiny basic button btn-add-single">{{ctx.Locale.Tr "repo.diff.comment.add_single_comment"}}</button> + {{end}} + {{end}} + {{if or (not $.HasComments) $.hidden}} + <button type="button" class="ui submit tiny basic button btn-cancel cancel-code-comment">{{ctx.Locale.Tr "cancel"}}</button> + {{end}} + </div> + </div> + </form> +{{end}} diff --git a/templates/repo/diff/comment_form_datahandler.tmpl b/templates/repo/diff/comment_form_datahandler.tmpl new file mode 100644 index 0000000..d0e4934 --- /dev/null +++ b/templates/repo/diff/comment_form_datahandler.tmpl @@ -0,0 +1,7 @@ +{{if $.comment}} + {{template "repo/diff/comment_form" dict "root" $.root "hidden" $.hidden "reply" $.reply "Line" $.comment.UnsignedLine "File" $.comment.TreePath "Side" $.comment.DiffSide "HasComments" true}} +{{else if $.root}} + {{template "repo/diff/comment_form" $}} +{{else}} + {{template "repo/diff/comment_form" dict "root" $}} +{{end}} diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl new file mode 100644 index 0000000..2e0c85d --- /dev/null +++ b/templates/repo/diff/comments.tmpl @@ -0,0 +1,75 @@ +{{range .comments}} + +{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} +<div class="comment" id="{{.HashTag}}"> + {{if .OriginalAuthor}} + <span class="avatar">{{ctx.AvatarUtils.Avatar nil}}</span> + {{else}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{end}} + <div class="content comment-container"> + <div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between"> + <div class="comment-header-left tw-flex tw-items-center"> + {{if .OriginalAuthor}} + <span class="text black tw-font-semibold tw-mr-1"> + {{svg (MigrationIcon $.root.Repository.GetOriginalURLHostname)}} + {{.OriginalAuthor}} + </span> + <span class="text grey muted-links"> + {{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdStr}} + </span> + <span class="text migrate"> + {{if $.root.Repository.OriginalURL}} + ({{ctx.Locale.Tr "repo.migrated_from" $.root.Repository.OriginalURL $.root.Repository.GetOriginalURLHostname}}) + {{end}} + </span> + {{else}} + <span class="text grey muted-links"> + {{template "shared/user/namelink" .Poster}} + {{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdStr}} + </span> + {{end}} + </div> + <div class="comment-header-right actions tw-flex tw-items-center"> + {{if .Invalidated}} + {{$referenceUrl := printf "%s#%s" $.root.Issue.Link .HashTag}} + <a href="{{AppSubUrl}}{{$referenceUrl}}" class="ui label basic small" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.outdated_description"}}"> + {{ctx.Locale.Tr "repo.issues.review.outdated"}} + </a> + {{end}} + {{if and .Review}} + {{if eq .Review.Type 0}} + <div class="ui label basic small yellow pending-label" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.pending.tooltip" (ctx.Locale.Tr "repo.diff.review") (ctx.Locale.Tr "repo.diff.review.approve") (ctx.Locale.Tr "repo.diff.review.comment") (ctx.Locale.Tr "repo.diff.review.reject")}}"> + {{ctx.Locale.Tr "repo.issues.review.pending"}} + </div> + {{else}} + <div class="ui label basic small"> + {{ctx.Locale.Tr "repo.issues.review.review"}} + </div> + {{end}} + {{end}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $.root "ActionURL" (printf "%s/comments/%d/reactions" $.root.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $.root "item" . "delete" true "issue" false "diff" true "IsCommentPoster" (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}} + </div> + </div> + <div class="ui attached segment comment-body"> + <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.root.IsSigned (eq $.root.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> + {{if .RenderedContent}} + {{.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + <div id="issuecomment-{{.ID}}-raw" class="raw-content tw-hidden">{{.Content}}</div> + <div class="edit-content-zone tw-hidden" data-update-url="{{$.root.RepoLink}}/comments/{{.ID}}" data-content-version="{{.ContentVersion}}" data-context="{{$.root.RepoLink}}" data-attachment-url="{{$.root.RepoLink}}/comments/{{.ID}}/attachments"></div> + {{if .Attachments}} + {{template "repo/issue/view_content/attachments" dict "Attachments" .Attachments "RenderedContent" .RenderedContent}} + {{end}} + </div> + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $.root "ActionURL" (printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions}} + {{end}} + </div> +</div> +{{end}} diff --git a/templates/repo/diff/compare.tmpl b/templates/repo/diff/compare.tmpl new file mode 100644 index 0000000..110f8ac --- /dev/null +++ b/templates/repo/diff/compare.tmpl @@ -0,0 +1,238 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository diff {{if .PageIsComparePull}}compare pull{{end}}"> + {{template "repo/header" .}} + {{$showDiffBox := false}} + <div class="ui container fluid padded"> + <h2 class="ui header"> + {{if and $.PageIsComparePull $.IsSigned (not .Repository.IsArchived)}} + {{ctx.Locale.Tr "repo.pulls.compare_changes"}} + <div class="sub header">{{ctx.Locale.Tr "repo.pulls.compare_changes_desc"}}</div> + {{else}} + {{ctx.Locale.Tr "action.compare_commits_general"}} + {{end}} + </h2> + {{$BaseCompareName := $.BaseName -}} + {{- $HeadCompareName := $.HeadRepo.OwnerName -}} + {{- if and (eq $.BaseName $.HeadRepo.OwnerName) (ne $.Repository.Name $.HeadRepo.Name) -}} + {{- $HeadCompareName = printf "%s/%s" $.HeadRepo.OwnerName $.HeadRepo.Name -}} + {{- end -}} + {{- $OwnForkCompareName := "" -}} + {{- if .OwnForkRepo -}} + {{- $OwnForkCompareName = .OwnForkRepo.OwnerName -}} + {{- end -}} + {{- $RootRepoCompareName := "" -}} + {{- if .RootRepo -}} + {{- $RootRepoCompareName = .RootRepo.OwnerName -}} + {{- if eq $.HeadRepo.OwnerName .RootRepo.OwnerName -}} + {{- $HeadCompareName = printf "%s/%s" $.HeadRepo.OwnerName $.HeadRepo.Name -}} + {{- end -}} + {{- end -}} + <div class="ui segment choose branch"> + <a class="tw-mr-2" href="{{$.HeadRepo.Link}}/compare/{{PathEscapeSegments $.HeadBranch}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.BaseName}}/{{PathEscape $.Repository.Name}}:{{end}}{{PathEscapeSegments $.BaseBranch}}" title="{{ctx.Locale.Tr "repo.pulls.switch_head_and_base"}}">{{svg "octicon-git-compare"}}</a> + <div class="ui floating filter dropdown" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}"> + <div class="ui basic small button"> + <span class="text">{{if $.PageIsComparePull}}{{ctx.Locale.Tr "repo.pulls.compare_base"}}{{else}}{{ctx.Locale.Tr "repo.compare.compare_base"}}{{end}}: {{$BaseCompareName}}:{{$.BaseBranch}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </div> + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-filter" 16}}</i> + <input name="search" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}..."> + </div> + <div class="header"> + <div class="ui grid"> + <div class="two column row"> + <a class="reference column" href="#" data-target=".base-branch-list"> + <span class="text black"> + {{svg "octicon-git-branch" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.branches"}} + </span> + </a> + <a class="reference column" href="#" data-target=".base-tag-list"> + <span class="text black"> + {{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.tags"}} + </span> + </a> + </div> + </div> + </div> + <div class="scrolling menu reference-list-menu base-branch-list"> + {{range .Branches}} + <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments $.HeadBranch}}">{{$BaseCompareName}}:{{.}}</div> + {{end}} + {{if and (not .PullRequestCtx.SameRepo) ($.HeadRepo.AllowsPulls ctx)}} + {{range .HeadBranches}} + <div class="item" data-url="{{$.HeadRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$HeadCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if and .OwnForkRepo (.OwnForkRepo.AllowsPulls ctx)}} + {{range .OwnForkRepoBranches}} + <div class="item" data-url="{{$.OwnForkRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$OwnForkCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if and .RootRepo (.RootRepo.AllowsPulls ctx)}} + {{range .RootRepoBranches}} + <div class="item" data-url="{{$.RootRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$RootRepoCompareName}}:{{.}}</div> + {{end}} + {{end}} + </div> + <div class="scrolling menu reference-list-menu base-tag-list tw-hidden"> + {{range .Tags}} + <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments $.HeadBranch}}">{{$BaseCompareName}}:{{.}}</div> + {{end}} + {{if and (not .PullRequestCtx.SameRepo) ($.HeadRepo.AllowsPulls ctx)}} + {{range .HeadTags}} + <div class="item" data-url="{{$.HeadRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$HeadCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if and .OwnForkRepo (.OwnForkRepo.AllowsPulls ctx)}} + {{range .OwnForkRepoTags}} + <div class="item" data-url="{{$.OwnForkRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$OwnForkCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if and .RootRepo (.RootRepo.AllowsPulls ctx)}} + {{range .RootRepoTags}} + <div class="item" data-url="{{$.RootRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$RootRepoCompareName}}:{{.}}</div> + {{end}} + {{end}} + </div> + </div> + </div> + <a href="{{.RepoLink}}/compare/{{PathEscapeSegments .BaseBranch}}{{.OtherCompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments $.HeadBranch}}" title="{{ctx.Locale.Tr "repo.pulls.switch_comparison_type"}}">{{svg "octicon-arrow-left" 16}}<div class="compare-separator">{{.CompareSeparator}}</div></a> + <div class="ui floating filter dropdown"> + <div class="ui basic small button"> + <span class="text">{{if $.PageIsComparePull}}{{ctx.Locale.Tr "repo.pulls.compare_compare"}}{{else}}{{ctx.Locale.Tr "repo.compare.compare_head"}}{{end}}: {{$HeadCompareName}}:{{$.HeadBranch}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </div> + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-filter" 16}}</i> + <input name="search" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}..."> + </div> + <div class="header"> + <div class="ui grid"> + <div class="two column row"> + <a class="reference column" href="#" data-target=".head-branch-list"> + <span class="text black"> + {{svg "octicon-git-branch" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.branches"}} + </span> + </a> + <a class="reference column" href="#" data-target=".head-tag-list"> + <span class="text black"> + {{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.tags"}} + </span> + </a> + </div> + </div> + </div> + <div class="scrolling menu reference-list-menu head-branch-list"> + {{range .HeadBranches}} + <div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments .}}">{{$HeadCompareName}}:{{.}}</div> + {{end}} + {{if not .PullRequestCtx.SameRepo}} + {{range .Branches}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.BaseName}}/{{PathEscape $.Repository.Name}}:{{PathEscapeSegments .}}">{{$BaseCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if .OwnForkRepo}} + {{range .OwnForkRepoBranches}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.OwnForkRepo.OwnerName}}/{{PathEscape $.OwnForkRepo.Name}}:{{PathEscapeSegments .}}">{{$OwnForkCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if .RootRepo}} + {{range .RootRepoBranches}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.RootRepo.OwnerName}}/{{PathEscape $.RootRepo.Name}}:{{PathEscapeSegments .}}">{{$RootRepoCompareName}}:{{.}}</div> + {{end}} + {{end}} + </div> + <div class="scrolling menu reference-list-menu head-tag-list tw-hidden"> + {{range .HeadTags}} + <div class="{{if eq $.HeadBranch .}}selected{{end}} item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{if not $.PullRequestCtx.SameRepo}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{end}}{{PathEscapeSegments .}}">{{$HeadCompareName}}:{{.}}</div> + {{end}} + {{if not .PullRequestCtx.SameRepo}} + {{range .Tags}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.BaseName}}/{{PathEscape $.Repository.Name}}:{{PathEscapeSegments .}}">{{$BaseCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if .OwnForkRepo}} + {{range .OwnForkRepoTags}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.OwnForkRepo.OwnerName}}/{{PathEscape $.OwnForkRepo.Name}}:{{PathEscapeSegments .}}">{{$OwnForkCompareName}}:{{.}}</div> + {{end}} + {{end}} + {{if .RootRepo}} + {{range .RootRepoTags}} + <div class="item" data-url="{{$.RepoLink}}/compare/{{PathEscapeSegments $.BaseBranch}}{{$.CompareSeparator}}{{PathEscape $.RootRepo.OwnerName}}/{{PathEscape $.RootRepo.Name}}:{{PathEscapeSegments .}}">{{$RootRepoCompareName}}:{{.}}</div> + {{end}} + {{end}} + </div> + </div> + </div> + </div> + + {{if .IsNothingToCompare}} + {{if and $.IsSigned $.AllowEmptyPr (not .Repository.IsArchived) .PageIsComparePull}} + <div class="ui segment">{{ctx.Locale.Tr "repo.pulls.nothing_to_compare_and_allow_empty_pr"}}</div> + <div class="ui info message show-form-container {{if .Flash}}tw-hidden{{end}}"> + <button class="ui button primary show-form">{{ctx.Locale.Tr "repo.pulls.new"}}</button> + </div> + <div class="pullrequest-form {{if not .Flash}}tw-hidden{{end}}"> + {{template "repo/issue/new_form" .}} + </div> + {{else if and .HeadIsBranch .BaseIsBranch}} + <div class="ui segment">{{ctx.Locale.Tr "repo.pulls.nothing_to_compare"}}</div> + {{else}} + <div class="ui segment">{{ctx.Locale.Tr "repo.pulls.nothing_to_compare_have_tag"}}</div> + {{end}} + {{else if and .PageIsComparePull (gt .CommitCount 0)}} + {{if .HasPullRequest}} + <div class="ui segment grid title"> + <div class="twelve wide column issue-title"> + {{ctx.Locale.Tr "repo.pulls.has_pull_request" (print $.RepoLink "/pulls/" .PullRequest.Issue.Index) $.RepoRelPath .PullRequest.Index}} + <h1> + <span id="issue-title">{{RenderIssueTitle $.Context .PullRequest.Issue.Title ($.Repository.ComposeMetas ctx)}}</span> + <span class="index">#{{.PullRequest.Issue.Index}}</span> + </h1> + </div> + <div class="four wide column middle aligned text right"> + {{- if .PullRequest.HasMerged -}} + <a href="{{$.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button purple show-form">{{svg "octicon-git-merge" 16}} {{ctx.Locale.Tr "repo.pulls.view"}}</a> + {{else if .Issue.IsClosed}} + <a href="{{$.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button red show-form">{{svg "octicon-issue-closed" 16}} {{ctx.Locale.Tr "repo.pulls.view"}}</a> + {{else}} + <a href="{{$.RepoLink}}/pulls/{{.PullRequest.Issue.Index}}" class="ui button primary show-form">{{svg "octicon-git-pull-request" 16}} {{ctx.Locale.Tr "repo.pulls.view"}}</a> + {{end}} + </div> + </div> + {{else}} + {{if and $.IsSigned (not .Repository.IsArchived)}} + <div class="ui info message show-form-container {{if .Flash}}tw-hidden{{end}}"> + <button class="ui button primary show-form">{{ctx.Locale.Tr "repo.pulls.new"}}</button> + </div> + {{else if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{if .Repository.ArchivedUnix.IsZero}} + {{ctx.Locale.Tr "repo.archive.title"}} + {{else}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateTime "long" .Repository.ArchivedUnix)}} + {{end}} + </div> + {{end}} + {{if $.IsSigned}} + <div class="pullrequest-form {{if not .Flash}}tw-hidden{{end}}"> + {{template "repo/issue/new_form" .}} + </div> + {{end}} + {{$showDiffBox = true}} + {{end}} + {{else if not .IsNothingToCompare}} + {{$showDiffBox = true}} + {{end}} + </div> + + {{if $showDiffBox}} + <div class="ui container fluid padded"> + {{template "repo/commits_table" .}} + {{template "repo/diff/box" .}} + </div> + {{end}} +</div> +{{template "base/footer" .}} diff --git a/templates/repo/diff/conversation.tmpl b/templates/repo/diff/conversation.tmpl new file mode 100644 index 0000000..c80d999 --- /dev/null +++ b/templates/repo/diff/conversation.tmpl @@ -0,0 +1,66 @@ +{{$resolved := (index .comments 0).IsResolved}} +{{$invalid := (index .comments 0).Invalidated}} +{{$resolveDoer := (index .comments 0).ResolveDoer}} +{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} +{{$referenceUrl := printf "%s#%s" $.Issue.Link (index .comments 0).HashTag}} +<div class="conversation-holder" data-path="{{(index .comments 0).TreePath}}" data-side="{{if lt (index .comments 0).Line 0}}left{{else}}right{{end}}" data-idx="{{(index .comments 0).UnsignedLine}}"> + {{if $resolved}} + <div class="ui attached header resolved-placeholder tw-flex tw-items-center tw-justify-between"> + <div class="ui grey text tw-flex tw-items-center tw-flex-wrap tw-gap-1"> + {{svg "octicon-check" 16 "icon tw-mr-1"}} + <b>{{$resolveDoer.Name}}</b> {{ctx.Locale.Tr "repo.issues.review.resolved_by"}} + {{if $invalid}} + <!-- + We only handle the case $resolved=true and $invalid=true in this template because if the comment is not resolved it has the outdated label in the comments area (not the header above). + The case $resolved=false and $invalid=true is handled in repo/diff/comments.tmpl + --> + <a href="{{AppSubUrl}}{{$referenceUrl}}" class="ui label basic small tw-ml-2" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.outdated_description"}}"> + {{ctx.Locale.Tr "repo.issues.review.outdated"}} + </a> + {{end}} + </div> + <div class="tw-flex tw-items-center tw-gap-2"> + <button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button show-outdated tw-flex tw-items-center"> + {{svg "octicon-unfold" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.review.show_resolved"}} + </button> + <button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="ui tiny labeled button hide-outdated tw-flex tw-items-center tw-hidden"> + {{svg "octicon-fold" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.review.hide_resolved"}} + </button> + </div> + </div> + {{end}} + <div id="code-comments-{{(index .comments 0).ID}}" class="field comment-code-cloud {{if $resolved}}tw-hidden{{end}}"> + <div class="comment-list"> + <ui class="ui comments"> + {{template "repo/diff/comments" dict "root" $ "comments" .comments}} + </ui> + </div> + <div class="button-row tw-flex tw-justify-end tw-items-center tw-flex-wrap tw-mt-2"> + <div class="ui buttons"> + <button class="ui icon tiny basic button previous-conversation"> + {{svg "octicon-arrow-up" 12 "icon"}} {{ctx.Locale.Tr "repo.issues.previous"}} + </button> + <button class="ui icon tiny basic button next-conversation"> + {{svg "octicon-arrow-down" 12 "icon"}} {{ctx.Locale.Tr "repo.issues.next"}} + </button> + </div> + {{if and $.CanMarkConversation $isNotPending}} + <button class="ui icon tiny basic button resolve-conversation" data-origin="diff" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation"> + {{if $resolved}} + {{ctx.Locale.Tr "repo.issues.review.un_resolve_conversation"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.resolve_conversation"}} + {{end}} + </button> + {{end}} + {{if and $.SignedUserID (not $.Repository.IsArchived)}} + <button class="comment-form-reply ui primary tiny labeled icon button"> + {{svg "octicon-reply" 16 "reply icon tw-mr-1"}}{{ctx.Locale.Tr "repo.diff.comment.reply"}} + </button> + {{end}} + </div> + {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}} + </div> +</div> diff --git a/templates/repo/diff/conversations.tmpl b/templates/repo/diff/conversations.tmpl new file mode 100644 index 0000000..5945337 --- /dev/null +++ b/templates/repo/diff/conversations.tmpl @@ -0,0 +1,3 @@ +{{range .conversations}} + {{template "repo/diff/conversation" dict "." $ "comments" .}} +{{end}} diff --git a/templates/repo/diff/csv_diff.tmpl b/templates/repo/diff/csv_diff.tmpl new file mode 100644 index 0000000..0f46da3 --- /dev/null +++ b/templates/repo/diff/csv_diff.tmpl @@ -0,0 +1,58 @@ +<tr> + <td> + {{$result := call .root.CreateCsvDiff .file .blobBase .blobHead}} + {{if $result.Error}} + <div class="ui center">{{$result.Error}}</div> + {{else if $result.Sections}} + <table class="data-table"> + {{range $i, $section := $result.Sections}} + <tbody {{if gt $i 0}}class="section"{{end}}> + {{range $j, $row := $section.Rows}} + <tr> + {{if and (eq $i 0) (eq $j 0)}} + <th class="line-num">{{.RowIdx}}</th> + {{range $j, $cell := $row.Cells}} + {{if not $cell}} + <th></th> + {{else if eq $cell.Type 2}} + <th class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></th> + {{else if eq $cell.Type 3}} + <th class="added"><span class="added-code">{{.RightCell}}</span></th> + {{else if eq $cell.Type 4}} + <th class="removed"><span class="removed-code">{{.LeftCell}}</span></th> + {{else if eq $cell.Type 5}} + <th class="moved">{{.RightCell}}</th> + {{else if eq $cell.Type 6}} + <th class="moved"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></th> + {{else}} + <th>{{.RightCell}}</th> + {{end}} + {{end}} + {{else}} + <td class="line-num">{{if .RowIdx}}{{.RowIdx}}{{end}}</td> + {{range $j, $cell := $row.Cells}} + {{if not $cell}} + <td></td> + {{else if eq $cell.Type 2}} + <td class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></td> + {{else if eq $cell.Type 3}} + <td class="added"><span class="added-code">{{.RightCell}}</span></td> + {{else if eq $cell.Type 4}} + <td class="removed"><span class="removed-code">{{.LeftCell}}</span></td> + {{else if eq $cell.Type 5}} + <td class="moved">{{.RightCell}}</td> + {{else if eq $cell.Type 6}} + <td class="moved"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></td> + {{else}} + <td>{{.RightCell}}</td> + {{end}} + {{end}} + {{end}} + </tr> + {{end}} + </tbody> + {{end}} + </table> + {{end}} + </td> +</tr> diff --git a/templates/repo/diff/escape_title.tmpl b/templates/repo/diff/escape_title.tmpl new file mode 100644 index 0000000..e70f402 --- /dev/null +++ b/templates/repo/diff/escape_title.tmpl @@ -0,0 +1,2 @@ +{{if .diff.EscapeStatus.HasInvisible}}{{ctx.Locale.Tr "repo.invisible_runes_line"}} {{end}}{{/* +*/}}{{if .diff.EscapeStatus.HasAmbiguous}}{{ctx.Locale.Tr "repo.ambiguous_runes_line"}}{{end}} diff --git a/templates/repo/diff/image_diff.tmpl b/templates/repo/diff/image_diff.tmpl new file mode 100644 index 0000000..0612854 --- /dev/null +++ b/templates/repo/diff/image_diff.tmpl @@ -0,0 +1,83 @@ +{{if or .blobBase .blobHead}} +<tr> + <td colspan="2"> + <div class="image-diff" + data-path-before="{{.root.BeforeRawPath}}/{{PathEscapeSegments .file.OldName}}" + data-path-after="{{.root.RawPath}}/{{PathEscapeSegments .file.Name}}" + data-mime-before="{{.sniffedTypeBase.GetMimeType}}" + data-mime-after="{{.sniffedTypeHead.GetMimeType}}" + > + <overflow-menu class="ui secondary pointing tabular top attached borderless menu"> + <div class="overflow-menu-items tw-justify-center"> + <a class="item active" data-tab="diff-side-by-side-{{.file.Index}}">{{ctx.Locale.Tr "repo.diff.image.side_by_side"}}</a> + {{if and .blobBase .blobHead}} + <a class="item" data-tab="diff-swipe-{{.file.Index}}">{{ctx.Locale.Tr "repo.diff.image.swipe"}}</a> + <a class="item" data-tab="diff-overlay-{{.file.Index}}">{{ctx.Locale.Tr "repo.diff.image.overlay"}}</a> + {{end}} + </div> + </overflow-menu> + <div class="image-diff-tabs is-loading"> + <div class="ui bottom attached tab image-diff-container active" data-tab="diff-side-by-side-{{.file.Index}}"> + <div class="diff-side-by-side"> + {{if .blobBase}} + <span class="side"> + <p class="side-header">{{ctx.Locale.Tr "repo.diff.file_before"}}</p> + <span class="before-container"><img class="image-before"></span> + <p> + <span class="bounds-info-before"> + {{ctx.Locale.Tr "repo.diff.file_image_width"}}: <span class="text bounds-info-width"></span> + | + {{ctx.Locale.Tr "repo.diff.file_image_height"}}: <span class="text bounds-info-height"></span> + | + </span> + {{ctx.Locale.Tr "repo.diff.file_byte_size"}}: <span class="text">{{ctx.Locale.TrSize .blobBase.Size}}</span> + </p> + </span> + {{end}} + {{if .blobHead}} + <span class="side"> + <p class="side-header">{{ctx.Locale.Tr "repo.diff.file_after"}}</p> + <span class="after-container"><img class="image-after"></span> + <p> + <span class="bounds-info-after"> + {{ctx.Locale.Tr "repo.diff.file_image_width"}}: <span class="text bounds-info-width"></span> + | + {{ctx.Locale.Tr "repo.diff.file_image_height"}}: <span class="text bounds-info-height"></span> + | + </span> + {{ctx.Locale.Tr "repo.diff.file_byte_size"}}: <span class="text">{{ctx.Locale.TrSize .blobHead.Size}}</span> + </p> + </span> + {{end}} + </div> + </div> + {{if and .blobBase .blobHead}} + <div class="ui bottom attached tab image-diff-container" data-tab="diff-swipe-{{.file.Index}}"> + <div class="diff-swipe"> + <div class="swipe-frame"> + <span class="before-container"><img class="image-before"></span> + <span class="swipe-container"> + <span class="after-container"><img class="image-after"></span> + </span> + <span class="swipe-bar"> + <span class="handle top-handle"></span> + <span class="handle bottom-handle"></span> + </span> + </div> + </div> + </div> + <div class="ui bottom attached tab image-diff-container" data-tab="diff-overlay-{{.file.Index}}"> + <div class="diff-overlay"> + <input type="range" min="0" max="100" value="50"> + <div class="overlay-frame"> + <span class="before-container"><img class="image-before"></span> + <span class="after-container"><img class="image-after"></span> + </div> + </div> + </div> + {{end}} + </div> + </div> + </td> +</tr> +{{end}} diff --git a/templates/repo/diff/new_comment.tmpl b/templates/repo/diff/new_comment.tmpl new file mode 100644 index 0000000..6a71539 --- /dev/null +++ b/templates/repo/diff/new_comment.tmpl @@ -0,0 +1,5 @@ +<div class="conversation-holder"> + <div class="field comment-code-cloud"> + {{template "repo/diff/comment_form_datahandler" .}} + </div> +</div> diff --git a/templates/repo/diff/new_review.tmpl b/templates/repo/diff/new_review.tmpl new file mode 100644 index 0000000..a2eae00 --- /dev/null +++ b/templates/repo/diff/new_review.tmpl @@ -0,0 +1,52 @@ +<div id="review-box"> + <button class="ui tiny primary button tw-pr-1 tw-flex js-btn-review {{if not $.IsShowingAllCommits}}disabled{{end}}" {{if not $.IsShowingAllCommits}}data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.review_only_possible_for_full_diff"}}"{{end}}> + {{ctx.Locale.Tr "repo.diff.review"}} + <span class="ui small label review-comments-counter" data-pending-comment-number="{{.PendingCodeCommentNumber}}">{{.PendingCodeCommentNumber}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </button> + {{if $.IsShowingAllCommits}} + <div class="review-box-panel tippy-target"> + <div class="ui segment"> + <form class="ui form form-fetch-action" action="{{.Link}}/reviews/submit" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="commit_id" value="{{.AfterCommitID}}"> + <div class="field tw-flex tw-items-center"> + <div class="tw-flex-1">{{ctx.Locale.Tr "repo.diff.review.header"}}</div> + <a class="muted close">{{svg "octicon-x" 16}}</a> + </div> + <div class="field"> + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.review.placeholder") + "DropzoneParentContainer" "form" + )}} + </div> + {{if .IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" .}} + </div> + {{end}} + <div class="divider"></div> + {{$showSelfTooltip := (and $.IsSigned ($.Issue.IsPoster $.SignedUser.ID))}} + {{if $showSelfTooltip}} + <span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_approve"}}"> + <button type="submit" name="type" value="approve" disabled class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button> + </span> + {{else}} + <button type="submit" name="type" value="approve" class="ui submit primary tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.approve"}}</button> + {{end}} + <button type="submit" name="type" value="comment" class="ui submit tiny basic button btn-submit">{{ctx.Locale.Tr "repo.diff.review.comment"}}</button> + {{if $showSelfTooltip}} + <span class="tw-inline-block" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.review.self_reject"}}"> + <button type="submit" name="type" value="reject" disabled class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button> + </span> + {{else}} + <button type="submit" name="type" value="reject" class="ui submit red tiny button btn-submit">{{ctx.Locale.Tr "repo.diff.review.reject"}}</button> + {{end}} + </form> + </div> + </div> + {{end}} +</div> diff --git a/templates/repo/diff/options_dropdown.tmpl b/templates/repo/diff/options_dropdown.tmpl new file mode 100644 index 0000000..09b7b80 --- /dev/null +++ b/templates/repo/diff/options_dropdown.tmpl @@ -0,0 +1,33 @@ +<div class="ui dropdown tiny basic button" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.options_button"}}"> + {{svg "octicon-kebab-horizontal"}} + <div class="menu"> + <a class="item" id="show-file-list-btn">{{ctx.Locale.Tr "repo.diff.show_diff_stats"}}</a> + {{if .Issue.Index}} + <a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.patch" download="{{.Issue.Index}}.patch">{{ctx.Locale.Tr "repo.diff.download_patch"}}</a> + <a class="item" href="{{$.RepoLink}}/pulls/{{.Issue.Index}}.diff" download="{{.Issue.Index}}.diff">{{ctx.Locale.Tr "repo.diff.download_diff"}}</a> + {{else if $.PageIsWiki}} + <a class="item" href="{{$.RepoLink}}/wiki/commit/{{PathEscape .Commit.ID.String}}.patch" download="{{ShortSha .Commit.ID.String}}.patch">{{ctx.Locale.Tr "repo.diff.download_patch"}}</a> + <a class="item" href="{{$.RepoLink}}/wiki/commit/{{PathEscape .Commit.ID.String}}.diff" download="{{ShortSha .Commit.ID.String}}.diff">{{ctx.Locale.Tr "repo.diff.download_diff"}}</a> + {{else if .Commit.ID.String}} + <a class="item" href="{{$.RepoLink}}/commit/{{PathEscape .Commit.ID.String}}.patch" download="{{ShortSha .Commit.ID.String}}.patch">{{ctx.Locale.Tr "repo.diff.download_patch"}}</a> + <a class="item" href="{{$.RepoLink}}/commit/{{PathEscape .Commit.ID.String}}.diff" download="{{ShortSha .Commit.ID.String}}.diff">{{ctx.Locale.Tr "repo.diff.download_diff"}}</a> + {{end}} + <a id="expand-files-btn" class="item">{{ctx.Locale.Tr "repo.pulls.expand_files"}}</a> + <a id="collapse-files-btn" class="item">{{ctx.Locale.Tr "repo.pulls.collapse_files"}}</a> + {{if .Issue.Index}} + {{if .ShowOutdatedComments}} + <a class="item" href="?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated=false"> + <label class="tw-pointer-events-none"> + {{ctx.Locale.Tr "repo.issues.review.option.hide_outdated_comments"}} + </label> + </a> + {{else}} + <a class="item" href="?style={{if $.IsSplitStyle}}split{{else}}unified{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated=true"> + <label class="tw-pointer-events-none"> + {{ctx.Locale.Tr "repo.issues.review.option.show_outdated_comments"}} + </label> + </a> + {{end}} + {{end}} + </div> +</div> diff --git a/templates/repo/diff/section_code.tmpl b/templates/repo/diff/section_code.tmpl new file mode 100644 index 0000000..3e8303e --- /dev/null +++ b/templates/repo/diff/section_code.tmpl @@ -0,0 +1 @@ +<code class="code-inner{{if .diff.EscapeStatus.Escaped}} has-escaped{{end}}"{{if .diff.EscapeStatus.Escaped}} title="{{template "repo/diff/escape_title" .}}"{{end}}>{{.diff.Content}}</code> diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl new file mode 100644 index 0000000..50522d9 --- /dev/null +++ b/templates/repo/diff/section_split.tmpl @@ -0,0 +1,156 @@ +{{$file := .file}} +{{$blobExcerptRepoLink := or $.root.CommitRepoLink $.root.RepoLink}} +<colgroup> + <col width="50"> + <col width="10"> + <col width="10"> + <col> + <col width="50"> + <col width="10"> + <col width="10"> + <col> +</colgroup> +{{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + {{$hasmatch := ne $line.Match -1}} + {{if or (ne .GetType 2) (not $hasmatch)}} + <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}"> + {{if eq .GetType 4}} + <td class="lines-num lines-num-old"> + <div class="tw-flex"> + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold-down"}} + </button> + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold-up"}} + </button> + {{end}} + {{if eq $line.GetExpandDirection 2}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=split&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold"}} + </button> + {{end}} + </div> + </td>{{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale}} + <td class="lines-escape lines-escape-old">{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}</td> + <td colspan="6" class="lines-code lines-code-old ">{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/* + */}}</td> + {{else if and (eq .GetType 3) $hasmatch}}{{/* DEL */}} + {{$match := index $section.Lines $line.Match}} + {{- $leftDiff := ""}}{{if $line.LeftIdx}}{{$leftDiff = $section.GetComputedInlineDiffFor $line ctx.Locale}}{{end}} + {{- $rightDiff := ""}}{{if $match.RightIdx}}{{$rightDiff = $section.GetComputedInlineDiffFor $match ctx.Locale}}{{end}} + <td class="lines-num lines-num-old del-code" data-line-num="{{$line.LeftIdx}}"><span rel="diff-{{$file.NameHash}}L{{$line.LeftIdx}}"></span></td> + <td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff}}"></button>{{end}}{{end}}</td> + <td class="lines-type-marker lines-type-marker-old del-code"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> + <td class="lines-code lines-code-old del-code">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* + */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</button>{{/* + */}}{{end}}{{/* + */}}{{if $line.LeftIdx}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $leftDiff}}{{/* + */}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + <td class="lines-num lines-num-new add-code" data-line-num="{{if $match.RightIdx}}{{$match.RightIdx}}{{end}}"><span rel="{{if $match.RightIdx}}diff-{{$file.NameHash}}R{{$match.RightIdx}}{{end}}"></span></td> + <td class="lines-escape add-code lines-escape-new">{{if $match.RightIdx}}{{if $rightDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $rightDiff}}"></button>{{end}}{{end}}</td> + <td class="lines-type-marker lines-type-marker-new add-code">{{if $match.RightIdx}}<span class="tw-font-mono" data-type-marker="{{$match.GetLineTypeMarker}}"></span>{{end}}</td> + <td class="lines-code lines-code-new add-code">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* + */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $match.CanComment)}} tw-invisible{{end}}" data-side="right" data-idx="{{$match.RightIdx}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</button>{{/* + */}}{{end}}{{/* + */}}{{if $match.RightIdx}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $rightDiff}}{{/* + */}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + {{else}} + {{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale}} + <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> + <td class="lines-escape lines-escape-old">{{if $line.LeftIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}{{end}}</td> + <td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> + <td class="lines-code lines-code-old">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 2))}}{{/* + */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-left{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="left" data-idx="{{$line.LeftIdx}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</button>{{/* + */}}{{end}}{{/* + */}}{{if $line.LeftIdx}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/* + */}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td> + <td class="lines-escape lines-escape-new">{{if $line.RightIdx}}{{if $inlineDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button>{{end}}{{end}}</td> + <td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td> + <td class="lines-code lines-code-new">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles (not (eq .GetType 3))}}{{/* + */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-right{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="right" data-idx="{{$line.RightIdx}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</button>{{/* + */}}{{end}}{{/* + */}}{{if $line.RightIdx}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/* + */}}{{else}}{{/* + */}}<code class="code-inner"></code>{{/* + */}}{{end}}{{/* + */}}</td> + {{end}} + </tr> + {{if and (eq .GetType 3) $hasmatch}} + {{$match := index $section.Lines $line.Match}} + {{if or $line.Conversations $match.Conversations}} + <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> + <td class="add-comment-left" colspan="4"> + {{if $line.Conversations}} + {{if eq $line.GetCommentSide "previous"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $line.Conversations}} + {{end}} + {{end}} + {{if $match.Conversations}} + {{if eq $match.GetCommentSide "previous"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $match.Conversations}} + {{end}} + {{end}} + </td> + <td class="add-comment-right" colspan="4"> + {{if $line.Conversations}} + {{if eq $line.GetCommentSide "proposed"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $line.Conversations}} + {{end}} + {{end}} + {{if $match.Conversations}} + {{if eq $match.GetCommentSide "proposed"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $match.Conversations}} + {{end}} + {{end}} + </td> + </tr> + {{end}} + {{else if $line.Conversations}} + <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> + <td class="add-comment-left" colspan="4"> + {{if eq $line.GetCommentSide "previous"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $line.Conversations}} + {{end}} + </td> + <td class="add-comment-right" colspan="4"> + {{if eq $line.GetCommentSide "proposed"}} + {{template "repo/diff/conversations" dict "." $.root "conversations" $line.Conversations}} + {{end}} + </td> + </tr> + {{end}} + {{end}} + {{end}} +{{end}} diff --git a/templates/repo/diff/section_unified.tmpl b/templates/repo/diff/section_unified.tmpl new file mode 100644 index 0000000..ab78097 --- /dev/null +++ b/templates/repo/diff/section_unified.tmpl @@ -0,0 +1,72 @@ +{{$file := .file}} +{{$blobExcerptRepoLink := or $.root.CommitRepoLink $.root.RepoLink}} +<colgroup> + <col width="50"> + <col width="50"> + <col width="10"> + <col width="10"> + <col> +</colgroup> +{{range $j, $section := $file.Sections}} + {{range $k, $line := $section.Lines}} + <tr class="{{.GetHTMLDiffLineType}}-code nl-{{$k}} ol-{{$k}}" data-line-type="{{.GetHTMLDiffLineType}}"> + {{if eq .GetType 4}} + {{if $.root.AfterCommitID}} + <td colspan="2" class="lines-num"> + <div class="tw-flex"> + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 5)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=down&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold-down"}} + </button> + {{end}} + {{if or (eq $line.GetExpandDirection 3) (eq $line.GetExpandDirection 4)}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=up&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold-up"}} + </button> + {{end}} + {{if eq $line.GetExpandDirection 2}} + <button class="code-expander-button" hx-target="closest tr" hx-get="{{$blobExcerptRepoLink}}/blob_excerpt/{{PathEscape $.root.AfterCommitID}}?{{$line.GetBlobExcerptQuery}}&style=unified&direction=&wiki={{$.root.PageIsWiki}}&anchor=diff-{{$file.NameHash}}K{{$line.SectionInfo.RightIdx}}"> + {{svg "octicon-fold"}} + </button> + {{end}} + </div> + </td> + {{else}} + {{/* for code file preview page or comment diffs on pull comment pages, do not show the expansion arrows */}} + <td colspan="2" class="lines-num"></td> + {{end}} + {{else}} + <td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{$file.NameHash}}L{{$line.LeftIdx}}{{end}}"></span></td> + <td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{$file.NameHash}}R{{$line.RightIdx}}{{end}}"></span></td> + {{end}} + {{$inlineDiff := $section.GetComputedInlineDiffFor $line ctx.Locale -}} + <td class="lines-escape"> + {{- if $inlineDiff.EscapeStatus.Escaped -}} + <button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $inlineDiff}}"></button> + {{- end -}} + </td> + <td class="lines-type-marker"><span class="tw-font-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> + {{if eq .GetType 4}} + <td class="chroma lines-code blob-hunk">{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/* + */}}</td> + {{else}} + <td class="chroma lines-code{{if (not $line.RightIdx)}} lines-code-old{{end}}">{{/* + */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* + */}}<button type="button" aria-label="{{ctx.Locale.Tr "repo.diff.comment.add_line_comment"}}" class="ui primary button add-code-comment add-code-comment-{{if $line.RightIdx}}right{{else}}left{{end}}{{if (not $line.CanComment)}} tw-invisible{{end}}" data-side="{{if $line.RightIdx}}right{{else}}left{{end}}" data-idx="{{if $line.RightIdx}}{{$line.RightIdx}}{{else}}{{$line.LeftIdx}}{{end}}">{{/* + */}}{{svg "octicon-plus"}}{{/* + */}}</button>{{/* + */}}{{end}}{{/* + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{/* + */}}</td> + {{end}} + </tr> + {{if $line.Conversations}} + <tr class="add-comment" data-line-type="{{.GetHTMLDiffLineType}}"> + <td class="add-comment-left add-comment-right" colspan="5"> + {{template "repo/diff/conversations" dict "." $.root "conversations" $line.Conversations}} + </td> + </tr> + {{end}} + {{end}} +{{end}} diff --git a/templates/repo/diff/stats.tmpl b/templates/repo/diff/stats.tmpl new file mode 100644 index 0000000..d0dff1b --- /dev/null +++ b/templates/repo/diff/stats.tmpl @@ -0,0 +1,5 @@ +{{Eval .file.Addition "+" .file.Deletion}} +<span class="diff-stats-bar tw-mx-2" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.stats_desc_file" (Eval .file.Addition "+" .file.Deletion) .file.Addition .file.Deletion}}"> + {{/* if the denominator is zero, then the float result is "width: NaNpx", as before, it just works */}} + <div class="diff-stats-add-bar" style="width: {{Eval 100 "*" .file.Addition "/" "(" .file.Addition "+" .file.Deletion "+" 0.0 ")"}}%"></div> +</span> diff --git a/templates/repo/diff/whitespace_dropdown.tmpl b/templates/repo/diff/whitespace_dropdown.tmpl new file mode 100644 index 0000000..c54de16 --- /dev/null +++ b/templates/repo/diff/whitespace_dropdown.tmpl @@ -0,0 +1,30 @@ +<div class="ui dropdown tiny basic button" data-tooltip-content="{{ctx.Locale.Tr "repo.diff.whitespace_button"}}"> + {{svg "gitea-whitespace"}} + <div class="menu"> + <a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=show-all&show-outdated={{$.ShowOutdatedComments}}"> + <label class="tw-pointer-events-none"> + <input class="tw-mr-2 tw-pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "show-all"}} checked{{end}}> + {{ctx.Locale.Tr "repo.diff.whitespace_show_everything"}} + </label> + </a> + <a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-all&show-outdated={{$.ShowOutdatedComments}}"> + <label class="tw-pointer-events-none"> + <input class="tw-mr-2 tw-pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-all"}} checked{{end}}> + {{ctx.Locale.Tr "repo.diff.whitespace_ignore_all_whitespace"}} + </label> + </a> + <a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-change&show-outdated={{$.ShowOutdatedComments}}"> + <label class="tw-pointer-events-none"> + <input class="tw-mr-2 tw-pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-change"}} checked{{end}}> + {{ctx.Locale.Tr "repo.diff.whitespace_ignore_amount_changes"}} + </label> + </a> + <a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-eol&show-outdated={{$.ShowOutdatedComments}}"> + <label class="tw-pointer-events-none"> + <input class="tw-mr-2 tw-pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-eol"}} checked{{end}}> + {{ctx.Locale.Tr "repo.diff.whitespace_ignore_at_eol"}} + </label> + </a> + </div> +</div> +<a class="ui tiny basic button" href="?style={{if .IsSplitStyle}}unified{{else}}split{{end}}&whitespace={{$.WhitespaceBehavior}}&show-outdated={{$.ShowOutdatedComments}}" data-tooltip-content="{{if .IsSplitStyle}}{{ctx.Locale.Tr "repo.diff.show_unified_view"}}{{else}}{{ctx.Locale.Tr "repo.diff.show_split_view"}}{{end}}">{{if .IsSplitStyle}}{{svg "gitea-join"}}{{else}}{{svg "gitea-split"}}{{end}}</a> diff --git a/templates/repo/editor/cherry_pick.tmpl b/templates/repo/editor/cherry_pick.tmpl new file mode 100644 index 0000000..f9c9eef --- /dev/null +++ b/templates/repo/editor/cherry_pick.tmpl @@ -0,0 +1,30 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file editor edit"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <form class="ui edit form" method="post" action="{{.RepoLink}}/_cherrypick/{{.SHA}}/{{.BranchName | PathEscapeSegments}}"> + {{.CsrfTokenHtml}} + <input type="hidden" name="last_commit" value="{{.last_commit}}"> + <input type="hidden" name="page_has_posted" value="true"> + <input type="hidden" name="revert" value="{{if eq .CherryPickType "revert"}}true{{else}}false{{end}}"> + <div class="repo-editor-header"> + <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}"> + {{$shaurl := printf "%s/commit/%s" $.RepoLink (PathEscape .SHA)}} + {{$shalink := HTMLFormat `<a class="ui primary sha label" href="%s">%s</a>` $shaurl (ShortSha .SHA)}} + {{if eq .CherryPickType "revert"}} + {{ctx.Locale.Tr "repo.editor.revert" $shalink}} + {{else}} + {{ctx.Locale.Tr "repo.editor.cherry_pick" $shalink}} + {{end}} + <a class="section" href="{{$.RepoLink}}">{{.Repository.FullName}}</a> + <div class="breadcrumb-divider">:</div> + <a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a> + <span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$shaurl}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span> + </div> + </div> + {{template "repo/editor/commit_form" .}} + </form> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/editor/commit_form.tmpl b/templates/repo/editor/commit_form.tmpl new file mode 100644 index 0000000..9f81b1d --- /dev/null +++ b/templates/repo/editor/commit_form.tmpl @@ -0,0 +1,82 @@ +<div class="commit-form-wrapper"> + {{ctx.AvatarUtils.Avatar .SignedUser 48 "commit-avatar"}} + <div class="commit-form"> + <h3>{{- if .CanCommitToBranch.WillSign}} + <span title="{{ctx.Locale.Tr "repo.signing.will_sign" .CanCommitToBranch.SigningKey}}">{{svg "octicon-lock" 24}}</span> + {{ctx.Locale.Tr "repo.editor.commit_signed_changes"}} + {{- else}} + <span title="{{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .CanCommitToBranch.WontSignReason)}}">{{svg "octicon-unlock" 24}}</span> + {{ctx.Locale.Tr "repo.editor.commit_changes"}} + {{- end}}</h3> + <div class="field"> + <input name="commit_summary" maxlength="100" placeholder="{{if .PageIsDelete}}{{ctx.Locale.Tr "repo.editor.delete" .TreePath}}{{else if .PageIsUpload}}{{ctx.Locale.Tr "repo.editor.upload_files_to_dir" .TreePath}}{{else if .IsNewFile}}{{ctx.Locale.TrString "repo.editor.add_tmpl"}}{{else if .PageIsPatch}}{{ctx.Locale.Tr "repo.editor.patch"}}{{else}}{{ctx.Locale.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus> + </div> + <div class="field"> + <textarea name="commit_message" placeholder="{{ctx.Locale.Tr "repo.editor.commit_message_desc"}}" rows="5">{{.commit_message}}</textarea> + </div> + <div class="inline field"> + <div class="ui checkbox"> + <input name="signoff" type="checkbox"> + <label>{{ctx.Locale.Tr "repo.editor.signoff_desc"}}</label> + </div> + </div> + <div class="quick-pull-choice js-quick-pull-choice"> + <div class="field"> + <div class="ui radio checkbox {{if not .CanCommitToBranch.CanCommitToBranch}}disabled{{end}}"> + <input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="direct" button_text="{{ctx.Locale.Tr "repo.editor.commit_changes"}}" {{if eq .commit_choice "direct"}}checked{{end}}> + <label> + {{svg "octicon-git-commit"}} + {{ctx.Locale.Tr "repo.editor.commit_directly_to_this_branch" .BranchName}} + {{if not .CanCommitToBranch.CanCommitToBranch}} + <div class="ui visible small warning message"> + {{ctx.Locale.Tr "repo.editor.no_commit_to_branch"}} + <ul> + {{if not .CanCommitToBranch.UserCanPush}}<li>{{ctx.Locale.Tr "repo.editor.user_no_push_to_branch"}}</li>{{end}} + {{if and .CanCommitToBranch.RequireSigned (not .CanCommitToBranch.WillSign)}}<li>{{ctx.Locale.Tr "repo.editor.require_signed_commit"}}</li>{{end}} + </ul> + </div> + {{end}} + </label> + </div> + </div> + {{if not .Repository.IsEmpty}} + <div class="field"> + <div class="ui radio checkbox"> + {{if .CanCreatePullRequest}} + <input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="commit-to-new-branch" button_text="{{ctx.Locale.Tr "repo.editor.propose_file_change"}}" {{if eq .commit_choice "commit-to-new-branch"}}checked{{end}}> + {{else}} + <input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="commit-to-new-branch" button_text="{{ctx.Locale.Tr "repo.editor.commit_changes"}}" {{if eq .commit_choice "commit-to-new-branch"}}checked{{end}}> + {{end}} + <label> + {{svg "octicon-git-pull-request"}} + {{if .CanCreatePullRequest}} + {{ctx.Locale.Tr "repo.editor.create_new_branch"}} + {{else}} + {{ctx.Locale.Tr "repo.editor.create_new_branch_np"}} + {{end}} + </label> + </div> + </div> + <div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}tw-hidden{{end}}"> + <div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}"> + {{svg "octicon-git-branch"}} + <input type="text" name="new_branch_name" maxlength="100" value="{{.new_branch_name}}" class="input-contrast tw-mr-1 js-quick-pull-new-branch-name" placeholder="{{ctx.Locale.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}} title="{{ctx.Locale.Tr "repo.editor.new_branch_name"}}"> + <span class="text-muted js-quick-pull-normalization-info"></span> + </div> + </div> + {{end}} + </div> + <div class="field {{if .Err_CommitMailID}}error{{end}}"> + <label for="commit_mail_id">Commit email</label> + <select class="ui selection dropdown" name="commit_mail_id"> + {{range .CommitMails}} + <option{{if eq $.DefaultCommitMail .Email}} selected="selected"{{end}} value="{{.ID}}">{{.Email}}</option> + {{end}} + </select> + </div> + </div> + <button id="commit-button" type="submit" class="ui primary button"> + {{if eq .commit_choice "commit-to-new-branch"}}{{ctx.Locale.Tr "repo.editor.propose_file_change"}}{{else}}{{ctx.Locale.Tr "repo.editor.commit_changes"}}{{end}} + </button> + <a class="ui button red" href="{{$.BranchLink}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.editor.cancel"}}</a> +</div> diff --git a/templates/repo/editor/delete.tmpl b/templates/repo/editor/delete.tmpl new file mode 100644 index 0000000..2c0c2fc --- /dev/null +++ b/templates/repo/editor/delete.tmpl @@ -0,0 +1,13 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file editor delete"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <form class="ui form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="last_commit" value="{{.last_commit}}"> + {{template "repo/editor/commit_form" .}} + </form> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/editor/diff_preview.tmpl b/templates/repo/editor/diff_preview.tmpl new file mode 100644 index 0000000..e2e922b --- /dev/null +++ b/templates/repo/editor/diff_preview.tmpl @@ -0,0 +1,11 @@ +<div class="diff-file-box"> + <div class="ui attached table segment"> + <div class="file-body file-code code-diff code-diff-unified unicode-escaped"> + <table> + <tbody> + {{template "repo/diff/section_unified" dict "file" .File "root" $}} + </tbody> + </table> + </div> + </div> +</div> diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl new file mode 100644 index 0000000..71cecf1 --- /dev/null +++ b/templates/repo/editor/edit.tmpl @@ -0,0 +1,74 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file editor edit"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <form class="ui edit form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="last_commit" value="{{.last_commit}}"> + <input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}"> + <div class="repo-editor-header"> + <div class="ui breadcrumb field{{if .Err_TreePath}} error{{end}}"> + <a class="section" href="{{$.BranchLink}}">{{.Repository.Name}}</a> + {{$n := len .TreeNames}} + {{$l := Eval $n "-" 1}} + {{range $i, $v := .TreeNames}} + <div class="breadcrumb-divider">/</div> + {{if eq $i $l}} + <input id="file-name" maxlength="255" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.name_your_file"}}" data-editorconfig="{{$.EditorconfigJson}}" required autofocus> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span> + {{else}} + <span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span> + {{end}} + {{end}} + <span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}{{if not .IsNewFile}}/{{PathEscapeSegments .TreePath}}{{end}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span> + <input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required> + </div> + </div> + <div class="field"> + <div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff"> + <a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a> + <a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a> + {{if not .IsNewFile}} + <a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a> + {{end}} + </div> + <div class="ui bottom attached active tab segment" data-tab="write"> + <textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-{{.TreePath}}" + data-url="{{.Repository.Link}}/markup" + data-context="{{.RepoLink}}" + data-previewable-extensions="{{.PreviewableExtensions}}" + data-line-wrap-extensions="{{.LineWrapExtensions}}">{{.FileContent}}</textarea> + <div class="editor-loading is-loading"></div> + </div> + <div class="ui bottom attached tab segment markup" data-tab="preview"> + {{ctx.Locale.Tr "loading"}} + </div> + <div class="ui bottom attached tab segment diff edit-diff" data-tab="diff"> + <div class="tw-p-16"></div> + </div> + </div> + {{template "repo/editor/commit_form" .}} + </form> + </div> + <div class="ui g-modal-confirm modal" id="edit-empty-content-modal"> + <div class="header"> + {{svg "octicon-file"}} + {{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}} + </div> + <div class="center content"> + <p>{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}</p> + </div> + <div class="actions"> + <button class="ui cancel button"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.editor.cancel"}} + </button> + <button class="ui primary ok button"> + {{svg "fontawesome-save"}} + {{ctx.Locale.Tr "repo.editor.commit_changes"}} + </button> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl new file mode 100644 index 0000000..1f046a8 --- /dev/null +++ b/templates/repo/editor/patch.tmpl @@ -0,0 +1,57 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file editor edit"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}"> + {{.CsrfTokenHtml}} + <input type="hidden" name="last_commit" value="{{.last_commit}}"> + <input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}"> + <div class="repo-editor-header"> + <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}"> + {{ctx.Locale.Tr "repo.editor.patching"}} + <a class="section" href="{{$.RepoLink}}">{{.Repository.FullName}}</a> + <div class="breadcrumb-divider">:</div> + <a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a> + <span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span> + <input type="hidden" id="tree_path" name="tree_path" value="patch" required> + <input id="file-name" maxlength="500" type="hidden" value="diff.patch"> + </div> + </div> + <div class="field"> + <div class="ui top attached tabular menu" data-write="write"> + <a class="active item" data-tab="write">{{svg "octicon-code" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.editor.new_patch"}}</a> + </div> + <div class="ui bottom attached active tab segment" data-tab="write"> + <textarea id="edit_area" name="content" class="tw-hidden" data-id="repo-{{.Repository.Name}}-patch" + data-context="{{.RepoLink}}" + data-line-wrap-extensions="{{.LineWrapExtensions}}"> +{{.FileContent}}</textarea> + <div class="editor-loading is-loading"></div> + </div> + </div> + {{template "repo/editor/commit_form" .}} + </form> + </div> + + <div class="ui g-modal-confirm modal" id="edit-empty-content-modal"> + <div class="header"> + {{svg "octicon-file"}} + {{ctx.Locale.Tr "repo.editor.commit_empty_file_header"}} + </div> + <div class="center content"> + <p>{{ctx.Locale.Tr "repo.editor.commit_empty_file_text"}}</p> + </div> + <div class="actions"> + <button class="ui cancel button"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.editor.cancel"}} + </button> + <button class="ui primary ok button"> + {{svg "fontawesome-save"}} + {{ctx.Locale.Tr "repo.editor.commit_changes"}} + </button> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/editor/upload.tmpl b/templates/repo/editor/upload.tmpl new file mode 100644 index 0000000..5725020 --- /dev/null +++ b/templates/repo/editor/upload.tmpl @@ -0,0 +1,33 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file editor upload"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <form class="ui comment form" method="post"> + {{.CsrfTokenHtml}} + <div class="repo-editor-header"> + <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}"> + <a class="section" href="{{$.BranchLink}}">{{.Repository.Name}}</a> + {{$n := len .TreeNames}} + {{$l := Eval $n "-" 1}} + {{range $i, $v := .TreeNames}} + <div class="breadcrumb-divider">/</div> + {{if eq $i $l}} + <input type="text" id="file-name" maxlength="255" value="{{$v}}" placeholder="{{ctx.Locale.Tr "repo.editor.add_subdir"}}" autofocus> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.editor.filename_help"}}">{{svg "octicon-info"}}</span> + {{else}} + <span class="section"><a href="{{$.BranchLink}}/{{index $.TreePaths $i | PathEscapeSegments}}">{{$v}}</a></span> + {{end}} + {{end}} + <span>{{ctx.Locale.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}{{if not .IsNewFile}}/{{.TreePath | PathEscapeSegments}}{{end}}">{{ctx.Locale.Tr "repo.editor.cancel_lower"}}</a></span> + <input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required> + </div> + </div> + <div class="field"> + {{template "repo/upload" .}} + </div> + {{template "repo/editor/commit_form" .}} + </form> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl new file mode 100644 index 0000000..7613643 --- /dev/null +++ b/templates/repo/empty.tmpl @@ -0,0 +1,82 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository quickstart"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="ui grid"> + <div class="sixteen wide column content"> + {{template "base/alert" .}} + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{if .Repository.ArchivedUnix.IsZero}} + {{ctx.Locale.Tr "repo.archive.title"}} + {{else}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateTime "long" .Repository.ArchivedUnix)}} + {{end}} + </div> + {{end}} + {{if .Repository.IsBroken}} + <div class="ui segment center"> + {{ctx.Locale.Tr "repo.broken_message"}} + </div> + {{else if .CanWriteCode}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.quick_guide"}} + </h4> + <div class="ui attached guide table segment empty-repo-guide"> + <div class="item"> + <h3>{{ctx.Locale.Tr "repo.clone_this_repo"}} <small>{{ctx.Locale.Tr "repo.clone_helper" "http://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository"}}</small></h3> + + <div class="repo-button-row"> + {{if and .CanWriteCode (not .Repository.IsArchived)}} + <a class="ui small button" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/"> + {{ctx.Locale.Tr "repo.editor.new_file"}} + </a> + {{if .RepositoryUploadEnabled}} + <a class="ui small button" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/"> + {{ctx.Locale.Tr "repo.editor.upload_file"}} + </a> + {{end}} + {{end}} + <div class="clone-panel ui action small input tw-flex-1"> + {{template "repo/clone_buttons" .}} + </div> + </div> + </div> + + {{if not .Repository.IsArchived}} + <div class="divider tw-my-0"></div> + + <div class="item"> + <h3>{{ctx.Locale.Tr "repo.create_new_repo_command"}}</h3> + <div class="markup"> + <pre><code>touch README.md +git init +{{if ne .Repository.DefaultBranch "master"}}git checkout -b {{.Repository.DefaultBranch}}{{end}} +git add README.md +git commit -m "first commit" +git remote add origin <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span> +git push -u origin {{.Repository.DefaultBranch}}</code></pre> + </div> + </div> + <div class="divider"></div> + + <div class="item"> + <h3>{{ctx.Locale.Tr "repo.push_exist_repo"}}</h3> + <div class="markup"> + <pre><code>git remote add origin <span class="js-clone-url">{{$.CloneButtonOriginLink.HTTPS}}</span> +git push -u origin {{.Repository.DefaultBranch}}</code></pre> + </div> + </div> + {{end}} + {{else}} + <div class="ui segment center"> + {{ctx.Locale.Tr "repo.empty_message"}} + </div> + {{end}} + {{template "repo/clone_script" .}} + </div> + </div> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/file_info.tmpl b/templates/repo/file_info.tmpl new file mode 100644 index 0000000..6ae7c15 --- /dev/null +++ b/templates/repo/file_info.tmpl @@ -0,0 +1,53 @@ +<div class="file-info tw-font-mono"> + {{if .FileIsSymlink}} + <div class="file-info-entry"> + {{ctx.Locale.Tr "repo.symbolic_link"}} + </div> + {{end}} + {{if .NumLinesSet}}{{/* Explicit attribute needed to show 0 line changes */}} + <div class="file-info-entry"> + {{.NumLines}} {{ctx.Locale.TrN .NumLines "repo.line" "repo.lines"}} + </div> + {{end}} + {{if .HasNoTrailingEOL}} + <div class="file-info-entry" data-tooltip-content="{{ctx.Locale.Tr "repo.no_eol.tooltip"}}"> + {{ctx.Locale.Tr "repo.no_eol.text"}} + </div> + {{end}} + {{if .FileSize}} + <div class="file-info-entry"> + {{ctx.Locale.TrSize .FileSize}}{{if .IsLFSFile}} ({{ctx.Locale.Tr "repo.stored_lfs"}}){{end}} + </div> + {{end}} + {{if .LFSLock}} + <div class="file-info-entry ui" data-tooltip-content="{{.LFSLockHint}}"> + {{svg "octicon-lock" 16 "tw-mr-1"}} + <a href="{{.LFSLockOwnerHomeLink}}">{{.LFSLockOwner}}</a> + </div> + {{end}} + {{if .LexerName}} + <div class="file-info-entry"> + {{.LexerName}} + </div> + {{end}} + {{if .IsExecutable}} + <div class="file-info-entry"> + {{ctx.Locale.Tr "repo.executable_file"}} + </div> + {{end}} + {{if .IsVendored}} + <div class="file-info-entry"> + {{ctx.Locale.Tr "repo.vendored"}} + </div> + {{end}} + {{if .IsGenerated}} + <div class="file-info-entry"> + {{ctx.Locale.Tr "repo.generated"}} + </div> + {{end}} + {{if .ImageSize}} + <div class="file-info-entry"> + {{.ImageSize}} + </div> + {{end}} +</div> diff --git a/templates/repo/find/files.tmpl b/templates/repo/find/files.tmpl new file mode 100644 index 0000000..548ce2f --- /dev/null +++ b/templates/repo/find/files.tmpl @@ -0,0 +1,21 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="tw-flex tw-items-center"> + <a href="{{$.RepoLink}}">{{.RepoName}}</a> + <span class="tw-mx-2">/</span> + <div class="ui input tw-flex-1"> + <input id="repo-file-find-input" type="text" autofocus data-url-data-link="{{.DataLink}}" data-url-tree-link="{{.TreeLink}}"> + </div> + </div> + <table id="repo-find-file-table" class="ui single line table"> + <tbody> + </tbody> + </table> + <div id="repo-find-file-no-result" class="ui row center tw-mt-8 tw-hidden"> + <h3>{{ctx.Locale.Tr "repo.find_file.no_matching"}}</h3> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/flags.tmpl b/templates/repo/flags.tmpl new file mode 100644 index 0000000..620357b --- /dev/null +++ b/templates/repo/flags.tmpl @@ -0,0 +1,33 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <div class="user-main-content twelve wide column"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.admin.manage_flags"}} + </h4> + <div class="ui attached segment"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <strong>{{ctx.Locale.Tr "repo.admin.enabled_flags"}}</strong> + <div class="ui segment tw-pl-4"> + {{range $flag, $checked := .Flags}} + <div class="field"> + <div class="ui checkbox{{if $checked}} checked{{end}}"> + <input name="flags" type="checkbox" value="{{$flag}}" {{if $checked}}checked{{end}}> + <label>{{$flag}}</label> + </div> + </div> + {{end}} + </div> + + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.admin.update_flags"}}</button> + </div> + </form> + </div> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/forks.tmpl b/templates/repo/forks.tmpl new file mode 100644 index 0000000..412c59b --- /dev/null +++ b/templates/repo/forks.tmpl @@ -0,0 +1,18 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository forks"> + {{template "repo/header" .}} + <div class="ui container"> + <h2 class="ui dividing header"> + {{ctx.Locale.Tr "repo.forks"}} + </h2> + {{range .Forks}} + <div class="tw-flex tw-items-center tw-py-2"> + <span class="tw-mr-1">{{ctx.AvatarUtils.Avatar .Owner}}</span> + <a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a> / <a href="{{.Link}}">{{.Name}}</a> + </div> + {{end}} + </div> + + {{template "base/paginate" .}} +</div> +{{template "base/footer" .}} diff --git a/templates/repo/graph.tmpl b/templates/repo/graph.tmpl new file mode 100644 index 0000000..04b056c --- /dev/null +++ b/templates/repo/graph.tmpl @@ -0,0 +1,65 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository commits"> + {{template "repo/header" .}} + <div class="ui container"> + <div id="git-graph-container" class="ui segment{{if eq .Mode "monochrome"}} monochrome{{end}}"> + <div id="git-graph-heading"> + <div id="git-graph-heading-left"> + <h2>{{ctx.Locale.Tr "repo.commit_graph"}}</h2> + <div class="ui multiple selection search dropdown" id="flow-select-refs-dropdown"> + <input type="hidden" name="flow"> + <div class="default text">{{ctx.Locale.Tr "repo.commit_graph.select"}}</div> + <div class="menu"> + <div class="item" data-value="...flow-hide-pr-refs"> + <span class="flex-text-block"> + {{svg "octicon-eye-closed" 16 "tw-mr-1"}}<span class="gt-ellipsis" title="{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}">{{ctx.Locale.Tr "repo.commit_graph.hide_pr_refs"}}</span> + </span> + </div> + {{range .AllRefs}} + {{$refGroup := .RefGroup}} + {{if eq $refGroup "pull"}} + <div class="item" data-value="{{.Name}}"> + <span class="flex-text-block"> + {{svg "octicon-git-pull-request" 16 "tw-mr-1"}}<span class="gt-ellipsis" title="{{.ShortName}}">#{{.ShortName}}</span> + </span> + </div> + {{else if eq $refGroup "tags"}} + <div class="item" data-value="{{.Name}}"> + <span class="flex-text-block"> + {{svg "octicon-tag" 16 "tw-mr-1"}}<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span> + </span> + </div> + {{else if eq $refGroup "remotes"}} + <div class="item" data-value="{{.Name}}"> + <span class="flex-text-block"> + {{svg "octicon-cross-reference" 16 "tw-mr-1"}}<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span> + </span> + </div> + {{else if eq $refGroup "heads"}} + <div class="item" data-value="{{.Name}}"> + <span class="flex-text-block"> + {{svg "octicon-git-branch" 16 "tw-mr-1"}}<span class="gt-ellipsis" title="{{.ShortName}}">{{.ShortName}}</span> + </span> + </div> + {{end}} + {{end}} + </div> + </div> + </div> + <div class="ui icon buttons small"> + <button id="flow-color-monochrome" class="ui icon button{{if eq .Mode "monochrome"}} active{{end}}" title="{{ctx.Locale.Tr "repo.commit_graph.monochrome"}}">{{svg "material-invert-colors" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.commit_graph.monochrome"}}</button> + <button id="flow-color-colored" class="ui icon button{{if ne .Mode "monochrome"}} active{{end}}" title="{{ctx.Locale.Tr "repo.commit_graph.color"}}">{{svg "material-palette" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.commit_graph.color"}}</button> + </div> + </div> + <div id="git-graph-content"> + <div class="is-loading tw-py-32 tw-hidden" id="loading-indicator"></div> + {{template "repo/graph/svgcontainer" .}} + {{template "repo/graph/commits" .}} + </div> + </div> + </div> +</div> +<div id="pagination"> + {{template "base/paginate" .}} +</div> +{{template "base/footer" .}} diff --git a/templates/repo/graph/commits.tmpl b/templates/repo/graph/commits.tmpl new file mode 100644 index 0000000..5c768f3 --- /dev/null +++ b/templates/repo/graph/commits.tmpl @@ -0,0 +1,79 @@ +<div id="rev-container"> + <ul id="rev-list"> + {{range $commitI, $commit := .Graph.Commits}} + <li {{if $commit.Rev}}id="commit-{{$commit.Rev}}"{{end}} data-flow="{{$commit.Flow}}"> + {{if $commit.OnlyRelation}} + <span></span> + {{else}} + <span class="sha" id="{{$commit.ShortRev}}"> + {{$class := "ui sha label"}} + {{if $commit.Commit.Signature}} + {{$class = (print $class " isSigned")}} + {{if $commit.Verification.Verified}} + {{if eq $commit.Verification.TrustStatus "trusted"}} + {{$class = (print $class " isVerified")}} + {{else if eq $commit.Verification.TrustStatus "untrusted"}} + {{$class = (print $class " isVerifiedUntrusted")}} + {{else}} + {{$class = (print $class " isVerifiedUnmatched")}} + {{end}} + {{else if $commit.Verification.Warning}} + {{$class = (print $class " isWarning")}} + {{end}} + {{end}} + <a href="{{$.RepoLink}}/commit/{{$commit.Rev|PathEscape}}" rel="nofollow" class="{{$class}}"> + <span class="shortsha">{{ShortSha $commit.Commit.ID.String}}</span> + {{- if $commit.Commit.Signature -}} + {{template "repo/shabox_badge" dict "root" $ "verification" $commit.Verification}} + {{- end -}} + </a> + </span> + <span class="message tw-inline-block gt-ellipsis tw-mr-2"> + <span>{{RenderCommitMessage $.Context $commit.Subject ($.Repository.ComposeMetas ctx)}}</span> + </span> + <span class="commit-refs tw-flex tw-items-center tw-mr-1"> + {{range $commit.Refs}} + {{$refGroup := .RefGroup}} + {{if eq $refGroup "pull"}} + {{if or (not $.HidePRRefs) (SliceUtils.Contains $.SelectedBranches .Name)}} + <!-- it's intended to use issues not pulls, if it's a pull you will get redirected --> + <a class="ui basic button" href="{{$.RepoLink}}/{{if $.Repository.UnitEnabled $.Context $.UnitTypePullRequests}}pulls{{else}}issues{{end}}/{{.ShortName|PathEscape}}"> + {{svg "octicon-git-pull-request"}} #{{.ShortName}} + </a> + {{end}} + {{else if eq $refGroup "tags"}} + <a class="ui basic button" href="{{$.RepoLink}}/src/tag/{{.ShortName|PathEscape}}"> + {{svg "octicon-tag"}} {{.ShortName}} + </a> + {{else if eq $refGroup "remotes"}} + <a class="ui basic button" href="{{$.RepoLink}}/src/commit/{{$commit.Rev|PathEscape}}"> + {{svg "octicon-cross-reference"}} {{.ShortName}} + </a> + {{else if eq $refGroup "heads"}} + <a class="ui basic button" href="{{$.RepoLink}}/src/branch/{{.ShortName|PathEscape}}"> + {{svg "octicon-git-branch"}} {{.ShortName}} + </a> + {{else}} + <!-- Unknown ref type .Name --> + {{end}} + {{end}} + </span> + <span class="author tw-flex tw-items-center tw-mr-2"> + {{$userName := $commit.Commit.Author.Name}} + {{if $commit.User}} + {{if and $commit.User.FullName DefaultShowFullName}} + {{$userName = $commit.User.FullName}} + {{end}} + <span class="tw-mr-1">{{ctx.AvatarUtils.Avatar $commit.User}}</span> + <a href="{{$commit.User.HomeLink}}">{{$userName}}</a> + {{else}} + <span class="tw-mr-1">{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName}}</span> + {{$userName}} + {{end}} + </span> + <span class="time tw-flex tw-items-center">{{DateTime "full" $commit.Date}}</span> + {{end}} + </li> + {{end}} + </ul> +</div> diff --git a/templates/repo/graph/div.tmpl b/templates/repo/graph/div.tmpl new file mode 100644 index 0000000..c0bd4e2 --- /dev/null +++ b/templates/repo/graph/div.tmpl @@ -0,0 +1,7 @@ +<div> + {{template "repo/graph/svgcontainer" .}} + {{template "repo/graph/commits" .}} + <div id="pagination"> + {{template "base/paginate" .}} + </div> +</div> diff --git a/templates/repo/graph/svgcontainer.tmpl b/templates/repo/graph/svgcontainer.tmpl new file mode 100644 index 0000000..99c3c87 --- /dev/null +++ b/templates/repo/graph/svgcontainer.tmpl @@ -0,0 +1,24 @@ +<div id="rel-container"> + <svg viewbox="{{Eval .Graph.MinColumn "*" 5}} {{Eval .Graph.MinRow "*" 12}} {{Eval .Graph.Width "*" 5 "+" 5}} {{Eval .Graph.Height "*" 12}}" width="{{Eval .Graph.Width "*" 10 "+" 10}}px"> + {{range $flowid, $flow := .Graph.Flows}} + <g id="flow-{{$flow.ID}}" class="flow-group flow-color-{{$flow.ColorNumber}} flow-color-16-{{$flow.Color16}}" data-flow="{{$flow.ID}}" data-color="{{$flow.ColorNumber}}"> + <path d="{{range $i, $glyph := $flow.Glyphs -}} + {{- if or (eq $glyph.Glyph '*') (eq $glyph.Glyph '|') -}} + M {{Eval $glyph.Column "*" 5 "+" 5}} {{Eval $glyph.Row "*" 12 "+" 0}} v 12 {{/* */ -}} + {{- else if eq $glyph.Glyph '/' -}} + M {{Eval $glyph.Column "*" 5 "+" 10}} {{Eval $glyph.Row "*" 12 "+" 0}} l -10 12 {{/* */ -}} + {{- else if eq $glyph.Glyph '\\' -}} + M {{Eval $glyph.Column "*" 5 "+" 0}} {{Eval $glyph.Row "*" 12 "+" 0}} l 10 12 {{/* */ -}} + {{- else if or (eq $glyph.Glyph '-') (eq $glyph.Glyph '.') -}} + M {{Eval $glyph.Column "*" 5 "+" 0}} {{Eval $glyph.Row "*" 12 "+" 12}} h 5 {{/* */ -}} + {{- else if eq $glyph.Glyph '_' -}} + M {{Eval $glyph.Column "*" 5 "+" 0}} {{Eval $glyph.Row "*" 12 "+" 12}} h 10 {{/* */ -}} + {{- end -}} + {{- end}}" stroke-width="1" fill="none" id="flow-{{$flow.ID}}-path" stroke-linecap="round"></path> + {{range $flow.Commits}} + <circle class="flow-commit" cx="{{Eval .Column "*" 5 "+" 5}}" cy="{{Eval .Row "*" 12 "+" 6}}" r="2.5" stroke="none" id="flow-commit-{{.Rev}}" data-rev="{{.Rev}}"></circle> + {{end}} + </g> + {{end}} + </svg> +</div> diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl new file mode 100644 index 0000000..777453e --- /dev/null +++ b/templates/repo/header.tmpl @@ -0,0 +1,201 @@ +<div class="secondary-nav"> +{{with .Repository}} + <div class="ui container"> + <div class="repo-header"> + <div class="flex-item tw-items-center"> + <div class="flex-item-leading"> + {{template "repo/icon" .}} + </div> + <div class="flex-item-main"> + <div class="flex-item-title gt-font-18"> + <a class="muted gt-font-normal" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/<a class="muted" href="{{$.RepoLink}}">{{.Name}}</a> + </div> + </div> + <div class="flex-item-trailing"> + {{if .IsArchived}} + <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.archived"}}</span> + <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.archived"}}">{{svg "octicon-archive" 18}}</div> + {{end}} + {{if .IsPrivate}} + <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.private"}}</span> + <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.private"}}">{{svg "octicon-lock" 18}}</div> + {{else}} + {{if .Owner.Visibility.IsPrivate}} + <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.internal"}}</span> + <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.internal"}}">{{svg "octicon-shield-lock" 18}}</div> + {{end}} + {{end}} + {{if .IsTemplate}} + <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.template"}}</span> + <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.template"}}">{{svg "octicon-repo-template" 18}}</div> + {{end}} + {{if eq .ObjectFormatName "sha256"}} + <span class="ui basic label">{{ctx.Locale.Tr "repo.desc.sha256"}}</span> + {{end}} + </div> + </div> + {{if not (or .IsBeingCreated .IsBroken)}} + <div class="repo-buttons button-row"> + {{if $.RepoTransfer}} + <form method="post" action="{{$.RepoLink}}/action/accept_transfer?redirect_to={{$.RepoLink}}"> + {{$.CsrfTokenHtml}} + <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}"> + <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}primary {{end}} ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}> + {{ctx.Locale.Tr "repo.transfer.accept"}} + </button> + </div> + </form> + <form method="post" action="{{$.RepoLink}}/action/reject_transfer?redirect_to={{$.RepoLink}}"> + {{$.CsrfTokenHtml}} + <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}"> + <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}red {{end}}ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}> + {{ctx.Locale.Tr "repo.transfer.reject"}} + </button> + </div> + </form> + {{end}} + {{if $.EnableFeed}} + {{/* An extra div-element is not necessary here, as this button does not secretly contain two buttons. */}} + <a class="ui compact small basic button" href="{{$.RepoLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}"> + {{svg "octicon-rss" 16}} + </a> + {{end}} + {{template "repo/watch_unwatch" $}} + {{if not $.DisableStars}} + {{template "repo/star_unstar" $}} + {{end}} + {{if not $.DisableForks}} + {{template "repo/header_fork" $}} + {{end}} + </div> + {{end}} + </div> + {{if $.PullMirror}} + <div class="fork-flag"> + {{ctx.Locale.Tr "repo.mirror_from"}} + <a target="_blank" rel="noopener noreferrer" href="{{$.PullMirror.RemoteAddress}}">{{$.PullMirror.RemoteAddress}}</a> + {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}} + </div> + {{end}} + {{if .IsFork}}<div class="fork-flag">{{ctx.Locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}} + {{if .IsGenerated}}<div class="fork-flag">{{ctx.Locale.Tr "repo.generated_from"}} <a href="{{(.TemplateRepo ctx).Link}}">{{(.TemplateRepo ctx).FullName}}</a></div>{{end}} + </div> +{{end}} + <overflow-menu class="ui container secondary pointing tabular top attached borderless menu tw-pt-0 tw-my-0"> + {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}} + <div class="overflow-menu-items"> + {{if .Permission.CanRead $.UnitTypeCode}} + <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if and (ne .BranchName .Repository.DefaultBranch) (not $.PageIsWiki)}}/src/{{.BranchNameSubURL}}{{end}}"> + {{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}} + </a> + {{end}} + + {{if .Permission.CanRead $.UnitTypeIssues}} + <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues"> + {{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues"}} + {{if .Repository.NumOpenIssues}} + <span class="ui small label">{{CountFmt .Repository.NumOpenIssues}}</span> + {{end}} + </a> + {{end}} + + {{if .Permission.CanRead $.UnitTypeExternalTracker}} + <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer"> + {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}} + </a> + {{end}} + + {{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}} + <a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls"> + {{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.pulls"}} + {{if .Repository.NumOpenPulls}} + <span class="ui small label">{{CountFmt .Repository.NumOpenPulls}}</span> + {{end}} + </a> + {{end}} + + {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}} + <a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item"> + {{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project"}} + {{if .Repository.NumOpenProjects}} + <span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span> + {{end}} + </a> + {{end}} + + {{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}} + <a class="{{if or .PageIsReleaseList .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/releases"> + {{svg "octicon-tag"}} {{ctx.Locale.Tr "repo.releases"}} + {{if .NumReleases}} + <span class="ui small label">{{CountFmt .NumReleases}}</span> + {{end}} + </a> + {{end}} + + {{if .Permission.CanRead $.UnitTypePackages}} + <a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item"> + {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}} + {{if .NumPackages}} + <span class="ui small label">{{CountFmt .NumPackages}}</span> + {{end}} + </a> + {{end}} + + {{if .Permission.CanRead $.UnitTypeWiki}} + <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki"> + {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}} + </a> + {{end}} + + {{if .Permission.CanRead $.UnitTypeExternalWiki}} + <a class="item" href="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer"> + {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.wiki"}} + </a> + {{end}} + + {{if and (.Permission.CanReadAny $.UnitTypeCode $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases)}} + <a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity"> + {{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}} + </a> + {{end}} + + {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}} + <a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions"> + {{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}} + {{if .Repository.NumOpenActionRuns}} + <span class="ui small label">{{CountFmt .Repository.NumOpenActionRuns}}</span> + {{end}} + </a> + {{end}} + + {{template "custom/extra_tabs" .}} + + {{if and RepoFlagsEnabled .SignedUser.IsAdmin}} + <a class="{{if .IsRepoFlagsPage}}active {{end}}item" href="{{.RepoLink}}/flags"> + {{svg "octicon-milestone"}} {{ctx.Locale.Tr "repo.admin.manage_flags"}} + </a> + {{end}} + + {{if .Permission.IsAdmin}} + {{$highlightSettings := true}} + {{if and .SignedUser.EnableRepoUnitHints (not (.Repository.AllUnitsEnabled ctx))}} + {{$highlightSettings = false}} + <a class="{{if .PageIsRepoSettingsUnits}}active {{end}}item" href="{{.RepoLink}}/settings/units"> + {{svg "octicon-plus"}} {{ctx.Locale.Tr "repo.settings.units.add_more"}} + </a> + {{end}} + <a id="settings-btn" class="{{if and .PageIsRepoSettings (or $highlightSettings (not .PageIsRepoSettingsUnits))}}active {{end}}right item" href="{{.RepoLink}}/settings"> + {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}} + </a> + {{end}} + </div> + {{else if .Permission.IsAdmin}} + <div class="overflow-menu-items"> + <a id="settings-btn" class="{{if .PageIsRepoSettings}}active {{end}}right item" href="{{.RepoLink}}/settings"> + {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}} + </a> + </div> + {{end}} + </overflow-menu> + <div class="ui tabs divider"></div> +</div> diff --git a/templates/repo/header_fork.tmpl b/templates/repo/header_fork.tmpl new file mode 100644 index 0000000..de83000 --- /dev/null +++ b/templates/repo/header_fork.tmpl @@ -0,0 +1,52 @@ +{{with .Repository}} +{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}} + <div class="ui labeled button + {{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}} + disabled + {{end}}" + {{if not $.IsSigned}} + data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}" + {{else if and (not $.CanSignedUserFork) (not $.UserAndOrgForks)}} + data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}" + {{end}} + > + <a class="ui compact{{if $.ShowForkModal}} show-modal{{end}} small basic button" + {{if not $.CanSignedUserFork}} + {{if gt (len $.UserAndOrgForks) 1}} + href="#" data-modal="#fork-repo-modal" + {{else if eq (len $.UserAndOrgForks) 1}} + href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}" + {{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}} + {{end}} + {{else if not $.UserAndOrgForks}} + href="{{$.RepoLink}}/fork" + {{else}} + href="#" data-modal="#fork-repo-modal" + {{end}} + > + {{svg "octicon-repo-forked"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.fork"}}</span> + </a> + <div class="ui small modal" id="fork-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.already_forked" .Name}} + </div> + <div class="content tw-text-left"> + <div class="ui list"> + {{range $.UserAndOrgForks}} + <div class="ui item tw-py-2"> + <a href="{{.Link}}">{{svg "octicon-repo-forked" 16 "tw-mr-2"}}{{.FullName}}</a> + </div> + {{end}} + </div> + {{if $.CanSignedUserFork}} + <div class="divider"></div> + <a href="{{$.RepoLink}}/fork">{{ctx.Locale.Tr "repo.fork_to_different_account"}}</a> + {{end}} + </div> + </div> + <a class="ui basic label" href="{{.Link}}/forks"> + {{CountFmt .NumForks}} + </a> + </div> +{{end}} +{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl new file mode 100644 index 0000000..f2a6179 --- /dev/null +++ b/templates/repo/home.tmpl @@ -0,0 +1,164 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}"> + {{template "repo/header" .}} + <div class="ui container {{if .IsBlame}}fluid padded{{end}}"> + {{template "base/alert" .}} + {{template "repo/code/recently_pushed_new_branches" .}} + {{if and (not .HideRepoInfo) (not .IsBlame)}} + <div class="repo-description"> + <div id="repo-desc" class="tw-break-anywhere tw-text-16"> + {{$description := .Repository.DescriptionHTML $.Context}} + {{if $description}}<span class="description">{{$description | RenderCodeBlock}}</span>{{else}}<span class="no-description text-italic">{{ctx.Locale.Tr "repo.no_desc"}}</span>{{end}} + {{if .Repository.Website}}<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>{{end}} + </div> + <form class="ignore-dirty" action="{{.RepoLink}}/search/{{if .CodeIndexerDisabled}}{{.BranchNameSubURL}}{{end}}" method="get" data-test-tag="codesearch"> + <div class="ui small action input"> + <input name="q" value="{{.Keyword}}" placeholder="{{ctx.Locale.Tr "search.code_kind"}}"> + {{template "shared/search/button"}} + </div> + </form> + </div> + <div class="tw-flex tw-items-center tw-flex-wrap tw-gap-2 tw-my-2" id="repo-topics"> + {{/* it should match the code in issue-home.js */}} + {{range .Topics}}<a class="repo-topic ui large label" href="{{AppSubUrl}}/explore/repos?q={{.Name}}&topic=1">{{.Name}}</a>{{end}} + {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}<button id="manage_topic" class="btn interact-fg tw-text-12">{{ctx.Locale.Tr "repo.topic.manage_topics"}}</button>{{end}} + </div> + {{end}} + {{if and .Permission.IsAdmin (not .Repository.IsArchived)}} + <div class="ui form tw-hidden tw-flex tw-gap-2 tw-my-2" id="topic_edit"> + <div class="ui fluid multiple search selection dropdown tw-flex-wrap tw-flex-1"> + <input type="hidden" name="topics" value="{{range $i, $v := .Topics}}{{.Name}}{{if Eval $i "+" 1 "<" (len $.Topics)}},{{end}}{{end}}"> + {{range .Topics}} + {{/* keep the same layout as Fomantic UI generated labels */}} + <a class="ui label transition visible tw-cursor-default tw-inline-block" data-value="{{.Name}}">{{.Name}}{{svg "octicon-x" 16 "delete icon"}}</a> + {{end}} + <div class="text"></div> + </div> + <div> + <button class="ui basic button" id="cancel_topic_edit">{{ctx.Locale.Tr "cancel"}}</button> + <button class="ui primary button" id="save_topic" data-link="{{.RepoLink}}/topics">{{ctx.Locale.Tr "save"}}</button> + </div> + </div> + {{end}} + + {{if RepoFlagsEnabled}} + {{template "custom/repo_flag_banners" .}} + {{if .SignedUser.IsAdmin}} + {{template "repo/admin_flags" .}} + {{end}} + {{end}} + + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{if .Repository.ArchivedUnix.IsZero}} + {{ctx.Locale.Tr "repo.archive.title"}} + {{else}} + {{ctx.Locale.Tr "repo.archive.title_date" (DateTime "long" .Repository.ArchivedUnix)}} + {{end}} + </div> + {{end}} + {{template "repo/sub_menu" .}} + {{$n := len .TreeNames}} + {{$l := Eval $n "-" 1}} + {{$isHomepage := (eq $n 0)}} + <div class="repo-button-row"> + <div class="tw-flex tw-items-center tw-gap-y-2"> + {{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mr-1"}} + {{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} + {{$cmpBranch := ""}} + {{if ne .Repository.ID .BaseRepo.ID}} + {{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}} + {{end}} + {{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}} + {{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}} + <a id="new-pull-request" role="button" class="ui compact basic button" href="{{$compareLink}}" + data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}"> + {{svg "octicon-git-pull-request"}} + </a> + {{end}} + <!-- Show go to file and breadcrumbs if not on home page --> + {{if $isHomepage}} + <a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button">{{ctx.Locale.Tr "repo.find_file.go_to_file"}}</a> + {{end}} + + {{if and .CanWriteCode .IsViewBranch (not .Repository.IsMirror) (not .Repository.IsArchived) (not .IsViewFile)}} + <button class="ui dropdown basic compact jump button tw-mr-1"{{if not .Repository.CanEnableEditor}} disabled{{end}}> + {{ctx.Locale.Tr "repo.editor.add_file"}} + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}"> + {{ctx.Locale.Tr "repo.editor.new_file"}} + </a> + {{if .RepositoryUploadEnabled}} + <a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}"> + {{ctx.Locale.Tr "repo.editor.upload_file"}} + </a> + {{end}} + <a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}"> + {{ctx.Locale.Tr "repo.editor.patch"}} + </a> + </div> + </button> + {{end}} + + {{if and $isHomepage (.Repository.IsTemplate)}} + <a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}"> + {{ctx.Locale.Tr "repo.use_template"}} + </a> + {{end}} + {{if (not $isHomepage)}} + <span class="breadcrumb repo-path tw-ml-1"> + <a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a> + {{- range $i, $v := .TreeNames -}} + <span class="breadcrumb-divider">/</span> + {{- if eq $i $l -}} + <span class="active section" title="{{$v}}">{{$v}}</span> + {{- else -}} + {{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span> + {{- end -}} + {{- end -}} + </span> + {{end}} + </div> + <div class="tw-flex tw-items-center"> + <!-- Only show clone panel in repository home page --> + {{if $isHomepage}} + <div class="clone-panel ui action tiny input"> + {{template "repo/clone_buttons" .}} + <button class="ui small jump dropdown icon button" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}"> + {{svg "octicon-kebab-horizontal"}} + <div class="menu"> + {{if not $.DisableDownloadSourceArchives}} + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.zip" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_zip"}}</a> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.tar.gz" rel="nofollow">{{svg "octicon-file-zip" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_tar"}}</a> + <a class="item archive-link" href="{{$.RepoLink}}/archive/{{PathEscapeSegments $.RefName}}.bundle" rel="nofollow">{{svg "octicon-package" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.download_bundle"}}</a> + {{end}} + {{if .CitationExist}} + <a class="item" id="cite-repo-button">{{svg "octicon-cross-reference" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.cite_this_repo"}}</a> + {{end}} + {{range .OpenWithEditorApps}} + <a class="item js-clone-url-editor" data-href-template="{{.OpenURL}}">{{.IconHTML}}{{ctx.Locale.Tr "repo.open_with_editor" .DisplayName}}</a> + {{end}} + </div> + </button> + {{template "repo/clone_script" .}}{{/* the script will update `.js-clone-url` and related elements */}} + </div> + {{template "repo/cite/cite_modal" .}} + {{end}} + {{if and (not $isHomepage) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}} + <a class="ui button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{.TreePath | PathEscapeSegments}}"> + {{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}} + </a> + {{end}} + </div> + </div> + {{if .IsViewFile}} + {{template "repo/view_file" .}} + {{else if .IsBlame}} + {{template "repo/blame" .}} + {{else}}{{/* IsViewDirectory */}} + {{template "repo/view_list" .}} + {{end}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/icon.tmpl b/templates/repo/icon.tmpl new file mode 100644 index 0000000..e5e0bd6 --- /dev/null +++ b/templates/repo/icon.tmpl @@ -0,0 +1,10 @@ +{{$avatarLink := (.RelAvatarLink ctx)}} +{{if $avatarLink}} + <img class="ui avatar tw-align-middle" src="{{$avatarLink}}" width="24" height="24" alt="{{.FullName}}"> +{{else if $.IsMirror}} + {{svg "octicon-mirror" 24}} +{{else if $.IsFork}} + {{svg "octicon-repo-forked" 24}} +{{else}} + {{svg "octicon-repo" 24}} +{{end}} diff --git a/templates/repo/issue/card.tmpl b/templates/repo/issue/card.tmpl new file mode 100644 index 0000000..0b255d6 --- /dev/null +++ b/templates/repo/issue/card.tmpl @@ -0,0 +1,78 @@ +{{with .Issue}} + {{if eq $.Page.Project.CardType 1}}{{/* Images and Text*/}} + {{$attachments := index $.Page.issuesAttachmentMap .ID}} + {{if $attachments}} + <div class="card-attachment-images"> + {{range $attachments}} + <img src="{{.DownloadURL}}" alt="{{.Name}}" /> + {{end}} + </div> + {{end}} + {{end}} + <div class="content tw-w-full"> + <div class="tw-flex tw-items-start tw-gap-[5px]"> + <div class="issue-card-icon"> + {{template "shared/issueicon" .}} + </div> + <a class="issue-card-title muted issue-title tw-break-anywhere" href="{{.Link}}">{{RenderRefIssueTitle $.Context .Title}}</a> + {{if and $.isPinnedIssueCard $.Page.IsRepoAdmin}} + <a role="button" class="issue-card-unpin muted tw-flex tw-items-center" data-tooltip-content={{ctx.Locale.Tr "repo.issues.unpin_issue"}} data-issue-id="{{.ID}}" data-unpin-url="{{$.Page.Link}}/unpin/{{.Index}}"> + {{svg "octicon-x" 16}} + </a> + {{end}} + </div> + <div class="meta"> + <span class="text light grey muted-links"> + {{if not $.Page.Repository}}{{.Repo.FullName}}{{end}}#{{.Index}} + {{$timeStr := TimeSinceUnix .GetLastEventTimestamp ctx.Locale}} + {{if .OriginalAuthor}} + {{ctx.Locale.Tr .GetLastEventLabelFake $timeStr .OriginalAuthor}} + {{else if gt .Poster.ID 0}} + {{ctx.Locale.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.GetDisplayName}} + {{else}} + {{ctx.Locale.Tr .GetLastEventLabelFake $timeStr .Poster.GetDisplayName}} + {{end}} + </span> + </div> + {{if .MilestoneID}} + <div class="meta tw-my-1"> + <a class="milestone" href="{{.Repo.Link}}/milestone/{{.MilestoneID}}"> + {{svg "octicon-milestone" 16 "tw-mr-1 tw-align-middle"}} + <span class="tw-align-middle">{{.Milestone.Name}}</span> + </a> + </div> + {{end}} + {{if $.Page.LinkedPRs}} + {{range index $.Page.LinkedPRs .ID}} + <div class="meta tw-my-1"> + <a href="{{$.Issue.Repo.Link}}/pulls/{{.Index}}"> + <span class="tw-m-0 text {{if .PullRequest.HasMerged}}purple{{else if .IsClosed}}red{{else}}green{{end}}">{{svg "octicon-git-merge" 16 "tw-mr-1 tw-align-middle"}}</span> + <span class="tw-align-middle">{{.Title}} <span class="text light grey">#{{.Index}}</span></span> + </a> + </div> + {{end}} + {{end}} + {{$tasks := .GetTasks}} + {{if gt $tasks 0}} + <div class="meta tw-my-1"> + {{svg "octicon-checklist" 16 "tw-mr-1 tw-align-middle"}} + <span class="tw-align-middle">{{.GetTasksDone}} / {{$tasks}}</span> + </div> + {{end}} + </div> + + {{if or .Labels .Assignees}} + <div class="issue-card-bottom"> + <div class="labels-list"> + {{range .Labels}} + <a target="_blank" href="{{$.Issue.Repo.Link}}/issues?labels={{.ID}}">{{RenderLabel ctx ctx.Locale .}}</a> + {{end}} + </div> + <div class="issue-card-assignees"> + {{range .Assignees}} + <a target="_blank" href="{{.HomeLink}}" data-tooltip-content="{{ctx.Locale.Tr "repo.projects.column.assigned_to"}} {{.Name}}">{{ctx.AvatarUtils.Avatar . 28}}</a> + {{end}} + </div> + </div> + {{end}} +{{end}} diff --git a/templates/repo/issue/choose.tmpl b/templates/repo/issue/choose.tmpl new file mode 100644 index 0000000..38cf9e4 --- /dev/null +++ b/templates/repo/issue/choose.tmpl @@ -0,0 +1,59 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new issue"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <div class="issue-navbar"> + {{template "repo/issue/navbar" .}} + </div> + <div class="divider"></div> + {{range .IssueTemplates}} + <div class="ui attached segment"> + <div class="ui two column grid"> + <div class="column left aligned"> + <strong>{{.Name}}</strong> + <br>{{.About}} + </div> + <div class="column right aligned"> + <a href="{{$.RepoLink}}/issues/new?template={{.FileName}}{{if $.milestone}}&milestone={{$.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui primary button">{{ctx.Locale.Tr "repo.issues.choose.get_started"}}</a> + </div> + </div> + </div> + {{end}} + {{range .IssueConfig.ContactLinks}} + <div class="ui attached segment"> + <div class="ui two column grid"> + <div class="column left aligned"> + <strong>{{.Name}}</strong> + <br>{{.About}} + </div> + <div class="column right aligned"> + <a href="{{.URL}}" class="ui primary button">{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues.choose.open_external_link"}}</a> + </div> + </div> + </div> + {{end}} + {{if .IssueConfig.BlankIssuesEnabled}} + <div class="ui attached segment"> + <div class="ui two column grid"> + <div class="column left aligned"> + <strong>{{ctx.Locale.Tr "repo.issues.choose.blank"}}</strong> + <br/>{{ctx.Locale.Tr "repo.issues.choose.blank_about"}} + </div> + <div class="column right aligned"> + <a href="{{.RepoLink}}/issues/new?{{if .milestone}}&milestone={{.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui primary button">{{ctx.Locale.Tr "repo.issues.choose.get_started"}}</a> + </div> + </div> + </div> + {{end}} + {{- if .IssueConfigError}}{{/* normal warning flash makes problems here*/}} + <div class="ui warning message"> + <div class="text left"> + <div>{{ctx.Locale.Tr "repo.issues.choose.invalid_config"}}</div> + <div>{{.IssueConfigError}}</div> + </div> + </div> + {{end}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/comment_tab.tmpl b/templates/repo/issue/comment_tab.tmpl new file mode 100644 index 0000000..4197ea4 --- /dev/null +++ b/templates/repo/issue/comment_tab.tmpl @@ -0,0 +1,21 @@ +{{$textareaContent := .BodyQuery}} +{{if not $textareaContent}}{{$textareaContent = .IssueTemplate}}{{end}} +{{if not $textareaContent}}{{$textareaContent = .PullRequestTemplate}}{{end}} +{{if not $textareaContent}}{{$textareaContent = .content}}{{end}} + +<div class="field"> + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "TextareaContent" $textareaContent + "TextareaPlaceholder" (ctx.Locale.Tr "repo.diff.comment.placeholder") + "DropzoneParentContainer" "form, .ui.form" + )}} +</div> + +{{if .IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" .}} + </div> +{{end}} diff --git a/templates/repo/issue/fields/checkboxes.tmpl b/templates/repo/issue/fields/checkboxes.tmpl new file mode 100644 index 0000000..531f401 --- /dev/null +++ b/templates/repo/issue/fields/checkboxes.tmpl @@ -0,0 +1,14 @@ +<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}}"> + {{template "repo/issue/fields/header" .}} + {{range $i, $opt := .item.Attributes.options}} + <div class="field inline"> + <div class="ui checkbox tw-mr-0 {{if and ($opt.visible) (not (SliceUtils.Contains $opt.visible "form"))}}tw-hidden{{end}}"> + <input type="checkbox" name="form-field-{{$.item.ID}}-{{$i}}" {{if $opt.required}}required{{end}}> + <label>{{RenderMarkdownToHtml $.context $opt.label}}</label> + </div> + {{if $opt.required}} + <label class="required"></label> + {{end}} + </div> + {{end}} +</div> diff --git a/templates/repo/issue/fields/dropdown.tmpl b/templates/repo/issue/fields/dropdown.tmpl new file mode 100644 index 0000000..26505f5 --- /dev/null +++ b/templates/repo/issue/fields/dropdown.tmpl @@ -0,0 +1,17 @@ +<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}}"> + {{template "repo/issue/fields/header" .}} + {{/* FIXME: required validation */}} + <div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}"> + <input type="hidden" name="form-field-{{.item.ID}}" value="{{.item.Attributes.default}}"> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + {{if not .item.Validations.required}} + {{svg "octicon-x" 14 "remove icon"}} + {{end}} + <div class="default text"></div> + <div class="menu"> + {{range $i, $opt := .item.Attributes.options}} + <div class="item" data-value="{{$i}}">{{$opt}}</div> + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/issue/fields/header.tmpl b/templates/repo/issue/fields/header.tmpl new file mode 100644 index 0000000..06c41af --- /dev/null +++ b/templates/repo/issue/fields/header.tmpl @@ -0,0 +1,6 @@ +{{if and (.item.Attributes.label) (not .item.Attributes.hide_label)}} + <h3>{{.item.Attributes.label}}{{if .item.Validations.required}}<label class="required"></label>{{end}}</h3> +{{end}} +{{if .item.Attributes.description}} + <span class="help">{{RenderMarkdownToHtml .Context .item.Attributes.description}}</span> +{{end}} diff --git a/templates/repo/issue/fields/input.tmpl b/templates/repo/issue/fields/input.tmpl new file mode 100644 index 0000000..039f9a9 --- /dev/null +++ b/templates/repo/issue/fields/input.tmpl @@ -0,0 +1,4 @@ +<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}}"> + {{template "repo/issue/fields/header" .}} + <input type="{{if .item.Validations.is_number}}number{{else}}text{{end}}" name="form-field-{{.item.ID}}" placeholder="{{.item.Attributes.placeholder}}" value="{{.item.Attributes.value}}" {{if .item.Validations.required}}required{{end}} {{if .item.Validations.regex}}pattern="{{.item.Validations.regex}}" title="{{.item.Validations.regex}}"{{end}}> +</div> diff --git a/templates/repo/issue/fields/markdown.tmpl b/templates/repo/issue/fields/markdown.tmpl new file mode 100644 index 0000000..934699e --- /dev/null +++ b/templates/repo/issue/fields/markdown.tmpl @@ -0,0 +1,3 @@ +<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}}"> + <div>{{RenderMarkdownToHtml .Context .item.Attributes.value}}</div> +</div> diff --git a/templates/repo/issue/fields/textarea.tmpl b/templates/repo/issue/fields/textarea.tmpl new file mode 100644 index 0000000..3ad69e1 --- /dev/null +++ b/templates/repo/issue/fields/textarea.tmpl @@ -0,0 +1,24 @@ +{{$useMarkdownEditor := not .item.Attributes.render}} +<div class="field {{if not .item.VisibleOnForm}}tw-hidden{{end}} {{if $useMarkdownEditor}}combo-editor-dropzone{{end}}"> + {{template "repo/issue/fields/header" .}} + + {{/* the real form element to provide the value */}} + <textarea class="form-field-real" name="form-field-{{.item.ID}}" placeholder="{{.item.Attributes.placeholder}}" {{if and .item.Validations.required}}required{{end}}>{{.item.Attributes.value}}</textarea> + + {{if $useMarkdownEditor}} + {{template "shared/combomarkdowneditor" (dict + "ContainerClasses" "tw-hidden" + "MarkdownPreviewUrl" (print .root.RepoLink "/markup") + "MarkdownPreviewContext" .root.RepoLink + "TextareaContent" .item.Attributes.value + "TextareaPlaceholder" .item.Attributes.placeholder + "DropzoneParentContainer" ".combo-editor-dropzone" + )}} + + {{if .root.IsAttachmentEnabled}} + <div class="tw-mt-4 form-field-dropzone tw-hidden"> + {{template "repo/upload" .root}} + </div> + {{end}} + {{end}} +</div> diff --git a/templates/repo/issue/filter_actions.tmpl b/templates/repo/issue/filter_actions.tmpl new file mode 100644 index 0000000..58b1ef8 --- /dev/null +++ b/templates/repo/issue/filter_actions.tmpl @@ -0,0 +1,128 @@ +<div class="ui secondary filter menu"> + {{if not .Repository.IsArchived}} + <!-- Action Button --> + {{if and .IsShowClosed.Has .IsShowClosed.Value}} + <button class="ui primary basic button issue-action" data-action="open" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_open"}}</button> + {{else if and .IsShowClosed.Has (not .IsShowClosed.Value)}} + <button class="ui red basic button issue-action" data-action="close" data-url="{{$.RepoLink}}/issues/status">{{ctx.Locale.Tr "repo.issues.action_close"}}</button> + {{end}} + {{if $.IsRepoAdmin}} + <button class="ui red button issue-action" + data-action="delete" data-url="{{$.RepoLink}}/issues/delete" + data-action-delete-confirm="{{ctx.Locale.Tr "confirm_delete_selected"}}" + >{{ctx.Locale.Tr "repo.issues.delete"}}</button> + {{end}} + <!-- Labels --> + <div class="ui {{if not .Labels}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_label"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-action="clear" data-url="{{$.RepoLink}}/issues/labels"> + {{ctx.Locale.Tr "repo.issues.new.clear_labels"}} + </div> + {{$previousExclusiveScope := "_no_scope"}} + {{range .Labels}} + {{$exclusiveScope := .ExclusiveScope}} + {{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}} + <div class="divider"></div> + {{end}} + {{$previousExclusiveScope = $exclusiveScope}} + <div class="item issue-action tw-flex tw-justify-between" data-action="toggle" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/labels"> + {{if SliceUtils.Contains $.SelLabelIDs .ID}}{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}{{end}} {{RenderLabel $.Context ctx.Locale .}} + {{template "repo/issue/labels/label_archived" .}} + </div> + {{end}} + </div> + </div> + + <!-- Milestone --> + <div class="ui {{if not (or .OpenMilestones .ClosedMilestones)}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_milestone"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/milestone"> + {{ctx.Locale.Tr "repo.issues.action_milestone_no_select"}} + </div> + {{if .OpenMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> + {{range .OpenMilestones}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> + {{.Name}} + </div> + {{end}} + {{end}} + {{if .ClosedMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_closed"}}</div> + {{range .ClosedMilestones}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/milestone"> + {{.Name}} + </div> + {{end}} + {{end}} + </div> + </div> + + <!-- Projects --> + <div class="ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.projects"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/projects"> + {{ctx.Locale.Tr "repo.issues.new.clear_projects"}} + </div> + {{if .OpenProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_projects"}} + </div> + {{range .OpenProjects}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </div> + {{end}} + {{end}} + {{if .ClosedProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} + </div> + {{range .ClosedProjects}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/projects"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </div> + {{end}} + {{end}} + </div> + </div> + + <!-- Assignees --> + <div class="ui {{if not .Assignees}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.action_assignee"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item issue-action" data-action="clear" data-url="{{$.Link}}/assignee"> + {{ctx.Locale.Tr "repo.issues.new.clear_assignees"}} + </div> + <div class="item issue-action" data-element-id="0" data-url="{{$.Link}}/assignee"> + {{ctx.Locale.Tr "repo.issues.action_assignee_no_select"}} + </div> + {{range .Assignees}} + <div class="item issue-action" data-element-id="{{.ID}}" data-url="{{$.RepoLink}}/issues/assignee"> + {{ctx.AvatarUtils.Avatar . 20}} {{.GetDisplayName}} + </div> + {{end}} + </div> + </div> + {{end}} +</div> + diff --git a/templates/repo/issue/filter_list.tmpl b/templates/repo/issue/filter_list.tmpl new file mode 100644 index 0000000..09f87b5 --- /dev/null +++ b/templates/repo/issue/filter_list.tmpl @@ -0,0 +1,158 @@ +<!-- Label --> +{{template "shared/label_filter" .}} + +{{if not .Milestone}} +<!-- Milestone --> +<div class="list-header-milestone ui {{if not (or .OpenMilestones .ClosedMilestones)}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_milestone"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_milestone"}}"> + </div> + <div class="divider"></div> + <a rel="nofollow" class="{{if not $.MilestoneID}}active selected {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone=0&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_all"}}</a> + <a rel="nofollow" class="{{if $.MilestoneID}}{{if eq $.MilestoneID -1}}active selected {{end}}{{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone=-1&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_milestone_none"}}</a> + {{if .OpenMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_open"}}</div> + {{range .OpenMilestones}} + <a rel="nofollow" class="{{if $.MilestoneID}}{{if eq $.MilestoneID .ID}}active selected {{end}}{{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.ID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> + {{svg "octicon-milestone" 16 "mr-2"}} + {{.Name}} + </a> + {{end}} + {{end}} + {{if .ClosedMilestones}} + <div class="divider"></div> + <div class="header">{{ctx.Locale.Tr "repo.issues.filter_milestone_closed"}}</div> + {{range .ClosedMilestones}} + <a rel="nofollow" class="{{if $.MilestoneID}}{{if eq $.MilestoneID .ID}}active selected {{end}}{{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.ID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> + {{svg "octicon-milestone" 16 "mr-2"}} + {{.Name}} + </a> + {{end}} + {{end}} + </div> +</div> +{{end}} + +<!-- Project --> +<div class="list-header-project ui{{if not (or .OpenProjects .ClosedProjects)}} disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_project"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_project"}}"> + </div> + <a rel="nofollow" class="{{if not .ProjectID}}active selected {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project=&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_project_all"}}</a> + <a rel="nofollow" class="{{if eq .ProjectID -1}}active selected {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project=-1&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_project_none"}}</a> + {{if .OpenProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_projects"}} + </div> + {{range .OpenProjects}} + <a rel="nofollow" class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item tw-flex" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> + {{svg .IconName 18 "tw-mr-2 tw-shrink-0"}}<span class="gt-ellipsis">{{.Title}}</span> + </a> + {{end}} + {{end}} + {{if .ClosedProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} + </div> + {{range .ClosedProjects}} + <a rel="nofollow" class="{{if $.ProjectID}}{{if eq $.ProjectID .ID}}active selected{{end}}{{end}} item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{.ID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </a> + {{end}} + {{end}} + </div> +</div> + +<!-- Author --> +<div class="list-header-author ui dropdown jump item user-remote-search" data-tooltip-content="{{ctx.Locale.Tr "repo.author_search_tooltip"}}" + data-search-url="{{if .Milestone}}{{$.RepoLink}}/issues/posters{{else}}{{$.Link}}/posters{{end}}" + data-selected-user-id="{{$.PosterID}}" + data-action-jump-url="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&fuzzy={{$.IsFuzzy}}&poster={user_id}{{if $.ShowArchivedLabels}}&archived=true{{end}}" +> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_poster"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_poster"}}"> + </div> + <a class="item" data-value="0">{{ctx.Locale.Tr "repo.issues.filter_poster_no_select"}}</a> + </div> +</div> + +<!-- Assignee --> +<div class="list-header-assignee ui {{if not .Assignees}}disabled{{end}} dropdown jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_assignee"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignee"}}"> + </div> + <a rel="nofollow" class="{{if not .AssigneeID}}active selected {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee=&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_select"}}</a> + <a rel="nofollow" class="{{if eq .AssigneeID -1}}active selected {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee=-1&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_assginee_no_assignee"}}</a> + <div class="divider"></div> + {{range .Assignees}} + <a rel="nofollow" class="{{if eq $.AssigneeID .ID}}active selected{{end}} item tw-flex" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{.ID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}"> + {{ctx.AvatarUtils.Avatar . 20}}{{template "repo/search_name" .}} + </a> + {{end}} + </div> +</div> + +{{if .IsSigned}} + <!-- Type --> + <div class="list-header-type ui dropdown type jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_type"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <a rel="nofollow" class="{{if eq .ViewType "all"}}active {{end}}item" href="?q={{$.Keyword}}&type=all&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.all_issues"}}</a> + <a rel="nofollow" class="{{if eq .ViewType "assigned"}}active {{end}}item" href="?q={{$.Keyword}}&type=assigned&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}</a> + <a rel="nofollow" class="{{if eq .ViewType "created_by"}}active {{end}}item" href="?q={{$.Keyword}}&type=created_by&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}</a> + {{if .PageIsPullList}} + <a rel="nofollow" class="{{if eq .ViewType "review_requested"}}active {{end}}item" href="?q={{$.Keyword}}&type=review_requested&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.review_requested"}}</a> + <a rel="nofollow" class="{{if eq .ViewType "reviewed_by"}}active {{end}}item" href="?q={{$.Keyword}}&type=reviewed_by&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.reviewed_by_you"}}</a> + {{end}} + <a rel="nofollow" class="{{if eq .ViewType "mentioned"}}active {{end}}item" href="?q={{$.Keyword}}&type=mentioned&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_type.mentioning_you"}}</a> + </div> + </div> +{{end}} + +<!-- Sort --> +<div class="list-header-sort ui dropdown downward type jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_sort"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <a rel="nofollow" class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=latest&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a> + <a rel="nofollow" class="{{if eq .SortType "oldest"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=oldest&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a> + <a rel="nofollow" class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a> + <a rel="nofollow" class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a> + <a rel="nofollow" class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a> + <a rel="nofollow" class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a> + <a rel="nofollow" class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a> + <a rel="nofollow" class="{{if eq .SortType "farduedate"}}active {{end}}item" href="?q={{$.Keyword}}&type={{$.ViewType}}&sort=farduedate&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}&project={{$.ProjectID}}&assignee={{$.AssigneeID}}&poster={{$.PosterID}}&fuzzy={{$.IsFuzzy}}{{if $.ShowArchivedLabels}}&archived=true{{end}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a> + </div> +</div> diff --git a/templates/repo/issue/filters.tmpl b/templates/repo/issue/filters.tmpl new file mode 100644 index 0000000..06e7c1a --- /dev/null +++ b/templates/repo/issue/filters.tmpl @@ -0,0 +1,26 @@ +<div id="issue-filters" class="issue-list-toolbar"> + <div class="issue-list-toolbar-left"> + {{if and $.CanWriteIssuesOrPulls .Issues}} + <input type="checkbox" autocomplete="off" class="issue-checkbox-all tw-mr-4" title="{{ctx.Locale.Tr "repo.issues.action_check_all"}}"> + {{end}} + {{template "repo/issue/openclose" .}} + <!-- Total Tracked Time --> + {{if .TotalTrackedTime}} + <div class="ui compact tiny secondary menu"> + <span class="item" data-tooltip-content='{{ctx.Locale.Tr "tracked_time_summary"}}'> + {{svg "octicon-clock"}} + {{.TotalTrackedTime | Sec2Time}} + </span> + </div> + {{end}} + </div> + <div class="issue-list-toolbar-right"> + <div class="ui secondary filter menu labels"> + {{if .PageIsMilestones}} + {{template "repo/issue/milestone/filter_list" .}} + {{else}} + {{template "repo/issue/filter_list" .}} + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/issue/label_precolors.tmpl b/templates/repo/issue/label_precolors.tmpl new file mode 100644 index 0000000..8000766 --- /dev/null +++ b/templates/repo/issue/label_precolors.tmpl @@ -0,0 +1,22 @@ +<div class="precolors"> + <div class="tw-flex"> + <a class="color" style="background-color:#e11d21" data-color-hex="#e11d21"></a> + <a class="color" style="background-color:#eb6420" data-color-hex="#eb6420"></a> + <a class="color" style="background-color:#fbca04" data-color-hex="#fbca04"></a> + <a class="color" style="background-color:#009800" data-color-hex="#009800"></a> + <a class="color" style="background-color:#006b75" data-color-hex="#006b75"></a> + <a class="color" style="background-color:#207de5" data-color-hex="#207de5"></a> + <a class="color" style="background-color:#0052cc" data-color-hex="#0052cc"></a> + <a class="color" style="background-color:#5319e7" data-color-hex="#5319e7"></a> + </div> + <div class="tw-flex"> + <a class="color" style="background-color:#f6c6c7" data-color-hex="#f6c6c7"></a> + <a class="color" style="background-color:#fad8c7" data-color-hex="#fad8c7"></a> + <a class="color" style="background-color:#fef2c0" data-color-hex="#fef2c0"></a> + <a class="color" style="background-color:#bfe5bf" data-color-hex="#bfe5bf"></a> + <a class="color" style="background-color:#bfdadc" data-color-hex="#bfdadc"></a> + <a class="color" style="background-color:#c7def8" data-color-hex="#c7def8"></a> + <a class="color" style="background-color:#bfd4f2" data-color-hex="#bfd4f2"></a> + <a class="color" style="background-color:#d4c5f9" data-color-hex="#d4c5f9"></a> + </div> +</div> diff --git a/templates/repo/issue/labels.tmpl b/templates/repo/issue/labels.tmpl new file mode 100644 index 0000000..230777e --- /dev/null +++ b/templates/repo/issue/labels.tmpl @@ -0,0 +1,22 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository labels"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="issue-navbar tw-mb-4"> + {{template "repo/issue/navbar" .}} + {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} + <button class="ui small primary new-label button">{{ctx.Locale.Tr "repo.issues.new_label"}}</button> + {{end}} + </div> + {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} + {{template "repo/issue/labels/label_new" .}} + {{end}} + {{template "base/alert" .}} + {{template "repo/issue/labels/label_list" .}} + </div> +</div> + +{{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} + {{template "repo/issue/labels/edit_delete_label" .}} +{{end}} +{{template "base/footer" .}} diff --git a/templates/repo/issue/labels/edit_delete_label.tmpl b/templates/repo/issue/labels/edit_delete_label.tmpl new file mode 100644 index 0000000..fcf6921 --- /dev/null +++ b/templates/repo/issue/labels/edit_delete_label.tmpl @@ -0,0 +1,72 @@ +<div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.issues.label_deletion"}} + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.issues.label_deletion_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} +</div> + +<div class="ui small edit-label modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.label_modify"}} + </div> + <div class="content"> + <form class="ui edit-label form ignore-dirty" action="{{$.Link}}/edit" method="post"> + {{.CsrfTokenHtml}} + <input id="label-modal-id" name="id" type="hidden"> + <div class="required field"> + <label for="name">{{ctx.Locale.Tr "repo.issues.label_title"}}</label> + <div class="ui small input"> + <input class="label-name-input" name="title" placeholder="{{ctx.Locale.Tr "repo.issues.new_label_placeholder"}}" autofocus required maxlength="50"> + </div> + </div> + <div class="field label-exclusive-input-field"> + <div class="ui checkbox"> + <input class="label-exclusive-input" name="exclusive" type="checkbox"> + <label>{{ctx.Locale.Tr "repo.issues.label_exclusive"}}</label> + </div> + <br> + <small class="desc">{{ctx.Locale.Tr "repo.issues.label_exclusive_desc"}}</small> + <div class="desc tw-ml-1 tw-mt-2 tw-hidden label-exclusive-warning"> + {{svg "octicon-alert"}} {{ctx.Locale.Tr "repo.issues.label_exclusive_warning"}} + </div> + <br> + </div> + <div class="field label-is-archived-input-field"> + <div class="ui checkbox"> + <input class="label-is-archived-input" name="is_archived" type="checkbox"> + <label>{{ctx.Locale.Tr "repo.issues.label_archive"}}</label> + </div> + <i class="tw-ml-1" data-tooltip-content={{ctx.Locale.Tr "repo.issues.label_archive_tooltip"}}> + {{svg "octicon-info"}} + </i> + </div> + <div class="field"> + <label for="description">{{ctx.Locale.Tr "repo.issues.label_description"}}</label> + <div class="ui small fluid input"> + <input class="label-desc-input" name="description" placeholder="{{ctx.Locale.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> + </div> + </div> + <div class="field color-field"> + <label for="color">{{ctx.Locale.Tr "repo.issues.label_color"}}</label> + <div class="column js-color-picker-input"> + <input name="color" value="#70c24a"placeholder="#c320f6" required maxlength="7"> + {{template "repo/issue/label_precolors"}} + </div> + </div> + </form> + </div> + <div class="actions"> + <button class="ui small basic cancel button"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "cancel"}} + </button> + <button class="ui primary small approve button"> + {{svg "fontawesome-save"}} + {{ctx.Locale.Tr "save"}} + </button> + </div> +</div> diff --git a/templates/repo/issue/labels/label.tmpl b/templates/repo/issue/labels/label.tmpl new file mode 100644 index 0000000..7844362 --- /dev/null +++ b/templates/repo/issue/labels/label.tmpl @@ -0,0 +1,8 @@ +<a + class="item {{if not .label.IsChecked}}tw-hidden{{end}}" + id="label_{{.label.ID}}" + href="{{.root.RepoLink}}/{{if or .root.IsPull .root.Issue.IsPull}}pulls{{else}}issues{{end}}?labels={{.label.ID}}"{{/* FIXME: use .root.Issue.Link or create .root.Link */}} + rel="nofollow" +> + {{- RenderLabel $.Context ctx.Locale .label -}} +</a> diff --git a/templates/repo/issue/labels/label_archived.tmpl b/templates/repo/issue/labels/label_archived.tmpl new file mode 100644 index 0000000..feaf77e --- /dev/null +++ b/templates/repo/issue/labels/label_archived.tmpl @@ -0,0 +1,5 @@ +{{if .IsArchived}} + <span class="ui label basic small" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.label_archive_tooltip"}}"> + {{ctx.Locale.Tr "archived"}} + </span> +{{end}} diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl new file mode 100644 index 0000000..8d7fc2c --- /dev/null +++ b/templates/repo/issue/labels/label_list.tmpl @@ -0,0 +1,88 @@ +<h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.issues.label_count" .NumLabels}} + <div class="ui right"> + <div class="ui secondary menu"> + <!-- Sort --> + <div class="item ui jump dropdown tw-py-2"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_sort"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <a class="{{if or (eq .SortType "alphabetically") (not .SortType)}}active {{end}}item" href="?sort=alphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.alphabetically"}}</a> + <a class="{{if eq .SortType "reversealphabetically"}}active {{end}}item" href="?sort=reversealphabetically&state={{$.State}}">{{ctx.Locale.Tr "repo.issues.label.filter_sort.reverse_alphabetically"}}</a> + <a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="?sort=leastissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a> + <a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="?sort=mostissues&state={{$.State}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a> + </div> + </div> + </div> + </div> <!-- filter menu --> +</h4> + +<div class="ui attached segment"> + {{if and (not $.PageIsOrgSettingsLabels) (or $.CanWriteIssues $.CanWritePulls) (eq .NumLabels 0) (not $.Repository.IsArchived)}} + {{template "repo/issue/labels/label_load_template" .}} + <div class="divider"></div> + {{else if and ($.PageIsOrgSettingsLabels) (eq .NumLabels 0)}} + {{template "repo/issue/labels/label_load_template" .}} + <div class="divider"></div> + {{end}} + + <ul class="issue-label-list"> + {{range .Labels}} + <li class="item"> + <div class="label-title"> + {{RenderLabel $.Context ctx.Locale .}} + {{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}} + </div> + <div class="label-issues"> + {{if $.PageIsOrgSettingsLabels}} + <a class="open-issues" href="{{AppSubUrl}}/issues?labels={{.ID}}">{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a> + {{else}} + <a class="open-issues" href="{{$.RepoLink}}/issues?labels={{.ID}}">{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues.label_open_issues" .NumOpenIssues}}</a> + {{end}} + </div> + <div class="label-operation tw-flex"> + {{template "repo/issue/labels/label_archived" .}} + <div class="tw-flex tw-ml-auto"> + {{if and (not $.PageIsOrgSettingsLabels) (not $.Repository.IsArchived) (or $.CanWriteIssues $.CanWritePulls)}} + <a class="edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" {{if .Exclusive}}data-exclusive{{end}} {{if gt .ArchivedUnix 0}}data-is-archived{{end}} data-num-issues="{{.NumIssues}}" data-description="{{.Description}}" data-color={{.Color}}>{{svg "octicon-pencil"}} {{ctx.Locale.Tr "repo.issues.label_edit"}}</a> + <a class="delete-button" href="#" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.issues.label_delete"}}</a> + {{else if $.PageIsOrgSettingsLabels}} + <a class="edit-label-button" href="#" data-id="{{.ID}}" data-title="{{.Name}}" {{if .Exclusive}}data-exclusive{{end}} {{if gt .ArchivedUnix 0}}data-is-archived{{end}} data-num-issues="{{.NumIssues}}" data-description="{{.Description}}" data-color={{.Color}}>{{svg "octicon-pencil"}} {{ctx.Locale.Tr "repo.issues.label_edit"}}</a> + <a class="delete-button" href="#" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}} {{ctx.Locale.Tr "repo.issues.label_delete"}}</a> + {{end}} + </div> + </div> + </li> + {{end}} + + {{if and (not .PageIsOrgSettingsLabels) (.OrgLabels)}} + <li class="item"> + <div class="ui grid middle aligned"> + <div class="ten wide column"> + {{ctx.Locale.Tr "repo.org_labels_desc"}} + {{if .IsOrganizationOwner}} + <a href="{{.OrganizationLink}}/settings/labels">({{ctx.Locale.Tr "repo.org_labels_desc_manage"}})</a>: + {{end}} + </div> + </div> + </li> + + {{range .OrgLabels}} + <li class="item org-label"> + <div class="label-title"> + {{RenderLabel $.Context ctx.Locale .}} + {{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}} + </div> + <div class="label-issues"> + <a class="open-issues" {{if .IsArchived}}data-is-archived{{end}} href="{{$.RepoLink}}/issues?labels={{.ID}}">{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues.label_open_issues" .NumOpenRepoIssues}}</a> + </div> + <div class="label-operation"> + {{template "repo/issue/labels/label_archived" .}} + </div> + </li> + {{end}} + {{end}} + </ul> +</div> diff --git a/templates/repo/issue/labels/label_load_template.tmpl b/templates/repo/issue/labels/label_load_template.tmpl new file mode 100644 index 0000000..0249430 --- /dev/null +++ b/templates/repo/issue/labels/label_load_template.tmpl @@ -0,0 +1,24 @@ +<div class="ui centered grid"> + <div class="twelve wide computer column"> + <div class="ui attached left aligned segment"> + <p>{{ctx.Locale.Tr "repo.issues.label_templates.info"}}</p> + <br> + <form class="ui form center" action="{{.Link}}/initialize" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <div class="ui selection dropdown"> + <input type="hidden" name="template_name" value="Default"> + <div class="default text">{{ctx.Locale.Tr "repo.issues.label_templates.helper"}}</div> + <div class="menu"> + {{range .LabelTemplateFiles}} + <div class="item" data-value="{{.DisplayName}}">{{.DisplayName}}<br><p>({{.Description}})</p></div> + {{end}} + </div> + {{svg "octicon-triangle-down" 18 "dropdown icon"}} + </div> + </div> + <button type="submit" class="ui primary button">{{ctx.Locale.Tr "repo.issues.label_templates.use"}}</button> + </form> + </div> + </div> +</div> diff --git a/templates/repo/issue/labels/label_new.tmpl b/templates/repo/issue/labels/label_new.tmpl new file mode 100644 index 0000000..32fd8e7 --- /dev/null +++ b/templates/repo/issue/labels/label_new.tmpl @@ -0,0 +1,48 @@ +<div class="ui small new-label modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new_label"}} + </div> + <div class="content"> + <form class="ui new-label form ignore-dirty" action="{{$.Link}}/new" method="post"> + {{.CsrfTokenHtml}} + <div class="required field"> + <label for="name">{{ctx.Locale.Tr "repo.issues.label_title"}}</label> + <div class="ui small input"> + <input class="label-name-input" name="title" placeholder="{{ctx.Locale.Tr "repo.issues.new_label_placeholder"}}" autofocus required maxlength="50"> + </div> + </div> + <div class="field label-exclusive-input-field"> + <div class="ui checkbox"> + <input class="label-exclusive-input" name="exclusive" type="checkbox"> + <label>{{ctx.Locale.Tr "repo.issues.label_exclusive"}}</label> + </div> + <br> + <small class="desc">{{ctx.Locale.Tr "repo.issues.label_exclusive_desc"}}</small> + </div> + <div class="field"> + <label for="description">{{ctx.Locale.Tr "repo.issues.label_description"}}</label> + <div class="ui small fluid input"> + <input class="label-desc-input" name="description" placeholder="{{ctx.Locale.Tr "repo.issues.new_label_desc_placeholder"}}" maxlength="200"> + </div> + </div> + <div class="field color-field"> + <label for="color">{{ctx.Locale.Tr "repo.issues.label_color"}}</label> + <div class="js-color-picker-input column"> + <input name="color" value="#70c24a" placeholder="#c320f6" required maxlength="7"> + {{template "repo/issue/label_precolors"}} + </div> + </div> + </form> + </div> + + <div class="actions"> + <button class="ui cancel button"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "cancel"}} + </button> + <button class="ui primary ok button"> + {{svg "octicon-check"}} + {{ctx.Locale.Tr "repo.issues.create_label"}} + </button> + </div> +</div> diff --git a/templates/repo/issue/labels/labels_selector_field.tmpl b/templates/repo/issue/labels/labels_selector_field.tmpl new file mode 100644 index 0000000..9e54e7a --- /dev/null +++ b/templates/repo/issue/labels/labels_selector_field.tmpl @@ -0,0 +1,46 @@ +<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-label dropdown"> + <span class="text muted flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.labels"}}</strong> + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </span> + <div class="filter menu ugc-labels" {{if .Issue}}data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/labels"{{else}}data-id="#label_ids"{{end}}> + {{if or .Labels .OrgLabels}} + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input class="tw-w-auto" type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_labels"}}"> + </div> + {{end}} + <a class="no-select item" href="#">{{ctx.Locale.Tr "repo.issues.new.clear_labels"}}</a> + {{if or .Labels .OrgLabels}} + {{$previousExclusiveScope := "_no_scope"}} + {{range .Labels}} + {{$exclusiveScope := .ExclusiveScope}} + {{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}} + <div class="divider"></div> + {{end}} + {{$previousExclusiveScope = $exclusiveScope}} + <a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span> {{RenderLabel $.Context ctx.Locale .}} + {{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}} + <p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p> + </a> + {{end}} + <div class="divider"></div> + {{$previousExclusiveScope = "_no_scope"}} + {{range .OrgLabels}} + {{$exclusiveScope := .ExclusiveScope}} + {{if and (ne $previousExclusiveScope "_no_scope") (ne $previousExclusiveScope $exclusiveScope)}} + <div class="divider"></div> + {{end}} + {{$previousExclusiveScope = $exclusiveScope}} + <a class="{{if .IsChecked}}checked{{end}} item" href="#" data-id="{{.ID}}" {{if .IsArchived}}data-is-archived{{end}} data-id-selector="#label_{{.ID}}" data-scope="{{$exclusiveScope}}"><span class="octicon-check {{if not .IsChecked}}tw-invisible{{end}}">{{if $exclusiveScope}}{{svg "octicon-dot-fill"}}{{else}}{{svg "octicon-check"}}{{end}}</span> {{RenderLabel $.Context ctx.Locale .}} + {{if .Description}}<br><small class="desc">{{.Description | RenderEmoji $.Context}}</small>{{end}} + <p class="archived-label-hint">{{template "repo/issue/labels/label_archived" .}}</p> + </a> + {{end}} + {{else}} + <div class="disabled item">{{ctx.Locale.Tr "repo.issues.new.no_items"}}</div> + {{end}} + </div> +</div> diff --git a/templates/repo/issue/labels/labels_sidebar.tmpl b/templates/repo/issue/labels/labels_sidebar.tmpl new file mode 100644 index 0000000..81fc970 --- /dev/null +++ b/templates/repo/issue/labels/labels_sidebar.tmpl @@ -0,0 +1,11 @@ +<div class="ui labels list"> + <span class="no-select {{if .root.HasSelectedLabel}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_label"}}</span> + <span class="labels-list ugc-labels"> + {{range .root.Labels}} + {{template "repo/issue/labels/label" dict "root" $.root "label" .}} + {{end}} + {{range .root.OrgLabels}} + {{template "repo/issue/labels/label" dict "root" $.root "label" .}} + {{end}} + </span> +</div> diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl new file mode 100644 index 0000000..8c81bf0 --- /dev/null +++ b/templates/repo/issue/list.tmpl @@ -0,0 +1,55 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository issue-list"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + + {{if .PinnedIssues}} + <div id="issue-pins" {{if .IsRepoAdmin}}data-is-repo-admin{{end}}> + {{range .PinnedIssues}} + <div class="issue-card tw-break-anywhere {{if $.IsRepoAdmin}}tw-cursor-grab{{end}}" data-move-url="{{$.Link}}/move_pin" data-issue-id="{{.ID}}"> + {{template "repo/issue/card" (dict "Issue" . "Page" $ "isPinnedIssueCard" true)}} + </div> + {{end}} + </div> + {{end}} + + <div class="list-header list-header-issues"> + {{template "repo/issue/navbar" .}} + {{template "repo/issue/search" .}} + {{if not .Repository.IsArchived}} + {{if .PageIsIssueList}} + <a class="ui small primary button issue-list-new" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{ctx.Locale.Tr "repo.issues.new"}}</a> + {{else}} + <a class="ui small primary button new-pr-button issue-list-new{{if not .PullRequestCtx.Allowed}} disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.Repository.Link}}/compare/{{.Repository.DefaultBranch | PathEscapeSegments}}...{{if ne .Repository.Owner.Name .PullRequestCtx.BaseRepo.Owner.Name}}{{PathEscape .Repository.Owner.Name}}:{{end}}{{.Repository.DefaultBranch | PathEscapeSegments}}{{end}}">{{ctx.Locale.Tr "repo.pulls.new"}}</a> + {{end}} + {{else}} + {{if not .PageIsIssueList}} + <a class="ui small primary small button issue-list-new{{if not .PullRequestCtx.Allowed}} disabled{{end}}" href="{{if .PullRequestCtx.Allowed}}{{.PullRequestCtx.BaseRepo.Link}}/compare/{{.PullRequestCtx.BaseRepo.DefaultBranch | PathEscapeSegments}}...{{if ne .Repository.Owner.Name .PullRequestCtx.BaseRepo.Owner.Name}}{{PathEscape .Repository.Owner.Name}}:{{end}}{{.Repository.DefaultBranch | PathEscapeSegments}}{{end}}">{{ctx.Locale.Tr "action.compare_commits_general"}}</a> + {{end}} + {{end}} + </div> + + {{template "repo/issue/filters" .}} + + <div id="issue-actions" class="issue-list-toolbar tw-hidden"> + <div class="issue-list-toolbar-left"> + {{template "repo/issue/openclose" .}} + <!-- Total Tracked Time --> + {{if .TotalTrackedTime}} + <div class="ui compact tiny secondary menu"> + <span class="item" data-tooltip-content='{{ctx.Locale.Tr "tracked_time_summary"}}'> + {{svg "octicon-clock"}} + {{.TotalTrackedTime | Sec2Time}} + </span> + </div> + {{end}} + </div> + <div class="issue-list-toolbar-right"> + {{template "repo/issue/filter_actions" .}} + </div> + </div> + {{template "shared/issuelist" dict "." . "listType" "repo"}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/milestone/filter_list.tmpl b/templates/repo/issue/milestone/filter_list.tmpl new file mode 100644 index 0000000..cc45d3b --- /dev/null +++ b/templates/repo/issue/milestone/filter_list.tmpl @@ -0,0 +1,16 @@ +<!-- Sort --> +<div class="list-header-sort ui dropdown type jump item"> + <span class="text"> + {{ctx.Locale.Tr "repo.issues.filter_sort"}} + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <a class="{{if or (eq .SortType "closestduedate") (not .SortType)}}active {{end}}item" href="?sort=closestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.earliest_due_data"}}</a> + <a class="{{if eq .SortType "furthestduedate"}}active {{end}}item" href="?sort=furthestduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.latest_due_date"}}</a> + <a class="{{if eq .SortType "leastcomplete"}}active {{end}}item" href="?sort=leastcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_complete"}}</a> + <a class="{{if eq .SortType "mostcomplete"}}active {{end}}item" href="?sort=mostcomplete&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_complete"}}</a> + <a class="{{if eq .SortType "mostissues"}}active {{end}}item" href="?sort=mostissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.most_issues"}}</a> + <a class="{{if eq .SortType "leastissues"}}active {{end}}item" href="?sort=leastissues&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.least_issues"}}</a> + <a class="{{if eq .SortType "name"}}active {{end}}item" href="?sort=name&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.milestones.filter_sort.name"}}</a> + </div> +</div> diff --git a/templates/repo/issue/milestone/select_menu.tmpl b/templates/repo/issue/milestone/select_menu.tmpl new file mode 100644 index 0000000..570acc2 --- /dev/null +++ b/templates/repo/issue/milestone/select_menu.tmpl @@ -0,0 +1,39 @@ +{{$useHTMX := not .NewIssuePage}} +{{if or .OpenMilestones .ClosedMilestones}} + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_milestones"}}"> + </div> + <div class="divider"></div> +{{end}} +<div class="no-select item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?issue_ids={{$.Issue.ID}}&htmx=true"{{end}}>{{ctx.Locale.Tr "repo.issues.new.clear_milestone"}}</div> +{{if and (not .OpenMilestones) (not .ClosedMilestones)}} + <div class="disabled item"> + {{ctx.Locale.Tr "repo.issues.new.no_items"}} + </div> +{{else}} + {{if .OpenMilestones}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_milestone"}} + </div> + {{range .OpenMilestones}} + <a class="item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true"{{else}} data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}"{{end}}> + {{svg "octicon-milestone" 16 "tw-mr-1"}} + {{.Name}} + </a> + {{end}} + {{end}} + {{if .ClosedMilestones}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_milestone"}} + </div> + {{range .ClosedMilestones}} + <a class="item"{{if $useHTMX}} hx-post="{{$.RepoLink}}/issues/milestone?id={{.ID}}&issue_ids={{$.Issue.ID}}&htmx=true"{{else}} data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?milestone={{.ID}}"{{end}}> + {{svg "octicon-milestone" 16 "tw-mr-1"}} + {{.Name}} + </a> + {{end}} + {{end}} +{{end}} diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl new file mode 100644 index 0000000..e5dc8cb --- /dev/null +++ b/templates/repo/issue/milestone_issues.tmpl @@ -0,0 +1,65 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository milestone-issue-list"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <div class="tw-flex tw-items-center tw-justify-between"> + <h1 class="tw-mb-2">{{.Milestone.Name}}</h1> + {{if not .Repository.IsArchived}} + <div class="tw-flex button-row"> + {{if or .CanWriteIssues .CanWritePulls}} + {{if .Milestone.IsClosed}} + <a class="ui primary button link-action" href data-url="{{$.RepoLink}}/milestones/{{.MilestoneID}}/open">{{ctx.Locale.Tr "repo.milestones.open"}} + </a> + {{else}} + <a class="ui red button link-action" href data-url="{{$.RepoLink}}/milestones/{{.MilestoneID}}/close">{{ctx.Locale.Tr "repo.milestones.close"}} + </a> + {{end}} + <a class="ui button" href="{{.RepoLink}}/milestones/{{.MilestoneID}}/edit">{{ctx.Locale.Tr "repo.milestones.edit"}}</a> + {{end}} + <a class="ui primary button" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}?milestone={{.MilestoneID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a> + </div> + {{end}} + </div> + {{if .Milestone.RenderedContent}} + <div class="markup content tw-mb-4"> + {{.Milestone.RenderedContent}} + </div> + {{end}} + <div class="tw-flex tw-flex-col tw-gap-2"> + <progress class="milestone-progress-big" value="{{.Milestone.Completeness}}" max="100"></progress> + <div class="tw-flex tw-gap-4"> + <div class="tw-flex tw-items-center"> + {{$closedDate:= TimeSinceUnix .Milestone.ClosedDateUnix ctx.Locale}} + {{if .IsClosed}} + {{svg "octicon-clock"}} {{ctx.Locale.Tr "repo.milestones.closed" $closedDate}} + {{else}} + + {{if .Milestone.DeadlineString}} + <span{{if .IsOverdue}} class="text red"{{end}}> + {{svg "octicon-calendar"}} + {{DateTime "short" .Milestone.DeadlineString}} + </span> + {{else}} + {{svg "octicon-calendar"}} + {{ctx.Locale.Tr "repo.milestones.no_due_date"}} + {{end}} + {{end}} + </div> + <div class="tw-mr-2">{{ctx.Locale.Tr "repo.milestones.completeness" .Milestone.Completeness}}</div> + {{if .TotalTrackedTime}} + <div data-tooltip-content='{{ctx.Locale.Tr "tracked_time_summary"}}'> + {{svg "octicon-clock"}} + {{.TotalTrackedTime | Sec2Time}} + </div> + {{end}} + </div> + </div> + <div class="divider"></div> + + {{template "repo/issue/filters" .}} + + {{template "shared/issuelist" dict "." . "listType" "milestone"}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/milestone_new.tmpl b/templates/repo/issue/milestone_new.tmpl new file mode 100644 index 0000000..9f32df0 --- /dev/null +++ b/templates/repo/issue/milestone_new.tmpl @@ -0,0 +1,59 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new milestone"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="issue-navbar"> + {{template "repo/issue/navbar" .}} + {{if and (or .CanWriteIssues .CanWritePulls) .PageIsEditMilestone}} + <div class="ui right floated secondary menu"> + <a class="ui primary button" href="{{$.RepoLink}}/milestones/new">{{ctx.Locale.Tr "repo.milestones.new"}}</a> + </div> + {{end}} + </div> + <div class="divider"></div> + <h2 class="ui dividing header"> + {{if .PageIsEditMilestone}} + {{ctx.Locale.Tr "repo.milestones.edit"}} + <div class="sub header">{{ctx.Locale.Tr "repo.milestones.edit_subheader"}}</div> + {{else}} + {{ctx.Locale.Tr "repo.milestones.new"}} + <div class="sub header">{{ctx.Locale.Tr "repo.milestones.new_subheader"}}</div> + {{end}} + </h2> + {{template "base/alert" .}} + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div class="field {{if .Err_Title}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.milestones.title"}}</label> + <input name="title" placeholder="{{ctx.Locale.Tr "repo.milestones.title"}}" value="{{.title}}" autofocus required maxlength="50"> + </div> + <div class="field {{if .Err_Deadline}}error{{end}}"> + <label> + {{ctx.Locale.Tr "repo.milestones.due_date"}} + <a id="clear-date">{{ctx.Locale.Tr "repo.milestones.clear"}}</a> + </label> + <input type="date" id="deadline" name="deadline" value="{{.deadline}}" placeholder="{{ctx.Locale.Tr "repo.issues.due_date_form"}}"> + </div> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.milestones.desc"}}</label> + <textarea name="content">{{.content}}</textarea> + </div> + <div class="divider"></div> + <div class="tw-text-right"> + {{if .PageIsEditMilestone}} + <a class="ui primary basic button" href="{{.RepoLink}}/milestones"> + {{ctx.Locale.Tr "repo.milestones.cancel"}} + </a> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.milestones.modify"}} + </button> + {{else}} + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.milestones.create"}} + </button> + {{end}} + </div> + </form> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl new file mode 100644 index 0000000..63a6f6b --- /dev/null +++ b/templates/repo/issue/milestones.tmpl @@ -0,0 +1,110 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository milestones"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + + <div class="list-header list-header-issues"> + {{template "repo/issue/navbar" .}} + {{template "repo/issue/search" .}} + {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} + <div class="button-row"> + <a class="ui small primary button" href="{{$.Link}}/new">{{ctx.Locale.Tr "repo.milestones.new"}}</a> + </div> + {{end}} + </div> + + {{template "repo/issue/filters" .}} + + <!-- milestone list --> + <div class="milestone-list"> + {{range .Milestones}} + <li class="milestone-card"> + <div class="milestone-header"> + <h3 class="flex-text-block tw-m-0"> + {{svg "octicon-milestone" 16}} + <a class="muted" href="{{$.RepoLink}}/milestone/{{.ID}}">{{.Name}}</a> + </h3> + <div class="tw-flex tw-items-center"> + <span class="tw-mr-2">{{.Completeness}}%</span> + <progress value="{{.Completeness}}" max="100"></progress> + </div> + </div> + <div class="milestone-toolbar"> + <div class="group"> + <div class="flex-text-block"> + {{svg "octicon-issue-opened" 14}} + {{ctx.Locale.PrettyNumber .NumOpenIssues}} {{ctx.Locale.Tr "repo.issues.open_title"}} + </div> + <div class="flex-text-block"> + {{svg "octicon-check" 14}} + {{ctx.Locale.PrettyNumber .NumClosedIssues}} {{ctx.Locale.Tr "repo.issues.closed_title"}} + </div> + {{if .TotalTrackedTime}} + <div class="flex-text-block"> + {{svg "octicon-clock"}} + {{.TotalTrackedTime|Sec2Time}} + </div> + {{end}} + {{if .UpdatedUnix}} + <div class="flex-text-block"> + {{svg "octicon-clock"}} + {{ctx.Locale.Tr "repo.milestones.update_ago" (TimeSinceUnix .UpdatedUnix ctx.Locale)}} + </div> + {{end}} + <div class="flex-text-block"> + {{if .IsClosed}} + {{$closedDate:= TimeSinceUnix .ClosedDateUnix ctx.Locale}} + {{svg "octicon-clock" 14}} + {{ctx.Locale.Tr "repo.milestones.closed" $closedDate}} + {{else}} + {{if .DeadlineString}} + <span class="flex-text-inline {{if .IsOverdue}}text red{{end}}"> + {{svg "octicon-calendar" 14}} + {{DateTime "short" .DeadlineString}} + </span> + {{else}} + {{svg "octicon-calendar" 14}} + {{ctx.Locale.Tr "repo.milestones.no_due_date"}} + {{end}} + {{end}} + </div> + </div> + {{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}} + <div class="group"> + <a class="flex-text-inline" href="{{$.Link}}/{{.ID}}/edit">{{svg "octicon-pencil" 14}}{{ctx.Locale.Tr "repo.issues.label_edit"}}</a> + {{if .IsClosed}} + <a class="link-action flex-text-inline" href data-url="{{$.Link}}/{{.ID}}/open">{{svg "octicon-check" 14}}{{ctx.Locale.Tr "repo.milestones.open"}}</a> + {{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> + </div> + {{end}} + </div> + {{if .Content}} + <div class="markup content"> + {{.RenderedContent}} + </div> + {{end}} + </li> + {{end}} + + {{template "base/paginate" .}} + </div> + </div> +</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> + {{template "base/modal_actions_confirm" .}} + </div> +{{end}} +{{template "base/footer" .}} diff --git a/templates/repo/issue/navbar.tmpl b/templates/repo/issue/navbar.tmpl new file mode 100644 index 0000000..30e42c7 --- /dev/null +++ b/templates/repo/issue/navbar.tmpl @@ -0,0 +1,4 @@ +<h2 class="ui compact small menu small-menu-items issue-list-navbar"> + <a class="{{if .PageIsLabels}}active {{end}}item" href="{{.RepoLink}}/labels">{{ctx.Locale.Tr "repo.labels"}}</a> + <a class="{{if .PageIsMilestones}}active {{end}}item" href="{{.RepoLink}}/milestones">{{ctx.Locale.Tr "repo.milestones"}}</a> +</h2> diff --git a/templates/repo/issue/new.tmpl b/templates/repo/issue/new.tmpl new file mode 100644 index 0000000..ccd45fd --- /dev/null +++ b/templates/repo/issue/new.tmpl @@ -0,0 +1,8 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new issue"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "repo/issue/new_form" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl new file mode 100644 index 0000000..c2cf4ee --- /dev/null +++ b/templates/repo/issue/new_form.tmpl @@ -0,0 +1,155 @@ +{{if .Flash}} +{{template "base/alert" .}} +{{end}} +<form class="issue-content ui comment form form-fetch-action" id="new-issue" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div class="issue-content-left"> + <div class="ui comments"> + <div class="comment"> + {{ctx.AvatarUtils.Avatar .SignedUser 40}} + <div class="ui segment content tw-my-0"> + <div class="field"> + <input name="title" class="js-autofocus-end" id="issue_title" placeholder="{{ctx.Locale.Tr "repo.milestones.title"}}" value="{{if .TitleQuery}}{{.TitleQuery}}{{else if .IssueTemplateTitle}}{{.IssueTemplateTitle}}{{else}}{{.title}}{{end}}" required maxlength="255" autocomplete="off"> + {{if .PageIsComparePull}} + <div class="title_wip_desc" data-wip-prefixes="{{JsonUtils.EncodeToString .PullRequestWorkInProgressPrefixes}}">{{ctx.Locale.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0)}}</div> + {{end}} + </div> + {{if .Fields}} + <input type="hidden" name="template-file" value="{{.TemplateFile}}"> + {{range .Fields}} + {{if eq .Type "input"}} + {{template "repo/issue/fields/input" dict "Context" $.Context "item" .}} + {{else if eq .Type "markdown"}} + {{template "repo/issue/fields/markdown" dict "Context" $.Context "item" .}} + {{else if eq .Type "textarea"}} + {{template "repo/issue/fields/textarea" dict "Context" $.Context "item" . "root" $}} + {{else if eq .Type "dropdown"}} + {{template "repo/issue/fields/dropdown" dict "Context" $.Context "item" .}} + {{else if eq .Type "checkboxes"}} + {{template "repo/issue/fields/checkboxes" dict "Context" $.Context "item" .}} + {{end}} + {{end}} + {{else}} + {{template "repo/issue/comment_tab" .}} + {{end}} + <div class="text right"> + <button class="ui primary button"> + {{if .PageIsComparePull}} + {{ctx.Locale.Tr "repo.pulls.create"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.create"}} + {{end}} + </button> + </div> + </div> + </div> + </div> + </div> + + <div class="issue-content-right ui segment"> + {{template "repo/issue/view_content/sidebar/branch_selector_field" .}} + + <input id="label_ids" name="label_ids" type="hidden" value="{{.label_ids}}"> + {{template "repo/issue/labels/labels_selector_field" .}} + {{template "repo/issue/labels/labels_sidebar" dict "root" $}} + + <div class="divider"></div> + + <input id="milestone_id" name="milestone_id" type="hidden" value="{{.milestone_id}}"> + <div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating jump select-milestone dropdown"> + <span class="text flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.milestone"}}</strong> + {{if .HasIssuesOrPullsWritePermission}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </span> + <div class="menu"> + {{template "repo/issue/milestone/select_menu" dict "." . "NewIssuePage" 1}} + </div> + </div> + <div class="ui select-milestone list"> + <span class="no-select item {{if .Milestone}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_milestone"}}</span> + <div class="selected"> + {{if .Milestone}} + <a class="item muted sidebar-item-link" href="{{.RepoLink}}/issues?milestone={{.Milestone.ID}}"> + {{svg "octicon-milestone" 18 "tw-mr-2"}} + {{.Milestone.Name}} + </a> + {{end}} + </div> + </div> + + {{if .IsProjectsEnabled}} + <div class="divider"></div> + + <input id="project_id" name="project_id" type="hidden" value="{{.project_id}}"> + <div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating jump select-project dropdown"> + <span class="text flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.projects"}}</strong> + {{if .HasIssuesOrPullsWritePermission}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </span> + <div class="menu"> + {{if or .OpenProjects .ClosedProjects}} + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_projects"}}"> + </div> + {{end}} + <div class="no-select item">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div> + {{if and (not .OpenProjects) (not .ClosedProjects)}} + <div class="disabled item"> + {{ctx.Locale.Tr "repo.issues.new.no_items"}} + </div> + {{else}} + {{if .OpenProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_projects"}} + </div> + {{range .OpenProjects}} + <a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link ctx}}"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </a> + {{end}} + {{end}} + {{if .ClosedProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} + </div> + {{range .ClosedProjects}} + <a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link ctx}}"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </a> + {{end}} + {{end}} + {{end}} + </div> + </div> + <div class="ui select-project list"> + <span class="no-select item {{if .Project}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_projects"}}</span> + <div class="selected"> + {{if .Project}} + <a class="item muted sidebar-item-link" href="{{.Project.Link ctx}}"> + {{svg .Project.IconName 18 "tw-mr-2"}}{{.Project.Title}} + </a> + {{end}} + </div> + </div> + {{end}} + <div class="divider"></div> + {{template "repo/issue/view_content/sidebar/assignees" dict "isExistingIssue" false "." .}} + {{if and .PageIsComparePull (not (eq .HeadRepo.FullName .BaseCompareRepo.FullName)) .CanWriteToHeadRepo}} + <div class="divider"></div> + <div class="inline field"> + <div class="ui checkbox"> + <label data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers_desc"}}"><strong>{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers"}}</strong></label> + <input name="allow_maintainer_edit" type="checkbox" {{if .AllowMaintainerEdit}}checked{{end}}> + </div> + </div> + {{end}} + </div> + <input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}"> +</form> diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl new file mode 100644 index 0000000..eb2d6e0 --- /dev/null +++ b/templates/repo/issue/openclose.tmpl @@ -0,0 +1,16 @@ +<div class="small-menu-items ui compact tiny menu"> + <a class="{{if eq .State "open"}}active {{end}}item" href="{{if eq .State "open"}}{{.AllStatesLink}}{{else}}{{.OpenLink}}{{end}}"> + {{if .PageIsMilestones}} + {{svg "octicon-milestone" 16 "tw-mr-2"}} + {{else if .PageIsPullList}} + {{svg "octicon-git-pull-request" 16 "tw-mr-2"}} + {{else}} + {{svg "octicon-issue-opened" 16 "tw-mr-2"}} + {{end}} + {{ctx.Locale.PrettyNumber .OpenCount}} {{ctx.Locale.Tr "repo.issues.open_title"}} + </a> + <a class="{{if eq .State "closed"}}active {{end}}item" href="{{if eq .State "closed"}}{{.AllStatesLink}}{{else}}{{.ClosedLink}}{{end}}"> + {{svg "octicon-check" 16 "tw-mr-2"}} + {{ctx.Locale.PrettyNumber .ClosedCount}} {{ctx.Locale.Tr "repo.issues.closed_title"}} + </a> +</div> diff --git a/templates/repo/issue/search.tmpl b/templates/repo/issue/search.tmpl new file mode 100644 index 0000000..f1c0ea3 --- /dev/null +++ b/templates/repo/issue/search.tmpl @@ -0,0 +1,20 @@ +<form class="list-header-search ui form ignore-dirty issue-list-search"> + <div class="ui small search fluid action input"> + <input type="hidden" name="state" value="{{$.State}}"> + {{if not .PageIsMilestones}} + <input type="hidden" name="type" value="{{$.ViewType}}"> + <input type="hidden" name="labels" value="{{.SelectLabels}}"> + <input type="hidden" name="milestone" value="{{$.MilestoneID}}"> + <input type="hidden" name="project" value="{{$.ProjectID}}"> + <input type="hidden" name="assignee" value="{{$.AssigneeID}}"> + <input type="hidden" name="poster" value="{{$.PosterID}}"> + {{end}} + {{if .PageIsPullList}} + {{template "shared/search/combo_fuzzy" dict "Value" .Keyword "IsFuzzy" .IsFuzzy "Placeholder" (ctx.Locale.Tr "search.pull_kind") "Tooltip" (ctx.Locale.Tr "explore.go_to")}} + {{else if .PageIsMilestones}} + {{template "shared/search/combo_fuzzy" dict "Value" .Keyword "IsFuzzy" .IsFuzzy "Placeholder" (ctx.Locale.Tr "search.milestone_kind") "Tooltip" (ctx.Locale.Tr "explore.go_to")}} + {{else}} + {{template "shared/search/combo_fuzzy" dict "Value" .Keyword "IsFuzzy" .IsFuzzy "Placeholder" (ctx.Locale.Tr "search.issue_kind") "Tooltip" (ctx.Locale.Tr "explore.go_to")}} + {{end}} + </div> +</form> diff --git a/templates/repo/issue/view.tmpl b/templates/repo/issue/view.tmpl new file mode 100644 index 0000000..1ef9e73 --- /dev/null +++ b/templates/repo/issue/view.tmpl @@ -0,0 +1,12 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository view issue pull"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "repo/issue/view_title" .}} + {{if .Issue.IsPull}} + {{template "repo/pulls/tab_menu" .}} + {{end}} + {{template "repo/issue/view_content" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl new file mode 100644 index 0000000..683dea8 --- /dev/null +++ b/templates/repo/issue/view_content.tmpl @@ -0,0 +1,188 @@ +<div class="issue-content"> + <!-- I know, there is probably a better way to do this (moved from sidebar.tmpl, original author: 6543 @ 2021-02-28) --> + <!-- Agree, there should be a better way, eg: introduce window.config.pageData (original author: wxiaoguang @ 2021-09-05) --> + <input type="hidden" id="repolink" value="{{$.RepoRelPath}}"> + <input type="hidden" id="repoId" value="{{.Repository.ID}}"> + <input type="hidden" id="issueIndex" value="{{.Issue.Index}}"> + <input type="hidden" id="type" value="{{.IssueType}}"> + + {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}} + <div class="issue-content-left comment-list prevent-before-timeline"> + <div class="ui timeline"> + <div id="{{.Issue.HashTag}}" class="timeline-item comment first"> + {{if .Issue.OriginalAuthor}} + <span class="timeline-avatar"> + {{ctx.AvatarUtils.Avatar nil 40}} + </span> + {{else}} + <a class="timeline-avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}> + {{ctx.AvatarUtils.Avatar .Issue.Poster 40}} + </a> + {{end}} + <div class="content comment-container"> + <div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between" role="heading" aria-level="3"> + <div class="comment-header-left tw-flex tw-items-center"> + {{if .Issue.OriginalAuthor}} + <span class="text black tw-font-semibold"> + {{svg (MigrationIcon .Repository.GetOriginalURLHostname)}} + {{.Issue.OriginalAuthor}} + </span> + <span class="text grey muted-links"> + {{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}} + </span> + <span class="text migrate"> + {{if .Repository.OriginalURL}} ({{ctx.Locale.Tr "repo.migrated_from" .Repository.OriginalURL .Repository.GetOriginalURLHostname}}){{end}} + </span> + {{else}} + <a class="inline-timeline-avatar" href="{{.Issue.Poster.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .Issue.Poster 24}} + </a> + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Issue.Poster}} + {{ctx.Locale.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr}} + </span> + {{end}} + </div> + <div class="comment-header-right actions tw-flex tw-items-center"> + {{template "repo/issue/view_content/show_role" dict "ShowRole" .Issue.ShowRole "IgnorePoster" true "IsPull" .Issue.IsPull}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index)}} + {{end}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" .Issue "delete" false "issue" true "diff" false "IsCommentPoster" $.IsIssuePoster}} + </div> + </div> + <div class="ui attached segment comment-body" role="article"> + <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission $.IsIssuePoster}}data-can-edit="true"{{end}}> + {{if .Issue.RenderedContent}} + {{.Issue.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + <div id="issue-{{.Issue.ID}}-raw" class="raw-content tw-hidden">{{.Issue.Content}}</div> + <div class="edit-content-zone tw-hidden" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-content-version="{{.Issue.ContentVersion}}" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div> + {{if .Issue.Attachments}} + {{template "repo/issue/view_content/attachments" dict "Attachments" .Issue.Attachments "RenderedContent" .Issue.RenderedContent}} + {{end}} + </div> + {{$reactions := .Issue.Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions}} + {{end}} + </div> + </div> + + {{template "repo/issue/view_content/comments" .}} + <div id="insert-timeline"></div> + + {{if and .Issue.IsPull (not $.Repository.IsArchived)}} + {{template "repo/issue/view_content/pull".}} + {{end}} + + {{if .IsSigned}} + {{if and (or .IsRepoAdmin .HasIssuesOrPullsWritePermission (not .Issue.IsLocked)) (not .Repository.IsArchived)}} + <div class="timeline-item comment form"> + <a class="timeline-avatar" href="{{.SignedUser.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 40}} + </a> + <div class="content"> + <form class="ui segment form form-fetch-action" id="comment-form" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/comments" method="post"> + {{template "repo/issue/comment_tab" .}} + {{.CsrfTokenHtml}} + <div class="field footer"> + <div class="text right"> + {{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .DisableStatusChange)}} + {{if .Issue.IsClosed}} + <button id="status-button" class="ui primary basic button" data-status="{{ctx.Locale.Tr "repo.issues.reopen_issue"}}" data-status-and-comment="{{ctx.Locale.Tr "repo.issues.reopen_comment_issue"}}" name="status" value="reopen"> + {{ctx.Locale.Tr "repo.issues.reopen_issue"}} + </button> + {{else}} + {{$closeTranslationKey := "repo.issues.close"}} + {{if .Issue.IsPull}} + {{$closeTranslationKey = "repo.pulls.close"}} + {{end}} + <button id="status-button" class="ui red basic button" data-status="{{ctx.Locale.Tr $closeTranslationKey}}" data-status-and-comment="{{ctx.Locale.Tr "repo.issues.close_comment_issue"}}" name="status" value="close"> + {{ctx.Locale.Tr $closeTranslationKey}} + </button> + {{end}} + {{end}} + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.issues.create_comment"}} + </button> + </div> + </div> + </form> + </div> + </div> + {{else if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.archive.pull.nocomment"}} + {{else}} + {{ctx.Locale.Tr "repo.archive.issue.nocomment"}} + {{end}} + </div> + {{end}} + {{else}} {{/* not .IsSigned */}} + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.archive.pull.nocomment"}} + {{else}} + {{ctx.Locale.Tr "repo.archive.issue.nocomment"}} + {{end}} + </div> + {{else}} + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.issues.sign_in_require_desc" .SignInLink}} + </div> + {{end}} + {{end}}{{/* end if: .IsSigned */}} + </div> + </div> + + {{template "repo/issue/view_content/sidebar" .}} +</div> + +<template id="issue-comment-editor-template"> + <div class="ui comment form"> + <div class="field"> + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "DropzoneParentContainer" ".ui.form" + )}} + </div> + + {{if .IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" .}} + </div> + {{end}} + + <div class="field"> + <div class="text right edit"> + <button class="ui basic cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button> + <button class="ui primary save button">{{ctx.Locale.Tr "repo.issues.save"}}</button> + </div> + </div> + </div> +</template> + +{{template "repo/issue/view_content/reference_issue_dialog" .}} + +<div class="tw-hidden" id="no-content"> + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> +</div> + +<div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.branch.delete" .HeadTarget}} + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.branch.delete_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} +</div> diff --git a/templates/repo/issue/view_content/add_reaction.tmpl b/templates/repo/issue/view_content/add_reaction.tmpl new file mode 100644 index 0000000..37931f2 --- /dev/null +++ b/templates/repo/issue/view_content/add_reaction.tmpl @@ -0,0 +1,12 @@ +{{if .ctxData.IsSigned}} +<div class="item action ui dropdown jump pointing top right select-reaction" data-action-url="{{.ActionURL}}"> + <a class="add-reaction muted"> + {{svg "octicon-smiley"}} + </a> + <div class="menu reactions-menu"> + {{range $value := AllowedReactions}} + <a class="item reaction" data-tooltip-content="{{$value}}" aria-label="{{$value}}" data-reaction-content="{{$value}}">{{ReactionToEmoji $value}}</a> + {{end}} + </div> +</div> +{{end}} diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl new file mode 100644 index 0000000..79085df --- /dev/null +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -0,0 +1,42 @@ +<div class="dropzone-attachments"> + {{if .Attachments}} + <div class="divider"></div> + {{end}} + {{$hasThumbnails := false}} + {{- range .Attachments -}} + <div class="tw-flex"> + <div class="tw-flex-1 tw-p-2"> + <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title="{{ctx.Locale.Tr "repo.issues.attachment.open_tab" .Name}}"> + {{if FilenameIsImage .Name}} + {{if not (StringUtils.Contains (StringUtils.ToString $.RenderedContent) .UUID)}} + {{$hasThumbnails = true}} + {{end}} + {{svg "octicon-file"}} + {{else}} + {{svg "octicon-desktop-download"}} + {{end}} + <span><strong>{{.Name}}</strong></span> + </a> + </div> + <div class="tw-p-2 tw-flex tw-items-center"> + <span class="ui text grey">{{.Size | ctx.Locale.TrSize}}</span> + </div> + </div> + {{end -}} + + {{if $hasThumbnails}} + <div class="divider"></div> + <div class="ui small thumbnails"> + {{- range .Attachments -}} + {{if FilenameIsImage .Name}} + {{if not (StringUtils.Contains (StringUtils.ToString $.RenderedContent) .UUID)}} + <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}"> + <img alt="{{.Name}}" src="{{.DownloadURL}}" title="{{ctx.Locale.Tr "repo.issues.attachment.open_tab" .Name}}"> + </a> + {{end}} + {{end}} + {{end -}} + </div> + {{end}} + +</div> diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl new file mode 100644 index 0000000..08c83c0 --- /dev/null +++ b/templates/repo/issue/view_content/comments.tmpl @@ -0,0 +1,691 @@ +{{template "base/alert"}} +{{range .Issue.Comments}} + {{if call $.ShouldShowCommentType .Type}} + {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} + + <!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, + 5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 8 = MILESTONE_CHANGE, + 9 = ASSIGNEES_CHANGE, 10 = TITLE_CHANGE, 11 = DELETE_BRANCH, 12 = START_TRACKING, + 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE, + 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE, + 22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED, + 26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST, 28 = MERGE_PULL_REQUEST, + 29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED + 32 = DISMISSED_REVIEW, 33 = COMMENT_TYPE_CHANGE_ISSUE_REF, 34 = PR_SCHEDULE_TO_AUTO_MERGE, + 35 = CANCEL_SCHEDULED_AUTO_MERGE_PR, 36 = PIN_ISSUE, 37 = UNPIN_ISSUE --> + {{if eq .Type 0}} + <div class="timeline-item comment" id="{{.HashTag}}"> + {{if .OriginalAuthor}} + <span class="timeline-avatar"> + {{ctx.AvatarUtils.Avatar nil 40}} + </span> + {{else}} + <a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}> + {{ctx.AvatarUtils.Avatar .Poster 40}} + </a> + {{end}} + <div class="content comment-container"> + <div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between" role="heading" aria-level="3"> + <div class="comment-header-left tw-flex tw-items-center"> + {{if .OriginalAuthor}} + <span class="text black tw-font-semibold tw-mr-1"> + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{.OriginalAuthor}} + </span> + <span class="text grey muted-links"> + {{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdStr}} {{if $.Repository.OriginalURL}} + </span> + <span class="text migrate"> + ({{ctx.Locale.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname}}){{end}} + </span> + {{else}} + {{if gt .Poster.ID 0}} + <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .Poster 24}} + </a> + {{end}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdStr}} + </span> + {{end}} + </div> + <div class="comment-header-right actions tw-flex tw-items-center"> + {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "IsPull" .Issue.IsPull}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{end}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + </div> + </div> + <div class="ui attached segment comment-body" role="article"> + <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> + {{if .RenderedContent}} + {{.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + <div id="issuecomment-{{.ID}}-raw" class="raw-content tw-hidden">{{.Content}}</div> + <div class="edit-content-zone tw-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-content-version="{{.ContentVersion}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + {{if .Attachments}} + {{template "repo/issue/view_content/attachments" dict "Attachments" .Attachments "RenderedContent" .RenderedContent}} + {{end}} + </div> + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} + {{end}} + </div> + </div> + {{else if eq .Type 1}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge tw-bg-green tw-text-white">{{svg "octicon-dot-fill"}}</span> + {{if not .OriginalAuthor}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{end}} + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.pulls.reopened_at" .EventTag $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.reopened_at" .EventTag $createdStr}} + {{end}} + </span> + </div> + {{else if eq .Type 2}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge tw-bg-red tw-text-white">{{svg "octicon-circle-slash"}}</span> + {{if not .OriginalAuthor}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{end}} + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.pulls.closed_at" .EventTag $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.closed_at" .EventTag $createdStr}} + {{end}} + </span> + </div> + {{else if eq .Type 28}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge tw-bg-purple tw-text-white">{{svg "octicon-git-merge"}}</span> + {{if not .OriginalAuthor}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{end}} + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}} + {{if eq $.Issue.PullRequest.Status 3}} + {{ctx.Locale.Tr "repo.issues.comment_manually_pull_merged_at" (HTMLFormat `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` $link (ShortSha $.Issue.PullRequest.MergedCommitID)) (HTMLFormat "<b>%[1]s</b>" $.BaseTarget) $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.comment_pull_merged_at" (HTMLFormat `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` $link (ShortSha $.Issue.PullRequest.MergedCommitID)) (HTMLFormat "<b>%[1]s</b>" $.BaseTarget) $createdStr}} + {{end}} + </span> + </div> + {{else if eq .Type 3 5 6}} + {{$refFrom:= ""}} + {{if ne .RefRepoID .Issue.RepoID}} + {{$refFrom = ctx.Locale.Tr "repo.issues.ref_from" .RefRepo.FullName}} + {{end}} + {{$refTr := "repo.issues.ref_issue_from"}} + {{if .Issue.IsPull}} + {{$refTr = "repo.issues.ref_pull_from"}} + {{else if eq .RefAction 1}} + {{$refTr = "repo.issues.ref_closing_from"}} + {{else if eq .RefAction 2}} + {{$refTr = "repo.issues.ref_reopening_from"}} + {{end}} + {{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-bookmark"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{if eq .RefAction 3}}<del>{{end}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr $refTr .EventTag $createdStr (.RefCommentLink ctx) $refFrom}} + </span> + {{if eq .RefAction 3}}</del>{{end}} + + <div class="detail flex-text-block"> + <span class="text grey muted-links"><a href="{{.RefIssueLink ctx}}"><b>{{.RefIssueTitle ctx | RenderEmoji $.Context | RenderCodeBlock}}</b> {{.RefIssueIdent ctx}}</a></span> + </div> + </div> + {{else if eq .Type 4}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-bookmark"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.pulls.commit_ref_at" .EventTag $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.commit_ref_at" .EventTag $createdStr}} + {{end}} + </span> + <div class="detail flex-text-block"> + {{svg "octicon-git-commit"}} + <span class="text grey muted-links">{{.Content | SanitizeHTML}}</span> + </div> + </div> + {{else if eq .Type 7}} + {{if or .AddedLabels .RemovedLabels}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-tag"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if and .AddedLabels (not .RemovedLabels)}} + {{ctx.Locale.TrN (len .AddedLabels) "repo.issues.add_label" "repo.issues.add_labels" (RenderLabels $.Context ctx.Locale .AddedLabels $.RepoLink .Issue.IsPull) $createdStr}} + {{else if and (not .AddedLabels) .RemovedLabels}} + {{ctx.Locale.TrN (len .RemovedLabels) "repo.issues.remove_label" "repo.issues.remove_labels" (RenderLabels $.Context ctx.Locale .RemovedLabels $.RepoLink .Issue.IsPull) $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.add_remove_labels" (RenderLabels $.Context ctx.Locale .AddedLabels $.RepoLink .Issue.IsPull) (RenderLabels $.Context ctx.Locale .RemovedLabels $.RepoLink .Issue.IsPull) $createdStr}} + {{end}} + </span> + </div> + {{end}} + {{else if eq .Type 8}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-milestone"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{ctx.Locale.Tr "repo.issues.change_milestone_at" .OldMilestone.Name .Milestone.Name $createdStr}}{{else}}{{ctx.Locale.Tr "repo.issues.remove_milestone_at" .OldMilestone.Name $createdStr}}{{end}}{{else if gt .MilestoneID 0}}{{ctx.Locale.Tr "repo.issues.add_milestone_at" .Milestone.Name $createdStr}}{{end}} + </span> + </div> + {{else if and (eq .Type 9) (gt .AssigneeID 0)}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-person"}}</span> + {{if .RemovedAssignee}} + {{template "shared/user/avatarlink" dict "user" .Assignee}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Assignee}} + {{if eq .Poster.ID .Assignee.ID}} + {{ctx.Locale.Tr "repo.issues.remove_self_assignment" $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.remove_assignee_at" .Poster.GetDisplayName $createdStr}} + {{end}} + </span> + {{else}} + {{template "shared/user/avatarlink" dict "user" .Assignee}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Assignee}} + {{if eq .Poster.ID .AssigneeID}} + {{ctx.Locale.Tr "repo.issues.self_assign_at" $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.add_assignee_at" .Poster.GetDisplayName $createdStr}} + {{end}} + </span> + {{end}} + </div> + {{else if eq .Type 10}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-pencil"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.change_title_at" (RenderRefIssueTitle $.Context .OldTitle) (RenderRefIssueTitle $.Context .NewTitle) $createdStr}} + </span> + </div> + {{else if eq .Type 11}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-git-branch"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.delete_branch_at" .OldRef $createdStr}} + </span> + </div> + {{else if eq .Type 12}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.start_tracking_history" $createdStr}} + </span> + </div> + {{else if eq .Type 13}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.stop_tracking_history" $createdStr}} + </span> + {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} + <div class="detail flex-text-block"> + {{svg "octicon-clock"}} + {{if .RenderedContent}} + {{/* compatibility with time comments made before v1.21 */}} + <span class="text grey muted-links">{{.RenderedContent}}</span> + {{else}} + <span class="text grey muted-links">{{.Content|Sec2Time}}</span> + {{end}} + </div> + </div> + {{else if eq .Type 14}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.add_time_history" $createdStr}} + </span> + {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} + <div class="detail flex-text-block"> + {{svg "octicon-clock"}} + {{if .RenderedContent}} + {{/* compatibility with time comments made before v1.21 */}} + <span class="text grey muted-links">{{.RenderedContent}}</span> + {{else}} + <span class="text grey muted-links">{{.Content|Sec2Time}}</span> + {{end}} + </div> + </div> + {{else if eq .Type 15}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.cancel_tracking_history" $createdStr}} + </span> + </div> + {{else if eq .Type 16}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.due_date_added" (DateTime "long" .Content) $createdStr}} + </span> + </div> + {{else if eq .Type 17}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{$parsedDeadline := StringUtils.Split .Content "|"}} + {{if eq (len $parsedDeadline) 2}} + {{$from := DateTime "long" (index $parsedDeadline 1)}} + {{$to := DateTime "long" (index $parsedDeadline 0)}} + {{ctx.Locale.Tr "repo.issues.due_date_modified" $to $from $createdStr}} + {{end}} + </span> + </div> + {{else if eq .Type 18}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.due_date_remove" (DateTime "long" .Content) $createdStr}} + </span> + </div> + {{else if eq .Type 19}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-package-dependents"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.dependency.added_dependency" $createdStr}} + </span> + {{if .DependentIssue}} + <div class="detail flex-text-block"> + {{svg "octicon-plus"}} + <span class="text grey muted-links"> + <a href="{{.DependentIssue.Link}}"> + {{$strTitle := RenderRefIssueTitle $.Context .DependentIssue.Title}} + {{if eq .DependentIssue.RepoID .Issue.RepoID}} + #{{.DependentIssue.Index}} {{$strTitle}} + {{else}} + {{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{$strTitle}} + {{end}} + </a> + </span> + </div> + {{end}} + </div> + {{else if eq .Type 20}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-package-dependents"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.dependency.removed_dependency" $createdStr}} + </span> + {{if .DependentIssue}} + <div class="detail flex-text-block"> + {{svg "octicon-trash"}} + <span class="text grey muted-links"> + <a href="{{.DependentIssue.Link}}"> + {{$strTitle := RenderRefIssueTitle $.Context .DependentIssue.Title}} + {{if eq .DependentIssue.RepoID .Issue.RepoID}} + #{{.DependentIssue.Index}} {{$strTitle}} + {{else}} + {{.DependentIssue.Repo.FullName}}#{{.DependentIssue.Index}} - {{$strTitle}} + {{end}} + </a> + </span> + </div> + {{end}} + </div> + {{else if eq .Type 22}} + <div class="timeline-item-group" id="{{.HashTag}}"> + <div class="timeline-item event"> + {{if not .OriginalAuthor}} + {{/* Some timeline avatars need a offset to correctly align with their speech bubble. + The condition depends on whether the comment has contents/attachments or reviews */}} + <a class="timeline-avatar{{if or .Content .Attachments (and .Review .Review.CodeComments)}} timeline-avatar-offset{{end}}"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}> + {{ctx.AvatarUtils.Avatar .Poster 40}} + </a> + {{end}} + <span class="badge{{if eq .Review.Type 1}} tw-bg-green tw-text-white{{else if eq .Review.Type 3}} tw-bg-red tw-text-white{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon)}}</span> + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{if eq .Review.Type 1}} + {{ctx.Locale.Tr "repo.issues.review.approve" $createdStr}} + {{else if eq .Review.Type 2}} + {{ctx.Locale.Tr "repo.issues.review.comment" $createdStr}} + {{else if eq .Review.Type 3}} + {{ctx.Locale.Tr "repo.issues.review.reject" $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.comment" $createdStr}} + {{end}} + {{if .Review.Dismissed}} + <div class="ui small label">{{ctx.Locale.Tr "repo.issues.review.dismissed_label"}}</div> + {{end}} + </span> + </div> + {{if or .Content .Attachments}} + <div class="timeline-item comment"> + <div class="content comment-container"> + <div class="ui top attached header comment-header tw-flex tw-items-center tw-justify-between"> + <div class="comment-header-left tw-flex tw-items-center"> + {{if gt .Poster.ID 0}} + <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .Poster 24}} + </a> + {{end}} + <span class="text grey muted-links"> + {{if .OriginalAuthor}} + <span class="text black tw-font-semibold"> + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{.OriginalAuthor}} + </span> + <span class="text grey muted-links"> {{if $.Repository.OriginalURL}}</span> + <span class="text migrate">({{ctx.Locale.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname}}){{end}}</span> + {{else}} + {{template "shared/user/authorlink" .Poster}} + {{end}} + + {{ctx.Locale.Tr "repo.issues.review.left_comment"}} + </span> + </div> + <div class="comment-header-right actions tw-flex tw-items-center"> + {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "IsPull" .Issue.IsPull}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" false "issue" true "diff" false "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} + </div> + </div> + <div class="ui attached segment comment-body"> + <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> + {{if .RenderedContent}} + {{.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + <div id="issuecomment-{{.ID}}-raw" class="raw-content tw-hidden">{{.Content}}</div> + <div class="edit-content-zone tw-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-content-version="{{.ContentVersion}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + {{if .Attachments}} + {{template "repo/issue/view_content/attachments" dict "Attachments" .Attachments "RenderedContent" .RenderedContent}} + {{end}} + </div> + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} + {{end}} + </div> + </div> + {{end}} + + {{if .Review.CodeComments}} + <div class="timeline-item event"> + {{range $filename, $lines := .Review.CodeComments}} + {{range $line, $comms := $lines}} + {{template "repo/issue/view_content/conversation" dict "." $ "comments" $comms}} + {{end}} + {{end}} + </div> + {{end}} + </div> + {{else if eq .Type 23}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-lock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{if .Content}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.lock_with_reason" .Content $createdStr}} + </span> + {{else}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.lock_no_reason" $createdStr}} + </span> + {{end}} + </div> + {{else if eq .Type 24}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-key"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{ctx.Locale.Tr "repo.issues.unlock_comment" $createdStr}} + </span> + </div> + {{else if eq .Type 25}} + <div class="timeline-item event"> + <span class="badge">{{svg "octicon-git-branch"}}</span> + {{if not .OriginalAuthor}} + {{template "shared/user/avatarlink" dict "user" .Poster}} + {{end}} + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{ctx.Locale.Tr "repo.pulls.change_target_branch_at" .OldRef .NewRef $createdStr}} + </span> + </div> + {{else if eq .Type 26}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-clock"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + + {{ctx.Locale.Tr "repo.issues.del_time_history" $createdStr}} + </span> + <div class="detail flex-text-block"> + {{svg "octicon-clock"}} + {{if .RenderedContent}} + {{/* compatibility with time comments made before v1.21 */}} + <span class="text grey muted-links">{{.RenderedContent}}</span> + {{else}} + <span class="text grey muted-links">- {{.Content|Sec2Time}}</span> + {{end}} + </div> + </div> + {{else if eq .Type 27}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-eye"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if (gt .AssigneeID 0)}} + {{if .RemovedAssignee}} + {{if eq .PosterID .AssigneeID}} + {{ctx.Locale.Tr "repo.issues.review.remove_review_request_self" $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.remove_review_request" .Assignee.GetDisplayName $createdStr}} + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.add_review_request" .Assignee.GetDisplayName $createdStr}} + {{end}} + {{else}} + <!-- If the assigned team is deleted, just displaying "Ghost Team" in the comment --> + {{$teamName := "Ghost Team"}} + {{if .AssigneeTeam}} + {{$teamName = .AssigneeTeam.Name}} + {{end}} + {{if .RemovedAssignee}} + {{ctx.Locale.Tr "repo.issues.review.remove_review_request" $teamName $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.add_review_request" $teamName $createdStr}} + {{end}} + {{end}} + </span> + </div> + {{else if and (eq .Type 29) (or (gt .CommitsNum 0) .IsForcePush)}} + <!-- If PR is closed, the comments whose type is CommentTypePullRequestPush(29) after latestCloseCommentID won't be rendered. //--> + {{if and .Issue.IsClosed (gt .ID $.LatestCloseCommentID)}} + {{continue}} + {{end}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-repo-push"}}</span> + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if .IsForcePush}} + {{ctx.Locale.Tr "repo.issues.force_push_codes" $.Issue.PullRequest.HeadBranch (ShortSha .OldCommit) ($.Issue.Repo.CommitLink .OldCommit) (ShortSha .NewCommit) ($.Issue.Repo.CommitLink .NewCommit) $createdStr}} + {{else}} + {{ctx.Locale.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr}} + {{end}} + </span> + {{if and .IsForcePush $.Issue.PullRequest.BaseRepo.Name}} + <span class="tw-float-right comparebox"> + <a href="{{$.Issue.PullRequest.BaseRepo.Link}}/compare/{{PathEscape .OldCommit}}..{{PathEscape .NewCommit}}" rel="nofollow" class="ui compare label">{{ctx.Locale.Tr "repo.issues.force_push_compare"}}</a> + </span> + {{end}} + </div> + {{if not .IsForcePush}} + {{template "repo/commits_list_small" dict "comment" . "root" $}} + {{end}} + {{else if eq .Type 30}} + {{if not $.UnitProjectsGlobalDisabled}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-project"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{$oldProjectDisplayHtml := "Unknown Project"}} + {{if .OldProject}} + {{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}} + {{if not .OldProject.IsGhost}} + {{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type)}} + {{end}} + {{$oldProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .OldProject.Title}} + {{end}} + {{$newProjectDisplayHtml := "Unknown Project"}} + {{if .Project}} + {{$tooltip := ctx.Locale.Tr "projects.deleted.display_name"}} + {{if not .Project.IsGhost}} + {{$tooltip = ctx.Locale.Tr (printf "projects.type-%d.display_name" .Project.Type)}} + {{end}} + {{$newProjectDisplayHtml = HTMLFormat `<span data-tooltip-content="%s">%s</span>` $tooltip .Project.Title}} + {{end}} + {{if and (gt .OldProjectID 0) (gt .ProjectID 0)}} + {{ctx.Locale.Tr "repo.issues.change_project_at" $oldProjectDisplayHtml $newProjectDisplayHtml $createdStr}} + {{else if gt .OldProjectID 0}} + {{ctx.Locale.Tr "repo.issues.remove_project_at" $oldProjectDisplayHtml $createdStr}} + {{else if gt .ProjectID 0}} + {{ctx.Locale.Tr "repo.issues.add_project_at" $newProjectDisplayHtml $createdStr}} + {{end}} + </span> + </div> + {{end}} + {{else if eq .Type 32}} + <div class="timeline-item-group"> + <div class="timeline-item event" id="{{.HashTag}}"> + <a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}> + <img src="{{.Poster.AvatarLink $.Context}}" width="40" height="40"> + </a> + <span class="badge grey">{{svg "octicon-x" 16}}</span> + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{$reviewerName := ""}} + {{if eq .Review.OriginalAuthor ""}} + {{$reviewerName = .Review.Reviewer.Name}} + {{else}} + {{$reviewerName = .Review.OriginalAuthor}} + {{end}} + <span class="dismissed-message">{{ctx.Locale.Tr "repo.issues.review.dismissed" $reviewerName $createdStr}}</span> + </span> + </div> + {{if .Content}} + <div class="timeline-item comment"> + <div class="content"> + <div class="ui top attached header comment-header-left tw-flex tw-items-center arrow-top"> + {{if gt .Poster.ID 0}} + <a class="inline-timeline-avatar" href="{{.Poster.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .Poster 24}} + </a> + {{end}} + <span class="text grey muted-links"> + {{ctx.Locale.Tr "action.review_dismissed_reason"}} + </span> + </div> + <div class="ui attached segment"> + <div class="render-content markup"> + {{if .RenderedContent}} + {{.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + </div> + </div> + </div> + {{end}} + </div> + {{else if eq .Type 33}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-git-branch"}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if and .OldRef .NewRef}} + {{ctx.Locale.Tr "repo.issues.change_ref_at" .OldRef .NewRef $createdStr}} + {{else if .OldRef}} + {{ctx.Locale.Tr "repo.issues.remove_ref_at" .OldRef $createdStr}} + {{else}} + {{ctx.Locale.Tr "repo.issues.add_ref_at" .NewRef $createdStr}} + {{end}} + </span> + </div> + {{else if or (eq .Type 34) (eq .Type 35)}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-git-merge" 16}}</span> + <span class="text grey muted-links"> + {{template "repo/issue/view_content/comments_authorlink" dict "ctxData" $ "comment" .}} + {{if eq .Type 34}}{{ctx.Locale.Tr "repo.pulls.auto_merge_newly_scheduled_comment" $createdStr}} + {{else}}{{ctx.Locale.Tr "repo.pulls.auto_merge_canceled_schedule_comment" $createdStr}}{{end}} + </span> + </div> + {{else if or (eq .Type 36) (eq .Type 37)}} + <div class="timeline-item event" id="{{.HashTag}}"> + <span class="badge">{{svg "octicon-pin" 16}}</span> + {{template "shared/user/avatarlink" dict "user" .Poster}} + <span class="text grey muted-links"> + {{template "shared/user/authorlink" .Poster}} + {{if eq .Type 36}}{{ctx.Locale.Tr "repo.issues.pin_comment" $createdStr}} + {{else}}{{ctx.Locale.Tr "repo.issues.unpin_comment" $createdStr}}{{end}} + </span> + </div> + {{end}} + {{end}} +{{end}} diff --git a/templates/repo/issue/view_content/comments_authorlink.tmpl b/templates/repo/issue/view_content/comments_authorlink.tmpl new file mode 100644 index 0000000..f652a0b --- /dev/null +++ b/templates/repo/issue/view_content/comments_authorlink.tmpl @@ -0,0 +1,11 @@ +{{if .comment.OriginalAuthor}} + <span class="text black"> + {{svg (MigrationIcon .ctxData.Repository.GetOriginalURLHostname)}} + {{.comment.OriginalAuthor}} + </span> + {{if .ctxData.Repository.OriginalURL}} + <span class="migrate">({{ctx.Locale.Tr "repo.migrated_from" .ctxData.Repository.OriginalURL .ctxData.Repository.GetOriginalURLHostname}})</span> + {{end}} +{{else}} + {{template "shared/user/authorlink" .comment.Poster}} +{{end}} diff --git a/templates/repo/issue/view_content/comments_delete_time.tmpl b/templates/repo/issue/view_content/comments_delete_time.tmpl new file mode 100644 index 0000000..2377e7c --- /dev/null +++ b/templates/repo/issue/view_content/comments_delete_time.tmpl @@ -0,0 +1,18 @@ +{{if and .comment.Time (.ctxData.Repository.IsTimetrackerEnabled ctx)}} {{/* compatibility with time comments made before v1.14 */}} + {{if (not .comment.Time.Deleted)}} + {{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}} + <span class="tw-float-right"> + <div class="ui mini modal issue-delete-time-modal" data-id="{{.comment.Time.ID}}"> + <form method="post" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete"> + {{.ctxData.CsrfTokenHtml}} + </form> + <div class="header">{{ctx.Locale.Tr "repo.issues.del_time"}}</div> + {{template "base/modal_actions_confirm"}} + </div> + <button class="ui icon button compact mini issue-delete-time" data-id="{{.comment.Time.ID}}" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.del_time"}}"> + {{svg "octicon-trash"}} + </button> + </span> + {{end}} + {{end}} +{{end}} diff --git a/templates/repo/issue/view_content/context_menu.tmpl b/templates/repo/issue/view_content/context_menu.tmpl new file mode 100644 index 0000000..4afd73c --- /dev/null +++ b/templates/repo/issue/view_content/context_menu.tmpl @@ -0,0 +1,27 @@ +<div class="item action ui dropdown jump pointing top right context-dropdown"> + <a class="context-menu muted"> + {{svg "octicon-kebab-horizontal"}} + </a> + <div class="menu"> + {{$referenceUrl := ""}} + {{if .issue}} + {{$referenceUrl = printf "%s#%s" .ctxData.Issue.Link .item.HashTag}} + {{else}} + {{$referenceUrl = printf "%s/files#%s" .ctxData.Issue.Link .item.HashTag}} + {{end}} + <div class="item context js-aria-clickable" data-clipboard-text-type="url" data-clipboard-text="{{$referenceUrl}}">{{ctx.Locale.Tr "repo.issues.context.copy_link"}}</div> + {{if and .ctxData.IsSigned (not .ctxData.Repository.IsArchived)}} + <div class="item context js-aria-clickable quote-reply {{if .diff}}quote-reply-diff{{end}}" data-target="{{.item.HashTag}}-raw">{{ctx.Locale.Tr "repo.issues.context.quote_reply"}}</div> + {{if not .ctxData.UnitIssuesGlobalDisabled}} + <div class="item context js-aria-clickable reference-issue" data-target="{{.item.HashTag}}-raw" data-modal="#reference-issue-modal" data-poster="{{.item.Poster.GetDisplayName}}" data-poster-username="{{.item.Poster.Name}}" data-reference="{{$referenceUrl}}">{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}</div> + {{end}} + {{if or .ctxData.Permission.IsAdmin .IsCommentPoster .ctxData.HasIssuesOrPullsWritePermission}} + <div class="divider"></div> + <div class="item context js-aria-clickable edit-content">{{ctx.Locale.Tr "repo.issues.context.edit"}}</div> + {{if .delete}} + <div class="item context js-aria-clickable delete-comment" data-comment-id={{.item.HashTag}} data-url="{{.ctxData.RepoLink}}/comments/{{.item.ID}}/delete" data-locale="{{ctx.Locale.Tr "repo.issues.delete_comment_confirm"}}">{{ctx.Locale.Tr "repo.issues.context.delete"}}</div> + {{end}} + {{end}} + {{end}} + </div> +</div> diff --git a/templates/repo/issue/view_content/conversation.tmpl b/templates/repo/issue/view_content/conversation.tmpl new file mode 100644 index 0000000..c788a61 --- /dev/null +++ b/templates/repo/issue/view_content/conversation.tmpl @@ -0,0 +1,137 @@ +{{$invalid := (index .comments 0).Invalidated}} +{{$resolved := (index .comments 0).IsResolved}} +{{$resolveDoer := (index .comments 0).ResolveDoer}} +{{$isNotPending := (not (eq (index .comments 0).Review.Type 0))}} +<div class="ui segments conversation-holder"> + <div class="ui segment collapsible-comment-box tw-py-2 tw-flex tw-items-center tw-justify-between"> + <div class="tw-flex tw-items-center"> + <a href="{{(index .comments 0).CodeCommentLink ctx}}" class="file-comment tw-ml-2 tw-break-anywhere">{{(index .comments 0).TreePath}}</a> + {{if $invalid}} + <span class="ui label basic small tw-ml-2" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.review.outdated_description"}}"> + {{ctx.Locale.Tr "repo.issues.review.outdated"}} + </span> + {{end}} + </div> + <div> + {{if or $invalid $resolved}} + <button id="show-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="{{if not $resolved}}tw-hidden {{end}}ui compact labeled button show-outdated tw-flex tw-items-center"> + {{svg "octicon-unfold" 16 "tw-mr-2"}} + {{if $resolved}} + {{ctx.Locale.Tr "repo.issues.review.show_resolved"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.show_outdated"}} + {{end}} + </button> + <button id="hide-outdated-{{(index .comments 0).ID}}" data-comment="{{(index .comments 0).ID}}" class="{{if $resolved}}tw-hidden {{end}}ui compact labeled button hide-outdated tw-flex tw-items-center"> + {{svg "octicon-fold" 16 "tw-mr-2"}} + {{if $resolved}} + {{ctx.Locale.Tr "repo.issues.review.hide_resolved"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.hide_outdated"}} + {{end}} + </button> + {{end}} + </div> + </div> + {{$diff := (CommentMustAsDiff ctx (index .comments 0))}} + {{if $diff}} + {{$file := (index $diff.Files 0)}} + <div id="code-preview-{{(index .comments 0).ID}}" class="ui table segment{{if $resolved}} tw-hidden{{end}}"> + <div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}"> + <div class="file-body file-code code-view code-diff code-diff-unified unicode-escaped"> + <table> + <tbody> + {{template "repo/diff/section_unified" dict "file" $file "root" $}} + </tbody> + </table> + </div> + </div> + </div> + {{end}} + <div id="code-comments-{{(index .comments 0).ID}}" class="comment-code-cloud ui segment{{if $resolved}} tw-hidden{{end}}"> + <div class="ui comments tw-mb-0"> + {{range .comments}} + {{$createdSubStr:= TimeSinceUnix .CreatedUnix ctx.Locale}} + <div class="comment code-comment tw-pb-4" id="{{.HashTag}}"> + <div class="content"> + <div class="header comment-header"> + <div class="comment-header-left tw-flex tw-items-center"> + {{if not .OriginalAuthor}} + <a class="avatar"> + {{ctx.AvatarUtils.Avatar .Poster 20}} + </a> + {{end}} + <span class="text grey muted-links"> + {{if .OriginalAuthor}} + <span class="text black"> + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname)}} + {{.OriginalAuthor}} + </span> + {{if $.Repository.OriginalURL}} + <span class="migrate">({{ctx.Locale.Tr "repo.migrated_from" $.Repository.OriginalURL $.Repository.GetOriginalURLHostname}})</span> + {{end}} + {{else}} + {{template "shared/user/authorlink" .Poster}} + {{end}} + {{ctx.Locale.Tr "repo.issues.commented_at" .HashTag $createdSubStr}} + </span> + </div> + <div class="comment-header-right actions tw-flex tw-items-center"> + {{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole "IsPull" $.Issue.IsPull}} + {{if not $.Repository.IsArchived}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}} + {{template "repo/issue/view_content/context_menu" dict "ctxData" $ "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}} + {{end}} + </div> + </div> + <div class="text comment-content"> + <div class="render-content markup" {{if or $.Permission.IsAdmin $.HasIssuesOrPullsWritePermission (and $.IsSigned (eq $.SignedUserID .PosterID))}}data-can-edit="true"{{end}}> + {{if .RenderedContent}} + {{.RenderedContent}} + {{else}} + <span class="no-content">{{ctx.Locale.Tr "repo.issues.no_content"}}</span> + {{end}} + </div> + <div id="issuecomment-{{.ID}}-raw" class="raw-content tw-hidden">{{.Content}}</div> + <div class="edit-content-zone tw-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-content-version="{{.ContentVersion}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + {{if .Attachments}} + {{template "repo/issue/view_content/attachments" dict "Attachments" .Attachments "RenderedContent" .RenderedContent}} + {{end}} + </div> + {{$reactions := .Reactions.GroupByType}} + {{if $reactions}} + {{template "repo/issue/view_content/reactions" dict "ctxData" $ "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions}} + {{end}} + </div> + </div> + {{end}} + </div> + <div class="code-comment-buttons tw-flex tw-items-center tw-flex-wrap tw-mt-2 tw-mb-1 tw-mx-2"> + <div class="tw-flex-1"> + {{if $resolved}} + <div class="ui grey text"> + {{svg "octicon-check" 16 "tw-mr-1"}} + <b>{{$resolveDoer.Name}}</b> {{ctx.Locale.Tr "repo.issues.review.resolved_by"}} + </div> + {{end}} + </div> + <div class="code-comment-buttons-buttons button-row"> + {{if and $.CanMarkConversation $isNotPending}} + <button class="ui tiny basic button resolve-conversation" data-origin="timeline" data-action="{{if not $resolved}}Resolve{{else}}UnResolve{{end}}" data-comment-id="{{(index .comments 0).ID}}" data-update-url="{{$.RepoLink}}/issues/resolve_conversation"> + {{if $resolved}} + {{ctx.Locale.Tr "repo.issues.review.un_resolve_conversation"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.review.resolve_conversation"}} + {{end}} + </button> + {{end}} + {{if and $.SignedUserID (not $.Repository.IsArchived)}} + <button class="comment-form-reply ui primary tiny labeled icon button"> + {{svg "octicon-reply" 16 "reply icon tw-mr-1"}}{{ctx.Locale.Tr "repo.diff.comment.reply"}} + </button> + {{end}} + </div> + </div> + {{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" (index .comments 0).ReviewID "root" $ "comment" (index .comments 0)}} + </div> +</div> diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl new file mode 100644 index 0000000..bbbb8bf --- /dev/null +++ b/templates/repo/issue/view_content/pull.tmpl @@ -0,0 +1,396 @@ +{{if and .Issue.PullRequest.HasMerged (not .IsPullBranchDeletable)}} +{{/* Then the merge box will not be displayed because this page already contains enough information */}} +{{else}} +<div class="timeline-item comment merge box"> + <div class="timeline-avatar text {{if .Issue.PullRequest.HasMerged}}purple + {{- else if .Issue.IsClosed}}grey + {{- else if .IsPullWorkInProgress}}grey + {{- else if .IsFilesConflicted}}grey + {{- else if .IsPullRequestBroken}}red + {{- else if .IsBlockedByApprovals}}red + {{- else if .IsBlockedByRejection}}red + {{- else if .IsBlockedByOfficialReviewRequests}}red + {{- else if .IsBlockedByOutdatedBranch}}red + {{- else if .IsBlockedByChangedProtectedFiles}}red + {{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red + {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow + {{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red + {{- else if .Issue.PullRequest.IsChecking}}yellow + {{- else if .Issue.PullRequest.IsEmpty}}grey + {{- else if .Issue.PullRequest.CanAutoMerge}}green + {{- else}}red{{end}}">{{svg "octicon-git-merge" 40}}</div> + <div class="content"> + {{if .LatestCommitStatus}} + <div class="ui attached segment fitted"> + {{template "repo/pulls/status" (dict + "CommitStatus" .LatestCommitStatus + "CommitStatuses" .LatestCommitStatuses + "MissingRequiredChecks" .MissingRequiredChecks + "ShowHideChecks" true + "is_context_required" .is_context_required + )}} + </div> + {{end}} + {{$showGeneralMergeForm := false}} + <div class="ui attached segment merge-section {{if not $.LatestCommitStatus}}no-header{{end}} flex-items-block"> + {{if .Issue.PullRequest.HasMerged}} + {{if .IsPullBranchDeletable}} + <div class="item item-section text tw-flex-1"> + <div class="item-section-left"> + <h3 class="tw-mb-2"> + {{ctx.Locale.Tr "repo.pulls.merged_success"}} + </h3> + <div class="merge-section-info"> + {{ctx.Locale.Tr "repo.pulls.merged_info_text" (HTMLFormat "<code>%s</code>" .HeadTarget)}} + </div> + </div> + <div class="item-section-right"> + <button class="delete-button ui button" data-url="{{.DeleteBranchLink}}">{{ctx.Locale.Tr "repo.branch.delete_html"}}</button> + </div> + </div> + {{end}} + {{else if .Issue.IsClosed}} + <div class="item item-section text tw-flex-1"> + <div class="item-section-left"> + <h3 class="tw-mb-2">{{ctx.Locale.Tr "repo.pulls.closed"}}</h3> + <div class="merge-section-info"> + {{if .IsPullRequestBroken}} + {{ctx.Locale.Tr "repo.pulls.cant_reopen_deleted_branch"}} + {{else}} + {{ctx.Locale.Tr "repo.pulls.reopen_to_merge"}} + {{end}} + </div> + </div> + {{if and .IsPullBranchDeletable (not .IsPullRequestBroken)}} + <div class="item-section-right"> + <button class="delete-button ui button" data-url="{{.DeleteBranchLink}}">{{ctx.Locale.Tr "repo.branch.delete_html"}}</button> + </div> + {{end}} + </div> + {{else if .IsPullFilesConflicted}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.files_conflicted"}} + </div> + <ul> + {{range .ConflictedFiles}} + <li>{{.}}</li> + {{end}} + </ul> + {{else if .IsPullRequestBroken}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.data_broken"}} + </div> + {{else if .IsPullWorkInProgress}} + <div class="item toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefixes="{{JsonUtils.EncodeToString .PullRequestWorkInProgressPrefixes}}" data-update-url="{{.Issue.Link}}/title"> + <div class="item-section-left flex-text-inline tw-flex-1"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.cannot_merge_work_in_progress"}} + </div> + {{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}} + <button class="ui compact button"> + {{ctx.Locale.Tr "repo.pulls.remove_prefix" .WorkInProgressPrefix}} + </button> + {{end}} + </div> + {{template "repo/issue/view_content/update_branch_by_merge" $}} + {{else if .Issue.PullRequest.IsChecking}} + <div class="item"> + {{svg "octicon-sync"}} + {{ctx.Locale.Tr "repo.pulls.is_checking"}} + </div> + {{else if .Issue.PullRequest.IsAncestor}} + <div class="item"> + {{svg "octicon-alert"}} + {{ctx.Locale.Tr "repo.pulls.is_ancestor"}} + </div> + {{else if or .Issue.PullRequest.CanAutoMerge .Issue.PullRequest.IsEmpty}} + {{if .IsBlockedByApprovals}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}} + </div> + {{else if .IsBlockedByRejection}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}} + </div> + {{else if .IsBlockedByOfficialReviewRequests}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}} + </div> + {{else if .IsBlockedByOutdatedBranch}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}} + </div> + {{else if .IsBlockedByChangedProtectedFiles}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n"}} + </div> + <ul> + {{range .ChangedProtectedFiles}} + <li>{{.}}</li> + {{end}} + </ul> + {{else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsError .RequiredStatusCheckState.IsFailure)}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}} + </div> + {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.required_status_check_missing"}} + </div> + {{else if and .AllowMerge .RequireSigned (not .WillSign)}} + <div class="item"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}} + </div> + <div class="item"> + {{svg "octicon-unlock"}} + {{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}} + </div> + {{end}} + + {{$notAllOverridableChecksOk := or .IsBlockedByApprovals .IsBlockedByRejection .IsBlockedByOfficialReviewRequests .IsBlockedByOutdatedBranch .IsBlockedByChangedProtectedFiles (and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess))}} + + {{/* admin can merge without checks, writer can merge when checks succeed */}} + {{$canMergeNow := and (or (and $.IsRepoAdmin (not .ProtectedBranch.ApplyToAdmins)) (not $notAllOverridableChecksOk)) (or (not .AllowMerge) (not .RequireSigned) .WillSign)}} + {{/* admin and writer both can make an auto merge schedule */}} + + {{if $canMergeNow}} + {{if $notAllOverridableChecksOk}} + <div class="item"> + {{svg "octicon-dot-fill"}} + {{ctx.Locale.Tr "repo.pulls.required_status_check_administrator"}} + </div> + {{else}} + <div class="item"> + {{svg "octicon-check"}} + {{ctx.Locale.Tr "repo.pulls.can_auto_merge_desc"}} + </div> + {{end}} + {{if .WillSign}} + <div class="item"> + {{svg "octicon-lock" 16 "text green"}} + {{ctx.Locale.Tr "repo.signing.will_sign" .SigningKey}} + </div> + {{else if .IsSigned}} + <div class="item"> + {{svg "octicon-unlock"}} + {{ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason)}} + </div> + {{end}} + {{end}} + {{template "repo/issue/view_content/update_branch_by_merge" $}} + {{if .Issue.PullRequest.IsEmpty}} + <div class="divider"></div> + + <div class="item"> + {{svg "octicon-alert"}} + {{ctx.Locale.Tr "repo.pulls.is_empty"}} + </div> + {{end}} + + {{if .AllowMerge}} {{/* user is allowed to merge */}} + {{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}} + {{if or $prUnit.PullRequestsConfig.AllowMerge $prUnit.PullRequestsConfig.AllowRebase $prUnit.PullRequestsConfig.AllowRebaseMerge $prUnit.PullRequestsConfig.AllowSquash $prUnit.PullRequestsConfig.AllowFastForwardOnly}} + {{$hasPendingPullRequestMergeTip := ""}} + {{if .HasPendingPullRequestMerge}} + {{$createdPRMergeStr := TimeSinceUnix .PendingPullRequestMerge.CreatedUnix ctx.Locale}} + {{$hasPendingPullRequestMergeTip = ctx.Locale.Tr "repo.pulls.auto_merge_has_pending_schedule" .PendingPullRequestMerge.Doer.Name $createdPRMergeStr}} + {{end}} + <div class="divider"></div> + <script type="module"> + const defaultMergeTitle = {{.DefaultMergeMessage}}; + const defaultSquashMergeTitle = {{.DefaultSquashMergeMessage}}; + const defaultMergeMessage = {{.DefaultMergeBody}}; + const defaultSquashMergeMessage = {{.DefaultSquashMergeBody}}; + const mergeForm = { + 'baseLink': {{.Link}}, + 'textCancel': {{ctx.Locale.Tr "cancel"}}, + 'textDeleteBranch': {{ctx.Locale.TrString "repo.branch.delete" .HeadTarget}}, + 'textAutoMergeButtonWhenSucceed': {{ctx.Locale.Tr "repo.pulls.auto_merge_button_when_succeed"}}, + 'textAutoMergeWhenSucceed': {{ctx.Locale.Tr "repo.pulls.auto_merge_when_succeed"}}, + 'textAutoMergeCancelSchedule': {{ctx.Locale.Tr "repo.pulls.auto_merge_cancel_schedule"}}, + 'textClearMergeMessage': {{ctx.Locale.Tr "repo.pulls.clear_merge_message"}}, + 'textClearMergeMessageHint': {{ctx.Locale.Tr "repo.pulls.clear_merge_message_hint"}}, + 'textMergeCommitId': {{ctx.Locale.Tr "repo.pulls.merge_commit_id"}}, + + 'canMergeNow': {{$canMergeNow}}, + 'allOverridableChecksOk': {{not $notAllOverridableChecksOk}}, + 'emptyCommit': {{.Issue.PullRequest.IsEmpty}}, + 'pullHeadCommitID': {{.PullHeadCommitID}}, + 'isPullBranchDeletable': {{.IsPullBranchDeletable}}, + 'defaultMergeStyle': {{.MergeStyle}}, + 'defaultDeleteBranchAfterMerge': {{$prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge}}, + 'mergeMessageFieldPlaceHolder': {{ctx.Locale.Tr "repo.editor.commit_message_desc"}}, + 'defaultMergeMessage': defaultMergeMessage, + + 'hasPendingPullRequestMerge': {{.HasPendingPullRequestMerge}}, + 'hasPendingPullRequestMergeTip': {{$hasPendingPullRequestMergeTip}}, + }; + + const generalHideAutoMerge = mergeForm.canMergeNow && mergeForm.allOverridableChecksOk; // if this pr can be merged now, then hide the auto merge + mergeForm['mergeStyles'] = [ + { + 'name': 'merge', + 'allowed': {{$prUnit.PullRequestsConfig.AllowMerge}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.merge_pull_request"}}, + 'mergeTitleFieldText': defaultMergeTitle, + 'mergeMessageFieldText': defaultMergeMessage, + 'hideAutoMerge': generalHideAutoMerge, + }, + { + 'name': 'rebase', + 'allowed': {{$prUnit.PullRequestsConfig.AllowRebase}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.rebase_merge_pull_request"}}, + 'hideMergeMessageTexts': true, + 'hideAutoMerge': generalHideAutoMerge, + }, + { + 'name': 'rebase-merge', + 'allowed': {{$prUnit.PullRequestsConfig.AllowRebaseMerge}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}}, + 'mergeTitleFieldText': defaultMergeTitle, + 'mergeMessageFieldText': defaultMergeMessage, + 'hideAutoMerge': generalHideAutoMerge, + }, + { + 'name': 'squash', + 'allowed': {{$prUnit.PullRequestsConfig.AllowSquash}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.squash_merge_pull_request"}}, + 'mergeTitleFieldText': defaultSquashMergeTitle, + 'mergeMessageFieldText': {{.GetCommitMessages}} + defaultSquashMergeMessage, + 'hideAutoMerge': generalHideAutoMerge, + }, + { + 'name': 'fast-forward-only', + 'allowed': {{and $prUnit.PullRequestsConfig.AllowFastForwardOnly (eq .Issue.PullRequest.CommitsBehind 0)}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.fast_forward_only_merge_pull_request"}}, + 'hideMergeMessageTexts': true, + 'hideAutoMerge': generalHideAutoMerge, + }, + { + 'name': 'manually-merged', + 'allowed': {{$prUnit.PullRequestsConfig.AllowManualMerge}}, + 'textDoMerge': {{ctx.Locale.Tr "repo.pulls.merge_manually"}}, + 'hideMergeMessageTexts': true, + 'hideAutoMerge': true, + } + ]; + window.config.pageData.pullRequestMergeForm = mergeForm; + </script> + + {{$showGeneralMergeForm = true}} + <div id="pull-request-merge-form"></div> + {{else}} + {{/* no merge style was set in repo setting: not or ($prUnit.PullRequestsConfig.AllowMerge ...) */}} + <div class="divider"></div> + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.no_merge_desc"}} + </div> + <div class="item"> + {{svg "octicon-info"}} + {{ctx.Locale.Tr "repo.pulls.no_merge_helper"}} + </div> + {{end}} {{/* end if the repo was set to use any merge style */}} + {{else}} + {{/* user is not allowed to merge */}} + <div class="divider"></div> + <div class="item"> + {{svg "octicon-info"}} + {{ctx.Locale.Tr "repo.pulls.no_merge_access"}} + </div> + {{end}} {{/* end if user is allowed to merge or not */}} + {{else}} + {{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}} + {{if .IsBlockedByApprovals}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_approvals" .GrantedApprovals .ProtectedBranch.RequiredApprovals}} + </div> + {{else if .IsBlockedByRejection}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_rejection"}} + </div> + {{else if .IsBlockedByOfficialReviewRequests}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_official_review_requests"}} + </div> + {{else if .IsBlockedByOutdatedBranch}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.blocked_by_outdated_branch"}} + </div> + {{else if .IsBlockedByChangedProtectedFiles}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.TrN $.ChangedProtectedFilesNum "repo.pulls.blocked_by_changed_protected_files_1" "repo.pulls.blocked_by_changed_protected_files_n"}} + </div> + <ul> + {{range .ChangedProtectedFiles}} + <li>{{.}}</li> + {{end}} + </ul> + {{else if and .EnableStatusCheck (not .RequiredStatusCheckState.IsSuccess)}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.required_status_check_failed"}} + </div> + {{else if and .RequireSigned (not .WillSign)}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.require_signed_wont_sign"}} + </div> + {{else}} + <div class="item text red"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_desc"}} + </div> + <div class="item"> + {{svg "octicon-info"}} + {{ctx.Locale.Tr "repo.pulls.cannot_auto_merge_helper"}} + </div> + {{end}} + {{end}}{{/* end if: pull request status */}} + + {{/* + Manually Merged is not a well-known feature, it is used to mark a non-mergeable PR (already merged, conflicted) as merged + To test it: + * Enable "Manually Merged" feature in the Repository Settings + * Create a pull request, either: + * - Merge the pull request branch locally and push the merged commit to Gitea + * - Make some conflicts between the base branch and the pull request branch + * Then the Manually Merged form will be shown in the merge form + */}} + {{if and $.StillCanManualMerge (not $showGeneralMergeForm)}} + <div class="divider"></div> + <div class="ui form"> + <form action="{{.Link}}/merge" method="post" class="form-fetch-action"> + {{.CsrfTokenHtml}} + <div class="field"> + <input type="text" name="merge_commit_id" placeholder="{{ctx.Locale.Tr "repo.pulls.merge_commit_id"}}"> + </div> + <button class="ui red button" type="submit" name="do" value="manually-merged"> + {{ctx.Locale.Tr "repo.pulls.merge_manually"}} + </button> + </form> + </div> + {{end}} + + {{if and .Issue.PullRequest.HeadRepo (not .Issue.PullRequest.HasMerged) (not .Issue.IsClosed)}} + {{template "repo/issue/view_content/pull_merge_instruction" dict "PullRequest" .Issue.PullRequest "ShowMergeInstructions" .ShowMergeInstructions "AutodetectManualMerge" .AutodetectManualMerge}} + {{end}} + </div> + </div> +</div> +{{end}} diff --git a/templates/repo/issue/view_content/pull_merge_instruction.tmpl b/templates/repo/issue/view_content/pull_merge_instruction.tmpl new file mode 100644 index 0000000..b7aae53 --- /dev/null +++ b/templates/repo/issue/view_content/pull_merge_instruction.tmpl @@ -0,0 +1,57 @@ +<div class="divider"></div> +<details class="collapsible"> + <summary class="tw-py-2"> {{ctx.Locale.Tr "repo.pulls.cmd_instruction_hint"}} </summary> + <div><h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_title"}}</h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_checkout_desc"}}</div> + {{$localBranch := .PullRequest.HeadBranch}} + {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}} + {{$localBranch = print .PullRequest.HeadRepo.OwnerName "-" .PullRequest.HeadBranch}} + {{end}} + <div class="ui secondary segment"> + {{if eq .PullRequest.Flow 0}} + <div>git fetch -u {{if ne .PullRequest.HeadRepo.ID .PullRequest.BaseRepo.ID}}<origin-url data-url="{{.PullRequest.HeadRepo.Link}}"></origin-url>{{else}}origin{{end}} {{.PullRequest.HeadBranch}}:{{$localBranch}}</div> + {{else}} + <div>git fetch -u origin +refs/pull/{{.PullRequest.Index}}/head:{{$localBranch}}</div> + {{end}} + <div>git checkout {{$localBranch}}</div> + </div> + {{if .ShowMergeInstructions}} + <div id="merge-instructions"> + <h3>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_title"}}</h3> + {{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_desc"}} + {{if not .AutodetectManualMerge}} + <p>{{ctx.Locale.Tr "repo.pulls.cmd_instruction_merge_warning"}}</p> + {{end}} + </div> + <div class="ui secondary segment"> + <div data-pull-merge-style="merge"> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge --no-ff {{$localBranch}}</div> + </div> + <div class="tw-hidden" data-pull-merge-style="rebase"> + <div>git checkout {{$localBranch}}</div> + <div>git rebase {{.PullRequest.BaseBranch}}</div> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge --ff-only {{$localBranch}}</div> + </div> + <div class="tw-hidden" data-pull-merge-style="rebase-merge"> + <div>git checkout {{$localBranch}}</div> + <div>git rebase {{.PullRequest.BaseBranch}}</div> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge --no-ff {{$localBranch}}</div> + </div> + <div class="tw-hidden" data-pull-merge-style="squash"> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge --squash {{$localBranch}}</div> + </div> + <div class="tw-hidden" data-pull-merge-style="fast-forward-only"> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge --ff-only {{$localBranch}}</div> + </div> + <div class="tw-hidden" data-pull-merge-style="manually-merged"> + <div>git checkout {{.PullRequest.BaseBranch}}</div> + <div>git merge {{$localBranch}}</div> + </div> + <div>git push origin {{.PullRequest.BaseBranch}}</div> + </div> + {{end}} +</details> diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl new file mode 100644 index 0000000..da63196 --- /dev/null +++ b/templates/repo/issue/view_content/reactions.tmpl @@ -0,0 +1,17 @@ +<div class="ui attached segment reactions" data-action-url="{{$.ActionURL}}"> +{{range $key, $value := .Reactions}} + {{$hasReacted := $value.HasUser $.ctxData.SignedUserID}} + <a role="button" class="ui label basic{{if $hasReacted}} primary{{end}}{{if not $.ctxData.IsSigned}} disabled{{end}} comment-reaction-button" + data-tooltip-content + title="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{ctx.Locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" + aria-label="{{$value.GetFirstUsers}}{{if gt ($value.GetMoreUserCount) 0}} {{ctx.Locale.Tr "repo.reactions_more" $value.GetMoreUserCount}}{{end}}" + data-tooltip-placement="bottom-start" + data-reaction-content="{{$key}}" data-has-reacted="{{$hasReacted}}"> + <span class="reaction">{{ReactionToEmoji $key}}</span> + <span class="reaction-count">{{len $value}}</span> + </a> +{{end}} +{{if AllowedReactions}} + {{template "repo/issue/view_content/add_reaction" dict "ctxData" $.ctxData "ActionURL" .ActionURL}} +{{end}} +</div> diff --git a/templates/repo/issue/view_content/reference_issue_dialog.tmpl b/templates/repo/issue/view_content/reference_issue_dialog.tmpl new file mode 100644 index 0000000..c7a471f --- /dev/null +++ b/templates/repo/issue/view_content/reference_issue_dialog.tmpl @@ -0,0 +1,28 @@ +<div class="ui small modal" id="reference-issue-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.context.reference_issue"}} + </div> + <div class="content"> + <form class="ui form form-fetch-action" action="{{.Repository.Link}}/issues/new" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <label><strong>{{ctx.Locale.Tr "repository"}}</strong></label> + <div class="ui search selection dropdown issue_reference_repository_search"> + <div class="default text gt-ellipsis">{{.Repository.FullName}}</div> + <div class="menu"></div> + </div> + </div> + <div class="field"> + <label><strong>{{ctx.Locale.Tr "repo.milestones.title"}}</strong></label> + <input name="title" value="" autofocus required maxlength="255" autocomplete="off"> + </div> + <div class="field"> + <label><strong>{{ctx.Locale.Tr "repo.issues.reference_issue.body"}}</strong></label> + <textarea name="content"></textarea> + </div> + <div class="text right"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.issues.create"}}</button> + </div> + </form> + </div> +</div> diff --git a/templates/repo/issue/view_content/show_role.tmpl b/templates/repo/issue/view_content/show_role.tmpl new file mode 100644 index 0000000..0f1b895 --- /dev/null +++ b/templates/repo/issue/view_content/show_role.tmpl @@ -0,0 +1,15 @@ +{{if and .ShowRole.IsPoster (not .IgnorePoster)}} + <div class="ui basic label role-label" data-tooltip-content=" + {{if .IsPull}} + {{ctx.Locale.Tr "repo.issues.author.tooltip.pr"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.author.tooltip.issue"}} + {{end}}"> + {{ctx.Locale.Tr "repo.issues.author"}} + </div> +{{end}} +{{if .ShowRole.RoleInRepo}} + <div class="ui basic label role-label" data-tooltip-content="{{.ShowRole.RoleInRepo.LocaleHelper ctx.Locale}}"> + {{.ShowRole.RoleInRepo.LocaleString ctx.Locale}} + </div> +{{end}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl new file mode 100644 index 0000000..623023b --- /dev/null +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -0,0 +1,66 @@ +<div class="issue-content-right ui segment"> + {{template "repo/issue/view_content/sidebar/branch_selector_field" .}} + {{if .Issue.IsPull}} + {{template "repo/issue/view_content/sidebar/pull_review" .}} + {{template "repo/issue/view_content/sidebar/pull_wip" .}} + <div class="divider"></div> + {{end}} + + {{template "repo/issue/labels/labels_selector_field" .}} + {{template "repo/issue/labels/labels_sidebar" dict "root" $}} + + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/milestones" .}} + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/projects" .}} + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/assignees" dict "isExistingIssue" true "." .}} + <div class="divider"></div> + + {{if .Participants}} + {{template "repo/issue/view_content/sidebar/participants" .}} + {{end}} + + {{if and $.IssueWatch (not .Repository.IsArchived)}} + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/watch" .}} + {{end}} + + {{if .Repository.IsTimetrackerEnabled $.Context}} + {{template "repo/issue/view_content/sidebar/timetracking" .}} + {{end}} + + <div class="divider"></div> + {{template "repo/issue/view_content/sidebar/due_deadline" .}} + + {{if .Repository.IsDependenciesEnabled $.Context}} + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/dependencies" .}} + {{end}} + + <div class="divider"></div> + {{template "repo/issue/view_content/sidebar/reference" .}} + + {{if and .IsRepoAdmin (not .Repository.IsArchived)}} + <div class="divider"></div> + + {{template "repo/issue/view_content/sidebar/actions" .}} + {{end}} + + {{if and + .Issue.IsPull + .IsIssuePoster + (not .Issue.IsClosed) + .Issue.PullRequest.HeadRepo + (not (eq .Issue.PullRequest.HeadRepo.FullName .Issue.PullRequest.BaseRepo.FullName)) + .CanWriteToHeadRepo + }} + <div class="divider"></div> + {{template "repo/issue/view_content/sidebar/pull_maintainer_edits" .}} + {{end}} +</div> diff --git a/templates/repo/issue/view_content/sidebar/actions.tmpl b/templates/repo/issue/view_content/sidebar/actions.tmpl new file mode 100644 index 0000000..36f2182 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/actions.tmpl @@ -0,0 +1,114 @@ +{{if or .PinEnabled .Issue.IsPinned}} + <form class="tw-mt-1 form-fetch-action single-button-form" method="post" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{ctx.Locale.Tr "repo.issues.max_pinned"}}"{{end}}> + {{$.CsrfTokenHtml}} + <button class="fluid ui button {{if not $.NewPinAllowed}}disabled{{end}}"> + {{if not .Issue.IsPinned}} + {{svg "octicon-pin" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "pin"}} + {{else}} + {{svg "octicon-pin-slash" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "unpin"}} + {{end}} + </button> + </form> +{{end}} + +<button class="tw-mt-1 fluid ui show-modal button {{if .Issue.IsLocked}} negative {{end}}" data-modal="#lock"> + {{if .Issue.IsLocked}} + {{svg "octicon-key"}} + {{ctx.Locale.Tr "repo.issues.unlock"}} + {{else}} + {{svg "octicon-lock"}} + {{ctx.Locale.Tr "repo.issues.lock"}} + {{end}} +</button> +<div class="ui tiny modal" id="lock"> + <div class="header"> + {{if .Issue.IsLocked}} + {{ctx.Locale.Tr "repo.issues.unlock.title"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.lock.title"}} + {{end}} + </div> + <div class="content"> + <div class="ui warning message"> + {{if .Issue.IsLocked}} + {{ctx.Locale.Tr "repo.issues.unlock.notice_1"}}<br> + {{ctx.Locale.Tr "repo.issues.unlock.notice_2"}}<br> + {{else}} + {{ctx.Locale.Tr "repo.issues.lock.notice_1"}}<br> + {{ctx.Locale.Tr "repo.issues.lock.notice_2"}}<br> + {{ctx.Locale.Tr "repo.issues.lock.notice_3"}}<br> + {{end}} + </div> + + <form class="ui form form-fetch-action" action="{{.Issue.Link}}{{if .Issue.IsLocked}}/unlock{{else}}/lock{{end}}" + method="post"> + {{.CsrfTokenHtml}} + + {{if not .Issue.IsLocked}} + <div class="field"> + <strong> {{ctx.Locale.Tr "repo.issues.lock.reason"}} </strong> + </div> + + <div class="field"> + <div class="ui fluid dropdown selection"> + + <select name="reason"> + <option value=""> </option> + {{range .LockReasons}} + <option value="{{.}}">{{.}}</option> + {{end}} + </select> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + + <div class="default text"> </div> + + <div class="menu"> + {{range .LockReasons}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + </div> + {{end}} + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button"> + {{if .Issue.IsLocked}} + {{ctx.Locale.Tr "repo.issues.unlock_confirm"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.lock_confirm"}} + {{end}} + </button> + </div> + </form> + </div> +</div> +<button class="tw-mt-1 fluid ui show-modal button" data-modal="#sidebar-delete-issue"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.issues.delete"}} +</button> +<div class="ui g-modal-confirm modal" id="sidebar-delete-issue"> + <div class="header"> + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.pulls.delete.title"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.delete.title"}} + {{end}} + </div> + <div class="content"> + <p> + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.pulls.delete.text"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.delete.text"}} + {{end}} + </p> + </div> + <form action="{{.Issue.Link}}/delete" method="post"> + {{.CsrfTokenHtml}} + {{template "base/modal_actions_confirm" .}} + </form> +</div> diff --git a/templates/repo/issue/view_content/sidebar/assignees.tmpl b/templates/repo/issue/view_content/sidebar/assignees.tmpl new file mode 100644 index 0000000..7a928fa --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/assignees.tmpl @@ -0,0 +1,62 @@ +<input id="assignee_ids" name="assignee_ids" type="hidden" value="{{.assignee_ids}}"> +<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-assignees{{if .isExistingIssue}}-modify{{end}} dropdown"> + <a class="text muted flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.assignees"}}</strong> + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </a> + <div class="filter menu" {{if .isExistingIssue}} data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/assignee" {{else}} data-id="#assignee_ids" {{end}}> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_assignees"}}"> + </div> + <div class="no-select item">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div> + {{range .Assignees}} + + {{$AssigneeID := .ID}} + <a class="item{{range $.Issue.Assignees}}{{if eq .ID $AssigneeID}} checked{{end}}{{end}}" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}"> + {{$checked := false}} + {{range $.Issue.Assignees}} + {{if eq .ID $AssigneeID}} + {{$checked = true}} + {{end}} + {{end}} + <span class="octicon-check {{if not $checked}}tw-invisible{{end}}">{{svg "octicon-check"}}</span> + <span class="text"> + {{ctx.AvatarUtils.Avatar . 20 "tw-mr-2"}}{{template "repo/search_name" .}} + </span> + </a> + {{end}} + </div> +</div> +<div class="ui assignees list"> + <span class="no-select item {{if .Issue.Assignees}}tw-hidden{{end}}"> + {{ctx.Locale.Tr "repo.issues.new.no_assignees"}} + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + {{with index .Assignees 0}} + – + <a class="select-assign-me" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}" {{if $.isExistingIssue}} data-action="update" {{end}} data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/assignee" role="option"> + {{ctx.Locale.Tr "repo.issues.new.assign_to_me"}} + </a> + {{end}} + {{end}} + </span> + <div class="selected"> + {{if .isExistingIssue}} + {{range .Issue.Assignees}} + <div class="item"> + <a class="muted sidebar-item-link" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?assignee={{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "tw-mr-2"}}{{.GetDisplayName}} + </a> + </div> + {{end}} + {{else}} + {{range .Assignees}} + <a class="item tw-p-1 muted tw-hidden" id="assignee_{{.ID}}" href="{{$.RepoLink}}/{{if $.Issue.IsPull}}pulls{{else}}issues{{end}}?assignee={{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "tw-mr-2"}}{{.GetDisplayName}} + </a> + {{end}} + {{end}} + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/branch_selector_field.tmpl b/templates/repo/issue/view_content/sidebar/branch_selector_field.tmpl new file mode 100644 index 0000000..c23e13b --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/branch_selector_field.tmpl @@ -0,0 +1,59 @@ +{{if and (not .Issue.IsPull) (not .PageIsComparePull)}} +<input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}"> +<input id="editing_mode" name="edit_mode" type="hidden" value="{{(or .IsIssueWriter .HasIssuesOrPullsWritePermission)}}"> +<form method="post" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form"> + {{$.CsrfTokenHtml}} +</form> +{{/* TODO: share this branch selector dropdown with the same in repo page */}} +<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown tw-max-w-full" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}"> + <div class="ui basic small button"> + <span class="text branch-name gt-ellipsis">{{if .Reference}}{{$.RefEndName}}{{else}}{{ctx.Locale.Tr "repo.issues.no_ref"}}{{end}}</span> + {{if .HasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}} + </div> + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-filter" 16}}</i> + <input name="search" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}..."> + </div> + <div class="header"> + <div class="ui grid"> + <div class="two column row"> + <a class="reference column muted" href="#" data-target="#branch-list"> + <span class="text black"> + {{svg "octicon-git-branch" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.branches"}} + </span> + </a> + <a class="reference column muted" href="#" data-target="#tag-list"> + <span class="text"> + {{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.tags"}} + </span> + </a> + </div> + </div> + </div> + <div class="branch-tag-divider"></div> + <div id="branch-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}}"> + {{if .Reference}} + <div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{ctx.Locale.Tr "repo.clear_ref"}}</a></strong></div> + {{end}} + {{range .Branches}} + <div class="item" data-id="refs/heads/{{.}}" data-name="{{.}}" data-id-selector="#ref_selector" title="{{.}}">{{.}}</div> + {{else}} + <div class="item">{{ctx.Locale.Tr "repo.pulls.no_results"}}</div> + {{end}} + </div> + <div id="tag-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}} tw-hidden"> + {{if .Reference}} + <div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{ctx.Locale.Tr "repo.clear_ref"}}</a></strong></div> + {{end}} + {{range .Tags}} + <div class="item" data-id="refs/tags/{{.}}" data-name="tags/{{.}}" data-id-selector="#ref_selector">{{.}}</div> + {{else}} + <div class="item">{{ctx.Locale.Tr "repo.pulls.no_results"}}</div> + {{end}} + </div> + </div> +</div> + +<div class="divider"></div> +{{end}} diff --git a/templates/repo/issue/view_content/sidebar/dependencies.tmpl b/templates/repo/issue/view_content/sidebar/dependencies.tmpl new file mode 100644 index 0000000..6a9b651 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/dependencies.tmpl @@ -0,0 +1,146 @@ +<div class="ui depending"> + {{if (and (not .BlockedByDependencies) (not .BlockedByDependenciesNotPermitted) (not .BlockingDependencies) (not .BlockingDependenciesNotPermitted))}} + <span class="text"><strong>{{ctx.Locale.Tr "repo.issues.dependency.title"}}</strong></span> + <br> + <p> + {{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.issues.dependency.pr_no_dependencies"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.dependency.issue_no_dependencies"}} + {{end}} + </p> + {{end}} + + {{if or .BlockingDependencies .BlockingDependenciesNotPermitted}} + <span class="text" data-tooltip-content="{{if .Issue.IsPull}}{{ctx.Locale.Tr "repo.issues.dependency.pr_close_blocks"}}{{else}}{{ctx.Locale.Tr "repo.issues.dependency.issue_close_blocks"}}{{end}}"> + <strong>{{ctx.Locale.Tr "repo.issues.dependency.blocks_short"}}</strong> + </span> + <div class="ui relaxed divided list"> + {{range .BlockingDependencies}} + <div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} tw-flex tw-items-center tw-justify-between"> + <div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis"> + <a class="title muted" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{RenderRefIssueTitle $.Context .Issue.Title}}}"> + #{{.Issue.Index}} {{RenderRefIssueTitle $.Context .Issue.Title}}} + </a> + <div class="text small gt-ellipsis" data-tooltip-content="{{.Repository.OwnerName}}/{{.Repository.Name}}"> + {{.Repository.OwnerName}}/{{.Repository.Name}} + </div> + </div> + <div class="item-right tw-flex tw-items-center tw-m-1"> + {{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} + <a class="delete-dependency-button ci muted" data-id="{{.Issue.ID}}" data-type="blocking" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dependency.remove_info"}}"> + {{svg "octicon-trash" 16}} + </a> + {{end}} + </div> + </div> + {{end}} + {{if .BlockingDependenciesNotPermitted}} + <div class="item tw-flex tw-items-center tw-justify-between gt-ellipsis"> + <span>{{ctx.Locale.TrN (len .BlockingDependenciesNotPermitted) "repo.issues.dependency.no_permission_1" "repo.issues.dependency.no_permission_n" (len .BlockingDependenciesNotPermitted)}}</span> + </div> + {{end}} + </div> + {{end}} + + {{if or .BlockedByDependencies .BlockedByDependenciesNotPermitted}} + <span class="text" data-tooltip-content="{{if .Issue.IsPull}}{{ctx.Locale.Tr "repo.issues.dependency.pr_closing_blockedby"}}{{else}}{{ctx.Locale.Tr "repo.issues.dependency.issue_closing_blockedby"}}{{end}}"> + <strong>{{ctx.Locale.Tr "repo.issues.dependency.blocked_by_short"}}</strong> + </span> + <div class="ui relaxed divided list"> + {{range .BlockedByDependencies}} + <div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} tw-flex tw-items-center tw-justify-between"> + <div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis"> + {{$title := RenderRefIssueTitle $.Context .Issue.Title}} + <a class="title muted" href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{RenderRefIssueTitle $.Context .Issue.Title}}"> + #{{.Issue.Index}} {{RenderRefIssueTitle $.Context .Issue.Title}} + </a> + <div class="text small gt-ellipsis" data-tooltip-content="{{.Repository.OwnerName}}/{{.Repository.Name}}"> + {{.Repository.OwnerName}}/{{.Repository.Name}} + </div> + </div> + <div class="item-right tw-flex tw-items-center tw-m-1"> + {{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} + <a class="delete-dependency-button ci muted" data-id="{{.Issue.ID}}" data-type="blockedBy" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dependency.remove_info"}}"> + {{svg "octicon-trash" 16}} + </a> + {{end}} + </div> + </div> + {{end}} + {{if $.CanCreateIssueDependencies}} + {{range .BlockedByDependenciesNotPermitted}} + <div class="item dependency{{if .Issue.IsClosed}} is-closed{{end}} tw-flex tw-items-center tw-justify-between"> + <div class="item-left tw-flex tw-justify-center tw-flex-col tw-flex-1 gt-ellipsis"> + <div class="gt-ellipsis"> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dependency.no_permission.can_remove"}}">{{svg "octicon-lock" 16}}</span> + <span class="title" data-tooltip-content="#{{.Issue.Index}} {{RenderRefIssueTitle $.Context .DependentIssue.Title}}"> + #{{.Issue.Index}} {{RenderRefIssueTitle $.Context .DependentIssue.Title}} + </span> + </div> + <div class="text small gt-ellipsis" data-tooltip-content="{{.Repository.OwnerName}}/{{.Repository.Name}}"> + {{.Repository.OwnerName}}/{{.Repository.Name}} + </div> + </div> + <div class="item-right tw-flex tw-items-center tw-m-1"> + {{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}} + <a class="delete-dependency-button ci muted" data-id="{{.Issue.ID}}" data-type="blocking" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dependency.remove_info"}}"> + {{svg "octicon-trash" 16}} + </a> + {{end}} + </div> + </div> + {{end}} + {{else if .BlockedByDependenciesNotPermitted}} + <div class="item tw-flex tw-items-center tw-justify-between gt-ellipsis"> + <span>{{ctx.Locale.TrN (len .BlockedByDependenciesNotPermitted) "repo.issues.dependency.no_permission_1" "repo.issues.dependency.no_permission_n" (len .BlockedByDependenciesNotPermitted)}}</span> + </div> + {{end}} + </div> + {{end}} + + {{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}} + <div> + <form method="post" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm"> + {{$.CsrfTokenHtml}} + <div class="ui fluid action input"> + <div class="ui search selection dropdown" id="new-dependency-drop-list" data-issue-id="{{.Issue.ID}}"> + <input name="newDependency" type="hidden"> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <input type="text" class="search"> + <div class="default text">{{ctx.Locale.Tr "repo.issues.dependency.add"}}</div> + </div> + <button class="ui icon button"> + {{svg "octicon-plus"}} + </button> + </div> + </form> + </div> + {{end}} +</div> + +{{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}} + <input type="hidden" id="crossRepoSearch" value="{{.AllowCrossRepositoryDependencies}}"> + + <div class="ui g-modal-confirm modal remove-dependency"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.issues.dependency.remove_header"}} + </div> + <div class="content"> + <form method="post" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm"> + {{$.CsrfTokenHtml}} + <input type="hidden" value="" name="removeDependencyID" id="removeDependencyID"> + <input type="hidden" value="" name="dependencyType" id="dependencyType"> + </form> + <p>{{if .Issue.IsPull}} + {{ctx.Locale.Tr "repo.issues.dependency.pr_remove_text"}} + {{else}} + {{ctx.Locale.Tr "repo.issues.dependency.issue_remove_text"}} + {{end}}</p> + </div> + {{$ModalButtonCancelText := ctx.Locale.Tr "repo.issues.dependency.cancel"}} + {{$ModalButtonOkText := ctx.Locale.Tr "repo.issues.dependency.remove"}} + {{template "base/modal_actions_confirm" (dict "." . "ModalButtonCancelText" $ModalButtonCancelText "ModalButtonOkText" $ModalButtonOkText)}} + </div> +{{end}} diff --git a/templates/repo/issue/view_content/sidebar/due_deadline.tmpl b/templates/repo/issue/view_content/sidebar/due_deadline.tmpl new file mode 100644 index 0000000..2de836b --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/due_deadline.tmpl @@ -0,0 +1,41 @@ +<span class="text"><strong>{{ctx.Locale.Tr "repo.issues.due_date"}}</strong></span> +<div class="ui form" id="deadline-loader"> + <div class="ui negative message tw-hidden" id="deadline-err-invalid-date"> + {{svg "octicon-x" 16 "close icon"}} + {{ctx.Locale.Tr "repo.issues.due_date_invalid"}} + </div> + {{if ne .Issue.DeadlineUnix 0}} + <p> + <div class="tw-flex tw-justify-between tw-items-center"> + <div class="due-date {{if .Issue.IsOverdue}}text red{{end}}" {{if .Issue.IsOverdue}}data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date_overdue"}}"{{end}}> + {{svg "octicon-calendar" 16 "tw-mr-2"}} + {{DateTime "long" .Issue.DeadlineUnix.FormatDate}} + </div> + <div> + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + <a class="issue-due-edit muted" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date_form_edit"}}">{{svg "octicon-pencil" 16 "tw-mr-1"}}</a> + <a class="issue-due-remove muted" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.due_date_form_remove"}}">{{svg "octicon-trash"}}</a> + {{end}} + </div> + </div> + </p> + {{else}} + <p>{{ctx.Locale.Tr "repo.issues.due_date_not_set"}}</p> + {{end}} + + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + <div {{if ne .Issue.DeadlineUnix 0}} class="tw-hidden"{{end}} id="deadlineForm"> + <form class="ui fluid action input issue-due-form" action="{{AppSubUrl}}/{{PathEscape .Repository.Owner.Name}}/{{PathEscape .Repository.Name}}/issues/{{.Issue.Index}}/deadline" method="post" id="update-issue-deadline-form"> + {{$.CsrfTokenHtml}} + <input required placeholder="{{ctx.Locale.Tr "repo.issues.due_date_form"}}" {{if gt .Issue.DeadlineUnix 0}}value="{{.Issue.DeadlineUnix.FormatDate}}"{{end}} type="date" name="deadlineDate" id="deadlineDate"> + <button class="ui icon button"> + {{if ne .Issue.DeadlineUnix 0}} + {{svg "octicon-pencil"}} + {{else}} + {{svg "octicon-plus"}} + {{end}} + </button> + </form> + </div> + {{end}} +</div> diff --git a/templates/repo/issue/view_content/sidebar/milestones.tmpl b/templates/repo/issue/view_content/sidebar/milestones.tmpl new file mode 100644 index 0000000..44d9419 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/milestones.tmpl @@ -0,0 +1,24 @@ +<div id="milestone-section" hx-swap="morph" hx-target="this" hx-indicator="this"> + <div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-milestone dropdown"> + <a class="text muted flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.milestone"}}</strong> + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </a> + <div class="menu"> + {{template "repo/issue/milestone/select_menu" .}} + </div> + </div> + <div class="ui select-milestone list"> + <span class="no-select item {{if .Issue.Milestone}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_milestone"}}</span> + <div class="selected"> + {{if .Issue.Milestone}} + <a class="item muted sidebar-item-link" href="{{.RepoLink}}/milestone/{{.Issue.Milestone.ID}}"> + {{svg "octicon-milestone" 18 "tw-mr-2"}} + {{.Issue.Milestone.Name}} + </a> + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/participants.tmpl b/templates/repo/issue/view_content/sidebar/participants.tmpl new file mode 100644 index 0000000..93e2579 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/participants.tmpl @@ -0,0 +1,8 @@ +<span class="text"><strong>{{ctx.Locale.TrN .NumParticipants "repo.issues.num_participants_one" "repo.issues.num_participants_few" .NumParticipants}}</strong></span> +<div class="ui list tw-flex tw-flex-wrap"> + {{range .Participants}} + <a {{if gt .ID 0}}href="{{.HomeLink}}"{{end}} data-tooltip-content="{{.GetDisplayName}}"> + {{ctx.AvatarUtils.Avatar . 28 "tw-my-0.5 tw-mr-1"}} + </a> + {{end}} +</div> diff --git a/templates/repo/issue/view_content/sidebar/projects.tmpl b/templates/repo/issue/view_content/sidebar/projects.tmpl new file mode 100644 index 0000000..91d75f3 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/projects.tmpl @@ -0,0 +1,54 @@ +<div class="ui {{if or (not .HasIssuesOrPullsWritePermission) .Repository.IsArchived}}disabled{{end}} floating jump select-project dropdown"> + <a class="text muted flex-text-block"> + <strong>{{ctx.Locale.Tr "repo.issues.new.projects"}}</strong> + {{if and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </a> + <div class="menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/projects"> + {{if or .OpenProjects .ClosedProjects}} + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_projects"}}"> + </div> + {{end}} + <div class="no-select item">{{ctx.Locale.Tr "repo.issues.new.clear_projects"}}</div> + {{if and (not .OpenProjects) (not .ClosedProjects)}} + <div class="disabled item"> + {{ctx.Locale.Tr "repo.issues.new.no_items"}} + </div> + {{end}} + {{if .OpenProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.open_projects"}} + </div> + {{range .OpenProjects}} + <a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link ctx}}"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </a> + {{end}} + {{end}} + {{if .ClosedProjects}} + <div class="divider"></div> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.new.closed_projects"}} + </div> + {{range .ClosedProjects}} + <a class="item muted sidebar-item-link" data-id="{{.ID}}" data-href="{{.Link ctx}}"> + {{svg .IconName 18 "tw-mr-2"}}{{.Title}} + </a> + {{end}} + {{end}} + </div> +</div> +<div class="ui select-project list"> + <span class="no-select item {{if .Issue.Project}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_projects"}}</span> + <div class="selected"> + {{if .Issue.Project}} + <a class="item muted sidebar-item-link" href="{{.Issue.Project.Link ctx}}"> + {{svg .Issue.Project.IconName 18 "tw-mr-2"}}{{.Issue.Project.Title}} + </a> + {{end}} + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/pull_maintainer_edits.tmpl b/templates/repo/issue/view_content/sidebar/pull_maintainer_edits.tmpl new file mode 100644 index 0000000..6ec5c05 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/pull_maintainer_edits.tmpl @@ -0,0 +1,10 @@ +<div class="inline field"> + <div class="ui checkbox loading-icon-2px" id="allow-edits-from-maintainers" + data-url="{{.Issue.Link}}" + data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers_desc"}}" + data-prompt-error="{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers_err"}}" + > + <label><strong>{{ctx.Locale.Tr "repo.pulls.allow_edits_from_maintainers"}}</strong></label> + <input type="checkbox" {{if .Issue.PullRequest.AllowMaintainerEdit}}checked{{end}}> + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/pull_review.tmpl b/templates/repo/issue/view_content/sidebar/pull_review.tmpl new file mode 100644 index 0000000..930c2a6 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/pull_review.tmpl @@ -0,0 +1,45 @@ +<input id="reviewer_id" name="reviewer_id" type="hidden" value="{{.reviewer_id}}"> +<div class="ui {{if or (and (not .Reviewers) (not .TeamReviewers)) (not .CanChooseReviewer) .Repository.IsArchived}}disabled{{end}} floating jump select-reviewers-modify dropdown"> + <a class="text tw-flex tw-items-center muted"> + <strong>{{ctx.Locale.Tr "repo.issues.review.reviewers"}}</strong> + {{if and .CanChooseReviewer (not .Repository.IsArchived)}} + {{svg "octicon-gear" 16 "tw-ml-1"}} + {{end}} + </a> + <div class="filter menu" data-action="update" data-issue-id="{{$.Issue.ID}}" data-update-url="{{$.RepoLink}}/issues/request_review"> + {{if .Reviewers}} + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search" 16}}</i> + <input type="text" placeholder="{{ctx.Locale.Tr "repo.issues.filter_reviewers"}}"> + </div> + {{end}} + {{if .Reviewers}} + {{range .Reviewers}} + {{if .User}} + <a class="{{if not .CanChange}}ui{{end}} item {{if .Checked}}checked{{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_{{.ItemID}}" {{if not .CanChange}} data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}> + <span class="octicon-check {{if not .Checked}}tw-invisible{{end}}">{{svg "octicon-check"}}</span> + <span class="text"> + {{ctx.AvatarUtils.Avatar .User 28 "tw-mr-2"}}{{template "repo/search_name" .User}} + </span> + </a> + {{end}} + {{end}} + {{end}} + {{if .TeamReviewers}} + {{if .Reviewers}} + <div class="divider"></div> + {{end}} + {{range .TeamReviewers}} + {{if .Team}} + <a class="{{if not .CanChange}}ui{{end}} item {{if .Checked}}checked{{end}} {{if not .CanChange}}ban-change{{end}}" href="#" data-id="{{.ItemID}}" data-id-selector="#review_request_team_{{.Team.ID}}" {{if not .CanChange}} data-tooltip-content="{{ctx.Locale.Tr "repo.issues.remove_request_review_block"}}"{{end}}> + <span class="octicon-check {{if not .Checked}}tw-invisible{{end}}">{{svg "octicon-check" 16}}</span> + <span class="text"> + {{svg "octicon-people" 16 "tw-ml-4 tw-mr-1"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}} + </span> + </a> + {{end}} + {{end}} + {{end}} + </div> +</div> +{{template "repo/issue/view_content/sidebar/pull_reviewers" .}} diff --git a/templates/repo/issue/view_content/sidebar/pull_reviewers.tmpl b/templates/repo/issue/view_content/sidebar/pull_reviewers.tmpl new file mode 100644 index 0000000..102508f --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/pull_reviewers.tmpl @@ -0,0 +1,67 @@ +<div class="ui assignees list"> + <span class="no-select item {{if or .OriginalReviews .PullReviewers}}tw-hidden{{end}}">{{ctx.Locale.Tr "repo.issues.new.no_reviewers"}}</span> + <div class="selected"> + {{range .PullReviewers}} + <div class="item tw-flex tw-items-center tw-py-2"> + <div class="tw-flex tw-items-center tw-flex-1"> + {{if .User}} + <a class="muted sidebar-item-link" href="{{.User.HomeLink}}">{{ctx.AvatarUtils.Avatar .User 20 "tw-mr-2"}}{{.User.GetDisplayName}}</a> + {{else if .Team}} + <span class="text">{{svg "octicon-people" 20 "tw-mr-2"}}{{$.Issue.Repo.OwnerName}}/{{.Team.Name}}</span> + {{end}} + </div> + <div class="tw-flex tw-items-center tw-gap-2"> + {{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed) (not $.Issue.PullRequest.HasMerged))}} + <a href="#" class="ui muted icon tw-flex tw-items-center show-modal" data-tooltip-content="{{ctx.Locale.Tr "repo.issues.dismiss_review"}}" data-modal="#dismiss-review-modal-{{.Review.ID}}"> + {{svg "octicon-x" 20}} + </a> + <div class="ui small modal" id="dismiss-review-modal-{{.Review.ID}}"> + <div class="header"> + {{ctx.Locale.Tr "repo.issues.dismiss_review"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.issues.dismiss_review_warning"}} + </div> + <form class="ui form dismiss-review-form" id="dismiss-review-{{.Review.ID}}" action="{{$.RepoLink}}/issues/dismiss_review" method="post"> + {{$.CsrfTokenHtml}} + <input type="hidden" name="review_id" value="{{.Review.ID}}"> + <div class="field"> + <label for="message">{{ctx.Locale.Tr "action.review_dismissed_reason"}}</label> + <input id="message" name="message"> + </div> + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button" type="submit">{{ctx.Locale.Tr "ok"}}</button> + </div> + </form> + </div> + </div> + {{end}} + {{if .Review.Stale}} + <span data-tooltip-content="{{ctx.Locale.Tr "repo.issues.is_stale"}}"> + {{svg "octicon-hourglass" 16}} + </span> + {{end}} + {{if and .CanChange (or .Checked (and (not $.Issue.IsClosed) (not $.Issue.PullRequest.HasMerged)))}} + <a href="#" class="ui muted icon re-request-review{{if .Checked}} checked{{end}}" data-tooltip-content="{{if .Checked}}{{ctx.Locale.Tr "repo.issues.remove_request_review"}}{{else}}{{ctx.Locale.Tr "repo.issues.re_request_review"}}{{end}}" data-issue-id="{{$.Issue.ID}}" data-id="{{.ItemID}}" data-update-url="{{$.RepoLink}}/issues/request_review">{{if .Checked}}{{svg "octicon-trash"}}{{else}}{{svg "octicon-sync"}}{{end}}</a> + {{end}} + {{svg (printf "octicon-%s" .Review.Type.Icon) 16 (printf "text %s" (.Review.HTMLTypeColorName))}} + </div> + </div> + {{end}} + {{range .OriginalReviews}} + <div class="item tw-flex tw-items-center tw-py-2"> + <div class="tw-flex tw-items-center tw-flex-1"> + <a class="muted" href="{{$.Repository.OriginalURL}}" data-tooltip-content="{{ctx.Locale.Tr "repo.migrated_from_fake" $.Repository.GetOriginalURLHostname}}"> + {{svg (MigrationIcon $.Repository.GetOriginalURLHostname) 20 "tw-mr-2"}} + {{.OriginalAuthor}} + </a> + </div> + <div class="tw-flex tw-items-center tw-gap-2"> + {{svg (printf "octicon-%s" .Type.Icon) 16 (printf "text %s" (.HTMLTypeColorName))}} + </div> + </div> + {{end}} + </div> + </div> diff --git a/templates/repo/issue/view_content/sidebar/pull_wip.tmpl b/templates/repo/issue/view_content/sidebar/pull_wip.tmpl new file mode 100644 index 0000000..f1588b3 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/pull_wip.tmpl @@ -0,0 +1,11 @@ +{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .HasMerged) (not .Issue.IsClosed)}} + <div class="toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefixes="{{JsonUtils.EncodeToString .PullRequestWorkInProgressPrefixes}}" data-update-url="{{.Issue.Link}}/title"> + <a class="muted"> + {{if .IsPullWorkInProgress}} + {{ctx.Locale.Tr "repo.pulls.ready_for_review"}} {{ctx.Locale.Tr "repo.pulls.remove_prefix" (index .PullRequestWorkInProgressPrefixes 0)}} + {{else}} + {{ctx.Locale.Tr "repo.pulls.still_in_progress"}} {{ctx.Locale.Tr "repo.pulls.add_prefix" (index .PullRequestWorkInProgressPrefixes 0)}} + {{end}} + </a> + </div> +{{end}} diff --git a/templates/repo/issue/view_content/sidebar/reference.tmpl b/templates/repo/issue/view_content/sidebar/reference.tmpl new file mode 100644 index 0000000..bbbc099 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/reference.tmpl @@ -0,0 +1,7 @@ +<div class="ui equal width compact grid"> + {{$issueReferenceLink := printf "%s#%d" .Issue.Repo.FullName .Issue.Index}} + <div class="row tw-items-center" data-tooltip-content="{{$issueReferenceLink}}"> + <span class="text column truncate">{{ctx.Locale.Tr "repo.issues.reference_link" $issueReferenceLink}}</span> + <button class="ui two wide button column tw-p-2" data-clipboard-text="{{$issueReferenceLink}}">{{svg "octicon-copy" 14}}</button> + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/timetracking.tmpl b/templates/repo/issue/view_content/sidebar/timetracking.tmpl new file mode 100644 index 0000000..610600b --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/timetracking.tmpl @@ -0,0 +1,73 @@ +{{if and .CanUseTimetracker (not .Repository.IsArchived)}} + <div class="divider"></div> + <div class="ui timetrack"> + <span class="text"><strong>{{ctx.Locale.Tr "repo.issues.tracker"}}</strong></span> + <div class="tw-mt-2"> + <form method="post" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form"> + {{$.CsrfTokenHtml}} + </form> + <form method="post" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form"> + {{$.CsrfTokenHtml}} + </form> + {{if $.IsStopwatchRunning}} + <button class="ui fluid button issue-stop-time"> + {{svg "octicon-stopwatch" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.stop_tracking"}} + </button> + <button class="ui fluid button issue-cancel-time tw-mt-2"> + {{svg "octicon-trash" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.cancel_tracking"}} + </button> + {{else}} + {{if .HasUserStopwatch}} + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.issues.tracking_already_started" .OtherStopwatchURL}} + </div> + {{end}} + <button class="ui fluid button issue-start-time" data-tooltip-content='{{ctx.Locale.Tr "repo.issues.start_tracking"}}'> + {{svg "octicon-stopwatch" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.start_tracking_short"}} + </button> + <div class="ui mini modal issue-start-time-modal"> + <div class="header">{{ctx.Locale.Tr "repo.issues.add_time"}}</div> + <div class="content"> + <form method="post" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui input fluid tw-gap-2"> + {{$.CsrfTokenHtml}} + <input placeholder='{{ctx.Locale.Tr "repo.issues.add_time_hours"}}' type="number" name="hours"> + <input placeholder='{{ctx.Locale.Tr "repo.issues.add_time_minutes"}}' type="number" name="minutes" class="ui compact"> + </form> + </div> + <div class="actions"> + <button class="ui primary approve button">{{ctx.Locale.Tr "repo.issues.add_time_short"}}</button> + <button class="ui cancel button">{{ctx.Locale.Tr "repo.issues.add_time_cancel"}}</button> + </div> + </div> + <button class="ui fluid button issue-add-time tw-mt-2" data-tooltip-content='{{ctx.Locale.Tr "repo.issues.add_time"}}'> + {{svg "octicon-plus" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.add_time_short"}} + </button> + {{end}} + </div> + </div> +{{end}} +{{if .WorkingUsers}} + <div class="divider"></div> + <div class="ui comments"> + <span class="text"><strong>{{ctx.Locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time)}}</strong></span> + <div> + {{range $user, $trackedtime := .WorkingUsers}} + <div class="comment tw-mt-2"> + <a class="avatar"> + {{ctx.AvatarUtils.Avatar $user}} + </a> + <div class="content"> + {{template "shared/user/authorlink" $user}} + <div class="text"> + {{$trackedtime|Sec2Time}} + </div> + </div> + </div> + {{end}} + </div> + </div> +{{end}} diff --git a/templates/repo/issue/view_content/sidebar/watch.tmpl b/templates/repo/issue/view_content/sidebar/watch.tmpl new file mode 100644 index 0000000..ee14168 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/watch.tmpl @@ -0,0 +1,6 @@ +<div class="ui watching"> + <span class="text"><strong>{{ctx.Locale.Tr "notification.notifications"}}</strong></span> + <div class="tw-mt-2"> + {{template "repo/issue/view_content/sidebar/watching" .}} + </div> +</div> diff --git a/templates/repo/issue/view_content/sidebar/watching.tmpl b/templates/repo/issue/view_content/sidebar/watching.tmpl new file mode 100644 index 0000000..d3d7594 --- /dev/null +++ b/templates/repo/issue/view_content/sidebar/watching.tmpl @@ -0,0 +1,19 @@ +<form hx-boost="true" hx-sync="this:replace" hx-target="this" method="post" action="{{.Issue.Link}}/watch" + {{if not $.IsSigned}} + {{if $.Issue.IsPull}} + data-tooltip-content="{{ctx.Locale.Tr "repo.subscribe.pull.guest.tooltip"}}" + {{else}} + data-tooltip-content="{{ctx.Locale.Tr "repo.subscribe.issue.guest.tooltip"}}" + {{end}} + {{end}}> + <input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}"> + <button class="fluid ui button {{if not $.IsSigned}}disabled{{end}}"> + {{if $.IssueWatch.IsWatching}} + {{svg "octicon-mute" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.unsubscribe"}} + {{else}} + {{svg "octicon-unmute" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.issues.subscribe"}} + {{end}} + </button> +</form> diff --git a/templates/repo/issue/view_content/update_branch_by_merge.tmpl b/templates/repo/issue/view_content/update_branch_by_merge.tmpl new file mode 100644 index 0000000..adce052 --- /dev/null +++ b/templates/repo/issue/view_content/update_branch_by_merge.tmpl @@ -0,0 +1,37 @@ +{{if and (gt $.Issue.PullRequest.CommitsBehind 0) (not $.Issue.IsClosed) (not $.Issue.PullRequest.IsChecking) (not $.IsPullFilesConflicted) (not $.IsPullRequestBroken)}} + <div class="divider"></div> + <div class="item item-section"> + <div class="item-section-left flex-text-inline"> + {{svg "octicon-alert"}} + {{ctx.Locale.Tr "repo.pulls.outdated_with_base_branch"}} + </div> + <div class="item-section-right"> + {{if and $.UpdateAllowed $.UpdateByRebaseAllowed}} + <div class="tw-inline-block"> + <div class="ui buttons update-button"> + <button class="ui button" data-do="{{$.Link}}/update" data-redirect="{{$.Link}}"> + <span class="button-text"> + {{ctx.Locale.Tr "repo.pulls.update_branch"}} + </span> + </button> + <div class="ui dropdown icon button"> + {{svg "octicon-triangle-down"}} + <div class="menu"> + <a class="item active selected" data-do="{{$.Link}}/update">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</a> + <a class="item" data-do="{{$.Link}}/update?style=rebase">{{ctx.Locale.Tr "repo.pulls.update_branch_rebase"}}</a> + </div> + </div> + </div> + </div> + {{end}} + {{if and $.UpdateAllowed (not $.UpdateByRebaseAllowed)}} + <form action="{{$.Link}}/update" method="post" class="ui update-branch-form"> + {{$.CsrfTokenHtml}} + <button class="ui compact button"> + <span class="ui text">{{ctx.Locale.Tr "repo.pulls.update_branch"}}</span> + </button> + </form> + {{end}} + </div> + </div> +{{end}} diff --git a/templates/repo/issue/view_title.tmpl b/templates/repo/issue/view_title.tmpl new file mode 100644 index 0000000..f60d958 --- /dev/null +++ b/templates/repo/issue/view_title.tmpl @@ -0,0 +1,144 @@ +{{if .Flash}} + <div class="sixteen wide column tw-mb-2"> + {{template "base/alert" .}} + </div> +{{end}} +<div class="issue-title-header"> + {{$canEditIssueTitle := and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .Repository.IsArchived)}} + <div class="issue-title" id="issue-title-display"> + <h1 class="tw-break-anywhere"> + {{RenderIssueTitle $.Context .Issue.Title ($.Repository.ComposeMetas ctx)}} <span class="index">#{{.Issue.Index}}</span> + </h1> + <div class="button-row"> + {{if $canEditIssueTitle}} + <button id="issue-title-edit-show" class="ui small basic button">{{ctx.Locale.Tr "repo.issues.edit"}}</button> + {{end}} + {{if not .Issue.IsPull}} + <a role="button" class="ui small primary button" href="{{.RepoLink}}/issues/new{{if .NewIssueChooseTemplate}}/choose{{end}}">{{ctx.Locale.Tr "repo.issues.new"}}</a> + {{end}} + </div> + </div> + {{if $canEditIssueTitle}} + <div class="ui form issue-title tw-hidden" id="issue-title-editor"> + <div class="ui input tw-flex-1"> + <input value="{{.Issue.Title}}" data-old-title="{{.Issue.Title}}" maxlength="245" autocomplete="off" class="js-quick-submit"> + </div> + <div class="button-row"> + <button class="ui small basic cancel button">{{ctx.Locale.Tr "repo.issues.cancel"}}</button> + <button class="ui small primary button" + data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title"> + {{ctx.Locale.Tr "repo.issues.save"}} + </button> + </div> + </div> + {{end}} + <div class="issue-title-meta"> + {{if .HasMerged}} + <div class="ui purple label issue-state-label">{{svg "octicon-git-merge" 16 "tw-mr-1"}} {{if eq .Issue.PullRequest.Status 3}}{{ctx.Locale.Tr "repo.pulls.manually_merged"}}{{else}}{{ctx.Locale.Tr "repo.pulls.merged"}}{{end}}</div> + {{else if .Issue.IsClosed}} + <div class="ui red label issue-state-label">{{if .Issue.IsPull}}{{svg "octicon-git-pull-request-closed"}}{{else}}{{svg "octicon-issue-closed"}}{{end}} {{ctx.Locale.Tr "repo.issues.closed_title"}}</div> + {{else if .Issue.IsPull}} + {{if .IsPullWorkInProgress}} + <div class="ui grey label issue-state-label">{{svg "octicon-git-pull-request-draft"}} {{ctx.Locale.Tr "repo.issues.draft_title"}}</div> + {{else}} + <div class="ui green label issue-state-label">{{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.issues.open_title"}}</div> + {{end}} + {{else}} + <div class="ui green label issue-state-label">{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues.open_title"}}</div> + {{end}} + <div class="tw-ml-2 tw-flex-1 tw-break-anywhere"> + {{if .Issue.IsPull}} + {{$headHref := .HeadTarget}} + {{if .HeadBranchLink}} + {{$headHref = HTMLFormat `<a href="%s">%s</a>` .HeadBranchLink $headHref}} + {{end}} + {{if not .MadeUsingAGit}} + {{$headHref = HTMLFormat `%s <button class="btn interact-fg" data-tooltip-content="%s" data-clipboard-text="%s">%s</button>` $headHref (ctx.Locale.Tr "copy_branch") .HeadTarget (svg "octicon-copy" 14)}} + {{end}} + {{$baseHref := .BaseTarget}} + {{if .BaseBranchLink}} + {{$baseHref = HTMLFormat `<a href="%s">%s</a>` .BaseBranchLink $baseHref}} + {{end}} + {{if .Issue.PullRequest.HasMerged}} + {{$mergedStr:= TimeSinceUnix .Issue.PullRequest.MergedUnix ctx.Locale}} + {{if .Issue.OriginalAuthor}} + {{.Issue.OriginalAuthor}} + <span class="pull-desc">{{ctx.Locale.TrN .NumCommits "repo.pulls.merged_title_desc_one" "repo.pulls.merged_title_desc_few" .NumCommits $headHref $baseHref $mergedStr}}</span> + {{else}} + <a {{if gt .Issue.PullRequest.Merger.ID 0}}href="{{.Issue.PullRequest.Merger.HomeLink}}"{{end}}>{{.Issue.PullRequest.Merger.GetDisplayName}}</a> + <span class="pull-desc">{{ctx.Locale.TrN .NumCommits "repo.pulls.merged_title_desc_one" "repo.pulls.merged_title_desc_few" .NumCommits $headHref $baseHref $mergedStr}}</span> + {{end}} + {{if .MadeUsingAGit}} + {{/* TODO: Move documentation link to the instructions at the bottom of the PR, show instructions when clicking label */}} + {{/* Note: #agit-label is necessary for testing whether the label appears when it should in tests/integration/git_test.go */}} + <a target="_blank" rel="noopener" href="https://forgejo.org/docs/latest/user/agit-support/"> + <span id="agit-label" data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.agit_explanation"}}" class="ui small label"> + {{ctx.Locale.Tr "repo.pulls.made_using_agit"}} + </span> + </a> + {{end}} + {{else}} + {{if .Issue.OriginalAuthor}} + <span id="pull-desc-display" class="pull-desc">{{.Issue.OriginalAuthor}} {{ctx.Locale.TrN .NumCommits "repo.pulls.title_desc_one" "repo.pulls.title_desc_few" .NumCommits $headHref $baseHref}}</span> + {{else}} + <span id="pull-desc-display" class="pull-desc"> + <a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.GetDisplayName}}</a> + {{ctx.Locale.TrN .NumCommits "repo.pulls.title_desc_one" "repo.pulls.title_desc_few" .NumCommits $headHref $baseHref}} + </span> + {{end}} + {{if .MadeUsingAGit}} + {{/* TODO: Move documentation link to the instructions at the bottom of the PR, show instructions when clicking label */}} + {{/* Note: #agit-label is necessary for testing whether the label appears when it should in tests/integration/git_test.go */}} + <a target="_blank" rel="noopener" href="https://forgejo.org/docs/latest/user/agit-support/"> + <span id="agit-label" data-tooltip-content="{{ctx.Locale.Tr "repo.pulls.agit_explanation"}}" class="ui small label"> + {{ctx.Locale.Tr "repo.pulls.made_using_agit"}} + </span> + </a> + {{end}} + <span id="pull-desc-editor" class="tw-hidden flex-text-block" data-target-update-url="{{$.RepoLink}}/pull/{{.Issue.Index}}/target_branch"> + <div class="ui floating filter dropdown"> + <div class="ui basic small button tw-mr-0"> + <span class="text">{{ctx.Locale.Tr "repo.pulls.compare_compare"}}: {{$.HeadTarget}}</span> + </div> + </div> + {{svg "octicon-arrow-right"}} + <div class="ui floating filter dropdown" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}"> + <div class="ui basic small button"> + <span class="text" id="pull-target-branch" data-basename="{{$.BaseName}}" data-branch="{{$.BaseBranch}}">{{ctx.Locale.Tr "repo.pulls.compare_base"}}: {{$.BaseName}}:{{$.BaseBranch}}</span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </div> + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-filter" 16}}</i> + <input name="search" placeholder="{{ctx.Locale.Tr "repo.pulls.filter_branch"}}..."> + </div> + <div class="scrolling menu" id="branch-select"> + {{range .Branches}} + {{$sameBase := ne $.BaseName $.HeadUserName}} + {{$differentBranch := ne . $.HeadBranch}} + {{if or $sameBase $differentBranch}} + <div class="item {{if eq $.BaseBranch .}}selected{{end}}" data-branch="{{.}}">{{$.BaseName}}{{if $.HeadRepo}}/{{$.HeadRepo}}{{end}}:{{.}}</div> + {{end}} + {{end}} + </div> + </div> + </div> + </span> + {{end}} + {{else}} + {{$createdStr:= TimeSinceUnix .Issue.CreatedUnix ctx.Locale}} + <span class="time-desc"> + {{if .Issue.OriginalAuthor}} + {{ctx.Locale.Tr "repo.issues.opened_by_fake" $createdStr .Issue.OriginalAuthor}} + {{else if gt .Issue.Poster.ID 0}} + {{ctx.Locale.Tr "repo.issues.opened_by" $createdStr .Issue.Poster.HomeLink .Issue.Poster.GetDisplayName}} + {{else}} + {{ctx.Locale.Tr "repo.issues.opened_by_fake" $createdStr .Issue.Poster.GetDisplayName}} + {{end}} + · + {{ctx.Locale.TrN .Issue.NumComments "repo.issues.num_comments_1" "repo.issues.num_comments" .Issue.NumComments}} + </span> + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/latest_commit.tmpl b/templates/repo/latest_commit.tmpl new file mode 100644 index 0000000..222d582 --- /dev/null +++ b/templates/repo/latest_commit.tmpl @@ -0,0 +1,31 @@ +{{if not .LatestCommit}} + <div class="ui active tiny slow centered inline">…</div> +{{else}} + {{if .LatestCommitUser}} + {{ctx.AvatarUtils.Avatar .LatestCommitUser 24 "tw-mr-2"}} + {{if and .LatestCommitUser.FullName DefaultShowFullName}} + <a class="muted author-wrapper" title="{{.LatestCommitUser.FullName}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{.LatestCommitUser.FullName}}</strong></a> + {{else}} + <a class="muted author-wrapper" title="{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}" href="{{.LatestCommitUser.HomeLink}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a> + {{end}} + {{else}} + {{if .LatestCommit.Author}} + {{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24 "tw-mr-2"}} + <span class="author-wrapper" title="{{.LatestCommit.Author.Name}}"><strong>{{.LatestCommit.Author.Name}}</strong></span> + {{end}} + {{end}} + <a rel="nofollow" class="ui sha label {{if .LatestCommit.Signature}} isSigned {{if .LatestCommitVerification.Verified}} isVerified{{if eq .LatestCommitVerification.TrustStatus "trusted"}}{{else if eq .LatestCommitVerification.TrustStatus "untrusted"}}Untrusted{{else}}Unmatched{{end}}{{else if .LatestCommitVerification.Warning}} isWarning{{end}}{{end}}" href="{{.RepoLink}}/commit/{{PathEscape .LatestCommit.ID.String}}"> + <span class="shortsha">{{ShortSha .LatestCommit.ID.String}}</span> + {{if .LatestCommit.Signature}} + {{template "repo/shabox_badge" dict "root" $ "verification" .LatestCommitVerification}} + {{end}} + </a> + {{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses}} + {{$commitLink:= printf "%s/commit/%s" .RepoLink (PathEscape .LatestCommit.ID.String)}} + <span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span class="message-wrapper">{{RenderCommitMessageLinkSubject $.Context .LatestCommit.Message $commitLink ($.Repository.ComposeMetas ctx)}}</span> + {{if IsMultilineCommitMessage .LatestCommit.Message}} + <button class="ui button js-toggle-commit-body ellipsis-button" aria-expanded="false">...</button> + <pre class="commit-body tw-hidden">{{RenderCommitBody $.Context .LatestCommit.Message ($.Repository.ComposeMetas ctx)}}</pre> + {{end}} + </span> +{{end}} diff --git a/templates/repo/migrate/codebase.tmpl b/templates/repo/migrate/codebase.tmpl new file mode 100644 index 0000000..cf46c8d --- /dev/null +++ b/templates/repo/migrate/codebase.tmpl @@ -0,0 +1,126 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_username">{{ctx.Locale.Tr "username"}}</label> + <input id="auth_username" name="auth_username" value="{{.auth_username}}" {{if not .auth_username}}data-need-clear="true"{{end}}> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_password">{{ctx.Locale.Tr "password"}}</label> + <input id="auth_password" name="auth_password" type="password" value="{{.auth_password}}"> + </div> + + {{template "repo/migrate/options" .}} + + <div id="migrate_items"> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/forgejo.tmpl b/templates/repo/migrate/forgejo.tmpl new file mode 100644 index 0000000..3caadbe --- /dev/null +++ b/templates/repo/migrate/forgejo.tmpl @@ -0,0 +1 @@ +{{template "repo/migrate/gitea" .}} diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl new file mode 100644 index 0000000..5ebf4cf --- /dev/null +++ b/templates/repo/migrate/git.tmpl @@ -0,0 +1,94 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_username">{{ctx.Locale.Tr "username"}}</label> + <input id="auth_username" name="auth_username" value="{{.auth_username}}" {{if not .auth_username}}data-need-clear="true"{{end}}> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_password">{{ctx.Locale.Tr "password"}}</label> + <input id="auth_password" name="auth_password" type="password" value="{{.auth_password}}"> + </div> + + {{template "repo/migrate/options" .}} + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar .}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/gitbucket.tmpl b/templates/repo/migrate/gitbucket.tmpl new file mode 100644 index 0000000..e8d6b60 --- /dev/null +++ b/templates/repo/migrate/gitbucket.tmpl @@ -0,0 +1,142 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_username">{{ctx.Locale.Tr "username"}}</label> + <input id="auth_username" name="auth_username" value="{{.auth_username}}" {{if not .auth_username}}data-need-clear="true"{{end}}> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_password">{{ctx.Locale.Tr "password"}}</label> + <input id="auth_password" name="auth_password" type="password" value="{{.auth_password}}"> + </div> + + {{template "repo/migrate/options" .}} + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .wiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_wiki"}}</label> + </div> + </div> + + <div id="migrate_items"> + <span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="releases" type="checkbox" {{if .releases}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl new file mode 100644 index 0000000..2f40d58 --- /dev/null +++ b/templates/repo/migrate/gitea.tmpl @@ -0,0 +1,138 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_token">{{ctx.Locale.Tr "access_token"}}</label> + <input id="auth_token" name="auth_token" type="password" autocomplete="new-password" value="{{.auth_token}}" {{if not .auth_token}} data-need-clear="true" {{end}}> + <a target="_blank" href="https://forgejo.org/docs/latest/user/api-usage/">{{svg "octicon-question"}}</a> + </div> + + {{template "repo/migrate/options" .}} + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .wiki}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_wiki"}}</label> + </div> + </div> + + <div id="migrate_items"> + <span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="releases" type="checkbox" {{if .releases}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar .}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl new file mode 100644 index 0000000..91c1a27 --- /dev/null +++ b/templates/repo/migrate/github.tmpl @@ -0,0 +1,140 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_token">{{ctx.Locale.Tr "access_token"}}</label> + <input id="auth_token" name="auth_token" type="password" autocomplete="new-password" value="{{.auth_token}}" {{if not .auth_token}}data-need-clear="true"{{end}}> + <a target="_blank" href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">{{svg "octicon-question"}}</a> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.github_token_desc"}} + </span> + </div> + + {{template "repo/migrate/options" .}} + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .wiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_wiki"}}</label> + </div> + </div> + <div id="migrate_items"> + <span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="releases" type="checkbox" {{if .releases}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl new file mode 100644 index 0000000..d93a001 --- /dev/null +++ b/templates/repo/migrate/gitlab.tmpl @@ -0,0 +1,137 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_token">{{ctx.Locale.Tr "access_token"}}</label> + <input id="auth_token" name="auth_token" type="password" autocomplete="new-password" value="{{.auth_token}}" {{if not .auth_token}}data-need-clear="true"{{end}}> + <a target="_blank" href="https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html">{{svg "octicon-question"}}</a> + </div> + + {{template "repo/migrate/options" .}} + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .wiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_wiki"}}</label> + </div> + </div> + <div id="migrate_items"> + <span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="releases" type="checkbox" {{if .releases}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl new file mode 100644 index 0000000..6c647be --- /dev/null +++ b/templates/repo/migrate/gogs.tmpl @@ -0,0 +1,137 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_token">{{ctx.Locale.Tr "access_token"}}</label> + <input id="auth_token" name="auth_token" type="password" autocomplete="new-password" value="{{.auth_token}}" {{if not .auth_token}} data-need-clear="true" {{end}}> + <!-- <a target="_blank" href="https://docs.gitea.com/development/api-usage">{{svg "octicon-question"}}</a> --> + </div> + + {{template "repo/migrate/options" .}} + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="wiki" type="checkbox" {{if .wiki}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_wiki"}}</label> + </div> + </div> + + <div id="migrate_items"> + <span class="help">{{ctx.Locale.Tr "repo.migrate.migrate_items_options"}}</span> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + <!-- Gogs do not support it + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_merge_requests"}}</label> + </div> + <div class="ui checkbox"> + <input name="releases" type="checkbox" {{if .releases}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_releases"}}</label> + </div> + </div> + --> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar .}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/helper.tmpl b/templates/repo/migrate/helper.tmpl new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/templates/repo/migrate/helper.tmpl diff --git a/templates/repo/migrate/migrate.tmpl b/templates/repo/migrate/migrate.tmpl new file mode 100644 index 0000000..c5c697e --- /dev/null +++ b/templates/repo/migrate/migrate.tmpl @@ -0,0 +1,32 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + {{template "repo/migrate/helper" .}} + <div class="ui cards migrate-entries"> + {{range .Services}} + <a class="ui card migrate-entry tw-flex tw-items-center" href="{{AppSubUrl}}/repo/migrate?service_type={{.}}&org={{$.Org}}&mirror={{$.Mirror}}"> + {{if eq .Name "github"}} + {{svg "octicon-mark-github" 184 "tw-p-4"}} + {{else if eq .Name "gitlab"}} + {{svg "gitea-gitlab" 184 "tw-p-4"}} + {{else if eq .Name "gitbucket"}} + {{svg "gitea-gitbucket" 184 "tw-p-4"}} + {{else}} + {{svg (printf "gitea-%s" .Name) 184}} + {{end}} + <div class="content"> + <div class="header tw-text-center"> + {{.Title}} + </div> + <div class="description tw-text-center"> + {{ctx.Locale.Tr (printf "repo.migrate.%s.description" .Name)}} + </div> + </div> + </a> + {{end}} + </div> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/migrating.tmpl b/templates/repo/migrate/migrating.tmpl new file mode 100644 index 0000000..0b53636 --- /dev/null +++ b/templates/repo/migrate/migrating.tmpl @@ -0,0 +1,101 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="ui grid"> + <div class="sixteen wide column content"> + {{template "base/alert" .}} + <div class="home"> + <div class="ui stackable middle very relaxed page grid"> + <div id="repo_migrating" class="sixteen wide center aligned centered column" data-migrating-task-id="{{.MigrateTask.ID}}"> + <div> + <img src="{{AssetUrlPrefix}}/img/forgejo-loading.svg" width="256" height="256"> + </div> + </div> + <div id="repo_migrating_failed_image" class="sixteen wide center aligned centered column tw-hidden"> + <div> + <span class="red">{{svg "octicon-git-pull-request-closed" 256 "ui red icon"}}</span> + </div> + </div> + </div> + <div class="ui stackable middle very relaxed page grid"> + <div class="sixteen wide center aligned centered column"> + <div id="repo_migrating_progress"> + <p>{{ctx.Locale.Tr "repo.migrate.migrating" .CloneAddr}}</p> + <p id="repo_migrating_progress_message"></p> + </div> + <div id="repo_migrating_failed" class="tw-hidden"> + {{if .CloneAddr}} + <p>{{ctx.Locale.Tr "repo.migrate.migrating_failed" .CloneAddr}}</p> + {{else}} + <p>{{ctx.Locale.Tr "repo.migrate.migrating_failed_no_addr"}}</p> + {{end}} + <p id="repo_migrating_failed_error"></p> + </div> + {{if .Permission.IsAdmin}} + <div class="divider"></div> + <div class="item"> + {{if .Failed}} + <button class="ui basic red show-modal button" data-modal="#delete-repo-modal">{{ctx.Locale.Tr "repo.settings.delete"}}</button> + {{else}} + <button class="ui basic show-modal button" data-modal="#cancel-repo-modal">{{ctx.Locale.Tr "cancel"}}</button> + {{end}} + <button id="repo_migrating_retry" data-migrating-task-retry-url="{{.Link}}/settings/migrate/retry" class="ui basic button tw-hidden">{{ctx.Locale.Tr "retry"}}</button> + </div> + {{end}} + </div> + </div> + </div> + </div> + </div> + </div> +</div> + +<div class="ui small modal" id="delete-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.delete"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.delete_notices_1"}}<br> + {{ctx.Locale.Tr "repo.settings.delete_notices_2" .Repository.FullName}} + {{if .Repository.NumForks}}<br> + {{ctx.Locale.Tr "repo.settings.delete_notices_fork_1"}} + {{end}} + </div> + <form class="ui form" action="{{.Link}}/settings" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="delete"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label for="repo_name_to_delete">{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input id="repo_name_to_delete" name="repo_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.confirm_delete"}}</button> + </div> + </form> + </div> +</div> + +<div class="ui g-modal-confirm modal" id="cancel-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.migrate.cancel_migrating_title"}} + </div> + <form action="{{.Link}}/settings/migrate/cancel" method="post"> + {{.CsrfTokenHtml}} + <div class="content"> + {{ctx.Locale.Tr "repo.migrate.cancel_migrating_confirm"}} + </div> + {{template "base/modal_actions_confirm" .}} + </form> +</div> + +{{template "base/footer" .}} diff --git a/templates/repo/migrate/onedev.tmpl b/templates/repo/migrate/onedev.tmpl new file mode 100644 index 0000000..ec15555 --- /dev/null +++ b/templates/repo/migrate/onedev.tmpl @@ -0,0 +1,126 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new migrate"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} + <input id="service_type" type="hidden" name="service" value="{{.service}}"> + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_CloneAddr}}error{{end}}"> + <label for="clone_addr">{{ctx.Locale.Tr "repo.migrate.clone_address"}}</label> + <input id="clone_addr" name="clone_addr" value="{{.clone_addr}}" autofocus required> + <span class="help"> + {{ctx.Locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate.clone_local_path"}}{{end}} + </span> + </div> + + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_username">{{ctx.Locale.Tr "username"}}</label> + <input id="auth_username" name="auth_username" value="{{.auth_username}}" {{if not .auth_username}}data-need-clear="true"{{end}}> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="auth_password">{{ctx.Locale.Tr "password"}}</label> + <input id="auth_password" name="auth_password" type="password" value="{{.auth_password}}"> + </div> + + {{template "repo/migrate/options" .}} + + <div id="migrate_items"> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_items"}}</label> + <div class="ui checkbox"> + <input name="issues" type="checkbox" {{if .issues}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_issues"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="pull_requests" type="checkbox" {{if .pull_requests}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_pullrequests"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="labels" type="checkbox" {{if .labels}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_labels"}}</label> + </div> + </div> + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input name="milestones" type="checkbox" {{if .milestones}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_items_milestones"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu" title="{{.SignedUser.Name}}"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required maxlength="100"> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox"> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" maxlength="2048">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.migrate_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/migrate/options.tmpl b/templates/repo/migrate/options.tmpl new file mode 100644 index 0000000..8a46e57 --- /dev/null +++ b/templates/repo/migrate/options.tmpl @@ -0,0 +1,26 @@ +{{if not .DisableNewPullMirrors}} +<div class="inline field"> + <label>{{ctx.Locale.Tr "repo.migrate_options"}}</label> + <div class="ui checkbox"> + <input id="mirror" name="mirror" type="checkbox" {{if .mirror}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_options_mirror_helper"}}</label> + </div> +</div> +{{end}} +{{if .LFSActive}} +<div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input id="lfs" name="lfs" type="checkbox" {{if .lfs}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.migrate_options_lfs"}}</label> + </div> + <span id="lfs_settings" class="tw-hidden">(<a id="lfs_settings_show" href="#">{{ctx.Locale.Tr "repo.settings.advanced_settings"}}</a>)</span> +</div> +<div id="lfs_endpoint" class="tw-hidden"> + <span class="help">{{ctx.Locale.Tr "repo.migrate_options_lfs_endpoint.description" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery"}}{{if .ContextUser.CanImportLocal}} {{ctx.Locale.Tr "repo.migrate_options_lfs_endpoint.description.local"}}{{end}}</span> + <div class="inline field {{if .Err_LFSEndpoint}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.migrate_options_lfs_endpoint.label"}}</label> + <input name="lfs_endpoint" value="{{.lfs_endpoint}}" placeholder="{{ctx.Locale.Tr "repo.migrate_options_lfs_endpoint.placeholder"}}"> + </div> +</div> +{{end}} diff --git a/templates/repo/navbar.tmpl b/templates/repo/navbar.tmpl new file mode 100644 index 0000000..b2471dc --- /dev/null +++ b/templates/repo/navbar.tmpl @@ -0,0 +1,14 @@ +<div class="ui fluid vertical menu"> + <a class="{{if .PageIsPulse}}active {{end}}item" href="{{.RepoLink}}/activity"> + {{ctx.Locale.Tr "repo.activity.navbar.pulse"}} + </a> + <a class="{{if .PageIsContributors}}active {{end}}item" href="{{.RepoLink}}/activity/contributors"> + {{ctx.Locale.Tr "repo.activity.navbar.contributors"}} + </a> + <a class="{{if .PageIsCodeFrequency}}active{{end}} item" href="{{.RepoLink}}/activity/code-frequency"> + {{ctx.Locale.Tr "repo.activity.navbar.code_frequency"}} + </a> + <a class="{{if .PageIsRecentCommits}}active{{end}} item" href="{{.RepoLink}}/activity/recent-commits"> + {{ctx.Locale.Tr "repo.activity.navbar.recent_commits"}} + </a> +</div> diff --git a/templates/repo/packages.tmpl b/templates/repo/packages.tmpl new file mode 100644 index 0000000..14e32c1 --- /dev/null +++ b/templates/repo/packages.tmpl @@ -0,0 +1,8 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository packages"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "package/shared/list" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/projects/list.tmpl b/templates/repo/projects/list.tmpl new file mode 100644 index 0000000..9eae401 --- /dev/null +++ b/templates/repo/projects/list.tmpl @@ -0,0 +1,8 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository projects milestones"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "projects/list" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/projects/new.tmpl b/templates/repo/projects/new.tmpl new file mode 100644 index 0000000..e70f3bc --- /dev/null +++ b/templates/repo/projects/new.tmpl @@ -0,0 +1,8 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository projects edit-project new milestone"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "projects/new" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl new file mode 100644 index 0000000..05ad726 --- /dev/null +++ b/templates/repo/projects/view.tmpl @@ -0,0 +1,15 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository projects view-project"> + {{template "repo/header" .}} + <div class="ui container padded"> + <div class="tw-flex tw-justify-between tw-items-center tw-mb-4"> + {{template "repo/issue/navbar" .}} + <a class="ui small primary button" href="{{.RepoLink}}/issues/new/choose?project={{.Project.ID}}">{{ctx.Locale.Tr "repo.issues.new"}}</a> + </div> + </div> + <div class="ui container fluid padded"> + {{template "projects/view" .}} + </div> +</div> + +{{template "base/footer" .}} diff --git a/templates/repo/pulls/commits.tmpl b/templates/repo/pulls/commits.tmpl new file mode 100644 index 0000000..bf6e812 --- /dev/null +++ b/templates/repo/pulls/commits.tmpl @@ -0,0 +1,10 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository view issue pull commits"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "repo/issue/view_title" .}} + {{template "repo/pulls/tab_menu" .}} + {{template "repo/commits_table" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/pulls/files.tmpl b/templates/repo/pulls/files.tmpl new file mode 100644 index 0000000..402bec8 --- /dev/null +++ b/templates/repo/pulls/files.tmpl @@ -0,0 +1,14 @@ +{{template "base/head" .}} + +<input type="hidden" id="repolink" value="{{$.RepoRelPath}}"> +<input type="hidden" id="issueIndex" value="{{.Issue.Index}}"> + +<div role="main" aria-label="{{.Title}}" class="page-content repository view issue pull files diff"> + {{template "repo/header" .}} + <div class="ui container fluid padded"> + {{template "repo/issue/view_title" .}} + {{template "repo/pulls/tab_menu" .}} + {{template "repo/diff/box" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/pulls/fork.tmpl b/templates/repo/pulls/fork.tmpl new file mode 100644 index 0000000..2cf0a85 --- /dev/null +++ b/templates/repo/pulls/fork.tmpl @@ -0,0 +1,90 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new fork"> + <div class="ui middle very relaxed page grid"> + <div class="column"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <h3 class="ui top attached header"> + {{ctx.Locale.Tr "new_fork"}} + </h3> + <div class="ui attached segment"> + {{template "base/alert" .}} + <div class="inline required field {{if .Err_Owner}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.owner"}}</label> + <div class="ui selection owner dropdown"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + {{if .CanForkToUser}} + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{end}} + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + </div> + + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.fork_from"}}</label> + <a href="{{.ForkRepo.Link}}" class="tw-inline-block">{{.ForkRepo.FullName}}</a> + </div> + <div class="inline required field {{if .Err_RepoName}}error{{end}}"> + <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input id="repo_name" name="repo_name" value="{{.repo_name}}" required> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui disabled checkbox"> + <input type="checkbox" disabled {{if .IsPrivate}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> + </div> + <span class="help">{{ctx.Locale.Tr "repo.fork_visibility_helper"}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.fork_branch"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" id="fork_single_branch" name="fork_single_branch" value="" required> + <span class="text truncated-item-container" data-value="" title="{{ctx.Locale.Tr "repo.all_branches"}}"> + <span class="truncated-item-name">{{ctx.Locale.Tr "repo.all_branches"}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item truncated-item-container" data-value="" title="{{ctx.Locale.Tr "repo.all_branches"}}"> + <span class="truncated-item-name">{{ctx.Locale.Tr "repo.all_branches"}}</span> + </div> + {{range .Branches}} + <div class="item truncated-item-container" data-value="{{.}}" title="{{.}}"> + <span class="truncated-item-name">{{.}}</span> + </div> + {{end}} + </div> + </div> + </div> + <div class="inline field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description">{{.description}}</textarea> + </div> + + <div class="inline field"> + <label></label> + <button class="ui primary button{{if not .CanForkRepo}} disabled{{end}}"> + {{ctx.Locale.Tr "repo.fork_repo"}} + </button> + </div> + </div> + </form> + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/pulls/status.tmpl b/templates/repo/pulls/status.tmpl new file mode 100644 index 0000000..e8636ba --- /dev/null +++ b/templates/repo/pulls/status.tmpl @@ -0,0 +1,59 @@ +{{/* +Template Attributes: +* CommitStatus: summary of all commit status state +* CommitStatuses: all commit status elements +* MissingRequiredChecks: commit check contexts that are required by branch protection but not present +* ShowHideChecks: whether use a button to show/hide the checks +* is_context_required: Used in pull request commit status check table +*/}} + +{{if .CommitStatus}} +<div class="commit-status-panel"> + <div class="ui top attached header commit-status-header"> + {{if or (eq .CommitStatus.State "pending") (.MissingRequiredChecks)}} + {{ctx.Locale.Tr "repo.pulls.status_checking"}} + {{else if eq .CommitStatus.State "success"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_success"}} + {{else if eq .CommitStatus.State "warning"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_warning"}} + {{else if eq .CommitStatus.State "failure"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_failure"}} + {{else if eq .CommitStatus.State "error"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_error"}} + {{else}} + {{ctx.Locale.Tr "repo.pulls.status_checking"}} + {{end}} + + {{if .ShowHideChecks}} + <div class="ui right"> + <button class="commit-status-hide-checks btn interact-fg" + data-show-all="{{ctx.Locale.Tr "repo.pulls.status_checks_show_all"}}" + data-hide-all="{{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}"> + {{ctx.Locale.Tr "repo.pulls.status_checks_hide_all"}}</button> + </div> + {{end}} + </div> + + <div class="commit-status-list"> + {{range .CommitStatuses}} + <div class="commit-status-item"> + {{template "repo/commit_status" .}} + <div class="status-context gt-ellipsis">{{.Context}} <span class="text light-2">{{.Description}}</span></div> + <div class="ui status-details"> + {{if $.is_context_required}} + {{if (call $.is_context_required .Context)}}<div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div>{{end}} + {{end}} + <span>{{if .TargetURL}}<a href="{{.TargetURL}}">{{ctx.Locale.Tr "repo.pulls.status_checks_details"}}</a>{{end}}</span> + </div> + </div> + {{end}} + {{range .MissingRequiredChecks}} + <div class="commit-status-item"> + {{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}} + <div class="status-context gt-ellipsis">{{.}}</div> + <div class="ui label">{{ctx.Locale.Tr "repo.pulls.status_checks_requested"}}</div> + </div> + {{end}} + </div> +</div> +{{end}} diff --git a/templates/repo/pulls/tab_menu.tmpl b/templates/repo/pulls/tab_menu.tmpl new file mode 100644 index 0000000..d5a8d6e --- /dev/null +++ b/templates/repo/pulls/tab_menu.tmpl @@ -0,0 +1,28 @@ +<div class="ui pull tabs container"> + <div class="ui top attached pull tabular menu"> + <a class="item {{if .PageIsPullConversation}}active{{end}}" href="{{.Issue.Link}}"> + {{svg "octicon-comment-discussion"}} + {{ctx.Locale.Tr "repo.pulls.tab_conversation"}} + <span class="ui small label">{{.Issue.NumComments}}</span> + </a> + <a class="item {{if .PageIsPullCommits}}active{{end}}" {{if .NumCommits}}href="{{.Issue.Link}}/commits"{{end}}> + {{svg "octicon-git-commit"}} + {{ctx.Locale.Tr "repo.pulls.tab_commits"}} + <span class="ui small label">{{if .NumCommits}}{{.NumCommits}}{{else}}-{{end}}</span> + </a> + <a class="item {{if .PageIsPullFiles}}active{{end}}" href="{{.Issue.Link}}/files"> + {{svg "octicon-diff"}} + {{ctx.Locale.Tr "repo.pulls.tab_files"}} + <span class="ui small label">{{if .NumFiles}}{{.NumFiles}}{{else}}-{{end}}</span> + </a> + {{if or .Diff.TotalAddition .Diff.TotalDeletion}} + <span class="tw-ml-auto tw-pl-3 tw-whitespace-nowrap tw-pr-0 tw-font-bold tw-flex tw-items-center tw-gap-2"> + <span><span class="text green">{{if .Diff.TotalAddition}}+{{.Diff.TotalAddition}}{{end}}</span> <span class="text red">{{if .Diff.TotalDeletion}}-{{.Diff.TotalDeletion}}{{end}}</span></span> + <span class="diff-stats-bar"> + <div class="diff-stats-add-bar" style="width: {{Eval 100 "*" .Diff.TotalAddition "/" "(" .Diff.TotalAddition "+" .Diff.TotalDeletion "+" 0.0 ")"}}%"></div> + </span> + </span> + {{end}} + </div> + <div class="ui tabs divider"></div> +</div> diff --git a/templates/repo/pulse.tmpl b/templates/repo/pulse.tmpl new file mode 100644 index 0000000..3554cf6 --- /dev/null +++ b/templates/repo/pulse.tmpl @@ -0,0 +1,239 @@ +<h2 class="ui header activity-header"> + <span>{{DateTime "long" .DateFrom}} - {{DateTime "long" .DateUntil}}</span> + <!-- Period --> + <div class="ui floating dropdown jump filter"> + <div class="ui basic compact button"> + {{ctx.Locale.Tr "repo.activity.period.filter_label"}} <strong>{{.PeriodText}}</strong> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </div> + <div class="menu"> + <a class="{{if eq .Period "daily"}}active {{end}}item" href="{{$.RepoLink}}/activity/daily">{{ctx.Locale.Tr "repo.activity.period.daily"}}</a> + <a class="{{if eq .Period "halfweekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/halfweekly">{{ctx.Locale.Tr "repo.activity.period.halfweekly"}}</a> + <a class="{{if eq .Period "weekly"}}active {{end}}item" href="{{$.RepoLink}}/activity/weekly">{{ctx.Locale.Tr "repo.activity.period.weekly"}}</a> + <a class="{{if eq .Period "monthly"}}active {{end}}item" href="{{$.RepoLink}}/activity/monthly">{{ctx.Locale.Tr "repo.activity.period.monthly"}}</a> + <a class="{{if eq .Period "quarterly"}}active {{end}}item" href="{{$.RepoLink}}/activity/quarterly">{{ctx.Locale.Tr "repo.activity.period.quarterly"}}</a> + <a class="{{if eq .Period "semiyearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/semiyearly">{{ctx.Locale.Tr "repo.activity.period.semiyearly"}}</a> + <a class="{{if eq .Period "yearly"}}active {{end}}item" href="{{$.RepoLink}}/activity/yearly">{{ctx.Locale.Tr "repo.activity.period.yearly"}}</a> + </div> + </div> +</h2> + +{{if (or (.Permission.CanRead $.UnitTypeIssues) (.Permission.CanRead $.UnitTypePullRequests))}} +<h4 class="ui top attached header">{{ctx.Locale.Tr "repo.activity.overview"}}</h4> +<div class="ui attached segment two column grid"> + {{if .Permission.CanRead $.UnitTypePullRequests}} + <div class="column"> + {{if gt .Activity.ActivePRCount 0}} + <div class="stats-table"> + {{if gt .Activity.MergedPRPerc 0}} + <a href="#merged-pull-requests" class="table-cell tiny tw-bg-purple" style="width: {{.Activity.MergedPRPerc}}%"></a> + {{end}} + <a href="#proposed-pull-requests" class="table-cell tiny tw-bg-green"></a> + </div> + {{else}} + <div class="stats-table"> + <a class="table-cell tiny tw-bg-grey"></a> + </div> + {{end}} + {{ctx.Locale.TrN .Activity.ActivePRCount "repo.activity.active_prs_count_1" "repo.activity.active_prs_count_n" .Activity.ActivePRCount}} + </div> + {{end}} + {{if .Permission.CanRead $.UnitTypeIssues}} + <div class="column"> + {{if gt .Activity.ActiveIssueCount 0}} + <div class="stats-table"> + {{if gt .Activity.ClosedIssuePerc 0}} + <a href="#closed-issues" class="table-cell tiny tw-bg-red" style="width: {{.Activity.ClosedIssuePerc}}%"></a> + {{end}} + <a href="#new-issues" class="table-cell tiny tw-bg-green"></a> + </div> + {{else}} + <div class="stats-table"> + <a class="table-cell tiny background light grey"></a> + </div> + {{end}} + {{ctx.Locale.TrN .Activity.ActiveIssueCount "repo.activity.active_issues_count_1" "repo.activity.active_issues_count_n" .Activity.ActiveIssueCount}} + </div> + {{end}} +</div> +<div class="ui attached segment horizontal segments"> + {{if .Permission.CanRead $.UnitTypePullRequests}} + <a href="#merged-pull-requests" class="ui attached segment text center"> + <span class="text purple">{{svg "octicon-git-pull-request"}}</span> <strong>{{.Activity.MergedPRCount}}</strong><br> + {{ctx.Locale.TrN .Activity.MergedPRCount "repo.activity.merged_prs_count_1" "repo.activity.merged_prs_count_n"}} + </a> + <a href="#proposed-pull-requests" class="ui attached segment text center"> + <span class="text green">{{svg "octicon-git-branch"}}</span> <strong>{{.Activity.OpenedPRCount}}</strong><br> + {{ctx.Locale.TrN .Activity.OpenedPRCount "repo.activity.opened_prs_count_1" "repo.activity.opened_prs_count_n"}} + </a> + {{end}} + {{if .Permission.CanRead $.UnitTypeIssues}} + <a href="#closed-issues" class="ui attached segment text center"> + <span class="text red">{{svg "octicon-issue-closed"}}</span> <strong>{{.Activity.ClosedIssueCount}}</strong><br> + {{ctx.Locale.TrN .Activity.ClosedIssueCount "repo.activity.closed_issues_count_1" "repo.activity.closed_issues_count_n"}} + </a> + <a href="#new-issues" class="ui attached segment text center"> + <span class="text green">{{svg "octicon-issue-opened"}}</span> <strong>{{.Activity.OpenedIssueCount}}</strong><br> + {{ctx.Locale.TrN .Activity.OpenedIssueCount "repo.activity.new_issues_count_1" "repo.activity.new_issues_count_n"}} + </a> + {{end}} +</div> +{{end}} + +{{if .Permission.CanRead $.UnitTypeCode}} + {{if eq .Activity.Code.CommitCountInAllBranches 0}} + <div class="ui center aligned segment"> + <h4 class="ui header">{{ctx.Locale.Tr "repo.activity.no_git_activity"}}</h4> + </div> + {{end}} + {{if gt .Activity.Code.CommitCountInAllBranches 0}} + <div class="ui attached segment horizontal segments"> + <div class="ui attached segment text"> + {{ctx.Locale.Tr "repo.activity.git_stats_exclude_merges"}} + <strong>{{ctx.Locale.TrN .Activity.Code.AuthorCount "repo.activity.git_stats_author_1" "repo.activity.git_stats_author_n" .Activity.Code.AuthorCount}}</strong> + {{ctx.Locale.TrN .Activity.Code.AuthorCount "repo.activity.git_stats_pushed_1" "repo.activity.git_stats_pushed_n"}} + <strong>{{ctx.Locale.TrN .Activity.Code.CommitCount "repo.activity.git_stats_commit_1" "repo.activity.git_stats_commit_n" .Activity.Code.CommitCount}}</strong> + {{ctx.Locale.Tr "repo.activity.git_stats_push_to_branch" .Repository.DefaultBranch}} + <strong>{{ctx.Locale.TrN .Activity.Code.CommitCountInAllBranches "repo.activity.git_stats_commit_1" "repo.activity.git_stats_commit_n" .Activity.Code.CommitCountInAllBranches}}</strong> + {{ctx.Locale.Tr "repo.activity.git_stats_push_to_all_branches"}} + {{ctx.Locale.Tr "repo.activity.git_stats_on_default_branch" .Repository.DefaultBranch}} + <strong>{{ctx.Locale.TrN .Activity.Code.ChangedFiles "repo.activity.git_stats_file_1" "repo.activity.git_stats_file_n" .Activity.Code.ChangedFiles}}</strong> + {{ctx.Locale.TrN .Activity.Code.ChangedFiles "repo.activity.git_stats_files_changed_1" "repo.activity.git_stats_files_changed_n"}} + {{ctx.Locale.Tr "repo.activity.git_stats_additions"}} + <strong class="text green">{{ctx.Locale.TrN .Activity.Code.Additions "repo.activity.git_stats_addition_1" "repo.activity.git_stats_addition_n" .Activity.Code.Additions}}</strong> + {{ctx.Locale.Tr "repo.activity.git_stats_and_deletions"}} + <strong class="text red">{{ctx.Locale.TrN .Activity.Code.Deletions "repo.activity.git_stats_deletion_1" "repo.activity.git_stats_deletion_n" .Activity.Code.Deletions}}</strong>. + </div> + <div class="ui attached segment"> + <div id="repo-activity-top-authors-chart" data-locale-commit-activity="{{ctx.Locale.Tr "repo.activity.commit"}}"></div> + </div> + </div> + {{end}} +{{end}} + +{{if gt .Activity.PublishedReleaseCount 0}} + <h4 class="divider divider-text" id="published-releases"> + {{svg "octicon-tag" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.activity.title.releases_published_by" + (ctx.Locale.TrN .Activity.PublishedReleaseCount "repo.activity.title.releases_1" "repo.activity.title.releases_n" .Activity.PublishedReleaseCount) + (ctx.Locale.TrN .Activity.PublishedReleaseAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n" .Activity.PublishedReleaseAuthorCount) + }} + </h4> + <div class="list"> + {{range .Activity.PublishedReleases}} + <p class="desc"> + {{if .IsTag}} + <span class="ui yellow label">{{ctx.Locale.Tr "repo.activity.published_tag_label"}}</span> + {{else if .IsPrerelease}} + <span class="ui orange label">{{ctx.Locale.Tr "repo.activity.published_prerelease_label"}}</span> + {{else}} + <span class="ui green label">{{ctx.Locale.Tr "repo.activity.published_release_label"}}</span> + {{end}} + {{if .IsTag}} + <a href="{{$.RepoLink}}/src/{{.TagName | PathEscapeSegments}}">{{.TagName}}</a> + {{else}} + {{.TagName}} + <a class="title" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}">{{.Title | RenderEmoji $.Context | RenderCodeBlock}}</a> + {{end}} + {{TimeSinceUnix .CreatedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} + +{{if gt .Activity.MergedPRCount 0}} + <h4 class="divider divider-text" id="merged-pull-requests"> + {{svg "octicon-git-pull-request" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.activity.title.prs_merged_by" + (ctx.Locale.TrN .Activity.MergedPRCount "repo.activity.title.prs_1" "repo.activity.title.prs_n" .Activity.MergedPRCount) + (ctx.Locale.TrN .Activity.MergedPRAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n" .Activity.MergedPRAuthorCount) + }} + </h4> + <div class="list"> + {{range .Activity.MergedPRs}} + <p class="desc"> + <span class="ui purple label">{{ctx.Locale.Tr "repo.activity.merged_prs_label"}}</span> + #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{RenderRefIssueTitle $.Context .Issue.Title}}</a> + {{TimeSinceUnix .MergedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} + +{{if gt .Activity.OpenedPRCount 0}} + <h4 class="divider divider-text" id="proposed-pull-requests"> + {{svg "octicon-git-branch" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.activity.title.prs_opened_by" + (ctx.Locale.TrN .Activity.OpenedPRCount "repo.activity.title.prs_1" "repo.activity.title.prs_n" .Activity.OpenedPRCount) + (ctx.Locale.TrN .Activity.OpenedPRAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n" .Activity.OpenedPRAuthorCount) + }} + </h4> + <div class="list"> + {{range .Activity.OpenedPRs}} + <p class="desc"> + <span class="ui green label">{{ctx.Locale.Tr "repo.activity.opened_prs_label"}}</span> + #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{RenderRefIssueTitle $.Context .Issue.Title}}</a> + {{TimeSinceUnix .Issue.CreatedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} + +{{if gt .Activity.ClosedIssueCount 0}} + <h4 class="divider divider-text" id="closed-issues"> + {{svg "octicon-issue-closed" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.activity.title.issues_closed_from" + (ctx.Locale.TrN .Activity.ClosedIssueCount "repo.activity.title.issues_1" "repo.activity.title.issues_n" .Activity.ClosedIssueCount) + (ctx.Locale.TrN .Activity.ClosedIssueAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n" .Activity.ClosedIssueAuthorCount) + }} + </h4> + <div class="list"> + {{range .Activity.ClosedIssues}} + <p class="desc"> + <span class="ui red label">{{ctx.Locale.Tr "repo.activity.closed_issue_label"}}</span> + #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{RenderRefIssueTitle $.Context .Title}}</a> + {{TimeSinceUnix .ClosedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} + +{{if gt .Activity.OpenedIssueCount 0}} + <h4 class="divider divider-text" id="new-issues"> + {{svg "octicon-issue-opened" 16 "tw-mr-2"}} + {{ctx.Locale.Tr "repo.activity.title.issues_created_by" + (ctx.Locale.TrN .Activity.OpenedIssueCount "repo.activity.title.issues_1" "repo.activity.title.issues_n" .Activity.OpenedIssueCount) + (ctx.Locale.TrN .Activity.OpenedIssueAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n" .Activity.OpenedIssueAuthorCount) + }} + </h4> + <div class="list"> + {{range .Activity.OpenedIssues}} + <p class="desc"> + <span class="ui green label">{{ctx.Locale.Tr "repo.activity.new_issue_label"}}</span> + #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{RenderRefIssueTitle $.Context .Title}}</a> + {{TimeSinceUnix .CreatedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} + +{{if gt .Activity.UnresolvedIssueCount 0}} + <h4 class="divider divider-text" id="unresolved-conversations" data-tooltip-content="{{ctx.Locale.Tr "repo.activity.unresolved_conv_desc"}}"> + {{svg "octicon-comment-discussion" 16 "tw-mr-2"}} + {{ctx.Locale.TrN .Activity.UnresolvedIssueCount "repo.activity.title.unresolved_conv_1" "repo.activity.title.unresolved_conv_n" .Activity.UnresolvedIssueCount}} + </h4> + <div class="list"> + {{range .Activity.UnresolvedIssues}} + <p class="desc"> + <span class="ui green label">{{ctx.Locale.Tr "repo.activity.unresolved_conv_label"}}</span> + #{{.Index}} + {{if .IsPull}} + <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{RenderRefIssueTitle $.Context .Title}}</a> + {{else}} + <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{RenderRefIssueTitle $.Context .Title}}</a> + {{end}} + {{TimeSinceUnix .UpdatedUnix ctx.Locale}} + </p> + {{end}} + </div> +{{end}} diff --git a/templates/repo/recent_commits.tmpl b/templates/repo/recent_commits.tmpl new file mode 100644 index 0000000..5c241d6 --- /dev/null +++ b/templates/repo/recent_commits.tmpl @@ -0,0 +1,9 @@ +{{if .Permission.CanRead $.UnitTypeCode}} + <div id="repo-recent-commits-chart" + data-locale-loading-title="{{ctx.Locale.Tr "graphs.component_loading" (ctx.Locale.Tr "graphs.recent_commits.what")}}" + data-locale-loading-title-failed="{{ctx.Locale.Tr "graphs.component_loading_failed" (ctx.Locale.Tr "graphs.recent_commits.what")}}" + data-locale-loading-info="{{ctx.Locale.Tr "graphs.component_loading_info"}}" + data-locale-component-failed-to-load="{{ctx.Locale.Tr "graphs.component_failed_to_load"}}" + > + </div> +{{end}} diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl new file mode 100644 index 0000000..4c7f13d --- /dev/null +++ b/templates/repo/release/list.tmpl @@ -0,0 +1,142 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository releases"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + {{template "repo/release_tag_header" .}} + <ul id="release-list"> + {{range $idx, $info := .Releases}} + {{$release := $info.Release}} + <li class="ui grid"> + <div class="ui four wide column meta"> + <a class="muted" href="{{if not (and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode))}}#{{else}}{{$.RepoLink}}/src/tag/{{$release.TagName | PathEscapeSegments}}{{end}}" rel="nofollow">{{svg "octicon-tag" 16 "tw-mr-1"}}{{$release.TagName}}</a> + {{if and $release.Sha1 ($.Permission.CanRead $.UnitTypeCode)}} + <a class="muted tw-font-mono" href="{{$.RepoLink}}/src/commit/{{$release.Sha1}}" rel="nofollow">{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha $release.Sha1}}</a> + {{template "repo/branch_dropdown" dict "root" $ "release" $release}} + {{end}} + </div> + <div class="ui twelve wide column detail"> + <div class="tw-flex tw-items-center tw-justify-between tw-flex-wrap tw-mb-2"> + <h4 class="release-list-title tw-break-anywhere"> + <a href="{{$.RepoLink}}/releases/tag/{{$release.TagName | PathEscapeSegments}}">{{$release.Title}}</a> + {{template "repo/commit_statuses" dict "Status" $info.CommitStatus "Statuses" $info.CommitStatuses "AdditionalClasses" "tw-flex"}} + {{if $release.IsDraft}} + <span class="ui yellow label">{{ctx.Locale.Tr "repo.release.draft"}}</span> + {{else if $release.IsPrerelease}} + <span class="ui orange label">{{ctx.Locale.Tr "repo.release.prerelease"}}</span> + {{else if (not $release.IsTag)}} + <span class="ui green label">{{ctx.Locale.Tr "repo.release.stable"}}</span> + {{end}} + </h4> + <div> + {{if $.CanCreateRelease}} + <a class="muted" data-tooltip-content="{{ctx.Locale.Tr "repo.release.edit"}}" href="{{$.RepoLink}}/releases/edit/{{$release.TagName | PathEscapeSegments}}" rel="nofollow"> + {{svg "octicon-pencil"}} + </a> + {{end}} + </div> + </div> + <p class="text grey"> + <span class="author"> + {{if $release.OriginalAuthor}} + {{svg (MigrationIcon $release.Repo.GetOriginalURLHostname) 20 "tw-mr-1"}}{{$release.OriginalAuthor}} + {{else if $release.Publisher}} + {{ctx.AvatarUtils.Avatar $release.Publisher 20 "tw-mr-1"}} + <a href="{{$release.Publisher.HomeLink}}">{{$release.Publisher.GetDisplayName}}</a> + {{else}} + Ghost + {{end}} + </span> + <span class="released"> + {{ctx.Locale.Tr "repo.released_this"}} + </span> + {{if $release.CreatedUnix}} + <span class="time">{{TimeSinceUnix $release.CreatedUnix ctx.Locale}}</span> + {{end}} + {{if and (not $release.IsDraft) ($.Permission.CanRead $.UnitTypeCode)}} + | <span class="ahead"><a href="{{$.RepoLink}}/compare/{{$release.TagName | PathEscapeSegments}}...{{$release.TargetBehind | PathEscapeSegments}}">{{ctx.Locale.Tr "repo.release.ahead.commits" $release.NumCommitsBehind}}</a> {{ctx.Locale.Tr "repo.release.ahead.target" $release.TargetBehind}}</span> + {{end}} + </p> + {{template "repo/tag/verification_line" (dict "ctxData" $ "release" $release)}} + <div class="markup desc"> + {{$release.RenderedNote}} + </div> + {{$hasReleaseAttachment := gt (len $release.Attachments) 0}} + {{$hasArchiveLinks := and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) (not $release.HideArchiveLinks) ($.Permission.CanRead $.UnitTypeCode)}} + {{if or $hasArchiveLinks $hasReleaseAttachment}} + <div class="divider"></div> + <details class="download" {{if eq $idx 0}}open{{end}}> + <summary class="tw-my-4"> + {{ctx.Locale.Tr "repo.release.downloads"}} + </summary> + <ul class="list"> + {{if $hasArchiveLinks}} + <li> + <a class="archive-link tw-flex-1 flex-text-inline tw-font-bold" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow"> + {{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP) + </a> + <div class="tw-mr-1"> + <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.Zip "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.Zip)}}</span> + </div> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> + {{svg "octicon-info"}} + </span> + </li> + <li class="{{if $hasReleaseAttachment}}start-gap{{end}}"> + <a class="archive-link tw-flex-1 flex-text-inline tw-font-bold" href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow"> + {{svg "octicon-file-zip" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ) + </a> + <div class="tw-mr-1"> + <span class="text grey">{{ctx.Locale.TrN .Release.ArchiveDownloadCount.TarGz "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .Release.ArchiveDownloadCount.TarGz)}}</span> + </div> + <span data-tooltip-content="{{ctx.Locale.Tr "repo.release.system_generated"}}"> + {{svg "octicon-info"}} + </span> + </li> + {{if $hasReleaseAttachment}}<hr>{{end}} + {{end}} + {{range $release.Attachments}} + {{if .ExternalURL}} + <li> + <a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download> + {{svg "octicon-link-external" 16 "tw-mr-1"}}{{.Name}} + </a> + </li> + {{else}} + <li> + <a class="tw-flex-1 flex-text-inline tw-font-bold" target="_blank" rel="nofollow" href="{{.DownloadURL}}" download> + {{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}} + </a> + <div> + <span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span> + </div> + </li> + {{end}} + {{end}} + </ul> + </details> + {{end}} + <div class="dot"></div> + </div> + </li> + {{end}} + </ul> + + {{template "base/paginate" .}} + </div> +</div> + +{{if (and ($.Permission.CanWrite $.UnitTypeCode) .PageIsTagList)}} + <div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.release.delete_tag"}} + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.release.deletion_tag_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} + </div> +{{end}} + +{{template "base/footer" .}} diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl new file mode 100644 index 0000000..9bbd11f --- /dev/null +++ b/templates/repo/release/new.tmpl @@ -0,0 +1,183 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository new release"> + {{template "repo/header" .}} + <div class="ui container"> + <h2 class="ui dividing header"> + {{if .PageIsEditRelease}} + {{ctx.Locale.Tr "repo.release.edit_release"}} + <div class="sub header">{{ctx.Locale.Tr "repo.release.edit_subheader"}}</div> + {{else}} + {{ctx.Locale.Tr "repo.release.new_release"}} + <div class="sub header">{{ctx.Locale.Tr "repo.release.new_subheader"}}</div> + {{end}} + </h2> + {{template "base/alert" .}} + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div class="ui seven wide target"> + <div class="inline field {{if .Err_TagName}}error{{end}}"> + {{if .PageIsEditRelease}} + <b>{{.tag_name}}</b><span class="at">@</span><strong>{{.tag_target}}</strong> + {{else}} + <input id="tag-name" name="tag_name" value="{{.tag_name}}" aria-label="{{ctx.Locale.Tr "repo.release.tag_name"}}" placeholder="{{ctx.Locale.Tr "repo.release.tag_name"}}" autofocus required maxlength="255"> + <input id="tag-name-editor" type="hidden" data-existing-tags="{{JsonUtils.EncodeToString .Tags}}" data-tag-helper="{{ctx.Locale.Tr "repo.release.tag_helper"}}" data-tag-helper-new="{{ctx.Locale.Tr "repo.release.tag_helper_new"}}" data-tag-helper-existing="{{ctx.Locale.Tr "repo.release.tag_helper_existing"}}"> + <div id="tag-target-selector" class="tw-inline-block"> + <span class="at">@</span> + <div class="ui selection dropdown"> + <input type="hidden" name="tag_target" value="{{.tag_target}}"> + {{svg "octicon-git-branch"}} + <div class="text"> + {{ctx.Locale.Tr "repo.release.target"}} : + <strong id="repo-branch-current">{{.Repository.DefaultBranch}}</strong> + </div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + {{range .Branches}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + </div> + <div> + <span id="tag-helper" class="help tw-mt-2 tw-pb-0">{{ctx.Locale.Tr "repo.release.tag_helper"}}</span> + </div> + {{end}} + </div> + </div> + <div class="eleven wide tw-pt-0"> + <div class="field {{if .Err_Title}}error{{end}}"> + <input name="title" aria-label="{{ctx.Locale.Tr "repo.release.title"}}" placeholder="{{ctx.Locale.Tr "repo.release.title"}}" value="{{.title}}" autofocus maxlength="255"> + </div> + <div class="field"> + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "TextareaContent" .content + "TextareaPlaceholder" (ctx.Locale.Tr "repo.release.message") + "TextareaAriaLabel" (ctx.Locale.Tr "repo.release.message") + "DropzoneParentContainer" "form" + "EasyMDE" true + )}} + </div> + {{range .attachments}} + <div class="field flex-text-block" id="attachment-{{.ID}}"> + <div class="flex-text-inline tw-flex-1"> + <div class="flex-text-inline tw-shrink-0" title="{{ctx.Locale.Tr "repo.release.type_attachment"}}"> + {{if .ExternalURL}} + {{svg "octicon-link-external" 16 "tw-mr-2"}} + {{else}} + {{svg "octicon-package" 16 "tw-mr-2"}} + {{end}} + </div> + <input name="attachment-edit-name-{{.UUID}}" placeholder="{{ctx.Locale.Tr "repo.release.asset_name"}}" class="attachment_edit" required value="{{.Name}}"> + <input name="attachment-del-{{.UUID}}" type="hidden" + value="false"> + {{if .ExternalURL}} + <input name="attachment-edit-exturl-{{.UUID}}" placeholder="{{ctx.Locale.Tr "repo.release.asset_external_url"}}" class="attachment_edit" required value="{{.ExternalURL}}"> + {{else}} + <span class="ui text grey tw-whitespace-nowrap tw-ml-auto tw-pl-3">{{ctx.Locale.TrN + .DownloadCount "repo.release.download_count_one" + "repo.release.download_count_few" (ctx.Locale.PrettyNumber + .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span> + {{end}} + </div> + <a class="ui mini red button remove-rel-attach tw-ml-3" data-id="{{.ID}}" data-uuid="{{.UUID}}"> + {{ctx.Locale.Tr "remove"}} + </a> + </div> + {{end}} + <div class="field flex-text-block tw-hidden" id="attachment-template"> + <div class="flex-text-inline tw-flex-1"> + <div class="flex-text-inline tw-shrink-0" title="{{ctx.Locale.Tr "repo.release.type_external_asset"}}"> + {{svg "octicon-link-external" 16 "tw-mr-2"}} + </div> + <input name="attachment-template-new-name" placeholder="{{ctx.Locale.Tr "repo.release.asset_name"}}" class="attachment_edit"> + <input name="attachment-template-new-exturl" placeholder="{{ctx.Locale.Tr "repo.release.asset_external_url"}}" class="attachment_edit"> + </div> + <a class="ui mini red button remove-rel-attach tw-ml-3"> + {{ctx.Locale.Tr "remove"}} + </a> + </div> + <button type="button" class="ui mini button tw-float-right tw-mb-4 tw-mt-2" id="add-external-link"> + {{ctx.Locale.Tr "repo.release.add_external_asset"}} + </button> + {{if .IsAttachmentEnabled}} + <div class="field"> + {{template "repo/upload" .}} + </div> + {{end}} + </div> + <div class="divider"></div> + <div class="ui"> + <div> + <fieldset> + {{if not .PageIsEditRelease}} + <label> + <input type="checkbox" name="add_tag_msg"> + {{ctx.Locale.Tr "repo.release.add_tag_msg"}} + </label> + {{else}} + <input type="hidden" name="add_tag_msg" value="false"> + {{end}} + <label> + <input type="checkbox" name="prerelease" {{if .prerelease}}checked{{end}}> + {{ctx.Locale.Tr "repo.release.prerelease_desc"}} + <span class="help">{{ctx.Locale.Tr "repo.release.prerelease_helper"}}</span> + </label> + {{if not .DisableDownloadSourceArchives}} + <label> + <input type="checkbox" name="hide_archive_links" {{if .hide_archive_links}}checked{{end}}> + {{ctx.Locale.Tr "repo.release.hide_archive_links"}} + <span class="help">{{ctx.Locale.Tr "repo.release.hide_archive_links_helper"}}</span> + </label> + {{end}} + </fieldset> + <div class="divider tw-mt-0"></div> + <div class="tw-flex tw-justify-end button-row"> + {{if .PageIsEditRelease}} + <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}}"> + {{ctx.Locale.Tr "repo.release.delete_release"}} + </a> + {{if .IsDraft}} + <button class="ui small button" type="submit" name="draft" value="{{ctx.Locale.Tr "repo.release.save_draft"}}">{{ctx.Locale.Tr "repo.release.save_draft"}}</button> + <button class="ui small primary button"> + {{ctx.Locale.Tr "repo.release.publish"}} + </button> + {{else}} + <button class="ui small primary button"> + {{ctx.Locale.Tr "repo.release.edit_release"}} + </button> + {{end}} + {{else}} + {{if not .tag_name}} + <button class="ui small button" name="tag_only" value="1">{{ctx.Locale.Tr "repo.release.add_tag"}}</button> + {{end}} + <button class="ui small button" name="draft" value="1">{{ctx.Locale.Tr "repo.release.save_draft"}}</button> + <button class="ui small primary button"> + {{ctx.Locale.Tr "repo.release.publish"}} + </button> + {{end}} + </div> + </div> + </div> + </form> + </div> +</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> + {{template "base/modal_actions_confirm" .}} + </div> +{{end}} +{{template "base/footer" .}} diff --git a/templates/repo/release_tag_header.tmpl b/templates/repo/release_tag_header.tmpl new file mode 100644 index 0000000..dafe9f2 --- /dev/null +++ b/templates/repo/release_tag_header.tmpl @@ -0,0 +1,31 @@ +{{$canReadReleases := $.Permission.CanRead $.UnitTypeReleases}} +{{$canReadCode := $.Permission.CanRead $.UnitTypeCode}} + +{{if $canReadReleases}} + <div class="tw-flex"> + <div class="tw-flex-1 tw-flex tw-items-center"> + <h2 class="ui compact small menu small-menu-items"> + <a class="{{if and .PageIsReleaseList (not .PageIsSingleTag)}}active {{end}}item" href="{{.RepoLink}}/releases">{{ctx.Locale.TrN .NumReleases "repo.n_release_one" "repo.n_release_few" (ctx.Locale.PrettyNumber .NumReleases)}}</a> + {{if $canReadCode}} + <a class="{{if or .PageIsTagList .PageIsSingleTag}}active {{end}}item" href="{{.RepoLink}}/tags">{{ctx.Locale.TrN .NumTags "repo.n_tag_one" "repo.n_tag_few" (ctx.Locale.PrettyNumber .NumTags)}}</a> + {{end}} + </h2> + </div> + <div class="button-row"> + {{if .EnableFeed}} + <a class="ui small button" href="{{.RepoLink}}/{{if .PageIsTagList}}tags{{else}}releases{{end}}.rss"> + {{svg "octicon-rss" 16}} {{ctx.Locale.Tr "rss_feed"}} + </a> + {{end}} + {{if and (not .PageIsTagList) .CanCreateRelease}} + <a class="ui small primary button" href="{{$.RepoLink}}/releases/new"> + {{ctx.Locale.Tr "repo.release.new_release"}} + </a> + {{end}} + </div> + </div> + <div class="divider"></div> +{{else if $canReadCode}} + {{/* if the "repo.releases" unit is disabled, only show the "commits / branches / tags" sub menu */}} + {{template "repo/sub_menu" .}} +{{end}} diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl new file mode 100644 index 0000000..6d114c8 --- /dev/null +++ b/templates/repo/search.tmpl @@ -0,0 +1,14 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository file list"> + {{template "repo/header" .}} + <div class="ui container"> + {{if $.CodeIndexerDisabled}} + {{$branchURLPrefix := printf "%s/search/branch/" $.RepoLink}} + {{$tagURLPrefix := printf "%s/search/tag/" $.RepoLink}} + {{$suffix := printf "?q=%s&fuzzy=%t" (.Keyword|QueryEscape) .IsFuzzy}} + {{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mb-3" "branchURLPrefix" $branchURLPrefix "branchURLSuffix" $suffix "tagURLPrefix" $tagURLPrefix "tagURLSuffix" $suffix}} + {{end}} + {{template "shared/search/code/search" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/search_name.tmpl b/templates/repo/search_name.tmpl new file mode 100644 index 0000000..951f168 --- /dev/null +++ b/templates/repo/search_name.tmpl @@ -0,0 +1 @@ +<span class="gt-ellipsis">{{.Name}}{{if DefaultShowFullName}}<span class="search-fullname"> {{.FullName}}</span>{{end}}</span> diff --git a/templates/repo/settings/actions.tmpl b/templates/repo/settings/actions.tmpl new file mode 100644 index 0000000..f38ab5b --- /dev/null +++ b/templates/repo/settings/actions.tmpl @@ -0,0 +1,11 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings actions")}} + <div class="repo-setting-content"> + {{if eq .PageType "runners"}} + {{template "shared/actions/runner_list" .}} + {{else if eq .PageType "secrets"}} + {{template "shared/secrets/add_list" .}} + {{else if eq .PageType "variables"}} + {{template "shared/variables/variable_list" .}} + {{end}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/branches.tmpl b/templates/repo/settings/branches.tmpl new file mode 100644 index 0000000..52c0c2c --- /dev/null +++ b/templates/repo/settings/branches.tmpl @@ -0,0 +1,78 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}} + <div class="repo-setting-content"> + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{ctx.Locale.Tr "repo.settings.archive.branchsettings_unavailable"}} + </div> + {{else}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.default_branch"}} + </h4> + <div class="ui attached segment"> + <p> + {{ctx.Locale.Tr "repo.settings.default_branch_desc"}} + </p> + <form class="tw-flex" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="default_branch"> + {{if not .Repository.IsEmpty}} + <div class="ui dropdown selection search tw-flex-1 tw-mr-2 tw-max-w-96"> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <input type="hidden" name="branch" value="{{.Repository.DefaultBranch}}"> + <div class="default text">{{.Repository.DefaultBranch}}</div> + <div class="menu"> + {{range .Branches}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.branches.update_default_branch"}}</button> + {{end}} + </form> + </div> + + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.protected_branch"}} + <div class="ui right"> + <a class="ui primary tiny button" href="{{$.Repository.Link}}/settings/branches/edit">{{ctx.Locale.Tr "repo.settings.branches.add_new_rule"}}</a> + </div> + </h4> + + <div class="ui attached segment"> + <div class="flex-list"> + {{range .ProtectedBranches}} + <div class="flex-item tw-items-center"> + <div class="flex-item-main"> + <div class="flex-item-title"> + <div class="ui basic primary label">{{.RuleName}}</div> + </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}}"> + {{ctx.Locale.Tr "repo.settings.protected_branch.delete_rule"}} + </button> + </div> + </div> + {{else}} + <div class="flex-item center aligned"> + {{ctx.Locale.Tr "repo.settings.no_protected_branch"}} + </div> + {{end}} + </div> + </div> + {{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> + {{template "base/modal_actions_confirm" .}} +</div> + +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/collaboration.tmpl b/templates/repo/settings/collaboration.tmpl new file mode 100644 index 0000000..8028642 --- /dev/null +++ b/templates/repo/settings/collaboration.tmpl @@ -0,0 +1,117 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings collaboration")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.collaboration"}} + </h4> + {{if .Collaborators}} + <div class="ui attached segment"> + <div class="flex-list"> + {{range .Collaborators}} + <div class="flex-item tw-items-center"> + <div class="flex-item-leading"> + <a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a> + </div> + <div class="flex-item-main"> + <div class="flex-item-title"> + {{template "shared/user/name" .}} + </div> + </div> + <div class="flex-item-trailing"> + <div class="flex-text-block"> + {{svg "octicon-shield-lock"}} + <div class="ui inline dropdown access-mode" data-url="{{$.Link}}/access_mode" data-uid="{{.ID}}" data-last-value="{{printf "%d" .Collaboration.Mode}}"> + <div class="text">{{if eq .Collaboration.Mode 1}}{{ctx.Locale.Tr "repo.settings.collaboration.read"}}{{else if eq .Collaboration.Mode 2}}{{ctx.Locale.Tr "repo.settings.collaboration.write"}}{{else if eq .Collaboration.Mode 3}}{{ctx.Locale.Tr "repo.settings.collaboration.admin"}}{{else}}{{ctx.Locale.Tr "repo.settings.collaboration.undefined"}}{{end}}</div> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item" data-text="{{ctx.Locale.Tr "repo.settings.collaboration.admin"}}" data-value="3">{{ctx.Locale.Tr "repo.settings.collaboration.admin"}}</div> + <div class="item" data-text="{{ctx.Locale.Tr "repo.settings.collaboration.write"}}" data-value="2">{{ctx.Locale.Tr "repo.settings.collaboration.write"}}</div> + <div class="item" data-text="{{ctx.Locale.Tr "repo.settings.collaboration.read"}}" data-value="1">{{ctx.Locale.Tr "repo.settings.collaboration.read"}}</div> + </div> + </div> + </div> + <button class="ui red tiny button inline delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}"> + {{ctx.Locale.Tr "repo.settings.delete_collaborator"}} + </button> + </div> + </div> + {{end}} + </div> + </div> + {{end}} + <div class="ui bottom attached segment"> + <form class="ui form" id="repo-collab-form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div id="search-user-box" class="ui search input tw-align-middle"> + <input class="prompt" name="collaborator" placeholder="{{ctx.Locale.Tr "search.user_kind"}}" autocomplete="off" autofocus required> + </div> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.add_collaborator"}}</button> + </form> + </div> + + {{if .RepoOwnerIsOrganization}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.teams"}} + </h4> + {{$allowedToChangeTeams := (or (.Org.RepoAdminChangeTeamAccess) (.Permission.IsOwner))}} + {{if .Teams}} + <div class="ui attached segment"> + <div class="flex-list"> + {{range $t, $team := .Teams}} + <div class="flex-item"> + <div class="flex-item-main"> + <a class="flex-item-title text primary" href="{{AppSubUrl}}/org/{{$.OrgName|PathEscape}}/teams/{{.LowerName|PathEscape}}"> + {{.Name}} + </a> + <div class="flex-item-body flex-text-block"> + {{svg "octicon-shield-lock"}} + {{if eq .AccessMode 1}}{{ctx.Locale.Tr "repo.settings.collaboration.read"}}{{else if eq .AccessMode 2}}{{ctx.Locale.Tr "repo.settings.collaboration.write"}}{{else if eq .AccessMode 3}}{{ctx.Locale.Tr "repo.settings.collaboration.admin"}}{{else if eq .AccessMode 4}}{{ctx.Locale.Tr "repo.settings.collaboration.owner"}}{{else}}{{ctx.Locale.Tr "repo.settings.collaboration.undefined"}}{{end}} + </div> + {{if or (eq .AccessMode 1) (eq .AccessMode 2)}} + {{$first := true}} + <div class="flex-item-body" data-tooltip-content="{{ctx.Locale.Tr "repo.settings.change_team_permission_tip"}}"> + Sections: {{range $u, $unit := $.Units}}{{if and ($.Repo.UnitEnabled $.Context $unit.Type) ($team.UnitEnabled $.Context $unit.Type)}}{{if $first}}{{$first = false}}{{else}}, {{end}}{{ctx.Locale.Tr $unit.NameKey}}{{end}}{{end}} {{if $first}}None{{end}} + </div> + {{end}} + </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}}"> + {{ctx.Locale.Tr "repo.settings.delete_collaborator"}} + </button> + </div> + {{end}} + </div> + {{end}} + </div> + </div> + {{end}} + <div class="ui bottom attached segment"> + {{if $allowedToChangeTeams}} + <form class="ui form" id="repo-collab-team-form" action="{{.Link}}/team" method="post"> + {{.CsrfTokenHtml}} + <div id="search-team-box" class="ui search input tw-align-middle" data-org-name="{{.OrgName}}"> + <input class="prompt" name="team" placeholder="{{ctx.Locale.Tr "search.team_kind"}}" autocomplete="off" autofocus required> + </div> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.add_team"}}</button> + </form> + {{else}} + <div class="item"> + {{ctx.Locale.Tr "repo.settings.change_team_access_not_allowed"}} + </div> + {{end}} + </div> + {{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> + {{template "base/modal_actions_confirm" .}} +</div> + +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl new file mode 100644 index 0000000..4bc3abf --- /dev/null +++ b/templates/repo/settings/deploy_keys.tmpl @@ -0,0 +1,86 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.deploy_keys"}} + <div class="ui right"> + {{if not .DisableSSH}} + <button class="ui primary tiny show-panel toggle button" data-panel="#add-deploy-key-panel">{{ctx.Locale.Tr "repo.settings.add_deploy_key"}}</button> + {{else}} + <button class="ui primary tiny button disabled">{{ctx.Locale.Tr "settings.ssh_disabled"}}</button> + {{end}} + </div> + </h4> + <div class="ui attached segment"> + <div class="{{if not .HasError}}tw-hidden{{end}} tw-mb-4" id="add-deploy-key-panel"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + {{ctx.Locale.Tr "repo.settings.deploy_key_desc"}} + </div> + <div class="field {{if .Err_Title}}error{{end}}"> + <label for="ssh-key-title">{{ctx.Locale.Tr "repo.settings.title"}}</label> + <input id="ssh-key-title" name="title" value="{{.title}}" autofocus required> + </div> + <div class="field {{if .Err_Content}}error{{end}}"> + <label for="ssh-key-content">{{ctx.Locale.Tr "repo.settings.deploy_key_content"}}</label> + <textarea id="ssh-key-content" name="content" placeholder="{{ctx.Locale.Tr "settings.key_content_ssh_placeholder"}}" required>{{.content}}</textarea> + </div> + <div class="field"> + <div class="ui checkbox {{if .Err_IsWritable}}error{{end}}"> + <input id="ssh-key-is-writable" name="is_writable" type="checkbox" value="1"> + <label for="ssh-key-is-writable"> + {{ctx.Locale.Tr "repo.settings.is_writable"}} + </label> + <small class="tw-pl-[26px]">{{ctx.Locale.Tr "repo.settings.is_writable_info"}}</small> + </div> + </div> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.settings.add_deploy_key"}} + </button> + <button class="ui hide-panel button" data-panel="#add-deploy-key-panel"> + {{ctx.Locale.Tr "cancel"}} + </button> + </form> + </div> + {{if .Deploykeys}} + <div class="flex-list"> + {{range .Deploykeys}} + <div class="flex-item"> + <div class="flex-item-leading"> + <span class="text {{if .HasRecentActivity}}green{{end}}" {{if .HasRecentActivity}}data-tooltip-content="{{ctx.Locale.Tr "settings.key_state_desc"}}"{{end}}>{{svg "octicon-key" 32}}</span> + </div> + <div class="flex-item-main"> + <div class="flex-item-title">{{.Name}}</div> + <div class="flex-item-body"> + {{.Fingerprint}} + </div> + <div class="flex-item-body"> + <p>{{ctx.Locale.Tr "settings.added_on" (DateTime "short" .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{DateTime "short" .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}} - <span>{{ctx.Locale.Tr "settings.can_read_info"}}{{if not .IsReadOnly}} / {{ctx.Locale.Tr "settings.can_write_info"}} {{end}}</span></p> + </div> + </div> + <div class="flex-item-trailing"> + <button class="ui red tiny button delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}"> + {{ctx.Locale.Tr "settings.delete_key"}} + </button> + </div> + </div> + {{end}} + </div> + {{else}} + {{ctx.Locale.Tr "repo.settings.no_deploy_keys"}} + {{end}} + </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> + {{template "base/modal_actions_confirm" .}} +</div> + +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/githook_edit.tmpl b/templates/repo/settings/githook_edit.tmpl new file mode 100644 index 0000000..e20f51b --- /dev/null +++ b/templates/repo/settings/githook_edit.tmpl @@ -0,0 +1,27 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit githook")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.githooks"}} + </h4> + <div class="ui attached segment"> + <p>{{ctx.Locale.Tr "repo.settings.githook_edit_desc"}}</p> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + {{with .Hook}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.settings.githook_name"}}</label> + <span class="hook-filename">{{.Name}}</span> + </div> + <div class="field"> + <label for="content">{{ctx.Locale.Tr "repo.settings.githook_content"}}</label> + <textarea id="content" name="content" class="tw-hidden">{{if .IsActive}}{{.Content}}{{else}}{{.Sample}}{{end}}</textarea> + <div class="editor-loading is-loading"></div> + </div> + <div class="inline field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_githook"}}</button> + </div> + {{end}} + </form> + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/githooks.tmpl b/templates/repo/settings/githooks.tmpl new file mode 100644 index 0000000..1a603f9 --- /dev/null +++ b/templates/repo/settings/githooks.tmpl @@ -0,0 +1,23 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings githooks")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.githooks"}} + </h4> + <div class="ui attached segment"> + <div class="ui list"> + <div class="item"> + {{ctx.Locale.Tr "repo.settings.githooks_desc"}} + </div> + {{range .Hooks}} + <div class="item truncated-item-container"> + <span class="text {{if .IsActive}}green{{else}}grey{{end}} tw-mr-2">{{svg "octicon-dot-fill" 22}}</span> + <span class="text truncate tw-flex-1 tw-mr-2">{{.Name}}</span> + <a class="muted tw-float-right tw-p-2" href="{{$.RepoLink}}/settings/hooks/git/{{.Name|PathEscape}}"> + {{svg "octicon-pencil"}} + </a> + </div> + {{end}} + </div> + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/layout_footer.tmpl b/templates/repo/settings/layout_footer.tmpl new file mode 100644 index 0000000..60cad3f --- /dev/null +++ b/templates/repo/settings/layout_footer.tmpl @@ -0,0 +1,11 @@ +{{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} +<div class="page-content"> + <div class="repo-layout-right"> + <div> + {{/* block: repo-setting-content */}} +{{end}} + + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/settings/layout_head.tmpl b/templates/repo/settings/layout_head.tmpl new file mode 100644 index 0000000..efec9bf --- /dev/null +++ b/templates/repo/settings/layout_head.tmpl @@ -0,0 +1,14 @@ +{{template "base/head" .ctxData}} +<div role="main" aria-label="{{.ctxData.Title}}" class="page-content {{.pageClass}}"> + {{template "repo/header" .ctxData}} + <div class="ui container flex-container"> + {{template "repo/settings/navbar" .ctxData}} + <div class="flex-container-main"> + {{template "base/alert" .ctxData}} + {{/* block: repo-setting-content */}} + +{{if false}}{{/* to make html structure "likely" complete to prevent IDE warnings */}} + </div> + </div> +</div> +{{end}} diff --git a/templates/repo/settings/lfs.tmpl b/templates/repo/settings/lfs.tmpl new file mode 100644 index 0000000..6d7aac2 --- /dev/null +++ b/templates/repo/settings/lfs.tmpl @@ -0,0 +1,53 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.lfs_filelist"}} ({{ctx.Locale.Tr "admin.total" .Total}}) + <div class="ui right"> + <a class="ui tiny button" href="{{.Link}}/locks">{{ctx.Locale.Tr "repo.settings.lfs_locks"}}</a> + <a class="ui primary tiny button" href="{{.Link}}/pointers"> {{ctx.Locale.Tr "repo.settings.lfs_findpointerfiles"}}</a> + </div> + </h4> + <table id="lfs-files-table" class="ui attached segment single line table"> + <tbody> + {{range .LFSFiles}} + <tr> + <td> + <a href="{{$.Link}}/show/{{.Oid}}" title="{{.Oid}}" class="ui brown button tw-font-mono"> + {{ShortSha .Oid}} + </a> + </td> + <td>{{ctx.Locale.TrSize .Size}}</td> + <td>{{TimeSince .CreatedUnix.AsTime ctx.Locale}}</td> + <td class="right aligned"> + <a class="ui primary button" href="{{$.Link}}/find?oid={{.Oid}}&size={{.Size}}">{{ctx.Locale.Tr "repo.settings.lfs_findcommits"}}</a> + <button class="ui basic show-modal icon button red" data-modal="#delete-{{.Oid}}"> + <span class="btn-octicon btn-octicon-danger" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.delete_this_file"}}">{{svg "octicon-trash"}}</span> + </button> + </td> + </tr> + {{else}} + <tr> + <td colspan="4">{{ctx.Locale.Tr "repo.settings.lfs_no_lfs_files"}}</td> + </tr> + {{end}} + </tbody> + </table> + {{template "base/paginate" .}} + {{range .LFSFiles}} + <div class="ui g-modal-confirm modal" id="delete-{{.Oid}}"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.lfs_delete" .Oid}} + </div> + <div class="content"> + <p> + {{ctx.Locale.Tr "repo.settings.lfs_delete_warning"}} + </p> + <form class="ui form" action="{{$.Link}}/delete/{{.Oid}}" method="post"> + {{$.CsrfTokenHtml}} + {{template "base/modal_actions_confirm" (dict "ModalButtonColors" "primary")}} + </form> + </div> + </div> + {{end}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/lfs_file.tmpl b/templates/repo/settings/lfs_file.tmpl new file mode 100644 index 0000000..5bcd2af --- /dev/null +++ b/templates/repo/settings/lfs_file.tmpl @@ -0,0 +1,57 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} + <div class="user-main-content twelve wide column content repository file list"> + <div class="tab-size-8 non-diff-file-content"> + <h4 class="ui top attached header"> + <a href="{{.LFSFilesLink}}">{{ctx.Locale.Tr "repo.settings.lfs"}}</a> / <span class="truncate sha">{{.LFSFile.Oid}}</span> + <div class="ui right"> + {{if .EscapeStatus.Escaped}} + <a class="ui tiny basic button unescape-button tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a> + <a class="ui tiny basic button escape-button">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a> + {{end}} + <a class="ui primary tiny button" href="{{.LFSFilesLink}}/find?oid={{.LFSFile.Oid}}&size={{.LFSFile.Size}}">{{ctx.Locale.Tr "repo.settings.lfs_findcommits"}}</a> + </div> + </h4> + <div class="ui bottom attached table unstackable segment"> + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}} + <div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsPlainText}} plain-text{{else if .IsTextFile}} code-view{{end}}"> + {{if .IsMarkup}} + {{if .FileContent}}{{.FileContent | SafeHTML}}{{end}} + {{else if .IsPlainText}} + <pre>{{if .FileContent}}{{.FileContent | SafeHTML}}{{end}}</pre> + {{else if not .IsTextFile}} + <div class="view-raw"> + {{if .IsImageFile}} + <img src="{{$.RawFileLink}}"> + {{else if .IsVideoFile}} + <video controls src="{{$.RawFileLink}}"> + <strong>{{ctx.Locale.Tr "repo.video_not_supported_in_browser"}}</strong> + </video> + {{else if .IsAudioFile}} + <audio controls src="{{$.RawFileLink}}"> + <strong>{{ctx.Locale.Tr "repo.audio_not_supported_in_browser"}}</strong> + </audio> + {{else if .IsPDFFile}} + <div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "diff.view_file"}}"></div> + {{else}} + <a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a> + {{end}} + </div> + {{else if .FileSize}} + <table> + <tbody> + <tr> + {{if .IsFileTooLarge}} + <td><strong>{{ctx.Locale.Tr "repo.file_too_large"}}</strong></td> + {{else}} + <td class="lines-num">{{.LineNums}}</td> + <td class="lines-code"><pre><code class="{{.HighlightClass}}"><ol>{{.FileContent}}</ol></code></pre></td> + {{end}} + </tr> + </tbody> + </table> + {{end}} + </div> + </div> + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/lfs_file_find.tmpl b/templates/repo/settings/lfs_file_find.tmpl new file mode 100644 index 0000000..809a028 --- /dev/null +++ b/templates/repo/settings/lfs_file_find.tmpl @@ -0,0 +1,46 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} + <div class="user-main-content twelve wide column content repository file list"> + <div class="tab-size-8 non-diff-file-content"> + <h4 class="ui top attached header"> + <a href="{{.LFSFilesLink}}">{{ctx.Locale.Tr "repo.settings.lfs"}}</a> / <span class="truncate sha">{{.Oid}}</span> + </h4> + <table id="lfs-files-find-table" class="ui attached segment single line table"> + <tbody> + {{range .Results}} + <tr> + <td> + {{svg "octicon-file"}} + <a href="{{$.RepoLink}}/src/commit/{{.SHA}}/{{PathEscapeSegments .Name}}" title="{{.Name}}">{{.Name}}</a> + </td> + <td class="message"> + <span class="truncate"> + <a href="{{$.RepoLink}}/commit/{{.SHA}}" title="{{.Summary}}"> + {{.Summary | RenderEmoji $.Context}} + </a> + </span> + </td> + <td> + <span class="text grey">{{svg "octicon-git-branch"}}{{.BranchName}}</span> + </td> + <td> + {{if .ParentHashes}} + {{ctx.Locale.Tr "repo.diff.parent"}} + {{range .ParentHashes}} + <a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{.String}}">{{ShortSha .String}}</a> + {{end}} + {{end}} + {{ctx.Locale.Tr "repo.diff.commit"}} + <a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{.SHA}}">{{ShortSha .SHA}}</a> + </td> + <td>{{TimeSince .When ctx.Locale}}</td> + </tr> + {{else}} + <tr> + <td colspan="5">{{ctx.Locale.Tr "repo.settings.lfs_lfs_file_no_commits"}}</td> + </tr> + {{end}} + </tbody> + </table> + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/lfs_locks.tmpl b/templates/repo/settings/lfs_locks.tmpl new file mode 100644 index 0000000..9a18f52 --- /dev/null +++ b/templates/repo/settings/lfs_locks.tmpl @@ -0,0 +1,56 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} + <div class="user-main-content twelve wide column content repository file list"> + <div class="tab-size-8 non-diff-file-content"> + <h4 class="ui top attached header"> + <a href="{{.LFSFilesLink}}">{{ctx.Locale.Tr "repo.settings.lfs"}}</a> / {{ctx.Locale.Tr "repo.settings.lfs_locks"}} ({{ctx.Locale.Tr "admin.total" .Total}}) + </h4> + <div class="ui attached segment"> + <form class="ui form ignore-dirty" method="post"> + {{$.CsrfTokenHtml}} + <div class="ui fluid action input"> + <input name="path" value="" placeholder="{{ctx.Locale.Tr "repo.settings.lfs_lock_path"}}" autofocus> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.lfs_lock"}}</button> + </div> + </form> + </div> + <table id="lfs-files-locks-table" class="ui attached segment single line table"> + <tbody> + {{range $index, $lock := .LFSLocks}} + <tr> + <td> + {{if index $.Linkable $index}} + {{svg "octicon-file"}} + <a href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments $.Repository.DefaultBranch}}/{{PathEscapeSegments $lock.Path}}" title="{{$lock.Path}}">{{$lock.Path}}</a> + {{else}} + {{svg "octicon-diff"}} + <span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.lfs_lock_file_no_exist"}}">{{$lock.Path}}</span> + {{end}} + {{if not (index $.Lockables $index)}} + <span data-tooltip-content="{{ctx.Locale.Tr "repo.settings.lfs_noattribute"}}">{{svg "octicon-alert"}}</span> + {{end}} + </td> + <td> + <a href="{{$lock.Owner.HomeLink}}"> + {{ctx.AvatarUtils.Avatar $lock.Owner}} + {{$lock.Owner.DisplayName}} + </a> + </td> + <td>{{TimeSince .Created ctx.Locale}}</td> + <td class="right aligned"> + <form action="{{$.LFSFilesLink}}/locks/{{$lock.ID}}/unlock" method="post"> + {{$.CsrfTokenHtml}} + <button class="ui primary button"><span class="btn-octicon">{{svg "octicon-lock"}}</span>{{ctx.Locale.Tr "repo.settings.lfs_force_unlock"}}</button> + </form> + </td> + </tr> + {{else}} + <tr> + <td colspan="4">{{ctx.Locale.Tr "repo.settings.lfs_locks_no_locks"}}</td> + </tr> + {{end}} + </tbody> + </table> + {{template "base/paginate" .}} + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/lfs_pointers.tmpl b/templates/repo/settings/lfs_pointers.tmpl new file mode 100644 index 0000000..a0bb8c4 --- /dev/null +++ b/templates/repo/settings/lfs_pointers.tmpl @@ -0,0 +1,56 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings lfs")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.lfs_pointers.found" .NumPointers .NumAssociated .NumNotAssociated .NumNoExist}} + {{if gt .NumAssociatable 0}} + <div class="ui right"> + <form class="ui form" method="post" action="{{$.Link}}/associate"> + {{.CsrfTokenHtml}} + {{range .Pointers}} + {{if .Associatable}} + <input type="hidden" name="oid" value="{{.Oid}} {{.Size}}"> + {{end}} + {{end}} + <button class="ui primary tiny button">{{ctx.Locale.Tr "repo.settings.lfs_pointers.associateAccessible" $.NumAssociatable}}</button> + </form> + </div> + {{end}} + </h4> + <div class="ui attached segment"> + <table id="lfs-files-table" class="ui fixed single line table"> + <thead> + <tr> + <th class="three wide">{{ctx.Locale.Tr "repo.settings.lfs_pointers.sha"}}</th> + <th class="four wide">{{ctx.Locale.Tr "repo.settings.lfs_pointers.oid"}}</th> + <th class="two wide">{{ctx.Locale.Tr "repo.settings.lfs_pointers.inRepo"}}</th> + <th class="two wide">{{ctx.Locale.Tr "repo.settings.lfs_pointers.exists"}}</th> + <th class="two wide" data-tooltip-content="{{ctx.Locale.Tr "repo.settings.lfs_pointers.accessible"}}">{{ctx.Locale.Tr "repo.settings.lfs_pointers.accessible"}}</th> + <th class="three wide"></th> + </tr> + </thead> + <tbody> + {{range .Pointers}} + <tr> + <td> + <a href="{{$.RepoLink}}/raw/blob/{{.SHA}}" rel="nofollow" target="_blank" title="{{.SHA}}" class="ui button tw-font-mono"> + {{ShortSha .SHA}} + </a> + </td> + <td> + <a {{if and .Exists .InRepo}}href="{{$.LFSFilesLink}}/show/{{.Oid}}" rel="nofollow" target="_blank"{{end}} title="{{.Oid}}" class="ui brown button tw-font-mono"> + {{ShortSha .Oid}} + </a> + </td> + <td>{{if .InRepo}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td> + <td>{{if .Exists}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td> + <td>{{if .Accessible}}{{svg "octicon-check"}}{{else}}{{svg "octicon-x"}}{{end}}</td> + <td class="tw-text-right"> + <a class="ui primary button" href="{{$.LFSFilesLink}}/find?oid={{.Oid}}&size={{.Size}}&sha={{.SHA}}">{{ctx.Locale.Tr "repo.settings.lfs_findcommits"}}</a> + </td> + </tr> + {{end}} + </tbody> + </table> + </div> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl new file mode 100644 index 0000000..0f6cb74 --- /dev/null +++ b/templates/repo/settings/navbar.tmpl @@ -0,0 +1,72 @@ +<div class="flex-container-nav"> + <div class="ui fluid vertical menu"> + <div class="header item">{{ctx.Locale.Tr "repo.settings"}}</div> + <a class="{{if .PageIsSettingsOptions}}active {{end}}item" href="{{.RepoLink}}/settings"> + {{ctx.Locale.Tr "repo.settings.options"}} + </a> + <details class="item toggleable-item" {{if .PageIsRepoSettingsUnits}}open{{end}}> + <summary {{if .PageIsRepoSettingsUnits}}class="active"{{end}}>{{ctx.Locale.Tr "repo.settings.units.units"}}</summary> + <div class="menu"> + <a class="item" href="{{.RepoLink}}/settings/units#overview"> + {{ctx.Locale.Tr "repo.settings.units.overview"}} + </a> + <a class="item" href="{{.RepoLink}}/settings/units#issues"> + {{ctx.Locale.Tr "repo.issues"}} + </a> + <a class="item" href="{{.RepoLink}}/settings/units#pulls"> + {{ctx.Locale.Tr "repo.pulls"}} + </a> + <a class="item" href="{{.RepoLink}}/settings/units#wiki"> + {{ctx.Locale.Tr "repo.wiki"}} + </a> + </div> + </details> + <a class="{{if .PageIsSettingsCollaboration}}active {{end}}item" href="{{.RepoLink}}/settings/collaboration"> + {{ctx.Locale.Tr "repo.settings.collaboration"}} + </a> + {{if not DisableWebhooks}} + <a class="{{if .PageIsSettingsHooks}}active {{end}}item" href="{{.RepoLink}}/settings/hooks"> + {{ctx.Locale.Tr "repo.settings.hooks"}} + </a> + {{end}} + {{if .Repository.UnitEnabled $.Context $.UnitTypeCode}} + {{if not .Repository.IsEmpty}} + <a class="{{if .PageIsSettingsBranches}}active {{end}}item" href="{{.RepoLink}}/settings/branches"> + {{ctx.Locale.Tr "repo.settings.branches"}} + </a> + {{end}} + <a class="{{if .PageIsSettingsTags}}active {{end}}item" href="{{.RepoLink}}/settings/tags"> + {{ctx.Locale.Tr "repo.settings.tags"}} + </a> + {{if .SignedUser.CanEditGitHook}} + <a class="{{if .PageIsSettingsGitHooks}}active {{end}}item" href="{{.RepoLink}}/settings/hooks/git"> + {{ctx.Locale.Tr "repo.settings.githooks"}} + </a> + {{end}} + <a class="{{if .PageIsSettingsKeys}}active {{end}}item" href="{{.RepoLink}}/settings/keys"> + {{ctx.Locale.Tr "repo.settings.deploy_keys"}} + </a> + {{if .LFSStartServer}} + <a class="{{if .PageIsSettingsLFS}}active {{end}}item" href="{{.RepoLink}}/settings/lfs"> + {{ctx.Locale.Tr "repo.settings.lfs"}} + </a> + {{end}} + {{end}} + {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}} + <details class="item toggleable-item" {{if or .PageIsSharedSettingsRunners .PageIsSharedSettingsSecrets .PageIsSharedSettingsVariables}}open{{end}}> + <summary>{{ctx.Locale.Tr "actions.actions"}}</summary> + <div class="menu"> + <a class="{{if .PageIsSharedSettingsRunners}}active {{end}}item" href="{{.RepoLink}}/settings/actions/runners"> + {{ctx.Locale.Tr "actions.runners"}} + </a> + <a class="{{if .PageIsSharedSettingsSecrets}}active {{end}}item" href="{{.RepoLink}}/settings/actions/secrets"> + {{ctx.Locale.Tr "secrets.secrets"}} + </a> + <a class="{{if .PageIsSharedSettingsVariables}}active {{end}}item" href="{{.RepoLink}}/settings/actions/variables"> + {{ctx.Locale.Tr "actions.variables"}} + </a> + </div> + </details> + {{end}} + </div> +</div> diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl new file mode 100644 index 0000000..09f80ca --- /dev/null +++ b/templates/repo/settings/options.tmpl @@ -0,0 +1,794 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings options")}} + <div class="user-main-content twelve wide column"> + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.basic_settings"}} + </h4> + <div class="ui attached segment"> + <form class="ui form" action="{{.Link}}" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="update"> + <div class="required field {{if .Err_RepoName}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.repo_name"}}</label> + <input name="repo_name" value="{{.Repository.Name}}" data-repo-name="{{.Repository.Name}}" autofocus required> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.repo_size"}}</label> + <span {{if not (eq .Repository.Size 0)}} data-tooltip-content="{{.Repository.SizeDetailsString ctx.Locale}}"{{end}}>{{ctx.Locale.TrSize .Repository.Size}}</span> + </div> + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.template"}}</label> + <div class="ui checkbox"> + <input name="template" type="checkbox" {{if .Repository.IsTemplate}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.template_helper"}}</label> + </div> + </div> + {{if not .Repository.IsFork}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.visibility"}}</label> + <div class="ui checkbox" {{if and (not .Repository.IsPrivate) (gt .Repository.NumStars 0)}}data-tooltip-content="{{ctx.Locale.Tr "repo.stars_remove_warning"}}"{{end}}> + {{if .IsAdmin}} + <input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}> + {{else}} + <input name="private" type="checkbox" {{if .Repository.IsPrivate}}checked{{end}}{{if and $.ForcePrivate .Repository.IsPrivate}} disabled{{end}}> + {{if and .Repository.IsPrivate $.ForcePrivate}}<input type="hidden" name="private" value="{{.Repository.IsPrivate}}">{{end}} + {{end}} + <label>{{ctx.Locale.Tr "repo.visibility_helper"}} {{if .Repository.NumForks}}<span class="text red">{{ctx.Locale.Tr "repo.visibility_fork_helper"}}</span>{{end}}</label> + </div> + </div> + {{end}} + <div class="field {{if .Err_Description}}error{{end}}"> + <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> + <textarea id="description" name="description" rows="2" maxlength="2048">{{.Repository.Description}}</textarea> + </div> + <div class="field {{if .Err_Website}}error{{end}}"> + <label for="website">{{ctx.Locale.Tr "repo.settings.site"}}</label> + <input id="website" name="website" type="url" maxlength="1024" value="{{.Repository.Website}}"> + </div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> + </form> + + <div class="divider"></div> + <form class="ui form" action="{{.Link}}/avatar" method="post" enctype="multipart/form-data"> + {{.CsrfTokenHtml}} + <div class="inline field"> + <label for="avatar">{{ctx.Locale.Tr "settings.choose_new_avatar"}}</label> + <input name="avatar" type="file" accept="image/png,image/jpeg,image/gif,image/webp"> + </div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "settings.update_avatar"}}</button> + <button class="ui red button link-action" data-url="{{.Link}}/avatar/delete">{{ctx.Locale.Tr "settings.delete_current_avatar"}}</button> + </div> + </form> + </div> + + {{if FederationEnabled}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.federation_settings"}} + </h4> + <div class="ui attached segment"> + <form class="ui form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="federation"> + <div class="field {{if .Err_FollowingRepos}}error{{end}}"> + <p>{{ctx.Locale.Tr "repo.settings.federation_apapiurl"}}</p> + <p><b>{{.RepositoryAPActorID}}</b></p> + <div class="divider"></div> + <label for="following_repos">{{ctx.Locale.Tr "repo.settings.federation_following_repos"}}</label> + <input id="following_repos" name="following_repos" value="{{.FollowingRepos}}"> + </div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> + </form> + </div> + {{end}} + + {{/* These variables exist to make the logic in the Settings window easier to comprehend and are not used later on. */}} + {{$newMirrorsPartiallyEnabled := or (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} + {{/* .Repository.IsMirror is not always reliable if the repository is not actively acting as a mirror because of errors. */}} + {{$showMirrorSettings := and (.Repository.UnitEnabled $.Context $.UnitTypeCode) (or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors)}} + {{$newMirrorsEntirelyEnabled := and (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} + {{$onlyNewPushMirrorsEnabled := and (not .DisableNewPushMirrors) .DisableNewPullMirrors}} + {{$onlyNewPullMirrorsEnabled := and .DisableNewPushMirrors (not .DisableNewPullMirrors)}} + {{$existingPushMirror := or .Repository.IsMirror .PushMirrors}} + {{$modifyBrokenPullMirror := and .Repository.IsMirror (not .PullMirror)}} + {{$isWorkingPullMirror := .PullMirror}} + + {{if $showMirrorSettings}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.mirror_settings"}} + </h4> + <div class="ui attached segment"> + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{ctx.Locale.Tr "repo.settings.archive.mirrors_unavailable"}} + </div> + {{else}} + {{if $newMirrorsEntirelyEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}} + <a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pushing-to-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} + <a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}</a><br> + {{else if $onlyNewPushMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + <a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br> + {{else if $onlyNewPullMirrorsEnabled}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}} + <a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} + {{if $existingPushMirror}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}<br> + {{end}} + + {{if .Repository.IsMirror}} + <table class="ui table"> + <thead> + <tr> + <th class="tw-w-2/5">{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</th> + <th>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}}</th> + <th>{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}}</th> + <th>{{ctx.Locale.Tr "repo.mirror_public_key"}}</th> + <th></th> + </tr> + </thead> + {{if $modifyBrokenPullMirror}} + {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}} + <tbody> + <tr> + <td colspan="4"> + <div class="text red tw-py-4">{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}: {{ctx.Locale.Tr "error.occurred"}}</div> + </td> + </tr> + </tbody> + {{else if $isWorkingPullMirror}} + <tbody> + <tr> + <td>{{.PullMirror.RemoteAddress}}</td> + <td>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.pull"}}</td> + <td>{{DateTime "full" .PullMirror.UpdatedUnix}}</td> + <td class="right aligned"> + <form method="post" class="tw-inline-block"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="mirror-sync"> + <button class="ui primary tiny button inline">{{ctx.Locale.Tr "repo.settings.sync_mirror"}}</button> + </form> + </td> + </tr> + <tr> + <td colspan="4"> + <form class="ui form" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="mirror"> + <div class="inline field {{if .Err_EnablePrune}}error{{end}}"> + <label>{{ctx.Locale.Tr "repo.mirror_prune"}}</label> + <div class="ui checkbox"> + <input id="enable_prune" name="enable_prune" type="checkbox" {{if .PullMirror.EnablePrune}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.mirror_prune_desc"}}</label> + </div> + </div> + <div class="inline field {{if .Err_Interval}}error{{end}}"> + <label for="interval">{{ctx.Locale.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label> + <input id="interval" name="interval" value="{{.PullMirror.Interval}}"> + </div> + {{$address := MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName}} + <div class="field {{if .Err_MirrorAddress}}error{{end}}"> + <label for="mirror_address">{{ctx.Locale.Tr "repo.mirror_address"}}</label> + <input id="mirror_address" name="mirror_address" value="{{$address.Address}}" required> + <p class="help">{{ctx.Locale.Tr "repo.mirror_address_desc"}}</p> + </div> + <details class="ui optional field" {{if or .Err_Auth $address.Username}}open{{end}}> + <summary class="tw-p-1"> + {{ctx.Locale.Tr "repo.need_auth"}} + </summary> + <div class="tw-p-1"> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="mirror_username">{{ctx.Locale.Tr "username"}}</label> + <input id="mirror_username" name="mirror_username" value="{{$address.Username}}" {{if not .mirror_username}}data-need-clear="true"{{end}}> + </div> + <div class="inline field {{if .Err_Auth}}error{{end}}"> + <label for="mirror_password">{{ctx.Locale.Tr "password"}}</label> + <input id="mirror_password" name="mirror_password" type="password" placeholder="{{if $address.Password}}{{ctx.Locale.Tr "repo.mirror_password_placeholder"}}{{else}}{{ctx.Locale.Tr "repo.mirror_password_blank_placeholder"}}{{end}}" value="" {{if not .mirror_password}}data-need-clear="true"{{end}} autocomplete="off"> + </div> + <p class="help">{{ctx.Locale.Tr "repo.mirror_password_help"}}</p> + </div> + </details> + + {{if .LFSStartServer}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.mirror_lfs"}}</label> + <div class="ui checkbox"> + <input id="mirror_lfs" name="mirror_lfs" type="checkbox" {{if .PullMirror.LFS}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.mirror_lfs_desc"}}</label> + </div> + </div> + <div class="field {{if .Err_LFSEndpoint}}error{{end}}"> + <label for="mirror_lfs_endpoint">{{ctx.Locale.Tr "repo.mirror_lfs_endpoint"}}</label> + <input id="mirror_lfs_endpoint" name="mirror_lfs_endpoint" value="{{.PullMirror.LFSEndpoint}}" placeholder="{{ctx.Locale.Tr "repo.migrate_options_lfs_endpoint.placeholder"}}"> + <p class="help">{{ctx.Locale.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery"}}</p> + </div> + {{end}} + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_mirror_settings"}}</button> + </div> + </form> + </td> + </tr> + </tbody> + {{end}}{{/* end if: $modifyBrokenPullMirror / $isWorkingPullMirror */}} + </table> + {{end}}{{/* end if .Repository.IsMirror */}} + + <table class="ui table"> + <thead> + <tr> + <th class="tw-w-2/5">{{ctx.Locale.Tr "repo.settings.mirror_settings.pushed_repository"}}</th> + <th>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction"}}</th> + <th>{{ctx.Locale.Tr "repo.settings.mirror_settings.last_update"}}</th> + <th>{{ctx.Locale.Tr "repo.mirror_public_key"}}</th> + <th></th> + </tr> + </thead> + <tbody> + {{range .PushMirrors}} + <tr> + <td class="tw-break-anywhere">{{.RemoteAddress}}</td> + <td>{{ctx.Locale.Tr "repo.settings.mirror_settings.direction.push"}}</td> + <td>{{if .LastUpdateUnix}}{{DateTime "full" .LastUpdateUnix}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .LastError}}<div class="ui red label" data-tooltip-content="{{.LastError}}">{{ctx.Locale.Tr "error"}}</div>{{end}}</td> + <td>{{if not (eq (len .GetPublicKey) 0)}}<a data-clipboard-text="{{.GetPublicKey}}">{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.copy_public_key"}}</a>{{else}}{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none_ssh"}}{{end}}</td> + <td class="right aligned df"> + <button + class="ui tiny button show-modal" + data-modal="#push-mirror-edit-modal" + data-tooltip-content="{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}}" + data-modal-push-mirror-edit-id="{{.ID}}" + data-modal-push-mirror-edit-interval="{{.Interval}}" + data-modal-push-mirror-edit-address="{{.RemoteAddress}}" + > + {{svg "octicon-pencil" 14}} + </button> + <form method="post" class="tw-inline-block"> + {{$.CsrfTokenHtml}} + <input type="hidden" name="action" value="push-mirror-sync"> + <input type="hidden" name="push_mirror_id" value="{{.ID}}"> + <button class="ui primary tiny button" data-tooltip-content="{{ctx.Locale.Tr "repo.settings.sync_mirror"}}">{{svg "octicon-sync" 14}}</button> + </form> + <form method="post" class="tw-inline-block"> + {{$.CsrfTokenHtml}} + <input type="hidden" name="action" value="push-mirror-remove"> + <input type="hidden" name="push_mirror_id" value="{{.ID}}"> + <button class="ui basic red tiny button" data-tooltip-content="{{ctx.Locale.Tr "remove"}}">{{svg "octicon-trash" 14}}</button> + </form> + </td> + </tr> + {{else}} + <tr> + <td>{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.none"}}</td> + </tr> + {{end}} + {{if (not .DisableNewPushMirrors)}} + <tr> + <td colspan="5"> + <form class="ui form" method="post"> + {{template "base/disable_form_autofill"}} + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="push-mirror-add"> + <div class="field {{if .Err_PushMirrorAddress}}error{{end}}"> + <label for="push_mirror_address">{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.remote_url"}}</label> + <input id="push_mirror_address" name="push_mirror_address" value="{{.push_mirror_address}}" required> + <p class="help">{{ctx.Locale.Tr "repo.mirror_address_desc"}}</p> + </div> + <details class="ui optional field" {{if or .Err_PushMirrorAuth .push_mirror_username}}open{{end}}> + <summary class="tw-p-1"> + {{ctx.Locale.Tr "repo.need_auth"}} + </summary> + <div class="tw-p-1"> + <div class="inline field {{if .Err_PushMirrorAuth}}error{{end}}"> + <label for="push_mirror_username">{{ctx.Locale.Tr "username"}}</label> + <input id="push_mirror_username" name="push_mirror_username" value="{{.push_mirror_username}}"> + </div> + <div class="inline field {{if .Err_PushMirrorAuth}}error{{end}}"> + <label for="push_mirror_password">{{ctx.Locale.Tr "password"}}</label> + <input id="push_mirror_password" name="push_mirror_password" type="password" value="{{.push_mirror_password}}" autocomplete="off"> + </div> + {{if .CanUseSSHMirroring}} + <div class="inline field {{if .Err_PushMirrorUseSSH}}error{{end}}"> + <div class="ui checkbox df ac"> + <input id="push_mirror_use_ssh" name="push_mirror_use_ssh" type="checkbox" {{if .push_mirror_use_ssh}}checked{{end}}> + <label for="push_mirror_use_ssh" class="inline">{{ctx.Locale.Tr "repo.mirror_use_ssh.text"}}</label> + <span class="help tw-block">{{ctx.Locale.Tr "repo.mirror_use_ssh.helper"}} + </div> + </div> + {{end}} + </div> + </details> + <div class="field"> + <div class="ui checkbox"> + <input id="push_mirror_sync_on_commit" name="push_mirror_sync_on_commit" type="checkbox" {{if .push_mirror_sync_on_commit}}checked{{end}}> + <label for="push_mirror_sync_on_commit">{{ctx.Locale.Tr "repo.mirror_sync_on_commit"}}</label> + </div> + </div> + <div class="inline field {{if .Err_PushMirrorInterval}}error{{end}}"> + <label for="push_mirror_interval">{{ctx.Locale.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label> + <input id="push_mirror_interval" name="push_mirror_interval" value="{{if .push_mirror_interval}}{{.push_mirror_interval}}{{else}}{{.DefaultMirrorInterval}}{{end}}"> + </div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.add"}}</button> + </div> + </form> + </td> + </tr> + {{end}} + </tbody> + </table> + {{end}} + </div> + {{end}} + + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.signing_settings"}} + </h4> + <div class="ui attached segment"> + <form class="ui form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="signing"> + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.trust_model"}}</label><br> + <div class="field"> + <div class="ui radio checkbox"> + <input type="radio" id="trust_model_default" name="trust_model" {{if eq .Repository.TrustModel.String "default"}}checked="checked"{{end}} value="default"> + <label for="trust_model_default">{{ctx.Locale.Tr "repo.settings.trust_model.default"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.trust_model.default.desc"}}</p> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input type="radio" id="trust_model_collaborator" name="trust_model" {{if eq .Repository.TrustModel.String "collaborator"}}checked="checked"{{end}} value="collaborator"> + <label for="trust_model_collaborator">{{ctx.Locale.Tr "repo.settings.trust_model.collaborator.long"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.trust_model.collaborator.desc"}}</p> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input type="radio" name="trust_model" id="trust_model_committer" {{if eq .Repository.TrustModel.String "committer"}}checked="checked"{{end}} value="committer"> + <label for="trust_model_committer">{{ctx.Locale.Tr "repo.settings.trust_model.committer.long"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.trust_model.committer.desc"}}</p> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input type="radio" name="trust_model" id="trust_model_collaboratorcommitter" {{if eq .Repository.TrustModel.String "collaboratorcommitter"}}checked="checked"{{end}} value="collaboratorcommitter"> + <label for="trust_model_collaboratorcommitter">{{ctx.Locale.Tr "repo.settings.trust_model.collaboratorcommitter.long"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.trust_model.collaboratorcommitter.desc"}}</p> + </div> + </div> + </div> + + <div class="divider"></div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> + </form> + </div> + + {{if .IsAdmin}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.admin_settings"}} + </h4> + <div class="ui attached segment"> + <form class="ui form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="admin"> + <div class="field"> + <div class="ui checkbox"> + <input name="enable_health_check" type="checkbox" {{if .Repository.IsFsckEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.admin_enable_health_check"}}</label> + </div> + </div> + + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> + </form> + + <div class="divider"></div> + <form class="ui form" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="admin_index"> + {{if .CodeIndexerEnabled}} + <h4 class="ui header">{{ctx.Locale.Tr "repo.settings.admin_code_indexer"}}</h4> + <div class="inline fields"> + <label>{{ctx.Locale.Tr "repo.settings.admin_indexer_commit_sha"}}</label> + <span class="field"> + {{if .CodeIndexerStatus}} + <a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.CodeIndexerStatus.CommitSha}}"> + <span class="shortsha">{{ShortSha .CodeIndexerStatus.CommitSha}}</span> + </a> + {{else}} + <span>{{ctx.Locale.Tr "repo.settings.admin_indexer_unindexed"}}</span> + {{end}} + </span> + <div class="field"> + <button class="ui primary button" name="request_reindex_type" value="code">{{ctx.Locale.Tr "repo.settings.reindex_button"}}</button> + </div> + </div> + {{end}} + <h4 class="ui header">{{ctx.Locale.Tr "repo.settings.admin_stats_indexer"}}</h4> + <div class="inline fields"> + {{if and .StatsIndexerStatus .StatsIndexerStatus.CommitSha}} + <label>{{ctx.Locale.Tr "repo.settings.admin_indexer_commit_sha"}}</label> + {{end}} + <span class="field"> + {{if and .StatsIndexerStatus .StatsIndexerStatus.CommitSha}} + <a rel="nofollow" class="ui sha label" href="{{.RepoLink}}/commit/{{.StatsIndexerStatus.CommitSha}}"> + <span class="shortsha">{{ShortSha .StatsIndexerStatus.CommitSha}}</span> + </a> + {{else}} + <span>{{ctx.Locale.Tr "repo.settings.admin_indexer_unindexed"}}</span> + {{end}} + </span> + <div class="field"> + <button class="ui primary button" name="request_reindex_type" value="stats">{{ctx.Locale.Tr "repo.settings.reindex_button"}}</button> + </div> + </div> + </form> + </div> + {{end}} + + {{if .Permission.IsOwner}} + <h4 class="ui top attached error header"> + {{ctx.Locale.Tr "repo.settings.danger_zone"}} + </h4> + <div class="ui attached error danger segment"> + <div class="flex-list"> + {{if .Repository.IsMirror}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.convert"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.convert_desc"}}</div> + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#convert-mirror-repo-modal">{{ctx.Locale.Tr "repo.settings.convert"}}</button> + </div> + </div> + {{end}} + {{if and .Repository.IsFork .Repository.Owner.CanCreateRepo}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.convert_fork"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.convert_fork_desc"}}</div> + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#convert-fork-repo-modal">{{ctx.Locale.Tr "repo.settings.convert_fork"}}</button> + </div> + </div> + {{end}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.transfer.title"}}</div> + <div class="flex-item-body"> + {{if .RepoTransfer}} + {{ctx.Locale.Tr "repo.settings.transfer_started" .RepoTransfer.Recipient.DisplayName}} + {{else}} + {{ctx.Locale.Tr "repo.settings.transfer_desc"}} + {{end}} + </div> + </div> + <div class="flex-item-trailing"> + {{if .RepoTransfer}} + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="cancel_transfer"> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.transfer_abort"}}</button> + </form> + {{else}} + <button class="ui basic red show-modal button" data-modal="#transfer-repo-modal">{{ctx.Locale.Tr "repo.settings.transfer.button"}}</button> + {{end}} + </div> + </div> + {{if .Permission.CanRead $.UnitTypeWiki}} + {{if ne $.Repository.GetWikiBranchName .DefaultWikiBranchName}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main_desc" .DefaultWikiBranchName}}</div> + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#rename-wiki-branch-modal">{{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main"}}</button> + </div> + </div> + {{end}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.wiki_delete"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.wiki_delete_desc"}}</div> + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#delete-wiki-modal">{{ctx.Locale.Tr "repo.settings.wiki_delete"}}</button> + </div> + </div> + {{end}} + <div class="flex-item"> + <div class="flex-item-main"> + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.delete"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.delete_desc"}}</div> + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#delete-repo-modal">{{ctx.Locale.Tr "repo.settings.delete"}}</button> + </div> + </div> + {{if not .Repository.IsMirror}} + <div class="flex-item tw-items-center"> + <div class="flex-item-main"> + {{if .Repository.IsArchived}} + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.unarchive.header"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.unarchive.text"}}</div> + {{else}} + <div class="flex-item-title">{{ctx.Locale.Tr "repo.settings.archive.header"}}</div> + <div class="flex-item-body">{{ctx.Locale.Tr "repo.settings.archive.text"}}</div> + {{end}} + </div> + <div class="flex-item-trailing"> + <button class="ui basic red show-modal button" data-modal="#archive-repo-modal"> + {{if .Repository.IsArchived}} + {{ctx.Locale.Tr "repo.settings.unarchive.button"}} + {{else}} + {{ctx.Locale.Tr "repo.settings.archive.button"}} + {{end}} + </button> + </div> + </div> + {{end}} + </div> + </div> + {{end}} + </div> +{{template "repo/settings/layout_footer" .}} + +{{if .Permission.IsOwner}} + {{if .Repository.IsMirror}} + <div class="ui small modal" id="convert-mirror-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.convert"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.convert_notices_1"}} + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="convert"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label>{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input name="repo_name" required maxlength="100"> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.convert_confirm"}}</button> + </div> + </form> + </div> + </div> + {{end}} + {{if and .Repository.IsFork .Repository.Owner.CanCreateRepo}} + <div class="ui small modal" id="convert-fork-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.convert_fork"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.convert_fork_notices_1"}} + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="convert_fork"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label>{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input name="repo_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.convert_fork_confirm"}}</button> + </div> + </form> + </div> + </div> + {{end}} + <div class="ui small modal" id="transfer-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.transfer.modal.title"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.transfer_notices_1"}} <br> + {{ctx.Locale.Tr "repo.settings.transfer_notices_2"}} <br> + {{ctx.Locale.Tr "repo.settings.transfer_notices_3"}} + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="transfer"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label>{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input name="repo_name" required> + </div> + <div class="required field"> + <label for="new_owner_name">{{ctx.Locale.Tr "repo.settings.transfer_owner"}}</label> + <input id="new_owner_name" name="new_owner_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.transfer_perform"}}</button> + </div> + </form> + </div> + </div> + + <div class="ui small modal" id="delete-repo-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.delete"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.delete_notices_1"}}<br> + {{ctx.Locale.Tr "repo.settings.delete_notices_2" .Repository.FullName}} + {{if .Repository.NumForks}}<br> + {{ctx.Locale.Tr "repo.settings.delete_notices_fork_1"}} + {{end}} + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="delete"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label for="repo_name_to_delete">{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input id="repo_name_to_delete" name="repo_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.confirm_delete"}}</button> + </div> + </form> + </div> + </div> + + {{if .Repository.UnitEnabled $.Context $.UnitTypeWiki}} + <div class="ui small modal" id="delete-wiki-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.wiki_delete"}} + </div> + <div class="content"> + <div class="ui warning message"> + {{ctx.Locale.Tr "repo.settings.delete_notices_1"}}<br> + {{ctx.Locale.Tr "repo.settings.wiki_delete_notices_1" .Repository.Name}} + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="delete-wiki"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label>{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input name="repo_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.confirm_wiki_delete"}}</button> + </div> + </form> + </div> + </div> + {{if ne $.Repository.GetWikiBranchName .DefaultWikiBranchName}} + <div class="ui small modal" id="rename-wiki-branch-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main"}} + </div> + <div class="content"> + <div class="ui warning message"> + <ul> + <li>{{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main_notices_1"}}</li> + <li>{{ctx.Locale.Tr "repo.settings.wiki_rename_branch_main_notices_2" .Repository.Name}}</li> + </ul> + </div> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="rename-wiki-branch"> + <div class="field"> + <label> + {{ctx.Locale.Tr "repo.settings.enter_repo_name"}} + <span class="text red">{{.Repository.FullName}}</span> + </label> + </div> + <div class="required field"> + <label>{{ctx.Locale.Tr "repo.settings.confirmation_string"}}</label> + <input name="repo_name" required> + </div> + + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button">{{ctx.Locale.Tr "repo.settings.confirm_wiki_branch_rename"}}</button> + </div> + </form> + </div> + </div> + {{end}} + {{end}} + + {{if not .Repository.IsMirror}} + <div class="ui g-modal-confirm modal" id="archive-repo-modal"> + <div class="header"> + {{if .Repository.IsArchived}} + {{ctx.Locale.Tr "repo.settings.unarchive.header"}} + {{else}} + {{ctx.Locale.Tr "repo.settings.archive.header"}} + {{end}} + </div> + <div class="content"> + <div class="ui warning message"> + {{if .Repository.IsArchived}} + {{ctx.Locale.Tr "repo.settings.unarchive.text"}} + {{else}} + {{ctx.Locale.Tr "repo.settings.archive.text"}} + {{end}} + </div> + <form action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="{{if .Repository.IsArchived}}unarchive{{else}}archive{{end}}"> + <input type="hidden" name="repo_id" value="{{.Repository.ID}}"> + <div class="text right actions"> + <button class="ui cancel button">{{ctx.Locale.Tr "settings.cancel"}}</button> + <button class="ui red button"> + {{if .Repository.IsArchived}} + {{ctx.Locale.Tr "repo.settings.unarchive.button"}} + {{else}} + {{ctx.Locale.Tr "repo.settings.archive.button"}} + {{end}} + </button> + </div> + </form> + </div> + </div> + {{end}} +{{end}} + +{{template "repo/settings/push_mirror_sync_modal" .}} diff --git a/templates/repo/settings/protected_branch.tmpl b/templates/repo/settings/protected_branch.tmpl new file mode 100644 index 0000000..ce7016e --- /dev/null +++ b/templates/repo/settings/protected_branch.tmpl @@ -0,0 +1,262 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings branches")}} + <div class="repo-setting-content"> + <h4 class="ui top attached header"> + {{if .Rule.RuleName}} + {{ctx.Locale.Tr "repo.settings.branch_protection" .Rule.RuleName}} + {{else}} + {{ctx.Locale.Tr "repo.settings.protect_new_rule"}} + {{end}} + </h4> + <form class="ui form attached segment" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <input name="rule_id" type="hidden" value="{{.Rule.ID}}"> + <fieldset class="branch-protection"> + <legend>{{ctx.Locale.Tr "repo.settings.protect_patterns"}}</legend> + <label>{{ctx.Locale.Tr "repo.settings.protect_branch_name_pattern"}} + <input name="rule_name" type="text" value="{{.Rule.RuleName}}"> + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_branch_name_pattern_desc" "https://github.com/gobwas/glob"}}</span> + </label> + <label>{{ctx.Locale.Tr "repo.settings.protect_protected_file_patterns"}} + <input name="protected_file_patterns" type="text" value="{{.Rule.ProtectedFilePatterns}}"> + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_protected_file_patterns_desc" "https://pkg.go.dev/github.com/gobwas/glob#Compile" "github.com/gobwas/glob"}}</span> + </label> + <label>{{ctx.Locale.Tr "repo.settings.protect_unprotected_file_patterns"}} + <input name="unprotected_file_patterns" type="text" value="{{.Rule.UnprotectedFilePatterns}}"> + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_unprotected_file_patterns_desc" "https://pkg.go.dev/github.com/gobwas/glob#Compile" "github.com/gobwas/glob"}}</span> + </label> + </fieldset> + + <fieldset> + <legend>{{ctx.Locale.Tr "repo.settings.event_push"}}</legend> + <label> + <input name="enable_push" type="radio" value="none" class="toggle-target-disabled" data-target="#whitelist_box" {{if not .Rule.CanPush}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.protect_disable_push"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_disable_push_desc"}}</span> + </label> + <label> + <input name="enable_push" type="radio" value="all" class="toggle-target-disabled" data-target="#whitelist_box" {{if and (.Rule.CanPush) (not .Rule.EnableWhitelist)}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.protect_enable_push"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_enable_push_desc"}}</span> + </label> + <label> + <input name="enable_push" type="radio" value="whitelist" class="toggle-target-enabled" data-target="#whitelist_box" {{if and (.Rule.CanPush) (.Rule.EnableWhitelist)}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.protect_whitelist_committers"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_whitelist_committers_desc"}}</span> + </label> + <div id="whitelist_box" class="grouped fields {{if not .Rule.EnableWhitelist}}disabled{{end}}"> + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_whitelist_users"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="whitelist_users" value="{{.whitelist_users}}"> + <div class="default text">{{ctx.Locale.Tr "search.user_kind"}}</div> + <div class="menu"> + {{range .Users}} + <div class="item" data-value="{{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} + </div> + {{end}} + </div> + </div> + </div> + {{if .Owner.IsOrganization}} + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_whitelist_teams"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="whitelist_teams" value="{{.whitelist_teams}}"> + <div class="default text">{{ctx.Locale.Tr "search.team_kind"}}</div> + <div class="menu"> + {{range .Teams}} + <div class="item" data-value="{{.ID}}"> + {{svg "octicon-people"}} + {{.Name}} + </div> + {{end}} + </div> + </div> + </div> + {{end}} + <div class="checkbox-sub-item field"> + <div class="ui checkbox"> + <input type="checkbox" name="whitelist_deploy_keys" {{if .Rule.WhitelistDeployKeys}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.protect_whitelist_deploy_keys"}}</label> + </div> + </div> + </div> + <label> + <input name="require_signed_commits" type="checkbox" {{if .Rule.RequireSignedCommits}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.require_signed_commits"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.require_signed_commits_desc"}}</span> + </label> + </fieldset> + <fieldset> + <legend>{{ctx.Locale.Tr "repo.settings.event_pull_request_approvals"}}</legend> + <label> + {{ctx.Locale.Tr "repo.settings.protect_required_approvals"}} + <input name="required_approvals" type="number" value="{{.Rule.RequiredApprovals}}"> + <span class="help tw-ml-0">{{ctx.Locale.Tr "repo.settings.protect_required_approvals_desc"}}</span> + </label> + <fieldset> + <label> + <input name="enable_approvals_whitelist" type="checkbox" class="toggle-target-enabled" data-target="#approvals_whitelist_box" {{if .Rule.EnableApprovalsWhitelist}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.protect_approvals_whitelist_enabled"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.protect_approvals_whitelist_enabled_desc"}}</span> + </label> + <div id="approvals_whitelist_box" class="grouped fields {{if not .Rule.EnableApprovalsWhitelist}}disabled{{end}}"> + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_approvals_whitelist_users"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="approvals_whitelist_users" value="{{.approvals_whitelist_users}}"> + <div class="default text">{{ctx.Locale.Tr "search.user_kind"}}</div> + <div class="menu"> + {{range .Users}} + <div class="item" data-value="{{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} + </div> + {{end}} + </div> + </div> + </div> + {{if .Owner.IsOrganization}} + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_approvals_whitelist_teams"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="approvals_whitelist_teams" value="{{.approvals_whitelist_teams}}"> + <div class="default text">{{ctx.Locale.Tr "search.team_kind"}}</div> + <div class="menu"> + {{range .Teams}} + <div class="item" data-value="{{.ID}}"> + {{svg "octicon-people"}} + {{.Name}} + </div> + {{end}} + </div> + </div> + </div> + {{end}} + </div> + </fieldset> + <label> + <input id="dismiss_stale_approvals" name="dismiss_stale_approvals" type="checkbox" {{if .Rule.DismissStaleApprovals}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.dismiss_stale_approvals"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.dismiss_stale_approvals_desc"}}</span> + </label> + <div id="ignore_stale_approvals_box" class="field {{if .Rule.DismissStaleApprovals}}disabled{{end}}"> + <div class="ui checkbox"> + <input id="ignore_stale_approvals" name="ignore_stale_approvals" type="checkbox" {{if .Rule.IgnoreStaleApprovals}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.ignore_stale_approvals"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.ignore_stale_approvals_desc"}}</p> + </div> + </div> + <fieldset> + <div class="field"> + <div class="ui checkbox"> + <input name="enable_status_check" type="checkbox" class="toggle-target-enabled" data-target="#statuscheck_contexts_box" {{if .Rule.EnableStatusCheck}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.protect_check_status_contexts"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.protect_check_status_contexts_desc"}}</p> + </div> + </div> + <div id="statuscheck_contexts_box" class="checkbox-sub-item field {{if not .Rule.EnableStatusCheck}}disabled{{end}}"> + <label>{{ctx.Locale.Tr "repo.settings.protect_status_check_patterns"}}</label> + <textarea id="status_check_contexts" name="status_check_contexts" rows="3">{{.status_check_contexts}}</textarea> + <p class="help">{{ctx.Locale.Tr "repo.settings.protect_status_check_patterns_desc"}}</p> + <table class="ui celled table"> + <thead> + <tr> + <th>{{ctx.Locale.Tr "repo.settings.protect_check_status_contexts_list"}}</th> + </tr> + </thead> + <tbody> + {{range $.recent_status_checks}} + <tr> + <td> + <span>{{.}}</span> + <span class="status-check-matched-mark tw-hidden" data-status-check="{{.}}">{{ctx.Locale.Tr "repo.settings.protect_status_check_matched"}}</span> + </td> + </tr> + {{else}} + <tr><td>-</td></tr> + {{end}} + </tbody> + </table> + </div> + </fieldset> + </fieldset> + <fieldset> + <legend>{{ctx.Locale.Tr "repo.settings.event_pull_request_merge"}}</legend> + <div class="grouped fields"> + <div class="field"> + <div class="ui radio checkbox"> + <input name="enable_merge_whitelist" type="radio" value="false" class="toggle-target-disabled" data-target="#merge_whitelist_box" {{if not .Rule.EnableMergeWhitelist}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.protect_enable_merge"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.protect_enable_merge_desc"}}</p> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input name="enable_merge_whitelist" type="radio" value="true" class="toggle-target-enabled" data-target="#merge_whitelist_box" {{if .Rule.EnableMergeWhitelist}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.protect_merge_whitelist_committers"}}</label> + <p class="help">{{ctx.Locale.Tr "repo.settings.protect_merge_whitelist_committers_desc"}}</p> + </div> + </div> + <div id="merge_whitelist_box" class="grouped fields {{if not .Rule.EnableMergeWhitelist}}disabled{{end}}"> + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_merge_whitelist_users"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="merge_whitelist_users" value="{{.merge_whitelist_users}}"> + <div class="default text">{{ctx.Locale.Tr "search.user_kind"}}</div> + <div class="menu"> + {{range .Users}} + <div class="item" data-value="{{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} + </div> + {{end}} + </div> + </div> + </div> + {{if .Owner.IsOrganization}} + <div class="checkbox-sub-item field"> + <label>{{ctx.Locale.Tr "repo.settings.protect_merge_whitelist_teams"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="merge_whitelist_teams" value="{{.merge_whitelist_teams}}"> + <div class="default text">{{ctx.Locale.Tr "search.team_kind"}}</div> + <div class="menu"> + {{range .Teams}} + <div class="item" data-value="{{.ID}}"> + {{svg "octicon-people"}} + {{.Name}} + </div> + {{end}} + </div> + </div> + </div> + {{end}} + </div> + </div> + <label> + <input name="block_on_rejected_reviews" type="checkbox" {{if .Rule.BlockOnRejectedReviews}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.block_rejected_reviews"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.block_rejected_reviews_desc"}}</span> + </label> + <label> + <input name="block_on_official_review_requests" type="checkbox" {{if .Rule.BlockOnOfficialReviewRequests}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.block_on_official_review_requests"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.block_on_official_review_requests_desc"}}</span> + </label> + <label> + <input name="block_on_outdated_branch" type="checkbox" {{if .Rule.BlockOnOutdatedBranch}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.block_outdated_branch"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.block_outdated_branch_desc"}}</span> + </label> + </fieldset> + <fieldset> + <legend>{{ctx.Locale.Tr "repo.settings.event_pull_request_enforcement"}}</legend> + <label> + <input name="apply_to_admins" type="checkbox" {{if .Rule.ApplyToAdmins}}checked{{end}}> + {{ctx.Locale.Tr "repo.settings.enforce_on_admins"}} + <span class="help">{{ctx.Locale.Tr "repo.settings.enforce_on_admins_desc"}}</span> + </label> + </fieldset> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.protected_branch.save_rule"}}</button> + </form> + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/push_mirror_sync_modal.tmpl b/templates/repo/settings/push_mirror_sync_modal.tmpl new file mode 100644 index 0000000..e8dad61 --- /dev/null +++ b/templates/repo/settings/push_mirror_sync_modal.tmpl @@ -0,0 +1,32 @@ +<div class="ui small modal" id="push-mirror-edit-modal"> + <div class="header"> + {{ctx.Locale.Tr "repo.settings.mirror_settings.push_mirror.edit_sync_time"}} + </div> + <div class="content"> + <form class="ui form ignore-dirty" method="post"> + {{.CsrfTokenHtml}} + <input type="hidden" name="action" value="push-mirror-update"> + <input type="hidden" name="push_mirror_id" id="push-mirror-edit-id"> + <div class="field"> + <label for="name">{{ctx.Locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</label> + <div class="ui small input"> + <input id="push-mirror-edit-address" readonly> + </div> + </div> + <div class="inline field"> + <label for="push-mirror-edit-interval">{{ctx.Locale.Tr "repo.mirror_interval" .MinimumMirrorInterval}}</label> + <input id="push-mirror-edit-interval" name="push_mirror_interval" autofocus> + </div> + <div class="actions"> + <button class="ui small basic cancel button"> + {{svg "octicon-x"}} + {{ctx.Locale.Tr "cancel"}} + </button> + <button class="ui primary small approve button"> + {{svg "fontawesome-save"}} + {{ctx.Locale.Tr "save"}} + </button> + </div> + </form> + </div> +</div> diff --git a/templates/repo/settings/runner_edit.tmpl b/templates/repo/settings/runner_edit.tmpl new file mode 100644 index 0000000..8b76aea --- /dev/null +++ b/templates/repo/settings/runner_edit.tmpl @@ -0,0 +1,5 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings runners")}} + <div class="repo-setting-content"> + {{template "shared/actions/runner_edit" .}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/secrets.tmpl b/templates/repo/settings/secrets.tmpl new file mode 100644 index 0000000..0b89639 --- /dev/null +++ b/templates/repo/settings/secrets.tmpl @@ -0,0 +1,5 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings")}} + <div class="repo-setting-content"> + {{template "shared/secrets/add_list" .}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/tags.tmpl b/templates/repo/settings/tags.tmpl new file mode 100644 index 0000000..e7a7aaa --- /dev/null +++ b/templates/repo/settings/tags.tmpl @@ -0,0 +1,126 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings edit")}} + <div class="repo-setting-content"> + {{if .Repository.IsArchived}} + <div class="ui warning message tw-text-center"> + {{ctx.Locale.Tr "repo.settings.archive.tagsettings_unavailable"}} + </div> + {{else}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.tags.protection"}} + </h4> + + <div class="ui attached segment"> + <div class="ui grid"> + <div class="sixteen wide column"> + <div class="ui segment"> + <form class="ui form" action="{{.Link}}" method="post"> + {{.CsrfTokenHtml}} + <div class="field"> + <label>{{ctx.Locale.Tr "repo.settings.tags.protection.pattern"}}</label> + <div id="search-tag-box" class="ui search"> + <div class="ui input"> + <input class="prompt" name="name_pattern" autocomplete="off" value="{{.name_pattern}}" placeholder="v*" autofocus required> + </div> + <div class="help">{{ctx.Locale.Tr "repo.settings.tags.protection.pattern.description" "https://forgejo.org/docs/latest/user/protection/#protected-tags"}}</div> + </div> + </div> + <div class="whitelist field"> + <label>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed.users"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="allowlist_users" value="{{.allowlist_users}}"> + <div class="default text">{{ctx.Locale.Tr "search.user_kind"}}</div> + <div class="menu"> + {{range .Users}} + <div class="item" data-value="{{.ID}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}}{{template "repo/search_name" .}} + </div> + {{end}} + </div> + </div> + </div> + {{if .Owner.IsOrganization}} + <div class="whitelist field"> + <label>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed.teams"}}</label> + <div class="ui multiple search selection dropdown"> + <input type="hidden" name="allowlist_teams" value="{{.allowlist_teams}}"> + <div class="default text">{{ctx.Locale.Tr "search.team_kind"}}</div> + <div class="menu"> + {{range .Teams}} + <div class="item" data-value="{{.ID}}"> + {{svg "octicon-people"}} + {{.Name}} + </div> + {{end}} + </div> + </div> + </div> + {{end}} + <div class="field"> + {{if .PageIsEditProtectedTag}} + <button class="ui primary button"> + {{ctx.Locale.Tr "save"}} + </button> + <a class="ui primary button" href="{{$.RepoLink}}/settings/tags"> + {{ctx.Locale.Tr "cancel"}} + </a> + {{else}} + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.settings.tags.protection.create"}} + </button> + {{end}} + </div> + </form> + </div> + </div> + + <div class="sixteen wide column"> + <table class="ui single line table"> + <thead> + <th>{{ctx.Locale.Tr "repo.settings.tags.protection.pattern"}}</th> + <th>{{ctx.Locale.Tr "repo.settings.tags.protection.allowed"}}</th> + <th></th> + </thead> + <tbody> + {{range .ProtectedTags}} + <tr> + <td><pre>{{.NamePattern}}</pre></td> + <td> + {{if or .AllowlistUserIDs (and $.Owner.IsOrganization .AllowlistTeamIDs)}} + {{$userIDs := .AllowlistUserIDs}} + {{range $.Users}} + {{if SliceUtils.Contains $userIDs .ID}} + <a class="ui basic label" href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 26}} {{.GetDisplayName}}</a> + {{end}} + {{end}} + {{if $.Owner.IsOrganization}} + {{$teamIDs := .AllowlistTeamIDs}} + {{range $.Teams}} + {{if SliceUtils.Contains $teamIDs .ID}} + <a class="ui basic label" href="{{$.Owner.OrganisationLink}}/teams/{{PathEscape .LowerName}}">{{.Name}}</a> + {{end}} + {{end}} + {{end}} + {{else}} + {{ctx.Locale.Tr "repo.settings.tags.protection.allowed.noone"}} + {{end}} + </td> + <td class="right aligned"> + <a class="ui tiny primary button" href="{{$.RepoLink}}/settings/tags/{{.ID}}">{{ctx.Locale.Tr "edit"}}</a> + <form class="tw-inline-block" action="{{$.RepoLink}}/settings/tags/delete" method="post"> + {{$.CsrfTokenHtml}} + <input type="hidden" name="id" value="{{.ID}}"> + <button class="ui tiny red button">{{ctx.Locale.Tr "remove"}}</button> + </form> + </td> + </tr> + {{else}} + <tr class="center aligned"><td colspan="3">{{ctx.Locale.Tr "repo.settings.tags.protection.none"}}</td></tr> + {{end}} + </tbody> + </table> + </div> + </div> + </div> + {{end}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/units.tmpl b/templates/repo/settings/units.tmpl new file mode 100644 index 0000000..66ed035 --- /dev/null +++ b/templates/repo/settings/units.tmpl @@ -0,0 +1,13 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings options")}} +<div class="user-main-content twelve wide column"> + <form class="ui form" method="post" action="{{.RepoLink}}/settings/units"> + {{.CsrfTokenHtml}} + {{template "repo/settings/units/overview" .}} + {{template "repo/settings/units/issues" .}} + {{if not .IsMirror}} + {{template "repo/settings/units/pulls" .}} + {{end}} + {{template "repo/settings/units/wiki" .}} + </form> +</div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/units/issues.tmpl b/templates/repo/settings/units/issues.tmpl new file mode 100644 index 0000000..b4217dd --- /dev/null +++ b/templates/repo/settings/units/issues.tmpl @@ -0,0 +1,102 @@ +<h4 class="ui top attached header" id="issues"> + {{ctx.Locale.Tr "repo.issues"}} +</h4> +<div class="ui attached segment"> + {{$isIssuesEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeIssues) (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}} + {{$isIssuesGlobalDisabled := .UnitTypeIssues.UnitGlobalDisabled}} + {{$isExternalTrackerGlobalDisabled := .UnitTypeExternalTracker.UnitGlobalDisabled}} + {{$isIssuesAndExternalGlobalDisabled := and $isIssuesGlobalDisabled $isExternalTrackerGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.issues"}}</label> + <div class="ui checkbox{{if $isIssuesAndExternalGlobalDisabled}} disabled{{end}}"{{if $isIssuesAndExternalGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_issues" type="checkbox" data-target="#issue_box" {{if $isIssuesEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.issues_desc"}}</label> + </div> + </div> + <div class="field {{if not $isIssuesEnabled}}disabled{{end}}" id="issue_box"> + <div class="field"> + <div class="ui radio checkbox{{if $isIssuesGlobalDisabled}} disabled{{end}}"{{if $isIssuesGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system-radio" name="enable_external_tracker" type="radio" value="false" data-context="#internal_issue_box" data-target="#external_issue_box" {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.use_internal_issue_tracker"}}</label> + </div> + </div> + <div class="field tw-pl-4 {{if (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}}disabled{{end}}" id="internal_issue_box"> + {{if .Repository.CanEnableTimetracker}} + <div class="field"> + <div class="ui checkbox"> + <input name="enable_timetracker" class="enable-system" data-target="#only_contributors" type="checkbox" {{if .Repository.IsTimetrackerEnabled $.Context}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.enable_timetracker"}}</label> + </div> + </div> + <div class="field {{if not (.Repository.IsTimetrackerEnabled $.Context)}}disabled{{end}}" id="only_contributors"> + <div class="ui checkbox"> + <input name="allow_only_contributors_to_track_time" type="checkbox" {{if .Repository.AllowOnlyContributorsToTrackTime $.Context}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.allow_only_contributors_to_track_time"}}</label> + </div> + </div> + {{end}} + <div class="field"> + <div class="ui checkbox"> + <input name="enable_issue_dependencies" type="checkbox" {{if (.Repository.IsDependenciesEnabled $.Context)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.issues.dependency.setting"}}</label> + </div> + </div> + <div class="ui checkbox"> + <input name="enable_close_issues_via_commit_in_any_branch" type="checkbox" {{if .Repository.CloseIssuesViaCommitInAnyBranch}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.admin_enable_close_issues_via_commit_in_any_branch"}}</label> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox{{if $isExternalTrackerGlobalDisabled}} disabled{{end}}"{{if $isExternalTrackerGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system-radio" name="enable_external_tracker" type="radio" value="true" data-context="#internal_issue_box" data-target="#external_issue_box" {{if .Repository.UnitEnabled $.Context $.UnitTypeExternalTracker}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.use_external_issue_tracker"}}</label> + </div> + </div> + <div class="field tw-pl-4 {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}}disabled{{end}}" id="external_issue_box"> + <div class="field"> + <label for="external_tracker_url">{{ctx.Locale.Tr "repo.settings.external_tracker_url"}}</label> + <input id="external_tracker_url" name="external_tracker_url" type="url" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker).ExternalTrackerConfig.ExternalTrackerURL}}"> + <p class="help">{{ctx.Locale.Tr "repo.settings.external_tracker_url_desc"}}</p> + </div> + <div class="field"> + <label for="tracker_url_format">{{ctx.Locale.Tr "repo.settings.tracker_url_format"}}</label> + <input id="tracker_url_format" name="tracker_url_format" type="url" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker).ExternalTrackerConfig.ExternalTrackerFormat}}" placeholder="https://github.com/{user}/{repo}/issues/{index}"> + <p class="help">{{ctx.Locale.Tr "repo.settings.tracker_url_format_desc"}}</p> + </div> + <div class="inline fields"> + <label for="issue_style">{{ctx.Locale.Tr "repo.settings.tracker_issue_style"}}</label> + <div class="field"> + <div class="ui radio checkbox"> + {{$externalTracker := (.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker)}} + {{$externalTrackerStyle := $externalTracker.ExternalTrackerConfig.ExternalTrackerStyle}} + <input class="js-tracker-issue-style" name="tracker_issue_style" type="radio" value="numeric" {{if eq $externalTrackerStyle "numeric"}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.tracker_issue_style.numeric"}} <span class="ui light grey text">#1234</span></label> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input class="js-tracker-issue-style" name="tracker_issue_style" type="radio" value="alphanumeric" {{if eq $externalTrackerStyle "alphanumeric"}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.tracker_issue_style.alphanumeric"}} <span class="ui light grey text">ABC-123 , DEFG-234</span></label> + </div> + </div> + <div class="field"> + <div class="ui radio checkbox"> + <input class="js-tracker-issue-style" name="tracker_issue_style" type="radio" value="regexp" {{if eq $externalTrackerStyle "regexp"}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.tracker_issue_style.regexp"}} <span class="ui light grey text">(ISSUE-\d+) , ISSUE-(\d+)</span></label> + </div> + </div> + </div> + <div class="field {{if ne $externalTrackerStyle "regexp"}}disabled{{end}}" id="tracker-issue-style-regex-box"> + <label for="external_tracker_regexp_pattern">{{ctx.Locale.Tr "repo.settings.tracker_issue_style.regexp_pattern"}}</label> + <input id="external_tracker_regexp_pattern" name="external_tracker_regexp_pattern" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker).ExternalTrackerConfig.ExternalTrackerRegexpPattern}}"> + <p class="help">{{ctx.Locale.Tr "repo.settings.tracker_issue_style.regexp_pattern_desc"}}</p> + </div> + </div> + </div> + + <div class="divider"></div> + + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> +</div> diff --git a/templates/repo/settings/units/overview.tmpl b/templates/repo/settings/units/overview.tmpl new file mode 100644 index 0000000..a851c66 --- /dev/null +++ b/templates/repo/settings/units/overview.tmpl @@ -0,0 +1,62 @@ +<h4 class="ui top attached header" id="overview"> + {{ctx.Locale.Tr "repo.settings.units.overview"}} +</h4> +<div class="ui attached segment"> + {{$isCodeEnabled := .Repository.UnitEnabled $.Context $.UnitTypeCode}} + {{$isCodeGlobalDisabled := .UnitTypeCode.UnitGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.code"}}</label> + <div class="ui checkbox{{if $isCodeGlobalDisabled}} disabled{{end}}"{{if $isCodeGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_code" type="checkbox"{{if $isCodeEnabled}} checked{{end}}> + <label>{{ctx.Locale.Tr "repo.code.desc"}}</label> + </div> + </div> + + {{$isProjectsEnabled := .Repository.UnitEnabled $.Context $.UnitTypeProjects}} + {{$isProjectsGlobalDisabled := .UnitTypeProjects.UnitGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.projects"}}</label> + <div class="ui checkbox{{if $isProjectsGlobalDisabled}} disabled{{end}}"{{if $isProjectsGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_projects" type="checkbox" {{if $isProjectsEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.projects_desc"}}</label> + </div> + </div> + + {{$isReleasesEnabled := .Repository.UnitEnabled $.Context $.UnitTypeReleases}} + {{$isReleasesGlobalDisabled := .UnitTypeReleases.UnitGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.releases"}}</label> + <div class="ui checkbox{{if $isReleasesGlobalDisabled}} disabled{{end}}"{{if $isReleasesGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_releases" type="checkbox" {{if $isReleasesEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.releases_desc"}}</label> + </div> + </div> + + {{$isPackagesEnabled := .Repository.UnitEnabled $.Context $.UnitTypePackages}} + {{$isPackagesGlobalDisabled := .UnitTypePackages.UnitGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.packages"}}</label> + <div class="ui checkbox{{if $isPackagesGlobalDisabled}} disabled{{end}}"{{if $isPackagesGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_packages" type="checkbox" {{if $isPackagesEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.packages_desc"}}</label> + </div> + </div> + + {{if .EnableActions}} + {{$isActionsEnabled := .Repository.UnitEnabled $.Context $.UnitTypeActions}} + {{$isActionsGlobalDisabled := .UnitTypeActions.UnitGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "actions.actions"}}</label> + <div class="ui checkbox{{if $isActionsGlobalDisabled}} disabled{{end}}"{{if $isActionsGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_actions" type="checkbox" {{if $isActionsEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.actions_desc"}}</label> + </div> + </div> + {{end}} + + <div class="divider"></div> + + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> +</div> diff --git a/templates/repo/settings/units/pulls.tmpl b/templates/repo/settings/units/pulls.tmpl new file mode 100644 index 0000000..4e9c53e --- /dev/null +++ b/templates/repo/settings/units/pulls.tmpl @@ -0,0 +1,132 @@ +<h4 class="ui top attached header" id="pulls"> + {{ctx.Locale.Tr "repo.pulls"}} +</h4> +<div class="ui attached segment"> + {{$pullRequestEnabled := .Repository.UnitEnabled $.Context $.UnitTypePullRequests}} + {{$pullRequestGlobalDisabled := .UnitTypePullRequests.UnitGlobalDisabled}} + {{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.pulls"}}</label> + <div class="ui checkbox{{if $pullRequestGlobalDisabled}} disabled{{end}}"{{if $pullRequestGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_pulls" type="checkbox" data-target="#pull_box" {{if $pullRequestEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls_desc"}}</label> + </div> + </div> + <div class="field{{if not $pullRequestEnabled}} disabled{{end}}" id="pull_box"> + <div class="field"> + <p> + {{ctx.Locale.Tr "repo.settings.merge_style_desc"}} + </p> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowMerge)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.merge_pull_request"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_rebase" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowRebase)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.rebase_merge_pull_request"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_rebase_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowRebaseMerge)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_squash" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowSquash)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.squash_merge_pull_request"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_fast_forward_only" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowFastForwardOnly)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.fast_forward_only_merge_pull_request"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_manual_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowManualMerge)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.pulls.merge_manually"}}</label> + </div> + </div> + + <div class="field"> + <p> + {{ctx.Locale.Tr "repo.settings.default_merge_style_desc"}} + </p> + <div class="ui dropdown selection"> + <select name="pulls_default_merge_style"> + <option value="merge" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "merge")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.merge_pull_request"}}</option> + <option value="rebase" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "rebase")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.rebase_merge_pull_request"}}</option> + <option value="rebase-merge" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "rebase-merge")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</option> + <option value="squash" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "squash")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.squash_merge_pull_request"}}</option> + <option value="fast-forward-only" {{if or (not $pullRequestEnabled) (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "fast-forward-only")}}selected{{end}}>{{ctx.Locale.Tr "repo.pulls.fast_forward_only_merge_pull_request"}}</option> + </select>{{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="default text"> + {{if (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "merge")}} + {{ctx.Locale.Tr "repo.pulls.merge_pull_request"}} + {{end}} + {{if (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "rebase")}} + {{ctx.Locale.Tr "repo.pulls.rebase_merge_pull_request"}} + {{end}} + {{if (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "rebase-merge")}} + {{ctx.Locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}} + {{end}} + {{if (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "squash")}} + {{ctx.Locale.Tr "repo.pulls.squash_merge_pull_request"}} + {{end}} + {{if (eq $prUnit.PullRequestsConfig.DefaultMergeStyle "fast-forward-only")}} + {{ctx.Locale.Tr "repo.pulls.fast_forward_only_merge_pull_request"}} + {{end}} + </div> + <div class="menu"> + <div class="item" data-value="merge">{{ctx.Locale.Tr "repo.pulls.merge_pull_request"}}</div> + <div class="item" data-value="rebase">{{ctx.Locale.Tr "repo.pulls.rebase_merge_pull_request"}}</div> + <div class="item" data-value="rebase-merge">{{ctx.Locale.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div> + <div class="item" data-value="squash">{{ctx.Locale.Tr "repo.pulls.squash_merge_pull_request"}}</div> + <div class="item" data-value="fast-forward-only">{{ctx.Locale.Tr "repo.pulls.fast_forward_only_merge_pull_request"}}</div> + </div> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="default_allow_maintainer_edit" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.DefaultAllowMaintainerEdit)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls.default_allow_edits_from_maintainers"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_allow_rebase_update" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AllowRebaseUpdate)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls.allow_rebase_update"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="default_delete_branch_after_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.DefaultDeleteBranchAfterMerge)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls.default_delete_branch_after_merge"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="enable_autodetect_manual_merge" type="checkbox" {{if or (not $pullRequestEnabled) ($prUnit.PullRequestsConfig.AutodetectManualMerge)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls.enable_autodetect_manual_merge"}}</label> + </div> + </div> + <div class="field"> + <div class="ui checkbox"> + <input name="pulls_ignore_whitespace" type="checkbox" {{if and $pullRequestEnabled ($prUnit.PullRequestsConfig.IgnoreWhitespaceConflicts)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.pulls.ignore_whitespace"}}</label> + </div> + </div> + </div> + + <div class="divider"></div> + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> +</div> diff --git a/templates/repo/settings/units/wiki.tmpl b/templates/repo/settings/units/wiki.tmpl new file mode 100644 index 0000000..23df294 --- /dev/null +++ b/templates/repo/settings/units/wiki.tmpl @@ -0,0 +1,51 @@ +<h4 class="ui top attached header" id="wiki"> + {{ctx.Locale.Tr "repo.wiki"}} +</h4> +<div class="ui attached segment"> + {{$isWikiEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeWiki) (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}} + {{$isWikiGlobalDisabled := .UnitTypeWiki.UnitGlobalDisabled}} + {{$isExternalWikiGlobalDisabled := .UnitTypeExternalWiki.UnitGlobalDisabled}} + {{$isBothWikiGlobalDisabled := and $isWikiGlobalDisabled $isExternalWikiGlobalDisabled}} + <div class="inline field"> + <label>{{ctx.Locale.Tr "repo.wiki"}}</label> + <div class="ui checkbox{{if $isBothWikiGlobalDisabled}} disabled{{end}}"{{if $isBothWikiGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system" name="enable_wiki" type="checkbox" data-target="#wiki_box" {{if $isWikiEnabled}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.wiki_desc"}}</label> + </div> + </div> + <div class="field{{if not $isWikiEnabled}} disabled{{end}}" id="wiki_box"> + <div class="field"> + <div class="ui radio checkbox{{if $isWikiGlobalDisabled}} disabled{{end}}"{{if $isWikiGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system-radio" name="enable_external_wiki" type="radio" value="false" data-context="#globally_writeable_checkbox" data-target="#external_wiki_box" {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.use_internal_wiki"}}</label> + </div> + </div> + {{if (not .Repository.IsPrivate)}} + <div class="field {{if (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}disabled{{end}}" id="globally_writeable_checkbox"> + <div class="field tw-pl-4"> + <div class="ui checkbox"> + <input name="globally_writeable_wiki" type="checkbox" {{if .Permission.IsGloballyWriteable $.UnitTypeWiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.wiki_globally_editable"}}</label> + </div> + </div> + </div> + {{end}} + <div class="field"> + <div class="ui radio checkbox{{if $isExternalWikiGlobalDisabled}} disabled{{end}}"{{if $isExternalWikiGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}> + <input class="enable-system-radio" name="enable_external_wiki" type="radio" value="true" data-context="#globally_writeable_checkbox" data-target="#external_wiki_box" {{if .Repository.UnitEnabled $.Context $.UnitTypeExternalWiki}}checked{{end}}> + <label>{{ctx.Locale.Tr "repo.settings.use_external_wiki"}}</label> + </div> + </div> + <div class="field tw-pl-4 {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}disabled{{end}}" id="external_wiki_box"> + <label for="external_wiki_url">{{ctx.Locale.Tr "repo.settings.external_wiki_url"}}</label> + <input id="external_wiki_url" name="external_wiki_url" type="url" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}"> + <p class="help">{{ctx.Locale.Tr "repo.settings.external_wiki_url_desc"}}</p> + </div> + </div> + + <div class="divider"></div> + + <div class="field"> + <button class="ui primary button">{{ctx.Locale.Tr "repo.settings.update_settings"}}</button> + </div> +</div> diff --git a/templates/repo/settings/webhook/base.tmpl b/templates/repo/settings/webhook/base.tmpl new file mode 100644 index 0000000..d524722 --- /dev/null +++ b/templates/repo/settings/webhook/base.tmpl @@ -0,0 +1,5 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings webhooks")}} + <div class="repo-setting-content"> + {{template "repo/settings/webhook/list" .}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl new file mode 100644 index 0000000..36e75a7 --- /dev/null +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -0,0 +1,26 @@ +<h4 class="ui top attached header"> + {{.Title}} + <div class="ui right"> + <div class="ui jump dropdown"> + <div class="ui primary tiny button">{{ctx.Locale.Tr "repo.settings.add_webhook"}}</div> + {{template "repo/settings/webhook/link_menu" .}} + </div> + </div> +</h4> +<div class="ui attached segment"> + <div class="ui list"> + <div class="item"> + {{.Description}} + </div> + {{range .Webhooks}} + <div class="item truncated-item-container"> + <span class="text {{if eq .LastStatus 1}}green{{else if eq .LastStatus 2}}red{{else}}grey{{end}} tw-mr-2">{{svg "octicon-dot-fill" 22}}</span> + <div class="text truncate tw-flex-1 tw-mr-2"> + <a title="{{.URL}}" href="{{$.BaseLink}}/{{.ID}}">{{.URL}}</a> + </div> + <a class="muted tw-p-2" href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a> + <a class="delete-button tw-p-2" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}}</a> + </div> + {{end}} + </div> +</div> diff --git a/templates/repo/settings/webhook/delete_modal.tmpl b/templates/repo/settings/webhook/delete_modal.tmpl new file mode 100644 index 0000000..9955ed3 --- /dev/null +++ b/templates/repo/settings/webhook/delete_modal.tmpl @@ -0,0 +1,10 @@ +<div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.settings.webhook_deletion"}} + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.settings.webhook_deletion_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} +</div> diff --git a/templates/repo/settings/webhook/history.tmpl b/templates/repo/settings/webhook/history.tmpl new file mode 100644 index 0000000..8ee1446 --- /dev/null +++ b/templates/repo/settings/webhook/history.tmpl @@ -0,0 +1,90 @@ +{{$isNew:=or .PageIsSettingsHooksNew .PageIsAdminDefaultHooksNew .PageIsAdminSystemHooksNew}} +{{if .PageIsSettingsHooksEdit}} + <h4 class="ui top attached header"> + {{ctx.Locale.Tr "repo.settings.recent_deliveries"}} + {{if .Permission.IsAdmin}} + <div class="ui right"> + <!-- the button is wrapped with a span because the tooltip doesn't show on hover if we put data-tooltip-content directly on the button --> + <span data-tooltip-content="{{if or $isNew .Webhook.IsActive}}{{ctx.Locale.Tr "repo.settings.webhook.test_delivery_desc"}}{{else}}{{ctx.Locale.Tr "repo.settings.webhook.test_delivery_desc_disabled"}}{{end}}"> + <button class="ui teal tiny button{{if not (or $isNew .Webhook.IsActive)}} disabled{{end}}" id="test-delivery" data-link="{{.Link}}/test" data-redirect="{{.Link}}"> + <span class="text">{{ctx.Locale.Tr "repo.settings.webhook.test_delivery"}}</span> + </button> + </span> + </div> + {{end}} + </h4> + <div class="ui attached segment"> + <div class="ui list"> + {{range .History}} + <div class="item"> + <div class="flex-text-block tw-justify-between"> + <div class="flex-text-inline"> + {{if .IsSucceed}} + <span class="text green">{{svg "octicon-check"}}</span> + {{else if not .IsDelivered}} + <span class="text orange">{{svg "octicon-stopwatch"}}</span> + {{else}} + <span class="text red">{{svg "octicon-alert"}}</span> + {{end}} + <a class="ui primary sha label toggle button show-panel" data-panel="#info-{{.ID}}">{{.UUID}}</a> + </div> + <span class="text grey"> + {{TimeSince .Delivered.AsTime ctx.Locale}} + </span> + </div> + <div class="info tw-hidden" id="info-{{.ID}}"> + <div class="ui top attached tabular menu"> + <a class="item active" data-tab="request-{{.ID}}">{{ctx.Locale.Tr "repo.settings.webhook.request"}}</a> + <a class="item" data-tab="response-{{.ID}}"> + {{ctx.Locale.Tr "repo.settings.webhook.response"}} + {{if .ResponseInfo}} + {{if .IsSucceed}} + <span class="ui green label">{{.ResponseInfo.Status}}</span> + {{else}} + <span class="ui red label">{{.ResponseInfo.Status}}</span> + {{end}} + {{else}} + <span class="ui label">-</span> + {{end}} + </a> + {{if or $.Permission.IsAdmin $.IsOrganizationOwner $.PageIsAdmin $.PageIsUserSettings}} + <div class="right menu"> + <form class="item" action="{{$.Link}}/replay/{{.UUID}}" method="post"> + {{$.CsrfTokenHtml}} + <span data-tooltip-content="{{if $.Webhook.IsActive}}{{ctx.Locale.Tr "repo.settings.webhook.replay.description"}}{{else}}{{ctx.Locale.Tr "repo.settings.webhook.replay.description_disabled"}}{{end}}"> + <button class="ui tiny button{{if not $.Webhook.IsActive}} disabled{{end}}">{{svg "octicon-sync"}}</button> + </span> + </form> + </div> + {{end}} + </div> + <div class="ui bottom attached tab segment active" data-tab="request-{{.ID}}"> + {{if .RequestInfo}} + <h5>{{ctx.Locale.Tr "repo.settings.webhook.headers"}}</h5> + <pre class="webhook-info"><strong>Request URL:</strong> {{.RequestInfo.URL}} +<strong>Request method:</strong> {{if .RequestInfo.HTTPMethod}}{{.RequestInfo.HTTPMethod}}{{else}}POST{{end}} +{{range $key, $val := .RequestInfo.Headers}}<strong>{{$key}}:</strong> {{$val}} +{{end}}</pre> + <h5>{{ctx.Locale.Tr "repo.settings.webhook.payload"}}</h5> + <pre class="webhook-info"><code class="json">{{or .RequestInfo.Body .PayloadContent}}</code></pre> + {{else}} + - + {{end}} + </div> + <div class="ui bottom attached tab segment" data-tab="response-{{.ID}}"> + {{if .ResponseInfo}} + <h5>{{ctx.Locale.Tr "repo.settings.webhook.headers"}}</h5> + <pre class="webhook-info">{{range $key, $val := .ResponseInfo.Headers}}<strong>{{$key}}:</strong> {{$val}} +{{end}}</pre> + <h5>{{ctx.Locale.Tr "repo.settings.webhook.body"}}</h5> + <pre class="webhook-info"><code>{{.ResponseInfo.Body}}</code></pre> + {{else}} + - + {{end}} + </div> + </div> + </div> + {{end}} + </div> + </div> +{{end}} diff --git a/templates/repo/settings/webhook/link_menu.tmpl b/templates/repo/settings/webhook/link_menu.tmpl new file mode 100644 index 0000000..2edc5af --- /dev/null +++ b/templates/repo/settings/webhook/link_menu.tmpl @@ -0,0 +1,12 @@ +{{$size := 20}} +{{if .Size}} + {{$size = .Size}} +{{end}} +<div class="menu"> + {{range .WebhookList}} + <a class="item" href="{{$.BaseLinkNew}}/{{.Type}}/new"> + {{.Icon $size}} + {{ctx.Locale.Tr (print "repo.settings.web_hook_name_" .Type)}} + </a> + {{end}} +</div> diff --git a/templates/repo/settings/webhook/list.tmpl b/templates/repo/settings/webhook/list.tmpl new file mode 100644 index 0000000..b24159f --- /dev/null +++ b/templates/repo/settings/webhook/list.tmpl @@ -0,0 +1,4 @@ + +{{template "repo/settings/webhook/base_list" .}} + +{{template "repo/settings/webhook/delete_modal" .}} diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl new file mode 100644 index 0000000..b04a442 --- /dev/null +++ b/templates/repo/settings/webhook/new.tmpl @@ -0,0 +1,7 @@ +{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings new webhook")}} + <div class="repo-setting-content"> + {{$CustomHeaderTitle := ctx.Locale.Tr "repo.settings.update_webhook"}} + {{if .PageIsSettingsHooksNew}}{{$CustomHeaderTitle = ctx.Locale.Tr "repo.settings.add_webhook"}}{{end}} + {{template "webhook/new" (dict "ctxData" . "CustomHeaderTitle" $CustomHeaderTitle)}} + </div> +{{template "repo/settings/layout_footer" .}} diff --git a/templates/repo/shabox_badge.tmpl b/templates/repo/shabox_badge.tmpl new file mode 100644 index 0000000..939292b --- /dev/null +++ b/templates/repo/shabox_badge.tmpl @@ -0,0 +1,15 @@ +<div class="ui detail icon button"> + {{if .verification.Verified}} + <div title="{{if eq .verification.TrustStatus "trusted"}}{{else if eq .verification.TrustStatus "untrusted"}}{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user"}}: {{else}}{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}: {{end}}{{.verification.Reason}}"> + {{if ne .verification.SigningUser.ID 0}} + {{svg "gitea-lock"}} + {{ctx.AvatarUtils.Avatar .verification.SigningUser 28 "signature"}} + {{else}} + <span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span> + {{ctx.AvatarUtils.AvatarByEmail .verification.SigningEmail "" 28 "signature"}} + {{end}} + </div> + {{else}} + <span title="{{ctx.Locale.Tr .verification.Reason}}">{{svg "gitea-unlock"}}</span> + {{end}} +</div> diff --git a/templates/repo/star_unstar.tmpl b/templates/repo/star_unstar.tmpl new file mode 100644 index 0000000..a407aa6 --- /dev/null +++ b/templates/repo/star_unstar.tmpl @@ -0,0 +1,14 @@ +<form hx-boost="true" hx-target="this" method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star"> + <div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.star_guest_user"}}"{{end}}> + <button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}> + {{if $.IsStaringRepo}} + {{svg "octicon-star-fill"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.unstar"}}</span> + {{else}} + {{svg "octicon-star"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.star"}}</span> + {{end}} + </button> + <a hx-boost="false" class="ui basic label" href="{{$.RepoLink}}/stars"> + {{CountFmt .Repository.NumStars}} + </a> + </div> +</form> diff --git a/templates/repo/sub_menu.tmpl b/templates/repo/sub_menu.tmpl new file mode 100644 index 0000000..ddf01b3 --- /dev/null +++ b/templates/repo/sub_menu.tmpl @@ -0,0 +1,45 @@ +{{if and (not .HideRepoInfo) (not .IsBlame)}} +<div class="ui segments repository-summary tw-mt-1 tw-mb-0"> + <div class="ui segment sub-menu repository-menu"> + {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo)}} + <a class="item muted {{if .PageIsCommits}}active{{end}}" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}"> + {{svg "octicon-history"}} {{ctx.Locale.TrN .CommitsCount "repo.n_commit_one" "repo.n_commit_few" (printf "<b>%d</b>" .CommitsCount | SafeHTML)}} + </a> + <a class="item muted {{if .PageIsBranches}}active{{end}}" href="{{.RepoLink}}/branches"> + {{svg "octicon-git-branch"}} {{ctx.Locale.TrN .BranchesCount "repo.n_branch_one" "repo.n_branch_few" (printf "<b>%d</b>" .BranchesCount | SafeHTML)}} + </a> + {{if $.Permission.CanRead $.UnitTypeCode}} + <a class="item muted {{if .PageIsTagList}}active{{end}}" href="{{.RepoLink}}/tags"> + {{svg "octicon-tag"}} {{ctx.Locale.TrN .NumTags "repo.n_tag_one" "repo.n_tag_few" (printf "<b>%d</b>" .NumTags | SafeHTML)}} + </a> + {{end}} + <span class="item not-mobile" {{if not (eq .Repository.Size 0)}}data-tooltip-content="{{.Repository.SizeDetailsString ctx.Locale}}"{{end}}> + {{$fileSizeFields := ctx.Locale.TrSize .Repository.Size}} + {{svg "octicon-database"}} <b>{{$fileSizeFields.PrettyNumber}}</b> {{$fileSizeFields.TranslatedUnit}} + </span> + {{end}} + </div> + {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo) .LanguageStats}} + <div class="ui segment sub-menu language-stats-details tw-hidden"> + {{range .LanguageStats}} + <div class="item"> + <i class="color-icon" style="background-color: {{.Color}}"></i> + <span class="tw-font-semibold"> + {{if eq .Language "other"}} + {{ctx.Locale.Tr "repo.language_other"}} + {{else}} + {{.Language}} + {{end}} + </span> + {{.Percentage}}% + </div> + {{end}} + </div> + <a class="ui segment language-stats show-panel toggle" data-panel=".repository-summary > .sub-menu"> + {{range .LanguageStats}} + <div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}} data-tooltip-follow-cursor="horizontal"></div> + {{end}} + </a> + {{end}} +</div> +{{end}} diff --git a/templates/repo/tag/list.tmpl b/templates/repo/tag/list.tmpl new file mode 100644 index 0000000..82f3dc0 --- /dev/null +++ b/templates/repo/tag/list.tmpl @@ -0,0 +1,79 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository tags"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + {{template "repo/release_tag_header" .}} + <h4 class="ui top attached header"> + <div class="five wide column tw-flex tw-items-center"> + {{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.tags"}} + </div> + </h4> + {{$canReadReleases := $.Permission.CanRead $.UnitTypeReleases}} + <div class="ui attached table segment"> + <table class="ui very basic striped fixed table single line" id="tags-table"> + <tbody class="tag-list"> + {{range $idx, $release := .Releases}} + <tr> + <td class="tag"> + <h3 class="release-tag-name tw-mb-2 tw-flex"> + {{if $canReadReleases}} + <a class="tw-flex tw-items-center" href="{{$.RepoLink}}/releases/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a> + {{else}} + <a class="tw-flex tw-items-center" href="{{$.RepoLink}}/src/tag/{{.TagName | PathEscapeSegments}}" rel="nofollow">{{.TagName}}</a> + {{end}} + {{template "repo/tag/verification_box" (dict "ctxData" $ "release" $release)}} + </h3> + <div class="download tw-flex tw-items-center"> + {{if $.Permission.CanRead $.UnitTypeCode}} + {{if .CreatedUnix}} + <span class="tw-mr-2">{{svg "octicon-clock" 16 "tw-mr-1"}}{{TimeSinceUnix .CreatedUnix ctx.Locale}}</span> + {{end}} + + <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> + + {{if not $.DisableDownloadSourceArchives}} + <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> + <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> + {{end}} + + {{if (and $canReadReleases $.CanCreateRelease $release.IsTag)}} + <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> + {{end}} + + {{if (and ($.Permission.CanWrite $.UnitTypeCode) $release.IsTag)}} + <a class="ui delete-button tw-mr-2 muted" data-url="{{$.RepoLink}}/tags/delete" data-id="{{.ID}}"> + {{svg "octicon-trash" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.release.delete_tag"}} + </a> + {{end}} + + {{if and $canReadReleases (not $release.IsTag)}} + <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> + {{end}} + {{end}} + </div> + </td> + </tr> + {{end}} + </tbody> + </table> + </div> + + {{template "base/paginate" .}} + </div> +</div> + +{{if $.Permission.CanWrite $.UnitTypeCode}} +<div class="ui g-modal-confirm delete modal"> + <div class="header"> + {{svg "octicon-trash"}} + {{ctx.Locale.Tr "repo.release.delete_tag"}} + </div> + <div class="content"> + <p>{{ctx.Locale.Tr "repo.release.deletion_tag_desc"}}</p> + </div> + {{template "base/modal_actions_confirm" .}} +</div> +{{end}} + +{{template "base/footer" .}} diff --git a/templates/repo/tag/verification_box.tmpl b/templates/repo/tag/verification_box.tmpl new file mode 100644 index 0000000..3cf88ac --- /dev/null +++ b/templates/repo/tag/verification_box.tmpl @@ -0,0 +1,27 @@ +{{$v := call .ctxData.VerifyTag .release}} +{{if call .ctxData.HasSignature $v}} + {{$class := "isSigned"}} + {{$href := ""}} + {{if $v.Verified}} + {{$href = $v.SigningUser.HomeLink}} + {{$class = (print $class " isVerified")}} + {{else}} + {{$class = (print $class " isWarning")}} + {{end}} + + <a {{if $href}}href="{{$href}}"{{end}} class="ui label tw-ml-2 {{$class}}"> + {{if $v.Verified}} + <div title="{{$v.Reason}}"> + {{if ne $v.SigningUser.ID 0}} + {{svg "gitea-lock"}} + {{ctx.AvatarUtils.Avatar $v.SigningUser 28 "signature"}} + {{else}} + <span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span> + {{ctx.AvatarUtils.AvatarByEmail $v.Verification.SigningEmail "" 28 "signature"}} + {{end}} + </div> + {{else}} + <span title="{{ctx.Locale.Tr $v.Reason}}">{{svg "gitea-unlock"}}</span> + {{end}} + </a> +{{end}} diff --git a/templates/repo/tag/verification_line.tmpl b/templates/repo/tag/verification_line.tmpl new file mode 100644 index 0000000..5f8335a --- /dev/null +++ b/templates/repo/tag/verification_line.tmpl @@ -0,0 +1,80 @@ +{{$v := call .ctxData.VerifyTag .release}} +{{if call .ctxData.HasSignature $v}} + {{$class := "isSigned"}} + {{$href := ""}} + {{if $v.Verified}} + {{$href = $v.SigningUser.HomeLink}} + {{$class = (print $class " isVerified")}} + {{else}} + {{$class = (print $class " isWarning")}} + {{end}} + + <div class="ui attached message tw-text-left tw-flex tw-content-center tw-justify-between tag-signature-row tw-flex-wrap {{$class}}"> + <div class="tw-flex tw-content-center"> + {{if $v.Verified}} + {{if ne $v.SigningUser.ID 0}} + {{svg "gitea-lock" 16 "tw-mr-2"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}</span> + {{ctx.AvatarUtils.Avatar $v.SigningUser 28 "tw-mr-2"}} + <a href="{{$v.SigningUser.HomeLink}}"><strong>{{$v.SigningUser.GetDisplayName}}</strong></a> + {{else}} + <span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog" 16 "tw-mr-2"}}</span> + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.signed_by"}}:</span> + {{ctx.AvatarUtils.AvatarByEmail $v.SigningEmail "" 28 "tw-mr-2"}} + <strong>{{$v.SigningUser.GetDisplayName}}</strong> + {{end}} + {{else}} + {{svg "gitea-unlock" 16 "tw-mr-2"}} + <span class="ui text">{{ctx.Locale.Tr $v.Reason}}</span> + {{end}} + </div> + + <div class="tw-flex tw-content-center"> + {{if $v.Verified}} + {{if ne $v.SigningUser.ID 0}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + {{if $v.SigningSSHKey}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{$v.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{$v.SigningKey.PaddedKeyID}} + {{end}} + {{else}} + {{svg "octicon-unverified" 16 "tw-mr-2"}} + {{if $v.SigningSSHKey}} + <span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{$v.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2" data-tooltip-content="{{ctx.Locale.Tr "gpg.default_key"}}">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{$v.SigningKey.PaddedKeyID}} + {{end}} + {{end}} + {{else if $v.Warning}} + {{svg "octicon-unverified" 16 "tw-mr-2"}} + {{if $v.SigningSSHKey}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{$v.SigningSSHKey.Fingerprint}} + {{else}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{$v.SigningKey.PaddedKeyID}} + {{end}} + {{else}} + {{if $v.SigningKey}} + {{if ne $v.SigningKey.KeyID ""}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.gpg_key_id"}}:</span> + {{$v.SigningKey.PaddedKeyID}} + {{end}} + {{end}} + {{if $v.SigningSSHKey}} + {{if ne $v.SigningSSHKey.Fingerprint ""}} + {{svg "octicon-verified" 16 "tw-mr-2"}} + <span class="ui text tw-mr-2">{{ctx.Locale.Tr "repo.commits.ssh_key_fingerprint"}}:</span> + {{$v.SigningSSHKey.Fingerprint}} + {{end}} + {{end}} + {{end}} + </div> + </div> +{{end}} diff --git a/templates/repo/unicode_escape_prompt.tmpl b/templates/repo/unicode_escape_prompt.tmpl new file mode 100644 index 0000000..8bceafa --- /dev/null +++ b/templates/repo/unicode_escape_prompt.tmpl @@ -0,0 +1,22 @@ +{{if .EscapeStatus}} + {{if .EscapeStatus.HasInvisible}} + <div class="ui warning message unicode-escape-prompt tw-text-left"> + <button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button> + <div class="header"> + {{ctx.Locale.Tr "repo.invisible_runes_header"}} + </div> + <p>{{ctx.Locale.Tr "repo.invisible_runes_description"}}</p> + {{if .EscapeStatus.HasAmbiguous}} + <p>{{ctx.Locale.Tr "repo.ambiguous_runes_description"}}</p> + {{end}} + </div> + {{else if .EscapeStatus.HasAmbiguous}} + <div class="ui warning message unicode-escape-prompt tw-text-left"> + <button class="btn close icon hide-panel" data-panel-closest=".message">{{svg "octicon-x" 16 "close inside"}}</button> + <div class="header"> + {{ctx.Locale.Tr "repo.ambiguous_runes_header"}} + </div> + <p>{{ctx.Locale.Tr "repo.ambiguous_runes_description"}}</p> + </div> + {{end}} +{{end}} diff --git a/templates/repo/upload.tmpl b/templates/repo/upload.tmpl new file mode 100644 index 0000000..eef5199 --- /dev/null +++ b/templates/repo/upload.tmpl @@ -0,0 +1,15 @@ +<div + class="ui dropzone" + data-link-url="{{.UploadLinkUrl}}" + data-upload-url="{{.UploadUrl}}" + data-remove-url="{{.UploadRemoveUrl}}" + data-accepts="{{.UploadAccepts}}" + data-max-file="{{.UploadMaxFiles}}" + data-max-size="{{.UploadMaxSize}}" + data-default-message="{{ctx.Locale.Tr "dropzone.default_message"}}" + data-invalid-input-type="{{ctx.Locale.Tr "dropzone.invalid_input_type"}}" + data-file-too-big="{{ctx.Locale.Tr "dropzone.file_too_big"}}" + data-remove-file="{{ctx.Locale.Tr "dropzone.remove_file"}}" +> + <div class="files"></div> +</div> diff --git a/templates/repo/user_cards.tmpl b/templates/repo/user_cards.tmpl new file mode 100644 index 0000000..88178db --- /dev/null +++ b/templates/repo/user_cards.tmpl @@ -0,0 +1,32 @@ +<div class="user-cards"> + {{if .CardsTitle}} + <h2> + {{.CardsTitle}} + </h2> + {{end}} + <ul class="list"> + {{range .Cards}} + <li class="card"> + <a href="{{.HomeLink}}"> + {{ctx.AvatarUtils.Avatar .}} + </a> + <div> + <h3 class="name"> + <a href="{{.HomeLink}}">{{.DisplayName}}</a> + </h3> + <div class="meta"> + {{if .Website}} + {{svg "octicon-link"}} <a href="{{.Website}}" target="_blank" rel="noopener noreferrer">{{.Website}}</a> + {{else if .Location}} + {{svg "octicon-location"}} {{.Location}} + {{else}} + {{svg "octicon-calendar"}} {{ctx.Locale.Tr "user.joined_on" (DateTime "short" .CreatedUnix)}} + {{end}} + </div> + </div> + </li> + {{end}} + </ul> + + {{template "base/paginate" .}} +</div> diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl new file mode 100644 index 0000000..d127c2e --- /dev/null +++ b/templates/repo/view_file.tmpl @@ -0,0 +1,158 @@ +<div {{if .ReadmeInList}}id="readme" {{end}}class="{{TabSizeClass .Editorconfig .FileName}} non-diff-file-content"> + {{- if .FileError}} + <div class="ui error message"> + <div class="text left tw-whitespace-pre">{{.FileError}}</div> + </div> + {{end}} + {{- if .FileWarning}} + <div class="ui warning message"> + <div class="text left tw-whitespace-pre">{{.FileWarning}}</div> + </div> + {{end}} + + {{if not .ReadmeInList}} + <div id="repo-file-commit-box" class="ui segment list-header tw-mb-4 tw-flex tw-justify-between"> + <div class="latest-commit"> + {{template "repo/latest_commit" .}} + </div> + {{if .LatestCommit}} + {{if .LatestCommit.Committer}} + <div class="text grey age"> + {{TimeSince .LatestCommit.Committer.When ctx.Locale}} + </div> + {{end}} + {{end}} + </div> + {{end}} + + <h4 class="file-header ui top attached header tw-flex tw-items-center tw-justify-between tw-flex-wrap"> + <div class="file-header-left tw-flex tw-items-center tw-py-2 tw-pr-4"> + {{if .ReadmeInList}} + {{svg "octicon-book" 16 "tw-mr-2"}} + <strong><a class="default-link muted" href="#readme">{{.FileName}}</a></strong> + {{else}} + {{template "repo/file_info" .}} + {{end}} + </div> + <div class="file-header-right file-actions tw-flex tw-items-center tw-flex-wrap"> + {{if .HasSourceRenderedToggle}} + <div class="ui compact icon buttons"> + <a href="?display=source" class="ui mini basic button {{if .IsDisplayingSource}}active{{end}}" data-tooltip-content="{{ctx.Locale.Tr "repo.file_view_source"}}">{{svg "octicon-code" 15}}</a> + <a href="{{$.Link}}" class="ui mini basic button {{if .IsDisplayingRendered}}active{{end}}" data-tooltip-content="{{ctx.Locale.Tr "repo.file_view_rendered"}}">{{svg "octicon-file" 15}}</a> + </div> + {{end}} + {{if not .ReadmeInList}} + <div class="ui buttons tw-mr-1"> + {{if .SymlinkURL}} + <a class="ui mini basic button" href="{{$.SymlinkURL}}" data-kind="follow-symlink">{{ctx.Locale.Tr "repo.file_follow"}}</a> + {{end}} + <a class="ui mini basic button" href="{{$.RawFileLink}}">{{ctx.Locale.Tr "repo.file_raw"}}</a> + {{if not .IsViewCommit}} + <a class="ui mini basic button" href="{{.RepoLink}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.file_permalink"}}</a> + {{end}} + {{if .IsRepresentableAsText}} + <a class="ui mini basic button" href="{{.RepoLink}}/blame/{{.BranchNameSubURL}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.blame"}}</a> + {{end}} + <a class="ui mini basic button" href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.file_history"}}</a> + {{if .EscapeStatus.Escaped}} + <button class="ui mini basic button unescape-button tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> + <button class="ui mini basic button escape-button">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> + {{end}} + </div> + <a download href="{{$.RawFileLink}}"><span class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.download_file"}}">{{svg "octicon-download"}}</span></a> + <a href="#" id="copy-content" class="btn-octicon {{if not .CanCopyContent}} disabled{{end}}"{{if or .IsImageFile (and .HasSourceRenderedToggle (not .IsDisplayingSource))}} data-link="{{$.RawFileLink}}"{{end}} data-tooltip-content="{{if .CanCopyContent}}{{ctx.Locale.Tr "copy_content"}}{{else}}{{ctx.Locale.Tr "copy_type_unsupported"}}{{end}}">{{svg "octicon-copy" 14}}</a> + {{if .EnableFeed}} + {{if .IsViewBranch}} + <a class="btn-octicon" href="{{$.FeedURL}}/rss/{{$.BranchNameSubURL}}/{{PathEscapeSegments .TreePath}}" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}"> + {{svg "octicon-rss" 14}} + </a> + {{else}} + <span class="btn-octicon disabled" data-tooltip-content="{{ctx.Locale.Tr "repo.rss.must_be_on_branch"}}"> + {{svg "octicon-rss" 14}} + </span> + {{end}} + {{end}} + {{if .Repository.CanEnableEditor}} + {{if .CanEditFile}} + <a href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}"><span class="btn-octicon" data-tooltip-content="{{.EditFileTooltip}}">{{svg "octicon-pencil"}}</span></a> + {{else}} + <span class="btn-octicon disabled" data-tooltip-content="{{.EditFileTooltip}}">{{svg "octicon-pencil"}}</span> + {{end}} + {{if .CanDeleteFile}} + <a href="{{.RepoLink}}/_delete/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}"><span class="btn-octicon btn-octicon-danger" data-tooltip-content="{{.DeleteFileTooltip}}">{{svg "octicon-trash"}}</span></a> + {{else}} + <span class="btn-octicon disabled" data-tooltip-content="{{.DeleteFileTooltip}}">{{svg "octicon-trash"}}</span> + {{end}} + {{end}} + {{else if .EscapeStatus.Escaped}} + <button class="ui mini basic button unescape-button tw-mr-1 tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> + <button class="ui mini basic button escape-button tw-mr-1">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> + {{end}} + {{if and .ReadmeInList .CanEditReadmeFile}} + <a class="btn-octicon" data-tooltip-content="{{ctx.Locale.Tr "repo.editor.edit_this_file"}}" href="{{.RepoLink}}/_edit/{{PathEscapeSegments .BranchName}}/{{PathEscapeSegments .TreePath}}/{{PathEscapeSegments .FileName}}">{{svg "octicon-pencil"}}</a> + {{end}} + </div> + </h4> + <div class="ui bottom attached table unstackable segment"> + {{if not (or .IsMarkup .IsRenderedHTML)}} + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}} + {{end}} + <div class="file-view{{if .IsMarkup}} markup {{.MarkupType}}{{else if .IsPlainText}} plain-text{{else if .IsTextSource}} code-view{{end}}"> + {{if .IsMarkup}} + {{if .FileContent}}{{.FileContent}}{{end}} + {{else if .IsPlainText}} + <pre>{{if .FileContent}}{{.FileContent}}{{end}}</pre> + {{else if not .IsTextSource}} + <div class="view-raw"> + {{if .IsImageFile}} + <img src="{{$.RawFileLink}}"> + {{else if .IsVideoFile}} + <video controls src="{{$.RawFileLink}}"> + <strong>{{ctx.Locale.Tr "repo.video_not_supported_in_browser"}}</strong> + </video> + {{else if .IsAudioFile}} + <audio controls src="{{$.RawFileLink}}"> + <strong>{{ctx.Locale.Tr "repo.audio_not_supported_in_browser"}}</strong> + </audio> + {{else if .IsPDFFile}} + <div class="pdf-content is-loading" data-src="{{$.RawFileLink}}" data-fallback-button-text="{{ctx.Locale.Tr "repo.diff.view_file"}}"></div> + {{else}} + <a href="{{$.RawFileLink}}" rel="nofollow">{{ctx.Locale.Tr "repo.file_view_raw"}}</a> + {{end}} + </div> + {{else if .FileSize}} + {{if .IsFileTooLarge}} + <table> + <tbody> + <tr> + <td><strong>{{ctx.Locale.Tr "repo.file_too_large"}}</strong></td> + </tr> + </tbody> + </table> + {{else}} + <table> + <tbody> + {{range $idx, $code := .FileContent}} + {{$line := Eval $idx "+" 1}} + <tr> + <td id="L{{$line}}" class="lines-num"><span id="L{{$line}}" data-line-number="{{$line}}"></span></td> + {{if $.EscapeStatus.Escaped}} + <td class="lines-escape">{{if (index $.LineEscapeStatus $idx).Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{if (index $.LineEscapeStatus $idx).HasInvisible}}{{ctx.Locale.Tr "repo.invisible_runes_line"}} {{end}}{{if (index $.LineEscapeStatus $idx).HasAmbiguous}}{{ctx.Locale.Tr "repo.ambiguous_runes_line"}}{{end}}"></button>{{end}}</td> + {{end}} + <td rel="L{{$line}}" class="lines-code chroma"><code class="code-inner">{{$code}}</code></td> + </tr> + {{end}} + </tbody> + </table> + <div class="code-line-menu tippy-target"> + {{if $.Permission.CanRead $.UnitTypeIssues}} + <a class="item ref-in-new-issue" role="menuitem" data-url-issue-new="{{.RepoLink}}/issues/new" data-url-param-body-link="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}" rel="nofollow noindex">{{ctx.Locale.Tr "repo.issues.context.reference_issue"}}</a> + {{end}} + <a class="item view_git_blame" role="menuitem" href="{{.Repository.Link}}/blame/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}">{{ctx.Locale.Tr "repo.view_git_blame"}}</a> + <a class="item copy-line-permalink" role="menuitem" data-url="{{.Repository.Link}}/src/commit/{{PathEscape .CommitID}}/{{PathEscapeSegments .TreePath}}{{if $.HasSourceRenderedToggle}}?display=source{{end}}">{{ctx.Locale.Tr "repo.file_copy_permalink"}}</a> + </div> + {{end}} + {{end}} + </div> + </div> +</div> diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl new file mode 100644 index 0000000..b750e91 --- /dev/null +++ b/templates/repo/view_list.tmpl @@ -0,0 +1,72 @@ +<table id="repo-files-table" class="ui single line table tw-mt-0" {{if .HasFilesWithoutLatestCommit}}hx-indicator="tr.notready td.message span" hx-trigger="load" hx-swap="morph" hx-post="{{.LastCommitLoaderURL}}"{{end}}> + <thead> + <tr class="commit-list"> + <th class="tw-overflow-hidden" colspan="2"> + <div class="tw-flex"> + <div class="latest-commit"> + {{template "repo/latest_commit" .}} + </div> + </div> + </th> + <th class="text grey right age">{{if .LatestCommit}}{{if .LatestCommit.Committer}}{{TimeSince .LatestCommit.Committer.When ctx.Locale}}{{end}}{{end}}</th> + </tr> + </thead> + <tbody> + {{if .HasParentPath}} + <tr class="has-parent"> + <td colspan="3"><a class="muted" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">{{svg "octicon-reply" 16 "tw-mr-2"}}..</a></td> + </tr> + {{end}} + {{range $item := .Files}} + {{$entry := $item.Entry}} + {{$commit := $item.Commit}} + {{$subModuleFile := $item.SubModuleFile}} + <tr data-entryname="{{$entry.Name}}" data-ready="{{if $commit}}true{{else}}false{{end}}" class="{{if not $commit}}not{{end}}ready entry"> + <td class="name four wide"> + <span class="truncate"> + {{if $entry.IsSubModule}} + {{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}} {{/* FIXME: the usage of AppUrl seems incorrect, it would be fixed in the future, use AppSubUrl instead */}} + {{$icon := (svg "octicon-file-submodule" 16 "tw-mr-2")}} + {{if $refURL}} + <a class="muted" href="{{$refURL}}">{{$icon}}{{$entry.Name}}</a><span class="at">@</span><a href="{{$refURL}}/commit/{{PathEscape $subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a> + {{else}} + {{$icon}}{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}} + {{end}} + {{else}} + {{if $entry.IsDir}} + {{$subJumpablePathName := $entry.GetSubJumpablePathName}} + <a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}"> + {{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}} + {{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}} + {{svg "octicon-file-directory-fill" 16 "tw-mr-2" -}} + {{if eq $subJumpablePathFieldLast 0 -}} + {{$subJumpablePathName}} + {{else -}} + {{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast -}} + <span class="text light-2">{{StringUtils.Join $subJumpablePathPrefixes "/"}}</span>/{{index $subJumpablePathFields $subJumpablePathFieldLast}} + {{end}} + </a> + {{else}} + <a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $entry.Name}}" title="{{$entry.Name}}">{{svg (printf "octicon-%s" (EntryIcon $entry)) 16 "tw-mr-2"}}{{$entry.Name}}</a> + {{end}} + {{end}} + </span> + </td> + <td class="message nine wide"> + <span class="truncate"> + {{if $commit}} + {{$commitLink := printf "%s/commit/%s" $.RepoLink (PathEscape $commit.ID.String)}} + {{RenderCommitMessageLinkSubject $.Context $commit.Message $commitLink ($.Repository.ComposeMetas ctx)}} + {{else}} + <div class="ui active tiny slow centered inline"></div> + {{end}} + </span> + </td> + <td class="text right age three wide">{{if $commit}}{{TimeSince $commit.Committer.When ctx.Locale}}{{end}}</td> + </tr> + {{end}} + </tbody> +</table> +{{if and .ReadmeExist (or .IsMarkup .IsPlainText)}} + {{template "repo/view_file" .}} +{{end}} diff --git a/templates/repo/watch_unwatch.tmpl b/templates/repo/watch_unwatch.tmpl new file mode 100644 index 0000000..3fea509 --- /dev/null +++ b/templates/repo/watch_unwatch.tmpl @@ -0,0 +1,14 @@ +<form hx-boost="true" hx-target="this" method="post" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch"> + <div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{ctx.Locale.Tr "repo.watch_guest_user"}}"{{end}}> + <button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}> + {{if $.IsWatchingRepo}} + {{svg "octicon-eye-closed" 16}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.unwatch"}}</span> + {{else}} + {{svg "octicon-eye"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.watch"}}</span> + {{end}} + </button> + <a hx-boost="false" class="ui basic label" href="{{.RepoLink}}/watchers"> + {{CountFmt .Repository.NumWatches}} + </a> + </div> +</form> diff --git a/templates/repo/watchers.tmpl b/templates/repo/watchers.tmpl new file mode 100644 index 0000000..1828544 --- /dev/null +++ b/templates/repo/watchers.tmpl @@ -0,0 +1,8 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository watchers"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "repo/user_cards" .}} + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/wiki/new.tmpl b/templates/repo/wiki/new.tmpl new file mode 100644 index 0000000..81433db --- /dev/null +++ b/templates/repo/wiki/new.tmpl @@ -0,0 +1,48 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository wiki new"> + {{template "repo/header" .}} + <div class="ui container"> + {{template "base/alert" .}} + <div class="ui header flex-text-block tw-justify-between"> + {{ctx.Locale.Tr "repo.wiki.new_page"}} + {{if .PageIsWikiEdit}} + <a class="ui tiny primary button" href="{{.RepoLink}}/wiki?action=_new">{{ctx.Locale.Tr "repo.wiki.new_page_button"}}</a> + {{end}} + </div> + <form class="ui form" action="?action={{if .PageIsWikiEdit}}_edit{{else}}_new{{end}}" method="post"> + {{.CsrfTokenHtml}} + <div class="field {{if .Err_Title}}error{{end}}"> + <input name="title" value="{{.title}}" aria-label="{{ctx.Locale.Tr "repo.wiki.page_title"}}" placeholder="{{ctx.Locale.Tr "repo.wiki.page_title"}}" autofocus required> + </div> + <div class="help"> + {{ctx.Locale.Tr "repo.wiki.page_name_desc"}} + </div> + + {{$content := .content}} + {{if not .PageIsWikiEdit}} + {{$content = ctx.Locale.Tr "repo.wiki.welcome"}} + {{end}} + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "TextareaPlaceholder" (ctx.Locale.Tr "repo.wiki.page_content") + "TextareaAriaLabel" (ctx.Locale.Tr "repo.wiki.page_content") + "TextareaContent" $content + "EasyMDE" true + )}} + + <div class="field tw-mt-4"> + <input name="message" aria-label="{{ctx.Locale.Tr "repo.wiki.default_commit_message"}}" placeholder="{{ctx.Locale.Tr "repo.wiki.default_commit_message"}}"> + </div> + <div class="divider"></div> + <div class="text right"> + <button class="ui primary button"> + {{ctx.Locale.Tr "repo.wiki.save_page"}} + </button> + <a class="ui button red" href="{{.Link}}">{{ctx.Locale.Tr "repo.wiki.cancel"}}</a> + </div> + </form> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/wiki/pages.tmpl b/templates/repo/wiki/pages.tmpl new file mode 100644 index 0000000..42c36a9 --- /dev/null +++ b/templates/repo/wiki/pages.tmpl @@ -0,0 +1,30 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository wiki pages"> + {{template "repo/header" .}} + <div class="ui container"> + <h2 class="ui header tw-flex tw-items-center tw-justify-between"> + <span>{{ctx.Locale.Tr "repo.wiki.pages"}}</span> + <span> + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <a class="ui small primary button" href="{{.RepoLink}}/wiki?action=_new">{{ctx.Locale.Tr "repo.wiki.new_page_button"}}</a> + {{end}} + </span> + </h2> + <table class="ui table wiki-pages-list"> + <tbody> + {{range .Pages}} + <tr> + <td> + {{svg "octicon-file"}} + <a href="{{$.RepoLink}}/wiki/{{.SubURL}}">{{.Name}}</a> + <a class="wiki-git-entry" href="{{$.RepoLink}}/wiki/{{.GitEntryName | PathEscape}}" data-tooltip-content="{{ctx.Locale.Tr "repo.wiki.original_git_entry_tooltip"}}">{{svg "octicon-chevron-right"}}</a> + </td> + {{$timeSince := TimeSinceUnix .UpdatedUnix ctx.Locale}} + <td class="text right">{{ctx.Locale.Tr "repo.wiki.last_updated" $timeSince}}</td> + </tr> + {{end}} + </tbody> + </table> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/wiki/revision.tmpl b/templates/repo/wiki/revision.tmpl new file mode 100644 index 0000000..7fca703 --- /dev/null +++ b/templates/repo/wiki/revision.tmpl @@ -0,0 +1,40 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository wiki revisions"> + {{template "repo/header" .}} + {{$title := .title}} + <div class="ui container"> + <div class="ui stackable grid"> + <div class="ui eight wide column"> + <div class="ui header"> + <a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.back_to_wiki"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}"><span>{{.revision}}</span> {{svg "octicon-home"}}</a> + {{$title}} + <div class="ui sub header tw-break-anywhere"> + {{$timeSince := TimeSince .Author.When ctx.Locale}} + {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}} + </div> + </div> + </div> + <div class="ui eight wide column text right"> + <div class="clone-panel ui action small input"> + {{template "repo/clone_buttons" .}} + {{template "repo/clone_script" .}} + </div> + </div> + </div> + <h2 class="ui top header">{{ctx.Locale.Tr "repo.wiki.wiki_page_revisions"}}</h2> + <div class="tw-mt-4"> + <h4 class="ui top attached header"> + <div class="ui stackable grid"> + <div class="sixteen wide column"> + {{.CommitCount}} {{ctx.Locale.Tr "repo.commits.commits"}} + </div> + </div> + </h4> + {{if and .Commits (gt .CommitCount 0)}} + {{template "repo/commits_list" .}} + {{end}} + {{template "base/paginate" .}} + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/wiki/search.tmpl b/templates/repo/wiki/search.tmpl new file mode 100644 index 0000000..7f4cb9c --- /dev/null +++ b/templates/repo/wiki/search.tmpl @@ -0,0 +1,12 @@ +{{if .Results}} + {{range .Results}} + <a class="item tw-max-w-[min(80vw,calc(0.8*var(--container-width)))]" href="{{$.RepoLink}}/wiki/{{.Filename}}"> + <b class="tw-block tw-mb-2 tw-whitespace-break-spaces">{{.Title}}</b> + {{range .LineCodes}} + <p class="tw-my-0 tw-whitespace-break-spaces">{{.}}</p> + {{end}} + </a> + {{end}} +{{else}} + <div class="item muted">{{ctx.Locale.Tr "repo.wiki.no_search_results"}}</div> +{{end}} diff --git a/templates/repo/wiki/start.tmpl b/templates/repo/wiki/start.tmpl new file mode 100644 index 0000000..1b3c3d5 --- /dev/null +++ b/templates/repo/wiki/start.tmpl @@ -0,0 +1,15 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository wiki start"> + {{template "repo/header" .}} + <div class="ui container"> + <div class="ui center segment tw-py-8"> + {{svg "octicon-book" 48}} + <h2>{{ctx.Locale.Tr "repo.wiki.welcome"}}</h2> + <p>{{ctx.Locale.Tr "repo.wiki.welcome_desc"}}</p> + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <a class="ui primary button" href="{{.RepoLink}}/wiki?action=_new">{{ctx.Locale.Tr "repo.wiki.create_first_page"}}</a> + {{end}} + </div> + </div> +</div> +{{template "base/footer" .}} diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl new file mode 100644 index 0000000..40af307 --- /dev/null +++ b/templates/repo/wiki/view.tmpl @@ -0,0 +1,124 @@ +{{template "base/head" .}} +<div role="main" aria-label="{{.Title}}" class="page-content repository wiki view"> + {{template "repo/header" .}} + {{$title := .title}} + <div class="ui container"> + <div class="repo-button-row"> + <div class="tw-flex tw-items-center"> + <div class="ui floating filter dropdown" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}"> + <div class="ui basic small button"> + <span class="text"> + {{ctx.Locale.Tr "repo.wiki.page"}}: + <strong>{{$title}}</strong> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + </div> + <div class="menu"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-filter" 16}}</i> + <input name="search" placeholder="{{ctx.Locale.Tr "repo.wiki.filter_page"}}..."> + </div> + <div class="scrolling menu"> + <a class="item muted" href="{{.RepoLink}}/wiki/?action=_pages">{{ctx.Locale.Tr "repo.wiki.pages"}}</a> + <div class="divider"></div> + {{range .Pages}} + <a class="item {{if eq $.Title .Name}}selected{{end}}" href="{{$.RepoLink}}/wiki/{{.SubURL}}">{{.Name}}</a> + {{end}} + </div> + </div> + </div> + </div> + <div class="clone-panel ui action small input tw-ml-auto"> + {{template "repo/clone_buttons" .}} + {{template "repo/clone_script" .}} + </div> + <div class="ui floating dropdown jump tw-ml-auto"> + <div class="ui icon search input"> + <i class="icon">{{svg "octicon-search"}}</i> + <input type="search" name="q" hx-get="{{$.RepoLink}}/wiki/search" hx-target="#wiki-search" hx-swap="innerHTML" hx-trigger="keyup changed delay:.5s" placeholder="{{ctx.Locale.Tr "repo.wiki.search"}}..." /> + </div> + <div id="wiki-search" class="menu tw-absolute tw-max-h-[65dvh] tw-overflow-y-auto tw-mt-3 tw-rounded left"> + <div class="item muted">{{ctx.Locale.Tr "repo.wiki.no_search_results"}}</div> + </div> + </div> + </div> + <div class="ui dividing header"> + <div class="ui stackable grid"> + <div class="eight wide column"> + <a class="file-revisions-btn ui basic button" title="{{ctx.Locale.Tr "repo.wiki.file_revision"}}" href="{{.RepoLink}}/wiki/{{.PageURL}}?action=_revision" ><span>{{.CommitCount}}</span> {{svg "octicon-history"}}</a> + {{$title}} + <div class="ui sub header"> + {{$timeSince := TimeSince .Author.When ctx.Locale}} + {{ctx.Locale.Tr "repo.wiki.last_commit_info" .Author.Name $timeSince}} + </div> + </div> + <div class="eight wide right aligned column"> + {{if .EscapeStatus.Escaped}} + <a class="ui small button unescape-button tw-hidden">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</a> + <a class="ui small button escape-button">{{ctx.Locale.Tr "repo.escape_control_characters"}}</a> + {{end}} + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <div class="ui right"> + <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> + </div> + {{end}} + </div> + </div> + </div> + {{if .FormatWarning}} + <div class="ui negative message"> + <p>{{.FormatWarning}}</p> + </div> + {{end}} + + <div class="wiki-content-parts"> + {{if .sidebarTocContent}} + <div class="markup wiki-content-sidebar wiki-content-toc"> + {{.sidebarTocContent | SafeHTML}} + </div> + {{end}} + + <div class="markup wiki-content-main {{if or .sidebarTocContent .sidebarPresent}}with-sidebar{{end}}"> + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}} + {{.content | SafeHTML}} + </div> + + {{if .sidebarPresent}} + <div class="markup wiki-content-sidebar"> + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <a class="tw-float-right muted" href="{{.RepoLink}}/wiki/_Sidebar?action=_edit" aria-label="{{ctx.Locale.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> + {{end}} + {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .sidebarEscapeStatus "root" $}} + {{.sidebarContent | SafeHTML}} + </div> + {{end}} + + <div class="tw-clear-both"></div> + + {{if .footerPresent}} + <div class="markup wiki-content-footer"> + {{if and .CanWriteWiki (not .Repository.IsMirror)}} + <a class="tw-float-right muted" href="{{.RepoLink}}/wiki/_Footer?action=_edit" aria-label="{{ctx.Locale.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> + {{end}} + {{template "repo/unicode_escape_prompt" dict "footerEscapeStatus" .sidebarEscapeStatus "root" $}} + {{.footerContent | SafeHTML}} + </div> + {{end}} + </div> + </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> + {{template "base/modal_actions_confirm" .}} +</div> + +{{template "base/footer" .}} |