Skip to content
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

Zip downloads: front-end only #161

Draft
wants to merge 8 commits into
base: mrc-6091-downloads-page
Choose a base branch
from
4 changes: 2 additions & 2 deletions app/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import active from "../config/active.json";
import { Header } from "./components/header";
import { Main } from "./components/main";

export default function App() {
export const App = () => {
return (
<div data-testid="app" className={active.instance}>
<Header />
Expand All @@ -11,4 +11,4 @@ export default function App() {
</div>
</div>
);
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/contents/changelogs/ChangeLogs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function ChangeLogs() {
export const ChangeLogs = () => {
return <div className="h-full flex-1 flex-col space-y-4 pl-8 lg:pl-0 pr-8">TODO</div>;
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/contents/changelogs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ChangeLogs from "./ChangeLogs";
import { ChangeLogs } from "./ChangeLogs";

export {ChangeLogs};
export { ChangeLogs };
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function ProjectDocumentation() {
export const ProjectDocumentation = () => {
return <div className="content">Project documentation page</div>;
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/contents/documents/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ProjectDocumentation from "./ProjectDocumentation";
import { ProjectDocumentation } from "./ProjectDocumentation";

export {ProjectDocumentation};
export { ProjectDocumentation };
4 changes: 2 additions & 2 deletions app/src/app/components/contents/downloads/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface DownloadButtonProps {
packetId: string;
}

export default function DownloadButton({ file, packetId }: DownloadButtonProps) {
export const DownloadButton = ({ file, packetId }: DownloadButtonProps) => {
const [error, setError] = useState("");

const downloadFile = (file: FileMetadata) => {
Expand All @@ -33,4 +33,4 @@ export default function DownloadButton({ file, packetId }: DownloadButtonProps)
<div className="text-red-500 pe-4">{error}</div>
</div>
);
}
};
14 changes: 10 additions & 4 deletions app/src/app/components/contents/downloads/Downloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { useParams } from "react-router-dom";
import { usePacketOutletContext } from "../../main/PacketOutlet";
import { PacketHeader } from "../packets";
import { Card, CardContent } from "../../Base/Card";
import FileRow from "./FileRow";
import { FileRow } from "./FileRow";
import { OrderlyDownloads } from "./orderly/OrderlyDownloads";
import { DownloadAllFilesButton } from "./orderly/DownloadAllFilesButton";

export default function Downloads() {
export const Downloads = () => {
const { packetId, packetName } = useParams();
const { packet } = usePacketOutletContext();
const packetIsFromOrderly = !!packet?.custom?.orderly;
Expand All @@ -14,7 +15,12 @@ export default function Downloads() {
<>
{packet && (
<>
<PacketHeader packetName={packetName ?? ""} packetId={packetId ?? ""} displayName={packet.displayName} />
<div className="md:flex justify-between">
<PacketHeader packetName={packetName ?? ""} packetId={packetId ?? ""} displayName={packet.displayName} />
<span className="self-end">
<DownloadAllFilesButton />
</span>
</div>
{packetIsFromOrderly && <OrderlyDownloads />}
{!packetIsFromOrderly && (
<>
Expand All @@ -36,4 +42,4 @@ export default function Downloads() {
)}
</>
);
}
};
6 changes: 3 additions & 3 deletions app/src/app/components/contents/downloads/FileRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { bytesToSize } from "../../../../helpers";
import DownloadButton from "./DownloadButton";
import { DownloadButton } from "./DownloadButton";
import { usePacketOutletContext } from "../../main/PacketOutlet";
import { ExtensionIcon } from "./ExtensionIcon";

Expand All @@ -8,7 +8,7 @@ interface FileRowProps {
sharedResource?: boolean;
}

export default function FileRow({ path, sharedResource }: FileRowProps) {
export const FileRow = ({ path, sharedResource }: FileRowProps) => {
const { packet } = usePacketOutletContext();
const file = packet?.files.filter((file) => {
return file.path === path.replace("//", "/");
Expand Down Expand Up @@ -38,4 +38,4 @@ export default function FileRow({ path, sharedResource }: FileRowProps) {
<DownloadButton file={file} packetId={packet.id} />
</div>
);
}
};
2 changes: 1 addition & 1 deletion app/src/app/components/contents/downloads/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Downloads from "./Downloads";
import { Downloads } from "./Downloads";

export { Downloads };
10 changes: 6 additions & 4 deletions app/src/app/components/contents/downloads/orderly/Artefacts.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { Card, CardContent, CardHeader } from "../../../Base/Card";
import FileRow from "../FileRow";
import { FileRow } from "../FileRow";
import { Artefact } from "../../../../../types";
import { FileGroupDownloadButton } from "./FileGroupDownloadButton";

interface ArtefactsProps {
artefacts: Artefact[];
}

export default function Artefacts({ artefacts }: ArtefactsProps) {
export const Artefacts = ({ artefacts }: ArtefactsProps) => {
return (
<ul className="space-y-4">
{artefacts.map((artefact, key) => (
<li key={key}>
<Card>
<CardHeader className="bg-muted p-4">
<CardHeader className="bg-muted p-2 ps-6 flex-row justify-between items-center space-y-0">
<h3 className="">{artefact.description}</h3>
<FileGroupDownloadButton />
</CardHeader>
<CardContent className="p-0">
<ul>
Expand All @@ -29,4 +31,4 @@ export default function Artefacts({ artefacts }: ArtefactsProps) {
))}
</ul>
);
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Button } from "../../../Base/Button";
import { FolderDown } from "lucide-react";

export const DownloadAllFilesButton = () => {
return (
<Button variant="default" className="py-1 h-fit">
<FolderDown size={26} className="pe-2" /> Download all as .zip
</Button>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Button } from "../../../Base/Button";
import { FolderDown } from "lucide-react";

export const FileGroupDownloadButton = () => {
return (
<Button variant="outline" className="bg-gray-100 hover:bg-gray-50 py-1 h-fit">
<FolderDown size={26} className="pe-2" /> Download as .zip
</Button>
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../../../Base/Accordion";
import { InputFileType } from "../../../../../types";
import Artefacts from "./Artefacts";
import OtherFiles from "./OtherFiles";
import { Artefacts } from "./Artefacts";
import { OtherFiles } from "./OtherFiles";
import { usePacketOutletContext } from "../../../main/PacketOutlet";

export const OrderlyDownloads = () => {
Expand Down
34 changes: 20 additions & 14 deletions app/src/app/components/contents/downloads/orderly/OtherFiles.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import { Card, CardContent } from "../../../Base/Card";
import FileRow from "../FileRow";
import { FileRow } from "../FileRow";
import { InputFiles, InputFileType } from "../../../../../types";
import { FileGroupDownloadButton } from "./FileGroupDownloadButton";

// 'Other files' are any files to display other than artefact groups.

interface OtherFilesProps {
inputFiles: InputFiles[];
}

export default function OtherFiles({ inputFiles }: OtherFilesProps) {
export const OtherFiles = ({ inputFiles }: OtherFilesProps) => {
return (
<Card>
<CardContent className="p-0">
<ul>
{inputFiles.map((input, index) => (
<li key={index} className="[&:not(:first-child)]:border-t">
<FileRow path={input.path} sharedResource={input.role === InputFileType.Shared} />
</li>
))}
</ul>
</CardContent>
</Card>
<div className="flex flex-col">
<span className="self-end mb-2">
<FileGroupDownloadButton />
</span>
<Card>
<CardContent className="p-0">
<ul>
{inputFiles.map((input, index) => (
<li key={index} className="[&:not(:first-child)]:border-t">
<FileRow path={input.path} sharedResource={input.role === InputFileType.Shared} />
</li>
))}
</ul>
</CardContent>
</Card>
</div>
);
}
};
4 changes: 3 additions & 1 deletion app/src/app/components/contents/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ChangeLogs } from "./changelogs";
import { ProjectDocumentation } from "./documents";
import { Downloads } from "./downloads";
import { Home } from "./home";
import { Metadata } from "./metadata";
import { PacketGroup } from "./PacketGroup";
import { WorkflowRunner } from "./workflow";

export { ChangeLogs, Downloads, Metadata, ProjectDocumentation, WorkflowRunner };
export { ChangeLogs, Downloads, Home, Metadata, PacketGroup, ProjectDocumentation, WorkflowRunner };
4 changes: 2 additions & 2 deletions app/src/app/components/contents/metadata/Metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
AccordionTrigger
} from "../../Base/Accordion";

export default function Metadata() {
export const Metadata = () => {
const { packetId, packetName } = useParams();
const { packet } = usePacketOutletContext();

Expand Down Expand Up @@ -108,4 +108,4 @@ export default function Metadata() {
)}
</>
);
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/contents/metadata/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Metadata from "./Metadata";
import { Metadata } from "./Metadata";

export {Metadata};
export { Metadata };
6 changes: 3 additions & 3 deletions app/src/app/components/contents/packets/PacketDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useParams } from "react-router-dom";
import { usePacketOutletContext } from "../../main/PacketOutlet";
import PacketHeader from "./PacketHeader";
import { PacketHeader } from "./PacketHeader";
import { PacketParameters } from "./PacketParameters";
import { PacketReports } from "./PacketReports";
import { Separator } from "../../Base/Separator";

export default function PacketDetails() {
export const PacketDetails = () => {
const { packetId, packetName } = useParams();
const { packet } = usePacketOutletContext();
const longDescription = packet?.custom?.orderly.description.long;
Expand All @@ -18,4 +18,4 @@ export default function PacketDetails() {
<PacketReports packet={packet} />
</>
);
}
};
2 changes: 1 addition & 1 deletion app/src/app/components/contents/packets/PacketHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface PacketHeaderProps {
displayName?: string;
}

export default function PacketHeader({ packetName, packetId, displayName }: PacketHeaderProps) {
export const PacketHeader = ({ packetName, packetId, displayName }: PacketHeaderProps) => {
if (!displayName || displayName === packetName) {
return (
<div>
Expand Down
7 changes: 4 additions & 3 deletions app/src/app/components/contents/packets/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PacketDetails from "./PacketDetails";
import PacketHeader from "./PacketHeader";
import { PacketDetails } from "./PacketDetails";
import { PacketHeader } from "./PacketHeader";
import { PacketFileFullScreen } from "./PacketFileFullScreen";

export { PacketDetails, PacketHeader };
export { PacketDetails, PacketHeader, PacketFileFullScreen };
3 changes: 2 additions & 1 deletion app/src/app/components/contents/runner/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PacketRunnerLayout } from "./PacketRunnerLayout";
import { PacketRun } from "./PacketRun";
import { PacketRunTasksLogs } from "./PacketRunTasksLogs";
import { PacketRunTaskLogs } from "./PacketRunTaskLogs";

export { PacketRunnerLayout, PacketRun, PacketRunTasksLogs };
export { PacketRunnerLayout, PacketRun, PacketRunTaskLogs, PacketRunTasksLogs };
4 changes: 2 additions & 2 deletions app/src/app/components/contents/workflow/WorkflowRunner.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function WorkflowRunner() {
export const WorkflowRunner = () => {
return <div className="content">Workflow runner page</div>;
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/contents/workflow/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import WorkflowRunner from "./WorkflowRunner";
import { WorkflowRunner } from "./WorkflowRunner";

export {WorkflowRunner};
export { WorkflowRunner };
4 changes: 2 additions & 2 deletions app/src/app/components/header/AccountHeaderDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useRedirectOnLogin } from "../providers/RedirectOnLoginProvider";
import { useUser } from "../providers/UserProvider";

export function AccountHeaderDropdown() {
export const AccountHeaderDropdown = () => {
const navigate = useNavigate();
const { removeUser, user } = useUser();
const { setLoggingOut } = useRedirectOnLogin();
Expand Down Expand Up @@ -52,4 +52,4 @@ export function AccountHeaderDropdown() {
</DropdownMenuContent>
</DropdownMenu>
);
}
};
4 changes: 2 additions & 2 deletions app/src/app/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { NavMenuMobile } from "./NavMenuMobile";
import { LeftNav } from "./LeftNav";
import { hasUserManagePermission } from "../../../lib/auth/hasPermission";

export default function Header() {
export const Header = () => {
const { user } = useUser();

return (
Expand Down Expand Up @@ -43,4 +43,4 @@ export default function Header() {
</div>
</header>
);
}
};
2 changes: 1 addition & 1 deletion app/src/app/components/header/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Header from "./Header";
import { Header } from "./Header";

export { Header };
4 changes: 2 additions & 2 deletions app/src/app/components/login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UserAuthForm } from "./UserAuthForm";
import { useSearchParams } from "react-router-dom";

export default function Login() {
export const Login = () => {
const [searchParams] = useSearchParams();
const sessionExpiryInfo = searchParams.get("info");
return (
Expand All @@ -15,4 +15,4 @@ export default function Login() {
<UserAuthForm />
</>
);
}
};
6 changes: 3 additions & 3 deletions app/src/app/components/login/Redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useLocation, useNavigate } from "react-router-dom";
import { useUser } from "../providers/UserProvider";
import { useRedirectOnLogin } from "../providers/RedirectOnLoginProvider";

export default function Redirect() {
export const Redirect = () => {
const navigate = useNavigate();
const { setUser } = useUser();
const { requestedUrl, setRequestedUrl } = useRedirectOnLogin();
Expand All @@ -12,7 +12,7 @@ export default function Redirect() {
const token = searchParams.get("token");
const error = searchParams.get("error");

const navigateToRequestedUrl = () => {
const navigateToRequestedUrl = () => {
const url = requestedUrl || "/";
setRequestedUrl(null); // reset requested url before redirecting
navigate(url);
Expand All @@ -34,4 +34,4 @@ export default function Redirect() {
<p>Redirecting user ...</p>
</div>
);
}
};
Loading
Loading