Skip to content

Commit

Permalink
fix: personal spaces can be made private without a pro plan
Browse files Browse the repository at this point in the history
  • Loading branch information
BlankParticle committed Sep 11, 2024
1 parent 420e7a9 commit 6da7062
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const spaceSettingsRouter = router({
console.error(error);
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: 'Error while updating Space description'
message: 'Error while updating Space type'
});
}

Expand Down
25 changes: 17 additions & 8 deletions apps/web/src/app/[orgShortcode]/[spaceShortcode]/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,20 @@ export default function SettingsPage() {
</div>
</div>
<ColorField
initialValue={spaceSettings?.settings?.color}
showSaved={setShowSaved}
isSpaceAdmin={isSpaceAdmin}
/>
<VisibilityField
initialValue={spaceSettings?.settings?.type}
initialValue={spaceSettings.settings.color}
showSaved={setShowSaved}
isSpaceAdmin={isSpaceAdmin}
/>
{/* Show visibility field only if the space is not a personal space or if it is a personal space and it is open so that users can change the visibility */}
{!spaceSettings.settings.personalSpace ||
spaceSettings.settings.type === 'open' ? (
<VisibilityField
initialValue={spaceSettings.settings.type}
showSaved={setShowSaved}
isSpaceAdmin={isSpaceAdmin}
personalSpace={spaceSettings.settings.personalSpace}
/>
) : null}
<Workflows
showSaved={setShowSaved}
isSpaceAdmin={isSpaceAdmin}
Expand Down Expand Up @@ -433,10 +438,12 @@ function ColorField({
function VisibilityField({
initialValue,
showSaved,
personalSpace,
isSpaceAdmin
}: {
initialValue: string;
isSpaceAdmin: boolean;
personalSpace: boolean;
showSaved: (value: boolean) => void;
}) {
const orgShortcode = useOrgShortcode();
Expand Down Expand Up @@ -483,7 +490,9 @@ function VisibilityField({
<SelectContent>
<SelectItem
value="open"
className="hover:bg-base-3 w-full rounded-sm">
className="hover:bg-base-3 w-full rounded-sm"
// Don't allow changing the visibility of a personal space to open
disabled={personalSpace === true}>
<div className="flex flex-row items-center justify-start gap-4 rounded-md p-1">
<Globe className="h-6 w-6" />
<div className="flex grow flex-col justify-start gap-2 text-left">
Expand All @@ -494,7 +503,7 @@ function VisibilityField({
</div>
</div>
</SelectItem>
{canAddSpace?.private ? (
{personalSpace === true || canAddSpace?.private ? (
<SelectItem
value="private"
className="hover:bg-base-3 w-full rounded-sm">
Expand Down

0 comments on commit 6da7062

Please sign in to comment.