-
-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/automatic builds project options #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
0955bd5
48979d6
478b7f7
b3fa28e
cdeea10
dbe5e4d
b0b6119
d415d88
373f1f4
1ea4e51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,46 @@ | ||
<script lang="ts"> | ||
import type { HTMLInputAttributes } from 'svelte/elements'; | ||
import type { HTMLInputAttributes, ChangeEventHandler } from 'svelte/elements'; | ||
import IconContainer from '../IconContainer.svelte'; | ||
import InputWithMessage from './InputWithMessage.svelte'; | ||
import type { ValueKey } from '$lib/locales.svelte'; | ||
interface Props { | ||
title?: ValueKey; | ||
message?: ValueKey; | ||
className?: string; | ||
formName?: string; | ||
name?: string; | ||
checked: boolean; | ||
canEdit?: boolean; | ||
inputAttr?: HTMLInputAttributes; | ||
onchange: ChangeEventHandler<HTMLInputElement>; | ||
onIcon?: string; | ||
offIcon?: string; | ||
} | ||
let { | ||
title, | ||
message, | ||
className = '', | ||
formName, | ||
name, | ||
checked = $bindable(), | ||
inputAttr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there may also be some cases where you do want to pass input attributes, so maybe don't delete this entirely |
||
canEdit = true, | ||
onchange, | ||
onIcon = '', | ||
offIcon = '' | ||
}: Props = $props(); | ||
let className = $derived(canEdit ? '' : 'cursor-not-allowed'); | ||
</script> | ||
|
||
<InputWithMessage {title} {message} {className}> | ||
<label class="group"> | ||
<div class="relative"> | ||
<input name={formName} type="checkbox" class="sr-only group" bind:checked {...inputAttr} /> | ||
<input | ||
{name} | ||
type="checkbox" | ||
class="sr-only group" | ||
bind:checked | ||
{onchange} | ||
disabled={!canEdit} | ||
/> | ||
<div | ||
class="block h-8 rounded-full bg-gray-3 dark:bg-dark-2 w-14 toggle group-has-checked:border-accent" | ||
></div> | ||
|
@@ -34,15 +49,11 @@ | |
> | ||
<span class="hidden group-has-checked:block"> | ||
<!-- Switch on -> public --> | ||
<IconContainer | ||
icon="mdi:lock-open-variant" | ||
class="-translate-y-px text-white" | ||
width="15" | ||
/> | ||
<IconContainer icon={onIcon} class="-translate-y-px text-white" width="15" /> | ||
</span> | ||
<span class="text-body-color dark:text-light group-has-checked:hidden"> | ||
<!-- Switch off -> private --> | ||
<IconContainer icon="mdi:lock" class="-translate-y-px text-black" width="15" /> | ||
<IconContainer icon={offIcon} class="-translate-y-px text-black" width="15" /> | ||
</span> | ||
</div> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!-- | ||
@component | ||
An abstraction over Toggle which makes it easier to submit simple POSTs using a toggle. | ||
--> | ||
<script lang="ts"> | ||
import { enhance } from '$app/forms'; | ||
import Toggle from '$lib/components/settings/Toggle.svelte'; | ||
import { m } from '$lib/paraglide/messages'; | ||
import { toast } from '$lib/utils'; | ||
import type { ValueKey } from '$lib/locales.svelte'; | ||
type Method = 'POST' | 'GET'; | ||
interface Props { | ||
name: string; | ||
method: Method; | ||
action: string; | ||
formVar: boolean; | ||
onmsg: string; | ||
offmsg: string; | ||
onIcon?: string; | ||
offIcon?: string; | ||
title: ValueKey; | ||
message: ValueKey; | ||
} | ||
let { name, method, action, formVar, onmsg, offmsg, title, message, onIcon, offIcon }: Props = | ||
$props(); | ||
let form: HTMLFormElement; | ||
</script> | ||
|
||
<form | ||
bind:this={form} | ||
{method} | ||
{action} | ||
use:enhance={() => | ||
({ update, result }) => { | ||
if (result.type === 'success') { | ||
const res = result.data as ActionData; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (res?.ok) { | ||
if (formVar) { | ||
toast('success', onmsg); | ||
} else { | ||
toast('success', offmsg); | ||
} | ||
} else { | ||
toast('error', m.errors_generic({ errorMessage: '' })); | ||
formVar = !formVar; | ||
} | ||
} | ||
update({ reset: false }); | ||
}} | ||
> | ||
<Toggle | ||
{title} | ||
{message} | ||
{name} | ||
bind:checked={formVar} | ||
onchange={() => { | ||
form.requestSubmit(); | ||
}} | ||
{onIcon} | ||
{offIcon} | ||
/> | ||
</form> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `AutomaticBuilds` on the `Projects` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "public"."Projects" DROP COLUMN "AutomaticBuilds", | ||
ADD COLUMN "AutoPublishOnRebuild" BOOLEAN DEFAULT false, | ||
ADD COLUMN "RebuildOnSoftwareUpdate" BOOLEAN DEFAULT false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
className
prop is still used in pretty much every location where this component is used. You will need to fix that.