mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
feat: add dev mode override for manual upgrade runs
This commit is contained in:
@@ -102,7 +102,7 @@ export const actions: Actions = {
|
||||
}
|
||||
},
|
||||
|
||||
run: async ({ params }) => {
|
||||
run: async ({ params, request }) => {
|
||||
const id = parseInt(params.id || '', 10);
|
||||
|
||||
if (isNaN(id)) {
|
||||
@@ -133,8 +133,13 @@ export const actions: Actions = {
|
||||
return fail(400, { error: `Upgrade not yet supported for ${instance.type}` });
|
||||
}
|
||||
|
||||
// Only allow manual runs in dry run mode
|
||||
if (!config.dryRun) {
|
||||
// Check for dev mode override
|
||||
const formData = await request.formData();
|
||||
const devOverride = formData.get('devOverride') === 'true';
|
||||
const isDev = import.meta.env.DEV;
|
||||
|
||||
// Only allow manual runs in dry run mode (or dev mode with override)
|
||||
if (!config.dryRun && !(isDev && devOverride)) {
|
||||
return fail(400, {
|
||||
error: 'Manual runs only allowed in Dry Run mode. Enable Dry Run first.'
|
||||
});
|
||||
@@ -143,7 +148,7 @@ export const actions: Actions = {
|
||||
try {
|
||||
await logger.debug(`Manual upgrade run triggered for "${instance.name}"`, {
|
||||
source: 'upgrades',
|
||||
meta: { instanceId: id, dryRun: config.dryRun }
|
||||
meta: { instanceId: id, dryRun: config.dryRun, devOverride }
|
||||
});
|
||||
|
||||
const result = await processUpgradeConfig(config, instance, true);
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
// Track if config exists
|
||||
$: isNewConfig = !data.config;
|
||||
|
||||
// Dev mode check
|
||||
const isDev = import.meta.env.DEV;
|
||||
|
||||
let showInfoModal = false;
|
||||
let saving = false;
|
||||
let running = false;
|
||||
@@ -108,6 +111,19 @@
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{:else if !isNewConfig && isDev}
|
||||
<Button
|
||||
text={running ? 'Running...' : 'Dev Run'}
|
||||
icon={Play}
|
||||
iconColor="text-red-600 dark:text-red-400"
|
||||
disabled={running || saving || $isDirty}
|
||||
on:click={() => {
|
||||
const runForm = document.getElementById('dev-run-form');
|
||||
if (runForm instanceof HTMLFormElement) {
|
||||
runForm.requestSubmit();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
<Button
|
||||
text={saving ? 'Saving...' : 'Save'}
|
||||
@@ -216,6 +232,22 @@
|
||||
};
|
||||
}}
|
||||
></form>
|
||||
{:else if !isNewConfig && isDev}
|
||||
<form
|
||||
id="dev-run-form"
|
||||
method="POST"
|
||||
action="?/run"
|
||||
class="hidden"
|
||||
use:enhance={() => {
|
||||
running = true;
|
||||
return async ({ update }) => {
|
||||
await update({ reset: false });
|
||||
running = false;
|
||||
};
|
||||
}}
|
||||
>
|
||||
<input type="hidden" name="devOverride" value="true" />
|
||||
</form>
|
||||
{/if}
|
||||
|
||||
<UpgradesInfoModal bind:open={showInfoModal} />
|
||||
|
||||
Reference in New Issue
Block a user