Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inputAttr prop is used in one location: /organizations/[id]/settings/products. It is only used to pass an onchange handler, so you should be able to just change that usage to that instead, then remove the inputAttr prop from the Props interface so it isn't allowed to be used.

Copy link
Contributor

Choose a reason for hiding this comment

The 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>
Expand All @@ -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>
Expand Down
65 changes: 65 additions & 0 deletions src/lib/components/settings/ToggleForm.svelte
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActionData needs to be imported from somewhere. Honestly I'd just change it from ActionData to { ok: boolean}.

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>
55 changes: 19 additions & 36 deletions src/lib/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@
"localePicker_placeholder": "Search by Language...",
"localePicker_region": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Region",
"countPlural=other": "Regions"
Expand All @@ -37,13 +32,8 @@
],
"localePicker_name": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Name",
"countPlural=other": "Names"
Expand All @@ -52,13 +42,8 @@
],
"localePicker_tag": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Tag",
"countPlural=other": "Tags"
Expand All @@ -67,13 +52,8 @@
],
"localePicker_variant": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Variant",
"countPlural=other": "Variants"
Expand Down Expand Up @@ -264,12 +244,8 @@
"products_unpublished": "Unpublished",
"products_numArtifacts": [
{
"declarations": [
"local countPlural = amount: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["local countPlural = amount: plural"],
"selectors": ["countPlural"],
"match": {
"amount=0": "No Product Files",
"countPlural=one": "{amount} Product File",
Expand Down Expand Up @@ -389,8 +365,12 @@
"project_details_language": "Language",
"project_details_type": "Project Type",
"project_settings_title": "Settings",
"project_autoRebuild_title": "Automatic Rebuilds",
"project_autoPublish_title": "Auto Publish on Rebuild",
"project_autoPublish_description": "When the rebuild workflow is run, skip verification and publish the app. Send a notification to owner and reviewers that the app was published without review.",
"project_autoRebuild_title": "Automatic Rebuild",
"project_autoRebuild_description": "When automatic rebuilds are on, Scriptoria will automatically rebuild your products when the input source is updated",
"project_autoRebuild_on_update_title": "Rebuild on Software Update",
"project_autoRebuild_on_update_description": "When the App Builder software used by Scriptoria is updated, rebuild the products of the project that have completed the initial workflow and are not currently being rebuilt.",
"project_orgDownloads_title": "Allow Other Organizations to download",
"project_orgDownloads_description": "When this setting is on, any Scriptoria User that is able to view your project in the Directory will be able to download the Product Files (the outputs of the products).",
"project_visibility_title": "Public Visibility",
Expand Down Expand Up @@ -418,6 +398,9 @@
"project_acts_downloads_on": "Allow project download is ON",
"project_acts_downloads_off": "Allow project download is OFF",
"project_acts_downloads_error": "Error: We could not change Allow Download status",
"project_acts_autoPublish_on": "Auto Publish is ON",
"project_acts_autoPublish_off": "Auto Publish is OFF",
"project_acts_autoPublish_error": "Error: We could not change Auto Publish status",
"project_acts_isPublic_on": "Project visibility is set to Public",
"project_acts_isPublic_off": "Project visibility is set to Private",
"project_acts_isPublic_error": "Error: We could not change Project visibility",
Expand Down Expand Up @@ -572,4 +555,4 @@
"system_publishFailed": "Publish failed",
"system_unavailable": "Scriptoria is currently unable to process background tasks",
"downloads_title": "Downloads"
}
}
55 changes: 19 additions & 36 deletions src/lib/locales/es-419.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@
"localePicker_placeholder": "Buscar por idioma...",
"localePicker_region": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Region",
"countPlural=other": "Region"
Expand All @@ -37,13 +32,8 @@
],
"localePicker_name": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Name",
"countPlural=other": "Names"
Expand All @@ -52,13 +42,8 @@
],
"localePicker_tag": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Tag",
"countPlural=other": "Tags"
Expand All @@ -67,13 +52,8 @@
],
"localePicker_variant": [
{
"declarations": [
"input count",
"local countPlural = count: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["input count", "local countPlural = count: plural"],
"selectors": ["countPlural"],
"match": {
"countPlural=one": "Variant",
"countPlural=other": "Variants"
Expand Down Expand Up @@ -264,12 +244,8 @@
"products_unpublished": "Sin publicar",
"products_numArtifacts": [
{
"declarations": [
"local countPlural = amount: plural"
],
"selectors": [
"countPlural"
],
"declarations": ["local countPlural = amount: plural"],
"selectors": ["countPlural"],
"match": {
"amount=0": "No hay archivos de producto",
"countPlural=one": "{amount} Product File",
Expand Down Expand Up @@ -389,8 +365,12 @@
"project_details_language": "Lenguaje",
"project_details_type": "Tipo de proyecto",
"project_settings_title": "Configuración",
"project_autoRebuild_title": "Recompilaciones automáticas",
"project_autoPublish_title": "Publicación Automática al Reconstruir",
"project_autoPublish_description": "Cuando se ejecuta la compilación, omite la verificación y publica la aplicación. Notificar al propietaro y a los revisores que la aplicación se publicó sin revisión.",
"project_autoRebuild_title": "Recompilaciones Automáticas",
"project_autoRebuild_description": "Cuando las recompilaciones automáticas están activadas, Scriptoria reconstruirá sus productos automáticamente cuando el código fuente se actualice",
"project_autoRebuild_on_update_title": "Recompilar cuando se Actualiza el Software",
"project_autoRebuild_on_update_description": "Cuando el App Builder se actualice, vuelva a compilar los productos del proyecto que se han completado el flujo de trabajo inicial y que no se están reconstruyendo.",
"project_orgDownloads_title": "Permitir descargar a otras organizaciones",
"project_orgDownloads_description": "Cuando esta configuración está activada, cualquier usuario de Scriptoria que pueda ver su proyecto en el Directorio podrá descargar los archivos del producto (los resultados de los productos).",
"project_visibility_title": "Visibilidad pública",
Expand All @@ -415,6 +395,9 @@
"project_acts_autoBuilds_on": "Compilaciones automáticas está activada",
"project_acts_autoBuilds_off": "Compilaciones automáticas está desactivada",
"project_acts_autoBuilds_error": "Error: No pudimos cambiar el estado de \"compilación automática\"",
"project_acts_autoPublish_on": "Publicaciones automáticas esta activada",
"project_acts_autoPublish_off": "Publicaciones automáticas está desactivada",
"project_acts_autoPublish_error": "Error: No pudimos cambiar el estado de \"publicaciones automáticas\"",
"project_acts_downloads_on": "Permitir descarga de proyecto está activada",
"project_acts_downloads_off": "Permitir descarga de proyecto está desactivada",
"project_acts_downloads_error": "Error: No pudimos cambiar el estado de \"permitir descargas\"",
Expand Down Expand Up @@ -572,4 +555,4 @@
"system_publishFailed": "Publish failed",
"system_unavailable": "Scriptoria actualmente no puede procesar tareas",
"downloads_title": "Downloads"
}
}
7 changes: 7 additions & 0 deletions src/lib/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@
"project_details_language": "Language",
"project_details_type": "Project Type",
"project_settings_title": "Settings",
"project_autoPublish_title": "Auto Publish on Rebuild",
"project_autoPublish_description": "When the rebuild workflow is run, skip verification and publish the app. Send a notification to owner and reviewers that the app was published without review.",
"project_autoRebuild_title": "Automatic Rebuilds",
"project_autoRebuild_on_update_title": "Rebuild on Software Update",
"project_autoRebuild_on_update_description": "When the App Builder software used by Scriptoria is updated, rebuild the products of the project that have completed the initial workflow and are not currently being rebuilt.",
"project_autoRebuild_description": "When automatic rebuilds are on, Scriptoria will automatically rebuild your products when the input source is updated",
"project_orgDownloads_title": "Allow Other Organizations to download",
"project_orgDownloads_description": "When this setting is on, any Scriptoria User that is able to view your project in the Directory will be able to download the Product Files (the outputs of the products).",
Expand All @@ -390,6 +394,9 @@
"project_acts_autoBuilds_on": "Automatic builds is ON",
"project_acts_autoBuilds_off": "Automatic builds is OFF",
"project_acts_autoBuilds_error": "Error: We could not change automatic build status",
"project_acts_autoPublish_on": "Auto Publish is ON",
"project_acts_autoPublish_off": "Auto Publish is OFF",
"project_acts_autoPublish_error": "Error: We could not change Auto Publish status",
"project_acts_downloads_on": "Allow project download is ON",
"project_acts_downloads_off": "Allow project download is OFF",
"project_acts_downloads_error": "Error: We could not change Allow Download status",
Expand Down
10 changes: 10 additions & 0 deletions src/lib/prisma/migrations/12_auto_rebuilds/migration.sql
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;
Loading
Loading