Skip to content

Commit

Permalink
✨ Add debug flag for analysis (#1601)
Browse files Browse the repository at this point in the history
- Requested for improving analysis experience when debugging

Signed-off-by: ibolton336 <[email protected]>
  • Loading branch information
ibolton336 authored Dec 11, 2023
1 parent 21b7afd commit e99029b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
4 changes: 4 additions & 0 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@
},
"terms": {
"advanced": "Advanced",
"advancedAnalysisDetails": "Enhanced analysis details",
"analysisMode": "Analysis mode",
"configureAnalysis": "Configure analysis",
"customRules": "Custom rules",
Expand All @@ -519,6 +520,9 @@
"title": {
"advancedOptions": "Advanced options",
"review": "Review analysis details"
},
"tooltip": {
"advancedAnalysisDetails": "Enable enhanced 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
16 changes: 11 additions & 5 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 @@ -192,11 +193,6 @@ export const Review: React.FC<IReview> = ({ applications, mode }) => {
</List>
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>
{t("wizard.terms.transactionReport")}
</DescriptionListTerm>
</DescriptionListGroup>{" "}
<DescriptionListGroup>
<DescriptionListTerm>
{t("wizard.terms.autoTagging")}
Expand All @@ -207,6 +203,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")}
</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();

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)
}
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 e99029b

Please sign in to comment.