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:
parent
b997d6f420
commit
bbf54216fe
3 changed files with 33 additions and 1 deletions
|
@ -0,0 +1,12 @@
|
||||||
|
export const featuredConnectorTargets = [
|
||||||
|
'google',
|
||||||
|
'apple',
|
||||||
|
'facebook',
|
||||||
|
'github',
|
||||||
|
'discord',
|
||||||
|
'wechat',
|
||||||
|
'alipay',
|
||||||
|
'kakao',
|
||||||
|
'naver',
|
||||||
|
'azuread',
|
||||||
|
];
|
|
@ -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(
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
Loading…
Reference in a new issue