Skip to content

Filter for tools supporting bowtie #1582

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion pages/tools/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export default function Sidebar({
(formData.get('showObsolete') as string) === 'showObsolete'
? 'true'
: 'false',
supportsBowtie:
(formData.get('supportsBowtie') as string) === 'supportsBowtie'
? 'true'
: 'false',
} satisfies Transform;
postAnalytics({ eventType: 'query', eventPayload: newTransform });
return newTransform;
Expand Down Expand Up @@ -123,7 +127,12 @@ export default function Sidebar({
name='showObsolete'
checked={transform['showObsolete'] === 'true'}
/>

<Checkbox
label='Support Bowtie'
value='supportsBowtie'
name='supportsBowtie'
checked={transform['supportsBowtie'] === 'true'}
/>
<div className='w-full flex items-center justify-between mt-4 gap-2'>
<button
type='submit'
Expand Down
9 changes: 9 additions & 0 deletions pages/tools/hooks/useToolsTransform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Transform {
toolingTypes: string[];
environments: string[];
showObsolete: 'true' | 'false';
supportsBowtie: 'true' | 'false';
}

export type TransformUpdate =
Expand All @@ -38,6 +39,7 @@ const buildQueryString = (transform: Transform) => {
toolingTypes: transform.toolingTypes.join(','),
environments: transform.environments.join(','),
showObsolete: transform.showObsolete,
supportsBowtie: transform.supportsBowtie,
}).toString();
};

Expand All @@ -56,6 +58,7 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
toolingTypes: [],
environments: [],
showObsolete: 'false',
supportsBowtie: 'false',
});

useEffect(() => {
Expand Down Expand Up @@ -89,6 +92,8 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
) as Transform['environments'],
showObsolete:
(query.showObsolete as Transform['showObsolete']) || 'false',
supportsBowtie:
(query.supportsBowtie as Transform['supportsBowtie']) || 'false',
} satisfies Transform;

const queryString = buildQueryString(updatedTransform);
Expand Down Expand Up @@ -137,6 +142,7 @@ export default function useToolsTransform(tools: JSONSchemaTool[]) {
toolingTypes: [],
environments: [],
showObsolete: 'false',
supportsBowtie: 'false',
};

const queryString = buildQueryString(initialTransform);
Expand Down Expand Up @@ -193,6 +199,9 @@ const filterTools = (
transform: Transform,
): JSONSchemaTool[] => {
const filteredTools = tools.filter((tool) => {
if (transform.supportsBowtie === 'true' && !tool.bowtie?.id) {
return false;
}
if (transform.showObsolete === 'false' && tool.status === 'obsolete')
return false;

Expand Down