-
Notifications
You must be signed in to change notification settings - Fork 351
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
Import/export saved favorites #964
Conversation
…ated jest.config for lodash-es and react-dnd
- Replaced existing favorites implementation with new components from @relate-by-ui/saved-scripts - Added ability to export and import saved favorites using .zip - Added @relate-by-ui/css for icons and material-ui styles
@@ -171,6 +194,10 @@ const mapDispatchToProps = dispatch => { | |||
saveCypherToFavorites: file => { | |||
dispatch(addFavorite(file)) | |||
}, | |||
saveManyFavorites: favorites => { | |||
const folders = getFoldersFromFavorites(favorites) | |||
console.log('saveManyFavorites', favorites, folders) |
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.
oops, this should be calling LOAD_FAVORITES
action creator
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.
fixed!
content: AboutDrawer | ||
} | ||
] | ||
function Sidebar (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.
Since class only had a render() method anyhow...
@@ -60,7 +65,7 @@ export default function reducer (state = initialState, action) { | |||
return mergeFavorites(initialState, updatedFavorites) | |||
case LOAD_FAVORITES: | |||
case UPDATE_FAVORITES: | |||
return mergeFavorites(initialState, action.favorites) | |||
return mergeFavorites(action.favorites, state) |
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 had to change this to ensure favorites got updated. Still not sure how it worked before, or if this is right
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, this is strange.
942ecec
to
5dc7e2a
Compare
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 like the new looks of the favorites sidebar.
And I love that I can rename them from the UI now!
The syncing seems to be working perfectly, well done on that part.
A few things that should be addressed before this goes in (apart from eventual inline comments):
-
Import doesn't seem to be working in Safari (I have not tried in IE 11 or FF). JS Error is thrown in console.
-
Re-ordering of favorites does not seem to work anymore. Moving between folders seems to be working though.
build_scripts/webpack-rules.js
Outdated
@@ -98,7 +98,7 @@ module.exports = [ | |||
use: ['style-loader', 'css-loader'] | |||
}, | |||
{ | |||
test: /\.svg$/, | |||
test: /\.(svg|png)/, |
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 break the neo4j logo on :play start
. And possibly more places.
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.
"deepmerge": "^2.1.1", | ||
"dnd-core": "^2.5.1", | ||
"dompurify": "^1.0.11", | ||
"file-saver": "^1.3.8", | ||
"firebase": "^5.8.3", | ||
"isomorphic-fetch": "^2.2.1", | ||
"jsonic": "^0.3.0", | ||
"jszip": "^3.2.2", |
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 need to verify that this works in IE 11.
getMissingFoldersFromNames | ||
} from './file-drop.utils' | ||
|
||
describe('file-drop.utils', () => { |
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.
👍
updateFolder | ||
} from './favorites.utils' | ||
|
||
describe('favorites.utils', () => { |
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.
👍
@@ -60,7 +65,7 @@ export default function reducer (state = initialState, action) { | |||
return mergeFavorites(initialState, updatedFavorites) | |||
case LOAD_FAVORITES: | |||
case UPDATE_FAVORITES: | |||
return mergeFavorites(initialState, action.favorites) | |||
return mergeFavorites(action.favorites, state) |
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, this is strange.
import { SLASH } from './export-favorites.constants' | ||
import { mapOldFavoritesAndFolders } from './export-favorites.utils' | ||
|
||
describe('user-favorites.utils', () => { |
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.
👍
@oskarhane thank you for your feedback!
|
@oskarhane I've updated the PR to address 1. I also found two unrelated bugs from the browser-lambda-parser PR which I fixed. Please check my changes to build_scripts so that I didn't miss 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.
Great!
Dragging a .png file shows error message in top banner rather than in a new error frame. Is that intentional?
build_scripts/webpack-rules.js
Outdated
@@ -98,7 +98,7 @@ module.exports = [ | |||
use: ['style-loader', 'css-loader'] | |||
}, | |||
{ | |||
test: /\.svg$/, | |||
test: /\.(svg|png)/, |
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.
@@ -23,7 +23,11 @@ const path = require('path') | |||
module.exports = [ | |||
{ | |||
test: /\.(js|jsx)$/, | |||
exclude: /(node_modules)|(cypher-codemirror)|(test_utils)|(dist)/, | |||
include: [ |
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 a bit worried that this might break something but from my tests it all seems fine.
We should verify each step in the build pipeline after this is merged.
@oskarhane Sorry completely forgot about the webpack bug. Fixed: |
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.
LGTM 🎉
Ignore the E2E test failures and merge.
This PR heavily refactors the user favorites implementation, and adds support for importing/exporting saved scripts as a ZIP archive
Key changes
@relate-by-ui/saved-scripts
(Bugfix saved scripts folder update neo4j-devtools/relate-by-ui#2)Unrelated changes
Screenshots
Adding new favorites
Renaming favorites
Exporting favorites
Importing favorites
Running this PR locally
yarn install && yarn link
inpackages/saved-scripts
-
yarn install && yarn link @relate-by-ui/saved-scripts
yarn start
Todo
file-drop.utils
@relate-by-ui/saved-scripts
is published