mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-03 00:13:09 +00:00
fix: open Save to Files with My files selected so Save here works right away
This commit is contained in:
@@ -48,4 +48,18 @@ describe('SaveToFilesDialog', () => {
|
||||
await waitFor(() => expect(createFileNode).toHaveBeenCalledWith('invoice.pdf', 'blob-mine', 'application/pdf', 1234, 'docs'));
|
||||
expect(copyBlobs).toHaveBeenCalledWith('team', ['blob-1'], 'me');
|
||||
});
|
||||
|
||||
// "Save here" was greyed out until My files was clicked, with nothing on
|
||||
// screen saying why.
|
||||
it('starts with My files selected, so Save here saves there right away', async () => {
|
||||
const createFileNode = vi.fn().mockResolvedValue({});
|
||||
const client = { listAllFileNodes: vi.fn().mockResolvedValue(nodes), createFileNode } as unknown as IJMAPClient;
|
||||
render(<SaveToFilesDialog attachment={attachment} client={client} onClose={vi.fn()} />);
|
||||
|
||||
await screen.findByText('Documents');
|
||||
const saveHere = screen.getByRole('button', { name: 'save_here' }) as HTMLButtonElement;
|
||||
expect(saveHere.disabled).toBe(false);
|
||||
fireEvent.click(saveHere);
|
||||
await waitFor(() => expect(createFileNode).toHaveBeenCalledWith('invoice.pdf', 'blob-1', 'application/pdf', 1234, null));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,6 +101,8 @@ export function SaveToFilesDialog({ attachment, client, blobAccountId, onClose }
|
||||
confirmText={t("save_here")}
|
||||
folders={folders}
|
||||
currentId={NO_CURRENT_FOLDER}
|
||||
// My files, ready to take it: Save here works without a pick first.
|
||||
initialSelectedId={null}
|
||||
onPick={(parentId) => void save(parentId)}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -26,6 +26,8 @@ interface FolderPickerDialogProps {
|
||||
excludeIds?: Set<string>;
|
||||
/** The folder that is pre-selected and can't be picked (where the items already are). */
|
||||
currentId?: string | null;
|
||||
/** A folder selected and ready to pick when the dialog opens; null is My files. */
|
||||
initialSelectedId?: string | null;
|
||||
}
|
||||
|
||||
const ROOT = "";
|
||||
@@ -35,10 +37,12 @@ const ROOT = "";
|
||||
* tree with My files at the top, browsed with the mouse or the arrow keys.
|
||||
*/
|
||||
export function FolderPickerDialog({
|
||||
isOpen, onClose, onPick, title, confirmText, folders, excludeIds, currentId = null,
|
||||
isOpen, onClose, onPick, title, confirmText, folders, excludeIds, currentId = null, initialSelectedId,
|
||||
}: FolderPickerDialogProps) {
|
||||
const t = useTranslations("files");
|
||||
const [selected, setSelected] = useState<string | null>(null);
|
||||
const [selected, setSelected] = useState<string | null>(
|
||||
initialSelectedId === undefined ? null : (initialSelectedId ?? ROOT),
|
||||
);
|
||||
const [expanded, setExpanded] = useState<Set<string>>(() => new Set([ROOT]));
|
||||
const listRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user