Skip to content

Commit 7d126f4

Browse files
committed
Quickfix context menu options that shouldn't be available
1 parent dadb27d commit 7d126f4

File tree

2 files changed

+65
-52
lines changed

2 files changed

+65
-52
lines changed

packages/app/src/app/overmind/actions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const notificationRemoved: Action<{
6262
}> = ({ state }, { id }) => {
6363
const { notifications } = state;
6464
const notificationToRemoveIndex = notifications.findIndex(
65-
notification => notification.id === id
65+
(notification) => notification.id === id
6666
);
6767

6868
state.notifications.splice(notificationToRemoveIndex, 1);
@@ -151,7 +151,7 @@ export const addNotification: Action<{
151151

152152
export const removeNotification: Action<number> = ({ state }, id) => {
153153
const notificationToRemoveIndex = state.notifications.findIndex(
154-
notification => notification.id === id
154+
(notification) => notification.id === id
155155
);
156156

157157
state.notifications.splice(notificationToRemoveIndex, 1);

packages/app/src/app/pages/Dashboard/Components/Selection/ContextMenus/SandboxMenu.tsx

Lines changed: 63 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ export const SandboxMenu: React.FC<SandboxMenuProps> = ({
4141
const label = isTemplate ? 'Template' : 'Sandbox';
4242
const isPro = user && Boolean(user.subscription);
4343

44+
const hasAccess = React.useMemo(() => item.sandbox.teamId === activeTeam, [
45+
item,
46+
activeTeam,
47+
]);
48+
4449
const isOwner = React.useMemo(() => {
4550
if (item.type !== 'template') {
46-
return true;
51+
return item.sandbox.teamId === activeTeam;
4752
}
53+
4854
return (
4955
item.sandbox.author && item.sandbox.author.username === user.username
5056
);
@@ -78,6 +84,7 @@ export const SandboxMenu: React.FC<SandboxMenuProps> = ({
7884
</Menu.ContextMenu>
7985
);
8086
}
87+
// TODO(@CompuIves): refactor this to an array
8188

8289
return (
8390
<Menu.ContextMenu
@@ -158,7 +165,7 @@ export const SandboxMenu: React.FC<SandboxMenuProps> = ({
158165
</MenuItem>
159166
)}
160167

161-
{isPro ? (
168+
{hasAccess && activeWorkspaceAuthorization !== 'READ' && isPro ? (
162169
<>
163170
<Menu.Divider />
164171
{sandbox.privacy !== 0 && (
@@ -200,8 +207,11 @@ export const SandboxMenu: React.FC<SandboxMenuProps> = ({
200207
</>
201208
) : null}
202209
<Menu.Divider />
203-
<MenuItem onSelect={() => setRenaming(true)}>Rename {label}</MenuItem>
204-
{activeWorkspaceAuthorization !== 'READ' &&
210+
{hasAccess && activeWorkspaceAuthorization !== 'READ' && (
211+
<MenuItem onSelect={() => setRenaming(true)}>Rename {label}</MenuItem>
212+
)}
213+
{hasAccess &&
214+
activeWorkspaceAuthorization !== 'READ' &&
205215
!isTemplate &&
206216
(sandbox.isFrozen ? (
207217
<MenuItem
@@ -226,53 +236,56 @@ export const SandboxMenu: React.FC<SandboxMenuProps> = ({
226236
Freeze {label}
227237
</MenuItem>
228238
))}
229-
{isTemplate ? (
230-
<MenuItem
231-
onSelect={() => {
232-
actions.dashboard.unmakeTemplates({
233-
templateIds: [sandbox.id],
234-
});
235-
}}
236-
>
237-
Convert to Sandbox
238-
</MenuItem>
239-
) : (
240-
<MenuItem
241-
onSelect={() => {
242-
actions.dashboard.makeTemplates({
243-
sandboxIds: [sandbox.id],
244-
});
245-
}}
246-
>
247-
Make Sandbox a Template
248-
</MenuItem>
249-
)}
239+
{hasAccess &&
240+
(isTemplate ? (
241+
<MenuItem
242+
onSelect={() => {
243+
actions.dashboard.unmakeTemplates({
244+
templateIds: [sandbox.id],
245+
});
246+
}}
247+
>
248+
Convert to Sandbox
249+
</MenuItem>
250+
) : (
251+
<MenuItem
252+
onSelect={() => {
253+
actions.dashboard.makeTemplates({
254+
sandboxIds: [sandbox.id],
255+
});
256+
}}
257+
>
258+
Make Sandbox a Template
259+
</MenuItem>
260+
))}
250261
<Menu.Divider />
251-
{isTemplate ? (
252-
<MenuItem
253-
onSelect={() => {
254-
const template = item as DashboardTemplate;
255-
actions.dashboard.deleteTemplate({
256-
sandboxId: template.sandbox.id,
257-
templateId: template.template.id,
258-
});
259-
setVisibility(false);
260-
}}
261-
>
262-
Delete Template
263-
</MenuItem>
264-
) : (
265-
<MenuItem
266-
onSelect={() => {
267-
actions.dashboard.deleteSandbox({
268-
ids: [sandbox.id],
269-
});
270-
setVisibility(false);
271-
}}
272-
>
273-
Delete Sandbox
274-
</MenuItem>
275-
)}
262+
{hasAccess &&
263+
activeWorkspaceAuthorization !== 'READ' &&
264+
(isTemplate ? (
265+
<MenuItem
266+
onSelect={() => {
267+
const template = item as DashboardTemplate;
268+
actions.dashboard.deleteTemplate({
269+
sandboxId: template.sandbox.id,
270+
templateId: template.template.id,
271+
});
272+
setVisibility(false);
273+
}}
274+
>
275+
Delete Template
276+
</MenuItem>
277+
) : (
278+
<MenuItem
279+
onSelect={() => {
280+
actions.dashboard.deleteSandbox({
281+
ids: [sandbox.id],
282+
});
283+
setVisibility(false);
284+
}}
285+
>
286+
Delete Sandbox
287+
</MenuItem>
288+
))}
276289
</Menu.ContextMenu>
277290
);
278291
};

0 commit comments

Comments
 (0)