Skip to content

Commit

Permalink
refactor: replace 'ALL' task by empty filter
Browse files Browse the repository at this point in the history
  • Loading branch information
caro3801 committed Nov 15, 2024
1 parent 3d745c0 commit 7dbfed5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/enums/taskNames.js
Original file line number Diff line number Diff line change
@@ -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}`)
}
2 changes: 1 addition & 1 deletion src/store/modules/indexing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/views/Task/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTaskProperties } from '@/views/Task/task-properties'
const props = defineProps({
taskFilter: {
type: Array,
required: true
default: () => []
},
pageName: {
type: String,
Expand Down

0 comments on commit 7dbfed5

Please sign in to comment.