-
Notifications
You must be signed in to change notification settings - Fork 751
Extract file search redux backend #3889
Extract file search redux backend #3889
Conversation
src/reducers/file-search.js
Outdated
|
|
||
| /** | ||
| * UI reducer | ||
| * @module reducers/ui |
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.
should be reducers/file-search
src/actions/file-search.js
Outdated
| import { getMatches } from "../utils/search"; | ||
| import type { ThunkArgs } from "./types"; | ||
|
|
||
| // import {} from "./index"; |
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.
remove this line
codehag
left a comment
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.
this looks really good! coupla nits
src/actions/file-search.js
Outdated
|
|
||
| async function searchContents(query: string, editor: Object) { | ||
| return async ({ getState, dispatch }) => { | ||
| // const { selectedSource, modifiers, editor: ed } = this.props; |
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 can remove this line as well
src/actions/file-search.js
Outdated
| const query = getFileSearchQuery(getState()); | ||
| const modifiers = getFileSearchModifiers(getState()); | ||
| const { searchResults: matches } = getFileSearchResults(); | ||
| // const { query, modifiers, searchResults: { matches } } = this.props; |
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.
this one too
src/reducers/file-search.js
Outdated
| count: number | ||
| }; | ||
|
|
||
| export type UIState = { |
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.
should this also be FileSearchState?
| } | ||
|
|
||
| case "TOGGLE_MODIFIER": { | ||
| const actionVal = !state.getIn(["modifiers", action.modifier]); |
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.
I'm on the fence about this but i will mention it anyway; is action.modifier a string? could we do something like
prefs[`fileSearch${action.modifier}`](i think it needs a first letter uppercase, but you get the idea)
since we seem to be doing the same thing each time, and we might not need this extra layer
f2eac48 to
7750a62
Compare
Codecov Report
@@ Coverage Diff @@
## master #3889 +/- ##
==========================================
- Coverage 54.69% 54.66% -0.03%
==========================================
Files 141 143 +2
Lines 5125 5098 -27
Branches 1056 1050 -6
==========================================
- Hits 2803 2787 -16
+ Misses 2322 2311 -11
Continue to review full report at Codecov.
|
| } | ||
|
|
||
| case "TOGGLE_MODIFIER": { | ||
| const actionVal = !state.getIn(["modifiers", action.modifier]); |
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.
lol we tried to do this kind of thing before, but it is too magical.
a big style reason not to, is that it is nice to grep for pref keys, just like it's nice to grep for l10n keys
| shiftSearchAgainShortcut | ||
| } = getShortcuts(); | ||
|
|
||
| shortcuts.on(searchShortcut, (_, e) => this.toggleSearch(e)); |
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.
Did you mean to remove the search shortcut?
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.
yes, because the search bar is now unmounted when it is not open. See the Editor/index render method
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.
I see that. But now there isn't a way to enable the search bar?
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.
oh, we should probably fix that :)
I think i was going to add a shortcut in App.js or Editor/index
c0efbe1 to
4b410e0
Compare
|
Working on this some more. Had to rework some of the code and rebase. Apologies for the delays. |
56f55af to
4d8c9a9
Compare
| dispatch(actions.toggleFileSearchModifier("caseSensitive")); | ||
| fileSearchModState = getFileSearchModifiers(getState()); | ||
| expect(fileSearchModState.get("caseSensitive")).toBe(true); | ||
| }); |
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.
i bet we can do some doSearch tests now where we stub codemirror. Obviously not a blocker, just excited
6bbe8ca to
42bfd73
Compare
42bfd73 to
6fe1d56
Compare
|
Almost ready to go! One last behavior to test and this is ready. 😄 |
5d6f79e to
9cb13dd
Compare
|
Travis keeps failing but I believe I've got it working like expected 😁 |
d4e76fe to
21fed11
Compare
21fed11 to
f22c1c0
Compare
|
Got it down to one failing mochitest that's unrelated? It's the browser_debug-console.js test. 🤔 |
f22c1c0 to
376af9b
Compare
|
|
||
| // Second time to hide console | ||
| pressKey(dbg, "Escape"); | ||
| pressKey(dbg, "CtrlEscape"); |
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.
Adding this key code worked but it feels wrong. 🙁 @jasonLaster Care to dig in a bit?
| const state = cm.state.search; | ||
|
|
||
| pressKey(dbg, "Enter"); | ||
| pressKey(dbg, "Enter"); |
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.
I don't know why the second ent here seems to be the trick.
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.
looks like it might be a timing issue
376af9b to
943c7d9
Compare
|
|
||
| // Second time to hide console | ||
| pressKey(dbg, "Escape"); | ||
| pressKey(dbg, "CtrlEscape"); |
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.
sure...
| const state = cm.state.search; | ||
|
|
||
| pressKey(dbg, "Enter"); | ||
| pressKey(dbg, "Enter"); |
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.
also weird...
|
can you rebase and I will take a look at the mochi test issue? |
codehag
left a comment
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.
Hey everyone. I will close this PR in favor of #4368
While i was able to fix the escape button bug, I also found that ctrl-cmd-i was no longer working in this branch. Unforunately too many changes were made in this pr for me to be able to accurately diagnose it, and some of them would need some work yet. The above pr is just a simplified version of this one
| shortcuts.on( | ||
| L10N.getStr("symbolSearch.search.key2"), | ||
| this.toggleSymbolModal | ||
| this.toggleVisible.bind(this, "symbol") |
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.
why do we have this name change here? it doesnt seem part of the reducer work
| ref: c => (this.$input = c) | ||
| ref: c => { | ||
| this.$input = c; | ||
| this.props.refFunc != null && this.props.refFunc(c); |
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.
why are we making this change?
| renderEditorPane: Function; | ||
| renderVerticalLayout: Function; | ||
| toggleSymbolModal: Function; | ||
| toggleVisible: Function; |
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.
also here: what is this change doing? can we leave it out?
| setSearchValue(value: string) { | ||
| const searchInput = this.searchInput(); | ||
| if (value == "" || !searchInput) { | ||
| if (!this.props.editor) { |
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.
moving this below e.stopPropagation and e.preventDefault is what was causing the escape button bug.
| } | ||
|
|
||
| getInputRef(c) { | ||
| this.searchInput = c; |
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.
this change doesnt make much sense to me, because this allows us to highjack the search and allows us to set the search field in two ways, via props and through setSearchValue.
we should instead have local state and props, props being the state that is sent to the search worker.
|
Closing as mentioned above. |

Summary of Changes
I realized #3888 was too big, so i'm taking the file search redux part out and making it its own PR.
Why extract:
Other questions / Musings:
The redux api (actions/selectors) need to be be really long like
setFileSearchQuerybecause they are shared among the entire app. It would be really cool if we could begin having sub-apps which are redux backends that are only connected to their root component.Test Plan
Re-use existing tests