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

✨ Revert inherited status #1642

Merged
merged 1 commit into from
Dec 19, 2023
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
37 changes: 30 additions & 7 deletions client/src/app/components/IconedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TimesCircleIcon from "@patternfly/react-icons/dist/esm/icons/times-circle
import InProgressIcon from "@patternfly/react-icons/dist/esm/icons/in-progress-icon";
import ExclamationCircleIcon from "@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon";
import UnknownIcon from "@patternfly/react-icons/dist/esm/icons/unknown-icon";
import QuestionCircleIcon from "@patternfly/react-icons/dist/esm/icons/question-circle-icon";
import TopologyIcon from "@patternfly/react-icons/dist/esm/icons/topology-icon";

export type IconedStatusPreset =
| "InheritedReviews"
Expand Down Expand Up @@ -53,17 +53,17 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
const { t } = useTranslation();
const presets: IconedStatusPresetType = {
InheritedReviews: {
icon: <QuestionCircleIcon />,
status: "info",
label: t("terms.inherited"),
icon: <CheckCircleIcon />,
status: "success",
label: t("terms.completed"),
tooltipMessage: t("message.inheritedReviewTooltip", {
count: tooltipCount,
}),
},
InheritedAssessments: {
icon: <QuestionCircleIcon />,
status: "info",
label: t("terms.inherited"),
icon: <CheckCircleIcon />,
status: "success",
label: t("terms.completed"),
tooltipMessage: t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
}),
Expand Down Expand Up @@ -120,6 +120,22 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
<>{children}</>
);

const getTooltipContent = () => {
switch (preset) {
case "InheritedReviews":
return t("message.inheritedReviewTooltip", {
count: tooltipCount,
});

case "InheritedAssessments":
return t("message.inheritedAssessmentTooltip", {
count: tooltipCount,
});
default:
return "";
}
};

return (
<Flex
flexWrap={{ default: "nowrap" }}
Expand All @@ -133,6 +149,13 @@ export const IconedStatus: React.FC<IIconedStatusProps> = ({
</IconWithOptionalTooltip>
</FlexItem>
<FlexItem>{label || presetProps?.label}</FlexItem>
{(preset === "InheritedReviews" || preset === "InheritedAssessments") && (
<FlexItem>
<Tooltip content={getTooltipContent()}>
<TopologyIcon />
</Tooltip>
</FlexItem>
)}
</Flex>
);
};
43 changes: 27 additions & 16 deletions client/src/app/components/questions-table/questions-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useTranslation } from "react-i18next";
import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing";
import { Assessment, Question, Questionnaire } from "@app/api/models";
import { useLocalTableControls } from "@app/hooks/table-controls";
import { Label, Tooltip } from "@patternfly/react-core";
import { Label, List, ListItem, Tooltip } from "@patternfly/react-core";
import { NoDataEmptyState } from "@app/components/NoDataEmptyState";
import AnswerTable from "@app/components/answer-table/answer-table";
import { AxiosError } from "axios";
Expand Down Expand Up @@ -101,28 +101,39 @@ const QuestionsTable: React.FC<{
)?.name || "";

const getConditionalTooltipContent = (question: Question) => {
const includeTags = question?.includeFor
?.map((tag) => tag.tag)
.join(", ");
const excludeTags = question?.excludeFor
?.map((tag) => tag.tag)
.join(", ");

return (
<div
className="pf-v5-c-tooltip__content pf-m-text-align-left"
id="conditional-tooltip-content"
>
<div>{t("message.dependentQuestionTooltip")}</div>
{includeTags && (
<div>
{t("terms.include")}: {includeTags}
</div>
{!!question.includeFor?.length && (
<>
<div>{t("terms.include")}:</div>
<List isPlain>
{question.includeFor.map((tag, index) => (
<ListItem key={index}>
<Label color="blue">
{tag.category} / {tag.tag}
</Label>
</ListItem>
))}
</List>
</>
)}
{excludeTags && (
<div>
{t("terms.exclude")}: {excludeTags}
</div>
{!!question.excludeFor?.length && (
<>
<div>{t("terms.exclude")}:</div>
<List isPlain>
{question.excludeFor.map((tag, index) => (
<ListItem key={index}>
<Label color="blue">
{tag.category} / {tag.tag}
</Label>
</ListItem>
))}
</List>
</>
)}
</div>
);
Expand Down
Loading