Improve a bunch of stuff

This commit is contained in:
Mattias Granlund 2023-11-27 22:15:26 +01:00
parent 3da78c2fe4
commit b4616eaa1f
6 changed files with 42 additions and 39 deletions

View File

@ -177,7 +177,7 @@
display: flex;
flex-grow: 1;
flex-shrink: 1;
align-items: start;
align-items: flex-start;
height: 100%;
padding: var(--space-16);
gap: var(--space-16);

View File

@ -1,6 +1,6 @@
<script lang="ts">
import type { BaseBranch, Branch, Commit } from '$lib/vbranches/types';
import { createEventDispatcher, getContext, onMount } from 'svelte';
import { getContext, onMount } from 'svelte';
import { dropzone } from '$lib/utils/draggable';
import {
isDraggableHunk,

View File

@ -14,41 +14,44 @@
$: isLocked = file.hunks.some((h) => h.locked);
</script>
<button
class="file-list-item"
id={`file-${file.id}`}
<div
on:click
on:keydown
use:draggable={{
...draggableFile(branchId, file),
disabled: readonly
}}
role="button"
tabindex="0"
>
<div class="info">
<div class="icon">
<img
src={getVSIFileIcon(file.path)}
alt="js"
width="12"
style="width: 0.75rem"
class="mr-1 inline"
/>
<div class="file-list-item" id={`file-${file.id}`}>
<div class="info">
<div class="icon">
<img
src={getVSIFileIcon(file.path)}
alt="js"
width="12"
style="width: 0.75rem"
class="mr-1 inline"
/>
</div>
<div class="name">
{file.filename}
</div>
<div class="path">
{file.justpath}
</div>
</div>
<div class="name">
{file.filename}
</div>
<div class="path">
{file.justpath}
{#if isLocked}
<div class="locked">
<Icon name="locked" />
</div>
{/if}
<div class="status">
<FileStatus status={computeFileStatus(file)} />
</div>
</div>
{#if isLocked}
<div class="locked">
<Icon name="locked" />
</div>
{/if}
<div class="status">
<FileStatus status={computeFileStatus(file)} />
</div>
</button>
</div>
<style lang="postcss">
.file-list-item {

View File

@ -135,7 +135,7 @@ test('parses a balanced hunk section', () => {
expect(hunkSection.subSections.length).toBe(4);
const firstContext = hunkSection.subSections[0];
expect(firstContext.sectionType).toBe(SectionType.Context);
expect(firstContext.expanded).toBeFalsy();
expect(firstContext.expanded).toBeTruthy();
expect(firstContext.lines).toEqual([
{
beforeLineNumber: 3,
@ -175,7 +175,7 @@ test('parses a balanced hunk section', () => {
]);
const secondContext = hunkSection.subSections[3];
expect(secondContext.sectionType).toBe(SectionType.Context);
expect(secondContext.expanded).toBeFalsy();
expect(secondContext.expanded).toBeTruthy();
expect(secondContext.lines).toEqual([
{
beforeLineNumber: 7,
@ -227,7 +227,7 @@ test('parses hunk sections with more added', () => {
expect(hunkSection.subSections.length).toBe(4);
const firstContext = hunkSection.subSections[0];
expect(firstContext.sectionType).toBe(SectionType.Context);
expect(firstContext.expanded).toBeFalsy();
expect(firstContext.expanded).toBeTruthy();
expect(firstContext.lines).toEqual([
{
beforeLineNumber: 3,
@ -275,7 +275,7 @@ test('parses hunk sections with more added', () => {
const secondContext = hunkSection.subSections[3];
expect(secondContext.sectionType).toBe(SectionType.Context);
expect(secondContext.expanded).toBeFalsy();
expect(secondContext.expanded).toBeTruthy();
expect(secondContext.lines).toEqual([
{
beforeLineNumber: 7,
@ -314,7 +314,7 @@ test('parses a hunk with two changed places', () => {
const firstContext = hunkSection.subSections[0];
expect(firstContext.sectionType).toBe(SectionType.Context);
expect(firstContext.expanded).toBeFalsy();
expect(firstContext.expanded).toBeTruthy();
expect(firstContext.lines).toEqual([
{
beforeLineNumber: 1,
@ -344,7 +344,7 @@ test('parses a hunk with two changed places', () => {
]);
const secondContext = hunkSection.subSections[2];
expect(secondContext.sectionType).toBe(SectionType.Context);
expect(secondContext.expanded).toBeFalsy();
expect(secondContext.expanded).toBeTruthy();
expect(secondContext.lines).toEqual([
{
beforeLineNumber: 5,
@ -389,7 +389,7 @@ test('parses a hunk with two changed places', () => {
]);
const thirdContext = hunkSection.subSections[5];
expect(thirdContext.sectionType).toBe(SectionType.Context);
expect(thirdContext.expanded).toBeFalsy();
expect(thirdContext.expanded).toBeTruthy();
expect(thirdContext.lines).toEqual([
{
beforeLineNumber: 10,
@ -431,7 +431,7 @@ test('parses file with one hunk and balanced add-remove', () => {
expect(sections.length).toBe(3);
const beforeSection = sections[0] as ContentSection;
expect(beforeSection.sectionType).toBe(SectionType.Context);
expect(beforeSection.expanded).toBeFalsy();
expect(beforeSection.expanded).toBeTruthy();
expect(beforeSection.lines.length).toBe(2);
expect(beforeSection.lines[0]).toEqual({
beforeLineNumber: 1,
@ -449,7 +449,7 @@ test('parses file with one hunk and balanced add-remove', () => {
const afterSection = sections[2] as ContentSection;
expect(afterSection.sectionType).toBe(SectionType.Context);
expect(afterSection.expanded).toBeFalsy();
expect(afterSection.expanded).toBeTruthy();
expect(afterSection.lines.length).toBe(3);
expect(afterSection.lines[0]).toEqual({
beforeLineNumber: 10,

View File

@ -1,7 +1,6 @@
<script lang="ts">
import { accordion } from './accordion';
import Scrollbar from '$lib/components/Scrollbar.svelte';
import { slide } from 'svelte/transition';
import Modal from '$lib/components/Modal.svelte';
import Button from '$lib/components/Button.svelte';
import type { BranchController } from '$lib/vbranches/branchController';
@ -9,7 +8,6 @@
import type { VirtualBranchService } from '$lib/vbranches/branchStoresCache';
import type { UIEventHandler } from 'svelte/elements';
import SectionHeader from './SectionHeader.svelte';
import Icon from '$lib/icons/Icon.svelte';
import Resizer from '$lib/components/Resizer.svelte';
import { getContext } from 'svelte';
import { SETTINGS_CONTEXT, type SettingsStore } from '$lib/settings/userSettings';

View File

@ -17,6 +17,7 @@
$: user$ = data.user$;
$: githubContext$ = data.githubContext$;
$: cloud = data.cloud;
$: project$ = data.project$;
$: branchController = data.branchController;
$: vbranchService = data.vbranchService;
@ -72,6 +73,7 @@
readonly={true}
githubContext={$githubContext$}
user={$user$}
projectPath={$project$.path}
/>
{:else}
<p>Branch no longer exists</p>