Skip to content

Commit b2c5b9b

Browse files
authored
Hide breadcrumbs for private orgs (#2477)
Hides "Back to [org name]" breadcrumb when viewing a public/unlisted collection when the public gallery isn't enabled for the org (except when logged into that org).
1 parent ac1236f commit b2c5b9b

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

backend/btrixcloud/colls.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,11 @@ async def get_collection_out(
342342
result = await self.get_collection_raw(coll_id, public_or_unlisted_only)
343343

344344
if resources:
345-
result["resources"], crawl_ids, pages_optimized = (
346-
await self.get_collection_crawl_resources(coll_id)
347-
)
345+
(
346+
result["resources"],
347+
crawl_ids,
348+
pages_optimized,
349+
) = await self.get_collection_crawl_resources(coll_id)
348350

349351
initial_pages, _ = await self.page_ops.list_pages(
350352
crawl_ids=crawl_ids,
@@ -389,6 +391,7 @@ async def get_public_collection_out(
389391
result = await self.get_collection_raw(coll_id)
390392

391393
result["orgName"] = org.name
394+
result["orgPublicProfile"] = org.enablePublicProfile
392395

393396
allowed_access = [CollAccessType.PUBLIC]
394397
if allow_unlisted:
@@ -542,6 +545,7 @@ async def list_collections(
542545
)
543546

544547
res["orgName"] = org.name
548+
res["orgPublicProfile"] = org.enablePublicProfile
545549

546550
if public_colls_out:
547551
collections.append(PublicCollOut.from_dict(res))
@@ -1009,9 +1013,11 @@ async def get_collection_all(org: Organization = Depends(org_viewer_dep)):
10091013
try:
10101014
all_collections, _ = await colls.list_collections(org, page_size=10_000)
10111015
for collection in all_collections:
1012-
results[collection.name], _, _ = (
1013-
await colls.get_collection_crawl_resources(collection.id)
1014-
)
1016+
(
1017+
results[collection.name],
1018+
_,
1019+
_,
1020+
) = await colls.get_collection_crawl_resources(collection.id)
10151021
except Exception as exc:
10161022
# pylint: disable=raise-missing-from
10171023
raise HTTPException(

backend/btrixcloud/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,7 @@ class PublicCollOut(BaseMongoModel):
15311531
slug: str
15321532
oid: UUID
15331533
orgName: str
1534+
orgPublicProfile: bool
15341535
description: Optional[str] = None
15351536
caption: Optional[str] = None
15361537
created: Optional[datetime] = None

frontend/src/pages/collections/collection.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@ export class Collection extends BtrixElement {
8080

8181
private readonly renderComplete = (collection: PublicCollection) => {
8282
const header: Parameters<typeof page>[0] = {
83-
breadcrumbs: [
84-
{
85-
href: `/${RouteNamespace.PublicOrgs}/${this.orgSlug}`,
86-
content: collection.orgName,
87-
},
88-
],
83+
breadcrumbs:
84+
collection.orgPublicProfile || collection.oid === this.orgId
85+
? [
86+
{
87+
href: `/${RouteNamespace.PublicOrgs}/${this.orgSlug}`,
88+
content: collection.orgName,
89+
},
90+
]
91+
: undefined,
8992
title: collection.name || "",
9093
actions: html`
9194
<btrix-share-collection

frontend/src/types/collection.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const publicCollectionSchema = z.object({
2121
slug: z.string(),
2222
oid: z.string(),
2323
orgName: z.string(),
24+
orgPublicProfile: z.boolean(),
2425
name: z.string(),
2526
created: z.string().datetime(),
2627
modified: z.string().datetime(),

0 commit comments

Comments
 (0)