diff --git a/src/webviews/apps/home/home.html b/src/webviews/apps/home/home.html index 0bf696d..ade1c53 100644 --- a/src/webviews/apps/home/home.html +++ b/src/webviews/apps/home/home.html @@ -103,6 +103,9 @@ + + Features which need a repository are currently unavailable + Popular views Commit Graph ✨ @@ -118,6 +122,7 @@ href="command:gitlens.showCommitDetailsView" title="Show Commit Details view" aria-label="Show Commit Details view" + data-requires="repo" >Commit Details view @@ -126,6 +131,7 @@ href="command:gitlens.showCommitsView" title="Show Commits view" aria-label="Show Commits view" + data-requires="repo" >Commits view @@ -134,6 +140,7 @@ href="command:gitlens.showFocusPage" title="Open Focus" aria-label="Open Focus" + data-requires="repo" >Focus ✨ @@ -142,6 +149,7 @@ href="command:gitlens.showFileHistoryView" title="Show File History view" aria-label="Show File History view" + data-requires="repo" >File History view @@ -150,6 +158,7 @@ href="command:gitlens.showTimelineView" title="Show Visual File History view" aria-label="Show Visual File History view" + data-requires="repo" >Visual File History ✨ @@ -158,6 +167,7 @@ href="command:gitlens.showSearchAndCompareView" title="Show Search & Compare view" aria-label="Show Search & Compare view" + data-requires="repo" >Search & Compare @@ -166,6 +176,7 @@ href="command:gitlens.showWorktreesView" title="Show Worktrees view" aria-label="Show Worktrees view" + data-requires="repo" >Worktrees ✨ @@ -185,6 +196,7 @@ href="command:workbench.view.extension.gitlensInspect" title="Show GitLens Inspect Side Bar" aria-label="Show GitLens Inspect Side Bar" + data-requires="repo" >GitLens Inspect @@ -193,6 +205,7 @@ href="command:workbench.view.scm" title="Show Source Control Side Bar" aria-label="Show GitLens Side Bar" + data-requires="repo" >Source Control @@ -212,6 +225,7 @@ href="command:gitlens.gitCommands" title="Open Git Command Palette" aria-label="Open Git Command Palette" + data-requires="repo" >Git Command Palette diff --git a/src/webviews/apps/home/home.scss b/src/webviews/apps/home/home.scss index d727063..cf2f3f5 100644 --- a/src/webviews/apps/home/home.scss +++ b/src/webviews/apps/home/home.scss @@ -171,6 +171,18 @@ ul { flex: none; padding: 0 2rem; } + + &__header:not([hidden]) + &__main [data-requires='repo'] { + opacity: 0.5; + cursor: not-allowed; + &:after { + opacity: 0.5; + } + } + + &__header[hidden] + &__main [data-requires='norepo'] { + display: none; + } } .centered { diff --git a/src/webviews/apps/home/home.ts b/src/webviews/apps/home/home.ts index 94316b8..5dcf2f3 100644 --- a/src/webviews/apps/home/home.ts +++ b/src/webviews/apps/home/home.ts @@ -15,6 +15,13 @@ export class HomeApp extends App { super('HomeApp'); } + private get blockRepoFeatures() { + const { + repositories: { openCount, hasUnsafe, trusted }, + } = this.state; + return !trusted || openCount === 0 || hasUnsafe; + } + protected override onInitialize() { this.state = this.getState() ?? this.state; this.updateState(); @@ -25,6 +32,7 @@ export class HomeApp extends App { disposables.push( DOM.on('[data-action]', 'click', (e, target: HTMLElement) => this.onDataActionClicked(e, target)), + DOM.on('[data-requires="repo"]', 'click', (e, target: HTMLElement) => this.onRepoFeatureClicked(e, target)), ); return disposables; @@ -49,6 +57,16 @@ export class HomeApp extends App { } } + private onRepoFeatureClicked(e: MouseEvent, _target: HTMLElement) { + if (this.blockRepoFeatures) { + e.preventDefault(); + e.stopPropagation(); + return false; + } + + return true; + } + private onDataActionClicked(_e: MouseEvent, target: HTMLElement) { const action = target.dataset.action; this.onActionClickedCore(action);
+ Features which need a repository are currently unavailable +