0
Fork 0
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:
Darcy Ye 2023-09-27 08:16:52 +08:00 committed by GitHub
parent c3f865ac2c
commit c8bcbff736
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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}
/>