Skip to content
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

Add Ferdi server to hosted services #49

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/api/apiBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const apiBase = (withVersion = true) => {
export default apiBase;

export function termsBase() {
// TODO: This needs to handle local vs ferdium vs franz servers
return (window as any).ferdium.stores.settings.all.app.server !== LIVE_FRANZ_API
vraravam marked this conversation as resolved.
Show resolved Hide resolved
? (window as any).ferdium.stores.settings.all.app.server
: DEV_API_FRANZ_WEBSITE;
Expand Down
11 changes: 7 additions & 4 deletions src/components/auth/ChangeServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Button from '../ui/Button';
import Link from '../ui/Link';
import Infobox from '../ui/Infobox';
import { url, required } from '../../helpers/validation-helpers';
import { LIVE_FERDIUM_API, LIVE_FRANZ_API } from '../../config';
import { LIVE_FERDIUM_API, LIVE_FRANZ_API, LIVE_FERDI_API } from '../../config';
import globalMessages from '../../i18n/globalMessages';

const messages = defineMessages({
Expand Down Expand Up @@ -43,9 +43,11 @@ class ChangeServer extends Component {

ferdiumServer = LIVE_FERDIUM_API;

ferdiServer = LIVE_FERDI_API;

franzServer = LIVE_FRANZ_API;

defaultServers = [this.franzServer, this.ferdiumServer];
defaultServers = [this.ferdiumServer, this.franzServer, this.ferdiServer];

form = new Form(
{
Expand All @@ -54,8 +56,9 @@ class ChangeServer extends Component {
label: this.props.intl.formatMessage(messages.label),
value: this.props.server,
options: [
{ value: this.ferdiumServer, label: 'Ferdium' },
{ value: this.ferdiumServer, label: 'Ferdium (Default)' },
{ value: this.franzServer, label: 'Franz' },
{ value: this.ferdiServer, label: 'Ferdi' },
{
value: this.defaultServers.includes(this.props.server)
? ''
Expand Down Expand Up @@ -108,7 +111,7 @@ class ChangeServer extends Component {
<form className="franz-form auth__form" onSubmit={e => this.submit(e)}>
<Link to='/auth/welcome'><img src="./assets/images/logo.svg" className="auth__logo" alt="" /></Link>
<h1>{intl.formatMessage(messages.headline)}</h1>
{form.$('server').value === this.franzServer && (
{(form.$('server').value === this.franzServer || form.$('server').value === this.ferdiServer) && (
<Infobox type="warning">
{intl.formatMessage(messages.warning)}
</Infobox>
Expand Down
20 changes: 19 additions & 1 deletion src/components/auth/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { observer, inject } from 'mobx-react';
import { defineMessages, injectIntl } from 'react-intl';

import { LIVE_FRANZ_API } from '../../config';
import { LIVE_FRANZ_API, LIVE_FERDI_API } from '../../config';
import { API_VERSION } from '../../environment-remote';
import Form from '../../lib/Form';
import { required, email } from '../../helpers/validation-helpers';
Expand Down Expand Up @@ -153,6 +153,24 @@ class Login extends Component {
</Link>
</p>
)}
{window['ferdium'].stores.settings.all.app.server !==
LIVE_FERDI_API && (
<p className="error-message center">
{intl.formatMessage(messages.customServerQuestion)}{' '}
<Link
to={`${window[
'ferdium'
].stores.settings.all.app.server.replace(
API_VERSION,
'',
)}/import`}
target="_blank"
style={{ cursor: 'pointer', textDecoration: 'underline' }}
>
{intl.formatMessage(messages.customServerSuggestion)}
</Link>
</p>
)}
</>
)}
{isSubmitting ? (
Expand Down
26 changes: 25 additions & 1 deletion src/components/settings/account/AccountDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { H1, H2 } from '../../ui/headline';
import Loader from '../../ui/Loader';
import Button from '../../ui/Button';
import Infobox from '../../ui/Infobox';
import { LOCAL_SERVER, LIVE_FRANZ_API } from '../../../config';
import { LOCAL_SERVER, LIVE_FRANZ_API, LIVE_FERDI_API } from '../../../config';

const messages = defineMessages({
headline: {
Expand Down Expand Up @@ -95,6 +95,7 @@ class AccountDashboard extends Component {

const isUsingWithoutAccount = server === LOCAL_SERVER;
const isUsingFranzServer = server === LIVE_FRANZ_API;
const isUsingFerdiServer = server === LIVE_FERDI_API;

return (
<div className="settings__main">
Expand Down Expand Up @@ -210,6 +211,29 @@ class AccountDashboard extends Component {
</div>
</div>
)}
{isUsingFerdiServer && (
<div className="account franz-form">
<div className="account__box">
<H2>
{intl.formatMessage(messages.headlineDangerZone)}
</H2>
{!isDeleteAccountSuccessful && (
<div className="account__subscription">
<p>{intl.formatMessage(messages.deleteInfo)}</p>
<Button
label={intl.formatMessage(messages.deleteAccount)}
buttonType="danger"
onClick={() => deleteAccount()}
loaded={!isLoadingDeleteAccount}
/>
</div>
)}
{isDeleteAccountSuccessful && (
<p>{intl.formatMessage(messages.deleteEmailSent)}</p>
)}
</div>
</div>
)}
</>
)}
</>
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const DEV_FRANZ_API = 'https://dev.franzinfra.com';

export const LIVE_FERDIUM_API = 'https://api.ferdium.org';
export const LIVE_FRANZ_API = 'https://api.franzinfra.com';
export const LIVE_FERDI_API = 'https://api.getferdi.com';

// URL used to submit debugger information, see https://github.com/ferdium/debugger
export const DEBUG_API = 'https://debug.ferdium.org';
Expand Down