-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: download manifest from search results (#14) * feat: update download manifest button (#376) --------- Co-authored-by: Fran McDade <[email protected]>
- Loading branch information
Showing
8 changed files
with
208 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...port/components/ManifestDownload/components/ManifestDownloadForm/manifestDownloadForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { Dispatch, SetStateAction } from "react"; | ||
import { FormFacet } from "../../../../common/entities"; | ||
import { ExportForm } from "../../../ExportForm/exportForm"; | ||
|
||
export interface ManifestDownloadFormProps { | ||
formFacet: FormFacet; | ||
isLoading: boolean; | ||
setIsRequestFormValid: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
export const ManifestDownloadForm = ({ | ||
formFacet, | ||
isLoading, | ||
setIsRequestFormValid, | ||
}: ManifestDownloadFormProps): JSX.Element => { | ||
return ( | ||
<ExportForm | ||
formFacet={formFacet} | ||
isLoading={isLoading} | ||
setIsRequestFormValid={setIsRequestFormValid} | ||
/> | ||
); | ||
}; |
61 changes: 61 additions & 0 deletions
61
...nts/ManifestDownload/components/ManifestDownloadNotStarted/manifestDownloadNotStarted.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { ElementType, useState } from "react"; | ||
import { FileManifestState } from "../../../../../../providers/fileManifestState"; | ||
import { ButtonPrimary } from "../../../../../common/Button/components/ButtonPrimary/buttonPrimary"; | ||
import { PAPER_PANEL_STYLE } from "../../../../../common/Paper/paper"; | ||
import { FluidPaper } from "../../../../../common/Paper/paper.styles"; | ||
import { Loading } from "../../../../../Loading/loading"; | ||
import { FormFacet } from "../../../../common/entities"; | ||
import { | ||
Section, | ||
SectionActions, | ||
SectionContent, | ||
} from "../../../../export.styles"; | ||
|
||
export interface ManifestDownloadNotStartedProps { | ||
fileManifestState: FileManifestState; | ||
formFacet: FormFacet; | ||
isLoading: boolean; | ||
ManifestDownloadForm: ElementType; | ||
ManifestDownloadStart: ElementType; | ||
onRequestManifest: () => void; | ||
} | ||
|
||
export const ManifestDownloadNotStarted = ({ | ||
fileManifestState, | ||
formFacet, | ||
isLoading, | ||
ManifestDownloadForm, | ||
ManifestDownloadStart, | ||
onRequestManifest, | ||
}: ManifestDownloadNotStartedProps): JSX.Element => { | ||
const [isRequestFormValid, setIsRequestFormValid] = useState<boolean>(false); | ||
return ( | ||
<div> | ||
<Loading | ||
loading={isLoading} | ||
panelStyle={PAPER_PANEL_STYLE.FLUID} | ||
text="Your manifest will be ready shortly..." | ||
/> | ||
<FluidPaper> | ||
<Section> | ||
<SectionContent> | ||
<ManifestDownloadStart /> | ||
</SectionContent> | ||
<ManifestDownloadForm | ||
formFacet={formFacet} | ||
isLoading={fileManifestState.isLoading} | ||
setIsRequestFormValid={setIsRequestFormValid} | ||
/> | ||
<SectionActions> | ||
<ButtonPrimary | ||
disabled={fileManifestState.isLoading || !isRequestFormValid} | ||
onClick={onRequestManifest} | ||
> | ||
Prepare Manifest | ||
</ButtonPrimary> | ||
</SectionActions> | ||
</Section> | ||
</FluidPaper> | ||
</div> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
...ponents/ManifestDownload/components/ManifestDownloadReady/manifestDownloadReady.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from "@emotion/styled"; | ||
import { Code as DXCode } from "../../../../../common/Code/code"; | ||
|
||
export const Code = styled(DXCode)` | ||
code { | ||
-webkit-box-orient: vertical; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 3; | ||
overflow: hidden; | ||
} | ||
`; |
40 changes: 40 additions & 0 deletions
40
...rt/components/ManifestDownload/components/ManifestDownloadReady/manifestDownloadReady.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Button } from "@mui/material"; | ||
import React, { ElementType } from "react"; | ||
import { FluidPaper } from "../../../../../common/Paper/paper.styles"; | ||
import { | ||
Section, | ||
SectionActions, | ||
SectionContent, | ||
} from "../../../../export.styles"; | ||
import { Code } from "./manifestDownloadReady.styles"; | ||
|
||
export interface ManifestDownloadReadyProps { | ||
ManifestDownloadSuccess: ElementType; | ||
manifestURL: string; | ||
} | ||
|
||
export const ManifestDownloadReady = ({ | ||
ManifestDownloadSuccess, | ||
manifestURL, | ||
}: ManifestDownloadReadyProps): JSX.Element => { | ||
return ( | ||
<FluidPaper> | ||
<Section> | ||
<SectionContent> | ||
<ManifestDownloadSuccess /> | ||
<Code code={manifestURL} /> | ||
</SectionContent> | ||
<SectionActions> | ||
<Button | ||
color="primary" | ||
download | ||
href={manifestURL} | ||
variant="contained" | ||
> | ||
Download Manifest | ||
</Button> | ||
</SectionActions> | ||
</Section> | ||
</FluidPaper> | ||
); | ||
}; |
70 changes: 70 additions & 0 deletions
70
...s/data-explorer-ui/src/components/Export/components/ManifestDownload/manifestDownload.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { ElementType } from "react"; | ||
import { MANIFEST_DOWNLOAD_FORMAT } from "../../../../apis/azul/common/entities"; | ||
import { Filters } from "../../../../common/entities"; | ||
import { FileManifestType } from "../../../../hooks/useFileManifest/common/entities"; | ||
import { useRequestFileManifest } from "../../../../hooks/useFileManifest/useRequestFileManifest"; | ||
import { | ||
FileLocation, | ||
useRequestFileLocation, | ||
} from "../../../../hooks/useRequestFileLocation"; | ||
import { FileManifestState } from "../../../../providers/fileManifestState"; | ||
import { FormFacet } from "../../common/entities"; | ||
import { ManifestDownloadNotStarted } from "./components/ManifestDownloadNotStarted/manifestDownloadNotStarted"; | ||
import { ManifestDownloadReady } from "./components/ManifestDownloadReady/manifestDownloadReady"; | ||
|
||
export interface ManifestDownloadProps { | ||
fileManifestState: FileManifestState; | ||
fileManifestType: FileManifestType; | ||
fileSummaryFacetName: string; | ||
filters: Filters; // Initializes manifest download filters. | ||
formFacet: FormFacet; | ||
ManifestDownloadForm: ElementType; | ||
ManifestDownloadStart: ElementType; | ||
ManifestDownloadSuccess: ElementType; | ||
} | ||
|
||
export const ManifestDownload = ({ | ||
fileManifestState, | ||
fileSummaryFacetName, | ||
filters, | ||
formFacet, | ||
ManifestDownloadForm, | ||
ManifestDownloadStart, | ||
ManifestDownloadSuccess, | ||
}: ManifestDownloadProps): JSX.Element => { | ||
useRequestFileManifest( | ||
MANIFEST_DOWNLOAD_FORMAT.COMPACT, | ||
filters, | ||
fileSummaryFacetName | ||
); | ||
const { requestURL } = fileManifestState; | ||
const { data, isLoading, run } = useRequestFileLocation(requestURL); | ||
const manifestURL = getManifestDownloadURL(data); | ||
return manifestURL ? ( | ||
<ManifestDownloadReady | ||
ManifestDownloadSuccess={ManifestDownloadSuccess} | ||
manifestURL={manifestURL} | ||
/> | ||
) : ( | ||
<ManifestDownloadNotStarted | ||
ManifestDownloadForm={ManifestDownloadForm} | ||
ManifestDownloadStart={ManifestDownloadStart} | ||
fileManifestState={fileManifestState} | ||
formFacet={formFacet} | ||
isLoading={isLoading} | ||
onRequestManifest={run} | ||
/> | ||
); | ||
}; | ||
|
||
/** | ||
* Returns the manifest download URL for the generated manifest. | ||
* @param fileLocation - Request file location. | ||
* @returns manifest download URL. | ||
*/ | ||
function getManifestDownloadURL( | ||
fileLocation?: FileLocation | ||
): string | undefined { | ||
const { location } = fileLocation || {}; | ||
return location; | ||
} |
72 changes: 0 additions & 72 deletions
72
packages/data-explorer-ui/src/components/Project/components/TitledText/titledText.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters