From bb36826e621d39f630aa808ddbbea36f46e29543 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Tue, 6 Sep 2022 11:28:48 -0400 Subject: [PATCH] Fixes actions for uncommitted commit details --- CHANGELOG.md | 4 ++++ src/webviews/apps/commitDetails/commitDetails.ts | 8 +++++++- src/webviews/apps/shared/components/commit/file-change-item.ts | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 458ebac..1fad5d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Fixed + +- Fixes Commit Details showing incorrect actions for uncommitted changes + ## [12.2.2] - 2022-09-06 ### Fixed diff --git a/src/webviews/apps/commitDetails/commitDetails.ts b/src/webviews/apps/commitDetails/commitDetails.ts index 973594c..59ac8e5 100644 --- a/src/webviews/apps/commitDetails/commitDetails.ts +++ b/src/webviews/apps/commitDetails/commitDetails.ts @@ -206,6 +206,7 @@ export class CommitDetailsApp extends App> { return; } + this.renderActions(this.state); this.renderPin(this.state); this.renderSha(this.state); this.renderMessage(this.state); @@ -218,6 +219,11 @@ export class CommitDetailsApp extends App> { // } } + renderActions(state: CommitState) { + const isHidden = state.selected?.sha === uncommittedSha ? 'true' : 'false'; + [...document.querySelectorAll('[data-action-type="graph"],[data-action-type="more"]')].forEach($el => $el.setAttribute('aria-hidden', isHidden)); + } + renderPin(state: CommitState) { const $el = document.querySelector('[data-action="pin"]'); if ($el == null) { @@ -322,7 +328,7 @@ export class CommitDetailsApp extends App> { } if (state.selected.files?.length) { - const stashAttr = state.selected.isStash ? 'stash ' : ''; + const stashAttr = state.selected.isStash ? 'stash ' : state.selected.sha === uncommittedSha ? 'uncommitted ' : ''; $el.innerHTML = state.selected.files .map( (file: Record) => ` diff --git a/src/webviews/apps/shared/components/commit/file-change-item.ts b/src/webviews/apps/shared/components/commit/file-change-item.ts index 0551d61..bfe0826 100644 --- a/src/webviews/apps/shared/components/commit/file-change-item.ts +++ b/src/webviews/apps/shared/components/commit/file-change-item.ts @@ -159,6 +159,9 @@ export class FileChangeItem extends LitElement { @property({ type: Boolean, reflect: true }) stash = false; + @property({ type: Boolean, reflect: true }) + uncommitted = false; + private renderIcon() { if (this.icon !== '') { return html``; @@ -197,14 +200,14 @@ export class FileChangeItem extends LitElement { title="Open file" aria-label="Open file" >${!this.uncommitted ? html`${!this.stash + >` : nothing}${!this.stash && !this.uncommitted ? html`