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);
|
const id = parseInt(params.id || '', 10);
|
||||||
|
|
||||||
if (isNaN(id)) {
|
if (isNaN(id)) {
|
||||||
@@ -133,8 +133,13 @@ export const actions: Actions = {
|
|||||||
return fail(400, { error: `Upgrade not yet supported for ${instance.type}` });
|
return fail(400, { error: `Upgrade not yet supported for ${instance.type}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only allow manual runs in dry run mode
|
// Check for dev mode override
|
||||||
if (!config.dryRun) {
|
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, {
|
return fail(400, {
|
||||||
error: 'Manual runs only allowed in Dry Run mode. Enable Dry Run first.'
|
error: 'Manual runs only allowed in Dry Run mode. Enable Dry Run first.'
|
||||||
});
|
});
|
||||||
@@ -143,7 +148,7 @@ export const actions: Actions = {
|
|||||||
try {
|
try {
|
||||||
await logger.debug(`Manual upgrade run triggered for "${instance.name}"`, {
|
await logger.debug(`Manual upgrade run triggered for "${instance.name}"`, {
|
||||||
source: 'upgrades',
|
source: 'upgrades',
|
||||||
meta: { instanceId: id, dryRun: config.dryRun }
|
meta: { instanceId: id, dryRun: config.dryRun, devOverride }
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await processUpgradeConfig(config, instance, true);
|
const result = await processUpgradeConfig(config, instance, true);
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
// Track if config exists
|
// Track if config exists
|
||||||
$: isNewConfig = !data.config;
|
$: isNewConfig = !data.config;
|
||||||
|
|
||||||
|
// Dev mode check
|
||||||
|
const isDev = import.meta.env.DEV;
|
||||||
|
|
||||||
let showInfoModal = false;
|
let showInfoModal = false;
|
||||||
let saving = false;
|
let saving = false;
|
||||||
let running = 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}
|
{/if}
|
||||||
<Button
|
<Button
|
||||||
text={saving ? 'Saving...' : 'Save'}
|
text={saving ? 'Saving...' : 'Save'}
|
||||||
@@ -216,6 +232,22 @@
|
|||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
></form>
|
></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}
|
{/if}
|
||||||
|
|
||||||
<UpgradesInfoModal bind:open={showInfoModal} />
|
<UpgradesInfoModal bind:open={showInfoModal} />
|
||||||
|
|||||||
Reference in New Issue
Block a user