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

feat(console): sort connectors (#2587)

This commit is contained in:
wangsijie 2022-12-06 16:42:41 +08:00 committed by GitHub
parent b997d6f420
commit bbf54216fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,12 @@
export const featuredConnectorTargets = [
'google',
'apple',
'facebook',
'github',
'discord',
'wechat',
'alipay',
'kakao',
'naver',
'azuread',
];

View file

@ -16,6 +16,7 @@ import { getConnectorGroups } from '../../utils';
import Guide from '../Guide'; import Guide from '../Guide';
import PlatformSelector from './PlatformSelector'; import PlatformSelector from './PlatformSelector';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
import { getConnectorOrder } from './utils';
type Props = { type Props = {
isOpen: boolean; isOpen: boolean;
@ -56,7 +57,14 @@ const CreateForm = ({ onClose, isOpen: isFormOpen, type }: Props) => {
existingConnectors.some(({ connectorId }) => connector.id === connectorId), existingConnectors.some(({ connectorId }) => connector.id === connectorId),
})), })),
})) }))
.filter(({ connectors }) => !connectors.every(({ added }) => added)); .filter(({ connectors }) => !connectors.every(({ added }) => added))
.slice()
.sort((connectorA, connectorB) => {
const orderA = getConnectorOrder(connectorA.target, connectorA.isStandard);
const orderB = getConnectorOrder(connectorB.target, connectorB.isStandard);
return orderA - orderB;
});
}, [factories, type, existingConnectors]); }, [factories, type, existingConnectors]);
const activeGroup = useMemo( const activeGroup = useMemo(

View file

@ -0,0 +1,12 @@
import { featuredConnectorTargets } from './constants';
export const getConnectorOrder = (target: string, isStandard?: boolean): number => {
const order = featuredConnectorTargets.indexOf(target);
if (order === -1) {
// Standard connectors come last.
return isStandard ? featuredConnectorTargets.length + 1 : featuredConnectorTargets.length;
}
return order;
};