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';
@@ -9,52 +9,63 @@ import { Modal } from '../common/Modal';
import { Text } from '../common/Text';
import { View } from '../common/View';
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 {
state = { hoveredBackup: null };
type LoadBackupProps = {
backups: Backup[];
onSelect: (id) => void;
};
onHover = id => {
this.setState({ hoveredBackup: id });
function BackupTable({ backups, onSelect }: LoadBackupProps) {
const [hoveredBackup, setHoveredBackup] = useState(null);
const onHover = id => {
setHoveredBackup(id);
};
render() {
const { backups, onSelect } = this.props;
const { hoveredBackup } = this.state;
return (
<View
style={{ flex: 1, maxHeight: 200, overflow: 'auto' }}
onMouseLeave={() => this.onHover(null)}
>
{backups.map((backup, idx) => (
<Row
key={backup.id}
collapsed={idx !== 0}
focused={hoveredBackup === backup.id}
onMouseEnter={() => this.onHover(backup.id)}
onClick={() => onSelect(backup.id)}
style={{ cursor: 'pointer' }}
>
<Cell
width="flex"
value={backup.date ? backup.date : 'Revert to Latest'}
valueStyle={{ paddingLeft: 20 }}
/>
</Row>
))}
</View>
);
}
return (
<View
style={{ flex: 1, maxHeight: 200, overflow: 'auto' }}
onMouseLeave={() => onHover(null)}
>
{backups.map((backup, idx) => (
<Row
key={backup.id}
collapsed={idx !== 0}
focused={hoveredBackup === backup.id}
onMouseEnter={() => onHover(backup.id)}
onClick={() => onSelect(backup.id)}
style={{ cursor: 'pointer' }}
>
<Cell
width="flex"
value={backup.date ? backup.date : 'Revert to Latest'}
valueStyle={{ paddingLeft: 20 }}
/>
</Row>
))}
</View>
);
}
type LoadBackupProps = {
budgetId: string;
watchUpdates: boolean;
backupDisabled: boolean;
actions: BoundActions;
modalProps: CommonModalProps;
};
export function LoadBackup({
budgetId,
watchUpdates,
backupDisabled,
actions,
modalProps,
}) {
const [backups, setBackups] = useState([]);
}: LoadBackupProps) {
const [backups, setBackups] = useState<Backup>([]);
useEffect(() => {
send('backups-get', { id: budgetId }).then(setBackups);

View File

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