Skip to content

Commit 23680e4

Browse files
authored
temperory allow org managers to handle pkgs meta client side (#2059)
1 parent 980109b commit 23680e4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/components/ViewPackagePage/components/important-files-view.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,10 @@ export default function ImportantFilesView({
8484
const canManagePackage = useMemo(() => {
8585
if (isOwner) return isOwner
8686
if (organization) {
87-
return organization.user_permissions?.can_manage_package
87+
return organization.user_permissions?.can_manage_org
8888
}
8989
return false
9090
}, [isOwner, organization])
91-
9291
// File type utilities
9392
const isLicenseFile = useCallback((filePath: string) => {
9493
const lowerPath = filePath.toLowerCase()

src/components/ViewPackagePage/components/sidebar-about-section.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { useState, useEffect, useMemo } from "react"
1010
import { usePackageFileById, usePackageFiles } from "@/hooks/use-package-files"
1111
import { getLicenseFromLicenseContent } from "@/lib/getLicenseFromLicenseContent"
1212
import { PackageInfo } from "@/lib/types"
13+
import { useOrganization } from "@/hooks/use-organization"
1314

1415
interface SidebarAboutSectionProps {
1516
packageInfo?: PackageInfo
@@ -25,6 +26,14 @@ export default function SidebarAboutSection({
2526
include_ai_review: true,
2627
})
2728

29+
const { organization } = useOrganization(
30+
packageInfo?.owner_org_id
31+
? { orgId: String(packageInfo.owner_org_id) }
32+
: packageInfo?.owner_github_username
33+
? { github_handle: packageInfo.owner_github_username }
34+
: {},
35+
)
36+
2837
const { data: releaseFiles } = usePackageFiles(
2938
packageInfo?.latest_package_release_id,
3039
)
@@ -52,6 +61,14 @@ export default function SidebarAboutSection({
5261
packageInfo?.owner_github_username ===
5362
useGlobalStore((s) => s.session?.github_username)
5463

64+
const canManageOrg = useMemo(() => {
65+
if (isOwner) return isOwner
66+
if (organization) {
67+
return organization.user_permissions?.can_manage_org
68+
}
69+
return false
70+
}, [isOwner, organization])
71+
5572
// Local state to store updated values before the query refetches
5673
const [localDescription, setLocalDescription] = useState<string>("")
5774
const [localWebsite, setLocalWebsite] = useState<string>("")
@@ -106,7 +123,7 @@ export default function SidebarAboutSection({
106123
<div className="mb-6">
107124
<div className="flex justify-between items-center mb-2">
108125
<h2 className="text-lg font-semibold">About</h2>
109-
{isOwner && (
126+
{canManageOrg && (
110127
<Button
111128
variant="ghost"
112129
size="sm"

0 commit comments

Comments
 (0)