0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(console): hide Management API from editing (#3509)

This commit is contained in:
Gao Sun 2023-03-20 11:00:16 +08:00 committed by GitHub
parent 10dca5891b
commit f27eb508ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View file

@ -1,5 +1,5 @@
import type { ResourceResponse, Scope, ScopeResponse } from '@logto/schemas'; import type { ResourceResponse, Scope, ScopeResponse } from '@logto/schemas';
import { PredefinedScope } from '@logto/schemas'; import { isManagementApi, PredefinedScope } from '@logto/schemas';
import { conditional } from '@silverhand/essentials'; import { conditional } from '@silverhand/essentials';
import classNames from 'classnames'; import classNames from 'classnames';
import type { ChangeEvent } from 'react'; import type { ChangeEvent } from 'react';
@ -82,7 +82,10 @@ const SourceScopesBox = ({ roleId, selectedScopes, onChange }: Props) => {
const excludeScopeIds = new Set([...existingScopeIds, PredefinedScope.All]); const excludeScopeIds = new Set([...existingScopeIds, PredefinedScope.All]);
return allResources return allResources
.filter(({ scopes }) => scopes.some(({ id }) => !excludeScopeIds.has(id))) .filter(
({ indicator, scopes }) =>
!isManagementApi(indicator) && scopes.some(({ id }) => !excludeScopeIds.has(id))
)
.map(({ scopes, ...resource }) => ({ .map(({ scopes, ...resource }) => ({
...resource, ...resource,
scopes: scopes scopes: scopes

View file

@ -1,5 +1,5 @@
import type { Resource } from '@logto/schemas'; import type { Resource } from '@logto/schemas';
import { defaultManagementApi, Theme } from '@logto/schemas'; import { isManagementApi, Theme } from '@logto/schemas';
import classNames from 'classnames'; import classNames from 'classnames';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
@ -42,7 +42,7 @@ function ApiResourceDetails() {
const Icon = theme === Theme.Light ? ApiResource : ApiResourceDark; const Icon = theme === Theme.Light ? ApiResource : ApiResourceDark;
const isOnPermissionPage = pathname.endsWith(ApiResourceDetailsTabs.Permissions); const isOnPermissionPage = pathname.endsWith(ApiResourceDetailsTabs.Permissions);
const isLogtoManagementApiResource = data?.indicator === defaultManagementApi.resource.indicator; const isLogtoManagementApiResource = isManagementApi(data?.indicator ?? '');
const [isDeleteFormOpen, setIsDeleteFormOpen] = useState(false); const [isDeleteFormOpen, setIsDeleteFormOpen] = useState(false);

View file

@ -1 +1,2 @@
export * from './role.js'; export * from './role.js';
export * from './management-api.js';

View file

@ -0,0 +1,2 @@
export const isManagementApi = (indicator: string) =>
/^https:\/\/[^.]+\.logto\.app\/api$/.test(indicator);