Fix project preselection when project identifier is not defined (#9)
This commit is contained in:
parent
1533c2261f
commit
1d2e336e3d
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "moco-browser-extensions",
|
||||
"description": "Browser plugin for MOCO",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "yarn start:chrome",
|
||||
|
@ -69,8 +69,9 @@ class App extends Component {
|
||||
head(projects)
|
||||
|
||||
const task =
|
||||
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(project) ||
|
||||
head(project?.tasks)
|
||||
findTask(this.changeset.task_id || service?.taskId || lastTaskId)(
|
||||
project
|
||||
) || head(project?.tasks)
|
||||
|
||||
const defaults = {
|
||||
remote_service: service?.name,
|
||||
@ -111,7 +112,7 @@ class App extends Component {
|
||||
|
||||
if (name === "assignment_id") {
|
||||
const project = findProjectByValue(value)(projects)
|
||||
this.changeset.task_id = head(project?.tasks)?.value
|
||||
this.changeset.task_id = head(project?.tasks)?.value
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -21,11 +21,17 @@ export const ERROR_UNKNOWN = "unknown"
|
||||
|
||||
export const noop = () => null
|
||||
|
||||
export const findProjectBy = prop => val =>
|
||||
compose(
|
||||
export const findProjectBy = prop => val => projects => {
|
||||
if (!val) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return compose(
|
||||
find(pathEq(prop, val)),
|
||||
flatMap(get("options"))
|
||||
)
|
||||
)(projects)
|
||||
}
|
||||
|
||||
export const findProjectByIdentifier = findProjectBy("identifier")
|
||||
export const findProjectByValue = findProjectBy("value")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user