diff --git a/packages/desktop-client/src/components/FinancesApp.js b/packages/desktop-client/src/components/FinancesApp.js index 1fde26b725dad2bd88685eeb06767d7a08706dd0..02c0a4792e7cd0838e69325e9733f7f0beaada41 100644 --- a/packages/desktop-client/src/components/FinancesApp.js +++ b/packages/desktop-client/src/components/FinancesApp.js @@ -52,8 +52,6 @@ import LinkSchedule from './schedules/LinkSchedule'; import PostsOfflineNotification from './schedules/PostsOfflineNotification'; import Settings from './settings'; import Titlebar, { TitlebarProvider } from './Titlebar'; -import FixSplitsTool from './tools/FixSplitsTool'; - // import Debugger from './Debugger'; function PageRoute({ path, component: Component }) { @@ -98,9 +96,10 @@ function Routes({ isMobile, location }) { component={PostsOfflineNotification} /> - <Route path="/rules" exact component={ManageRulesPage} /> <Route path="/payees" exact component={ManagePayeesPage} /> - <Route path="/tools/fix-splits" exact component={FixSplitsTool} /> + <Route path="/rules" exact component={ManageRulesPage} /> + <Route path="/settings" component={Settings} /> + <Route path="/accounts/:id" exact @@ -116,7 +115,6 @@ function Routes({ isMobile, location }) { exact component={isMobile ? MobileAccounts : Account} /> - <Route path="/settings" component={Settings} /> </Route> </Switch> ); diff --git a/packages/desktop-client/src/components/settings/FixSplits.js b/packages/desktop-client/src/components/settings/FixSplits.js new file mode 100644 index 0000000000000000000000000000000000000000..7a9b4ae02ed24c1a321ad5c7e4a016153c03e56d --- /dev/null +++ b/packages/desktop-client/src/components/settings/FixSplits.js @@ -0,0 +1,109 @@ +import React, { useState } from 'react'; + +import { send } from 'loot-core/src/platform/client/fetch'; +import { + View, + Text, + P, + ButtonWithLoading +} from 'loot-design/src/components/common'; +import { colors } from 'loot-design/src/style'; + +import { ButtonSetting } from './UI'; + +function renderResults(results) { + let { numBlankPayees, numCleared, numDeleted } = results; + let result = ''; + if (numBlankPayees === 0 && numCleared === 0 && numDeleted === 0) { + result = 'No split transactions found needing repair.'; + } else { + if (numBlankPayees > 0) { + result += `Fixed ${numBlankPayees} splits with a blank payee.`; + } + if (numCleared > 0) { + if (result !== '') { + result += '\n'; + } + result += `Fixed ${numCleared} splits with the wrong cleared flag.`; + } + if (numDeleted > 0) { + if (result !== '') { + result += '\n'; + } + result += `Fixed ${numDeleted} splits that weren't properly deleted.`; + } + } + + return ( + <P + style={{ + color: colors.g3, + marginBottom: 0, + marginLeft: '1em', + textAlign: 'right', + whiteSpace: 'pre-wrap' + }} + > + {result} + </P> + ); +} + +export default function FixSplitsTool() { + let [loading, setLoading] = useState(false); + let [results, setResults] = useState(null); + + async function onFix() { + setLoading(true); + let res = await send('tools/fix-split-transactions'); + setResults(res); + setLoading(false); + } + + return ( + <ButtonSetting + button={ + <View + style={{ + flexDirection: 'row', + justifyContent: 'space-between', + maxWidth: 500, + width: '100%', + alignItems: 'center' + }} + > + <ButtonWithLoading loading={loading} onClick={onFix}> + Repair split transactions + </ButtonWithLoading> + {results && renderResults(results)} + </View> + } + > + <Text> + <strong>Repair split transactions</strong> if you are experiencing bugs + relating to split transactions and the “Reset budget cache†button above + does not help. If you see blank payees on splits or account balances (or + any balances) are incorrect, this tool may fix them. + </Text> + <View style={{ alignItems: 'flex-start' }}> + <P>This tool does two things:</P> + <P> + <ul style={{ margin: 0, paddingLeft: '1.5em' }}> + <li style={{ marginBottom: '1em' }}> + Ensures that deleted split transactions are fully deleted. In + previous versions of the app, certain split transactions may + appear deleted but not all of them are actually deleted. This + causes the transactions list to look correct, but certain balances + may be incorrect when filtering. + </li> + <li> + Sync the payee and cleared flag of a split transaction to the main + or "parent" transaction, if appropriate. The payee will only be + set if it currently doesn't have one. + </li> + </ul> + </P> + </View> + </ButtonSetting> + ); +} diff --git a/packages/desktop-client/src/components/settings/UI.js b/packages/desktop-client/src/components/settings/UI.js index dbbb0adb71d3085b1f0b8113227b973a34a7a414..eb3b39ad6749efb31f53fe9fe3a8528d8dc53a16 100644 --- a/packages/desktop-client/src/components/settings/UI.js +++ b/packages/desktop-client/src/components/settings/UI.js @@ -1,4 +1,6 @@ import React, { useState } from 'react'; +import { useEffect } from 'react'; +import { useLocation } from 'react-router'; import { css, media } from 'glamor'; @@ -52,9 +54,17 @@ export function ButtonSetting({ button, children }) { } export function AdvancedToggle({ children }) { - let [expanded, setExpanded] = useState(false); + let location = useLocation(); + let [expanded, setExpanded] = useState(location.hash === '#advanced'); + return expanded ? ( <Section + innerRef={el => { + if (el && location.hash === '#advanced') { + el.scrollIntoView(true); + } + }} + id="advanced" title="Advanced Settings" {...css( { @@ -70,6 +80,7 @@ export function AdvancedToggle({ children }) { </Section> ) : ( <Link + id="advanced" onClick={() => setExpanded(true)} style={{ flexShrink: 0, diff --git a/packages/desktop-client/src/components/settings/index.js b/packages/desktop-client/src/components/settings/index.js index 0ba5a6a9f87e5b8fcf4eb9f59614d647eaedae3c..da545a46fd03adc8489b1e19e4617220986a38cb 100644 --- a/packages/desktop-client/src/components/settings/index.js +++ b/packages/desktop-client/src/components/settings/index.js @@ -17,6 +17,7 @@ import { isMobile } from '../../util'; import { Page } from '../Page'; import EncryptionSettings from './Encryption'; import ExportBudget from './Export'; +import FixSplitsTool from './FixSplits'; import FormatSettings from './Format'; import GlobalSettings from './Global'; import { ResetCache, ResetSync } from './Reset'; @@ -107,6 +108,7 @@ function Settings({ <AdvancedAbout prefs={prefs} /> <ResetCache /> <ResetSync resetSync={resetSync} /> + <FixSplitsTool /> </AdvancedToggle> </View> </Page> diff --git a/packages/desktop-client/src/components/tools/FixSplitsTool.js b/packages/desktop-client/src/components/tools/FixSplitsTool.js deleted file mode 100644 index 0b8a36ead27bf424936b175c850cc8ee4c1eb999..0000000000000000000000000000000000000000 --- a/packages/desktop-client/src/components/tools/FixSplitsTool.js +++ /dev/null @@ -1,88 +0,0 @@ -import React, { useState } from 'react'; - -import { send } from 'loot-core/src/platform/client/fetch'; -import { View, P, ButtonWithLoading } from 'loot-design/src/components/common'; -import { colors } from 'loot-design/src/style'; - -import { Page } from '../Page'; - -function renderResults(results) { - let { numBlankPayees, numCleared, numDeleted } = results; - if (numBlankPayees === 0 && numCleared === 0 && numDeleted === 0) { - return ( - <P style={{ alignSelf: 'center', color: colors.g3 }}> - No split transactions found needing repair. - </P> - ); - } - - let fixed = ''; - if (numBlankPayees > 0) { - fixed += `${numBlankPayees} split transactions with a blank payee`; - } - if (numCleared > 0) { - if (fixed !== '') { - fixed += ', and '; - } - fixed += `${numCleared} split transactions with the wrong cleared flag`; - } - if (numDeleted > 0) { - if (fixed !== '') { - fixed += ', and '; - } - fixed += `${numDeleted} split transactions that weren't properly deleted`; - } - - return ( - <P style={{ alignSelf: 'center', color: colors.g3 }}>Fixed {fixed}.</P> - ); -} - -export default function FixSplitsTool() { - let [loading, setLoading] = useState(false); - let [results, setResults] = useState(null); - - async function onFix() { - setLoading(true); - let res = await send('tools/fix-split-transactions'); - setResults(res); - setLoading(false); - } - - return ( - <Page title="Repair Split Transactions" modalSize={{ width: 650 }}> - <View style={{ alignItems: 'flex-start' }}> - <P>This tool does two things:</P> - <P> - <ul style={{ margin: 0 }}> - <li style={{ marginBottom: '1em' }}> - Ensures that deleted split transactions are fully deleted. In - previous versions of the app, certain split transactions may - appear deleted but not all of them are actually deleted. This - causes the transactions list to look correct, but certain balances - may be incorrect when filtering. - </li> - <li> - Sync the payee and cleared flag of a split transaction to the main - or "parent" transaction, if appropriate. The payee will only be - set if it currently doesn't have one. - </li> - </ul> - </P> - <P> - If you see blank payees on splits or account balances (or any - balances) are incorrect, this may fix it. - </P> - <ButtonWithLoading - primary - loading={loading} - onClick={onFix} - style={{ alignSelf: 'center', margin: '15px 0' }} - > - Repair split transactions - </ButtonWithLoading> - {results && renderResults(results)} - </View> - </Page> - ); -} diff --git a/packages/loot-design/src/components/sidebar.js b/packages/loot-design/src/components/sidebar.js index 425e4ed9b1870de00d27f046dad3901986f23357..5af7b5443076007f1d13708528b8798bd2538ec4 100644 --- a/packages/loot-design/src/components/sidebar.js +++ b/packages/loot-design/src/components/sidebar.js @@ -15,7 +15,6 @@ import CheveronDown from '../svg/v1/CheveronDown'; import CheveronRight from '../svg/v1/CheveronRight'; import Cog from '../svg/v1/Cog'; import DotsHorizontalTriple from '../svg/v1/DotsHorizontalTriple'; -import LoadBalancer from '../svg/v1/LoadBalancer'; import Reports from '../svg/v1/Reports'; import StoreFrontIcon from '../svg/v1/StoreFront'; import TuningIcon from '../svg/v1/Tuning'; @@ -541,12 +540,6 @@ function Tools() { to="/rules" indent={15} /> - <SecondaryItem - title="Repair split transactions" - Icon={LoadBalancer} - to="/tools/fix-splits" - indent={15} - /> </> )} </View>