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: #586 #590

Merged
merged 2 commits 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
9 changes: 9 additions & 0 deletions src/lib/components/list-editor/list-editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
export let blockInteraction = false;
export let addOnMount: string | undefined = undefined;

/**
* Pass an array of keys for items which the user will not be able to add to the list.
*/
export let blockedKeys: string[] = [];

$: selectedPercentages = Object.fromEntries(
Object.entries(percentages).filter(([slug]) => selected.includes(slug)),
);
Expand Down Expand Up @@ -90,6 +95,8 @@
let gitProject = await gitProjectService.getByUrl(inputValue);

const id = gitProject.source.url;
if (blockedKeys.includes(id)) throw new Error('Project ID is already used');

// Prevent duplicates.
if (selected.indexOf(id) === -1) {
items[id] = projectItem(gitProject);
Expand Down Expand Up @@ -124,6 +131,8 @@
: await ensStore.reverseLookup(inputValue);
assert(address);

if (blockedKeys.includes(address)) throw new Error('This address is already used');

if (items[address]) {
isAddingProject = false;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
bind:percentages={$context.dependencySplits.percentages}
bind:items={$context.dependencySplits.items}
bind:valid={formValid}
blockedKeys={$context.maintainerSplits.selected}
/>
<svelte:fragment slot="actions">
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
bind:items={$context.maintainerSplits.items}
bind:valid={formValid}
allowedItems="eth-addresses"
blockedKeys={$context.dependencySplits.selected}
/>
<svelte:fragment slot="actions">
<Button disabled={!formValid} icon={ArrowRight} variant="primary" on:click={nextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
bind:percentages={$context.dependencySplits.percentages}
bind:items={$context.dependencySplits.items}
bind:valid={formValid}
blockedKeys={$context.maintainerSplits.selected}
maxItems={200 - countOfMaintainerSplits}
/>
<svelte:fragment slot="left-actions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
bind:valid={formValid}
maxItems={200 - countOfDependencySplits}
allowedItems="eth-addresses"
blockedKeys={$context.dependencySplits.selected}
/>
<svelte:fragment slot="left-actions">
<Button icon={ArrowLeftIcon} on:click={() => dispatch('goBackward')}>Go back</Button>
Expand Down
Loading