Skip to content

Commit

Permalink
move feature to data tab
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkav committed Jun 13, 2023
1 parent c52acf9 commit 72f0ebf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
39 changes: 2 additions & 37 deletions packages/insomnia/src/ui/components/settings/general.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, Fragment, useEffect } from 'react';
import React, { FC, Fragment } from 'react';
import { useSelector } from 'react-redux';

import {
Expand All @@ -18,7 +18,6 @@ import * as models from '../../../models';
import { initNewOAuthSession } from '../../../network/o-auth-2/misc';
import { selectSettings, selectStats } from '../../redux/selectors';
import { Link } from '../base/link';
import { PromptButton } from '../base/prompt-button';
import { CheckForUpdatesButton } from '../check-for-updates-button';
import { HelpTooltip } from '../help-tooltip';
import { Tooltip } from '../tooltip';
Expand Down Expand Up @@ -77,14 +76,7 @@ const DevelopmentOnlySettings: FC = () => {

export const General: FC = () => {
const settings = useSelector(selectSettings);
const [backupTime, setBackupTime] = React.useState('');
useEffect(() => {
const fn = async () => {
const t = await window.main.getLatestBackupTime();
setBackupTime(t);
};
fn();
}, []);

return (
<div className="pad-bottom">
<div className="row-fill row-fill--top">
Expand Down Expand Up @@ -354,33 +346,6 @@ export const General: FC = () => {
disabled={!settings.proxyEnabled}
/>
</div>
<Fragment>
<hr className="pad-top" />
<div>
<h2>Backup and Restore</h2>
<label>{backupTime}</label>
<div className="pull-right">
<button
className="btn btn--clicky pointer"
onClick={async () => {
await window.main.overwriteLatestBackup();
const t = await window.main.getLatestBackupTime();
setBackupTime(t);
}}
>
Backup
</button>
<PromptButton
className="btn btn--clicky pointer"
onClick={() => {
window.main.restoreLatestBackup();
}}
>
Restore
</PromptButton>
</div>
</div>
</Fragment>
{updatesSupported() && (
<Fragment>
<hr className="pad-top" />
Expand Down
39 changes: 38 additions & 1 deletion packages/insomnia/src/ui/components/settings/import-export.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, Fragment, useCallback, useState } from 'react';
import React, { FC, Fragment, useCallback, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';

Expand All @@ -12,6 +12,7 @@ import { importers } from '../../../utils/importers/importers';
import { selectActiveProjectName, selectActiveWorkspace, selectActiveWorkspaceName, selectWorkspaceRequestsAndRequestGroups, selectWorkspacesForActiveProject } from '../../redux/selectors';
import { Dropdown, DropdownButton, DropdownItem, DropdownSection, ItemContent } from '../base/dropdown';
import { Link } from '../base/link';
import { PromptButton } from '../base/prompt-button';
import { AlertModal } from '../modals/alert-modal';
import { ExportRequestsModal } from '../modals/export-requests-modal';
import { ImportModal } from '../modals/import-modal';
Expand Down Expand Up @@ -52,6 +53,15 @@ export const ImportExport: FC<Props> = ({ hideSettingsModal }) => {
hideSettingsModal();
}, [hideSettingsModal, projectName, workspacesForActiveProject]);

const [backupTime, setBackupTime] = React.useState('');
useEffect(() => {
const fn = async () => {
const t = await window.main.getLatestBackupTime();
setBackupTime(t);
};
fn();
}, []);

return (
<Fragment>
<div data-testid="import-export-tab">
Expand Down Expand Up @@ -120,6 +130,33 @@ export const ImportExport: FC<Props> = ({ hideSettingsModal }) => {
defaultWorkspaceId={workspaceId}
/>
)}
<Fragment>
<hr className="pad-top" />
<div>
<h2>Backup and Restore</h2>
<label>{backupTime}</label>
<div className="pull-right">
<button
className="btn btn--clicky pointer margin-right-sm"
onClick={async () => {
await window.main.overwriteLatestBackup();
const t = await window.main.getLatestBackupTime();
setBackupTime(t);
}}
>
Backup
</button>
<PromptButton
className="btn btn--clicky pointer"
onClick={() => {
window.main.restoreLatestBackup();
}}
>
Restore
</PromptButton>
</div>
</div>
</Fragment>
</Fragment>
);
};

0 comments on commit 72f0ebf

Please sign in to comment.