Browse Source

Updates the home view to be omnipresent

main
Keith Daulton 2 years ago
parent
commit
a312aa4bd8
6 changed files with 74 additions and 3 deletions
  1. +0
    -1
      package.json
  2. +12
    -0
      src/webviews/apps/home/home.html
  3. +12
    -0
      src/webviews/apps/home/home.scss
  4. +19
    -0
      src/webviews/apps/home/home.ts
  5. +23
    -2
      src/webviews/home/homeWebviewView.ts
  6. +8
    -0
      src/webviews/home/protocol.ts

+ 0
- 1
package.json View File

@ -12198,7 +12198,6 @@
"type": "webview", "type": "webview",
"id": "gitlens.views.home", "id": "gitlens.views.home",
"name": "Home", "name": "Home",
"when": "!gitlens:disabled && gitlens:plus:enabled",
"contextualTitle": "GitLens", "contextualTitle": "GitLens",
"icon": "$(gitlens-gitlens)", "icon": "$(gitlens-gitlens)",
"visibility": "visible" "visibility": "visible"

+ 12
- 0
src/webviews/apps/home/home.html View File

@ -123,6 +123,18 @@
GitLens is deeply integrated into many areas and aspects of VS Code, especially editors and GitLens is deeply integrated into many areas and aspects of VS Code, especially editors and
views. views.
</p> </p>
<card-section no-heading id="no-repo" aria-hidden="true">
<div class="centered">
<p>
To use GitLens, open a folder containing a git repository or clone from a URL from the
Explorer.
</p>
<vscode-button class="mb-1" data-action="command:workbench.view.explorer"
>Open a Folder or Repository</vscode-button
>
</div>
</card-section>
<div class="activitybar-banner"> <div class="activitybar-banner">
<ul> <ul>
<li> <li>

+ 12
- 0
src/webviews/apps/home/home.scss View File

@ -246,6 +246,18 @@ ul {
max-width: 10rem; max-width: 10rem;
height: auto; height: auto;
} }
#no-repo[aria-hidden='false'] ~ & {
display: none;
}
}
#no-repo {
margin-bottom: 0;
&[aria-hidden='true'] {
display: none;
}
} }
.video-banner { .video-banner {

+ 19
- 0
src/webviews/apps/home/home.ts View File

@ -6,6 +6,7 @@ import { getSubscriptionTimeRemaining, SubscriptionState } from '../../../subscr
import type { State } from '../../home/protocol'; import type { State } from '../../home/protocol';
import { import {
CompleteStepCommandType, CompleteStepCommandType,
DidChangeExtensionEnabledType,
DidChangeSubscriptionNotificationType, DidChangeSubscriptionNotificationType,
DismissSectionCommandType, DismissSectionCommandType,
} from '../../home/protocol'; } from '../../home/protocol';
@ -78,6 +79,14 @@ export class HomeApp extends App {
this.updateState(); this.updateState();
}); });
break; break;
case DidChangeExtensionEnabledType.method:
this.log(`${this.appName}.onMessageReceived(${msg.id}): name=${msg.method}`);
onIpc(DidChangeExtensionEnabledType, msg, params => {
this.state.extensionEnabled = params.extensionEnabled;
this.updateNoRepo();
});
break;
default: default:
super.onMessageReceived?.(e); super.onMessageReceived?.(e);
@ -157,6 +166,15 @@ export class HomeApp extends App {
} }
} }
private updateNoRepo() {
const { extensionEnabled } = this.state;
const $el = document.getElementById('no-repo');
if ($el) {
$el.setAttribute('aria-hidden', extensionEnabled ? 'true' : 'false');
}
}
private updatePlusContent(days = this.getDaysRemaining()) { private updatePlusContent(days = this.getDaysRemaining()) {
const { subscription, visibility } = this.state; const { subscription, visibility } = this.state;
@ -211,6 +229,7 @@ export class HomeApp extends App {
private updateState() { private updateState() {
const { completedSteps, dismissedSections, plusEnabled } = this.state; const { completedSteps, dismissedSections, plusEnabled } = this.state;
this.updateNoRepo();
document.getElementById('restore-plus')?.classList.toggle('hide', plusEnabled); document.getElementById('restore-plus')?.classList.toggle('hide', plusEnabled);
const showRestoreWelcome = completedSteps?.length || dismissedSections?.length; const showRestoreWelcome = completedSteps?.length || dismissedSections?.length;

+ 23
- 2
src/webviews/home/homeWebviewView.ts View File

@ -2,8 +2,9 @@ import type { Disposable } from 'vscode';
import { window } from 'vscode'; import { window } from 'vscode';
import { getAvatarUriFromGravatarEmail } from '../../avatars'; import { getAvatarUriFromGravatarEmail } from '../../avatars';
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import { CoreCommands } from '../../constants';
import { ContextKeys, CoreCommands } from '../../constants';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { getContext, onDidChangeContext } from '../../context';
import type { RepositoriesVisibility } from '../../git/gitProviderService'; import type { RepositoriesVisibility } from '../../git/gitProviderService';
import type { SubscriptionChangeEvent } from '../../plus/subscription/subscriptionService'; import type { SubscriptionChangeEvent } from '../../plus/subscription/subscriptionService';
import { ensurePlusFeaturesEnabled } from '../../plus/subscription/utils'; import { ensurePlusFeaturesEnabled } from '../../plus/subscription/utils';
@ -16,6 +17,7 @@ import type { CompleteStepParams, DismissSectionParams, State } from './protocol
import { import {
CompletedActions, CompletedActions,
CompleteStepCommandType, CompleteStepCommandType,
DidChangeExtensionEnabledType,
DidChangeSubscriptionNotificationType, DidChangeSubscriptionNotificationType,
DismissSectionCommandType, DismissSectionCommandType,
} from './protocol'; } from './protocol';
@ -24,7 +26,13 @@ export class HomeWebviewView extends WebviewViewBase {
constructor(container: Container) { constructor(container: Container) {
super(container, 'gitlens.views.home', 'home.html', 'Home', 'homeView'); super(container, 'gitlens.views.home', 'home.html', 'Home', 'homeView');
this.disposables.push(this.container.subscription.onDidChange(this.onSubscriptionChanged, this));
this.disposables.push(
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
onDidChangeContext(key => {
if (key !== ContextKeys.Disabled) return;
this.notifyExtensionEnabled();
}),
);
} }
override async show(options?: { preserveFocus?: boolean | undefined }): Promise<void> { override async show(options?: { preserveFocus?: boolean | undefined }): Promise<void> {
@ -158,6 +166,7 @@ export class HomeWebviewView extends WebviewViewBase {
const sections = this.container.storage.get('home:sections:dismissed', []); const sections = this.container.storage.get('home:sections:dismissed', []);
return { return {
extensionEnabled: this.getExtensionEnabled(),
webroot: this.getWebRoot(), webroot: this.getWebRoot(),
subscription: subscriptionState.subscription, subscription: subscriptionState.subscription,
completedActions: subscriptionState.completedActions, completedActions: subscriptionState.completedActions,
@ -177,6 +186,18 @@ export class HomeWebviewView extends WebviewViewBase {
); );
} }
private getExtensionEnabled() {
return !getContext(ContextKeys.Disabled, false);
}
private notifyExtensionEnabled() {
if (!this.isReady) return;
void this.notify(DidChangeExtensionEnabledType, {
extensionEnabled: this.getExtensionEnabled(),
});
}
private _validating: Promise<void> | undefined; private _validating: Promise<void> | undefined;
private async validateSubscription(): Promise<void> { private async validateSubscription(): Promise<void> {
if (this._validating == null) { if (this._validating == null) {

+ 8
- 0
src/webviews/home/protocol.ts View File

@ -8,6 +8,7 @@ export const enum CompletedActions {
} }
export interface State { export interface State {
extensionEnabled: boolean;
webroot?: string; webroot?: string;
subscription: Subscription; subscription: Subscription;
completedActions: CompletedActions[]; completedActions: CompletedActions[];
@ -37,3 +38,10 @@ export interface DidChangeSubscriptionParams {
export const DidChangeSubscriptionNotificationType = new IpcNotificationType<DidChangeSubscriptionParams>( export const DidChangeSubscriptionNotificationType = new IpcNotificationType<DidChangeSubscriptionParams>(
'subscription/didChange', 'subscription/didChange',
); );
export interface DidChangeExtensionEnabledParams {
extensionEnabled: boolean;
}
export const DidChangeExtensionEnabledType = new IpcNotificationType<DidChangeExtensionEnabledParams>(
'extensionEnabled/didChange',
);

Loading…
Cancel
Save