-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split configuration and definition, only handle configurations in res…
…ource manager level Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
- Loading branch information
1 parent
d452aff
commit 7f7eb62
Showing
11 changed files
with
163 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,29 @@ | ||
import { TaskDefinition } from 'react-components'; | ||
import { getTaskDefinition, TaskDefinition } from 'react-components'; | ||
|
||
export interface TaskResource { | ||
task_definition_id: string; | ||
display_name?: string; | ||
} | ||
|
||
export class TaskResourceManager { | ||
supportedTasks: Record<string, TaskDefinition>; | ||
tasks: TaskDefinition[]; | ||
|
||
constructor(supportedTasks: TaskDefinition[] | undefined) { | ||
this.supportedTasks = {}; | ||
if (supportedTasks) { | ||
for (const t of supportedTasks) { | ||
this.supportedTasks[t.taskDefinitionId] = t; | ||
constructor(taskResources: TaskResource[]) { | ||
this.tasks = []; | ||
for (const taskResource of taskResources) { | ||
const definition = getTaskDefinition(taskResource.task_definition_id); | ||
if (!definition) { | ||
console.error( | ||
`Invalid tasks configured for dashboard: [${taskResource.task_definition_id}]`, | ||
); | ||
continue; | ||
} | ||
|
||
if (taskResource.display_name !== undefined) { | ||
definition.taskDisplayName = taskResource.display_name; | ||
} | ||
|
||
this.tasks.push(definition); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.