Skip to content
Snippets Groups Projects
Commit ceca21af authored by Giannis Koumoutsos's avatar Giannis Koumoutsos
Browse files

move tasks and icons to the frontend

parent 1a61cea3
No related branches found
No related tags found
1 merge request!393Move General tasks and icons to the frontend
Pipeline #137094 passed
import type { Task } from '../types';
export const generalTasks: Task[] = [
{
icon: 'graphInput.svg',
task_type: 'graphInput',
output_names: [''],
task_identifier: 'graphInput',
optional_input_names: [''],
category: 'General',
required_input_names: [''],
},
{
icon: 'graphOutput.svg',
task_type: 'graphOutput',
output_names: [''],
task_identifier: 'graphOutput',
optional_input_names: [''],
category: 'General',
required_input_names: [''],
},
{
required_input_names: [],
category: 'General',
task_identifier: 'taskSkeleton',
task_type: 'ppfmethod',
icon: 'orange2.png',
optional_input_names: [],
output_names: [],
},
];
......@@ -5,6 +5,8 @@ import path from 'path-browserify';
import type { DeleteResponse, IconResponse, ListResponse } from './models';
import { QueryKey } from './models';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import graphInput from 'images/graphInput.svg';
import graphOutput from 'images/graphOutput.svg';
async function fetchIconIds() {
const { data } = await client.get<ListResponse>(`/icons`);
......@@ -53,7 +55,11 @@ export function useIcons() {
assertDefined(icons);
return icons;
return [
...icons,
{ name: 'graphInput.svg', data_url: graphInput },
{ name: 'graphOutput.svg', data_url: graphOutput },
];
}
export function useInvalidateIcons() {
......
......@@ -3,6 +3,7 @@ import type { Task } from '../types';
import { getTaskName } from '../utils';
import { assertDefined } from '../utils/typeGuards';
import { client } from './client';
import { generalTasks } from './generalTasks';
import type {
DeleteResponse,
ListResponse,
......@@ -50,9 +51,11 @@ export function useTasks(): Task[] {
const { data: axiosResponse } = query;
assertDefined(axiosResponse);
return axiosResponse.data.items.sort((a, b) =>
getTaskName(a).localeCompare(getTaskName(b))
);
const tasks = [
...axiosResponse.data.items.filter((task) => task.category !== 'General'),
...generalTasks,
];
return tasks.sort((a, b) => getTaskName(a).localeCompare(getTaskName(b)));
}
export function useInvalidateTasks() {
......
......@@ -40,7 +40,11 @@ function TaskList() {
<TaskItem
key={task.task_identifier}
task={task}
onClick={() => setSelectTaskId(task.task_identifier)}
onClick={() => {
if (task.category !== 'General') {
setSelectTaskId(task.task_identifier);
}
}}
isSelected={task.task_identifier === selectedTaskId}
/>
))}
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M13 7v-6l11 11-11 11v-6h-13v-10z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 8v-5l9 9-9 9v-5h-12v-8h12zm12-4h-3v16h3v-16z"/></svg>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment