mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-18 01:19:24 +00:00
Data drive Sanitize and Remove Password
This commit is contained in:
parent
a16ee308e5
commit
5be766121a
@ -1,20 +0,0 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TooltipContent } from '../../types/tips';
|
||||
|
||||
export const useRemovePasswordTips = (): TooltipContent => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return {
|
||||
header: {
|
||||
title: t("removePassword.title", "Remove Password")
|
||||
},
|
||||
tips: [
|
||||
{
|
||||
description: t(
|
||||
"removePassword.tooltip.description",
|
||||
"Removing password protection requires the current password that was used to encrypt the PDF. This will decrypt the document, making it accessible without a password."
|
||||
)
|
||||
}
|
||||
]
|
||||
};
|
||||
};
|
@ -1,61 +1,12 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||
import RemovePasswordSettings from "../components/tools/removePassword/RemovePasswordSettings";
|
||||
import { useRemovePasswordParameters } from "../hooks/tools/removePassword/useRemovePasswordParameters";
|
||||
import { useRemovePasswordOperation } from "../hooks/tools/removePassword/useRemovePasswordOperation";
|
||||
import { useRemovePasswordTips } from "../components/tooltips/useRemovePasswordTips";
|
||||
import { useBaseTool } from "../hooks/tools/shared/useBaseTool";
|
||||
import { BaseToolProps, ToolComponent } from "../types/tool";
|
||||
import GenericTool from '../components/tools/shared/GenericTool';
|
||||
import { removePasswordDefinition } from './definitions/removePasswordDefinition';
|
||||
import { BaseToolProps, ToolComponent } from '../types/tool';
|
||||
|
||||
const RemovePassword = (props: BaseToolProps) => {
|
||||
const { t } = useTranslation();
|
||||
const removePasswordTips = useRemovePasswordTips();
|
||||
|
||||
const base = useBaseTool(
|
||||
'removePassword',
|
||||
useRemovePasswordParameters,
|
||||
useRemovePasswordOperation,
|
||||
props
|
||||
);
|
||||
|
||||
return createToolFlow({
|
||||
files: {
|
||||
selectedFiles: base.selectedFiles,
|
||||
isCollapsed: base.hasResults,
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
title: t("removePassword.password.stepTitle", "Remove Password"),
|
||||
isCollapsed: base.settingsCollapsed,
|
||||
onCollapsedClick: base.hasResults ? base.handleSettingsReset : undefined,
|
||||
tooltip: removePasswordTips,
|
||||
content: (
|
||||
<RemovePasswordSettings
|
||||
parameters={base.params.parameters}
|
||||
onParameterChange={base.params.updateParameter}
|
||||
disabled={base.endpointLoading}
|
||||
/>
|
||||
),
|
||||
},
|
||||
],
|
||||
executeButton: {
|
||||
text: t("removePassword.submit", "Remove Password"),
|
||||
isVisible: !base.hasResults,
|
||||
loadingText: t("loading"),
|
||||
onClick: base.handleExecute,
|
||||
disabled: !base.params.validateParameters() || !base.hasFiles || !base.endpointEnabled,
|
||||
},
|
||||
review: {
|
||||
isVisible: base.hasResults,
|
||||
operation: base.operation,
|
||||
title: t("removePassword.results.title", "Decrypted PDFs"),
|
||||
onFileClick: base.handleThumbnailClick,
|
||||
onUndo: base.handleUndo,
|
||||
},
|
||||
});
|
||||
return <GenericTool definition={removePasswordDefinition} {...props} />;
|
||||
};
|
||||
|
||||
// Static method to get the operation hook for automation
|
||||
RemovePassword.tool = () => useRemovePasswordOperation;
|
||||
RemovePassword.tool = () => removePasswordDefinition.useOperation;
|
||||
|
||||
export default RemovePassword as ToolComponent;
|
||||
|
@ -1,59 +1,12 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { createToolFlow } from "../components/tools/shared/createToolFlow";
|
||||
import SanitizeSettings from "../components/tools/sanitize/SanitizeSettings";
|
||||
import { useSanitizeParameters } from "../hooks/tools/sanitize/useSanitizeParameters";
|
||||
import { useSanitizeOperation } from "../hooks/tools/sanitize/useSanitizeOperation";
|
||||
import { useBaseTool } from "../hooks/tools/shared/useBaseTool";
|
||||
import { BaseToolProps, ToolComponent } from "../types/tool";
|
||||
import GenericTool from '../components/tools/shared/GenericTool';
|
||||
import { sanitizeDefinition } from './definitions/sanitizeDefinition';
|
||||
import { BaseToolProps, ToolComponent } from '../types/tool';
|
||||
|
||||
const Sanitize = (props: BaseToolProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const base = useBaseTool(
|
||||
'sanitize',
|
||||
useSanitizeParameters,
|
||||
useSanitizeOperation,
|
||||
props
|
||||
);
|
||||
|
||||
return createToolFlow({
|
||||
files: {
|
||||
selectedFiles: base.selectedFiles,
|
||||
isCollapsed: base.hasResults,
|
||||
placeholder: t("sanitize.files.placeholder", "Select a PDF file in the main view to get started"),
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
title: t("sanitize.steps.settings", "Settings"),
|
||||
isCollapsed: base.settingsCollapsed,
|
||||
onCollapsedClick: base.settingsCollapsed ? base.handleSettingsReset : undefined,
|
||||
content: (
|
||||
<SanitizeSettings
|
||||
parameters={base.params.parameters}
|
||||
onParameterChange={base.params.updateParameter}
|
||||
disabled={base.endpointLoading}
|
||||
/>
|
||||
),
|
||||
},
|
||||
],
|
||||
executeButton: {
|
||||
text: t("sanitize.submit", "Sanitize PDF"),
|
||||
isVisible: !base.hasResults,
|
||||
loadingText: t("loading"),
|
||||
onClick: base.handleExecute,
|
||||
disabled: !base.params.validateParameters() || !base.hasFiles || !base.endpointEnabled,
|
||||
},
|
||||
review: {
|
||||
isVisible: base.hasResults,
|
||||
operation: base.operation,
|
||||
title: t("sanitize.sanitizationResults", "Sanitization Results"),
|
||||
onFileClick: base.handleThumbnailClick,
|
||||
onUndo: base.handleUndo,
|
||||
},
|
||||
});
|
||||
return <GenericTool definition={sanitizeDefinition} {...props} />;
|
||||
};
|
||||
|
||||
// Static method to get the operation hook for automation
|
||||
Sanitize.tool = () => useSanitizeOperation;
|
||||
Sanitize.tool = () => sanitizeDefinition.useOperation;
|
||||
|
||||
export default Sanitize as ToolComponent;
|
||||
|
41
frontend/src/tools/definitions/removePasswordDefinition.ts
Normal file
41
frontend/src/tools/definitions/removePasswordDefinition.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { ToolDefinition } from '../../components/tools/shared/toolDefinition';
|
||||
import { RemovePasswordParameters, useRemovePasswordParameters } from '../../hooks/tools/removePassword/useRemovePasswordParameters';
|
||||
import { useRemovePasswordOperation } from '../../hooks/tools/removePassword/useRemovePasswordOperation';
|
||||
import RemovePasswordSettings from '../../components/tools/removePassword/RemovePasswordSettings';
|
||||
|
||||
export const removePasswordDefinition: ToolDefinition<RemovePasswordParameters> = {
|
||||
id: 'removePassword',
|
||||
|
||||
useParameters: useRemovePasswordParameters,
|
||||
useOperation: useRemovePasswordOperation,
|
||||
|
||||
steps: [
|
||||
{
|
||||
key: 'settings',
|
||||
title: (t) => t("removePassword.password.stepTitle", "Remove Password"),
|
||||
component: RemovePasswordSettings,
|
||||
tooltip: (t) => ({
|
||||
header: {
|
||||
title: t("removePassword.title", "Remove Password")
|
||||
},
|
||||
tips: [
|
||||
{
|
||||
description: t(
|
||||
"removePassword.tooltip.description",
|
||||
"Removing password protection requires the current password that was used to encrypt the PDF. This will decrypt the document, making it accessible without a password."
|
||||
)
|
||||
}
|
||||
]
|
||||
}),
|
||||
},
|
||||
],
|
||||
|
||||
executeButton: {
|
||||
text: (t) => t("removePassword.submit", "Remove Password"),
|
||||
loadingText: (t) => t("loading"),
|
||||
},
|
||||
|
||||
review: {
|
||||
title: (t) => t("removePassword.results.title", "Decrypted PDFs"),
|
||||
},
|
||||
};
|
28
frontend/src/tools/definitions/sanitizeDefinition.ts
Normal file
28
frontend/src/tools/definitions/sanitizeDefinition.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { ToolDefinition } from '../../components/tools/shared/toolDefinition';
|
||||
import { SanitizeParameters, useSanitizeParameters } from '../../hooks/tools/sanitize/useSanitizeParameters';
|
||||
import { useSanitizeOperation } from '../../hooks/tools/sanitize/useSanitizeOperation';
|
||||
import SanitizeSettings from '../../components/tools/sanitize/SanitizeSettings';
|
||||
|
||||
export const sanitizeDefinition: ToolDefinition<SanitizeParameters> = {
|
||||
id: 'sanitize',
|
||||
|
||||
useParameters: useSanitizeParameters,
|
||||
useOperation: useSanitizeOperation,
|
||||
|
||||
steps: [
|
||||
{
|
||||
key: 'settings',
|
||||
title: (t) => t("sanitize.steps.settings", "Settings"),
|
||||
component: SanitizeSettings,
|
||||
},
|
||||
],
|
||||
|
||||
executeButton: {
|
||||
text: (t) => t("sanitize.submit", "Sanitize PDF"),
|
||||
loadingText: (t) => t("loading"),
|
||||
},
|
||||
|
||||
review: {
|
||||
title: (t) => t("sanitize.sanitizationResults", "Sanitization Results"),
|
||||
},
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user