Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added datadoc and list access permissions for user groups #1533

Merged
merged 24 commits into from
Feb 6, 2025

Conversation

jczhong84
Copy link
Collaborator

This is the same PR of #1297 (author: @jij1949), with rebasing and adding some demo users.

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "querybook",
"version": "3.38.0",
"version": "3.38.1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump minor?

from enum import Enum


class Permission(Enum):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is a bit too general

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EntityPermission? probably more clear with a comment on where this is used



@with_session
def assert_is_not_group(id, session=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is a bit generic, can we rename id to board_editor_id

Comment on lines 95 to 96
if user is None:
api_assert(False, "USER_DNE", RESOURCE_NOT_FOUND_STATUS_CODE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uid = sql.Column(sql.Integer, sql.ForeignKey("user.id", ondelete="CASCADE"))

this check is not needed? since sql constraints to prevent it


return [
BoardEditor(
# [0] is id, [1] is uid, [2] is read, [3] is write
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment is not needed?
seems to be more ideal to write like this

for id, uid, read, write in editors

querybook/server/logic/generic_permission.py Show resolved Hide resolved
if (uid in editorsByUid || uid === board.owner_uid) {
if (
uid === board.owner_uid ||
(uid in editorsByUid && editorsByUid[uid].id !== null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!!editorsByUid[uid]?.id

seems easier to just check this

@@ -20,33 +22,40 @@ export function readWriteToPermission(
read: boolean,
write: boolean,
isOwner: boolean,
publicDoc: boolean
publicDoc: boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publicDoc isn't used? should we remove?

@@ -20,33 +22,40 @@ export function readWriteToPermission(
read: boolean,
write: boolean,
isOwner: boolean,
publicDoc: boolean
publicDoc: boolean,
id: number
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of id field, it should be a boolean to indicate if its a permissionFromGroup

(dataDoc, editorsByUserId, viewerIds) => {
(state: IStoreState) => state.user.myUserInfo.uid,
(dataDoc, editorsByUserId, viewerIds, uid) => {
const newEditorsByUserId = Object.fromEntries(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonGroupEditorsByUserId

@jczhong84 jczhong84 force-pushed the external/group-permissions branch from bbe8c13 to 87284e3 Compare February 6, 2025 01:40
czgu
czgu previously approved these changes Feb 6, 2025
@jczhong84 jczhong84 merged commit 3122770 into pinterest:master Feb 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants