Parcourir la source

Updates the home view to be omnipresent

main
Keith Daulton il y a 2 ans
Parent
révision
a312aa4bd8
6 fichiers modifiés avec 74 ajouts et 3 suppressions
  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 Voir le fichier

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

+ 12
- 0
src/webviews/apps/home/home.html Voir le fichier

@ -123,6 +123,18 @@
GitLens is deeply integrated into many areas and aspects of VS Code, especially editors and
views.
</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">
<ul>
<li>

+ 12
- 0
src/webviews/apps/home/home.scss Voir le fichier

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

+ 19
- 0
src/webviews/apps/home/home.ts Voir le fichier

@ -6,6 +6,7 @@ import { getSubscriptionTimeRemaining, SubscriptionState } from '../../../subscr
import type { State } from '../../home/protocol';
import {
CompleteStepCommandType,
DidChangeExtensionEnabledType,
DidChangeSubscriptionNotificationType,
DismissSectionCommandType,
} from '../../home/protocol';
@ -78,6 +79,14 @@ export class HomeApp extends App {
this.updateState();
});
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:
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()) {
const { subscription, visibility } = this.state;
@ -211,6 +229,7 @@ export class HomeApp extends App {
private updateState() {
const { completedSteps, dismissedSections, plusEnabled } = this.state;
this.updateNoRepo();
document.getElementById('restore-plus')?.classList.toggle('hide', plusEnabled);
const showRestoreWelcome = completedSteps?.length || dismissedSections?.length;

+ 23
- 2
src/webviews/home/homeWebviewView.ts Voir le fichier

@ -2,8 +2,9 @@ import type { Disposable } from 'vscode';
import { window } from 'vscode';
import { getAvatarUriFromGravatarEmail } from '../../avatars';
import { configuration } from '../../configuration';
import { CoreCommands } from '../../constants';
import { ContextKeys, CoreCommands } from '../../constants';
import type { Container } from '../../container';
import { getContext, onDidChangeContext } from '../../context';
import type { RepositoriesVisibility } from '../../git/gitProviderService';
import type { SubscriptionChangeEvent } from '../../plus/subscription/subscriptionService';
import { ensurePlusFeaturesEnabled } from '../../plus/subscription/utils';
@ -16,6 +17,7 @@ import type { CompleteStepParams, DismissSectionParams, State } from './protocol
import {
CompletedActions,
CompleteStepCommandType,
DidChangeExtensionEnabledType,
DidChangeSubscriptionNotificationType,
DismissSectionCommandType,
} from './protocol';
@ -24,7 +26,13 @@ export class HomeWebviewView extends WebviewViewBase {
constructor(container: Container) {
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> {
@ -158,6 +166,7 @@ export class HomeWebviewView extends WebviewViewBase {
const sections = this.container.storage.get('home:sections:dismissed', []);
return {
extensionEnabled: this.getExtensionEnabled(),
webroot: this.getWebRoot(),
subscription: subscriptionState.subscription,
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 async validateSubscription(): Promise<void> {
if (this._validating == null) {

+ 8
- 0
src/webviews/home/protocol.ts Voir le fichier

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

Chargement…
Annuler
Enregistrer