-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Site Settings: create a Back navigation button and add it to the JP Disconnect Site #17691
Conversation
b3e8ca8
to
766c48f
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.
Looking good though slightly out of place — added a few comments inline.
left: 600px; | ||
bottom: 200px; | ||
|
||
.button.is-compact.is-borderless { |
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.
.render-return-button__container
is being applied directly to the button itself, so this property isn't being applied and should be moved to the same level and the first class.
render() { | ||
const { translate } = this.props; | ||
|
||
return ( | ||
<Main className="disconnect-site site-settings"> | ||
<DocumentHead title={ translate( 'Site Settings' ) } /> | ||
<ReturnToPreviousPage onBackClick={ this.handleClickBack } { ...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.
The button should be on the very top left-hand corner of the view area, so maybe we need to pop it outside of the Main
area and create an outer div.
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.
Same level as the '<- Switch Site', correct?
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, kind of like this:
We could even make the case that it's better to drop the sidebar altogether for this survey. What do you think @rickybanister ?
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 agree with that. The sidebar only really provides a distraction here. Full screen will help us accomplish our goal better and will help us improve the mobile view more.
71ab31d
to
f148713
Compare
766c48f
to
37effcf
Compare
37effcf
to
feef6a6
Compare
d25df7b
to
0b2f887
Compare
f67fca9
to
aec29f3
Compare
6f512ad
to
2c69a4f
Compare
aec29f3
to
19aa1dc
Compare
6eda017
to
3818380
Compare
@@ -32,3 +30,9 @@ | |||
text-align: center; | |||
} | |||
} | |||
|
|||
.disconnect-site__back-button { |
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.
By using percentages here, the button will “float” around depending on the screen's resolution. Instead, we can just use the same styles as .reader-full-post__back-container
(ref:
wp-calypso/client/blocks/reader-full-post/style.scss
Lines 37 to 60 in 64d9a90
.reader-full-post__back-container { | |
margin: 0; | |
position: fixed; | |
top: 47px; | |
left: 0; | |
z-index: z-index( '.masterbar', '.reader-back' ); | |
.button.is-compact.is-borderless { | |
padding: 18px 40px 18px 20px; | |
@include breakpoint( "<660px" ) { | |
padding: 20px 8px 16px; | |
} | |
} | |
@include breakpoint( "<660px" ) { | |
top: 0; | |
left: 0; | |
right: 0; | |
height: 46px; | |
background: $white; | |
border-bottom: 1px solid $gray-light; | |
} | |
} |
.disconnect-site__back-button {
margin: 0;
position: fixed;
top: 47px;
left: 0;
z-index: z-index( '.masterbar', '.reader-back' );
.button.is-compact.is-borderless {
padding: 18px 40px 18px 20px;
@include breakpoint( "<660px" ) {
padding: 20px 8px 16px;
}
}
@include breakpoint( "<660px" ) {
top: 0;
left: 0;
right: 0;
height: 46px;
background: $white;
border-bottom: 1px solid $gray-light;
}
}
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.
Makes sense, thanks @keoshi.
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 also moved the button specific styling to the component's style file. IMHO the idea would be to define button's container styling when using it (e.g. its positioning ), and not worry about the looks of it.
@@ -0,0 +1,33 @@ | |||
/** @format */ |
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 file be removed?
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, ofc. Bad copy. Thanks!
@@ -0,0 +1,33 @@ | |||
/** @format */ |
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 is a generic component, not restricted to use with the site settings, so I think it may make sense for it to live at https://github.com/Automattic/wp-calypso/tree/master/client/components.
</Main> | ||
<div> | ||
<span className="disconnect-site__back-button"> | ||
<NavigationBackButton redirectRoute={ this.getRoute() } { ...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.
Seems passing ...this.props
is not necessary.
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.
@seear, this is to pass e.g. translate
as a prop, since the component is not connected. Is there a better way to go about 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.
Ah, ok! The call to localize()
wraps a component with the localize
higher-order-component, which has some useful props, one of which is translate
, meaning we don't need to pass it down.
|
||
#Props: | ||
|
||
- `getRoute()` is a function returning redirection route loaded in the `onClick` |
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.
now takes redirectRoute
as a string.
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, true. Thanks!
@AnnaMag This is looking good. I left a few comments, the major one to consider being whether to move this to the shared /components folder, which on balance I think we should. |
116645b
to
255a862
Compare
Name was changed to better reflect the generic functionality of the component.
…omponent Previously the positioning of the button was expressed in %, which made affected its positioning depending on the screen resolution. In addition to fixing the latter, the style properties referring to the button itself are placed in component specific style.css file. Therefore, to use it it is only required to style the container of the button component (e.g. its positioning). To make it clear, the `className` of the button container was changed to reflect that.
ac89842
to
69303cc
Compare
Status: included the feedback + improved styling. |
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.
getRoute() { | ||
const { siteSlug } = this.props; | ||
|
||
if ( siteSlug ) { |
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 is totally unnecessary with the current implementation (because we're displaying a placeholder if sites are not loaded), but just asking: is it intentional that we don't return anything if siteSlug
is not there yet? Do we want to safeguard and return /settings/manage-connection
there in that case?
</Main> | ||
<div> | ||
<span className="disconnect-site__back-button-container"> | ||
<NavigationBackButton redirectRoute={ this.getRoute() } { ...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.
Do we really want to pass all props down to <NavigationBackButton />
? It's always more readable and sustainable to be specific about which props you're passing down, rather than just passing them all. And that's even more valid in this case - I don't see any additional props necessary there, so maybe remove { ...this.props }
completely?
import NavigationBackButton from 'my-sites/site-settings/navigation-back-button'; | ||
... | ||
|
||
getRoute() { |
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 is probably not necessary. Since we try to keep examples as simple as possible, we can just include a dummy path here instead of a method.
... // return a route | ||
} | ||
|
||
<span className="...."> |
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.
Would you like to place this within a render()
method, just so it's clear where one's supposed to be calling this one? Also, maybe you want to remove { ...this.props }
from the example.
|
||
- `redirectRoute` -- destination redirect route (string) | ||
|
||
##Exemplary use |
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'd say we need only the section that demonstrates how NavigationBackButton
works, without the one that demonstrates how getRoute
works - to me that one is unnecessary in the context of the back button.
} | ||
|
||
``` | ||
- `props` -- used to pass `translate` function to the 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.
We usually don't pass translate
down to other components; we rather prefer wrapping the component that needs to call translate
with the localize
HoC. You actually did this already, so you might want to remove this line from the readme.
import Button from 'components/button'; | ||
|
||
const NavigationBackButton = ( { redirectRoute, translate } ) => { | ||
const handleClick = () => { |
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.
How about using a Component
or a PureComponent
instead of a stateless functional component here? The problem with this approach is that it will generate a new handleClick
handler on every render.
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.
Let's avoid page
routing altogether when there's an href
prop we can use: https://github.com/Automattic/wp-calypso/blob/master/client/components/button/README.md#props
Okay, this is ready for another round of reviews. |
Oh, turns out we might not need this after all: #17696 (comment) |
Closing, since #18749 uses |
Purpose: add an option of site Return (
Back button
) to the Jetpack Disconnect Flow.Included in the patch:
NavigationBackButton
component, where the destination route is passed as a prop.Manage Connection
link in/settings/general
).To test:
https://calypso.live/?branch=update/site-settings-disconnect-site-add-return
settings/disconnect-site/:site
For Jetpack and non-Atomic sites:
Back
button is visible in the left top corner and redirects to/settings/manage-connection/:site
, where :site is the Jetpack site.All other sites: have no access = no site visibility
Note: please ignore the site settings specific Placeholder used here. This patch does not deal with adjusting it to the Disconnect Flow ( coming up).
Visuals:
