-
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: Hide the delete site notice if the site is not loaded yet #2983
Conversation
@@ -32,6 +32,10 @@ | |||
&.is-info { | |||
background: $blue-wordpress; | |||
} | |||
|
|||
&.hidden { |
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 doesn't seem a great way to handle these — we should just not render the notice.
@@ -113,7 +114,7 @@ module.exports = React.createClass( { | |||
<ActionPanel> | |||
<ActionPanelTitle>{ strings.deleteSite }</ActionPanelTitle> | |||
<ActionPanelBody> | |||
<Notice status="is-warning" showDismiss={ false }> | |||
<Notice status="is-warning" className={ classNames( { hidden: ! site } ) } showDismiss={ false }> |
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 Matias. We could do something like the following:
{ site &&
<Notice status="is-warning" showDismiss={ false }>
{ this.translate( '{{strong}}%(domain)s{{/strong}} will be unavailable in the future.', {
components: {
strong: <strong />
},
args: {
domain: site.domain
}
} ) }
</Notice>
}
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, that seems better.
982081f
to
ddfa596
Compare
ddfa596
to
01fef7c
Compare
I changed the way the notice is rendered following @mtias advice, PR is ready to be reviewed again! |
👍 |
} | ||
} ) } | ||
</Notice> | ||
); |
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.
You could reduce the length of this function by doing the opposite - which I find more logic by the way:
renderNotice: function() {
var site = this.state.site;
if ( site ) {
return (
<Notice status="is-warning" showDismiss={ false }>
{ this.translate( '{{strong}}%(domain)s{{/strong}} will be unavailable in the future.', {
components: {
strong: <strong />
},
args: {
domain: site.domain
}
} ) }
</Notice>
);
}
},
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 not sure if there is a benefit either way, but if it is arbitrary, my preference is for the way @Tug implemented it, because:
- It works with multiple conditions that bail out early (example from
ManagePurchase
):
if ( ! isRenewable( purchase ) && ! isRedeemable( purchase ) ) {
return null;
}
if ( ! isExpired( purchase ) ) {
return null;
}
- It's easier (for me) to read JSX that isn't wrapped in an extra block/blocks.
LGTM 👍 |
Site Settings: Hide the delete site notice if the site is not loaded yet
This fixes an error reported by @drewblaisdell in D979:
Testing instructions:
http://calypso.localhost:3000/settings/delete-site/:site
localStorage.clear();
Review: