mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Add selection and export for all list pages (#873)
* Include studios in movie export * Generalise cards * Add selection and export for movies * Refactor gallery card * Refactor export dialogs * Add performer selection and export * Add selection and export for studios * Add selection and export of tags * Include movie scenes and gallery images
This commit is contained in:
70
ui/v2.5/src/components/Shared/ExportDialog.tsx
Normal file
70
ui/v2.5/src/components/Shared/ExportDialog.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import React, { useState } from "react";
|
||||
import { Form } from "react-bootstrap";
|
||||
import { mutateExportObjects } from "src/core/StashService";
|
||||
import { Modal } from "src/components/Shared";
|
||||
import { useToast } from "src/hooks";
|
||||
import { downloadFile } from "src/utils";
|
||||
import { ExportObjectsInput } from "src/core/generated-graphql";
|
||||
|
||||
interface IExportDialogProps {
|
||||
exportInput: ExportObjectsInput;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const ExportDialog: React.FC<IExportDialogProps> = (
|
||||
props: IExportDialogProps
|
||||
) => {
|
||||
const [includeDependencies, setIncludeDependencies] = useState(true);
|
||||
|
||||
// Network state
|
||||
const [isRunning, setIsRunning] = useState(false);
|
||||
|
||||
const Toast = useToast();
|
||||
|
||||
async function onExport() {
|
||||
try {
|
||||
setIsRunning(true);
|
||||
const ret = await mutateExportObjects({
|
||||
...props.exportInput,
|
||||
includeDependencies,
|
||||
});
|
||||
|
||||
// download the result
|
||||
if (ret.data && ret.data.exportObjects) {
|
||||
const link = ret.data.exportObjects;
|
||||
downloadFile(link);
|
||||
}
|
||||
} catch (e) {
|
||||
Toast.error(e);
|
||||
} finally {
|
||||
setIsRunning(false);
|
||||
props.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
show
|
||||
icon="cogs"
|
||||
header="Export"
|
||||
accept={{ onClick: onExport, text: "Export" }}
|
||||
cancel={{
|
||||
onClick: () => props.onClose(),
|
||||
text: "Cancel",
|
||||
variant: "secondary",
|
||||
}}
|
||||
isRunning={isRunning}
|
||||
>
|
||||
<Form>
|
||||
<Form.Group>
|
||||
<Form.Check
|
||||
id="include-dependencies"
|
||||
checked={includeDependencies}
|
||||
label="Include related objects in export"
|
||||
onChange={() => setIncludeDependencies(!includeDependencies)}
|
||||
/>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user