Skip to content

Commit

Permalink
Remove deprecated Component.defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
leSamo committed Oct 17, 2024
1 parent 3b56873 commit d64cdf2
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import CSAwRuleSummary from './CSAwRuleSummary';
import './CSAwRuleBox.scss';
import { HashLink } from 'react-router-hash-link';

const CSAwRuleBox = ({ rules, synopsis, intl, setHeaderFilters, headerFilters }) => {
const CSAwRuleBox = ({ rules = [], synopsis, intl, setHeaderFilters, headerFilters }) => {
const sortedRules = [].concat(rules).sort((a, b) => (b.systems_affected - a.systems_affected));
const handleExposedSystemFilter = (ruleId) => {
setHeaderFilters(headerFilters?.rule !== ruleId
Expand Down Expand Up @@ -252,10 +252,6 @@ const CSAwRuleBox = ({ rules, synopsis, intl, setHeaderFilters, headerFilters })
};
/*eslint-enable max-len*/

CSAwRuleBox.defaultProps = {
rules: []
};

CSAwRuleBox.propTypes = {
intl: PropTypes.any,
rules: PropTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ renderer.link = function() {

marked.setOptions({ renderer });

const CSAwRuleSummary = ({ text, truncate, intl, ...props }) => {
const CSAwRuleSummary = ({ text, truncate = true, intl, ...props }) => {
const dangerousHtml = (text) => ({ __html: sanitizeHtml(text) });

return (text &&
Expand All @@ -41,12 +41,6 @@ const CSAwRuleSummary = ({ text, truncate, intl, ...props }) => {
</TextContent>
</StackItem>
);

};

CSAwRuleSummary.defaultProps = {
truncate: true,
link: null
};

CSAwRuleSummary.propTypes = {
Expand Down
16 changes: 9 additions & 7 deletions src/Components/PresentationalComponents/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ import { intl } from '../../../Utilities/IntlProvider';
import { Split, SplitItem } from '@patternfly/react-core';
import BaseDropdown from '../BaseDropdown/BaseDropdown';

const Header = ({ title, actions, breadcrumbs, showBreadcrumb, children, actionsOuiaId, labels }) => {
const Header = ({
title = intl.formatMessage(messages.cvesHeader),
actions = [],
breadcrumbs,
showBreadcrumb = true,
children,
actionsOuiaId,
labels
}) => {

return (
<PageHeader>
Expand Down Expand Up @@ -38,12 +46,6 @@ const Header = ({ title, actions, breadcrumbs, showBreadcrumb, children, actions
);
};

Header.defaultProps = {
showBreadcrumb: true,
actions: [],
title: intl.formatMessage(messages.cvesHeader)
};

Header.propTypes = {
breadcrumbs: propTypes.array,
actions: propTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const kebabItemDownloadPDF = (loading, downloadReport, props = {}) => (
className="pf-v5-c-dropdown__menu-item"
onClick={() => downloadReport(true)} {...props}
>
{loading ? <FormattedMessage {...messages.loading} /> : <FormattedMessage {...messages.kebabexportToPDF} />}
{loading ? <FormattedMessage {...messages.loading} /> : <FormattedMessage {...messages.kebabExportToPDF} />}
</button>
</DropdownItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import propTypes from 'prop-types';
import React from 'react';
import { DEFAULT_PAGE_SIZE } from '../../../Helpers/constants';

const PaginationWrapper = ({ apply, meta, variant }) => {
const PaginationWrapper = ({ apply, meta, variant = PaginationVariant.bottom }) => {
const { page, total_items: totalItems, page_size: pageSize } = meta;

const handleChangePage = (_event, pageNumber) => apply({ page: pageNumber });
Expand All @@ -27,10 +27,6 @@ const PaginationWrapper = ({ apply, meta, variant }) => {
);
};

PaginationWrapper.defaultProps = {
variant: 'bottom'
};

PaginationWrapper.propTypes = {
apply: propTypes.func.isRequired,
meta: propTypes.object.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { marked } from 'marked';
import propTypes from 'prop-types';
import sanitizeHtml from 'sanitize-html';

const ReportDetails = ({ report, kbaDetail, kbaLoading }) => {
const ReportDetails = ({ report = {}, kbaDetail = {}, kbaLoading }) => {
const rule = report.rule || report;
const templateProcessor = (template, definitions) => {
const DOT_SETTINGS = { ...doT.templateSettings, varname: ['pydata'], strip: false };
Expand Down Expand Up @@ -121,11 +121,6 @@ const ReportDetails = ({ report, kbaDetail, kbaLoading }) => {

export default ReportDetails;

ReportDetails.defaultProps = {
report: {},
kbaDetail: {}
};

ReportDetails.propTypes = {
report: propTypes.object,
kbaDetail: propTypes.object,
Expand Down
6 changes: 0 additions & 6 deletions src/Components/SmartComponents/CVEs/CVEsTableToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,6 @@ CVEsTableToolbarWithContext.propTypes = {
canToggleCvesWithoutErrata: propTypes.bool
};

CVEsTableToolbarWithContext.defaultProps = {
totalNumber: 0,
apply: () => undefined,
downloadReport: () => undefined
};

const CVEsTableToolbar = props => (
<CVETableContext.Consumer>
{context => <CVEsTableToolbarWithContext context={context} {...props} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import messages from '../../../../Messages';
import PageLoading from '../../../PresentationalComponents/Snippets/PageLoading';
import useFeatureFlag from '../../../../Utilities/useFeatureFlag';

const ImmutableDevices = ({ intl, cveName, filterRuleValues, inventoryRef, headerFilters }) => {
const ImmutableDevices = ({ intl, cveName, filterRuleValues, inventoryRef, headerFilters = {} }) => {
const [[canReadHostsInventory], isLoadingInventory] = useRbac([
PERMISSIONS.readHosts
], 'inventory');
Expand Down Expand Up @@ -137,9 +137,6 @@ const ImmutableDevices = ({ intl, cveName, filterRuleValues, inventoryRef, heade
/>;
};

ImmutableDevices.defaultProps = {
headerFilters: {}
};
ImmutableDevices.propTypes = {
cveName: propTypes.string,
intl: propTypes.object,
Expand Down
4 changes: 0 additions & 4 deletions src/Components/SmartComponents/Reports/Common/firstPagePDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ const firstPagePDF = ({ data, meta, filters, intl, isReportDynamic, reportData,
);
};

firstPagePDF.defaultProps = {
user: undefined
};

firstPagePDF.propTypes = {
intl: PropTypes.any,
filters: PropTypes.array,
Expand Down
9 changes: 2 additions & 7 deletions src/Components/SmartComponents/Reports/DownloadCVEsReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const DownloadCVEsReport = ({
reportData = {},
buttonProps,
isReportDynamic = false,
label,
shouldUseHybridSystemFilter,
label = messages.kebabExportToPDF,
shouldUseHybridSystemFilter = false,
...props
}) => {
const intl = useIntl();
Expand Down Expand Up @@ -186,11 +186,6 @@ const DownloadCVEsReport = ({
);
};

DownloadCVEsReport.defaultProps = {
label: messages.kebabexportToPDF,
shouldUseHybridSystemFilter: false
};

DownloadCVEsReport.propTypes = {
filters: propTypes.oneOfType([
propTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const DownloadSystemsReport = ({
params,
reportData = {},
buttonProps,
label,
label = messages.kebabExportToPDF,
...props
}) => {
const intl = useIntl();
Expand Down Expand Up @@ -109,10 +109,6 @@ const DownloadSystemsReport = ({
);
};

DownloadSystemsReport.defaultProps = {
label: messages.kebabexportToPDF
};

DownloadSystemsReport.propTypes = {
filters: propTypes.oneOfType([
propTypes.array,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ const SystemCveToolbarWithContext = ({
);
};

SystemCveToolbarWithContext.defaultProps = {
totalNumber: 0,
apply: () => undefined,
downloadReport: () => undefined
};

SystemCveToolbarWithContext.propTypes = {
entity: propTypes.string,
context: propTypes.object,
Expand All @@ -162,4 +156,5 @@ SystemCveToolbarWithContext.propTypes = {
const SystemCveToolbar = props => (
<CVETableContext.Consumer>{context => <SystemCveToolbarWithContext context={context} {...props} />}</CVETableContext.Consumer>
);

export default injectIntl(SystemCveToolbar);
32 changes: 8 additions & 24 deletions src/Components/SmartComponents/SystemCves/SystemCves.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ export const CVETableContext = createContext({});
export const SystemCVEs = ({
entity,
intl,
showHeaderLabel,
setPageTitle,
showHeaderLabel = false,
setPageTitle = false,
canExport,
customAction,
canSelect,
canEditPairStatus,
canManageColumns,
canSelect = true,
canEditPairStatus = true,
canManageColumns = true,
defaultColumns,
filters,
linkToCustomerPortal
linkToCustomerPortal = false
}) => {
const dispatch = useDispatch();
const [StatusModal, setStatusModal] = useState(() => () => null);
Expand Down Expand Up @@ -267,16 +267,6 @@ export const SystemCVEs = ({
}
};

SystemCVEs.defaultProps = {
allowedCveActions: [],
showHeaderLabel: false,
setPageTitle: false,
canSelect: true,
canManageColumns: true,
canEditPairStatus: true,
linkToCustomerPortal: false
};

SystemCVEs.propTypes = {
entity: propTypes.object,
intl: propTypes.any,
Expand All @@ -294,14 +284,14 @@ SystemCVEs.propTypes = {

export const ConnectedSystemCves = injectIntl(SystemCVEs);

const TranslateSystemCves = ({ customItnlProvider, customIntlProvider, ...props }) => {
const TranslateSystemCves = ({ customItnlProvider = false, customIntlProvider = false, customRouter = false, ...props }) => {
const Wrapper = (customItnlProvider || customIntlProvider) ? IntlProvider : Fragment;

return <Wrapper {...(customItnlProvider || customIntlProvider) && {
locale: navigator.language.slice(0, 2),
messages
}} >
<ConnectedSystemCves {...props} />
<ConnectedSystemCves customRouter={customRouter} {...props} />
</Wrapper>;
};

Expand All @@ -311,10 +301,4 @@ TranslateSystemCves.propTypes = {
customRouter: propTypes.bool
};

TranslateSystemCves.defaultProps = {
customItnlProvider: false,
customIntlProvider: false,
customRouter: false
};

export default TranslateSystemCves;
2 changes: 1 addition & 1 deletion src/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ export default defineMessages({
description: 'Title label for systems PDF report',
defaultMessage: 'Insights Vulnerability Systems report'
},
kebabexportToPDF: {
kebabExportToPDF: {
id: 'kebab.exportToPDF',
description: 'Kebab item',
defaultMessage: 'Export to PDF'
Expand Down

0 comments on commit d64cdf2

Please sign in to comment.