-
Notifications
You must be signed in to change notification settings - Fork 557
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
feat: users can save their progress #18511
base: main
Are you sure you want to change the base?
Conversation
Tasklist Test Results143 files 143 suites 1h 36m 41s ⏱️ Results for commit 9102846. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@douglasbouttell-camunda This PR is already a bit too, next time please it into smaller ones (a PR for the visual component and one for the mutation logic for example)
const {error} = await request(api.saveVariables({taskId, variables})); | ||
|
||
if (error !== null) { | ||
throw error ?? new Error('Could not complete task'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw error ?? new Error('Could not complete task'); | |
throw error; |
tasklist/client/src/modules/api.ts
Outdated
return new Request(getFullURL(`/v1/tasks/${taskId}/variables`), { | ||
...BASE_REQUEST_OPTIONS, | ||
method: 'POST', | ||
body: JSON.stringify(body), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but there's no need to create a var since it's no reused
body: JSON.stringify(body), | |
body: JSON.stringify({ | |
variables, | |
}), |
function formatFormDataToVariables(data: object) { | ||
return Object.keys(data).map((key) => ({ | ||
name: key, | ||
// @ts-expect-error TS7053: data[key] can be anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the types instead of ignoring them
@@ -79,6 +79,10 @@ const VariableEditor: React.FC<Props> = ({ | |||
}) => { | |||
const {dirtyFields} = useFormState<FormValues, Partial<FormValues>>(); | |||
|
|||
const nonDraftVariables = variables.filter( | |||
(v) => v.value !== null || v.previewValue !== null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(v) => v.value !== null || v.previewValue !== null, | |
({value, previewValue}) => value !== null || previewValue !== null, |
})} | ||
description="Saving..." | ||
iconDescription="Saving" | ||
status={'active'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status={'active'} | |
status="active" |
vi.advanceTimersByTime(5000); | ||
}); | ||
|
||
expect(screen.getByRole('status')).toBeEmptyDOMElement(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it bad for a11y to have it empty? maybe we should stop rending it
await waitFor(() => { | ||
expect(screen.getByTitle(/save current progress/i)).not.toHaveAttribute( | ||
'disabled', | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await waitFor(() => { | |
expect(screen.getByTitle(/save current progress/i)).not.toHaveAttribute( | |
'disabled', | |
); | |
}); | |
await waitFor(() => { | |
expect(screen.getByTitle(/save current progress/i)).toBeDisabled(); | |
}); |
savingState === 'finished' ? ( | ||
<SaveSuccessMessage /> | ||
) : savingState === 'error' ? ( | ||
<SaveFailedMessage /> | ||
) : undefined | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the AsyncActionButton
, I see no reason to not reuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the AsyncActionButton doesn't do what the UX design wants.
const newVariables: Array<Pick<Variable, 'name' | 'value'>> = []; | ||
|
||
variables.forEach((variable) => { | ||
if (variable.draft) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's invert the logic to use a explicit check like everywhere else
if (variable.draft) { | |
if (variable.draft === null) { |
save( | ||
formatFormDataToVariables( | ||
formManagerRef.current | ||
?.get('form') | ||
._getSubmitData() as object, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be using form-js
internal methods like this, part of the epic should have been changing adapting form-js
and make this public...
6f16f98
to
114af82
Compare
@esraagamal6 Could you please test this PR? |
db2cbff
to
9102846
Compare
Description
Some tasks require significant effort from the user or due to circumstances tasks may need to be transferred to other people. Camunda should support allowing users to save their progress in order to help their job.
Related issues
closes #17609