Skip to content
Permalink
Browse files

feat(Todos): Add option to disable todos

  • Loading branch information...
adlk committed Sep 6, 2019
1 parent 024fb39 commit 5d03b91dd789ffd6d3d5753c223b4b6412887220
@@ -101,6 +101,7 @@ export default @observer class EditSettingsForm extends Component {
onClearAllCache: PropTypes.func.isRequired,
cacheSize: PropTypes.string.isRequired,
isSpellcheckerIncludedInCurrentPlan: PropTypes.bool.isRequired,
isTodosEnabled: PropTypes.bool.isRequired,
};

static contextTypes = {
@@ -131,6 +132,7 @@ export default @observer class EditSettingsForm extends Component {
onClearAllCache,
cacheSize,
isSpellcheckerIncludedInCurrentPlan,
isTodosEnabled,
} = this.props;
const { intl } = this.context;

@@ -162,6 +164,9 @@ export default @observer class EditSettingsForm extends Component {
{process.platform === 'win32' && (
<Toggle field={form.$('minimizeToSystemTray')} />
)}
{isTodosEnabled && (
<Toggle field={form.$('enableTodos')} />
)}

{/* Appearance */}
<h2 id="apperance">{intl.formatMessage(messages.headlineAppearance)}</h2>
@@ -6,6 +6,7 @@ import { defineMessages, intlShape } from 'react-intl';
import AppStore from '../../stores/AppStore';
import SettingsStore from '../../stores/SettingsStore';
import UserStore from '../../stores/UserStore';
import TodosStore from '../../features/todos/store';
import Form from '../../lib/Form';
import { APP_LOCALES, SPELLCHECKER_LOCALES } from '../../i18n/languages';
import { DEFAULT_APP_SETTINGS } from '../../config';
@@ -17,6 +18,7 @@ import EditSettingsForm from '../../components/settings/settings/EditSettingsFor
import ErrorBoundary from '../../components/util/ErrorBoundary';

import globalMessages from '../../i18n/globalMessages';
import { DEFAULT_IS_FEATURE_ENABLED_BY_USER } from '../../features/todos';

const messages = defineMessages({
autoLaunchOnStart: {
@@ -67,6 +69,10 @@ const messages = defineMessages({
id: 'settings.app.form.beta',
defaultMessage: '!!!Include beta versions',
},
enableTodos: {
id: 'settings.app.form.enableTodos',
defaultMessage: '!!!Enable Franz Todos',
},
});

export default @inject('stores', 'actions') @observer class EditSettingsScreen extends Component {
@@ -75,7 +81,13 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
};

onSubmit(settingsData) {
const { app, settings, user } = this.props.actions;
const { todos } = this.props.stores;
const {
app,
settings,
user,
todos: todosActions,
} = this.props.actions;

app.launchOnStartup({
enable: settingsData.autoLaunchOnStart,
@@ -105,10 +117,16 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
locale: settingsData.locale,
},
});

if (todos.isFeatureActive) {
todosActions.toggleTodosFeatureVisibility();
}
}

prepareForm() {
const { app, settings, user } = this.props.stores;
const {
app, settings, user, todos,
} = this.props.stores;
const { intl } = this.context;

const locales = getSelectOptions({
@@ -192,16 +210,28 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
},
};

if (todos.isFeatureActive) {
config.fields.enableTodos = {
label: intl.formatMessage(messages.enableTodos),
value: todos.settings.isFeatureEnabledByUser,
default: DEFAULT_IS_FEATURE_ENABLED_BY_USER,
};
}

return new Form(config);
}

render() {
const {
app,
todos,
} = this.props.stores;
const {
updateStatus,
cacheSize,
updateStatusTypes,
isClearingAllCache,
} = this.props.stores.app;
} = app;
const {
checkForUpdates,
installUpdate,
@@ -224,6 +254,7 @@ export default @inject('stores', 'actions') @observer class EditSettingsScreen e
isClearingAllCache={isClearingAllCache}
onClearAllCache={clearAllCache}
isSpellcheckerIncludedInCurrentPlan={spellcheckerConfig.isIncludedInCurrentPlan}
isTodosEnabled={todos.isFeatureActive}
/>
</ErrorBoundary>
);
@@ -235,6 +266,7 @@ EditSettingsScreen.wrappedComponent.propTypes = {
app: PropTypes.instanceOf(AppStore).isRequired,
user: PropTypes.instanceOf(UserStore).isRequired,
settings: PropTypes.instanceOf(SettingsStore).isRequired,
todos: PropTypes.instanceOf(TodosStore).isRequired,
}).isRequired,
actions: PropTypes.shape({
app: PropTypes.shape({
@@ -249,5 +281,8 @@ EditSettingsScreen.wrappedComponent.propTypes = {
user: PropTypes.shape({
update: PropTypes.func.isRequired,
}).isRequired,
todos: PropTypes.shape({
toggleTodosFeatureVisibility: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
};
@@ -6,6 +6,7 @@ export const todoActions = createActionsFromDefinitions({
width: PropTypes.number.isRequired,
},
toggleTodosPanel: {},
toggleTodosFeatureVisibility: {},
setTodosWebview: {
webview: PropTypes.instanceOf(Element).isRequired,
},
@@ -8,6 +8,7 @@ export const GA_CATEGORY_TODOS = 'Todos';
export const DEFAULT_TODOS_WIDTH = 300;
export const TODOS_MIN_WIDTH = 200;
export const DEFAULT_TODOS_VISIBLE = true;
export const DEFAULT_IS_FEATURE_ENABLED_BY_USER = true;

export const TODOS_ROUTES = {
TARGET: '/todos',
@@ -11,7 +11,7 @@ import { FeatureStore } from '../utils/FeatureStore';
import { createReactions } from '../../stores/lib/Reaction';
import { createActionBindings } from '../utils/ActionBinding';
import {
DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES,
DEFAULT_TODOS_WIDTH, TODOS_MIN_WIDTH, DEFAULT_TODOS_VISIBLE, TODOS_ROUTES, DEFAULT_IS_FEATURE_ENABLED_BY_USER,
} from '.';
import { IPC } from './constants';
import { state as delayAppState } from '../delayApp';
@@ -33,7 +33,7 @@ export default class TodoStore extends FeatureStore {

@computed get isTodosPanelForceHidden() {
const { isAnnouncementShown } = this.stores.announcements;
return delayAppState.isDelayAppScreenVisible || isAnnouncementShown;
return delayAppState.isDelayAppScreenVisible || !this.settings.isFeatureEnabledByUser || isAnnouncementShown;
}

@computed get isTodosPanelVisible() {
@@ -60,6 +60,7 @@ export default class TodoStore extends FeatureStore {
[todoActions.setTodosWebview, this._setTodosWebview],
[todoActions.handleHostMessage, this._handleHostMessage],
[todoActions.handleClientMessage, this._handleClientMessage],
[todoActions.toggleTodosFeatureVisibility, this._toggleTodosFeatureVisibility],
]));

// REACTIONS
@@ -74,6 +75,12 @@ export default class TodoStore extends FeatureStore {
this._registerReactions(this._allReactions);

this.isFeatureActive = true;

if (this.settings.isFeatureEnabledByUser === undefined) {
this._updateSettings({
isFeatureEnabledByUser: DEFAULT_IS_FEATURE_ENABLED_BY_USER,
});
}
}

@action stop() {
@@ -128,6 +135,14 @@ export default class TodoStore extends FeatureStore {
}
};

@action _toggleTodosFeatureVisibility = () => {
debug('_toggleTodosFeatureVisibility');

this._updateSettings({
isFeatureEnabledByUser: !this.settings.isFeatureEnabledByUser,
});
};

// Todos client message handlers

_onTodosClientInitialized = () => {

0 comments on commit 5d03b91

Please sign in to comment.
You can’t perform that action at this time.