diff --git a/src/lib/components/documents/DocumentListItem.svelte b/src/lib/components/documents/DocumentListItem.svelte index 350be3f9b..4623a7583 100644 --- a/src/lib/components/documents/DocumentListItem.svelte +++ b/src/lib/components/documents/DocumentListItem.svelte @@ -236,6 +236,7 @@ If we're in an embed, we want to open links to documents in new tabs and hide th text-overflow: ellipsis; /* white-space: nowrap; */ max-width: 100%; + margin: 0; } .meta { diff --git a/src/lib/components/layouts/AddOnBrowser.svelte b/src/lib/components/layouts/AddOnBrowser.svelte index 98f2873da..fb1488f89 100644 --- a/src/lib/components/layouts/AddOnBrowser.svelte +++ b/src/lib/components/layouts/AddOnBrowser.svelte @@ -13,7 +13,6 @@ import { _ } from "svelte-i18n"; import { Hourglass24, Plug24 } from "svelte-octicons"; - import AddOnsNavigation from "$lib/components/addons/AddOnsNavigation.svelte"; import Scheduled from "$lib/components/addons/Scheduled.svelte"; import Empty from "$lib/components/common/Empty.svelte"; import Error from "$lib/components/common/Error.svelte"; @@ -27,6 +26,10 @@ import Premium from "$lib/components/icons/Premium.svelte"; import Star from "$lib/components/icons/Star.svelte"; import ContentLayout from "$lib/components/layouts/ContentLayout.svelte"; + import Documents from "../sidebar/Documents.svelte"; + import Projects from "../sidebar/Projects.svelte"; + import AddOns from "$lib/components/sidebar/AddOns.svelte"; + import SidebarLayout from "./SidebarLayout.svelte"; export let addons: Promise>>; export let events: Promise>>; @@ -50,107 +53,119 @@ $: showTip = ["active", "featured", "premium"].includes(active); -
- -
- - - - - {#if showTip} -
- {#if active === "active"} - - - {$_("addonBrowserDialog.pinnedTip")} - - {:else if active === "featured"} - - - {$_("addonBrowserDialog.featuredTip")} - - {:else if active === "premium"} - - - {$_("addonBrowserDialog.premiumTip")} - - {/if} -
- {/if} - {#await addons} + + + + + + +
+
+ + + + + {#if showTip} +
+ {#if active === "active"} + + + {$_("addonBrowserDialog.pinnedTip")} + + {:else if active === "featured"} + + + {$_("addonBrowserDialog.featuredTip")} + + {:else if active === "premium"} + + + {$_("addonBrowserDialog.premiumTip")} + + {/if} +
+ {/if} + {#await addons} + {$_("common.loading")} + {:then { data: page }} + {#each page?.results ?? [] as addon} + + {:else} + {$_("addonBrowserDialog.empty")} + {/each} + {:catch error} + {String(error)} + {/await} + + + + {#await addons} + + {:then { data: page }} + { + if (page?.next) paginate(page.next); + }} + on:previous={() => { + if (page?.previous) paginate(page.previous); + }} + /> + {/await} + + +
+
+
- -
+ {#await runs} + {$_("common.loading")} + {:then { data: runs }} + + {/await} + + + diff --git a/src/lib/components/layouts/AddOnLayout.svelte b/src/lib/components/layouts/AddOnLayout.svelte index 541bbafca..bb82772f3 100644 --- a/src/lib/components/layouts/AddOnLayout.svelte +++ b/src/lib/components/layouts/AddOnLayout.svelte @@ -12,7 +12,13 @@ import { _ } from "svelte-i18n"; import { setContext } from "svelte"; - import { Clock16, History16, Hourglass24, Play16 } from "svelte-octicons"; + import { + Clock16, + History16, + Hourglass24, + Play16, + SidebarExpand16, + } from "svelte-octicons"; import AddOnDispatch, { values } from "../forms/AddOnDispatch.svelte"; import AddOnMeta from "../addons/AddOnMeta.svelte"; @@ -33,6 +39,13 @@ import { schedules } from "../addons/ScheduledEvent.svelte"; import { getProcessLoader } from "../processing/ProcessContext.svelte"; + import SidebarLayout from "./SidebarLayout.svelte"; + import Documents from "../sidebar/Documents.svelte"; + import Projects from "../sidebar/Projects.svelte"; + import AddOns from "../sidebar/AddOns.svelte"; + import Flex from "../common/Flex.svelte"; + import { sidebars } from "./Sidebar.svelte"; + import Button from "../common/Button.svelte"; export let addon: AddOnListItem; export let event: Event | null = null; @@ -87,141 +100,179 @@ } -
-
-
-
- (currentTab = "dispatch")} - > - - {$_("addonDispatchDialog.dispatch")} - - - (currentTab = "history")} - > - - {$_("addonDispatchDialog.history")} - + + + + + + +
+
+
+ {#if !addon.parameters.documents && $sidebars["navigation"] === false} +
+ +
+ {/if} + +
+
+ (currentTab = "dispatch")} + > + + {$_("addonDispatchDialog.dispatch")} + - {#if canSchedule} (currentTab = "scheduled")} + active={currentTab === "history"} + on:click={() => (currentTab = "history")} > - - {$_("addonDispatchDialog.scheduled")} + + {$_("addonDispatchDialog.history")} - {/if} -
-
- {#if currentTab === "scheduled"} - {#await scheduled} - {$_("common.loading")} - {:then scheduled} - {#if scheduled} - - {/if} - {/await} - {:else if currentTab === "history"} -
- {#await history} + + {#if canSchedule} + (currentTab = "scheduled")} + > + + {$_("addonDispatchDialog.scheduled")} + + {/if} +
+
+ {#if currentTab === "scheduled"} + {#await scheduled} {$_("common.loading")} - {:then history} - {#if history} - - {:else} - {$_("addonDispatchDialog.noHistory")} {/if} {/await} -
- {:else} - - - {#await search then results} - + {#await history} + {$_("common.loading")} + {:then history} + {#if history} + + {:else} + {$_("addonDispatchDialog.noHistory")} + {/if} + {/await} +
+ {:else} + + + {#await search then results} + + {/await} + + + {/if} + +
+ {#if addon.parameters.documents} +
+ + + {#if $sidebars["navigation"] === false} +
+ +
+ {/if} + + + +
+ + {#await search} + {$_("common.loading")} + {:then search} + {/await} - - {/if} - - - {#if addon.parameters.documents} -
- - - - - - {#await search} - {$_("common.loading")} - {:then search} - - {/await} - - - + + - - {#if $visible && $total} - {$_("inputs.resultsCount", { - values: { n: $visible.size, total: $total }, - })} - {/if} - - - -
- {/if} -
+ + {#if $visible && $total} + {$_("inputs.resultsCount", { + values: { n: $visible.size, total: $total }, + })} + {/if} + + + +
+ {/if} + + diff --git a/src/lib/components/layouts/DocumentLayout.svelte b/src/lib/components/layouts/DocumentLayout.svelte index 7388c8e22..e2a26123f 100644 --- a/src/lib/components/layouts/DocumentLayout.svelte +++ b/src/lib/components/layouts/DocumentLayout.svelte @@ -3,12 +3,7 @@ Assumes it's a child of a ViewerContext --> @@ -33,7 +29,7 @@ - +
diff --git a/src/lib/components/layouts/Sidebar.svelte b/src/lib/components/layouts/Sidebar.svelte index 2d9a3b5fa..ccdd40718 100644 --- a/src/lib/components/layouts/Sidebar.svelte +++ b/src/lib/components/layouts/Sidebar.svelte @@ -130,7 +130,7 @@ display: flex; flex-direction: column; position: relative; - gap: 1rem; + gap: 0.5rem; height: 100%; z-index: 0; } diff --git a/src/lib/components/layouts/stories/AppLayout.stories.svelte b/src/lib/components/layouts/stories/AppLayout.stories.svelte index 5fa0b5e3b..a60b768df 100644 --- a/src/lib/components/layouts/stories/AppLayout.stories.svelte +++ b/src/lib/components/layouts/stories/AppLayout.stories.svelte @@ -30,6 +30,9 @@ stores: { page: { url: "/", + data: { + pinnedAddons: Promise.resolve({ data: activeAddons }), + }, }, }, }, @@ -47,7 +50,7 @@ - + diff --git a/src/lib/components/layouts/stories/SidebarLayout.stories.svelte b/src/lib/components/layouts/stories/SidebarLayout.stories.svelte index 1a25ce266..6eb1b5282 100644 --- a/src/lib/components/layouts/stories/SidebarLayout.stories.svelte +++ b/src/lib/components/layouts/stories/SidebarLayout.stories.svelte @@ -27,6 +27,9 @@ stores: { page: { url: "/", + data: { + pinnedAddons: Promise.resolve({ data: activeAddons }), + }, }, }, }, @@ -44,9 +47,7 @@ - + diff --git a/src/lib/components/projects/Collaborators.svelte b/src/lib/components/projects/Collaborators.svelte index 408b5ee84..71e5ab38d 100644 --- a/src/lib/components/projects/Collaborators.svelte +++ b/src/lib/components/projects/Collaborators.svelte @@ -109,9 +109,11 @@ {#each Object.entries(group(sort(users))) as [key, members]} -
-

{$_(accessLabels[key])}

-
+ {#if members.length} +
+

{$_(accessLabels[key])}

+
+ {/if} {#each members as user} {#if isProjectUser || project.edit_access} diff --git a/src/lib/components/sidebar/AddOns.svelte b/src/lib/components/sidebar/AddOns.svelte index 9fc6c97aa..0c488292c 100644 --- a/src/lib/components/sidebar/AddOns.svelte +++ b/src/lib/components/sidebar/AddOns.svelte @@ -1,17 +1,15 @@ - - {#each Object.entries(actions) as [action, [label, icon]]} - + {#each Object.entries(actions) as [action, [label, icon, mode]]} + {/each} diff --git a/src/lib/components/sidebar/Documents.svelte b/src/lib/components/sidebar/Documents.svelte index 427c7d981..b68be76b8 100644 --- a/src/lib/components/sidebar/Documents.svelte +++ b/src/lib/components/sidebar/Documents.svelte @@ -8,13 +8,11 @@ Search16, File16, Globe16, - Person16, - ShieldLock16, + Lock16, Organization16, } from "svelte-octicons"; import { page } from "$app/stores"; - import Flex from "$lib/components/common/Flex.svelte"; import SidebarItem from "$lib/components/sidebar/SidebarItem.svelte"; import SignedIn from "$lib/components/common/SignedIn.svelte"; @@ -23,7 +21,6 @@ import { userDocs } from "$lib/utils/search"; import { getCurrentUser } from "@/lib/utils/permissions"; import SidebarGroup from "@/lib/components/sidebar/SidebarGroup.svelte"; - import { size } from "lodash-es"; import Button from "@/lib/components/common/Button.svelte"; const me = getCurrentUser(); @@ -31,7 +28,6 @@ $: query = $page.url.searchParams?.get("q") || ""; - $: mine = $me ? userDocs($me) : ""; $: minePublic = $me ? userDocs($me, "public") : ""; $: minePrivate = $me ? userDocs($me, "private") : ""; @@ -70,11 +66,22 @@ href={searchUrl(minePrivate)} active={query === minePrivate} > - + {$_("documents.accessDocuments", { values: { access: "Private " }, })} + + + {$_("documents.accessDocuments", { + values: { access: "Public " }, + })} + {#if $org && !$org.individual} {/if} - - - {$_("documents.accessDocuments", { - values: { access: "Public " }, - })} - diff --git a/src/lib/components/sidebar/Projects.svelte b/src/lib/components/sidebar/Projects.svelte index 021c05e81..b71ab68a9 100644 --- a/src/lib/components/sidebar/Projects.svelte +++ b/src/lib/components/sidebar/Projects.svelte @@ -5,12 +5,10 @@ import { FileDirectory16, - FileDirectory24, Hourglass24, People16, Person16, Pin16, - Pin24, Search16, } from "svelte-octicons"; import { _ } from "svelte-i18n"; @@ -21,10 +19,9 @@ import SidebarItem from "$lib/components/sidebar/SidebarItem.svelte"; import { canonicalUrl } from "$lib/api/projects"; - import { getCurrentUser } from "$lib/utils/permissions"; import Button from "../common/Button.svelte"; + import SignedIn from "../common/SignedIn.svelte"; - const me = getCurrentUser(); let pinned: Project[] | Promise = []; $: pinned = $page.data.pinnedProjects || []; @@ -34,22 +31,22 @@ } - - - {$_("sidebar.projects.title")} - - - {#if $me} + + + + {$_("sidebar.projects.title")} + + {$_("projects.shared")} - {/if} - {#await pinned} - {$_("common.loading")} - {:then projects} - {#each sort(projects) as project} - - - {project.title} - - {:else} - - - {$_("sidebar.projects.pinned")} - - {/each} - {/await} - + {#await pinned} + {$_("common.loading")} + {:then projects} + {#each sort(projects) as project} + + + {project.title} + + {:else} + + + {$_("sidebar.projects.pinned")} + + {/each} + {/await} + + diff --git a/src/routes/(app)/+layout.ts b/src/routes/(app)/+layout.ts index 3198050a7..a0cb1d757 100644 --- a/src/routes/(app)/+layout.ts +++ b/src/routes/(app)/+layout.ts @@ -1,6 +1,16 @@ -import type { Org, User } from "$lib/api/types"; +import type { + AddOnListItem, + APIResponse, + Nullable, + Org, + Page, + Project, + User, +} from "$lib/api/types"; import { getMe, orgUsers, userOrgs } from "$lib/api/accounts"; import { getTipOfDay } from "$lib/api/flatpages"; +import { getPinnedAddons } from "$lib/api/addons"; +import { list as listProjects } from "$lib/api/projects"; export const trailingSlash = "always"; @@ -11,6 +21,9 @@ export async function load({ fetch }) { let user_orgs: Promise = Promise.resolve([]); let org_users: Promise = Promise.resolve([]); + let pinnedAddons: Promise>>> = + Promise.resolve(null); + let pinnedProjects: Promise = Promise.resolve([]); if (me && org) { user_orgs = userOrgs(me, fetch).catch((e) => { console.error(e); @@ -21,6 +34,18 @@ export async function load({ fetch }) { return []; }); } + if (me) { + pinnedAddons = getPinnedAddons(fetch).catch((e) => { + console.error(e); + return null; + }); + pinnedProjects = listProjects({ pinned: true }, fetch) + .then((r) => r.data?.results ?? []) + .catch((e) => { + console.error(e); + return []; + }); + } return { me, @@ -29,5 +54,7 @@ export async function load({ fetch }) { breadcrumbs: [], user_orgs, org_users, + pinnedAddons, + pinnedProjects, }; } diff --git a/src/routes/(app)/documents/+layout.ts b/src/routes/(app)/documents/+layout.ts index e96b615cf..a169797e3 100644 --- a/src/routes/(app)/documents/+layout.ts +++ b/src/routes/(app)/documents/+layout.ts @@ -1,20 +1,11 @@ -import * as projects from "$lib/api/projects"; -import { getPinnedAddons } from "$lib/api/addons"; import { breadcrumbTrail } from "$lib/utils/navigation"; -export async function load({ fetch, parent }) { - const pinnedAddons = getPinnedAddons(fetch).catch(console.error); - const pinnedProjects = projects - .list({ pinned: true }, fetch) - .then((r) => r.data?.results); - +export async function load({ parent }) { const breadcrumbs = await breadcrumbTrail(parent, [ { href: "/documents/", title: "Documents" }, ]); return { - pinnedAddons, - pinnedProjects, breadcrumbs, }; } diff --git a/src/routes/(app)/documents/+page.svelte b/src/routes/(app)/documents/+page.svelte index 457f70da8..007955039 100644 --- a/src/routes/(app)/documents/+page.svelte +++ b/src/routes/(app)/documents/+page.svelte @@ -1,36 +1,25 @@ @@ -41,19 +30,15 @@ - - - - + + - {#if isSignedIn($me)} - - - {/if} + + diff --git a/src/routes/(app)/documents/+page.ts b/src/routes/(app)/documents/+page.ts index 6e14acba5..f1ea847b5 100644 --- a/src/routes/(app)/documents/+page.ts +++ b/src/routes/(app)/documents/+page.ts @@ -1,8 +1,7 @@ -import type { DocumentResults, SearchOptions } from "$lib/api/types"; +import type { SearchOptions } from "$lib/api/types"; import { DEFAULT_PER_PAGE } from "@/config/config.js"; import { search } from "$lib/api/documents"; -import { getPinnedAddons } from "$lib/api/addons.js"; export async function load({ url, fetch, data }) { const query = url.searchParams.get("q") || ""; @@ -24,14 +23,11 @@ export async function load({ url, fetch, data }) { const searchResults = search(query, options, fetch); - const pinnedAddons = getPinnedAddons(fetch); - return { ...data, query, per_page, cursor, searchResults, - pinnedAddons, }; } diff --git a/src/routes/(app)/documents/[id]-[slug]/+page.svelte b/src/routes/(app)/documents/[id]-[slug]/+page.svelte index 60a4d8d5b..3cd09c3da 100644 --- a/src/routes/(app)/documents/[id]-[slug]/+page.svelte +++ b/src/routes/(app)/documents/[id]-[slug]/+page.svelte @@ -25,7 +25,6 @@ $: canonical_url = documents.canonicalUrl(document).href; $: action = data.action; - $: addons = data.pinnedAddons; $: hasDescription = Boolean(document.description?.trim().length); $: query = data.query || ""; @@ -67,6 +66,6 @@ - + diff --git a/src/routes/(app)/documents/[id]-[slug]/+page.ts b/src/routes/(app)/documents/[id]-[slug]/+page.ts index 3f86b3942..f652c087b 100644 --- a/src/routes/(app)/documents/[id]-[slug]/+page.ts +++ b/src/routes/(app)/documents/[id]-[slug]/+page.ts @@ -8,7 +8,6 @@ import type { ReadMode } from "@/lib/api/types"; import { redirect } from "@sveltejs/kit"; import * as documents from "$lib/api/documents"; -import { getPinnedAddons } from "$lib/api/addons"; import { breadcrumbTrail } from "$lib/utils/index"; import loadDocument from "$lib/load/document"; @@ -39,9 +38,6 @@ export async function load({ fetch, params, parent, depends, url }) { { href: canonical.pathname, title: document.title }, ]); - // stream this - const pinnedAddons = getPinnedAddons(fetch); - const query = getQuery(url); return { @@ -49,7 +45,6 @@ export async function load({ fetch, params, parent, depends, url }) { mode, asset_url, action, - pinnedAddons, breadcrumbs, query, }; diff --git a/src/routes/(app)/projects/+page.svelte b/src/routes/(app)/projects/+page.svelte index 12ba9c2d9..4c3648e29 100644 --- a/src/routes/(app)/projects/+page.svelte +++ b/src/routes/(app)/projects/+page.svelte @@ -15,12 +15,10 @@ import Button from "$lib/components/common/Button.svelte"; import ContentLayout from "$lib/components/layouts/ContentLayout.svelte"; import Empty from "$lib/components/common/Empty.svelte"; - import Flex from "$lib/components/common/Flex.svelte"; import PageToolbar from "$lib/components/common/PageToolbar.svelte"; import Paginator from "$lib/components/common/Paginator.svelte"; import ProjectListItem from "$lib/components/projects/ProjectListItem.svelte"; import Search from "$lib/components/forms/Search.svelte"; - import SidebarItem from "$lib/components/sidebar/SidebarItem.svelte"; import SidebarLayout from "@/lib/components/layouts/SidebarLayout.svelte"; import EditProject from "@/lib/components/forms/EditProject.svelte"; @@ -28,6 +26,9 @@ import Portal from "$lib/components/layouts/Portal.svelte"; import { getCurrentUser } from "$lib/utils/permissions"; + import Documents from "@/lib/components/sidebar/Documents.svelte"; + import Projects from "@/lib/components/sidebar/Projects.svelte"; + import AddOns from "@/lib/components/sidebar/AddOns.svelte"; const me = getCurrentUser(); @@ -57,22 +58,9 @@ - - {#if $me} - - - {$_("projects.yours")} - - - - {$_("projects.shared")} - - {/if} - - - {$_("projects.public")} - - + + + diff --git a/src/routes/(app)/projects/[id]-[slug]/+page.svelte b/src/routes/(app)/projects/[id]-[slug]/+page.svelte index c33e1ef9f..608f7df07 100644 --- a/src/routes/(app)/projects/[id]-[slug]/+page.svelte +++ b/src/routes/(app)/projects/[id]-[slug]/+page.svelte @@ -1,6 +1,8 @@ @@ -36,4 +39,4 @@ {/if} - + diff --git a/src/routes/(app)/projects/[id]-[slug]/+page.ts b/src/routes/(app)/projects/[id]-[slug]/+page.ts index 84d8a1381..d94c03a4c 100644 --- a/src/routes/(app)/projects/[id]-[slug]/+page.ts +++ b/src/routes/(app)/projects/[id]-[slug]/+page.ts @@ -52,9 +52,6 @@ export async function load({ params, url, parent, data, fetch }) { fetch, ); - // stream this - const pinnedAddons = getPinnedAddons(fetch); - return { ...(data ?? {}), // include csrf_token breadcrumbs, @@ -62,6 +59,5 @@ export async function load({ params, url, parent, data, fetch }) { query, project: project.data, users, - pinnedAddons, }; } diff --git a/src/routes/(app)/upload/+page.svelte b/src/routes/(app)/upload/+page.svelte index f699eece1..91795dde0 100644 --- a/src/routes/(app)/upload/+page.svelte +++ b/src/routes/(app)/upload/+page.svelte @@ -1,11 +1,11 @@