Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/build-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,25 @@ describe("Forgejo 15 native integration", () => {
expect(read("styles", "components", "newrepo.ts")).toContain(".page-content.repository.new.repo {");
});

it("shows the issue's branch as GitHub's Development section, last in both issue sidebars", () => {
const read = (...parts: string[]) =>
fs.readFileSync(path.join(ROOT_DIR, "templates", "repo", "issue", ...parts), "utf-8");
const field = read("view_content", "sidebar", "branch_selector_field.tmpl");
expect(field).toContain("<strong>Development</strong>");
expect(field).toContain('<span class="text branch-name gt-ellipsis">');
expect(field).not.toContain('<div class="divider"></div>');
const form = read("new_form.tmpl");
const order = [
"sidebar/assignees",
"labels_selector_field",
"select-project dropdown",
"select-milestone dropdown",
"sidebar/branch_selector_field",
].map(part => form.indexOf(part));
expect(order.every(index => index > 0)).toBe(true);
expect([...order].sort((a, b) => a - b)).toEqual(order);
});

it("matches GitHub's repository About, visibility, and code-search details", () => {
const headerStyle = fs.readFileSync(path.join(ROOT_DIR, "styles", "templates", "repo", "header.ts"), "utf-8");
const headerTemplate = fs.readFileSync(path.join(ROOT_DIR, "templates", "repo", "home_header.tmpl"), "utf-8");
Expand Down
23 changes: 22 additions & 1 deletion styles/components/issues/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ const prBranch = css`
}
`;

// GitHub's Development section in the issue sidebar: the linked branch or tag under the heading.
const issueDevelopment = css`
.issue-content-right .ui.dropdown.theme-issue-development {
display: flex;
flex-direction: column;
align-items: stretch;
}
.issue-content-right .theme-issue-development-ref {
display: flex;
align-items: center;
gap: 4px;
min-width: 0;
color: ${themeVars.color.text.light.num1};
font-size: 12px;
line-height: 18px;
> svg {
flex: none;
}
}
`;

const dropdown = css`
.repository {
/* Issue/PR 列表下的所有筛选菜单 */
Expand Down Expand Up @@ -148,4 +169,4 @@ const reactions = css`
}
`;

export default cssCombine(button, babel, prBranch, dropdown, issueTitle, reactions);
export default cssCombine(button, babel, prBranch, issueDevelopment, dropdown, issueTitle, reactions);
161 changes: 161 additions & 0 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{{/* Forgejo 17's new issue and pull request form with the sidebar in GitHub's order, as on an issue: assignees,
labels, projects, milestone, then Development (the branch or tag). */}}
{{if .Flash}}
{{template "base/alert" .}}
{{end}}
<form class="issue-content ui comment form form-fetch-action" id="new-issue" action="{{.Link}}" method="post">
<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/assignees" dict "isExistingIssue" false "." .}}

<div class="divider"></div>

<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" $}}

{{if or .IsProjectsEnabled (and .OwnerHasProjects .IsOwnerProjectsEnabled)}}
<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 "issues.search.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 16 "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 16 "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 16 "tw-mr-2"}}{{.Project.Title}}
</a>
{{end}}
</div>
</div>
{{end}}

<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 not .PageIsComparePull}}
<div class="divider"></div>
{{template "repo/issue/view_content/sidebar/branch_selector_field" .}}
{{end}}
{{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>
6 changes: 4 additions & 2 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
<div class="divider"></div>
{{end}}

{{/* Ends with its own divider on issues. */}}
{{template "repo/issue/view_content/sidebar/branch_selector_field" .}}
{{if not .Issue.IsPull}}
{{template "repo/issue/view_content/sidebar/branch_selector_field" .}}
<div class="divider"></div>
{{end}}

{{if and $.IssueWatch (not .Repository.IsArchived)}}
{{template "repo/issue/view_content/sidebar/watch" .}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{/* Forgejo 17's branch and tag selector as GitHub's Development section: a heading with the gear like the other
sidebar sections, then the linked branch or tag. The menu and its scripts are Forgejo's; the caller places the
dividers. */}}
{{if and (not .Issue.IsPull) (not .PageIsComparePull)}}
{{$hasIssuesOrPullsWritePermission := and .HasIssuesOrPullsWritePermission (not .Repository.IsArchived)}}
<input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}">
<input id="editing_mode" name="edit_mode" type="hidden" value="{{$hasIssuesOrPullsWritePermission}}">
<form method="post" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form">
</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 theme-issue-development" data-no-results="{{ctx.Locale.Tr "repo.pulls.no_results"}}">
<a class="text muted flex-text-block">
<strong>Development</strong>
{{if $hasIssuesOrPullsWritePermission}}{{svg "octicon-gear" 16 "tw-ml-1"}}{{end}}
</a>
{{/* Forgejo's script writes the chosen branch or tag into .branch-name inside a .ui element of this dropdown. */}}
<div class="ui theme-issue-development-ref">
{{svg "octicon-git-branch" 16}}
<span class="text branch-name gt-ellipsis">{{if .Reference}}{{$.RefEndName}}{{else}}{{ctx.Locale.Tr "repo.issues.no_ref"}}{{end}}</span>
</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="branch-tag-tab">
<a class="branch-tag-item muted" href="#" data-target="#branch-list">
{{svg "octicon-git-branch"}}{{ctx.Locale.Tr "repo.branches"}}
</a>
<a class="branch-tag-item muted" href="#" data-target="#tag-list">
{{svg "octicon-tag"}}{{ctx.Locale.Tr "repo.tags"}}
</a>
</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>
{{end}}
Loading