Skip to content

Commit

Permalink
chore: remove defaultProps to get rid of warning messages (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanFl authored Aug 30, 2024
1 parent 10a6686 commit e9f0268
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 64 deletions.
2 changes: 0 additions & 2 deletions frontend/src/commons/custom_fields/LabeledTextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ const LabeledTextField = (props: LabeledTextFieldProps) => {
);
};

LabeledTextField.defaultProps = { label: "" };

export default LabeledTextField;
2 changes: 0 additions & 2 deletions frontend/src/commons/custom_fields/MarkdownField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ const MarkdownField = (props: MarkdownProps) => {
);
};

MarkdownField.defaultProps = { label: "" };

export default MarkdownField;
2 changes: 0 additions & 2 deletions frontend/src/commons/custom_fields/ObservationsCountField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,4 @@ const ObservationsCountField = (props: ObservationsProps) => {
) : null;
};

ObservationsCountField.defaultProps = { label: "Open observations" };

export default ObservationsCountField;
6 changes: 2 additions & 4 deletions frontend/src/commons/custom_fields/SecurityGateTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChipField, useRecordContext } from "react-admin";

interface SecurityGateTextProps {
sortable: boolean;
label: string;
}

Expand All @@ -26,9 +25,10 @@ export const SecurityGateTextField = (props: SecurityGateTextProps) => {

return record && record.security_gate_passed != null ? (
<ChipField
label={props.label}
source="text"
record={get_text_record()}
sortable={props.sortable}
sortable={true}
sortBy="security_gate_passed"
sx={{
backgroundColor: get_severity_color(),
Expand All @@ -37,5 +37,3 @@ export const SecurityGateTextField = (props: SecurityGateTextProps) => {
/>
) : null;
};

SecurityGateTextField.defaultProps = { label: "Security gate", sortable: true };
5 changes: 1 addition & 4 deletions frontend/src/commons/custom_fields/SeverityField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { get_severity_color } from "../functions";

interface SeverityProps {
source: string;
sortable: boolean;
label: string;
}

Expand All @@ -30,7 +29,7 @@ export const SeverityField = (props: SeverityProps) => {
return record ? (
<ChipField
source={props.source}
sortable={props.sortable}
sortable={true}
sortBy={props.source}
sx={{
backgroundColor: get_severity_color(get_current_severity(record)),
Expand All @@ -40,5 +39,3 @@ export const SeverityField = (props: SeverityProps) => {
/>
) : null;
};

SeverityField.defaultProps = { label: "Severity", sortable: true };
2 changes: 0 additions & 2 deletions frontend/src/commons/custom_fields/TextUrlField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,4 @@ const TextUrlField = (props: TextUrlFieldProps) => {
);
};

TextUrlField.defaultProps = { label: "" };

export default TextUrlField;
8 changes: 6 additions & 2 deletions frontend/src/core/branches/BranchEmbeddedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ const BranchEmbeddedList = ({ product }: BranchEmbeddedListProps) => {
<WithRecord
label="Name"
render={(branch) => (
<TextUrlField text={branch.name} url={get_observations_url(product.id, branch.id)} />
<TextUrlField
label="Name"
text={branch.name}
url={get_observations_url(product.id, branch.id)}
/>
)}
/>
<BooleanField source="is_default_branch" label="Default branch / version" sortable={false} />
<TextField source="purl" label="PURL" />
<TextField source="cpe23" label="CPE 2.3" />
<ObservationsCountField withLabel={false} />
<ObservationsCountField label="Open observations" withLabel={false} />
<DateField source="last_import" showTime />
<WithRecord
label="Protect"
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/core/observation_logs/ObservationLogShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const ObservationLogComponent = () => {
<TextField source="user_full_name" />
</Labeled>
{observation_log.severity && (
<Labeled label="Severity">
<SeverityField source="severity" />
<Labeled>
<SeverityField label="Severity" source="severity" />
</Labeled>
)}
{observation_log.status && (
Expand Down Expand Up @@ -147,8 +147,8 @@ const ObservationLogComponent = () => {
/>
</Labeled>
)}
<Labeled label="Comment">
<MarkdownField content={observation_log.comment} />
<Labeled>
<MarkdownField content={observation_log.comment} label="Comment" />
</Labeled>
<Labeled label="Created">
<DateField source="created" showTime />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ObservationDashboardList = () => {
>
<TextField source="product_data.name" label="Product" />
<TextField source="title" sx={{ wordBreak: "break-word" }} />
<SeverityField source="current_severity" />
<SeverityField label="Severity" source="current_severity" />
<ChipField source="current_status" label="Status" />
<TextField source="scanner_name" label="Scanner" />
<FunctionField<Observation>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/observations/ObservationEmbeddedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const ObservationsEmbeddedList = ({ product }: ObservationsEmbeddedListProps) =>
>
{product && product.has_branches && <TextField source="branch_name" label="Branch / Version" />}
<TextField source="title" />
<SeverityField source="current_severity" />
<SeverityField label="Severity" source="current_severity" />
<ChipField source="current_status" label="Status" />
{product && product.has_component && <NumberField source="epss_score" label="EPSS" />}
{product && product.has_services && <TextField source="origin_service_name" label="Service" />}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/observations/ObservationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const ObservationList = () => {
<TextField source="product_data.product_group_name" label="Group" />
<TextField source="branch_name" label="Branch / Version" />
<TextField source="title" />
<SeverityField source="current_severity" />
<SeverityField label="Severity" source="current_severity" />
<ChipField source="current_status" label="Status" />
<NumberField source="epss_score" label="EPSS" />
<TextField source="origin_service_name" label="Service" />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/observations/ObservationReviewList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const ObservationsReviewList = ({ product }: ObservationsReviewListProps) => {
>
<TextField source="branch_name" label="Branch / Version" />
<TextField source="title" />
<SeverityField source="current_severity" />
<SeverityField label="Severity" source="current_severity" />
{product && product.has_component && <NumberField source="epss_score" label="EPSS" />}
<ChipField source="current_status" label="Status" />
{product && product.has_services && <TextField source="origin_service_name" label="Service" />}
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/core/observations/ObservationShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const ObservationShowComponent = () => {
<Stack direction="row" spacing={4}>
<Stack spacing={2}>
<Labeled>
<SeverityField source="current_severity" />
<SeverityField label="Severity" source="current_severity" />
</Labeled>
{observation.parser_severity != "" &&
(observation.rule_severity != "" || observation.assessment_severity != "") && (
Expand Down Expand Up @@ -193,8 +193,9 @@ const ObservationShowComponent = () => {
)}
{observation.vulnerability_id != "" &&
get_vulnerability_url(observation.vulnerability_id) != null && (
<Labeled label="Vulnerability ID">
<Labeled>
<TextUrlField
label="Vulnerability ID"
text={observation.vulnerability_id}
url={
observation.vulnerability_id &&
Expand All @@ -214,8 +215,12 @@ const ObservationShowComponent = () => {
</Labeled>
)}
{observation.cwe != null && (
<Labeled label="CWE">
<TextUrlField text={observation.cwe} url={get_cwe_url(observation.cwe)} />
<Labeled>
<TextUrlField
label="CWE"
text={observation.cwe}
url={get_cwe_url(observation.cwe)}
/>
</Labeled>
)}
{observation.epss_score != null && (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/core/observations/ObservationShowAside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ const MetaData = () => {
/>
)}
{observation.issue_tracker_issue_id != "" && (
<Labeled label="Issue">
<Labeled>
<TextUrlField
label="Issue"
text={
observation.product_data.issue_tracker_type +
" #" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const ObservationShowDescriptionRecommendation = () => {
return (
<Stack spacing={2}>
{observation && observation.description != "" && (
<Labeled label="Description" sx={{ paddingTop: 2 }}>
<MarkdownField content={observation.description} />
<Labeled sx={{ paddingTop: 2 }}>
<MarkdownField content={observation.description} label="Description" />
</Labeled>
)}
{observation && observation.recommendation != "" && (
<Labeled label="Recommendation">
<MarkdownField content={observation.recommendation} />
<Labeled>
<MarkdownField content={observation.recommendation} label="Recommendation" />
</Labeled>
)}
</Stack>
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/core/observations/ObservationShowOrigins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ const ObservationShowOrigins = ({ elevated }: ObservationShowOriginsProps) => {
observation.origin_component_purl_type,
observation.origin_component_purl_namespace
) != null && (
<Labeled label="Component PURL">
<Labeled>
<TextUrlField
label="Component PURL"
text={observation.origin_component_purl}
url={
observation.origin_component_purl &&
Expand Down Expand Up @@ -130,8 +131,9 @@ const ObservationShowOrigins = ({ elevated }: ObservationShowOriginsProps) => {
Endpoint
</Typography>
{observation.origin_endpoint_url != "" && (
<Labeled label="Endpoint URL">
<Labeled>
<TextUrlField
label="Endpoint URL"
text={observation.origin_endpoint_url}
url={observation.origin_endpoint_url}
/>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/observations/PotentialDuplicatesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const PotentialDuplicatesList = ({ observation }: PotentialDuplicatesListProps)
resource="potential_duplicates"
>
<TextField source="potential_duplicate_observation.title" label="Title" />
<SeverityField source="potential_duplicate_observation.current_severity" />
<SeverityField label="Severity" source="potential_duplicate_observation.current_severity" />
<ChipField source="potential_duplicate_observation.current_status" label="Status" />
<TextField source="potential_duplicate_observation.origin_service_name" label="Service" />
{observation && observation.product_data.has_component && (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/core/product_groups/ProductGroupHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const ProductGroupHeader = () => {
<Labeled label="Product Group name">
<TextField source="name" className={classes.fontBigBold} />
</Labeled>
<Labeled label="Open observations">
<ObservationsCountField withLabel={true} />
<Labeled>
<ObservationsCountField label="Open observations" withLabel={true} />
</Labeled>
</Paper>
</RecordContextProvider>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/product_groups/ProductGroupList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ProductGroupList = () => {
<Datagrid size={getSettingListSize()} rowClick="show" bulkActionButtons={false}>
<TextField source="name" />
<TextField source="products_count" label="Products" />
<ObservationsCountField withLabel={false} />
<ObservationsCountField label="Open observations" withLabel={false} />
</Datagrid>
</List>
</Fragment>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/core/products/ProductEmbeddedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ const ProductEmbeddedList = ({ product_group }: ProductEmbeddedListProps) => {
label="Default branch / version"
sortable={false}
/>
<SecurityGateTextField />
<ObservationsCountField withLabel={false} />
<SecurityGateTextField label="Security gate" />
<ObservationsCountField label="Open observations" withLabel={false} />
<FunctionField<Product>
label="Last observation change"
sortBy="last_observation_change"
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/core/products/ProductHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const ProductHeader = () => {
</Labeled>
{product && product.security_gate_passed != undefined && (
<Labeled>
<SecurityGateTextField />
<SecurityGateTextField label="Security gate" />
</Labeled>
)}
<Labeled label={get_open_observation_label(product)}>
<ObservationsCountField withLabel={true} />
<Labeled>
<ObservationsCountField label={get_open_observation_label(product)} withLabel={true} />
</Labeled>
</Paper>
</RecordContextProvider>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/core/products/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ const ProductList = () => {
label="Default branch / version"
sortable={false}
/>
<SecurityGateTextField />
<ObservationsCountField withLabel={false} />
<SecurityGateTextField label="Security gate" />
<ObservationsCountField label="Open observations" withLabel={false} />
<FunctionField<Product>
label="Last observation change"
sortBy="last_observation_change"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/core/services/ServiceEmbeddedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const ServiceEmbeddedList = ({ product }: ServiceEmbeddedListProps) => {
<div style={{ width: "100%" }}>
<Datagrid size={getSettingListSize()} sx={{ width: "100%" }} bulkActionButtons={false} rowClick={false}>
<WithRecord
label="Name"
render={(service) => (
<TextUrlField
label="Name"
text={service.name}
url={get_observations_url(product.id, service.id, product.repository_default_branch)}
/>
)}
/>
<ObservationsCountField withLabel={false} />
<ObservationsCountField label="Open observations" withLabel={false} />
<WithRecord
render={(service) => (
<Stack direction="row" spacing={4}>
Expand Down
21 changes: 12 additions & 9 deletions frontend/src/metrics/MetricsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,21 @@ const MetricsHeader = (props: MetricsHeaderProps) => {
{!loading && (
<Fragment>
{props.repository_default_branch && (
<Labeled label="Default branch">
<LabeledTextField text={props.repository_default_branch} />
<Labeled>
<LabeledTextField label="Default branch" text={props.repository_default_branch} />
</Labeled>
)}
<Labeled
label="Metrics last calculated"
sx={{ marginLeft: get_margin_left(props.repository_default_branch) }}
>
<LabeledTextField text={new Date(data.last_calculated).toLocaleString()} />
<Labeled sx={{ marginLeft: get_margin_left(props.repository_default_branch) }}>
<LabeledTextField
label="Metrics last calculated"
text={new Date(data.last_calculated).toLocaleString()}
/>
</Labeled>
<Labeled label="Metrics calculation interval" sx={{ marginLeft: 8 }}>
<LabeledTextField text={data.calculation_interval + " minutes"} />
<Labeled sx={{ marginLeft: 8 }}>
<LabeledTextField
label="Metrics calculation interval"
text={data.calculation_interval + " minutes"}
/>
</Labeled>
</Fragment>
)}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/rules/general_rules/GeneralRuleShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const GeneralRuleComponent = () => {
<TextField source="name" className={classes.fontBigBold} />
</Labeled>
{rule.description && (
<Labeled label="Description">
<MarkdownField content={rule.description} />
<Labeled>
<MarkdownField content={rule.description} label="Description" />
</Labeled>
)}

Expand Down
Loading

0 comments on commit e9f0268

Please sign in to comment.