diff --git a/src/enums/taskNames.js b/src/enums/taskNames.js new file mode 100644 index 0000000000..0a084306db --- /dev/null +++ b/src/enums/taskNames.js @@ -0,0 +1,28 @@ +const BATCH_SEARCH = 'BatchSearchRunner' +const BATCH_DOWNLOAD = 'BatchDownloadRunner' +const SCAN = 'ScanTask' +const INDEX = 'IndexTask' +const EXTRACT_NLP = 'ExtractNlpTask' +export const TASK_NAMES = Object.freeze({ + BATCH_SEARCH, + BATCH_DOWNLOAD, + SCAN, + INDEX, + EXTRACT_NLP +}) +export const taskNameValidator = (v) => TASK_NAMES.includes(v) + +export function getTaskName(longName) { + const taskName = longName.split('.').pop() + if (taskNameValidator(taskName)) { + return taskName + } + throw new Error(`Wrong task name ${longName}`) +} + +export function getLongTaskName(shortName) { + if (taskNameValidator(shortName)) { + return `org.icij.datashare.tasks.${shortName}` + } + throw new Error(`Wrong task name ${shortName}`) +} diff --git a/src/store/modules/indexing.js b/src/store/modules/indexing.js index 906621f376..9b08d35284 100644 --- a/src/store/modules/indexing.js +++ b/src/store/modules/indexing.js @@ -56,7 +56,7 @@ function actionsBuilder(api) { }, async getTasks({ commit }, taskNames) { try { - if (taskNames.includes('ALL')) { + if (taskNames.length === 0) { const tasks = await api.getTasks() commit(UPDATE_TASKS, tasks) } else { diff --git a/src/views/Task/Task.vue b/src/views/Task/Task.vue index e836008f68..b1d0c51548 100644 --- a/src/views/Task/Task.vue +++ b/src/views/Task/Task.vue @@ -10,7 +10,7 @@ import { useTaskProperties } from '@/views/Task/task-properties' const props = defineProps({ taskFilter: { type: Array, - required: true + default: () => [] }, pageName: { type: String,