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:
parent
10dca5891b
commit
f27eb508ed
4 changed files with 10 additions and 4 deletions
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export * from './role.js';
|
export * from './role.js';
|
||||||
|
export * from './management-api.js';
|
||||||
|
|
2
packages/schemas/src/utils/management-api.ts
Normal file
2
packages/schemas/src/utils/management-api.ts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export const isManagementApi = (indicator: string) =>
|
||||||
|
/^https:\/\/[^.]+\.logto\.app\/api$/.test(indicator);
|
Loading…
Add table
Reference in a new issue