Skip to content

Commit

Permalink
Merge pull request #555 from AFP-Medialab/assistant/update-source-cre…
Browse files Browse the repository at this point in the history
…dibility

added credibility-scope to source cred results
  • Loading branch information
Sallaa authored Jul 10, 2024
2 parents 25e9cfb + 2e9d16c commit c0753e0
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 13 deletions.
117 changes: 116 additions & 1 deletion public/locales/en/components/NavItems/tools/Assistant.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ import Box from "@mui/material/Box";
import Tooltip from "@mui/material/Tooltip";
import HelpOutlineOutlinedIcon from "@mui/icons-material/HelpOutlineOutlined";
import useMyStyles from "../../../Shared/MaterialUiStyles/useMyStyles";
import { getUrlTypeFromCredScope } from "./assistantUtils";

const renderSource = (keyword, trafficLightColor, source) => {
const renderScope = (keyword, scope) => {
return (
<Typography color={trafficLightColor}>
{keyword("source_cred_popup_header")} {source}
</Typography>
<ListItem>
{scope.includes("/") ? (
<Typography variant={"subtitle2"}>
{` ${keyword("account_scope")} ${scope} `}
</Typography>
) : scope ? (
<Typography variant={"subtitle2"}>
{` ${keyword("domain_scope")} ${scope} `}
</Typography>
) : null}
</ListItem>
);
};

Expand Down Expand Up @@ -130,15 +139,39 @@ const ExtractedSourceCredibilityDBKFDialog = ({
? sourceCredibilityResults.map((value, key) => (
<Accordion key={key}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
{renderSource(
keyword,
trafficLightColor,
sourceCredibilityResults[key].credibilitySource,
)}
{sourceCredibilityResults[
key
].credibilityScope.includes("/") ? (
<Typography color={trafficLightColor}>
{` ${keyword("this")}`}
{getUrlTypeFromCredScope(
value.credibilityScope,
)}
{` ${keyword(
"source_credibility_warning_account",
)} ${" "}${value.credibilitySource}`}
</Typography>
) : sourceCredibilityResults[key]
.credibilityScope ? (
<Typography color={trafficLightColor}>
{` ${keyword(
"source_cred_popup_header_domain",
)} ${
sourceCredibilityResults[key]
.credibilitySource
} `}
</Typography>
) : null}
</AccordionSummary>

<AccordionDetails>
<List key={key}>
{renderScope(
keyword,
sourceCredibilityResults[key]
.credibilityScope,
)}

{renderLabels(
keyword,
sourceCredibilityResults[key]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const SourceCredibilityDBKFDialog = (props) => {
<IconButton onClick={handleClose}>
<CloseIcon />
</IconButton>
{keyword("source_cred_popup_header")} {source}
{keyword("source_cred_popup_header_domain")} {source}
</Typography>
</DialogTitle>
<DialogContent dividers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ListItemSecondaryAction from "@mui/material/ListItemSecondaryAction";
import SourceCredibilityDBKFDialog from "./SourceCredibilityDBKFDialog";
import Typography from "@mui/material/Typography";
import { i18nLoadNamespace } from "components/Shared/Languages/i18nLoadNamespace";
import { getUrlTypeFromCredScope } from "./assistantUtils";

const SourceCredibilityResult = (props) => {
// central
Expand Down Expand Up @@ -36,8 +37,24 @@ const SourceCredibilityResult = (props) => {
align={"left"}
color={"textPrimary"}
>
{keyword("source_credibility_warning")}{" "}
{value.credibilitySource}
{value.credibilityScope.includes("/") ? (
<Typography>
{` ${keyword("this")}`}
{/* {inputUrlType
? capitaliseFirstLetter(inputUrlType)
: null} */}
{getUrlTypeFromCredScope(value.credibilityScope)}
{` ${keyword(
"source_credibility_warning_account",
)} ${" "}${value.credibilitySource}`}
</Typography>
) : value.credibilityScope ? (
<Typography>
{` ${keyword(
"source_credibility_warning_domain",
)} ${" "}${value.credibilitySource}`}
</Typography>
) : null}
</Typography>
<Box mb={0.5} />
</div>
Expand All @@ -48,6 +65,19 @@ const SourceCredibilityResult = (props) => {
component={"div"}
color={"textSecondary"}
>
{value.credibilityScope.includes("/") ? (
<Typography variant={"subtitle2"}>
{` ${" "} ${keyword("account_scope")} ${
value.credibilityScope
} `}
</Typography>
) : value.credibilityScope ? (
<Typography variant={"subtitle2"}>
{` ${keyword("domain_scope")} ${
value.credibilityScope
} `}
</Typography>
) : null}
{value.credibilityLabels ? (
<Typography variant={"subtitle2"}>
{` ${keyword("labelled_as")} ${
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function capitaliseFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

export const getUrlTypeFromCredScope = (string) => {
let urlType = string.split("/")[0].replace(".com", "");
if (urlType === "t.me") {
urlType = "telegram";
}
return capitaliseFirstLetter(urlType);
};
1 change: 1 addition & 0 deletions src/redux/sagas/assistantSaga.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ const addToRelevantSourceCred = (sourceCredList, result) => {
credibilityLabels: result["labels"],
credibilityDescription: result["description"],
credibilityEvidence: resultEvidence,
credibilityScope: result["credibility-scope"],
});
};

Expand Down

0 comments on commit c0753e0

Please sign in to comment.