Skip to content

Commit

Permalink
Removed check for permission in the project selection dialog as we mu…
Browse files Browse the repository at this point in the history
…st read all projects to check the permissions
  • Loading branch information
GermanBluefox committed Apr 9, 2024
1 parent ef8cb1c commit eed2688
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/vis-2/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ function copyFolder(source, target, ignore) {

gulp.task('7-patch', done => {
patchFile(`${__dirname}/www/edit.html`);
patchFile(`${__dirname}/www/index.html`);
patchFile(`${__dirname}/src/build/index.html`);
patchFile(`${__dirname}/src/build/edit.html`);
fs.existsSync(`${__dirname}/www/marketplaceConfig.sample.js`) && fs.unlinkSync(`${__dirname}/www/marketplaceConfig.sample.js`);
Expand All @@ -487,6 +488,6 @@ gulp.task('7-patch', done => {

gulp.task('7-patch-dep', gulp.series('6-copy-dep', '7-patch'));

gulp.task('buildReact', gulp.series('7-patch-dep', 'runtime-7-patch-dep'));
gulp.task('buildReact', gulp.series('runtime-7-patch-dep', '7-patch-dep'));

gulp.task('default', gulp.series('buildReact'));
25 changes: 20 additions & 5 deletions packages/vis-2/src/src/Runtime.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,9 @@ class Runtime extends GenericApp {
return <Dialog
open={!0}
maxWidth="sm"
onClose={() => {}} // do nothing
onClose={() => {
/* do nothing */
}}
>
<DialogTitle>
<img
Expand All @@ -924,7 +926,10 @@ class Runtime extends GenericApp {
</div> : null}
<MenuList>
{this.state.projects.map(project =>
<ListItemButton key={project} onClick={() => window.location.href = `?${project}`} disabled={!hasProjectAccess({ editMode: this.state.editMode, project: visProject, user: activeUser })}>
<ListItemButton
key={project}
onClick={() => window.location.href = `?${project}`}
>
<ListItemIcon>
<IconDocument />
</ListItemIcon>
Expand Down Expand Up @@ -986,9 +991,19 @@ class Runtime extends GenericApp {

const { visProject, activeUser } = store.getState();

if (!hasProjectAccess({ editMode: this.state.editMode, project: visProject, user: activeUser }) || !hasViewAccess({
editMode: this.state.editMode, project: visProject, user: activeUser, view: this.state.selectedView,
})) {
if (
!hasProjectAccess({
editMode: this.state.editMode,
project: visProject,
user: activeUser,
}) ||
!hasViewAccess({
editMode: this.state.editMode,
project: visProject,
user: activeUser,
view: this.state.selectedView,
})
) {
console.warn(`User "${activeUser}" has no permissions for ${this.state.editMode ? 'edit mode' : 'runtime'} of project "${this.state.projectName}" with view "${this.state.selectedView}"`);
if (this.state.projects) {
return this.showSmallProjectsDialog();
Expand Down
4 changes: 2 additions & 2 deletions packages/vis-2/src/src/Utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ export const DEFAULT_PERMISSIONS: Permissions = { read: true, write: true };
export function hasProjectAccess(options: CheckAccessOptions): boolean {
const { project, user, editMode } = options;

const permissions = project.___settings.permissions?.[user] ?? DEFAULT_PERMISSIONS;
const permissions = project?.___settings?.permissions?.[user] ?? DEFAULT_PERMISSIONS;

if (editMode && permissions.write) {
if (editMode && permissions?.write) {
return true;
}

Expand Down

0 comments on commit eed2688

Please sign in to comment.