-
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
Changes from 2 commits
f45bbf4
0e4ecec
baecf33
362b06b
a25dbc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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'; | ||
|
||
import './SettingsWrapper.less'; | ||
|
||
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]} selectable={false} 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@import '~antd/lib/menu/style/index'; | ||
|
||
.settings-screen { | ||
.@{menu-prefix-cls} { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should be scoped to this page only. Our tabs should have the same look everywhere (unless it makes sense to have a different look in a specific component). Btw, I said it needs to be consistent, but I didn't say to which direction :-) We can also make the vertical tabs consistent with the horizontal tabs. I think right now they still use bootstrap classes/components, we can try and switch them to Ant component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like variant 2 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean migrate the vertical tabs? Me too :) Then let's revert the color change here and have a separate task of migrating the vertical tabs? It's a single place for all the list pages, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went with "this page only" approach because it was the valid one in this scope, but let's discuss the second option in #4338, then we come back here :) |
||
&-item > a:hover { | ||
color: black !important; | ||
} | ||
|
||
&-item-selected { | ||
color: black !important; | ||
> a, | ||
> a:hover { | ||
color: black !important; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
This file was deleted.
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