From 18494f66a7e0f4020cbc77374d4679421fcf469a Mon Sep 17 00:00:00 2001 From: kytwb Date: Sat, 18 Dec 2021 04:24:10 +0100 Subject: Refactor autoUpdater usage --- src/features/nightlyBuilds/Component.js | 142 -------------------------------- src/features/nightlyBuilds/index.ts | 41 --------- src/features/nightlyBuilds/store.ts | 7 -- 3 files changed, 190 deletions(-) delete mode 100644 src/features/nightlyBuilds/Component.js delete mode 100644 src/features/nightlyBuilds/index.ts delete mode 100644 src/features/nightlyBuilds/store.ts (limited to 'src/features/nightlyBuilds') diff --git a/src/features/nightlyBuilds/Component.js b/src/features/nightlyBuilds/Component.js deleted file mode 100644 index 216e35f65..000000000 --- a/src/features/nightlyBuilds/Component.js +++ /dev/null @@ -1,142 +0,0 @@ -import { Component } from 'react'; -import PropTypes from 'prop-types'; -import { observer, inject } from 'mobx-react'; -import injectSheet from 'react-jss'; -import { defineMessages, injectIntl } from 'react-intl'; -import { H1 } from '../../components/ui/headline'; - -import Modal from '../../components/ui/Modal'; -import Button from '../../components/ui/Button'; -import { state as ModalState } from './store'; -import SettingsStore from '../../stores/SettingsStore'; -import UIStore from '../../stores/UIStore'; -import UserStore from '../../stores/UserStore'; -import globalMessages from '../../i18n/globalMessages'; - -const messages = defineMessages({ - title: { - id: 'feature.nightlyBuilds.title', - defaultMessage: 'Nightly Builds', - }, - info: { - id: 'feature.nightlyBuilds.info', - defaultMessage: - "Nightly builds are highly experimental versions of Ferdi that may contain unpolished or uncompleted features. These nightly builds are mainly used by developers to test their newly developed features and how they will perform in the final build. If you don't know what you are doing, we suggest not activating nightly builds.", - }, - activate: { - id: 'feature.nightlyBuilds.activate', - defaultMessage: 'Activate', - }, -}); - -const styles = theme => ({ - modal: { - width: '80%', - maxWidth: 600, - background: theme.styleTypes.primary.contrast, - paddingTop: 30, - }, - info: { - paddingBottom: 20, - }, - headline: { - fontSize: 20, - marginBottom: 20, - marginTop: -27, - }, - buttonContainer: { - display: 'flex', - }, - button: { - width: '50%', - marginTop: 10, - cursor: 'pointer', - }, - activateButton: { - marginRight: 10, - background: '#c45a5a !important', - color: '#ffffff !important', - }, -}); - -class NightlyBuildsModal extends Component { - close() { - ModalState.isModalVisible = false; - - const { ui } = this.props.actions; - ui.openSettings({ path: 'app' }); - } - - activate() { - const { settings, user } = this.props.actions; - - settings.update({ - type: 'app', - data: { - nightly: true, - }, - }); - user.update({ - userData: { - nightly: true, - }, - }); - this.close(); - } - - render() { - const { isModalVisible } = ModalState; - - const { classes } = this.props; - - const { intl } = this.props; - - return ( - -

- {intl.formatMessage(messages.title)} -

- -

{intl.formatMessage(messages.info)}

- -
-
-
- ); - } -} - -NightlyBuildsModal.propTypes = { - stores: PropTypes.shape({ - settings: PropTypes.instanceOf(SettingsStore).isRequired, - }).isRequired, - actions: PropTypes.shape({ - settings: PropTypes.instanceOf(SettingsStore).isRequired, - user: PropTypes.instanceOf(UserStore).isRequired, - ui: PropTypes.instanceOf(UIStore).isRequired, - }).isRequired, - classes: PropTypes.object.isRequired, -}; - -export default injectIntl( - injectSheet(styles)( - inject('stores', 'actions')(observer(NightlyBuildsModal)), - ), -); diff --git a/src/features/nightlyBuilds/index.ts b/src/features/nightlyBuilds/index.ts deleted file mode 100644 index 14afbaf1b..000000000 --- a/src/features/nightlyBuilds/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { state as ModalState } from './store'; - -export { default as Component } from './Component'; - -const debug = require('debug')('Ferdi:feature:nightlyBuilds'); - -const state = ModalState; - -export default function initialize() { - debug('Initialize nightlyBuilds feature'); - - function showModal() { - state.isModalVisible = true; - } - - function toggleFeature() { - if (window['ferdi'].stores.settings.app.nightly) { - window['ferdi'].actions.settings.update({ - type: 'app', - data: { - nightly: false, - }, - }); - window['ferdi'].actions.user.update({ - userData: { - nightly: false, - }, - }); - } else { - // We need to close the settings, otherwise the modal will be drawn under the settings window - window['ferdi'].actions.ui.closeSettings(); - showModal(); - } - } - - window['ferdi'].features.nightlyBuilds = { - state, - showModal, - toggleFeature, - }; -} diff --git a/src/features/nightlyBuilds/store.ts b/src/features/nightlyBuilds/store.ts deleted file mode 100644 index ed06e5a7d..000000000 --- a/src/features/nightlyBuilds/store.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { observable } from 'mobx'; - -const defaultState = { - isModalVisible: false, -}; - -export const state = observable(defaultState); -- cgit v1.2.3-70-g09d2