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

Mastodon post fixes #558

Merged
merged 9 commits into from
Aug 9, 2024
54 changes: 42 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/preset-react": "^7.22.15",
"@playwright/experimental-ct-react": "^1.43.1",
"@playwright/experimental-ct-react": "^1.45.3",
"@playwright/test": "^1.43.1",
"@svgr/webpack": "^8.1.0",
"@types/node": "^18.18.4",
Expand Down
5 changes: 5 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export default defineConfig({
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
timeout: 60 * 1000,
globalTimeout: 60 * 1000,
expect: {
timeout: 60 * 1000,
},

/* Configure projects for major browsers */
projects: [
Expand Down
73 changes: 48 additions & 25 deletions src/components/NavItems/Assistant/AssistantRuleBook.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react";
import analysisIconOff from "../../NavBar/images/tools/video_logoOff.png";
import keyframesIconOff from "../../NavBar/images/tools/keyframesOff.png";
import thumbnailsIconOff from "../../NavBar/images/tools/youtubeOff.png";
Expand All @@ -6,6 +7,7 @@ import metadataIconOff from "../../NavBar/images/tools/metadataOff.png";
import videoRightsIconOff from "../../NavBar/images/tools/copyrightOff.png";
import forensicIconOff from "../../NavBar/images/tools/forensic_logoOff.png";
import videoIconOff from "../../NavBar/images/tools/video_logoOff.png";
import DownloadIcon from "@mui/icons-material/Download";

export const NE_SUPPORTED_LANGS = ["en", "pt", "fr", "de", "el", "es", "it"];

Expand Down Expand Up @@ -113,11 +115,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_analysis_video",
icon: analysisIconOff,
linksAccepted: [
KNOWN_LINKS.YOUTUBE,
KNOWN_LINKS.FACEBOOK,
KNOWN_LINKS.TWITTER,
],
linksAccepted: [KNOWN_LINKS.YOUTUBE, KNOWN_LINKS.FACEBOOK],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
useInputUrl: true,
Expand All @@ -142,14 +140,10 @@ export const ASSISTANT_ACTIONS = [
linksAccepted: [
KNOWN_LINKS.YOUTUBE,
KNOWN_LINKS.FACEBOOK,
KNOWN_LINKS.TWITTER,
KNOWN_LINKS.DAILYMOTION,
KNOWN_LINKS.VIMEO,
KNOWN_LINKS.YOUTUBE,
KNOWN_LINKS.YOUTUBESHORTS,
KNOWN_LINKS.LIVELEAK,
KNOWN_LINKS.OWN,
KNOWN_LINKS.INSTAGRAM,
],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
Expand All @@ -172,7 +166,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_magnifier",
icon: magnifierIconOff,
linksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
processLinksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
cTypes: [CONTENT_TYPE.IMAGE],
exceptions: [],
useInputUrl: false,
Expand All @@ -183,7 +177,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_metadata",
icon: metadataIconOff,
linksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
processLinksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
cTypes: [CONTENT_TYPE.IMAGE, CONTENT_TYPE.VIDEO],
exceptions: [
/(pbs.twimg.com)|(youtu.be|youtube)|(instagram)|(fbcdn.net)|(vimeo)|(tiktok.com)/,
Expand All @@ -196,11 +190,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_rights",
icon: videoRightsIconOff,
linksAccepted: [
KNOWN_LINKS.YOUTUBE,
KNOWN_LINKS.FACEBOOK,
KNOWN_LINKS.TWITTER,
],
linksAccepted: [KNOWN_LINKS.YOUTUBE],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
useInputUrl: true,
Expand All @@ -211,7 +201,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_forensic",
icon: forensicIconOff,
linksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
processLinksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
cTypes: [CONTENT_TYPE.IMAGE],
exceptions: [],
useInputUrl: false,
Expand All @@ -222,7 +212,7 @@ export const ASSISTANT_ACTIONS = [
{
title: "navbar_ocr",
icon: forensicIconOff,
linksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
processLinksAccepted: [KNOWN_LINKS.MISC, KNOWN_LINKS.OWN],
cTypes: [CONTENT_TYPE.IMAGE],
exceptions: [],
useInputUrl: false,
Expand All @@ -233,14 +223,49 @@ export const ASSISTANT_ACTIONS = [
{
title: "assistant_video_download_action",
icon: videoIconOff,
linksAccepted: [KNOWN_LINKS.TELEGRAM, KNOWN_LINKS.MISC],
linksAccepted: [
KNOWN_LINKS.TELEGRAM,
KNOWN_LINKS.FACEBOOK,
KNOWN_LINKS.TWITTER,
KNOWN_LINKS.MASTODON,
],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
useInputUrl: false,
text: "assistant_video_download_action_description",
tsvPrefix: "assistant_video",
download: true,
},
{
title: "assistant_video_download_generic",
icon: <DownloadIcon color="disabled" fontSize="large" />,
linksAccepted: [
KNOWN_LINKS.YOUTUBESHORTS,
KNOWN_LINKS.INSTAGRAM,
KNOWN_LINKS.FACEBOOK,
KNOWN_LINKS.VK,
KNOWN_LINKS.VIMEO,
KNOWN_LINKS.LIVELEAK,
KNOWN_LINKS.DAILYMOTION,
],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
useInputUrl: false,
text: "assistant_video_download_generic_description",
tsvPrefix: "assistant_video",
path: null,
},
{
title: "assistant_video_download_tiktok",
icon: <DownloadIcon color="disabled" fontSize="large" />,
linksAccepted: [KNOWN_LINKS.TIKTOK],
cTypes: [CONTENT_TYPE.VIDEO],
exceptions: [],
useInputUrl: false,
text: "assistant_video_download_tiktok_description",
tsvPrefix: "assistant_video",
path: null,
},
];

export const selectCorrectActions = (
Expand All @@ -251,12 +276,10 @@ export const selectCorrectActions = (
) => {
let possibleActions = ASSISTANT_ACTIONS.filter(
(action) =>
((action.useInputUrl &&
action.linksAccepted.includes(inputUrlType) &&
action.cTypes.includes(contentType)) ||
(!action.useInputUrl &&
action.linksAccepted.includes(processUrlType) &&
action.cTypes.includes(contentType))) &&
(!action.linksAccepted || action.linksAccepted.includes(inputUrlType)) &&
(!action.processLinksAccepted ||
action.processLinksAccepted.includes(processUrlType)) &&
action.cTypes.includes(contentType) &&
(action.exceptions.length === 0 || !processUrl.match(action.exceptions)),
);
return possibleActions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const AssistantImageResult = () => {
height={"100%"}
alt={processUrl}
width={"100%"}
data-testid="assistant-media-image"
/>
</CardMedia>
<CardActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const AssistantProcessUrlActions = () => {
dl.setAttribute("href", resultUrl);
dl.setAttribute("download", "");
dl.click();
} else if (resultUrl != null) {
} else if (action.path === null) {
return; // Do nothing if path is null
} else if (resultUrl !== null) {
navigate(
"/app/" +
action.path +
Expand Down Expand Up @@ -70,19 +72,31 @@ const AssistantProcessUrlActions = () => {
<Card className={classes.assistantHover} variant={"outlined"}>
<ListItem onClick={() => handleClick(action)}>
<ListItemAvatar>
<Avatar variant={"square"} src={action.icon} />
{typeof action.icon === "string" && (
<Avatar variant={"square"} src={action.icon} />
)}
{typeof action.icon !== "string" && action.icon}
</ListItemAvatar>
<ListItemText
primary={
<Typography component={"span"}>
<Box fontWeight="fontWeightBold">
<Box
fontWeight="fontWeightBold"
data-testid={action.title}
>
{keyword(action.title)}
</Box>
</Typography>
}
secondary={
<Typography color={"textSecondary"} component={"span"}>
<Box fontStyle="italic">{keyword(action.text)}</Box>
<Box fontStyle="italic">
<div
dangerouslySetInnerHTML={{
__html: keyword(action.text),
}}
></div>
</Box>
</Typography>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const AssistantTextResult = () => {

return (
<Grid item xs={12}>
<Card>
<Card data-testid="assistant-text-scraped-text">
<CardHeader
className={classes.assistantCardHeader}
title={keyword("text_title")}
Expand Down
Loading