FilesSelectedIndicator

This commit is contained in:
Connor Yoh 2025-08-20 11:24:30 +01:00
parent f1cb8ce5b3
commit fa60de51f9
11 changed files with 25 additions and 21 deletions

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from "react";
import { Text } from '@mantine/core'; import { Text } from "@mantine/core";
import { useTranslation } from "react-i18next";
export interface FileStatusIndicatorProps { export interface FileStatusIndicatorProps {
selectedFiles?: File[]; selectedFiles?: File[];
@ -8,20 +9,25 @@ export interface FileStatusIndicatorProps {
const FileStatusIndicator = ({ const FileStatusIndicator = ({
selectedFiles = [], selectedFiles = [],
placeholder = "Select a PDF file in the main view to get started" placeholder,
}: FileStatusIndicatorProps) => { }: FileStatusIndicatorProps) => {
const { t } = useTranslation();
const defaultPlaceholder = placeholder || t("files.placeholder", "Select a PDF file in the main view to get started");
// Only show content when no files are selected // Only show content when no files are selected
if (selectedFiles.length === 0) { if (selectedFiles.length === 0) {
return ( return (
<Text size="sm" c="dimmed"> <Text size="sm" c="dimmed">
{placeholder} {defaultPlaceholder}
</Text> </Text>
); );
} }
// Return nothing when files are selected return (
return null; <Text size="sm" c="dimmed" style={{ wordBreak: 'break-word', whiteSpace: 'normal' }}>
} {selectedFiles.length === 1 ? t("fileSelected", "Selected: {{filename}}", { filename: selectedFiles[0]?.name }) : t("filesSelected", "{{count}} files selected", { count: selectedFiles.length })}
</Text>
);
};
export default FileStatusIndicator; export default FileStatusIndicator;

View File

@ -68,7 +68,7 @@ const AddPassword = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
}, },
steps: [ steps: [
{ {

View File

@ -189,7 +189,7 @@ const AddWatermark = ({ onPreviewFile, onComplete, onError }: BaseToolProps) =>
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
}, },
steps: getSteps(), steps: getSteps(),
executeButton: { executeButton: {

View File

@ -64,7 +64,7 @@ const ChangePermissions = ({ onPreviewFile, onComplete, onError }: BaseToolProps
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
}, },
steps: [ steps: [
{ {

View File

@ -62,7 +62,7 @@ const Compress = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles && !hasResults, isCollapsed: hasResults,
}, },
steps: [ steps: [
{ {

View File

@ -97,7 +97,7 @@ const Convert = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: filesCollapsed, isCollapsed: hasResults,
placeholder: t("convert.selectFilesPlaceholder", "Select files in the main view to get started"), placeholder: t("convert.selectFilesPlaceholder", "Select files in the main view to get started"),
}, },
steps: [ steps: [

View File

@ -80,7 +80,7 @@ const OCR = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
}, },
steps: [ steps: [
{ {

View File

@ -62,7 +62,7 @@ const RemovePassword = ({ onPreviewFile, onComplete, onError }: BaseToolProps) =
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
}, },
steps: [ steps: [
{ {

View File

@ -57,7 +57,7 @@ const Repair = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: hasFiles || hasResults, isCollapsed: hasResults,
placeholder: t("repair.files.placeholder", "Select a PDF file in the main view to get started"), placeholder: t("repair.files.placeholder", "Select a PDF file in the main view to get started"),
}, },
steps: [], steps: [],
@ -77,4 +77,4 @@ const Repair = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
}); });
}; };
export default Repair; export default Repair;

View File

@ -55,13 +55,12 @@ const Sanitize = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
const hasFiles = selectedFiles.length > 0; const hasFiles = selectedFiles.length > 0;
const hasResults = sanitizeOperation.files.length > 0; const hasResults = sanitizeOperation.files.length > 0;
const filesCollapsed = hasFiles || hasResults;
const settingsCollapsed = !hasFiles || hasResults; const settingsCollapsed = !hasFiles || hasResults;
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: filesCollapsed, isCollapsed: hasResults,
placeholder: t("sanitize.files.placeholder", "Select a PDF file in the main view to get started"), placeholder: t("sanitize.files.placeholder", "Select a PDF file in the main view to get started"),
}, },
steps: [ steps: [

View File

@ -54,13 +54,12 @@ const Split = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
const hasFiles = selectedFiles.length > 0; const hasFiles = selectedFiles.length > 0;
const hasResults = splitOperation.downloadUrl !== null; const hasResults = splitOperation.downloadUrl !== null;
const filesCollapsed = hasFiles || hasResults;
const settingsCollapsed = !hasFiles || hasResults; const settingsCollapsed = !hasFiles || hasResults;
return createToolFlow({ return createToolFlow({
files: { files: {
selectedFiles, selectedFiles,
isCollapsed: filesCollapsed, isCollapsed: hasResults,
placeholder: "Select a PDF file in the main view to get started", placeholder: "Select a PDF file in the main view to get started",
}, },
steps: [ steps: [