Skip to content

Commit a8a3afe

Browse files
committed
feat: Add the ability to clear an invalid site URL
1 parent 2e5d67a commit a8a3afe

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/components/app.js

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class App extends Component {
6363
handleLogout = () => this.props.store.logout();
6464
handleSiteURL = url => this.props.store.setSiteURL(url);
6565
clearSiteURL = url => this.props.store.clearSiteURL();
66+
clearStoreError = () => this.props.store.setError();
6667
handleExternalLogin = provider => this.props.store.externalLogin(provider);
6768
handleUser = ({ name, email, password }) => {
6869
const { store } = this.props;
@@ -201,6 +202,9 @@ class App extends Component {
201202
onClose={this.handleClose}
202203
logo={store.modal.logo}
203204
t={store.translate}
205+
isLocal={store.isLocal}
206+
clearSiteURL={this.clearSiteURL}
207+
clearStoreError={this.clearStoreError}
204208
>
205209
{this.renderBody()}
206210
{this.renderProviders()}

src/components/modal/index.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ export default class Modal extends Component {
3434
isOpen,
3535
children,
3636
logo,
37-
t
37+
t,
38+
isLocal,
39+
clearSiteURL,
40+
clearStoreError
3841
} = this.props;
3942
const hidden = loading || !isOpen;
43+
const formattedError = error ? formatError(error) : null;
4044
return (
4145
<div
4246
className="modalContainer"
@@ -86,9 +90,22 @@ export default class Modal extends Component {
8690
</button>
8791
</div>
8892
)}
89-
{error && (
93+
{formattedError && (
9094
<div className="flashMessage error">
91-
<span>{t(formatError(error))}</span>
95+
<span>{t(formattedError)}</span>
96+
</div>
97+
)}
98+
{isLocal && formattedError && formattedError.includes('Failed to load settings from') && (
99+
<div>
100+
<button
101+
onclick={e => {
102+
clearSiteURL(e);
103+
clearStoreError(null);
104+
}}
105+
className="btnLink forgotPasswordLink"
106+
>
107+
{t("site_url_link_text")}
108+
</button>
92109
</div>
93110
)}
94111
{children}

0 commit comments

Comments
 (0)