Skip to content
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

fix: possible to submit claim flow with more than 200 splits #585

Merged
merged 1 commit into from
Jul 25, 2023
Merged
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
7 changes: 4 additions & 3 deletions src/lib/components/list-editor/list-editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import GitProjectService from '$lib/utils/project/GitProjectService';
import { isSupportedGitUrl } from '$lib/utils/is-valid-git-url';

export let max_items = 200;
export let maxItems = 200;

export let selected: string[] = ['svelte-stepper', 'svelte-stored-writable', 'foo-bar'];
export let percentages: Percentages = {};
Expand Down Expand Up @@ -94,7 +94,7 @@
if (selected.indexOf(id) === -1) {
items[id] = projectItem(gitProject);

if (selected.length < max_items) selected.push(id);
if (selected.length < maxItems) selected.push(id);
percentages = { ...percentages, [id]: 0 };

await tick();
Expand Down Expand Up @@ -131,7 +131,7 @@

items[address] = ethAddressItem(address);

if (selected.length < max_items) selected.push(address);
if (selected.length < maxItems) selected.push(address);
percentages = { ...percentages, [address]: 0 };
} catch (e) {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -254,6 +254,7 @@
multiselect
{items}
showEmptyState={false}
maxSelected={maxItems}
/>
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
console.log('💧 ~ Could not fetch project dependencies:', error);
}
}

$: countOfMaintainerSplits = $context.maintainerSplits.selected.length;
</script>

<StandaloneFlowStepLayout
Expand All @@ -63,14 +65,15 @@
Object.keys($context.dependencySplits.items).length
? ' We’ve imported these projects from your package.json to give you a head start.'
: ''
: ''} You can change this later anytime."
: ''} In total, you can add up to 200 maintainers and dependencies, and change this list later anytime."
>
<!-- TODO: Prevent splitting to the same project we're trying to claim. -->
<ListEditor
bind:selected={$context.dependencySplits.selected}
bind:percentages={$context.dependencySplits.percentages}
bind:items={$context.dependencySplits.items}
bind:valid={formValid}
maxItems={200 - countOfMaintainerSplits}
/>
<svelte:fragment slot="left-actions">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@
});

let formValid: boolean;

$: countOfDependencySplits = $context.dependencySplits.selected.length;
</script>

<StandaloneFlowStepLayout
headline="Split to your maintainers"
description="Decide how you want to divide the {$context.highLevelPercentages[
'maintainers'
]}% split to your project’s maintainers. You can change this later anytime."
]}% split to your project’s maintainers. In total, you can add up to 200 maintainers and dependencies, and change this list later anytime."
>
<ListEditor
bind:selected={$context.maintainerSplits.selected}
bind:percentages={$context.maintainerSplits.percentages}
bind:items={$context.maintainerSplits.items}
bind:valid={formValid}
maxItems={200 - countOfDependencySplits}
allowedItems="eth-addresses"
/>
<svelte:fragment slot="left-actions">
Expand Down
Loading