Skip to content

Commit

Permalink
Give instructions on how to fix folder names
Browse files Browse the repository at this point in the history
  • Loading branch information
hatton committed Dec 21, 2024
1 parent 28aeb4d commit d2df592
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
17 changes: 11 additions & 6 deletions src/components/FolderPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ export interface IProps {
const dummyPreviewImage: string =
URL.pathToFileURL(`assets/invisible.png`).toString();

const FileDisplay = observer((props: { folder: Folder }) => {
const selectedFile = props.folder.selectedFile;
return selectedFile ? (
<div>Current File: {selectedFile.getTextProperty("filename")}</div>
) : null;
});

export const FolderPane: React.FunctionComponent<
IProps & React.HTMLAttributes<HTMLDivElement>
> = (props) => {
> = observer((props) => {
//const [tabs, setTabs] = React.useState<JSX.Element>(<React.Fragment />);
if (!props.folder) {
return <h1>No folder selected.</h1>;
Expand Down Expand Up @@ -89,9 +96,7 @@ export const FolderPane: React.FunctionComponent<
<FileStatusBlock
folder={props.folder}
file={props.folder.selectedFile}
fileName={props.folder.selectedFile?.getTextProperty(
"filename"
)}
fileName={props.folder.selectedFile.getTextProperty("filename")}
/>
<ErrorBoundary>
<FileTabs {...props} />
Expand All @@ -102,11 +107,12 @@ export const FolderPane: React.FunctionComponent<
</SplitPane>
</div>
);
};
});

const FileTabs: React.FunctionComponent<
IProps & React.HTMLAttributes<HTMLDivElement>
> = observer((props) => {
console.log("rendering FileTabs");
useLingui();
const [tabIndex, setTabIndex] = React.useState(0);

Expand Down Expand Up @@ -480,4 +486,3 @@ const FileTabs: React.FunctionComponent<
);
}
});
export default observer(FolderPane);
33 changes: 12 additions & 21 deletions src/model/file/FileStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,16 @@ export function getStatusOfFile(f: File): {
info
};
} else if (hasFileNamingProblem(f.getActualFilePath())) {
let message = t`This file does not comply with the file naming rules of the current archive.`;
if (f.type === "Person" || f.type === "Session") {
message +=
" " +
t`To fix it, change the ID, click out of the field, and then you can change it back.`;
}
return {
missing: false,
status: "fileNamingProblem",
info: t`This file does not comply with the file naming rules of the current archive.`
info: message
};
} else
return {
Expand Down Expand Up @@ -132,14 +138,13 @@ export function getLinkStatusIconPath(f: File): string {
}
}

const _FileStatusBlock: React.FunctionComponent<{
export const FileStatusBlock: React.FunctionComponent<{
file: File;
fileName: string;
folder: Folder;
}> = (props) => {
console.log("FileStatusBlock rendering on " + props.fileName);
}> = observer((props) => {
console.log("Rendering FileStatusBlock " + props.fileName);
const fileStatus = getStatusOfFile(props.file);

const color =
fileStatus.status === "noMediaFolderConnection"
? lameta_orange
Expand All @@ -165,25 +170,11 @@ const _FileStatusBlock: React.FunctionComponent<{
`}
>
{fileStatus.info}
{/* {(props.file.type === "Person" || props.file.type === "Session") && (
// I got this working but then a few minutes later you get
// Pop ups about can't save because the old file is not being found.
// Somehow this doesn't happen if you manually cause the fix by tweaking the name.
<button
onClick={() => {
props.folder.nameMightHaveChanged();
}}
>
Fix
</button>
)} */}
</p>
</div>
);
};
});

function hasFileNamingProblem(path: string): boolean {
return Path.basename(path) !== sanitizeForArchive(Path.basename(path));
}

const x = observer(_FileStatusBlock);
export { x as FileStatusBlock };

0 comments on commit d2df592

Please sign in to comment.