Skip to content

Commit

Permalink
feat(tags): add multiple tags on pull request filter
Browse files Browse the repository at this point in the history
  • Loading branch information
buddyvegas committed Mar 8, 2021
1 parent e3b9f37 commit 4b9b2ca
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
38 changes: 36 additions & 2 deletions src/components/CustomListSettings/CustomListSettings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
export let onDone: () => void;
export let id: string;
let tags: string[] = $customLists.find(list => list.id === id)?.tags ?? [];
let listName: string = $customLists.find(list => list.id === id)
? $customLists.find(list => list.id === id).name
: null;
Expand All @@ -24,6 +26,8 @@
? $customLists.find(list => list.id === id).repositoriesIds
: [];
let tag: string;
const onImport = async () => {
const result: any = await app.invoke('file-import');
Expand Down Expand Up @@ -58,6 +62,7 @@
id,
name: listName,
repositoriesIds,
tags,
};
customLists.update(_list =>
Expand All @@ -74,6 +79,7 @@
id: uuidv4(),
name: listName,
repositoriesIds,
tags,
};
customLists.update(_list => [..._list, list]);
Expand All @@ -89,6 +95,25 @@
}
};
const onAddTag = (event: KeyboardEvent): void => {
event.preventDefault();
if (event.key === ';') {
console.log(tag, tags, event.key);
const result = tag.substring(0, tag.indexOf(';'));
if (result) {
tags = [...tags, result];
}
tag = '';
} else if (event.key === 'Backspace' && !tag) {
const result = tags.slice(0, tags.length - 1);
tags = [...result];
}
};
const deleteRepository = (id: string): void => {
const newRepositoriesIds = repositoriesIds.filter(repo => repo !== id);
repositoriesIds = [...newRepositoriesIds];
Expand Down Expand Up @@ -163,7 +188,9 @@
on:click={() => {
repositoriesIds = [...repositoriesIds, selectedRepoId];
}}
>Ajouter</button>
>
Ajouter
</button>
</div>
{#if repositoriesIds.length}
<p class="intro">
Expand All @@ -187,7 +214,9 @@
e.preventDefault();
deleteRepository(repo);
}}
><Icons.Delete /></button>
>
<Icons.Delete />
</button>
</li>
{/each}
</ul>
Expand All @@ -196,6 +225,11 @@
{/if}
</Fieldset>
{/if}

<Fieldset title="Tag" intro="Choisissez un tag, il apparaitra dans l'onglet.">
<input id="list-name" type="text" bind:value={tag} on:keyup={onAddTag} />
</Fieldset>

<div class="bar">
<input
disabled={!listName}
Expand Down
30 changes: 23 additions & 7 deletions src/components/Main/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Tabs from 'components/Tabs';
import Modale from 'components/Modale';
import CustomListSettings from 'components/CustomListSettings';
import type { CustomListType, ExportType } from 'models/skizzle';
import type { CustomListType, ExportType, LabelType } from 'models/skizzle';
const app = require('electron').ipcRenderer;
let creatingList: boolean = false;
Expand Down Expand Up @@ -57,11 +57,25 @@
};
const filterList = (customList: CustomListType) => {
return $pullRequests.filter(pullRequest =>
customList.repositoriesIds
.map(String)
.includes(String(pullRequest.repositoryId)),
);
let filteredPullRequests = $pullRequests;
if (customList.repositoriesIds.length) {
filteredPullRequests = filteredPullRequests.filter(pullRequest =>
customList.repositoriesIds
.map(String)
.includes(String(pullRequest.repositoryId)),
);
}
if (customList.tags) {
// filteredPullRequests = filteredPullRequests.filter(pullRequest =>
// pullRequest.labels
// ?.map(label => label.name.toLocaleLowerCase())
// .includes(customList.tags.map(tag => tag.toLocaleLowerCase())),
// );
}
return filteredPullRequests;
};
const getTabs = lists => {
Expand Down Expand Up @@ -107,7 +121,9 @@
on:click={() => {
modifyingListId = currentTab;
}}
>Modifier</button>
>
Modifier
</button>
<button on:click={deleteList}>Supprimer</button>
<button on:click={exportList}>Exporter</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/models/skizzle/CustomListType.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export type CustomListType = {
id: string;
name: string;
tags?: string[];
tags: string[];
projectsIds?: string[];
repositoriesIds?: string[];
hiddenPullRequestsIds?: string[];
Expand Down

0 comments on commit 4b9b2ca

Please sign in to comment.