-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add note history (back/forward) #2819
Conversation
No, the arrows should stay where they are. Why would you want to move the mouse all over to the search bar. This makes no sense and is not very user friendly. Unless you have a mockup that shows the difference and it turns out to be better, I'm against changing the position of the arrows. |
Fair enough. What do you think @laurent22 ? |
Yes I also think we should leave them where they are now, unless someone makes a convincing case to move them elsewhere. I feel they should be completely to the left of the toolbar though, even before the "In: Notebook" button. What do you think? |
This is a very good idea, and it will make it consistent with the other action "goto". Agree too with the history limit. |
One issue with the button location is the buttons move if you are using them in The buttons move because the If you press So keeping them in the left most position on the toolbar might be nicer. Edit: OK, I now see Laurent has already suggested this above. |
I do notice a different issue though, the history doesn't seem to track keyboard navigation, ie when I move around the note list using the keyboard. master commit 159eaf7 |
@mic704b Some integration tests in showAllNotes were still failing for me. I applied your fix and it works now. Replacing
|
There is a waiting PR #2777 for this. The travis problem is unrelated, it might have just been a temporary glitch. |
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.
Thanks @naviji
I also have a general design question: what is the advantage of choosing to implement this feature as separate forward and backward history arrays, rather than a single history array and a pointer within it?
To implement backward and forward functionality as in browsers or file explorers we need two stacks. Check this out. |
With your integration test, you have two helper functions
Is this intention of this function to simulate the user pressing the back button? |
Yes. |
Ok, good. We need to change it though, so it is like what the front end does. Think of the feature test as if you asked a user to test the app for you. The So the idea is to feed in the events exactly like what would come from the front end, and check that the visible response to the user is as expected. The visible response to the user for this feature is primarily the selected folder and note. So that's what we should be checking in the The unit tests are for testing the internal states, individual methods and low level details. The feature tests are trying to be more higher level, across the app, end to end, to make sure all the bits are working together right. Also it might help to think of it like this. Imagine I decided to replace your implementation with a circular buffer. (I'm not going to, your implementation is good, this is just hypothetical!). If I ran your feature tests, they would all fail because my circular buffer doesn have a So, for context, the goal of the feature tests are to check the high level behaviour, end to end. And two reasons are to make sure your implementation works, and to make sure no one changes something else in the system and accidently breaks your feature. |
Thanks @mic704b for the clear explanation. I was writing integration tests like unit tests. I'll change my Expect statements to reflect the expectations of a user clicking the arrows.
But it does. Here is the left arrow's code in the front end. tooltip: _('Back'),
iconName: 'fa-arrow-left',
enabled: (this.props.backwardHistoryNotes.length > 0),
onClick: () => {
if (!this.props.backwardHistoryNotes.length) return;
const lastItem = this.props.backwardHistoryNotes[this.props.backwardHistoryNotes.length - 1];
this.props.dispatch({
type: 'FOLDER_AND_NOTE_SELECT',
folderId: lastItem.parent_id,
noteId: lastItem.id,
historyAction: 'goBackward',
});
} We are using backwardHistoryNotes for two things. First, to disable the button if there is no history. The NOTE_SELECT event uses the noteId attribute of this action. I don't see how we can decouple the backwardHistoryNotes from the button click. |
I stand corrected on that bit! That's exactly what we want. Excellent!
Great! And I will update the documentation so this is clearer for people writing feature tests in the future. Thanks @naviji. |
@laurent22 perhaps it might be worthwhile to schedule in a review of #2777 in case it can be merged? It is only small but has some changes that affect this PR. |
Yes, that's quite straightforward, I've merged it now. |
There's a bug in npm, which makes it change package-lock all the time even though nothing has changed. If we were merging it, there would be many unneeded commits on this file and probably frequent conflicts. So we only merge when it's needed - i.e. when something has changed in package.json; or when running |
Ok, ready for review |
@laurent22 Edit: It looks like the old feature_ForwardBackwardNoteHistory.js is causing everyone's test to fail! |
This reverts commit d1cab4b. Part of this revert: d2582f4 For rationale see #2819 (comment)
I reverted this commit as it was linked to the history feature: ec8ccc9 |
Thanks for fixing the conflicts @naviji, I indeed expected there might be a few after the recent refactoring of the text editor. I'm not entirely sure that we need combineReducer to simplify the code. Perhaps you could however move your history-specific functions to a separate file. Also I don't think you need to call handleHistory a bit everywhere as you're doing now. You could just add That way there are minimal changes to reducer.js, and all the history logic will be in a separate file, which makes it easier to maintain long term. |
Thanks @naviji for this very useful feature, and thanks @mic704b for reviewing and providing support! |
@naviji, one of the note history tests is randomly failing on CI, for example on these two pull requests: https://travis-ci.org/github/laurent22/joplin/jobs/693070952#L1005 https://travis-ci.org/github/laurent22/joplin/jobs/692433735#L1005
Do you know what could be the reason and how to fix it? |
@laurent22 I don't know why it fails randomly but, now that I look at this test again, I can see that it will pass even if we don't remove adjacent duplicates. I'll rewrite the test, and we'll see if that fixes it. Is that okay? |
@naviji, yes that would be great if you could fix it. It's happening semi-regularly on pull requests. |
For now I have disabled the tests, as it makes most new pull requests fail: afcfb0e |
@laurent22 Here is the rewritten test. #3328 |
Written test |
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.
Written test
I also edited the other tests with the fixes by @mic704b
I would also like to change somethings:
Suggestions?