Compare commits

...

2 Commits

Author SHA1 Message Date
Joel Jeremy Marquez
8e71dcccd8 Release notes 2024-01-28 23:49:56 -08:00
Joel Jeremy Marquez
de9a1880a7 Migrate LoadBackup to ts 2024-01-28 23:49:10 -08:00
2 changed files with 52 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
import React, { Component, useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { send, listen, unlisten } from 'loot-core/src/platform/client/fetch'; import { send, listen, unlisten } from 'loot-core/src/platform/client/fetch';
@@ -9,29 +9,33 @@ import { Modal } from '../common/Modal';
import { Text } from '../common/Text'; import { Text } from '../common/Text';
import { View } from '../common/View'; import { View } from '../common/View';
import { Row, Cell } from '../table'; import { Row, Cell } from '../table';
import { Backup } from 'loot-core/server/backups';
import { CommonModalProps } from '../../types/modals';
import { BoundActions } from '../../hooks/useActions';
class BackupTable extends Component { type LoadBackupProps = {
state = { hoveredBackup: null }; backups: Backup[];
onSelect: (id) => void;
};
onHover = id => { function BackupTable({ backups, onSelect }: LoadBackupProps) {
this.setState({ hoveredBackup: id }); const [hoveredBackup, setHoveredBackup] = useState(null);
const onHover = id => {
setHoveredBackup(id);
}; };
render() {
const { backups, onSelect } = this.props;
const { hoveredBackup } = this.state;
return ( return (
<View <View
style={{ flex: 1, maxHeight: 200, overflow: 'auto' }} style={{ flex: 1, maxHeight: 200, overflow: 'auto' }}
onMouseLeave={() => this.onHover(null)} onMouseLeave={() => onHover(null)}
> >
{backups.map((backup, idx) => ( {backups.map((backup, idx) => (
<Row <Row
key={backup.id} key={backup.id}
collapsed={idx !== 0} collapsed={idx !== 0}
focused={hoveredBackup === backup.id} focused={hoveredBackup === backup.id}
onMouseEnter={() => this.onHover(backup.id)} onMouseEnter={() => onHover(backup.id)}
onClick={() => onSelect(backup.id)} onClick={() => onSelect(backup.id)}
style={{ cursor: 'pointer' }} style={{ cursor: 'pointer' }}
> >
@@ -44,17 +48,24 @@ class BackupTable extends Component {
))} ))}
</View> </View>
); );
}
} }
type LoadBackupProps = {
budgetId: string;
watchUpdates: boolean;
backupDisabled: boolean;
actions: BoundActions;
modalProps: CommonModalProps;
};
export function LoadBackup({ export function LoadBackup({
budgetId, budgetId,
watchUpdates, watchUpdates,
backupDisabled, backupDisabled,
actions, actions,
modalProps, modalProps,
}) { }: LoadBackupProps) {
const [backups, setBackups] = useState([]); const [backups, setBackups] = useState<Backup>([]);
useEffect(() => { useEffect(() => {
send('backups-get', { id: budgetId }).then(setBackups); send('backups-get', { id: budgetId }).then(setBackups);

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [joel-jeremy]
---
Migrate LoadBackup to ts