Skip to content

Commit 3a97c42

Browse files
authored
feat: Add the ability to clear an invalid site URL (#305)
* feat: Add the ability to clear an invalid site URL * fix: formatting issues * Remove invalid function param * Make lint happy
1 parent 76c2c8e commit 3a97c42

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-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

+22-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,11 +90,26 @@ 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>
9296
</div>
9397
)}
98+
{isLocal &&
99+
formattedError &&
100+
formattedError.includes("Failed to load settings from") && (
101+
<div>
102+
<button
103+
onclick={(e) => {
104+
clearSiteURL(e);
105+
clearStoreError();
106+
}}
107+
className="btnLink forgotPasswordLink"
108+
>
109+
{t("site_url_link_text")}
110+
</button>
111+
</div>
112+
)}
94113
{children}
95114
</div>
96115
</div>

0 commit comments

Comments
 (0)