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

added credibility-scope to source cred results #555

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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