Try sandboxing again

This commit is contained in:
Gregory Schier
2023-11-19 17:06:31 -08:00
parent 5c3f1af87b
commit ed1427d421
8 changed files with 34 additions and 25 deletions

View File

@@ -1,7 +1,6 @@
import classNames from 'classnames';
import React, { memo } from 'react';
import { useActiveRequest } from '../hooks/useActiveRequest';
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
import { Icon } from './core/Icon';
import { IconButton } from './core/IconButton';
import { HStack } from './core/Stacks';
@@ -17,7 +16,6 @@ interface Props {
export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Props) {
const activeRequest = useActiveRequest();
const activeWorkspace = useActiveWorkspace();
return (
<HStack
@@ -29,13 +27,7 @@ export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Prop
<HStack space={0.5} className="flex-1 pointer-events-none" alignItems="center">
<SidebarActions />
<HStack alignItems="center">
<WorkspaceActionsDropdown
leftSlot={
<div className="w-4 h-4 leading-4 rounded text-[0.8em] bg-[#1B88DE] bg-opacity-80 text-white mr-1">
{activeWorkspace?.name[0]?.toUpperCase()}
</div>
}
/>
<WorkspaceActionsDropdown />
<Icon icon="chevronRight" className="text-gray-900 text-opacity-disabled" />
<EnvironmentActionsDropdown className="w-auto pointer-events-auto" />
</HStack>

View File

@@ -1,17 +1,12 @@
import { useMutation } from '@tanstack/react-query';
import { invoke } from '@tauri-apps/api';
import type { SaveDialogOptions } from '@tauri-apps/api/dialog';
import { save } from '@tauri-apps/api/dialog';
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
import slugify from 'slugify';
import { useActiveWorkspace } from './useActiveWorkspace';
import { useAlert } from './useAlert';
const saveArgs: SaveDialogOptions = {
title: 'Export Data',
defaultPath: 'yaak-export.json',
};
export function useExportData() {
const workspaceId = useActiveWorkspaceId();
const workspace = useActiveWorkspace();
const alert = useAlert();
return useMutation({
@@ -19,12 +14,18 @@ export function useExportData() {
alert({ title: 'Export Failed', body: err });
},
mutationFn: async () => {
const exportPath = await save(saveArgs);
if (workspace == null) return;
const workspaceSlug = slugify(workspace.name, { lower: true });
const exportPath = await save({
title: 'Export Data',
defaultPath: `yaak.${workspaceSlug}.json`,
});
if (exportPath == null) {
return;
}
await invoke('export_data', { workspaceId, exportPath });
await invoke('export_data', { workspaceId: workspace.id, exportPath });
},
});
}