insomnia/packages/insomnia-app/app/ui/components/panes/placeholder-request-pane.tsx

79 lines
2.6 KiB
TypeScript
Raw Normal View History

2021-07-14 00:10:49 +00:00
import React, { FC, useCallback } from 'react';
2021-07-22 23:04:56 +00:00
import { useDispatch, useSelector } from 'react-redux';
import { hotKeyRefs } from '../../../common/hotkeys';
import { ForceToWorkspace } from '../../redux/modules/helpers';
2021-07-14 00:10:49 +00:00
import { importFile } from '../../redux/modules/import';
import { selectActiveWorkspace, selectSettings } from '../../redux/selectors';
import { Hotkey } from '../hotkey';
2021-07-22 23:04:56 +00:00
import { Pane, PaneBody, PaneHeader } from './pane';
interface Props {
handleCreateRequest: () => void;
}
export const PlaceholderRequestPane: FC<Props> = ({
handleCreateRequest,
2021-07-14 00:10:49 +00:00
}) => {
const dispatch = useDispatch();
const { hotKeyRegistry } = useSelector(selectSettings);
2021-07-14 00:10:49 +00:00
const workspaceId = useSelector(selectActiveWorkspace)?._id;
const handleImportFile = useCallback(() => dispatch(importFile({ workspaceId, forceToWorkspace: ForceToWorkspace.current })), [workspaceId, dispatch]);
2021-07-14 00:10:49 +00:00
return (
<Pane type="request">
<PaneHeader />
<PaneBody placeholder>
<div>
<table className="table--fancy">
<tbody>
<tr>
<td>New Request</td>
<td className="text-right">
<code>
<Hotkey
keyBindings={hotKeyRegistry[hotKeyRefs.REQUEST_SHOW_CREATE.id]}
2021-08-07 08:03:56 +00:00
useFallbackMessage
/>
2021-07-14 00:10:49 +00:00
</code>
</td>
</tr>
<tr>
<td>Switch Requests</td>
<td className="text-right">
<code>
<Hotkey
keyBindings={hotKeyRegistry[hotKeyRefs.REQUEST_QUICK_SWITCH.id]}
2021-08-07 08:03:56 +00:00
useFallbackMessage
/>
2021-07-14 00:10:49 +00:00
</code>
</td>
</tr>
<tr>
<td>Edit Environments</td>
<td className="text-right">
<code>
<Hotkey
keyBindings={hotKeyRegistry[hotKeyRefs.ENVIRONMENT_SHOW_EDITOR.id]}
2021-08-07 08:03:56 +00:00
useFallbackMessage
/>
2021-07-14 00:10:49 +00:00
</code>
</td>
</tr>
</tbody>
</table>
<div className="text-center pane__body--placeholder__cta">
<button className="btn inline-block btn--clicky" onClick={handleImportFile}>
2021-07-29 15:52:17 +00:00
Import from File
2021-07-14 00:10:49 +00:00
</button>
<button className="btn inline-block btn--clicky" onClick={handleCreateRequest}>
2021-07-29 15:52:17 +00:00
New Request
2021-07-14 00:10:49 +00:00
</button>
</div>
</div>
2021-07-14 00:10:49 +00:00
</PaneBody>
</Pane>
);
};