Skip to content

Commit 6b67dee

Browse files
fix permission and no module selected
1 parent 68bbaad commit 6b67dee

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/app/src/app/overmind/namespaces/editor/models/EditorSandbox.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
resolveModule,
77
resolveModuleWrapped,
88
} from '@codesandbox/common/lib/sandbox/modules';
9+
import { hasPermission } from '@codesandbox/common/lib/utils/permission';
910
import getTemplate, { TemplateType } from '@codesandbox/common/lib/templates';
1011
import { generateFileFromSandbox } from '@codesandbox/common/lib/templates/configuration/package-json';
1112
import {
@@ -69,8 +70,8 @@ export class EditorSandbox {
6970

7071
private currentModuleShortid: string | null = null;
7172
private changedModuleShortids: string[] = [];
72-
public errors: ModuleError[];
73-
public corrections: ModuleCorrection[];
73+
public errors: ModuleError[] = [];
74+
public corrections: ModuleCorrection[] = [];
7475
private getModuleParents(modules, directories, shortid): string[] {
7576
const module = modules.find(moduleEntry => moduleEntry.shortid === shortid);
7677

@@ -336,7 +337,7 @@ export class EditorSandbox {
336337
}
337338

338339
hasPermission(permission: PermissionType) {
339-
return this.currentSandbox.authorization === permission;
340+
return hasPermission(this.currentSandbox.authorization, permission);
340341
}
341342

342343
toggleLiked() {

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/DirectoryChildren/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const DirectoryChildren: React.FC<IDirectoryChildrenProps> = ({
7676
mainModuleId={mainModule.id}
7777
modules={modules}
7878
directories={directories}
79-
currentModuleShortid={currentModule.shortid}
79+
currentModuleShortid={currentModule?.shortid}
8080
isInProjectView={isInProjectView}
8181
markTabsNotDirty={markTabsNotDirty}
8282
getModulePath={getModulePath}

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/DirectoryChildren/ModuleEntry.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const ModuleEntry: React.FC<IModuleEntryProps> = ({
4343
live,
4444
},
4545
} = useOvermind();
46-
const isActive = module.shortid === currentModule.shortid;
46+
const isActive = module.shortid === currentModule?.shortid;
4747
const isMainModule = module.id === mainModule.id;
4848
const type = getType(module.title);
4949
const hasError = module.errors.length > 0;

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/DirectoryChildren/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const DirectoryChildren: React.FC<IDirectoryChildrenProps> = ({
7676
mainModuleId={mainModule.id}
7777
modules={modules}
7878
directories={directories}
79-
currentModuleShortid={currentModule.shortid}
79+
currentModuleShortid={currentModule?.shortid}
8080
isInProjectView={isInProjectView}
8181
markTabsNotDirty={markTabsNotDirty}
8282
getModulePath={getModulePath}

0 commit comments

Comments
 (0)