mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(console): should not show admin console in audit log app selector (#4587)
This commit is contained in:
parent
c3f865ac2c
commit
c8bcbff736
1 changed files with 15 additions and 2 deletions
|
@ -1,8 +1,12 @@
|
|||
import type { Application } from '@logto/schemas';
|
||||
import { adminConsoleApplicationId } from '@logto/schemas';
|
||||
import { adminConsoleApplicationId, adminTenantId } from '@logto/schemas';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import { useContext } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { isCloud } from '@/consts/env';
|
||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||
import Select from '@/ds-components/Select';
|
||||
|
||||
type Props = {
|
||||
|
@ -12,6 +16,7 @@ type Props = {
|
|||
|
||||
function ApplicationSelector({ value, onChange }: Props) {
|
||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
|
||||
const { currentTenantId } = useContext(TenantsContext);
|
||||
const { data } = useSWR<Application[]>('api/applications');
|
||||
const options =
|
||||
data?.map(({ id, name }) => ({
|
||||
|
@ -23,7 +28,15 @@ function ApplicationSelector({ value, onChange }: Props) {
|
|||
<Select
|
||||
isClearable
|
||||
value={value}
|
||||
options={[{ value: adminConsoleApplicationId, title: 'Admin Console' }, ...options]}
|
||||
options={[
|
||||
...(conditional(
|
||||
isCloud &&
|
||||
currentTenantId === adminTenantId && [
|
||||
{ value: adminConsoleApplicationId, title: 'Admin Console' },
|
||||
]
|
||||
) ?? []),
|
||||
...options,
|
||||
]}
|
||||
placeholder={t('logs.application')}
|
||||
onChange={onChange}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue