style(git): align the repository picker with sibling controls and drop the redundant submenu
The picker label now uses the section-header face (matching 更改/提交图) and the select mirrors the graph toolbar branch filter. The More-actions Repository submenu is removed: the standalone picker owns repository switching, and branch filtering already lives under the graph toolbar.
This commit is contained in:
1 parent
ea770cc2e1
commit
3590ec9c53
6 files changed
+26
-39
No files matched your search
+2
-2
@@ -156,8 +156,8 @@
|
||||
|
||||
### v0.30.1
|
||||
|
||||
- 🌿 **Git 面板新增「仓库 ▾」下拉,同名仓库一眼可辨**:容器工作区发现多个仓库时,顶部显示紧凑的「仓库 [当前仓库 ▾]」下拉——当前选中的仓库始终可见,完整列表一键展开,仓库再多也只占一行。选项使用位置消歧标签:深层仓库显示 `名 (相对父路径)`(如 `knowhow (ob-harness/contexts)`),同名可辨,极端冲突用完整路径兜底;「更多操作 → 仓库」菜单共用同一份标签。若服务端把所选仓库回退到其他根,下拉会以禁用项如实显示实际根,不冒充候选。单仓库工作区不显示此行;切换仍走既有 `chooseRepo`,读数、写操作与提交图继续钉在选中的根上。
|
||||
- 🧪 测试:`tests/git-repo-labels.spec.ts`(32 例:路径方言、同名消歧、顺序与输入不变)与 `tests/git-repo-switcher.spec.tsx`(下拉选项与标签、菜单同标签、拼写折叠、服务端回退的禁用临时项、单仓不显示)。
|
||||
- 🌿 **Git 面板新增「仓库 ▾」下拉,同名仓库一眼可辨**:容器工作区发现多个仓库时,顶部显示与分区标题同款的「仓库 [当前仓库 ▾]」下拉,下拉框样式与提交图的分支筛选一致——当前选中的仓库始终可见,完整列表一键展开,仓库再多也只占一行。选项使用位置消歧标签:深层仓库显示 `名 (相对父路径)`(如 `knowhow (ob-harness/contexts)`),同名可辨,极端冲突用完整路径兜底。若服务端把所选仓库回退到其他根,下拉会以禁用项如实显示实际根,不冒充候选;原「更多操作 → 仓库」二级菜单随独立下拉移除。单仓库工作区不显示此行;切换仍走既有 `chooseRepo`,读数、写操作与提交图继续钉在选中的根上。
|
||||
- 🧪 测试:`tests/git-repo-labels.spec.ts`(32 例:路径方言、同名消歧、顺序与输入不变)与 `tests/git-repo-switcher.spec.tsx`(下拉选项与标签、拼写折叠、服务端回退的禁用临时项、单仓不显示)。
|
||||
|
||||
- 🎯 **设置页「侧边卡片」的导航图标不再叠成两个**:插件此前按"宿主设置导航还没有图标通道"的老假设,用 CSS 把兜底齿轮藏起来、再画自己的图标;宿主早已提供按 section id 寻址的 `settings.section.icon` 插槽,而且图标的 DOM 外面多了一层 span,老选择器失效后兜底 SVG 露了出来,与插件图标并排显示。现在改为**走宿主插槽**提供图标,删掉标记 + CSS 遮罩那一套(顺带去掉了一个监听整个 document 的 MutationObserver)。
|
||||
- 🧪 测试:`tests/settings-nav-icon.spec.tsx` 钉住图标按宿主给的 `size` 缩放、只用 `currentColor`;真实宿主上用无头浏览器确认导航行只剩一个 `svg`、无残留标记。
|
||||
|
||||
+2
-2
@@ -152,8 +152,8 @@
|
||||
|
||||
### v0.30.1
|
||||
|
||||
- 🌿 **A labeled "Repository" dropdown for multi-repo workspaces, with same-named checkouts tellable apart**: when a container workspace discovers several repositories, the panel now shows a compact `Repository [current ▾]` select — the current root stays on screen and the full list is one click away, one line however many roots discovery finds. Options carry location labels: deeper repositories show `name (relative/parent)` (e.g. `knowhow (ob-harness/contexts)`), so same-named checkouts are distinguishable, and extreme collisions fall back to full paths; the ⋯ → Repository submenu shares the same list. If the server fell back from the requested root, the picker displays the actual root as a disabled stand-in instead of masquerading as a candidate. Single-repository workspaces render no row; switching still goes through the existing `chooseRepo`, so reads, mutations and the commit graph stay pinned to the chosen root.
|
||||
- 🧪 `tests/git-repo-labels.spec.ts` (32 cases: path dialects, duplicate disambiguation, order and input immutability) and `tests/git-repo-switcher.spec.tsx` (picker options and labels, shared menu labels, spelling folding, the server-fallback disabled stand-in, single-repo absence).
|
||||
- 🌿 **A labeled "Repository" dropdown for multi-repo workspaces, with same-named checkouts tellable apart**: when a container workspace discovers several repositories, the panel shows a `Repository [current ▾]` select styled like the section headers and the graph's branch filter — the current root stays on screen and the full list is one click away, one line however many roots discovery finds. Options carry location labels: deeper repositories show `name (relative/parent)` (e.g. `knowhow (ob-harness/contexts)`), so same-named checkouts are distinguishable, and extreme collisions fall back to full paths. If the server fell back from the requested root, the picker displays the actual root as a disabled stand-in instead of masquerading as a candidate; the former ⋯ → Repository submenu is removed now that the picker stands alone. Single-repository workspaces render no row; switching still goes through the existing `chooseRepo`, so reads, mutations and the commit graph stay pinned to the chosen root.
|
||||
- 🧪 `tests/git-repo-labels.spec.ts` (32 cases: path dialects, duplicate disambiguation, order and input immutability) and `tests/git-repo-switcher.spec.tsx` (picker options and labels, spelling folding, the server-fallback disabled stand-in, single-repo absence).
|
||||
|
||||
- 🎯 **The "Side card" settings row no longer shows two icons**: the plugin still assumed the settings navigation had no icon channel, so it hid the fallback gear with CSS and painted its own glyph. The shell has long since exposed a `settings.section.icon` slot addressed by section id, and it now wraps the nav icon in a span — the stale `> svg:first-child` rule stopped hiding the fallback, so both glyphs rendered side by side. The row now contributes its icon **through the slot**, and the marker + CSS-mask apparatus is gone (along with a document-wide MutationObserver).
|
||||
- 🧪 `tests/settings-nav-icon.spec.tsx` pins the glyph to the slot-provided `size` and `currentColor`; a headless pass against a real host confirms one `svg` in the row and no leftover marker.
|
||||
|
||||
@@ -1181,9 +1181,6 @@ export function GitLens(props: GitLensProps) {
|
||||
items={[
|
||||
{ id: 'pull', label: t('pull'), disabled: busy || suggesting || snapshot?.detached === true },
|
||||
{ id: 'push', label: t('push'), disabled: busy || suggesting || snapshot?.detached === true },
|
||||
...(repoChoices.length > 1 ? [{ id: 'repos', label: t('gitRepository'),
|
||||
submenu: repositoryLabels.map(({ root, label }) => ({ id: `repo:${root}`, label, disabled: busy || suggesting })),
|
||||
}] : []),
|
||||
...(worktrees.length > 1 ? [{ id: 'worktrees', label: t('worktree'),
|
||||
submenu: worktrees.map(entry => ({ id: `worktree:${entry.path}`,
|
||||
label: `${entry.branch || t('gitDetached')} · ${baseName(entry.path)} (${entry.changes})`, disabled: busy || suggesting,
|
||||
@@ -1194,7 +1191,6 @@ export function GitLens(props: GitLensProps) {
|
||||
setMoreMenu(null)
|
||||
if (id === 'push') push()
|
||||
else if (id === 'pull') pull()
|
||||
else if (id.startsWith('repo:')) chooseRepo(id.slice(5))
|
||||
else if (id.startsWith('worktree:')) chooseWorktree(id.slice(9))
|
||||
}} />
|
||||
</div>
|
||||
|
||||
@@ -62,16 +62,18 @@
|
||||
pinned to ONE root, so the picker is the only surface that names the current
|
||||
one and lists the others one click away. A labeled select scales to any
|
||||
number of discovered roots in a single compact band — a chip per root does
|
||||
not, once location labels distinguish same-named checkouts. */
|
||||
not, once location labels distinguish same-named checkouts. The label
|
||||
mirrors the section headers; the box mirrors the graph's branch select. */
|
||||
.repoPick {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
padding: 0 6px 2px;
|
||||
color: var(--dsw-alias-label-secondary);
|
||||
font: var(--dsw-font-xxxs-11);
|
||||
min-height: 28px;
|
||||
padding: 0 6px;
|
||||
font: var(--dsw-font-xxs-strong-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
cursor: pointer;
|
||||
}
|
||||
.repoPickLabel { flex: none; white-space: nowrap; }
|
||||
@@ -79,19 +81,13 @@
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: 22px;
|
||||
padding: 0 4px;
|
||||
border: 1px solid var(--dsw-alias-border-l1);
|
||||
height: 28px;
|
||||
border: 1px solid var(--dsw-alias-border-l2);
|
||||
border-radius: 3px;
|
||||
background: transparent;
|
||||
background: var(--dsw-alias-bg-base);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: var(--dsw-font-xxxs-11);
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
.repoPickSelect:hover:not(:disabled) { border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-interactive-bg-hover); }
|
||||
.repoPickSelect:disabled { opacity: 0.45; cursor: default; }
|
||||
.repoPickSelect:focus-visible { outline: 2px solid var(--dsw-alias-interactive-bg-hover-accent); outline-offset: -2px; }
|
||||
|
||||
/* Docked by the flex column above (a sibling of `.gitScroll`), plus sticky so
|
||||
it also survives the case where the host tab body itself scrolls the whole
|
||||
|
||||
@@ -8,16 +8,15 @@
|
||||
* the Changes section: each option pairs the display-only disambiguation
|
||||
* label (`buildRepositoryLabels(roots, scope.cwd, hostHome)` — deeper roots
|
||||
* carry their relative parent, so same-named checkouts stay tellable apart)
|
||||
* with its absolute root as the value. The ⋯ → Repository submenu shares the
|
||||
* same label list.
|
||||
* with its absolute root as the value.
|
||||
* - The picker's value is the RESOLVED status root, and both spellings of one
|
||||
* checkout fold (forward/back slashes, trailing separator, Windows case).
|
||||
* When that root is no longer among the retained choices (the server fell
|
||||
* back), it renders as a DISABLED stand-in option with its own short label —
|
||||
* the stale request or the first option is never silently presented as the
|
||||
* selection.
|
||||
* - Changing the picker re-pins the scope through the same `chooseRepo` the
|
||||
* submenu uses, so the next status read carries that root and the picker
|
||||
* - Changing the picker re-pins the scope through the existing `chooseRepo`,
|
||||
* so the next status read carries that root and the picker
|
||||
* survives the following read (a selected child still reports the full
|
||||
* `repositories` list).
|
||||
* - A single-repository workspace renders NO picker: the row must not steal
|
||||
@@ -110,18 +109,10 @@ it('renders no picker for a single-repository workspace', async () => {
|
||||
expect(view.container.querySelector('[data-scm-section="changes"]')).not.toBeNull()
|
||||
})
|
||||
|
||||
it('labels deeper repositories with their relative parent and shares the list with the menu', async () => {
|
||||
it('labels deeper repositories with their relative parent', async () => {
|
||||
const view = await mount({ sessionId: 'scm-repos-labels', repositories: [CWD, DEEP_A, DEEP_B] })
|
||||
expect(options(picker(view.container)).map(option => option.textContent))
|
||||
.toEqual(['work', 'alpha (pack)', 'beta (pack)'])
|
||||
// The ⋯ → Repository submenu reads the same label list.
|
||||
act(() => { view.container.querySelector<HTMLButtonElement>(`button[aria-label="${t('gitMoreActions')}"]`)!.click() })
|
||||
const parent = [...document.querySelectorAll<HTMLButtonElement>('button[role="menuitem"]')]
|
||||
.find(button => button.textContent?.trim() === t('gitRepository'))
|
||||
expect(parent).not.toBeUndefined()
|
||||
act(() => { parent!.click() })
|
||||
const items = [...document.querySelectorAll<HTMLButtonElement>('[role="menu"] [role="menu"] button[role="menuitem"]')]
|
||||
expect(items.map(item => item.textContent)).toEqual(['work', 'alpha (pack)', 'beta (pack)'])
|
||||
})
|
||||
|
||||
it('shows the server-fallback root as a disabled stand-in, never as a silent first option', async () => {
|
||||
|
||||
@@ -258,11 +258,12 @@ describe('GitLens (changes tab, git lens) linked-worktree consistency', () => {
|
||||
await flushEffects()
|
||||
|
||||
// The workspace container's child repositories retain their basename labels.
|
||||
const repoOptions = openMoreSubmenu(container, t('gitRepository'))
|
||||
expect(repoOptions.map(button => button.textContent)).toEqual(['a', 'b'])
|
||||
const repoPicker = container.querySelector<HTMLSelectElement>(`[data-scm-repos] select[aria-label="${t('gitRepository')}"]`)!
|
||||
expect(repoPicker).not.toBeNull()
|
||||
expect([...repoPicker.options].map(option => option.textContent)).toEqual(['a', 'b'])
|
||||
const listingsBefore = worktrees.mock.calls.length
|
||||
|
||||
await act(async () => { repoOptions[1]!.click() })
|
||||
await act(async () => { repoPicker.value = REPO_B; repoPicker.dispatchEvent(new Event('change', { bubbles: true })) })
|
||||
await flushEffects()
|
||||
|
||||
// The listing carries the selected repoRoot — a container's own listing
|
||||
@@ -286,7 +287,10 @@ describe('GitLens (changes tab, git lens) linked-worktree consistency', () => {
|
||||
act(() => { document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })) })
|
||||
act(() => { document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })) })
|
||||
|
||||
await chooseMoreOption(container, t('gitRepository'), 'a')
|
||||
// The standalone picker replaced the ⋯ → Repository submenu.
|
||||
const picker = container.querySelector<HTMLSelectElement>(`[data-scm-repos] select[aria-label="${t('gitRepository')}"]`)!
|
||||
await act(async () => { picker.value = REPO_A; picker.dispatchEvent(new Event('change', { bubbles: true })) })
|
||||
await flushEffects()
|
||||
expect(branchButton(container).title).toBe(`${t('branch')}: a-main*`)
|
||||
expect(container.querySelector('[data-path="a-change.ts"]')).not.toBeNull()
|
||||
expect(container.querySelector('[data-path="b-change.ts"]')).toBeNull()
|
||||
|
||||
Reference in new issue
Block a user