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

Deploy v9.3.3 to production #3927

Merged
merged 23 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
071ff42
Bump version to 9.2.4
github-actions[bot] Apr 25, 2024
0888fc9
Bump react-dom from 18.2.0 to 18.3.1 in /app/assets
dependabot[bot] Apr 29, 2024
dcb1610
Bump @testing-library/dom from 10.0.0 to 10.1.0 in /app/assets
dependabot[bot] Apr 29, 2024
7ee4568
Bump @babel/preset-env from 7.24.4 to 7.24.5 in /app/assets
dependabot[bot] Apr 30, 2024
489f25f
Bump @babel/runtime from 7.24.4 to 7.24.5 in /app/assets
dependabot[bot] Apr 30, 2024
a034b15
Bump @babel/core from 7.24.4 to 7.24.5 in /app/assets
dependabot[bot] Apr 30, 2024
b1c0c1d
Auxiliary files can be pdf (#3913)
kdid May 1, 2024
442a457
Bump @testing-library/react from 15.0.4 to 15.0.6 in /app/assets
dependabot[bot] May 2, 2024
3c9077e
Update Authoritex to v1.1.0
mbklein May 2, 2024
e079161
Remove email from aux file download call
kdid May 2, 2024
98ea7fa
Merge pull request #3939 from nulib/4694-authoritex-update
bmquinn May 2, 2024
7d17621
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/testing-libra…
github-actions[bot] May 2, 2024
8749830
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/babel/core-7.…
github-actions[bot] May 2, 2024
f327dc6
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/babel/runtime…
github-actions[bot] May 2, 2024
356c163
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/babel/preset-…
github-actions[bot] May 2, 2024
d7946cf
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/testing-libra…
github-actions[bot] May 2, 2024
4ef156d
Merge dependabot/npm_and_yarn/app/assets/deploy/staging/react-dom-18.…
github-actions[bot] May 2, 2024
d1ea75f
Bump react from 18.2.0 to 18.3.1 in /app/assets
dependabot[bot] Apr 29, 2024
a21ceb8
Merge pull request #3931 from nulib/dependabot/npm_and_yarn/app/asset…
mbklein May 2, 2024
7846709
Merge pull request #3941 from nulib/combined-dependencies
mbklein May 3, 2024
6e64d41
Merge pull request #3940 from nulib/download-no-email
kdid May 3, 2024
36511ed
Bump version to 9.3.3
kdid May 3, 2024
984cfb3
Update terraform rds version to 11.22
kdid May 3, 2024
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
62 changes: 52 additions & 10 deletions app/assets/js/components/Work/Fileset/ActionButtons/Auxillary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,65 @@ import PropTypes from "prop-types";
import { IIIFContext } from "@js/components/IIIF/IIIFProvider";
import { IIIF_SIZES } from "@js/services/global-vars";
import { ImageDownloader } from "@samvera/image-downloader";
import useFileSet from "@js/hooks/useFileSet";
import { Button } from "@nulib/design-system";
import { IconDownload } from "@js/components/Icon";
import { toastWrapper } from "@js/services/helpers";
import { useWorkState } from "@js/context/work-context";
import { GET_DCAPI_ENDPOINT } from "@js/components/UI/ui.gql";
import { getApiResponse } from "@js/services/get-api-response";
import { useQuery } from "@apollo/client";

const WorkFilesetActionButtonsAuxiliary = ({ fileSet }) => {
const iiifServerUrl = useContext(IIIFContext);
const url = `${iiifServerUrl}${fileSet.id}${IIIF_SIZES.IIIF_FULL}`;
const { altFileFormat, isImage, isAltFormat } = useFileSet();
const { dcApiToken } = useWorkState();
const { data: dataDcApiEndpoint } = useQuery(GET_DCAPI_ENDPOINT);

const handleDownloadFile = async () => {
const dcApiFileSet = `${dataDcApiEndpoint?.dcapiEndpoint?.url}/file-sets/${fileSet.id}`;
const uri = `${dcApiFileSet}/download`;

try {
const response = await getApiResponse(uri, dcApiToken);
if (response?.status !== 200) throw Error(response);
window.location.href = response.url;
} catch (error) {
console.error(error);
toastWrapper("is-danger", `The download request failed.`);
}
};

return (

<div className="buttons is-flex is-justify-content-flex-end">
<a className="button" href={url} target="_blank">
View Aux File
</a>
<ImageDownloader
imageUrl={url}
imageTitle={fileSet.accessionNumber}
className="button"
>
Download JPG
</ImageDownloader>
{isImage(fileSet) && (
<div>
<a className="button" href={url} target="_blank">
View Aux File
</a>
<ImageDownloader
imageUrl={url}
imageTitle={fileSet.accessionNumber}
className="button"
>
Download JPG
</ImageDownloader>
</div>
)}

{isAltFormat(fileSet) && (
<div>
<Button
data-testid="download-file-button"
onClick={handleDownloadFile}>
<IconDownload />
<span>Download {altFileFormat(fileSet)}</span>
</Button>
</div>
)}

</div>
);
};
Expand Down
31 changes: 24 additions & 7 deletions app/assets/js/components/Work/Fileset/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function WorkFilesetListItem({
const iiifServerUrl = useContext(IIIFContext);
const { id, coreMetadata } = fileSet;
const dispatch = useWorkDispatch();
const { isMedia } = useFileSet();
const {isImage, isMedia, isPDF, isZip } = useFileSet();
const workContextState = useWorkState();

// Helper for media type file sets
Expand All @@ -41,13 +41,31 @@ function WorkFilesetListItem({
if (!imgState.errored) {
setImgState({
errored: true,
src: isMedia(fileSet)
? "/images/video-placeholder2.png"
: "/images/placeholder.png",
src: placeholderImage(fileSet),
});
}
};

const placeholderImage = (fileSet) => {
if (isMedia(fileSet)) {
return "/images/video-placeholder2.png";
} else if (isPDF(fileSet)) {
return "/images/placeholder-pdf.png";
} else if (isZip(fileSet)) {
return "/images/placeholder-zip.png";
} else {
return "/images/placeholder.png";
}
}

const showWorkImageToggle = () => {
if (fileSet.role.id === "A" && workContextState.workTypeId === "AUDIO") {
return false;
} else {
return isImage(fileSet);
}
}

return (
<article className="box" data-testid="fileset-item">
<div className="columns">
Expand Down Expand Up @@ -102,9 +120,8 @@ function WorkFilesetListItem({
<div className="column is-5 has-text-right is-clearfix">
{!isEditing && (
<>
{!(
workContextState.workTypeId === "AUDIO" &&
fileSet.role.id === "A"
{(
showWorkImageToggle()
) && (
<AuthDisplayAuthorized>
<div className="field">
Expand Down
10 changes: 8 additions & 2 deletions app/assets/js/hooks/useAcceptedMimeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@ export default function useAcceptedMimeTypes() {
}

const mimeParts = mimeType.split("/");
const acceptedAltFormats = [
"application/pdf",
"application/zip",
"application/zip-compressed",
];
const isImage = mimeParts[0] === "image";
const isAudio = mimeParts[0] === "audio";
const isVideo = mimeParts[0] === "video";
const isAltFormat = acceptedAltFormats.includes(mimeType);
let code = "";
let message = "";
let isValid = true;

switch (fileSetRole) {
case "X":
if (!isImage) {
if (!isImage && !isAltFormat) {
isValid = false;
code = "invalid-image";
message = "Auxiliary files can only be image mime types";
message = "Auxiliary files can only be image, pdf, or zip mime types";
}
break;

Expand Down
37 changes: 37 additions & 0 deletions app/assets/js/hooks/useFileSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ export default function useFileSet() {
return !fileSet || Object.keys(fileSet).length === 0;
}

function isAltFormat(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
const acceptedTypes = [
"application/pdf",
"application/zip",
"application/zip-compressed",
];
return acceptedTypes.includes(mimeType);
}

function isImage(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
Expand All @@ -35,18 +46,44 @@ export default function useFileSet() {
return mimeType.includes("video") || mimeType.includes("audio");
}

function isPDF(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
return mimeType === "application/pdf";
}

function isVideo(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
return mimeType.includes("video");
}

function isZip(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
return mimeType.includes("zip");
}

function altFileFormat(fileSet = {}) {
const mimeType = fileSet.coreMetadata?.mimeType?.toLowerCase();
if (!mimeType) return;
if (mimeType === "application/pdf") {
return "pdf";
} else {
return "zip";
}
}

return {
altFileFormat,
filterFileSets,
getWebVttString,
isAltFormat,
isEmpty,
isImage,
isMedia,
isPDF,
isVideo,
isZip,
};
}
Loading
Loading