-
Notifications
You must be signed in to change notification settings - Fork 2
Move user menu, create org menu #1992
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
Draft
GregorShear
wants to merge
16
commits into
main
Choose a base branch
from
greg/move-avatar
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7faacc2
move help and user menus, create org menu, remove prefix selector fro…
GregorShear a712916
OrgMenu: default to the first available tenant on render
GregorShear 62d6a9d
Fix Prettier formatting in Billing index
GregorShear faaf8be
OrgMenu: honor ?prefix= deep-link and use one org list for all users
GregorShear 6cc847b
OrgMenu: keep the support autocomplete dialog, validate per-user list
GregorShear d0675b2
OrgMenu: support dialog lists the same tenants as the old selector
GregorShear 341f36a
Add a logout escape hatch to the legal-check error screen
GregorShear a179417
Always offer logout on the full-page error, not per call site
GregorShear 496597c
Add a Reload button beside Logout on the full-page error
GregorShear ad7450a
Revert PrefixedName changes; leave component untouched in this PR
GregorShear 2fc90c7
clean up comments
GregorShear 8e4c2b9
Move tenant-selection bootstrap from OrgMenu into TenantGuard
GregorShear b3e4b00
Document why userDetails.emailVerified is effectively always true
GregorShear f71f0e6
tweak exports
GregorShear 1f93b3c
Consolidate side-nav rows into ListItemLink and simplify the menus
GregorShear 233eee3
update comments
GregorShear 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,22 @@ | ||
| import { useCallback, useEffect, useRef } from 'react'; | ||
|
|
||
| import { useBillingStore } from 'src/stores/Billing'; | ||
| import { useTenantStore } from 'src/stores/Tenant'; | ||
|
|
||
| export function useTenantChangeReset() { | ||
| const selectedTenant = useTenantStore((state) => state.selectedTenant); | ||
|
|
||
| const resetBillingState = useBillingStore((state) => state.resetState); | ||
|
|
||
| const resetStores = useCallback(() => { | ||
| resetBillingState(); | ||
| }, [resetBillingState]); | ||
|
|
||
| const previousTenant = useRef(selectedTenant); | ||
| useEffect(() => { | ||
| if (previousTenant.current !== selectedTenant) { | ||
| previousTenant.current = selectedTenant; | ||
| resetStores(); | ||
| } | ||
| }, [selectedTenant, resetStores]); | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -3,14 +3,15 @@ import type { ErrorDetails } from 'src/components/shared/Error/types'; | |
|
|
||
| import { useMemo } from 'react'; | ||
|
|
||
| import { Divider, Stack, Typography } from '@mui/material'; | ||
| import { Button, Divider, Stack, Typography } from '@mui/material'; | ||
|
|
||
| import { FormattedMessage } from 'react-intl'; | ||
| import { useMount } from 'react-use'; | ||
|
|
||
| import FullPageWrapper from 'src/app/FullPageWrapper'; | ||
| import MessageWithLink from 'src/components/content/MessageWithLink'; | ||
| import Error from 'src/components/shared/Error'; | ||
| import { supabaseClient } from 'src/context/GlobalProviders'; | ||
| import { logRocketEvent } from 'src/services/shared'; | ||
| import { CustomEvents } from 'src/services/types'; | ||
|
|
||
|
|
@@ -56,6 +57,27 @@ function FullPageError({ | |
| <Typography variant="subtitle1"> | ||
| <MessageWithLink messageID="fullPage.instructions" /> | ||
| </Typography> | ||
|
|
||
| <Stack direction="row" spacing={1}> | ||
| <Button | ||
| variant="contained" | ||
| onClick={() => { | ||
| window.location.reload(); | ||
| }} | ||
| > | ||
| <FormattedMessage id="cta.reload" /> | ||
| </Button> | ||
|
|
||
| <Button | ||
| variant="outlined" | ||
| onClick={() => { | ||
| void supabaseClient.auth.signOut(); | ||
| }} | ||
| > | ||
| <FormattedMessage id="cta.logout" /> | ||
| </Button> | ||
| </Stack> | ||
|
Comment on lines
+61
to
+79
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user menu (and logout menu item) moved to the sidenav, which the FullPageError omits, so putting a a logout button directly in the error dialog |
||
|
|
||
| <Divider /> | ||
| <Error error={error} condensed /> | ||
| </Stack> | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,132 @@ | ||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogTitle, | ||
| MenuItem, | ||
| Popover, | ||
| Typography, | ||
| } from '@mui/material'; | ||
|
|
||
| import { Check } from 'iconoir-react'; | ||
| import { FormattedMessage, useIntl } from 'react-intl'; | ||
|
|
||
| import PrefixSelector from 'src/components/inputs/PrefixedName/PrefixSelector'; | ||
| import { | ||
| sideNavMenuAnchorOrigin, | ||
| sideNavMenuTransformOrigin, | ||
| } from 'src/components/menus/shared'; | ||
| import { useUserInfoSummaryStore } from 'src/context/UserInfoSummary/useUserInfoSummaryStore'; | ||
| import { useEntitiesStore_tenantsWithAdmin } from 'src/stores/Entities/hooks'; | ||
| import { useTenantStore } from 'src/stores/Tenant'; | ||
|
|
||
| interface OrgMenuProps { | ||
| anchorEl: HTMLElement | null; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| export const OrgMenu = ({ anchorEl, onClose }: OrgMenuProps) => { | ||
| const intl = useIntl(); | ||
| const selectedTenant = useTenantStore((state) => state.selectedTenant); | ||
| const setSelectedTenant = useTenantStore( | ||
| (state) => state.setSelectedTenant | ||
| ); | ||
| // Same tenant list the old TenantSelector showed everyone (incl. estuary_support). | ||
| const tenantNames = useEntitiesStore_tenantsWithAdmin(); | ||
| const hasSupportAccess = useUserInfoSummaryStore( | ||
| (state) => state.hasSupportAccess | ||
| ); | ||
|
|
||
| // Support users get the searchable dialog (every prefix); everyone else | ||
| // gets the popover list anchored to the trigger. | ||
| if (hasSupportAccess) { | ||
| return ( | ||
| <Dialog | ||
| open={Boolean(anchorEl)} | ||
| onClose={onClose} | ||
| fullWidth | ||
| maxWidth="xs" | ||
| > | ||
| <DialogTitle> | ||
| <FormattedMessage id="tenant.organization" /> | ||
| </DialogTitle> | ||
| <DialogContent> | ||
| <PrefixSelector | ||
| disabled={false} | ||
| error={false} | ||
| label={intl.formatMessage({ | ||
| id: 'common.tenant', | ||
| })} | ||
| labelId="org-switcher" | ||
| onChange={(newValue) => { | ||
| setSelectedTenant(newValue); | ||
| onClose(); | ||
| }} | ||
| options={tenantNames} | ||
| value={selectedTenant} | ||
| variantString="outlined" | ||
| /> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Popover | ||
| open={Boolean(anchorEl)} | ||
| anchorEl={anchorEl} | ||
| onClose={onClose} | ||
| anchorOrigin={sideNavMenuAnchorOrigin} | ||
| transformOrigin={sideNavMenuTransformOrigin} | ||
| slotProps={{ | ||
| paper: { | ||
| sx: { | ||
| width: 240, | ||
| p: 1, | ||
| borderRadius: 2, | ||
| }, | ||
| }, | ||
| }} | ||
| > | ||
| <Typography | ||
| sx={{ | ||
| px: 1, | ||
| pt: 0.5, | ||
| pb: 1, | ||
| fontSize: 11, | ||
| fontWeight: 600, | ||
| textTransform: 'uppercase', | ||
| letterSpacing: 0.5, | ||
| color: 'text.secondary', | ||
| }} | ||
| > | ||
| <FormattedMessage id="tenant.organization" /> | ||
| </Typography> | ||
|
|
||
| {tenantNames.map((tenant) => { | ||
| const label = tenant.replace(/\/$/, ''); | ||
| const isSelected = tenant === selectedTenant; | ||
|
|
||
| return ( | ||
| <MenuItem | ||
| key={tenant} | ||
| selected={isSelected} | ||
| onClick={() => { | ||
| setSelectedTenant(tenant); | ||
| onClose(); | ||
| }} | ||
| sx={{ | ||
| borderRadius: 1, | ||
| fontSize: 13, | ||
| py: 0.75, | ||
| justifyContent: 'space-between', | ||
| }} | ||
| > | ||
| {label} | ||
|
|
||
| {isSelected ? <Check /> : null} | ||
| </MenuItem> | ||
| ); | ||
| })} | ||
| </Popover> | ||
| ); | ||
| }; |
Oops, something went wrong.
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.
This hook is transitional - it extracts the billing reset logic from the deleted TenantOptions component.
A follow-up PR will key billing data on the selected tenant making this reset unnecessary.