// Copyright 2025 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import '../../ui/kit/kit.js'; import * as Common from '../../core/common/common.js'; import * as Host from '../../core/host/host.js'; import * as i18n from '../../core/i18n/i18n.js'; import type * as Platform from '../../core/platform/platform.js'; import * as Root from '../../core/root/root.js'; import * as Geometry from '../../models/geometry/geometry.js'; import * as Persistence from '../../models/persistence/persistence.js'; import * as Workspace from '../../models/workspace/workspace.js'; import * as Buttons from '../../ui/components/buttons/buttons.js'; import * as UI from '../../ui/legacy/legacy.js'; import {html, nothing, render} from '../../ui/lit/lit.js'; import selectWorkspaceDialogStyles from './selectWorkspaceDialog.css.js'; /* * Strings that don't need to be translated at this time. */ const UIStringsNotTranslate = { /** * @description Heading of dialog box which asks user to select a workspace folder. */ selectFolder: 'Select folder', /** * @description Heading of dialog box which asks user to select a workspace folder for a11y clients. */ selectFolderAccessibleLabel: 'Select a folder to apply changes', /** * @description Button text for canceling workspace selection. */ cancel: 'Cancel', /** * @description Button text for confirming the selected workspace folder. */ select: 'Select', /** * @description Button text for adding a workspace folder. */ addFolder: 'Add folder', /** * @description Explanation for selecting the correct workspace folder. */ selectProjectRoot: 'Source code from the selected folder is sent to Google. This data may be seen by human reviewers to improve this feature.', /** * @description Explanation for selecting the correct workspace folder when enterprise logging is off. */ selectProjectRootNoLogging: 'Source code from the selected folder is sent to Google. This data will not be used to improve Google’s AI models. Your organization may change these settings at any time.', } as const; const lockedString = i18n.i18n.lockedString; interface Folder { name: string; path: string; project?: Workspace.Workspace.Project; automaticFileSystem?: Persistence.AutomaticFileSystemManager.AutomaticFileSystem; } interface ViewInput { folders: Folder[]; selectedIndex: number; selectProjectRootText: Platform.UIString.LocalizedString; showAutomaticWorkspaceNudge: boolean; onProjectSelected: (index: number) => void; onSelectButtonClick: () => void; onCancelButtonClick: () => void; onAddFolderButtonClick: () => void; onListItemKeyDown: (event: KeyboardEvent) => void; } type View = (input: ViewInput, output: undefined, target: HTMLElement) => void; export const SELECT_WORKSPACE_DIALOG_DEFAULT_VIEW: View = (input, _output, target): void => { const hasFolders = input.folders.length > 0; // clang-format off render( html`