Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/connectors/connector-wecom/src/constant.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 authorizationEndpointQrcode = 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect';
Expand All @@ -15,7 +15,7 @@ export const invalidAccessTokenErrcode = [40_001, 40_014];
export const defaultMetadata: ConnectorMetadata = {
id: 'wecom-universal',
target: 'wecom',
platform: null,
platform: ConnectorPlatform.Universal,
name: {
en: 'WeCom',
'zh-CN': '企业微信',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type ConnectorFactoryResponse } from '@logto/schemas';
import { useContext } from 'react';
import { Trans, useTranslation } from 'react-i18next';

Expand All @@ -7,22 +6,15 @@ import QuotaGuardFooter from '@/components/QuotaGuardFooter';
import SkuName from '@/components/SkuName';
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider';
import Button from '@/ds-components/Button';
import { type ConnectorGroup } from '@/types/connector';
import { hasReachedSubscriptionQuotaLimit } from '@/utils/quota';

type Props = {
readonly isCreatingSocialConnector: boolean;
readonly selectedConnectorGroup?: ConnectorGroup<ConnectorFactoryResponse>;
readonly isCreateButtonDisabled: boolean;
readonly onClickCreateButton: () => void;
};

function Footer({
isCreatingSocialConnector,
selectedConnectorGroup,
isCreateButtonDisabled,
onClickCreateButton,
}: Props) {
function Footer({ isCreatingSocialConnector, isCreateButtonDisabled, onClickCreateButton }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' });
const { currentSku, currentSubscriptionUsage, currentSubscriptionQuota } =
useContext(SubscriptionDataContext);
Expand All @@ -33,12 +25,7 @@ function Footer({
quota: currentSubscriptionQuota,
});

if (
isCreatingSocialConnector &&
selectedConnectorGroup &&
isSocialConnectorsReachLimit &&
!selectedConnectorGroup.isStandard
) {
if (isCreatingSocialConnector && isSocialConnectorsReachLimit) {
return (
<QuotaGuardFooter>
<Trans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function CreateConnectorForm({ onClose, isOpen: isFormOpen, type }: Props) {
existingConnectors && (
<Footer
isCreatingSocialConnector={isCreatingSocialConnector}
selectedConnectorGroup={activeGroup}
isCreateButtonDisabled={!activeFactoryId}
onClickCreateButton={() => {
onClose?.(activeFactoryId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function PlanComparisonTable() {
{ name: appLogoAndFavicon, data: ['✓', '✓', '✓'] },
{ name: darkMode, data: ['✓', '✓', '✓'] },
{ name: i18n, data: ['✓', '✓', '✓'] },
{ name: bringYourUi, data: ['-', comingSoon, comingSoon] },
{ name: bringYourUi, data: ['-', '✓', '✓'] },
],
},
{
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/routes/connector/index.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"200": {
"description": "The created connector."
},
"403": {
"description": "The tenant has reached the maximum number of connectors."
},
"422": {
"description": "Invalid request body."
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/routes/connector/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function connectorRoutes<T extends ManagementApiRouter>(
*/
.merge(Connectors.createGuard.pick({ id: true }).partial()),
response: connectorResponseGuard,
status: [200, 400, 422],
status: [200, 400, 403, 422],
}),
async (ctx, next) => {
const {
Expand Down
Loading