Skip to content

Commit

Permalink
Merge pull request #1237 from rainlanguage/2024-02-05-registry-url
Browse files Browse the repository at this point in the history
loading registry url from url params
  • Loading branch information
hardyjosh authored Feb 5, 2025
2 parents cc0ff8b + e255022 commit 192af45
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
11 changes: 11 additions & 0 deletions packages/webapp/src/routes/deploy/+layout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { registryUrl } from '$lib/stores/registry';
import type { LayoutLoad } from './$types';

export const load: LayoutLoad = async ({ url }) => {
// get the registry url from the url params
const registry = url.searchParams.get('registry');
if (registry) {
registryUrl.set(registry);
}
return { registry };
};
26 changes: 16 additions & 10 deletions packages/webapp/src/routes/deploy/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@
loading = false;
};
const loadStrategy = () => {
const loadRawStrategy = () => {
if (inputDotrain.trim()) {
files = [];
$rawDotrain = inputDotrain;
inputDotrain = '';
}
};
const loadRegistryUrl = () => {
fetchFilesFromRegistry($registryUrl);
// add the registry url to the url params
window.history.pushState({}, '', window.location.pathname + '?registry=' + $registryUrl);
};
</script>

<div class="flex w-full flex-col">
Expand All @@ -48,9 +54,7 @@
placeholder="Enter URL to raw strategy registry file"
bind:value={$registryUrl}
/>
<Button class="text-nowrap" on:click={() => fetchFilesFromRegistry($registryUrl)}>
Load URL
</Button>
<Button class="text-nowrap" on:click={loadRegistryUrl}>Load Registry URL</Button>
</div>
<div class="flex w-full items-start gap-4">
<Textarea
Expand All @@ -59,7 +63,7 @@
rows="8"
bind:value={inputDotrain}
/>
<Button class="text-nowrap" on:click={loadStrategy}>Load Strategy</Button>
<Button class="text-nowrap" on:click={loadRawStrategy}>Load Raw Strategy</Button>
</div>
</div>
{/if}
Expand All @@ -75,11 +79,13 @@
<p>{errorDetails}</p>
{/if}
{#if files.length > 0}
<div class="mb-36 flex flex-col gap-8">
{#each files as { name, url }}
<StrategySection strategyUrl={url} strategyName={name} />
{/each}
</div>
{#key files}
<div class="mb-36 flex flex-col gap-8">
{#each files as { name, url }}
<StrategySection strategyUrl={url} strategyName={name} />
{/each}
</div>
{/key}
{:else if $rawDotrain}
<StrategySection rawDotrain={$rawDotrain} strategyName={'raw'} />
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { DotrainOrderGui } from '@rainlanguage/orderbook/js_api';
import { get } from 'svelte/store';
import type { PageLoad } from './$types';

export const load: PageLoad = async ({ fetch, params }) => {
export const load: PageLoad = async ({ fetch, params, parent }) => {
const { strategyName, deploymentKey } = params;
const { registry } = await parent();
if (registry) {
registryUrl.set(registry);
}
try {
const { strategyName, deploymentKey } = params;

let dotrain;
if (strategyName === 'raw' && get(rawDotrain)) {
dotrain = get(rawDotrain);
Expand Down

0 comments on commit 192af45

Please sign in to comment.