Skip to content

Commit

Permalink
feat: Add the ability to clear an invalid site URL (#305)
Browse files Browse the repository at this point in the history
* feat: Add the ability to clear an invalid site URL

* fix: formatting issues

* Remove invalid function param

* Make lint happy
  • Loading branch information
amorriscode authored Jul 29, 2020
1 parent 76c2c8e commit 3a97c42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class App extends Component {
handleLogout = () => this.props.store.logout();
handleSiteURL = (url) => this.props.store.setSiteURL(url);
clearSiteURL = (url) => this.props.store.clearSiteURL();
clearStoreError = () => this.props.store.setError();
handleExternalLogin = (provider) => this.props.store.externalLogin(provider);
handleUser = ({ name, email, password }) => {
const { store } = this.props;
Expand Down Expand Up @@ -201,6 +202,9 @@ class App extends Component {
onClose={this.handleClose}
logo={store.modal.logo}
t={store.translate}
isLocal={store.isLocal}
clearSiteURL={this.clearSiteURL}
clearStoreError={this.clearStoreError}
>
{this.renderBody()}
{this.renderProviders()}
Expand Down
25 changes: 22 additions & 3 deletions src/components/modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ export default class Modal extends Component {
isOpen,
children,
logo,
t
t,
isLocal,
clearSiteURL,
clearStoreError
} = this.props;
const hidden = loading || !isOpen;
const formattedError = error ? formatError(error) : null;
return (
<div
className="modalContainer"
Expand Down Expand Up @@ -86,11 +90,26 @@ export default class Modal extends Component {
</button>
</div>
)}
{error && (
{formattedError && (
<div className="flashMessage error">
<span>{t(formatError(error))}</span>
<span>{t(formattedError)}</span>
</div>
)}
{isLocal &&
formattedError &&
formattedError.includes("Failed to load settings from") && (
<div>
<button
onclick={(e) => {
clearSiteURL(e);
clearStoreError();
}}
className="btnLink forgotPasswordLink"
>
{t("site_url_link_text")}
</button>
</div>
)}
{children}
</div>
</div>
Expand Down

0 comments on commit 3a97c42

Please sign in to comment.