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

feat: remove ipfs-desktop settings #1445

Merged
merged 2 commits into from
Apr 21, 2020
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
19 changes: 2 additions & 17 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"settingsWillBeUsedNextTime": "The new settings will be used next time you restart the IPFS daemon.",
"ipfsConfigDescription": "The IPFS config file is a JSON document. It is read once when the IPFS daemon is started. Save your changes, then restart the IPFS daemon to apply them.",
"ipfsConfigHelp": "Check the documentation for further information.",
"ipfsDesktop": "IPFS Desktop",
"takeScreenshot": "Take screenshot",
"takeScreenshotDescription": "Use <0>{key1}</0> + <2>{key2}</2> + <3>{key3}</3> to take screenshots and add them to your repository.",
"downloadHash": "Download hash",
"downloadHashDescription": "Use <0>{key1}</0> + <2>{key2}</2> + <3>{key3}</3> to download the last copied hash or path to your system.",
"launchOnStartup": "Launch on login",
"globalShortcuts": "Global Shortcuts",
"globalShortcutsAre": "IPFS Desktop provides some features that can be globally accessed through keyboard shortcuts. You can enable or disable them here.",
"AnalyticsToggle": {
"label": "Help improve this app by sending anonymous usage data",
"summary": "Configure what is collected",
Expand Down Expand Up @@ -96,13 +88,6 @@
"description": "Here you can get an early preview into new IPFS features by enabling options below. We are testing these ideas, and they may not be perfect yet so we'd love to hear your feedback.",
"issueUrl": "Open an issue",
"feedbackUrl": "💌Leave feedback",
"readMoreUrl": "Read More",
"npmOnIpfs": {
"title": "NPM on IPFS",
"label": "Enable ipfs-npm",
"description": "Install npm modules through IPFS with the 'ipfs-npm' command line tool!"
}
},
"ipfsCmdTools": "IPFS command line tools",
"ipfsCmdToolsDescription": "Add <0>ipfs</0> binary to your system <0>PATH</0> so you can use it in the command line."
"readMoreUrl": "Read More"
}
}
4 changes: 0 additions & 4 deletions src/bundles/config-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ const bundle = {
}
await store.doMarkConfigAsOutdated()
dispatch({ type: 'CONFIG_SAVE_FINISHED' })

if (store.selectIsIpfsDesktop()) {
store.doDesktopIpfsConfigChanged()
}
}
}

Expand Down
26 changes: 3 additions & 23 deletions src/bundles/experiments.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,7 @@ export const ACTIONS = {
EXP_UPDATE_STATE: 'EXPERIMENTS_UPDATE_STATE'
}

const EXPERIMENTS = [
{
key: 'npmOnIpfs',
actionUrls: [
{
url: 'https://github.com/ipfs-shipyard/npm-on-ipfs',
key: 'readMoreUrl'
},
{
url: 'https://github.com/ipfs-shipyard/npm-on-ipfs/issues',
key: 'issueUrl'
},
{
url: 'https://github.com/ipfs-shipyard/ipfs-desktop/issues/957',
key: 'feedbackUrl'
}
],
desktopOnly: true
}
]
const EXPERIMENTS = []

const mergeState = (state, payload) =>
Object.keys(payload).reduce(
Expand Down Expand Up @@ -114,10 +95,9 @@ export default {
selectExperimentsState: state => state.experiments,

selectExperiments: createSelector(
'selectIsIpfsDesktop',
'selectExperimentsState',
(isDesktop, state) =>
EXPERIMENTS.filter(e => !!e.desktopOnly === isDesktop).map(e => ({
(state) =>
EXPERIMENTS.map(e => ({
...e,
...state[e.key]
}))
Expand Down
88 changes: 0 additions & 88 deletions src/bundles/ipfs-desktop.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import { ACTIONS as EXP_ACTIONS } from './experiments'

export const ACTIONS = {
SETTING_TOGGLE_STARTED: 'DESKTOP_SETTING_TOGGLE_STARTED',
SETTING_TOGGLE_FINISHED: 'DESKTOP_SETTING_TOGGLE_FINISHED',
SETTING_TOGGLE_FAILED: 'DESKTOP_SETTING_TOGGLE_FAILED'
}

let bundle = {
name: 'ipfsDesktop',
reducer: (state = {}) => state,
Expand All @@ -16,88 +8,12 @@ let bundle = {
if (window.ipfsDesktop) {
bundle = {
...bundle,
reducer: (state = {}, action) => {
if (action.type === EXP_ACTIONS.EXP_TOGGLE_STARTED) {
window.ipfsDesktop.toggleSetting(`experiments.${action.payload.key}`)
}

if (!action.type.startsWith('DESKTOP_')) {
return state
}

if (action.type === 'DESKTOP_SETTINGS_CHANGED') {
return action.payload
}

return state
},

selectDesktopSettings: state => state.ipfsDesktop,

selectDesktopPlatform: state => state.ipfsDesktop.platform,

selectDesktopVersion: () => window.ipfsDesktop.version,

selectDesktopCountlyDeviceId: () => window.ipfsDesktop.countlyDeviceId,

selectDesktopCountlyActions: () => window.ipfsDesktop.countlyActions,

doDesktopStartListening: () => async ({ dispatch, store }) => {
window.ipfsDesktop.onConfigChanged(({ platform, config, changed, success }) => {
const prevConfig = store.selectDesktopSettings()

if (Object.keys(prevConfig).length === 0) {
dispatch({
type: EXP_ACTIONS.EXP_UPDATE_STATE,
payload: Object.keys(config.experiments).reduce(
(all, key) => ({
...all,
[key]: {
enabled: config.experiments[key]
}
}),
{}
)
})
}

if (changed) {
const isExperiment = changed.startsWith('experiments.')
const key = isExperiment
? changed.replace('experiments.', '')
: changed

const type = isExperiment
? success
? EXP_ACTIONS.EXP_TOGGLE_FINISHED
: EXP_ACTIONS.EXP_TOGGLE_FAILED
: success
? ACTIONS.SETTING_TOGGLE_FINISHED
: ACTIONS.SETTING_TOGGLE_FAILED

const value = isExperiment
? config.experiments[key]
: config[key]

dispatch({ type, payload: { key, value } })
}

dispatch({
type: 'DESKTOP_SETTINGS_CHANGED',
payload: config ? { ...config, platform } : undefined
})
})
},

doDesktopSettingsToggle: setting => ({ dispatch }) => {
dispatch({ type: ACTIONS.SETTING_TOGGLE_STARTED, payload: { key: setting } })
window.ipfsDesktop.toggleSetting(setting)
},

doDesktopIpfsConfigChanged: () => () => {
window.ipfsDesktop.configHasChanged()
},

doDesktopSelectDirectory: () => () => {
return window.ipfsDesktop.selectDirectory()
},
Expand All @@ -108,10 +24,6 @@ if (window.ipfsDesktop) {

doDesktopRemoveConsent: consent => () => {
return window.ipfsDesktop.removeConsent(consent)
},

init: store => {
store.doDesktopStartListening()
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/bundles/notify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createSelector } from 'redux-bundler'
import { ACTIONS as EXP_ACTIONS } from './experiments'
import { ACTIONS as FILES_ACTIONS } from './files'
import { ACTIONS as DESK_ACTIONS } from './ipfs-desktop'

/*
# Notify
Expand Down Expand Up @@ -71,15 +70,6 @@ const notify = {
}
}

if (action.type === DESK_ACTIONS.SETTING_TOGGLE_FAILED) {
return {
...state,
show: true,
error: true,
eventId: `desktopToggleErrors.${action.payload.key}`
}
}

return state
},

Expand Down
94 changes: 0 additions & 94 deletions src/settings/DesktopSettings.js

This file was deleted.

5 changes: 1 addition & 4 deletions src/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Button from '../components/button/Button'
import LanguageSelector from '../components/language-selector/LanguageSelector'
import AnalyticsToggle from '../components/analytics-toggle/AnalyticsToggle'
import JsonEditor from './editor/JsonEditor'
import DesktopSettings from './DesktopSettings'
import Experiments from '../components/experiments/ExperimentsPanel'
import Title from './Title'

Expand All @@ -23,7 +22,7 @@ const PAUSE_AFTER_SAVE_MS = 3000
export const SettingsPage = ({
t, tReady, isIpfsConnected,
isConfigBlocked, isLoading, isSaving,
hasSaveFailed, hasSaveSucceded, hasErrors, hasLocalChanges, hasExternalChanges, isIpfsDesktop,
hasSaveFailed, hasSaveSucceded, hasErrors, hasLocalChanges, hasExternalChanges,
config, onChange, onReset, onSave, editorKey, analyticsEnabled, doToggleAnalytics,
toursEnabled, handleJoyrideCallback
}) => (
Expand All @@ -32,8 +31,6 @@ export const SettingsPage = ({
<title>{t('title')} - IPFS</title>
</Helmet>

{ isIpfsDesktop && <DesktopSettings /> }

<Box className='mb3 pa4'>
<div className='mb4 joyride-settings-language'>
<Title>{t('language')}</Title>
Expand Down
12 changes: 0 additions & 12 deletions src/settings/SettingsPage.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { withKnobs, boolean } from '@storybook/addon-knobs'
import i18n from '../i18n'
import { SettingsPage } from './SettingsPage'
import i18nDecorator from '../i18n-decorator'
import { TranslatedDesktopSettings as DesktopSettings } from './DesktopSettings'
import config from './editor/fixtures/example-config.json'

storiesOf('Settings Page', module)
Expand All @@ -31,14 +30,3 @@ storiesOf('Settings Page', module)
onSave={action('save')} />
</div>
))
.add('Desktop Settings', () => (
<div className='sans-serif'>
<DesktopSettings
doDesktopSettingsToggle={action('toggle')}
desktopSettings={{
autoLaunch: true,
screenshotShortcut: false,
downloadHashShortcut: true
}} />
</div>
))