-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Hackathon admin add users UI (#854)
* Updated examples/access-token-server pkg json - Also added yarn.lock file * Pass store object to provider - Pass existing store object into provider. Found out 2 stores were created when createStore function is passed into Provider's 'store' prop. This would lead to sagas being called twice for one action. * Implemented admin add user logic - Added addUsers saga which does (in rough order): - - Check for existing Hackathon Role - - Check for or creates group for default hackathon - - Creates or updates user and enables them - - Adds user to the hackathon group - - Sets up user api3, email creds - - Sends password reset token email - - Updates user attributes, landing_page and hackathon attr - Added parseCsv saga to parse csv of users, then call addUsers - Added Admin UI tab and UI to add CSV of users and single user - Updated package.json with papaparse dependency for csv parsing - Updated yarn.lock - Update hackathon Readme with new directions and api entitlements Co-authored-by: John Kaster <kaster@google.com>
- Loading branch information
1 parent
b019a6f
commit a6fe4fd
Showing
16 changed files
with
5,719 additions
and
43 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,80 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2021 Looker Data Sciences, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
export interface UserToAdd { | ||
first: string | ||
last: string | ||
email: string | ||
} | ||
|
||
export enum Actions { | ||
PARSE_CSV = 'PARSE_CSV', | ||
ADD_USERS = 'ADD_USERS', | ||
INCREMENT_USERS_ADDED = 'INCREMENT_USERS_ADDED', | ||
RESET_ADD_USERS = 'RESET_ADD_USERS', | ||
} | ||
|
||
export interface ParseCsvAction { | ||
type: Actions.PARSE_CSV | ||
payload: File | ||
} | ||
|
||
export interface AddUsersAction { | ||
type: Actions.ADD_USERS | ||
payload: Array<UserToAdd> | ||
} | ||
|
||
export interface IncrementUsersAddedAction { | ||
type: Actions.INCREMENT_USERS_ADDED | ||
} | ||
|
||
export interface ResetAddUsersAction { | ||
type: Actions.RESET_ADD_USERS | ||
} | ||
|
||
export type AddUserAction = | ||
| ParseCsvAction | ||
| AddUsersAction | ||
| IncrementUsersAddedAction | ||
| ResetAddUsersAction | ||
|
||
export const parseCsv = (csvFile: File): ParseCsvAction => ({ | ||
type: Actions.PARSE_CSV, | ||
payload: csvFile, | ||
}) | ||
|
||
export const addUsers = (usersToAdd: Array<UserToAdd>): AddUsersAction => ({ | ||
type: Actions.ADD_USERS, | ||
payload: usersToAdd, | ||
}) | ||
|
||
export const incrementUsersAdded = (): IncrementUsersAddedAction => ({ | ||
type: Actions.INCREMENT_USERS_ADDED, | ||
}) | ||
|
||
export const resetAddUsers = (): ResetAddUsersAction => ({ | ||
type: Actions.RESET_ADD_USERS, | ||
}) |
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,80 @@ | ||
/* | ||
MIT License | ||
Copyright (c) 2021 Looker Data Sciences, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
import type { AddUserAction, UserToAdd } from './actions' | ||
import { Actions } from './actions' | ||
|
||
export enum ADD_STAGES { | ||
INIT, | ||
USERS_ADDING, | ||
USERS_ADDED, | ||
} | ||
|
||
export interface AddUserState { | ||
usersToAdd: Array<UserToAdd> | ||
usersAdded: number | ||
stage: ADD_STAGES | ||
} | ||
|
||
const defaultState: Readonly<AddUserState> = Object.freeze({ | ||
usersToAdd: [], | ||
usersAdded: 0, | ||
stage: ADD_STAGES.INIT, | ||
}) | ||
|
||
export const addUserReducer = ( | ||
state: AddUserState = defaultState, | ||
action: AddUserAction | ||
): AddUserState => { | ||
switch (action.type) { | ||
case Actions.PARSE_CSV: | ||
return { | ||
...defaultState, | ||
} | ||
case Actions.ADD_USERS: | ||
return { | ||
...defaultState, | ||
stage: ADD_STAGES.USERS_ADDING, | ||
usersToAdd: action.payload, | ||
usersAdded: 0, | ||
} | ||
case Actions.INCREMENT_USERS_ADDED: | ||
return { | ||
...state, | ||
usersAdded: state.usersAdded + 1, | ||
stage: | ||
state.usersAdded + 1 < state.usersToAdd.length | ||
? ADD_STAGES.USERS_ADDING | ||
: ADD_STAGES.INIT, | ||
} | ||
case Actions.RESET_ADD_USERS: | ||
return { | ||
...defaultState, | ||
} | ||
default: | ||
return state | ||
} | ||
} |
Oops, something went wrong.