Rename branch property readonly -> isUnapplied

This commit is contained in:
Mattias Granlund 2024-01-29 14:19:08 +01:00
parent ecede7f6a6
commit 34ceebfcb9
16 changed files with 66 additions and 57 deletions

View File

@ -31,7 +31,7 @@
import type { BaseBranch, Branch, File } from '$lib/vbranches/types';
export let branch: Branch;
export let readonly = false;
export let isUnapplied = false;
export let project: Project;
export let base: BaseBranch | undefined | null;
export let cloud: ReturnType<typeof getCloudApiClient>;
@ -136,7 +136,7 @@
class="branch-card__contents"
>
<BranchHeader
{readonly}
{isUnapplied}
{branchController}
{branch}
{base}
@ -159,14 +159,14 @@
active: 'cherrypick-dz-active',
accepts: acceptCherrypick,
onDrop: onCherrypicked,
disabled: readonly
disabled: isUnapplied
}}
use:dropzone={{
hover: 'lane-dz-hover',
active: 'lane-dz-active',
accepts: acceptBranchDrop,
onDrop: onBranchDrop,
disabled: readonly
disabled: isUnapplied
}}
>
<DropzoneOverlay class="cherrypick-dz-marker" label="Apply here" />
@ -175,7 +175,7 @@
<div class="card">
<BranchFiles
{branch}
{readonly}
{isUnapplied}
{selectedOwnership}
{selectedFiles}
showCheckboxes={$commitBoxOpen}
@ -244,7 +244,7 @@
{branchController}
{branchService}
{branchCount}
{readonly}
{isUnapplied}
/>
</div>
</div>

View File

@ -12,7 +12,7 @@
export let githubService: GitHubService;
export let branchController: BranchController;
export let branchService: BranchService;
export let readonly: boolean;
export let isUnapplied: boolean;
export let branchCount: number;
</script>
@ -25,7 +25,7 @@
{branchService}
{branchCount}
{githubService}
{readonly}
{isUnapplied}
type="upstream"
/>
<CommitList
@ -35,7 +35,7 @@
{branchController}
{branchService}
{githubService}
{readonly}
{isUnapplied}
type="local"
/>
<CommitList
@ -45,7 +45,7 @@
{branchController}
{branchService}
{githubService}
{readonly}
{isUnapplied}
type="remote"
/>
<CommitList
@ -55,7 +55,7 @@
{branchController}
{branchService}
{githubService}
{readonly}
{isUnapplied}
type="integrated"
/>
{/if}

View File

@ -11,7 +11,7 @@
import type { Writable } from 'svelte/store';
export let branch: Branch;
export let readonly: boolean;
export let isUnapplied: boolean;
export let selectedOwnership: Writable<Ownership>;
export let selectedFiles: Writable<File[]>;
export let showCheckboxes = false;
@ -63,7 +63,7 @@
</div>
{/if}
<div class="branch-files" class:readonly>
<div class="branch-files" class:isUnapplied>
<div class="header" bind:this={headerElement}>
<div class="header__left">
{#if showCheckboxes && selectedListMode == 'list' && branch.files.length > 1}
@ -94,7 +94,13 @@
<div class="scroll-container">
<!-- TODO: This is an experiment in file sorting. Accept or reject! -->
{#if selectedListMode == 'list'}
<BranchFilesList {branch} {selectedOwnership} {selectedFiles} {showCheckboxes} {readonly} />
<BranchFilesList
{branch}
{selectedOwnership}
{selectedFiles}
{showCheckboxes}
{isUnapplied}
/>
{:else}
<FileTree
node={filesToFileTree(branch.files)}
@ -103,7 +109,7 @@
isRoot={true}
{selectedOwnership}
{selectedFiles}
{readonly}
{isUnapplied}
/>
{/if}
</div>
@ -115,7 +121,7 @@
flex: 1;
background: var(--clr-theme-container-light);
border-radius: var(--radius-m) var(--radius-m) 0 0;
&.readonly {
&.isUnapplied {
border-radius: var(--radius-m);
}
}

View File

@ -7,7 +7,7 @@
export let branch: Branch;
export let selectedOwnership: Writable<Ownership>;
export let readonly = false;
export let isUnapplied = false;
export let showCheckboxes = false;
export let selectedFiles: Writable<File[]>;
</script>
@ -15,7 +15,7 @@
{#each sortLikeFileTree(branch.files) as file (file.id)}
<FileListItem
{file}
{readonly}
{isUnapplied}
branchId={branch.id}
{selectedOwnership}
showCheckbox={showCheckboxes}

View File

@ -14,7 +14,7 @@
import type { BaseBranch, Branch } from '$lib/vbranches/types';
import { goto } from '$app/navigation';
export let readonly = false;
export let isUnapplied = false;
export let branch: Branch;
export let base: BaseBranch | undefined | null;
export let branchController: BranchController;
@ -41,13 +41,13 @@
</script>
<div class="header__wrapper">
<div class="header card" bind:this={container} class:readonly>
<div class="header card" bind:this={container} class:isUnapplied>
<div class="header__info">
<div class="header__label">
<BranchLabel
bind:name={branch.name}
on:change={handleBranchNameChange}
disabled={readonly}
disabled={isUnapplied}
/>
</div>
<div class="header__remote-branch">
@ -74,7 +74,7 @@
<Icon name="virtual-branch-small" /> virtual
</div>
{/if}
{#if !readonly}
{#if !isUnapplied}
<div
class="pending-name"
use:tooltip={'Branch name that will be used when pushing. You can change it from the lane menu.'}
@ -144,8 +144,11 @@
<div class="header__actions">
<div class="header__buttons">
{#if branch.selectedForChanges}
<Button help="New changes will land here" icon="target" notClickable disabled={readonly}
>Default branch</Button
<Button
help="New changes will land here"
icon="target"
notClickable
disabled={isUnapplied}>Default branch</Button
>
{:else}
<Button
@ -153,7 +156,7 @@
icon="target"
kind="outlined"
color="neutral"
disabled={readonly}
disabled={isUnapplied}
on:click={async () => {
await branchController.setSelectedForChanges(branch.id);
}}
@ -163,7 +166,7 @@
{/if}
</div>
<div class="relative" bind:this={meatballButton}>
{#if readonly}
{#if isUnapplied}
<Button
help="Restores these changes into your working directory"
icon="plus-small"
@ -204,7 +207,7 @@
{branchController}
{branch}
{projectId}
{readonly}
{isUnapplied}
bind:visible
on:action
/>
@ -233,7 +236,7 @@
opacity: 1;
}
}
&.readonly {
&.isUnapplied {
background: var(--clr-theme-container-pale);
}
}
@ -263,7 +266,7 @@
border-radius: 0 0 var(--radius-m) var(--radius-m);
user-select: none;
}
.readonly .header__actions {
.isUnapplied .header__actions {
background: var(--clr-theme-container-dim);
}
.header__buttons {

View File

@ -11,7 +11,7 @@
import type { BaseBranch, Branch, File } from '$lib/vbranches/types';
export let branch: Branch;
export let readonly = false;
export let isUnapplied = false;
export let project: Project;
export let base: BaseBranch | undefined | null;
export let cloud: ReturnType<typeof getCloudApiClient>;
@ -45,7 +45,7 @@
>
<BranchCard
{branch}
{readonly}
{isUnapplied}
{project}
{base}
{cloud}
@ -68,8 +68,8 @@
{projectPath}
{branchController}
{selectedOwnership}
{readonly}
selectable={$commitBoxOpen && !readonly}
{isUnapplied}
selectable={$commitBoxOpen && !isUnapplied}
on:close={() => {
const selectedId = selected?.id;
selectedFiles.update((fileIds) => fileIds.filter((file) => file.id != selectedId));

View File

@ -14,7 +14,7 @@
export let branch: Branch;
export let projectId: string;
export let visible: boolean;
export let readonly = false;
export let isUnapplied = false;
let deleteBranchModal: Modal;
let renameRemoteModal: Modal;
@ -34,7 +34,7 @@
{#if visible}
<ContextMenu>
<ContextMenuSection>
{#if !readonly}
{#if !isUnapplied}
<ContextMenuItem
label="Unapply"
on:click={() => {
@ -58,13 +58,13 @@
dispatch('action', 'generate-branch-name');
visible = false;
}}
disabled={readonly || !$aiGenEnabled || branch.files?.length == 0 || !branch.active}
disabled={isUnapplied || !$aiGenEnabled || branch.files?.length == 0 || !branch.active}
/>
</ContextMenuSection>
<ContextMenuSection>
<ContextMenuItem
label="Set branch name"
disabled={readonly || hasIntegratedCommits}
disabled={isUnapplied || hasIntegratedCommits}
on:click={() => {
newRemoteName = branch.upstreamName || '';
visible = false;

View File

@ -19,7 +19,7 @@
export let commitUrl: string | undefined = undefined;
export let isHeadCommit: boolean = false;
export let resetHeadCommit: () => void | undefined = () => undefined;
export let readonly = false;
export let isUnapplied = false;
let previewCommitModal: Modal;
let minWidth = 2;
@ -60,7 +60,7 @@
<span class="commit__description text-base-12 truncate">
{commit.description}
</span>
{#if isHeadCommit && !readonly}
{#if isHeadCommit && !isUnapplied}
<Tag
color="ghost"
icon="undo-small"

View File

@ -15,7 +15,7 @@
export let type: CommitStatus;
export let githubService: GitHubService;
export let branchService: BranchService;
export let readonly: boolean;
export let isUnapplied: boolean;
export let branchCount: number = 0;
let headerHeight: number;
@ -46,7 +46,7 @@
{commit}
{base}
{project}
{readonly}
{isUnapplied}
isChained={idx != commits.length - 1}
isHeadCommit={commit.id === headCommit?.id}
/>
@ -65,7 +65,7 @@
{githubService}
{type}
{base}
{readonly}
{isUnapplied}
projectId={project.id}
/>
</div>

View File

@ -11,7 +11,7 @@
export let branch: Branch;
export let type: CommitStatus;
export let readonly: boolean;
export let isUnapplied: boolean;
export let branchController: BranchController;
export let branchService: BranchService;
export let githubService: GitHubService;
@ -62,7 +62,7 @@
}
</script>
{#if !readonly && type != 'integrated'}
{#if !isUnapplied && type != 'integrated'}
<div class="actions">
{#if $githubEnabled$ && !$pr$ && type == 'local' && !branch.upstream}
<PushButton

View File

@ -22,7 +22,7 @@
export let base: BaseBranch | undefined | null;
export let isHeadCommit: boolean;
export let isChained: boolean;
export let readonly = false;
export let isUnapplied = false;
export let branchController: BranchController;
function acceptAmend(commit: Commit | RemoteCommit) {
@ -137,7 +137,7 @@
commitUrl={base?.commitUrl(commit.id)}
{isHeadCommit}
{resetHeadCommit}
{readonly}
{isUnapplied}
/>
</div>
<!-- <div class="reset-head">

View File

@ -26,7 +26,7 @@
export let conflicted: boolean;
export let projectPath: string | undefined;
export let branchController: BranchController;
export let readonly: boolean;
export let isUnapplied: boolean;
export let selectable = false;
export let selectedOwnership: Writable<Ownership>;
@ -151,7 +151,7 @@
role="cell"
use:draggable={{
...draggableHunk(branchId, section.hunk),
disabled: readonly || section.hunk.locked
disabled: isUnapplied || section.hunk.locked
}}
on:dblclick
class="hunk"

View File

@ -10,7 +10,7 @@
export let branchId: string;
export let file: File;
export let readonly: boolean;
export let isUnapplied: boolean;
export let selected: boolean;
export let showCheckbox: boolean = false;
export let selectedOwnership: Writable<Ownership>;
@ -40,7 +40,7 @@
}}
use:draggable={{
...draggableFile(branchId, file, selectedFiles),
disabled: readonly,
disabled: isUnapplied,
selector: '.selected-draggable'
}}
role="button"

View File

@ -17,7 +17,7 @@
export let selectedOwnership: Writable<Ownership>;
export let selectedFiles: Writable<File[]>;
export let branchId: string;
export let readonly: boolean;
export let isUnapplied: boolean;
function isNodeChecked(selectedOwnership: Ownership, node: TreeNode): boolean {
if (node.file) {
@ -72,7 +72,7 @@
{showCheckboxes}
{selectedFiles}
{branchId}
{readonly}
{isUnapplied}
on:checked
on:unchecked
/>
@ -85,7 +85,7 @@
<TreeListFile
file={node.file}
{branchId}
{readonly}
{isUnapplied}
selected={$selectedFiles.includes(file)}
{selectedOwnership}
{selectedFiles}
@ -130,7 +130,7 @@
{showCheckboxes}
{selectedFiles}
{branchId}
{readonly}
{isUnapplied}
on:checked
on:unchecked
/>

View File

@ -11,7 +11,7 @@
export let branchId: string;
export let file: File;
export let selected: boolean;
export let readonly: boolean;
export let isUnapplied: boolean;
export let showCheckbox: boolean = false;
export let selectedOwnership: Writable<Ownership>;
export let selectedFiles: Writable<File[]>;
@ -41,7 +41,7 @@
}}
use:draggable={{
...draggableFile(branchId, file, selectedFiles),
disabled: readonly,
disabled: isUnapplied,
selector: '.selected'
}}
on:click

View File

@ -40,7 +40,7 @@
base={$baseBranch$}
{cloud}
project={$project$}
readonly={!branch.active}
isUnapplied={!branch.active}
user={$user$}
projectPath={$project$.path}
{githubService}