Skip to content

chore(site): remove template version editor xservice #10490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tarFile in a single state call
  • Loading branch information
BrunoQuaresma committed Nov 2, 2023
commit 4893156a657bd0bce5b5edf8901c734f6c2526f5
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend reviewing this file by looking into it without the diff.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TemplateVersionEditor } from "./TemplateVersionEditor";
import { useOrganizationId } from "hooks/useOrganizationId";
import { FC, useEffect, useRef, useState } from "react";
import { FC, useEffect, useState } from "react";
import { Helmet } from "react-helmet-async";
import { useNavigate, useParams } from "react-router-dom";
import { pageTitle } from "utils/page";
Expand Down Expand Up @@ -204,19 +204,23 @@ export const TemplateVersionEditorPage: FC = () => {
};

const useFileTree = (templateVersion: TemplateVersion | undefined) => {
const tarFileRef = useRef<TarReader | null>(null);
const fileQuery = useQuery({
...file(templateVersion?.job.file_id ?? ""),
enabled: templateVersion !== undefined,
});
const [fileTree, setFileTree] = useState<FileTree>();
const [state, setState] = useState<{
fileTree?: FileTree;
tarFile?: TarReader;
}>({
fileTree: undefined,
tarFile: undefined,
});
useEffect(() => {
const initializeFileTree = async (file: ArrayBuffer) => {
const tarReader = new TarReader();
await tarReader.readFile(file);
tarFileRef.current = tarReader;
const fileTree = await createTemplateVersionFileTree(tarReader);
setFileTree(fileTree);
const tarFile = new TarReader();
await tarFile.readFile(file);
const fileTree = await createTemplateVersionFileTree(tarFile);
setState({ fileTree, tarFile });
};

if (fileQuery.data) {
Expand All @@ -226,10 +230,7 @@ const useFileTree = (templateVersion: TemplateVersion | undefined) => {
}
}, [fileQuery.data]);

return {
fileTree,
tarFile: tarFileRef.current,
};
return state;
};

const useVersionLogs = (
Expand Down