-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add user group db schema support
- Loading branch information
Showing
12 changed files
with
198 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
querybook/migrations/versions/1b8aba201c94_add_user_group_support.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""add user group support | ||
Revision ID: 1b8aba201c94 | ||
Revises: 27ed76f75106 | ||
Create Date: 2023-02-03 00:31:09.209132 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy.dialects import mysql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "1b8aba201c94" | ||
down_revision = "27ed76f75106" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table( | ||
"user_group_member", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("gid", sa.Integer(), nullable=False), | ||
sa.Column("uid", sa.Integer(), nullable=False), | ||
sa.ForeignKeyConstraint(["gid"], ["user.id"], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(["uid"], ["user.id"], ondelete="CASCADE"), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.add_column("user", sa.Column("is_group", sa.Boolean(), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column("user", "is_group") | ||
op.drop_table("user_group_member") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.UserGroupCard { | ||
max-width: 400px; | ||
|
||
.members-container { | ||
display: flex; | ||
align-items: center; | ||
flex-wrap: wrap; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
querybook/webapp/components/UserGroupCard/UserGroupCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { UserBadge } from 'components/UserBadge/UserBadge'; | ||
import { IUserInfo } from 'const/user'; | ||
import { UserResource } from 'resource/user'; | ||
import { AccentText } from 'ui/StyledText/StyledText'; | ||
|
||
import './UserGroupCard.scss'; | ||
|
||
interface IProps { | ||
userGroup: IUserInfo; | ||
} | ||
|
||
export const UserGroupCard = ({ userGroup }: IProps) => { | ||
const [members, setMembers] = useState([]); | ||
|
||
useEffect(() => { | ||
UserResource.getUserGroupMembers(userGroup.id).then(({ data }) => { | ||
setMembers(data); | ||
}); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return ( | ||
<div className="UserGroupCard"> | ||
<div> | ||
<AccentText color="dark" weight="bold"> | ||
{userGroup.fullname} | ||
</AccentText> | ||
<AccentText color="light">{userGroup.username}</AccentText> | ||
</div> | ||
<div className="mt8"> | ||
<AccentText color="dark" weight="bold"> | ||
</AccentText> | ||
<AccentText color="light">{userGroup.email}</AccentText> | ||
</div> | ||
<div className="mt8"> | ||
<AccentText color="dark" weight="bold"> | ||
Description | ||
</AccentText> | ||
<AccentText color="light"> | ||
{userGroup.properties?.description} | ||
</AccentText> | ||
</div> | ||
<div className="mt8"> | ||
<AccentText color="dark" weight="bold"> | ||
Group members | ||
</AccentText> | ||
<div className="members-container"> | ||
{members.map((m) => ( | ||
<div key={m.id} className="ml8"> | ||
<UserBadge uid={m.id} mini /> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters