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
7 changes: 7 additions & 0 deletions src/build-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,13 @@ describe("Forgejo 15 native integration", () => {
expect(home).toContain('{{template "components/dashboard/context/context" dict "Data" . "Page" ""}}');
expect(home).toContain('{{template "components/dashboard/context/pages" dict "Data" . "Current" "home"}}');
expect(home).toContain('template "components/repository/picker/picker"');
// With organizations, the repositories heading opens a menu that swaps in the organizations, chosen before paint.
expect(home).toContain('"Items" "user/dashboard/home_lists"');
expect(home).toContain("{{range .Orgs}}");
expect(home).toContain('localStorage.getItem(key) === "organizations"');
// Switching lists is not an unsaved change: Forgejo's leave-page warning skips the form.
expect(home).toContain('<form class="ui form ignore-dirty github-home-list-form">');
expect(read("templates", "user", "dashboard", "home_lists.tmpl")).toContain('"Value" "organizations"');
expect(home).not.toContain('template "user/heatmap"');
expect(home).not.toContain('template "user/dashboard/repolist"');
// The feed in day groups beside the work rail; the profile keeps Forgejo's own feed.
Expand Down
39 changes: 39 additions & 0 deletions styles/pages/dashboard-home.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,45 @@
color: var(--color-text-light-1);
}

/* With organizations, the heading is a quiet menu that reads like the plain heading: its text, then a caret. */
/* Fomantic's .ui.form sets 14px; the heading's 12px/600 passes through to the trigger instead. */
.ui.form.github-home-list-form {
display: inline-block;
margin: 0;
font: inherit;
}

.github-home-list-menu > summary.theme-control {
gap: 2px;
height: auto;
min-height: 0;
margin-left: -4px;
padding: 2px 4px;
color: inherit;
font: inherit;
}

.github-home-list-menu > summary.theme-control > .svg {
color: inherit;
}

.github-home-list-menu > .theme-dropdown-panel {
inset: calc(100% + 4px) auto auto 0;
width: 200px;
}

/* One list at a time; the organizations show once chosen. */
.github-home-repositories[data-github-home-list="repositories"] > .github-home-organizations,
.github-home-repositories[data-github-home-list="organizations"] > .theme-repo-picker,
.github-home-repositories[data-github-home-list="organizations"] .theme-icon-button[data-theme-repo-picker-toggle] {
display: none;
}

.github-home-organizations .ui.avatar {
flex: none;
border-radius: 4px;
}

.page-content.theme-sidebar-layout[data-theme-sidebar] > .ui.container.theme-sidebar-main.github-home-main {
max-width: 1280px !important;
}
Expand Down
44 changes: 42 additions & 2 deletions templates/user/dashboard/dashboard.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,54 @@ organization's pages in the sidebar. */}}
{{template "components/dashboard/context/context" dict "Data" . "Page" ""}}
{{template "components/dashboard/context/pages" dict "Data" . "Current" "home"}}
<hr>
<section class="github-home-repositories" aria-labelledby="github-home-repositories-title">
{{/* GitHub's heading over the top repositories. With organizations, the heading opens a menu that swaps the list
for them; the choice is kept in the browser and restored before the first paint. */}}
<section class="github-home-repositories" aria-labelledby="github-home-repositories-title" data-github-home-list="repositories">
<div class="github-home-repositories-heading">
<h2 id="github-home-repositories-title">{{ctx.Locale.Tr "home.my_repos"}}</h2>
<h2 id="github-home-repositories-title">
{{- /* The form only gives the options the dropdown's form styles; choosing one never submits it, and ignore-dirty keeps Forgejo from warning about unsaved changes. */}}
{{- if .Orgs}}<form class="ui form ignore-dirty github-home-list-form">{{template "components/common/dropdown/dropdown" dict "Kind" "single" "Quiet" true "Label" (ctx.Locale.Tr "home.my_repos") "UpdateLabel" true "Class" "github-home-list-menu" "Items" "user/dashboard/home_lists" "Data" (dict "Context" ctx)}}</form>
{{- else}}{{ctx.Locale.Tr "home.my_repos"}}{{end -}}
</h2>
<button type="button" class="theme-icon-button" data-theme-repo-picker-toggle aria-controls="github-home-repositories" aria-label="{{ctx.Locale.Tr "search.repo_kind"}}" data-tooltip-content="{{ctx.Locale.Tr "search.repo_kind"}}">{{svg "octicon-search" 16}}</button>
</div>
{{$teamID := 0}}{{if .Team}}{{$teamID = .Team.ID}}{{end}}
{{template "components/repository/picker/picker" dict "ID" "github-home-repositories" "UID" $user.ID "Team" $teamID "FullName" true "Limit" 10 "More" true "Label" (ctx.Locale.Tr "home.my_repos")}}
{{if .Orgs}}
<ul class="theme-repo-picker-list github-home-organizations" aria-label="{{ctx.Locale.Tr "home.my_orgs"}}">
{{range .Orgs}}
<li><a class="theme-repo-picker-item" href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 16}}<span class="theme-repo-picker-name">{{.Name}}</span></a></li>
{{end}}
</ul>
{{end}}
</section>
{{if .Orgs}}
<script>
(() => {
const section = document.currentScript.previousElementSibling;
const key = "github-home-list";
const show = list => {
section.dataset.githubHomeList = list;
const input = section.querySelector(`input[name="${key}"][value="${list}"]`);
if (!input) return;
input.checked = true;
const label = section.querySelector("[data-theme-dropdown-label]");
const text = input.closest(".theme-dropdown-option")?.querySelector("span")?.textContent;
if (label && text) label.textContent = text;
};
try {
if (localStorage.getItem(key) === "organizations") show("organizations");
} catch {}
section.addEventListener("change", event => {
if (event.target.name !== key) return;
show(event.target.value);
try {
localStorage.setItem(key, event.target.value);
} catch {}
});
})();
</script>
{{end}}
</div>
{{template "components/common/sidebar/toggle" .}}
</aside>
Expand Down
2 changes: 2 additions & 0 deletions templates/user/dashboard/home_lists.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{template "components/common/dropdown/option" dict "Type" "radio" "Name" "github-home-list" "Value" "repositories" "Label" (ctx.Locale.Tr "home.my_repos") "Checked" true}}
{{template "components/common/dropdown/option" dict "Type" "radio" "Name" "github-home-list" "Value" "organizations" "Label" (ctx.Locale.Tr "home.my_orgs")}}
Loading