Browse Source

Adds unsafe banner to home view

main
Keith Daulton 1 year ago
parent
commit
efdad20120
3 changed files with 30 additions and 10 deletions
  1. +13
    -1
      src/webviews/apps/home/home.html
  2. +1
    -1
      src/webviews/apps/home/home.scss
  3. +16
    -8
      src/webviews/apps/home/home.ts

+ 13
- 1
src/webviews/apps/home/home.html View File

@ -65,7 +65,7 @@
</nav>
</div>
<header class="home__header">
<div id="no-repo-alert" class="alert alert--info mb-0" aria-hidden="true">
<div id="no-repo-alert" class="alert alert--info mb-0" aria-hidden="true" hidden>
<h1 class="alert__title">No repository detected</h1>
<div class="alert__description">
<p>
@ -84,6 +84,18 @@
</p>
</div>
</div>
<div id="unsafe-repo-alert" class="alert alert--info mb-0" aria-hidden="true" hidden>
<h1 class="alert__title">Unsafe repository</h1>
<div class="alert__description">
<p>
Unable to open any repositories as Git blocked them as potentially unsafe, due to the folder(s)
not being owned by the current user.
</p>
<p class="centered">
<vscode-button data-action="command:workbench.view.scm">Manage in Source Control</vscode-button>
</p>
</div>
</div>
<header-card id="header-card" image="#{webroot}/media/gitlens-logo.webp"></header-card>
</header>
<main class="home__main scrollable" id="main" tabindex="-1">

+ 1
- 1
src/webviews/apps/home/home.scss View File

@ -134,7 +134,7 @@ body {
padding: 0 2rem;
position: relative;
[aria-hidden='false'] + header-card {
[aria-hidden='false'] ~ header-card {
display: none;
}
}

+ 16
- 8
src/webviews/apps/home/home.ts View File

@ -243,10 +243,7 @@ export class HomeApp extends App {
private updateNoRepo() {
const { repositories } = this.state;
const hasRepos = repositories.count > 0;
// TODO@d13 provide better feedback if there are unsafe repos (maybe even if there are no "open" repos?)
const hasRepos = repositories.openCount > 0;
const value = hasRepos ? 'true' : 'false';
let $el = document.getElementById('no-repo');
@ -258,11 +255,22 @@ export class HomeApp extends App {
}
$el = document.getElementById('no-repo-alert');
$el?.setAttribute('aria-hidden', value);
if (hasRepos) {
$el?.setAttribute('hidden', value);
const showUnsafe = repositories.hasUnsafe && !hasRepos;
const $unsafeEl = document.getElementById('unsafe-repo-alert');
if (showUnsafe) {
$el?.setAttribute('aria-hidden', 'true');
$el?.setAttribute('hidden', 'true');
$unsafeEl?.setAttribute('aria-hidden', 'false');
$unsafeEl?.removeAttribute('hidden');
} else {
$el?.removeAttribute('hidden');
$unsafeEl?.setAttribute('aria-hidden', 'true');
$unsafeEl?.setAttribute('hidden', 'true');
$el?.setAttribute('aria-hidden', value);
if (hasRepos) {
$el?.setAttribute('hidden', value);
} else {
$el?.removeAttribute('hidden');
}
}
}

Loading…
Cancel
Save