-
-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(console): add notification for m2m role
- Loading branch information
Showing
17 changed files
with
65 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ import { Theme, RoleType } from '@logto/schemas'; | |
import classNames from 'classnames'; | ||
import { useEffect, useState } from 'react'; | ||
import { toast } from 'react-hot-toast'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
import { Outlet, useLocation, useParams } from 'react-router-dom'; | ||
import useSWR, { useSWRConfig } from 'swr'; | ||
|
||
|
@@ -14,13 +14,17 @@ import UserRoleIconDark from '@/assets/icons/user-role-dark.svg'; | |
import UserRoleIcon from '@/assets/icons/user-role.svg'; | ||
import DetailsPage from '@/components/DetailsPage'; | ||
import DetailsPageHeader from '@/components/DetailsPage/DetailsPageHeader'; | ||
import { isDevFeaturesEnabled } from '@/consts/env'; | ||
import { RoleDetailsTabs } from '@/consts/page-tabs'; | ||
import ConfirmModal from '@/ds-components/ConfirmModal'; | ||
import InlineNotification from '@/ds-components/InlineNotification'; | ||
import TabNav, { TabNavItem } from '@/ds-components/TabNav'; | ||
import TextLink from '@/ds-components/TextLink'; | ||
import type { RequestError } from '@/hooks/use-api'; | ||
import useApi from '@/hooks/use-api'; | ||
import useTenantPathname from '@/hooks/use-tenant-pathname'; | ||
import useTheme from '@/hooks/use-theme'; | ||
import useUserPreferences from '@/hooks/use-user-preferences'; | ||
|
||
import * as styles from './index.module.scss'; | ||
import { type RoleDetailsOutletContext } from './types'; | ||
|
@@ -47,6 +51,16 @@ function RoleDetails() { | |
const { mutate: mutateGlobal } = useSWRConfig(); | ||
const isLoading = !data && !error; | ||
|
||
const { | ||
data: { m2mRoleNotificationAcknowledged }, | ||
update: updateUserPreferences, | ||
isLoaded: isUserPreferencesLoaded, | ||
} = useUserPreferences(); | ||
// Default to true to avoid page flickering | ||
const isM2mRoleNotificationAcknowledged = isUserPreferencesLoaded | ||
? Boolean(m2mRoleNotificationAcknowledged) | ||
: true; | ||
|
||
const [isDeletionAlertOpen, setIsDeletionAlertOpen] = useState(false); | ||
|
||
useEffect(() => { | ||
|
@@ -83,6 +97,25 @@ function RoleDetails() { | |
className={classNames(isPageHasTable && styles.withTable)} | ||
onRetry={mutate} | ||
> | ||
{/* Todo @xiaoyijun remove dev feature flag */} | ||
Check warning on line 100 in packages/console/src/pages/RoleDetails/index.tsx GitHub Actions / ESLint Report Analysispackages/console/src/pages/RoleDetails/index.tsx#L100
|
||
{isDevFeaturesEnabled && !isM2mRoleNotificationAcknowledged && ( | ||
<InlineNotification | ||
action="general.got_it" | ||
onClick={() => { | ||
void updateUserPreferences({ | ||
m2mRoleNotificationAcknowledged: true, | ||
}); | ||
}} | ||
> | ||
<Trans | ||
components={{ | ||
a: <TextLink to="/applications" />, | ||
}} | ||
> | ||
{t('role_details.m2m_role_notification')} | ||
</Trans> | ||
</InlineNotification> | ||
)} | ||
{data && ( | ||
<> | ||
<DetailsPageHeader | ||
|
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
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
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
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