0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(console,core,connector): fix display issues and POST /connectors API code guard (#6481)

* fix(console,core,connector): fix display issues

* chore: add changeset
This commit is contained in:
Darcy Ye 2024-08-21 11:17:28 +08:00 committed by GitHub
parent 2caeacaf93
commit 763dd60cd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 20 deletions

View file

@ -0,0 +1,5 @@
---
"@logto/connector-wecom": patch
---
fix wecom connector platform, should be `Universal` instead of `null`

View file

@ -1,5 +1,5 @@
import type { ConnectorMetadata } from '@logto/connector-kit'; import type { ConnectorMetadata } from '@logto/connector-kit';
import { ConnectorConfigFormItemType } from '@logto/connector-kit'; import { ConnectorConfigFormItemType, ConnectorPlatform } from '@logto/connector-kit';
export const authorizationEndpointInside = 'https://open.weixin.qq.com/connect/oauth2/authorize'; export const authorizationEndpointInside = 'https://open.weixin.qq.com/connect/oauth2/authorize';
export const authorizationEndpointQrcode = 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect'; export const authorizationEndpointQrcode = 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect';
@ -15,7 +15,7 @@ export const invalidAccessTokenErrcode = [40_001, 40_014];
export const defaultMetadata: ConnectorMetadata = { export const defaultMetadata: ConnectorMetadata = {
id: 'wecom-universal', id: 'wecom-universal',
target: 'wecom', target: 'wecom',
platform: null, platform: ConnectorPlatform.Universal,
name: { name: {
en: 'WeCom', en: 'WeCom',
'zh-CN': '企业微信', 'zh-CN': '企业微信',

View file

@ -1,4 +1,3 @@
import { type ConnectorFactoryResponse } from '@logto/schemas';
import { useContext } from 'react'; import { useContext } from 'react';
import { Trans, useTranslation } from 'react-i18next'; import { Trans, useTranslation } from 'react-i18next';
@ -7,22 +6,15 @@ import QuotaGuardFooter from '@/components/QuotaGuardFooter';
import SkuName from '@/components/SkuName'; import SkuName from '@/components/SkuName';
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider'; import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
import Button from '@/ds-components/Button'; import Button from '@/ds-components/Button';
import { type ConnectorGroup } from '@/types/connector';
import { hasReachedSubscriptionQuotaLimit } from '@/utils/quota'; import { hasReachedSubscriptionQuotaLimit } from '@/utils/quota';
type Props = { type Props = {
readonly isCreatingSocialConnector: boolean; readonly isCreatingSocialConnector: boolean;
readonly selectedConnectorGroup?: ConnectorGroup<ConnectorFactoryResponse>;
readonly isCreateButtonDisabled: boolean; readonly isCreateButtonDisabled: boolean;
readonly onClickCreateButton: () => void; readonly onClickCreateButton: () => void;
}; };
function Footer({ function Footer({ isCreatingSocialConnector, isCreateButtonDisabled, onClickCreateButton }: Props) {
isCreatingSocialConnector,
selectedConnectorGroup,
isCreateButtonDisabled,
onClickCreateButton,
}: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' }); const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' });
const { currentSku, currentSubscriptionUsage, currentSubscriptionQuota } = const { currentSku, currentSubscriptionUsage, currentSubscriptionQuota } =
useContext(SubscriptionDataContext); useContext(SubscriptionDataContext);
@ -33,12 +25,7 @@ function Footer({
quota: currentSubscriptionQuota, quota: currentSubscriptionQuota,
}); });
if ( if (isCreatingSocialConnector && isSocialConnectorsReachLimit) {
isCreatingSocialConnector &&
selectedConnectorGroup &&
isSocialConnectorsReachLimit &&
!selectedConnectorGroup.isStandard
) {
return ( return (
<QuotaGuardFooter> <QuotaGuardFooter>
<Trans <Trans

View file

@ -121,7 +121,6 @@ function CreateConnectorForm({ onClose, isOpen: isFormOpen, type }: Props) {
existingConnectors && ( existingConnectors && (
<Footer <Footer
isCreatingSocialConnector={isCreatingSocialConnector} isCreatingSocialConnector={isCreatingSocialConnector}
selectedConnectorGroup={activeGroup}
isCreateButtonDisabled={!activeFactoryId} isCreateButtonDisabled={!activeFactoryId}
onClickCreateButton={() => { onClickCreateButton={() => {
onClose?.(activeFactoryId); onClose?.(activeFactoryId);

View file

@ -185,7 +185,7 @@ function PlanComparisonTable() {
{ name: appLogoAndFavicon, data: ['✓', '✓', '✓'] }, { name: appLogoAndFavicon, data: ['✓', '✓', '✓'] },
{ name: darkMode, data: ['✓', '✓', '✓'] }, { name: darkMode, data: ['✓', '✓', '✓'] },
{ name: i18n, data: ['✓', '✓', '✓'] }, { name: i18n, data: ['✓', '✓', '✓'] },
{ name: bringYourUi, data: ['-', comingSoon, comingSoon] }, { name: bringYourUi, data: ['-', '✓', '✓'] },
], ],
}, },
{ {

View file

@ -39,6 +39,9 @@
"200": { "200": {
"description": "The created connector." "description": "The created connector."
}, },
"403": {
"description": "The tenant has reached the maximum number of connectors."
},
"422": { "422": {
"description": "Invalid request body." "description": "Invalid request body."
} }

View file

@ -68,7 +68,7 @@ export default function connectorRoutes<T extends ManagementApiRouter>(
*/ */
.merge(Connectors.createGuard.pick({ id: true }).partial()), .merge(Connectors.createGuard.pick({ id: true }).partial()),
response: connectorResponseGuard, response: connectorResponseGuard,
status: [200, 400, 422], status: [200, 400, 403, 422],
}), }),
async (ctx, next) => { async (ctx, next) => {
const { const {