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

chore: add google connector default prompt (#6734)

* chore: add google connector default prompt

* fix: fix console integration tests
This commit is contained in:
Darcy Ye 2024-10-24 12:27:48 +08:00 committed by GitHub
parent 84af9ee2ba
commit 5bb9375055
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"@logto/connector-google": minor
---
update the default `prompts` to be `select_account`

View file

@ -0,0 +1,5 @@
---
"@logto/console": patch
---
Connector config default values should only show up when creating new connectors

View file

@ -69,6 +69,7 @@ export const defaultMetadata: ConnectorMetadata = {
.map((prompt) => ({
value: prompt,
})),
defaultValue: [OidcPrompt.SelectAccount],
},
],
};

View file

@ -6,9 +6,19 @@ import { conditional } from '@silverhand/essentials';
import { SyncProfileMode, type ConnectorFormType } from '@/types/connector';
import { safeParseJson } from '@/utils/json';
/**
* @remarks
* - When creating a new connector, this function will be called in the `convertFactoryResponseToForm()` method. At this time, there is no `config` data, so the default values in `formItems` are used.
* - When editing an existing connector, this function will be called in the `convertResponseToForm()` method. `config` data will always exist, and the `config` data is used, never using the default values.
*/
const initFormData = (formItems: ConnectorConfigFormItem[], config?: Record<string, unknown>) => {
const data: Array<[string, unknown]> = formItems.map((item) => {
const value = config?.[item.key] ?? item.defaultValue;
const configValue =
config?.[item.key] ??
conditional(item.type === ConnectorConfigFormItemType.Json && {}) ??
conditional(item.type === ConnectorConfigFormItemType.MultiSelect && []);
const { defaultValue } = item;
const value = config ? configValue : defaultValue;
if (item.type === ConnectorConfigFormItemType.Json) {
return [item.key, JSON.stringify(value, null, 2)];