Skip to content

Commit f10c051

Browse files
committed
Move configuration action handlers from utils to a dedicated actions directory
- move upsert/create/delete, etc. utils to `apps/editor/src/views/actions` - handle duplicating web configuration by name and handle it in settings - 'create web configuration' handler should not be responsible for duplicating. Duplication should have its own separate handling. - add missing translations to [Fragment]
1 parent 2be8bd8 commit f10c051

43 files changed

Lines changed: 76 additions & 74 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/editor/src/views/utils/create-web-configuration.ts renamed to apps/editor/src/views/actions/create-web-configuration.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import * as vscode from 'vscode'
22
import { dictionary } from '@shared/constants/dictionary'
33
import { CHATBOTS } from '@shared/constants/chatbots'
4-
import {
5-
ConfigWebConfigurationFormat
6-
} from './web-configuration-format-converters'
7-
import { generate_unique_name } from './generate-unique-name'
4+
import { ConfigWebConfigurationFormat } from '../utils/web-configuration-format-converters'
5+
import { generate_unique_name } from '../utils/generate-unique-name'
86

97
export const create_web_configuration = async (params: {
108
placement?: 'top' | 'bottom'

apps/editor/src/views/utils/delete-api-configuration.ts renamed to apps/editor/src/views/actions/delete-api-configuration.ts

File renamed without changes.

apps/editor/src/views/utils/delete-web-configuration.ts renamed to apps/editor/src/views/actions/delete-web-configuration.ts

File renamed without changes.

apps/editor/src/views/utils/duplicate-web-configuration.ts renamed to apps/editor/src/views/actions/duplicate-web-configuration.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
import * as vscode from 'vscode'
22
import { dictionary } from '@shared/constants/dictionary'
33
import { ConfigWebConfigurationFormat } from '@/views/utils/web-configuration-format-converters'
4-
import { generate_unique_name } from './generate-unique-name'
4+
import { generate_unique_name } from '../utils/generate-unique-name'
55

66

77
export const duplicate_web_configuration = async (params: {
8-
index: number
8+
name: string
99
}): Promise<void> => {
10-
const original_index = params.index
10+
const original_name = params.name
1111
const config = vscode.workspace.getConfiguration('codeWebChat')
1212
const current_web_configurations =
1313
config.get<ConfigWebConfigurationFormat[]>('webConfigurations', []) || []
1414

15-
if (original_index < 0 || original_index >= current_web_configurations.length) {
15+
const original_index = current_web_configurations.findIndex((c, i) => (c.name ?? `unnamed-${i}`) === original_name)
16+
17+
if (original_index === -1) {
1618
vscode.window.showErrorMessage(
17-
dictionary.error_message.PRESET_NOT_FOUND(`at index ${original_index}`)
19+
dictionary.error_message.PRESET_NOT_FOUND(`with name ${original_name}`)
1820
)
1921
return
2022
}
2123

2224
const web_configuration_to_duplicate = current_web_configurations[original_index]
2325

2426
const new_name = generate_unique_name(
25-
web_configuration_to_duplicate.name,
26-
current_web_configurations.map(c => c.name)
27+
web_configuration_to_duplicate.name || 'unnamed',
28+
current_web_configurations.map((c, i) => c.name ?? `unnamed-${i}`)
2729
)
2830

2931
const duplicated_web_configuration = {

apps/editor/src/views/utils/reorder-api-configurations.ts renamed to apps/editor/src/views/actions/reorder-api-configurations.ts

File renamed without changes.

apps/editor/src/views/utils/reorder-web-configurations.ts renamed to apps/editor/src/views/actions/reorder-web-configurations.ts

File renamed without changes.

apps/editor/src/views/utils/toggle-pinned-web-configuration.ts renamed to apps/editor/src/views/actions/toggle-pinned-web-configuration.ts

File renamed without changes.

apps/editor/src/views/utils/upsert-api-configuration/interactions/edit-model-for-api-config.ts renamed to apps/editor/src/views/actions/upsert-api-configuration/interactions/edit-model-for-api-config.ts

File renamed without changes.

apps/editor/src/views/utils/upsert-api-configuration/interactions/edit-provider-for-api-config.ts renamed to apps/editor/src/views/actions/upsert-api-configuration/interactions/edit-provider-for-api-config.ts

File renamed without changes.

apps/editor/src/views/utils/upsert-api-configuration/interactions/edit-reasoning-effort-for-api-config.ts renamed to apps/editor/src/views/actions/upsert-api-configuration/interactions/edit-reasoning-effort-for-api-config.ts

File renamed without changes.

0 commit comments

Comments
 (0)