Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #81 - On starting a timer mark TP task as "In Progress", if current task state is "Open" or "Dev ready" #82

Merged
merged 4 commits into from
Feb 26, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,26 @@ export const start = async (packageVersion: string, apiProvider: ApiProvider, da
const notes = createNotes(noteInformation, [ details.notes ]);

const harvestApi = apiProvider.getHarvestApi();
const targetprocessApi = apiProvider.getTargetprocessApi();

log.info("Starting Harvest timer...");
try {
await harvestApi.startTimeEntry(details.projectId, details.taskId, date, notes, details.hours, details.running);

// Issue #81: If the linked TP entity is a Task *and* its current state is 'Open' or 'Dev ready', set the task to 'In Progress'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this comment too as the issue will have a reference to this pr

if (details.entity &&
details.entity.Id &&
details.entity.ResourceType === "Task" &&
details.entity.EntityState &&
details.entity.EntityState.Name &&
(details.entity.EntityState.Name.toUpperCase() === "OPEN" ||
details.entity.EntityState.Name.toUpperCase() === "DEV READY") &&
details.entity.Project &&
details.entity.Project.Process &&
details.entity.Project.Process.Id) {

await targetprocessApi.setTaskState(details.entity.Id, "In Progress", details.entity.Project.Process.Id);
}
} catch (e) {
log.error(e);
}
Expand Down