Skip to content

Commit

Permalink
Add conditional tooltip
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 committed Dec 7, 2023
1 parent ca600a3 commit 22e7c36
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@
},
"terms": {
"advanced": "Advanced",
"advancedAnalysisDetails": "Enhanced analysis details",
"analysisMode": "Analysis mode",
"configureAnalysis": "Configure analysis",
"customRules": "Custom rules",
Expand All @@ -518,6 +519,9 @@
"title": {
"advancedOptions": "Advanced options",
"review": "Review analysis details"
},
"tooltip": {
"advancedAnalysisDetails": "Enable advanced analysis details to get more information about the analysis."
}
}
}
1 change: 1 addition & 0 deletions client/src/app/api/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export interface TaskData {
tagger: {
enabled: boolean;
};
verbosity: number;
mode: {
binary: boolean;
withDeps: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const defaultTaskData: TaskData = {
tagger: {
enabled: true,
},
verbosity: 0,
mode: {
binary: false,
withDeps: false,
Expand Down Expand Up @@ -178,6 +179,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
branch: "",
rootPath: "",
autoTaggingEnabled: true,
advancedAnalysisEnabled: false,
},
resolver: yupResolver(allFieldsSchema),
mode: "all",
Expand Down Expand Up @@ -227,6 +229,7 @@ export const AnalysisWizard: React.FC<IAnalysisWizard> = ({
tasks: analyzableApplications.map((app: Application) => initTask(app)),
data: {
...defaultTaskData,
verbosity: fieldValues.advancedAnalysisEnabled ? 1 : 0,
tagger: {
enabled: fieldValues.autoTaggingEnabled,
},
Expand Down
11 changes: 11 additions & 0 deletions client/src/app/pages/applications/analysis-wizard/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const Review: React.FC<IReview> = ({ applications, mode }) => {
customRulesFiles,
excludedRulesTags,
autoTaggingEnabled,
advancedAnalysisEnabled,
} = watch();

const hasIncludedPackages = withKnownLibs.includes("select");
Expand Down Expand Up @@ -207,6 +208,16 @@ export const Review: React.FC<IReview> = ({ applications, mode }) => {
: t("wizard.terms.disabled")}
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
{t("wizard.terms.advancedAnalysisDetails")}
</DescriptionListTerm>
<DescriptionListDescription id="advanced-analysis-details">
{advancedAnalysisEnabled
? t("wizard.terms.enabled")
: t("wizard.terms.disabled")}

Check warning on line 218 in client/src/app/pages/applications/analysis-wizard/review.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/review.tsx#L217-L218

Added lines #L217 - L218 were not covered by tests
</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
</>
);
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/pages/applications/analysis-wizard/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ const useCustomRulesStepSchema = (): yup.SchemaOf<CustomRulesStepValues> => {
export interface OptionsStepValues {
excludedRulesTags: string[];
autoTaggingEnabled: boolean;
advancedAnalysisEnabled: boolean;
selectedSourceLabels: TargetLabel[];
}

Expand All @@ -165,6 +166,7 @@ const useOptionsStepSchema = (): yup.SchemaOf<OptionsStepValues> => {
return yup.object({
excludedRulesTags: yup.array().of(yup.string().defined()),
autoTaggingEnabled: yup.bool().defined(),
advancedAnalysisEnabled: yup.bool().defined(),
selectedSourceLabels: yup.array().of(
yup.object().shape({
name: yup.string().defined(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as React from "react";
import {
Checkbox,
Flex,
FlexItem,
Form,
Text,
TextContent,
Title,
Tooltip,
} from "@patternfly/react-core";
import {
SelectVariant,
Expand All @@ -25,14 +28,20 @@ import { getParsedLabel } from "@app/utils/rules-utils";
import { DEFAULT_SELECT_MAX_HEIGHT } from "@app/Constants";
import { useFetchTargets } from "@app/queries/targets";
import defaultSources from "./sources";
import { QuestionCircleIcon } from "@patternfly/react-icons";

export const SetOptions: React.FC = () => {
const { t } = useTranslation();

const { watch, control, setValue } =
useFormContext<AnalysisWizardFormValues>();

const { formLabels, excludedRulesTags, autoTaggingEnabled } = watch();
const {
formLabels,
excludedRulesTags,
autoTaggingEnabled,
advancedAnalysisEnabled,
} = watch();

Check warning on line 44 in client/src/app/pages/applications/analysis-wizard/set-options.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/set-options.tsx#L44

Added line #L44 was not covered by tests

const [isSelectTargetsOpen, setSelectTargetsOpen] = React.useState(false);
const [isSelectSourcesOpen, setSelectSourcesOpen] = React.useState(false);
Expand Down Expand Up @@ -254,6 +263,30 @@ export const SetOptions: React.FC = () => {
id="enable-auto-tagging-checkbox"
name="autoTaggingEnabled"
/>
<Flex>
<FlexItem>
<Checkbox
className={spacing.mtMd}
label={t("wizard.composed.enable", {
what: t("wizard.terms.advancedAnalysisDetails").toLowerCase(),
})}
isChecked={advancedAnalysisEnabled}
onChange={() =>
setValue("advancedAnalysisEnabled", !advancedAnalysisEnabled)

Check warning on line 275 in client/src/app/pages/applications/analysis-wizard/set-options.tsx

View check run for this annotation

Codecov / codecov/patch

client/src/app/pages/applications/analysis-wizard/set-options.tsx#L275

Added line #L275 was not covered by tests
}
id="enable-advanced-analysis-details-checkbox"
name="advancedAnalysisDetailsEnabled"
/>
</FlexItem>
<FlexItem>
<Tooltip
position="right"
content={t("wizard.tooltip.advancedAnalysisDetails")}
>
<QuestionCircleIcon className={spacing.mlSm} />
</Tooltip>
</FlexItem>
</Flex>
</Form>
);
};

0 comments on commit 22e7c36

Please sign in to comment.