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

Fix/tasks edit #15549

Merged
merged 5 commits into from
Oct 23, 2019
Merged

Fix/tasks edit #15549

merged 5 commits into from
Oct 23, 2019

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Oct 23, 2019

Closes #15534

Problem

The page would crash whenever an existing task was selected to edit. In addition, data on the task form would not populate or persist whenever a task was selected to edit / was toggled between task

Solution

The app was originally failing because of a race condition where the currentTask that was needed to call the setAllTaskOptions was only being populate after the componentDidMount function selectTaskByID was triggered. Since they were both being triggered in the CDM lifecycle, the setAllTaskOptions would never actually populate the data. To solve this, I created a new setAllTaskOptionsByID to get the task data based on the id.

In doing so, this fixed our issue of data persistence in the TaskForm. To resolve the issue of data persistence when toggling between schedule tasks simply required a modification to the following reducer:

https://github.com/influxdata/influxdb/blob/master/ui/src/tasks/reducers/index.ts#L94

It seems like the original intent of this conditional was to prevent data persistence from mucking up the task (i.e. storing interval data and cron data may have set the data for both), but these fears seem unfounded since the data is set correctly without any unintended consequences.

tasks_test

  • CHANGELOG.md updated with a link to the PR (not the Issue)

@asalem1 asalem1 requested a review from a team October 23, 2019 16:39
@ghost ghost requested review from ebb-tide and hoorayimhelping and removed request for a team October 23, 2019 16:39
Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

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

great work!

small nitpick (not worth blocking on), and a comment / question about skipping that reducer test. would just like a little clarification on that test :)

ui/cypress/e2e/tasks.test.ts Show resolved Hide resolved
ui/src/tasks/actions/index.ts Outdated Show resolved Hide resolved
ui/cypress/e2e/tasks.test.ts Show resolved Hide resolved
@@ -5,7 +5,8 @@ import tasksReducer, {
import {setTaskOption} from 'src/tasks/actions'
import {TaskSchedule} from 'src/utils/taskOptionsToFluxScript'

describe('tasksReducer', () => {
// skipping this test since the cron and interval values should not be reset when toggling between schedule tasks
describe.skip('tasksReducer', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

if this asserts something that is no longer the case, or it represents outdated assumptions, i'd say just remove the whole assertion. i think keeping it around will be more confusing than helpful. i appreciate the hesitation to delete an entire file someone else wrote though :)

if we're not sure what this is supposed to do, let's get some clarification from russ.

what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I appreciate the sympathy - definitely didn't wanna go around deleting files and taking names my second week, but it doesn't seem applicable. The only reason why I'd want to keep it would be to have a basis for fleshing out tests on the reducer later on. I'll go ahead and fix the tests so that they're consistent with the new logic of not overwriting the previous values

… the issue where task form data didn't persist when toggling between schedule task options
…rrent reducer functionality and updated the parameter name for consistency
Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

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

Dude you're killing it with this PR!

LGTM! just cut that comment in the test before merging

@@ -5,11 +5,13 @@ import tasksReducer, {
import {setTaskOption} from 'src/tasks/actions'
import {TaskSchedule} from 'src/utils/taskOptionsToFluxScript'

// skipping this test since the cron and interval values should not be reset when toggling between schedule tasks
Copy link
Contributor

Choose a reason for hiding this comment

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

✂️ this comment 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, good eyes!

@hoorayimhelping hoorayimhelping removed the request for review from a team October 23, 2019 19:06
@asalem1 asalem1 merged commit f28913a into master Oct 23, 2019
@asalem1 asalem1 deleted the fix/tasks-edit branch November 8, 2019 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetching task gives Uncaught TypeError: Cannot destructure property name of 'undefined' or 'null'.
2 participants