Skip to content

Commit 2c6c5d1

Browse files
committed
[dashboard] add org default image settings
1 parent 90a851e commit 2c6c5d1

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

components/dashboard/src/menu/OrganizationSelector.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ export default function OrganizationSelector() {
7070
separator: false,
7171
link: "/usage",
7272
});
73-
}
74-
75-
// Show billing & settings if user is an owner of current org
76-
if (currentOrg.data && currentOrg.data.isOwner) {
77-
if (billingMode?.mode === "usage-based") {
78-
linkEntries.push({
79-
title: "Billing",
80-
customContent: <LinkEntry>Billing</LinkEntry>,
81-
active: false,
82-
separator: false,
83-
link: "/billing",
84-
});
73+
// Show billing if user is an owner of current org
74+
if (currentOrg.data.isOwner) {
75+
if (billingMode?.mode === "usage-based") {
76+
linkEntries.push({
77+
title: "Billing",
78+
customContent: <LinkEntry>Billing</LinkEntry>,
79+
active: false,
80+
separator: false,
81+
link: "/billing",
82+
});
83+
}
8584
}
85+
// Org settings is available for all members, but only owner can change them
8686
linkEntries.push({
8787
title: "Settings",
8888
customContent: <LinkEntry>Settings</LinkEntry>,

components/dashboard/src/teams/TeamSettings.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ export default function TeamSettingsPage() {
3939
if (!org?.id) {
4040
throw new Error("no organization selected");
4141
}
42+
if (!org.isOwner) {
43+
throw new Error("no organization settings change permission");
44+
}
4245
updateTeamSettings.mutate({
4346
...settings,
4447
...newSettings,
4548
});
4649
},
47-
[updateTeamSettings, org?.id, settings],
50+
[updateTeamSettings, org?.id, org?.isOwner, settings],
4851
);
4952

5053
const close = () => setModal(false);
@@ -60,6 +63,9 @@ export default function TeamSettingsPage() {
6063

6164
const updateTeamInformation = useCallback(
6265
async (e: React.FormEvent) => {
66+
if (!org?.isOwner) {
67+
return;
68+
}
6369
e.preventDefault();
6470

6571
if (!orgFormIsValid) {
@@ -74,7 +80,7 @@ export default function TeamSettingsPage() {
7480
console.error(error);
7581
}
7682
},
77-
[orgFormIsValid, updateOrg, teamName],
83+
[orgFormIsValid, updateOrg, teamName, org],
7884
);
7985

8086
const deleteTeam = useCallback(async () => {
@@ -117,24 +123,36 @@ export default function TeamSettingsPage() {
117123
value={teamName}
118124
error={teamNameError.message}
119125
onChange={setTeamName}
126+
disabled={!org?.isOwner}
120127
onBlur={teamNameError.onBlur}
121128
/>
122129

123-
<Button className="mt-4" htmlType="submit" disabled={org?.name === teamName || !orgFormIsValid}>
124-
Update Organization
125-
</Button>
130+
{org?.isOwner && (
131+
<Button className="mt-4" htmlType="submit" disabled={org?.name === teamName || !orgFormIsValid}>
132+
Update Organization
133+
</Button>
134+
)}
126135

127136
<Heading2 className="pt-12">Collaboration & Sharing</Heading2>
128137
<CheckboxInputField
129138
label="Workspace Sharing"
130139
hint="Allow workspaces created within an Organization to share the workspace with any authenticated user."
131140
checked={!settings?.workspaceSharingDisabled}
132141
onChange={(checked) => handleUpdateTeamSettings({ workspaceSharingDisabled: !checked })}
133-
disabled={isLoading}
142+
disabled={isLoading || !org?.isOwner}
143+
/>
144+
145+
<Heading2 className="pt-12">Workspace Settings</Heading2>
146+
<TextInputField
147+
label="Default Image"
148+
hint="Default image of organization workspaces"
149+
value={settings?.defaultWorkspaceImage ?? ""}
150+
onChange={(value) => handleUpdateTeamSettings({ defaultWorkspaceImage: value })}
151+
disabled={isLoading || !org?.isOwner}
134152
/>
135153
</form>
136154

137-
{user?.organizationId !== org?.id && (
155+
{user?.organizationId !== org?.id && org?.isOwner && (
138156
<>
139157
<Heading2 className="pt-12">Delete Organization</Heading2>
140158
<Subheading className="pb-4 max-w-2xl">

0 commit comments

Comments
 (0)