Skip to content

Commit 462067e

Browse files
wolfibDevtools-frontend LUCI CQ
authored andcommitted
[Patch agent] Select workspace dialog: select newly added workspaces
When the user adds a new workspace via the SelectWorkspaceDialog, the newly added workspace is automatically selected/highlighted. The user only needs to confirm the selection, instead of selecting and then confirming. Bug: 393266352 Change-Id: I6971e31cf1438d54b058807afa2d8a0832d0f6e3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6368840 Reviewed-by: Ergün Erdoğmuş <[email protected]> Auto-Submit: Wolfgang Beyer <[email protected]> Commit-Queue: Wolfgang Beyer <[email protected]>
1 parent f6929e1 commit 462067e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

front_end/panels/ai_assistance/SelectWorkspaceDialog.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ describeWithEnvironment('SelectWorkspaceDialog', () => {
7979
const {view} = createComponent();
8080
assert.strictEqual(view.callCount, 1);
8181
assert.lengthOf(view.input.projects, 2);
82+
assert.strictEqual(view.input.selectedIndex, 0);
83+
8284
view.input.onAddFolderButtonClick();
8385
assert.isTrue(addProjectSpy.calledOnce);
8486

8587
createTestFilesystem('file://test3');
8688
const input = await view.nextInput;
8789
assert.strictEqual(view.callCount, 2);
8890
assert.lengthOf(input.projects, 3);
91+
assert.strictEqual(input.projects[2].name, 'test3');
92+
assert.strictEqual(input.selectedIndex, 2);
8993
});
9094
});

front_end/panels/ai_assistance/SelectWorkspaceDialog.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import type * as Common from '../../core/common/common.js';
56
import * as i18n from '../../core/i18n/i18n.js';
67
import type * as Platform from '../../core/platform/platform.js';
78
import * as Persistence from '../../models/persistence/persistence.js';
@@ -206,8 +207,13 @@ export class SelectWorkspaceDialog extends UI.Widget.VBox {
206207
Persistence.PlatformFileSystem.PlatformFileSystemType.WORKSPACE_PROJECT);
207208
}
208209

209-
#onProjectAdded(): void {
210+
#onProjectAdded(event: Common.EventTarget.EventTargetEvent<Workspace.Workspace.Project>): void {
211+
const addedProject = event.data;
210212
this.#projects = this.#getProjects();
213+
const projectIndex = this.#projects.indexOf(addedProject);
214+
if (projectIndex !== -1) {
215+
this.#selectedIndex = projectIndex;
216+
}
211217
this.requestUpdate();
212218
}
213219

0 commit comments

Comments
 (0)