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

✨ Add debug flag for analysis #1601

Merged
merged 1 commit into from
Dec 11, 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
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 @@ -212,7 +212,7 @@
identity?: Ref;
createTime?: string;
createUser?: string;
id: any;

Check warning on line 215 in client/src/app/api/models.ts

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
enabled: boolean;
}

Expand Down Expand Up @@ -324,6 +324,7 @@
tagger: {
enabled: boolean;
};
verbosity: number;
mode: {
binary: boolean;
withDeps: boolean;
Expand Down Expand Up @@ -368,7 +369,7 @@

export interface TaskgroupTask {
name: string;
data: any;

Check warning on line 372 in client/src/app/api/models.ts

View workflow job for this annotation

GitHub Actions / unit-test (18.x)

Unexpected any. Specify a different type
application: Ref;
}

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>
);
};
Loading