-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'leszek/cleanup-view-switcher-etc' of github.com:kobotoo…
…lbox/kpi into leszek/cleanup-view-switcher-etc
- Loading branch information
Showing
31 changed files
with
1,059 additions
and
563 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
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 |
---|---|---|
|
@@ -75,7 +75,7 @@ openpyxl | |
psycopg | ||
pymongo | ||
python-dateutil | ||
pyxform==1.9.0 | ||
pyxform==2.1.1 | ||
requests | ||
regex | ||
responses | ||
|
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
33 changes: 0 additions & 33 deletions
33
jsapp/js/account/organizations/requireOrgOwner.component.tsx
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
jsapp/js/account/organizations/validateOrgPermissions.component.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,49 @@ | ||
import React, {Suspense, useEffect} from 'react'; | ||
import {useNavigate} from 'react-router-dom'; | ||
import LoadingSpinner from 'js/components/common/loadingSpinner'; | ||
import {ACCOUNT_ROUTES} from 'js/account/routes.constants'; | ||
import {useOrganizationQuery} from 'js/account/stripe.api'; | ||
import {OrganizationUserRole} from '../stripe.types'; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
validRoles?: OrganizationUserRole[]; | ||
mmoOnly?: boolean; | ||
redirect?: boolean; | ||
} | ||
|
||
/** | ||
* Use to handle display of pages that should only be accessible to certain user roles | ||
* or members of MMOs. Defaults to allowing access for all users, so you must supply | ||
* any restrictions. | ||
*/ | ||
export const ValidateOrgPermissions = ({ | ||
children, | ||
validRoles = undefined, | ||
mmoOnly = false, | ||
redirect = true, | ||
}: Props) => { | ||
const navigate = useNavigate(); | ||
const orgQuery = useOrganizationQuery(); | ||
const hasValidRole = validRoles ? validRoles.includes( | ||
orgQuery.data?.request_user_role ?? OrganizationUserRole.member | ||
) : true; | ||
const hasValidOrg = mmoOnly ? orgQuery.data?.is_mmo : true; | ||
|
||
// Redirect to Account Settings if conditions not met | ||
useEffect(() => { | ||
if ( | ||
redirect && | ||
orgQuery.data && | ||
(!hasValidRole || !hasValidOrg) | ||
) { | ||
navigate(ACCOUNT_ROUTES.ACCOUNT_SETTINGS); | ||
} | ||
}, [redirect, orgQuery.data, navigate]); | ||
|
||
return redirect && hasValidRole && hasValidOrg ? ( | ||
<Suspense fallback={null}>{children}</Suspense> | ||
) : ( | ||
<LoadingSpinner /> | ||
); | ||
}; |
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
Oops, something went wrong.