ui for ok with force pushing

This commit is contained in:
Nikita Galaiko 2023-12-11 11:17:20 +01:00 committed by GitButler
parent 0840e69db8
commit a1e4e651cc
3 changed files with 44 additions and 0 deletions

View File

@ -24,6 +24,7 @@ export type Project = {
path: string; path: string;
api?: CloudProject & { sync: boolean }; api?: CloudProject & { sync: boolean };
preferred_key: Key; preferred_key: Key;
ok_with_force_push: boolean;
}; };
export class ProjectService { export class ProjectService {
@ -59,6 +60,7 @@ export class ProjectService {
title?: string; title?: string;
api?: CloudProject & { sync: boolean }; api?: CloudProject & { sync: boolean };
preferred_key?: Key; preferred_key?: Key;
okWithForcePush?: boolean;
}) { }) {
await invoke<Project>('update_project', { project: params }); await invoke<Project>('update_project', { project: params });
this.reload(); this.reload();

View File

@ -4,6 +4,7 @@
import CloudForm from './CloudForm.svelte'; import CloudForm from './CloudForm.svelte';
import DetailsForm from './DetailsForm.svelte'; import DetailsForm from './DetailsForm.svelte';
import KeysForm from './KeysForm.svelte'; import KeysForm from './KeysForm.svelte';
import PreferencesForm from './PreferencesForm.svelte';
import type { PageData } from './$types'; import type { PageData } from './$types';
import Modal from '$lib/components/Modal.svelte'; import Modal from '$lib/components/Modal.svelte';
import Button from '$lib/components/Button.svelte'; import Button from '$lib/components/Button.svelte';
@ -39,6 +40,8 @@
projectService.updateProject({ ...$project$, ...e.detail }); projectService.updateProject({ ...$project$, ...e.detail });
const onCloudUpdated = (e: { detail: Project }) => const onCloudUpdated = (e: { detail: Project }) =>
projectService.updateProject({ ...$project$, ...e.detail }); projectService.updateProject({ ...$project$, ...e.detail });
const onPreferencesUpdated = (e: { detail: { ok_with_force_push: boolean } }) =>
projectService.updateProject({ ...$project$, ...e.detail });
const onDetailsUpdated = async (e: { detail: Project }) => { const onDetailsUpdated = async (e: { detail: Project }) => {
const api = const api =
$user$ && e.detail.api $user$ && e.detail.api
@ -71,6 +74,8 @@
<Spacer /> <Spacer />
<KeysForm project={$project$} on:updated={onKeysUpdated} /> <KeysForm project={$project$} on:updated={onKeysUpdated} />
<Spacer /> <Spacer />
<PreferencesForm project={$project$} on:updated={onPreferencesUpdated} />
<Spacer />
<div class="flex gap-x-4"> <div class="flex gap-x-4">
<a <a

View File

@ -0,0 +1,37 @@
<script lang="ts">
import type { Project } from '$lib/backend/projects';
import Checkbox from '$lib/components/Checkbox.svelte';
import { createEventDispatcher } from 'svelte';
export let project: Project;
let allowForcePushing = project?.ok_with_force_push;
const dispatch = createEventDispatcher<{
updated: {
ok_with_force_push: boolean;
};
}>();
</script>
<div
class="flex flex-row items-center justify-between rounded-lg border border-light-400 p-2 dark:border-dark-500"
>
<div class="flex flex-row space-x-3">
<div class="flex flex-row">
<form class="flex items-center gap-1">
<Checkbox
name="allow-force-pushing"
checked={allowForcePushing}
on:change={() => {
allowForcePushing = !allowForcePushing;
dispatch('updated', { ok_with_force_push: allowForcePushing });
}}
/>
<label class="ml-2" for="allow-force-pushing">
Rebase my branches instead of creating merge commmits
</label>
</form>
</div>
</div>
</div>