From eb7b2481f631cec5953265eef4ebc3f2fa7e496a Mon Sep 17 00:00:00 2001 From: muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> Date: Wed, 16 Nov 2022 23:30:39 +0530 Subject: Transform JSX components to TSX (#755) * color picker types * Import * SetupAssistant * Services & appear * ServiceWebView * SettingsLayout * ImportantScreen * WorkspaceDrawer * SetupAssistant * chore: update vscode settings * chore: removed stale Import screen component & its tree --- src/components/services/content/Services.tsx | 162 +++++++++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 src/components/services/content/Services.tsx (limited to 'src/components/services/content/Services.tsx') diff --git a/src/components/services/content/Services.tsx b/src/components/services/content/Services.tsx new file mode 100644 index 000000000..53cddd907 --- /dev/null +++ b/src/components/services/content/Services.tsx @@ -0,0 +1,162 @@ +import { Component, ReactElement } from 'react'; +import { observer } from 'mobx-react'; +import { Link } from 'react-router-dom'; +import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'; +import Confetti from 'react-confetti'; +import ms from 'ms'; +import withStyles, { WithStylesProps } from 'react-jss'; +import ServiceView from './ServiceView'; +import Appear from '../../ui/effects/Appear'; +import Service from '../../../models/Service'; + +const messages = defineMessages({ + getStarted: { + id: 'services.getStarted', + defaultMessage: 'Get started', + }, + login: { + id: 'services.login', + defaultMessage: 'Please login to use Ferdium.', + }, + serverless: { + id: 'services.serverless', + defaultMessage: 'Use Ferdium without an Account', + }, + serverInfo: { + id: 'services.serverInfo', + defaultMessage: + 'Optionally, you can change your Ferdium server by clicking the cog in the bottom left corner. If you are switching over (from one of the hosted servers) to using Ferdium without an account, please be informed that you can export your data from that server and subsequently import it using the Help menu to resurrect all your workspaces and configured services!', + }, +}); + +const styles = { + confettiContainer: { + position: 'absolute', + width: '100%', + zIndex: 9999, + pointerEvents: 'none', + }, +}; + +interface IProps extends WrappedComponentProps, WithStylesProps { + services?: Service[]; + setWebviewReference: () => void; + detachService: () => void; + handleIPCMessage: () => void; + openWindow: () => void; + reload: (options: { serviceId: string }) => void; + openSettings: (options: { path: string }) => void; + update: (options: { + serviceId: string; + serviceData: { isEnabled: boolean }; + redirect: boolean; + }) => void; + userHasCompletedSignup: boolean; + isSpellcheckerEnabled: boolean; +} + +interface IState { + showConfetti: boolean; +} + +@observer +class Services extends Component { + _confettiTimeout: number | null = null; + + constructor(props: IProps) { + super(props); + + this.state = { + showConfetti: true, + }; + } + + componentDidMount(): void { + this._confettiTimeout = window.setTimeout(() => { + this.setState({ + showConfetti: false, + }); + }, ms('8s')); + } + + componentWillUnmount(): void { + if (this._confettiTimeout) { + clearTimeout(this._confettiTimeout); + } + } + + render(): ReactElement { + const { + services = [], + handleIPCMessage, + setWebviewReference, + detachService, + openWindow, + reload, + openSettings, + update, + userHasCompletedSignup, + classes, + isSpellcheckerEnabled, + intl, + } = this.props; + + const { showConfetti } = this.state; + + return ( +
+ {userHasCompletedSignup && ( +
+ +
+ )} + {services.length === 0 && ( + +
+ Logo + + + {intl.formatMessage(messages.getStarted)} + + +
+
+ )} + {services + .filter(service => !service.isTodosService) + .map(service => ( + reload({ serviceId: service.id })} + edit={() => openSettings({ path: `services/edit/${service.id}` })} + enable={() => + update({ + serviceId: service.id, + serviceData: { + isEnabled: true, + }, + redirect: false, + }) + } + isSpellcheckerEnabled={isSpellcheckerEnabled} + /> + ))} +
+ ); + } +} + +export default injectIntl(withStyles(styles, { injectTheme: true })(Services)); -- cgit v1.2.3-54-g00ecf