-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Migrate Settings Screen to React #4323
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f45bbf4
Migrate settings-screen to React
gabrieldutra 0e4ecec
Use black instead of blue color for active item
gabrieldutra baecf33
Revert "Use black instead of blue color for active item"
gabrieldutra 362b06b
Add selectable=false to the Menu
gabrieldutra a25dbc0
Merge branch 'master' into react-settings
gabrieldutra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import Menu from 'antd/lib/menu'; | ||
import { PageHeader } from '@/components/PageHeader'; | ||
import { $location } from '@/services/ng'; | ||
import settingsMenu from '@/services/settingsMenu'; | ||
|
||
|
||
function wrapSettingsTab(options, WrappedComponent) { | ||
if (options) { | ||
settingsMenu.add(options); | ||
} | ||
|
||
return function SettingsTab(props) { | ||
const activeItem = settingsMenu.getActiveItem($location.path()); | ||
return ( | ||
<div className="settings-screen"> | ||
<div className="container"> | ||
<PageHeader title="Settings" /> | ||
<div className="bg-white tiled"> | ||
<Menu selectedKeys={[activeItem && activeItem.title]} mode="horizontal"> | ||
{settingsMenu.items.map(item => ( | ||
<Menu.Item key={item.title}><a href={item.path}>{item.title}</a></Menu.Item> | ||
))} | ||
</Menu> | ||
<div className="p-15"> | ||
<div> | ||
<WrappedComponent {...props} /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
} | ||
|
||
export default wrapSettingsTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Very nice 👍
Haven't you thought about implementing this not as HOC, but as a regular component and then use it to wrap a return value in
render()
functions where needed. Like:I don't mean that there's something wrong with your solution, just wondering why you decided to implement this as HOC 🙂
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 did think about it, my reason was to centralize the "registration" of settings tabs in one place (which ended up not being as much as I initially thought 😅 - just a
settingsMenu.add
removed from each component).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.
Yeah, I didn't notice that first, but now I see. Very cool, I like it 👍
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 the same thought as @kravets-levko :)
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.
What I first had in mind was to move the routing part to the HOC function as well, but ended up moving only the
settingsMenu.add
. Anyway, it seemed to make sense to have this logic centralized in there, so I didn't bother to change.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.
There is no much sense to do anything with routing until we replave
angular-router
with React alternative. And even in this case routing should not be coupled with this settings screen HOC. So I think it's good that you decided to not change routing part here