Skip to content

Commit

Permalink
chore: add google connector default prompt (#6734)
Browse files Browse the repository at this point in the history
* chore: add google connector default prompt

* fix: fix console integration tests
  • Loading branch information
darcyYe authored Oct 24, 2024
1 parent 84af9ee commit 5bb9375
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/light-clocks-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@logto/connector-google": minor
---

update the default `prompts` to be `select_account`
5 changes: 5 additions & 0 deletions .changeset/tricky-walls-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@logto/console": patch
---

Connector config default values should only show up when creating new connectors
1 change: 1 addition & 0 deletions packages/connectors/connector-google/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const defaultMetadata: ConnectorMetadata = {
.map((prompt) => ({
value: prompt,
})),
defaultValue: [OidcPrompt.SelectAccount],
},
],
};
Expand Down
12 changes: 11 additions & 1 deletion packages/console/src/utils/connector-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down

0 comments on commit 5bb9375

Please sign in to comment.