-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Move file settings to the file management area #3500
Move file settings to the file management area #3500
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe pull request introduces several enhancements to the desktop client application, including the addition of new modal components for managing file settings and confirming directory changes. It implements functionality for moving budget directories through IPC communication and updates the application state management to accommodate new user preferences. Additionally, existing components are modified to integrate these new features, ensuring a cohesive user experience across the application. Key changes include the addition of the Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller
Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged No assets were unchanged |
return Promise.reject(error); | ||
} | ||
}, | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copies the budget files into the new directory, then removes the old directory.
- If it fails the copy nothing is deleted - recoverable.
- If it fails the delete the copy has been successful - recoverable
In the event of a failure the user is instructed to check the directories so they can remedy it manually or fix whatever was causing the error (like a file lock).
…lectron/file-management-settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🧹 Outside diff range and nitpick comments (10)
packages/loot-core/typings/window.d.ts (1)
20-23
: LGTM! Consider adding documentation and error handling.The new
moveBudgetDirectory
method is well-defined and aligns with the PR objectives. It correctly uses TypeScript types and follows naming conventions.To improve the code further:
- Add JSDoc comments to explain the method's purpose and parameters. For example:
/** * Moves the budget directory from the current location to a new one. * @param currentBudgetDirectory The current location of the budget directory. * @param newDirectory The new location for the budget directory. * @returns A promise that resolves when the operation is complete. */ moveBudgetDirectory: ( currentBudgetDirectory: string, newDirectory: string, ) => Promise<void>;
- Consider how error handling will be implemented in the actual function. You might want to update the return type to
Promise<void | Error>
if you plan to return errors, or ensure that error handling is documented in the implementation.packages/desktop-electron/preload.ts (1)
76-86
: Consider updating documentation and testsThe new
moveBudgetDirectory
method enhances the file management capabilities as intended. To ensure long-term maintainability:
- Update any relevant documentation to reflect this new functionality.
- Consider adding unit tests for this new method, if not already done.
packages/desktop-client/src/browser-preload.browser.js (1)
155-155
: Consider additional updates to support budget directory movementWhile the addition of
moveBudgetDirectory
is a good start, consider the following suggestions to ensure comprehensive support for this new functionality:
Document the intended use and parameters of the
moveBudgetDirectory
method. This will help other developers understand how to use it when it's fully implemented.Consider if any additional methods or updates to existing methods (like
openFileDialog
orsaveFile
) are needed to fully support the budget directory movement functionality.Ensure that any related state management or IPC communication needed for this feature is properly set up in this file or related files.
Here's a suggested documentation format for the method:
/** * Moves the budget directory to a new location. * @param {string} newPath - The new path for the budget directory. * @returns {Promise<boolean>} - Resolves to true if the move was successful, false otherwise. * @throws {Error} If the operation fails. */ moveBudgetDirectory: (newPath) => { // TODO: Implement budget directory movement functionality console.warn('moveBudgetDirectory: Not yet implemented'); throw new Error('moveBudgetDirectory is not yet implemented'); },This documentation provides clear expectations for the method's future implementation and usage.
packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (2)
16-16
: Consider removing unused state variable.The state variable
_documentDirChanged
is declared but never used in the component. Consider removing it to keep the code clean and avoid potential confusion.- const [_documentDirChanged, setDirChanged] = useState(false); + const [, setDirChanged] = useState(false);If the state is not needed at all, you can remove the entire line.
84-85
: Consider removing unused variable.The variable
_setServerSelfSignedCertPref
is declared but never used in the component. Consider removing it to keep the code clean and avoid potential confusion.- const [serverSelfSignedCertPref, _setServerSelfSignedCertPref] = - useGlobalPref('serverSelfSignedCert'); + const [serverSelfSignedCertPref] = useGlobalPref('serverSelfSignedCert');packages/desktop-client/src/components/settings/index.tsx (1)
180-180
: LGTM: Conditional rendering ofBackups
component addedThe addition of the
Backups
component with conditional rendering based onisElectron()
aligns well with the PR objectives. This change enhances the settings page for Electron environments while maintaining compatibility with other platforms.Consider extracting the
isElectron()
check into a constant at the beginning of the component for improved readability:export function Settings() { const [floatingSidebar] = useGlobalPref('floatingSidebar'); const [budgetName] = useMetadataPref('budgetName'); + const isElectronEnv = isElectron(); // ... (rest of the component code) return ( <Page // ... (other JSX) > <View> {/* ... (other components) */} - {isElectron() && <Backups />} + {isElectronEnv && <Backups />} {/* ... (rest of the JSX) */} </View> </Page> ); }This change would make the code more readable and allow for easier reuse of the
isElectron
check if needed elsewhere in the component.packages/loot-core/src/client/state-types/modals.d.ts (1)
91-94
: LGTM: 'confirm-change-document-dir' modal type added.The addition of the 'confirm-change-document-dir' modal type with
currentBudgetDirectory
andnewDirectory
properties is well-defined and aligns with the PR objective of allowing users to change the data directory.For consistency with other modal types in this file, consider using camelCase for the modal name. Apply this change:
- 'confirm-change-document-dir': { + 'confirmChangeDocumentDir': { currentBudgetDirectory: string; newDirectory: string; };packages/desktop-client/src/components/manager/BudgetList.tsx (2)
337-354
: LGTM: New SettingsButton component looks good.The
SettingsButton
component is well-implemented, using proper React practices and maintaining consistency with other components. It's great to see the use of internationalization and accessibility attributes.Consider extracting the inline styles to a separate object or using a styled-component approach for better maintainability. For example:
const settingsButtonStyle = { padding: 10 }; // Then in the component: <Button variant="bare" aria-label={t('Menu')} onPress={onOpenSettings} style={settingsButtonStyle} > <SvgCog style={{ width: 18, height: 18 }} /> </Button>
Line range hint
356-392
: LGTM: BudgetListHeader updated correctly with new SettingsButton.The
BudgetListHeader
component has been successfully updated to include the newSettingsButton
. The conditional rendering based on the Electron environment is appropriate, and the layout changes improve the organization of the buttons.Consider extracting the inline styles for the button container to a separate object or using a styled-component approach. This would improve readability and maintainability. For example:
const buttonContainerStyle = { flexDirection: 'row' as const, gap: '0.2rem', }; // Then in the component: <View style={buttonContainerStyle}> <RefreshButton onRefresh={onRefresh} /> {isElectron() && <SettingsButton onOpenSettings={onOpenSettings} />} </View>packages/desktop-client/src/components/Modals.tsx (1)
578-587
: LGTM: New modal cases added correctlyThe new case statements for 'files-settings' and 'confirm-change-document-dir' modals are correctly implemented and follow the existing pattern in the switch statement. The props are correctly passed to the
ConfirmChangeDocumentDirModal
component.For consistency with other single-line cases, consider simplifying the 'files-settings' case to a single line:
- case 'files-settings': - return <FilesSettingsModal key={name} />; + case 'files-settings': return <FilesSettingsModal key={name} />;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (2)
upcoming-release-notes/3500.md
is excluded by!**/*.md
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (14)
- packages/desktop-client/src/browser-preload.browser.js (1 hunks)
- packages/desktop-client/src/components/Modals.tsx (2 hunks)
- packages/desktop-client/src/components/manager/BudgetList.tsx (5 hunks)
- packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx (1 hunks)
- packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (1 hunks)
- packages/desktop-client/src/components/settings/Backups.tsx (1 hunks)
- packages/desktop-client/src/components/settings/Global.tsx (0 hunks)
- packages/desktop-client/src/components/settings/index.tsx (3 hunks)
- packages/desktop-electron/index.ts (2 hunks)
- packages/desktop-electron/package.json (2 hunks)
- packages/desktop-electron/preload.ts (1 hunks)
- packages/loot-core/src/client/state-types/modals.d.ts (1 hunks)
- packages/loot-core/src/server/main.ts (2 hunks)
- packages/loot-core/typings/window.d.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (1)
- packages/desktop-client/src/components/settings/Global.tsx
🔇 Additional comments (28)
packages/desktop-client/src/components/settings/Backups.tsx (3)
1-6
: LGTM: Imports are well-organized and necessary.The imports are logically structured, including React core, third-party library (react-i18next), and local components. All imported items are used in the component.
8-27
: LGTM: Component structure is clean and follows best practices.The
Backups
component is well-structured:
- It's a functional component, aligning with modern React patterns.
- It uses composition with
Setting
andText
components, suggesting a consistent UI structure.- The component is properly exported for use in other parts of the application.
1-27
: Overall, excellent implementation of the Backups component.The
Backups
component is well-implemented, adhering to React and TypeScript best practices. It's focused, uses appropriate sub-components, and consistently applies internationalization. The code is clean, readable, and maintainable.A minor suggestion for improvement has been made regarding parameterizing backup details, but this doesn't detract from the overall quality of the implementation.
packages/desktop-electron/preload.ts (2)
Line range hint
1-86
: Overall, the changes look good and align with the PR objectives.The new
moveBudgetDirectory
method is well-integrated into the existing structure of the preload script. It enhances the file management capabilities as intended, without introducing unnecessary complexity.
77-86
: LGTM! ThemoveBudgetDirectory
method is well-implemented.The new method is correctly added to the
Actual
object and properly usesipcRenderer.invoke
for IPC communication. The naming is clear, and the types are correctly specified.To ensure complete implementation, let's verify the corresponding handler in the main process:
This script will help confirm that the main process is prepared to handle the 'move-budget-directory' event.
packages/desktop-electron/package.json (3)
93-93
: LGTM: Addition of fs-extra dependencyThe addition of
fs-extra
(version ^11.2.0) is appropriate for enhancing file system operations. This aligns well with the PR objective of moving budget files when the data directory changes.
102-102
: LGTM: Addition of @types/fs-extra dependencyThe inclusion of
@types/fs-extra
(version ^11) is appropriate for providing TypeScript type definitions. This addition enhances type safety and improves the development experience when working withfs-extra
.
93-93
: Summary: Appropriate additions to enhance file system operationsThe additions of
fs-extra
and@types/fs-extra
are well-justified and align perfectly with the PR objectives. These dependencies will facilitate the implementation of moving budget files when the data directory changes, as outlined in the PR summary. The use of up-to-date versions and the inclusion of TypeScript definitions demonstrate good development practices.Also applies to: 102-102
packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx (3)
1-10
: LGTM: Import statements are well-organized and appropriate.The import statements are logically organized and include all necessary dependencies for the components. Good job on keeping the imports clean and relevant.
36-173
: LGTM: Well-structured component with proper state management and error handling.The
ConfirmChangeDocumentDirModal
component is well-implemented with good use of React hooks for state management. It properly handles loading states, error conditions, and provides clear user feedback. The internationalization support is a great addition for maintaining a multilingual application.
57-80
: Ensure proper security measures when changing directories.When changing directories and moving files, it's crucial to ensure that the application has the necessary permissions and that the operation doesn't pose any security risks. Consider implementing the following security measures:
- Validate the new directory path to prevent potential directory traversal attacks.
- Ensure that the application has the necessary permissions to read from and write to both the old and new directories.
- Implement proper error handling and rollback mechanisms in case the directory change or file move operations fail midway.
- Consider adding a check to ensure that the new directory is not a subdirectory of the old one to prevent potential infinite loops or data corruption.
To help verify these security considerations, you can run the following script:
This script will help identify if these security considerations are already being addressed in the codebase.
packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (5)
1-12
: LGTM: Import statements are appropriate and concise.The import statements are well-organized and include all necessary dependencies for the components in this file. There are no unused imports, which is good for maintaining clean code.
14-81
: LGTM: FileLocationSettings component is well-implemented.The
FileLocationSettings
component is well-structured and follows React best practices. It correctly uses hooks for managing state and preferences, and the UI is styled consistently with the application's theme. The directory selection process is handled asynchronously, which is appropriate for file system operations.
83-135
: LGTM: SelfSignedCertLocationSettings component is well-implemented.The
SelfSignedCertLocationSettings
component is well-structured and follows React best practices. It correctly uses hooks for managing preferences and employs conditional rendering based on the existence of the certificate preference. The UI is styled consistently with the application's theme.
137-183
: LGTM: FilesSettingsModal component is well-implemented.The
FilesSettingsModal
component is well-structured and serves as an effective container for the file settings UI. It correctly uses theuseDispatch
hook for managing actions and implements acloseModal
function that ensures all files are reloaded when the modal is closed, which is good for maintaining data consistency. The component's layout is clear and consistent with the application's theme, incorporating theFileLocationSettings
andSelfSignedCertLocationSettings
components appropriately.
1-183
: Overall, the file is well-implemented and aligns with PR objectives.This new file,
FilesSettingsModal.tsx
, successfully introduces components for managing file settings, which aligns well with the PR objectives of moving file settings to the file management area. The implementation is clean, well-organized, and follows React best practices.Key points:
- The
FileLocationSettings
component allows users to view and change the data directory, as specified in the PR objectives.- The
SelfSignedCertLocationSettings
component provides information about the server's self-signed certificate when applicable.- The
FilesSettingsModal
component serves as a container for these settings, providing a cohesive user interface.The code demonstrates good use of React hooks, consistent styling, and appropriate error handling. While there are a couple of minor issues with unused variables, these do not affect functionality and can be easily addressed.
This implementation lays a solid foundation for the file management enhancements described in the PR objectives.
packages/desktop-client/src/components/settings/index.tsx (3)
5-5
: LGTM: Import path update forisElectron
The import path for
isElectron
has been updated from 'loot-core/src/shared/environment' to 'loot-core/shared/environment'. This change appears to be part of a project restructuring and doesn't affect the functionality.
Line range hint
1-190
: Overall assessment: Changes align well with PR objectivesThe modifications to the
Settings
component successfully integrate the newBackups
functionality for Electron environments while maintaining compatibility with other platforms. The code structure is clean, and the changes are well-implemented.Key points:
- Import statements have been updated appropriately.
- The new
Backups
component is conditionally rendered based on the Electron environment.- The removal of
GlobalSettings
and addition ofBackups
align with the PR objectives.These changes enhance the settings page as described in the PR summary, providing a solid foundation for future improvements to the file management area.
27-27
: LGTM: NewBackups
component import addedThe addition of the
Backups
import aligns with the PR objectives to include information about Electron's backup functionality. This is a good enhancement to the settings page.To ensure the
Backups
component is properly implemented, please run the following script:✅ Verification successful
Verified:
Backups
component correctly implementedThe
Backups
component exists and is properly implemented, providing clear information about the backup functionality as intended. This addition enhances the settings page by informing users about backup frequency and storage details.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of the Backups component # Test: Check if the Backups component file exists fd -t f "Backups.tsx" packages/desktop-client/src/components/settings # Test: Examine the contents of the Backups component fd -t f "Backups.tsx" packages/desktop-client/src/components/settings -x catLength of output: 804
packages/loot-core/src/client/state-types/modals.d.ts (2)
89-90
: LGTM: 'files-settings' modal type added.The addition of the 'files-settings' modal type with a null value is appropriate for a settings modal that doesn't require additional parameters. This aligns with the PR objective of adding file management settings.
89-94
: Summary: New modal types added for file management features.The addition of 'files-settings' and 'confirm-change-document-dir' modal types enhances the type definitions for the new file management features. These changes are minimal, focused, and well-integrated into the existing
FinanceModals
type. They provide proper type safety for the new modals, aligning with the PR objectives of improving file management functionality.packages/desktop-electron/index.ts (1)
21-21
: LGTM: Appropriate import for the new functionality.The import of
copy
andremove
functions fromfs-extra
is correct and necessary for the new budget directory moving feature.packages/desktop-client/src/components/manager/BudgetList.tsx (3)
15-18
: LGTM: Import statements updated correctly.The new imports for
isElectron
,isNonProductionEnvironment
, andSvgCog
are correctly added and necessary for the new functionality.Also applies to: 32-32
469-469
: LGTM: BudgetList component updated correctly.The
BudgetList
component has been properly updated to pass theonOpenSettings
prop toBudgetListHeader
. The use ofpushModal
action to open the 'files-settings' modal is appropriate and consistent with the application's modal management approach.
Line range hint
1-538
: Overall assessment: Changes are well-implemented and align with PR objectives.The modifications to
BudgetList.tsx
successfully introduce the new settings functionality while maintaining code quality and consistency. The newSettingsButton
component and the updates toBudgetListHeader
andBudgetList
components are well-structured and properly integrated.A few minor suggestions have been made for improving code maintainability, primarily related to extracting inline styles. These are not critical issues but could enhance the code's readability and maintainability in the long term.
The changes align well with the PR objectives of moving file settings to the file management area and lay a good foundation for further enhancements.
packages/desktop-client/src/components/Modals.tsx (3)
44-44
: LGTM: Import statement for ConfirmChangeDocumentDirModalThe import statement for the new
ConfirmChangeDocumentDirModal
component is correctly added and follows the existing import pattern in the file.
46-46
: LGTM: Import statement for FilesSettingsModalThe import statement for the new
FilesSettingsModal
component is correctly added and follows the existing import pattern in the file.
44-46
: Summary: New file management modals integrated successfullyThe changes in this file successfully integrate the new
FilesSettingsModal
andConfirmChangeDocumentDirModal
components into the existingModals
component. These additions align well with the PR objectives of enhancing file management capabilities and providing a confirmation step for changing the document directory.The implementation is consistent with the existing code structure and follows established patterns. The new modals are correctly imported and integrated into the switch statement that determines which modal to display.
These changes lay a solid foundation for the file management enhancements described in the PR objectives.
Also applies to: 578-587
packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
Show resolved
Hide resolved
packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/desktop-client/src/components/alerts.tsx (1)
71-71
: Approved: Style override behavior improved, but consider adding documentation.The change to move the spread operator
...style
to the end of the style object is a good improvement. This allows thestyle
prop to override default styles, providing more flexibility for customization.Consider adding a comment or updating the component's documentation to clarify this new behavior. This will help other developers understand that custom styles passed via the
style
prop will now take precedence over the default styles.Example documentation:
/** * Information alert component. * @param {Object} props - The component props. * @param {CSSProperties} [props.style] - Custom styles to apply. These will override default styles. */ export const Information = ({ style, children }: ScopedAlertProps) => { // ... (rest of the component code) };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- packages/desktop-client/src/components/alerts.tsx (1 hunks)
- packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx (1 hunks)
- packages/desktop-client/src/components/settings/Backups.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/desktop-client/src/components/modals/manager/ConfirmChangeDocumentDir.tsx
- packages/desktop-client/src/components/settings/Backups.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/loot-core/src/server/main.ts (1)
1276-1284
: LGTM! Consider adding a comment for clarity.The addition of
serverSelfSignedCert
to the global preferences is a good enhancement for handling secure connections, especially in development or testing environments.Consider adding a brief comment explaining the purpose of the
serverSelfSignedCert
preference for better code documentation:[, serverSelfSignedCert], + // Path to a self-signed certificate for secure server connections ] = await asyncStorage.multiGet([ 'floating-sidebar', 'max-months',
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- packages/desktop-client/src/components/settings/index.tsx (3 hunks)
- packages/desktop-electron/package.json (2 hunks)
- packages/loot-core/src/server/main.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/desktop-client/src/components/settings/index.tsx
- packages/desktop-electron/package.json
🔇 Additional comments (1)
packages/loot-core/src/server/main.ts (1)
1303-1303
: LGTM! Consistent handling of the new preference.The addition of
serverSelfSignedCert
to the returned preferences object is well-implemented. It follows the pattern of other preferences and correctly defaults toundefined
if not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/desktop-electron/index.ts (1)
407-434
: Solid implementation with room for minor improvements.The implementation of the 'move-budget-directory' IPC handler is well-structured and addresses the main concerns raised in the previous review. Good job on the input validation and error handling. Here are a few suggestions for further improvement:
- Consider returning a success message or boolean to indicate successful completion.
- Add a check to ensure the destination directory is empty to prevent unintended overwrites.
- For large directories, implement a progress reporting mechanism to provide feedback to the user during the operation.
Here's a suggested improvement incorporating these points:
ipcMain.handle( 'move-budget-directory', async (_event, currentBudgetDirectory: string, newDirectory: string) => { try { if (!currentBudgetDirectory || !newDirectory) { throw new Error('The from and to directories must be provided'); } if (newDirectory.startsWith(currentBudgetDirectory)) { throw new Error( 'The destination must not be a subdirectory of the current directory', ); } if (!(await exists(newDirectory))) { throw new Error('The destination directory does not exist'); } const destContents = await fs.readdir(newDirectory); if (destContents.length > 0) { throw new Error('The destination directory is not empty'); } await copy(currentBudgetDirectory, newDirectory, { overwrite: true, filter: (src, dest) => { // You can implement progress reporting here console.log(`Copying: ${src}`); return true; }, }); await remove(currentBudgetDirectory); return { success: true, message: 'Budget directory moved successfully' }; } catch (error) { console.error('There was an error moving your directory', error); throw error; } }, );This implementation adds a check for an empty destination directory, includes a basic progress reporting mechanism (which can be enhanced to send progress to the renderer process), and returns a success message.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (2)
- packages/desktop-electron/index.ts (2 hunks)
- packages/desktop-electron/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/desktop-electron/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (4)
1-13
: Consider reordering imports for consistency.The imports are generally well-organized, but there's a minor opportunity for improvement in the order.
Consider moving the import of
SvgPencil1
before the import oftheme
andstyles
to maintain a consistent order:import { useGlobalPref } from '../../../hooks/useGlobalPref'; +import { SvgPencil1 } from '../../../icons/v2'; import { theme, styles } from '../../../style'; import { Button } from '../../common/Button2'; import { Modal, ModalCloseButton, ModalHeader } from '../../common/Modal'; import { Text } from '../../common/Text'; import { View } from '../../common/View'; -import { SvgPencil1 } from '../../../icons/v2';🧰 Tools
🪛 GitHub Check: lint
[warning] 13-13:
../../../icons/v2
import should occur before import of../../../style
15-88
: Well-implemented component with room for enhanced error handling.The
FileLocationSettings
component is well-structured and effectively manages the document directory setting. The use ofuseGlobalPref
for state management and the implementation of the directory selection process are commendable.Consider adding error handling for the file dialog operation:
async function onChooseDocumentDir() { - const chosenDirectory = await window.Actual?.openFileDialog({ - properties: ['openDirectory'], - }); + try { + const chosenDirectory = await window.Actual?.openFileDialog({ + properties: ['openDirectory'], + }); - if (chosenDirectory && documentDir && chosenDirectory[0] !== documentDir) { - setDirChanged(true); + if (chosenDirectory && documentDir && chosenDirectory[0] !== documentDir) { + setDirChanged(true); - dispatch( - pushModal('confirm-change-document-dir', { - currentBudgetDirectory: documentDir, - newDirectory: chosenDirectory[0], - }), - ); + dispatch( + pushModal('confirm-change-document-dir', { + currentBudgetDirectory: documentDir, + newDirectory: chosenDirectory[0], + }), + ); + } + } catch (error) { + console.error('Error selecting directory:', error); + // Consider adding user feedback here, e.g., a toast notification } }This change will help catch and log any errors that might occur during the file dialog operation, improving the robustness of the component.
90-142
: Consider enhancing the SelfSignedCertLocationSettings component.The
SelfSignedCertLocationSettings
component effectively displays the server's self-signed certificate location when applicable. The conditional rendering and styling are well-implemented.Consider the following enhancements to improve user experience and functionality:
- Add a tooltip or info icon that explains the purpose and importance of the self-signed certificate when hovered over.
- Implement a way to verify the certificate's validity or expiration date.
- Provide a button to regenerate the certificate if it's expired or invalid.
Here's a conceptual example of how you might implement the first suggestion:
import { Tooltip } from '../../common/Tooltip'; // Assume this component exists // Inside the component's JSX <Text> <strong> <Trans>Server self-signed certificate</Trans> </strong>{' '} <Tooltip content={<Trans>This certificate ensures a secure connection between the client and server.</Trans>}> <span style={{ cursor: 'help' }}>ℹ️</span> </Tooltip> </Text>These enhancements would provide users with more information and control over the self-signed certificate, improving overall security awareness and management.
144-190
: Well-structured modal component with a minor suggestion for improvement.The
FilesSettingsModal
component is well-implemented, providing a cohesive container for the file settings. The use of Redux for state management and the overall structure of the modal are commendable.Consider renaming the "OK" button to "Save" or "Apply" to more accurately reflect its action:
<Button variant="primary" style={{ padding: '10px 30px', fontSize: 14, alignSelf: 'center', }} onPress={() => closeModal(close)} > - <Trans>OK</Trans> + <Trans>Save</Trans> </Button>This change would make it clearer to users that their settings will be saved when they dismiss the modal.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (1)
- packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (1 hunks)
🧰 Additional context used
🪛 GitHub Check: lint
packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx
[warning] 13-13:
../../../icons/v2
import should occur before import of../../../style
🔇 Additional comments (1)
packages/desktop-client/src/components/modals/manager/FilesSettingsModal.tsx (1)
1-190
: Summary: Well-implemented file settings modal aligning with PR objectives.This new file successfully implements the file settings modal as described in the PR objectives. The components work together seamlessly to provide users with the ability to manage file locations and view certificate information. The implementation aligns well with the goal of moving file settings to the file management area.
Key strengths:
- Proper use of React hooks and Redux for state management.
- Consistent styling and layout across components.
- Implementation of file dialog for changing the document directory.
- Conditional rendering of certificate information based on user preferences.
The suggested improvements, if implemented, would further enhance the robustness, user experience, and clarity of the file settings functionality.
Overall, this implementation provides a solid foundation for the file management enhancements described in the PR objectives.
🧰 Tools
🪛 GitHub Check: lint
[warning] 13-13:
../../../icons/v2
import should occur before import of../../../style
This is step 1 to resolving this issue: #3371
Step 2 is to allow configuration before creating a budget (will tackle that in a follow up PR).
Changing the data directory
Settings page (if electron):
Tested on: