-
Notifications
You must be signed in to change notification settings - Fork 4
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/330 private groups #753
Open
tomitheninja
wants to merge
24
commits into
master
Choose a base branch
from
feat/330-anon-join
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9d26d2b
Temporary change authentication
tomitheninja 9740606
Create column groups.kind
tomitheninja 7c4dc44
Convert enum values to uppercase
tomitheninja 6c6e902
Apply db changes for anonymous groups
tomitheninja 1efce8e
Assign groupRole to user when joining
tomitheninja 84aaffb
Fix: req.group is not an instance of Group
tomitheninja 69b1130
Add missing whitespaces
tomitheninja fbf0872
Implement api route to approve joining requests
tomitheninja 033ff1f
Implement front end for the new role system
tomitheninja ea9406a
Rename GroupKind.Anonymous to GroupKind.Private
tomitheninja ad1ca1f
Add GroupKind selector to the newGroup form
tomitheninja ebd94d0
Send different email for private groups
tomitheninja d73f54e
Implement GroupKind changing for group editing
tomitheninja df5451c
Implement GroupKind for group copy
tomitheninja 787584d
Show private groups on user profile when viewing self
tomitheninja 4503571
Show event on the user's profile if the event is owned by the viewer
tomitheninja 858a174
Remove a console.log
tomitheninja d573f3b
Revert "Temporary change authentication"
tomitheninja 8a33968
Rename GroupKind to GroupType
tomitheninja 0cc3ec2
Remove a console.log
tomitheninja 2cda550
Create service for fetching groups of the user
tomitheninja 287a065
Do not hide group members and show role labels
tomitheninja e7118e4
Remove duplicate role checks
tomitheninja 45060df
Merge branch 'master' into feat/330-anon-join
tomitheninja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as Knex from 'knex' | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex.schema.alterTable('groups', table => { | ||
table.enu('type', ['CLASSIC', 'PRIVATE'], { | ||
useNative: true, | ||
enumName: 'group_type' | ||
}).defaultTo('CLASSIC') | ||
}) | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex.schema.alterTable('groups', table => { | ||
table.dropColumn('type') | ||
}) | ||
} |
31 changes: 31 additions & 0 deletions
31
migrations/20210825160429_add_group_role_to_users_groups.ts
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,31 @@ | ||
import * as Knex from 'knex' | ||
|
||
const ENUM_VALUES = ['OWNER', 'MEMBER', 'UNAPPROVED'] | ||
const ENUM_CONFIG = { useNative: true, enumName: 'group_roles' } | ||
export async function up(knex: Knex): Promise<void> { | ||
// create role | ||
await knex.schema.alterTable('users_groups', (table) => | ||
table | ||
.enu('group_role', ENUM_VALUES, ENUM_CONFIG) | ||
.defaultTo('MEMBER') | ||
.notNullable() | ||
) | ||
|
||
// save owners | ||
const ownerJoins = knex('users_groups') | ||
.select('users_groups.id') | ||
.join('groups', 'group_id', '=', 'groups.id') | ||
.whereRaw('user_id = owner_id') | ||
|
||
await knex('users_groups') | ||
.update('group_role', 'OWNER') | ||
.where('id', 'in', ownerJoins) | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
// TODO: drop enum `group_roles` | ||
|
||
await knex.schema.alterTable('users_groups', (table) => { | ||
table.dropColumn('group_role') | ||
}) | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop the enum on migrate:down, or else the second migrate:up will fail, because the enum already exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could use some help with this one 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried searching knex docs but didn't really find anything, worst case you can use
.raw
withDROP TYPE group_roles
.