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

src: Fix "no-unnecessary-condition" issues (HMS-5355) #2760

Merged
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
1 change: 0 additions & 1 deletion src/Components/Blueprints/BlueprintActionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const BlueprintActionsMenu: React.FunctionComponent<
variant="plain"
aria-label="blueprint menu toggle"
data-testid="blueprint-action-menu-toggle"
isDisabled={selectedBlueprintId === undefined}
>
<EllipsisVIcon aria-hidden="true" />
</MenuToggle>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Blueprints/BlueprintsPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const BlueprintsPagination = () => {
const { data: blueprintsData } = useGetBlueprintsQuery(searchParams);
const dispatch = useAppDispatch();

const blueprintsTotal = blueprintsData?.meta?.count || 0;
const blueprintsTotal = blueprintsData?.meta.count || 0;
const onSetPage: OnSetPage = (_, page) => {
const direction = page > currPage ? 1 : -1; // Calculate offset based on direction of paging
const nextOffset = blueprintsOffset + direction * blueprintsLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Blueprints/BlueprintsSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
const dispatch = useAppDispatch();
const blueprints = blueprintsData?.data;

const blueprintsTotal = blueprintsData?.meta?.count || 0;
const blueprintsTotal = blueprintsData?.meta.count || 0;

if (isLoading) {
return (
Expand Down Expand Up @@ -175,7 +175,7 @@
const BlueprintSearch = ({ blueprintsTotal }: blueprintSearchProps) => {
const blueprintSearchInput = useAppSelector(selectBlueprintSearchInput);
const dispatch = useAppDispatch();
const debouncedSearch = useCallback(

Check warning on line 178 in src/Components/Blueprints/BlueprintsSideBar.tsx

View workflow job for this annotation

GitHub Actions / dev-check

React Hook useCallback received a function whose dependencies are unknown. Pass an inline function instead
debounce((filter) => {
dispatch(setBlueprintsOffset(0));
dispatch(imageBuilderApi.util.invalidateTags([{ type: 'Blueprints' }]));
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Blueprints/BuildImagesButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const BuildImagesButton = ({ children }: BuildImagesButtonPropTypes) => {
id: selectedBlueprintId,
body: {
image_types: blueprintImageType?.filter(
(target) => !deselectedTargets?.includes(target)
(target) => !deselectedTargets.includes(target)
),
},
});
Expand Down Expand Up @@ -78,7 +78,7 @@ export const BuildImagesButton = ({ children }: BuildImagesButtonPropTypes) => {
) => {
const imageType = blueprintImageType?.[itemId];

if (imageType && deselectedTargets?.includes(imageType)) {
if (imageType && deselectedTargets.includes(imageType)) {
setDeselectedTargets(
deselectedTargets.filter((target) => target !== imageType)
);
Expand Down Expand Up @@ -143,7 +143,8 @@ export const BuildImagesButton = ({ children }: BuildImagesButtonPropTypes) => {
hasCheckbox
itemId={index}
isSelected={
!deselectedTargets || !deselectedTargets.includes(imageType)
deselectedTargets.length === 0 ||
!deselectedTargets.includes(imageType)
}
>
{targetOptions[imageType]}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Blueprints/DeleteBlueprintModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const DeleteBlueprintModal: React.FunctionComponent<

const { blueprintName } = useGetBlueprintsQuery(searchParams, {
selectFromResult: ({ data }) => ({
blueprintName: data?.data?.find(
blueprintName: data?.data.find(
(blueprint: { id: string | undefined }) =>
blueprint.id === selectedBlueprintId
)?.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const mapOnPremToHosted = (
fips:
blueprint.customizations?.fips !== undefined
? {
enabled: blueprint.customizations?.fips,
enabled: blueprint.customizations.fips,
}
: undefined,
timezone:
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ImagesTable/ImagesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const ImagesTable = () => {
searchParamsGetBlueprints,
{
selectFromResult: ({ data }) => ({
selectedBlueprintVersion: data?.data?.find(
selectedBlueprintVersion: data?.data.find(
(blueprint: BlueprintItem) => blueprint.id === selectedBlueprintId
)?.version,
}),
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ImagesTable/ImagesTableToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ImagesTableToolbar: React.FC<imagesTableToolbarProps> = ({
{ search: blueprintSearchInput as string },
{
selectFromResult: ({ data }) => {
const bp = data?.data?.find(
const bp = data?.data.find(
(blueprint: BlueprintItem) => blueprint.id === selectedBlueprintId
);
return {
Expand Down
10 changes: 3 additions & 7 deletions src/Components/ImagesTable/Instance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type CloudInstancePropTypes = {
export const CloudInstance = ({ compose }: CloudInstancePropTypes) => {
const { initialized: chromeInitialized } = useChrome();
const scalprum = useScalprum();
const hasProvisioning = chromeInitialized && scalprum.config?.provisioning;
const hasProvisioning = chromeInitialized && scalprum.config.provisioning;

const { data, isSuccess } = useGetComposeStatusQuery({
composeId: compose.id,
Expand Down Expand Up @@ -114,7 +114,7 @@ const ProvisioningLink = ({
{ search: blueprintSearchInput },
{
selectFromResult: ({ data }) => ({
selectedBlueprintVersion: data?.data?.find(
selectedBlueprintVersion: data?.data.find(
(blueprint: BlueprintItem) => blueprint.id === selectedBlueprintId
)?.version,
}),
Expand All @@ -128,7 +128,7 @@ const ProvisioningLink = ({
) {
return <DisabledProvisioningLink />;
} else {
const ProvisioningWizard = exposedScalprumModule?.default;
const ProvisioningWizard = exposedScalprumModule.default;
const provider = getImageProvider(compose);

const options = compose.request.image_requests[0].upload_request.options;
Expand Down Expand Up @@ -239,10 +239,6 @@ export const OciInstance = ({ compose, isExpired }: OciInstancePropTypes) => {
composeId: compose.id,
});

if (!isSuccess) {
return <Skeleton />;
}

const options = data?.image_status.upload_status?.options;

if (options && !isOciUploadStatus(options)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ImagesTable/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const AwsDetailsStatus = ({ compose }: ComposeStatusPropTypes) => {
<ErrorStatus
icon={statuses[data.image_status.status].icon}
text={statuses[data.image_status.status].text}
error={data?.image_status?.error || ''}
error={data.image_status.error || ''}
/>
);
default:
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ImagesTable/Target.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const AwsTarget = ({ compose }: AwsTargetPropTypes) => {
return <Skeleton />;
}

const text = `${targetOptions.aws} (${data?.data?.length ?? 0 + 1})`;
const text = `${targetOptions.aws} (${data?.data.length ?? 0 + 1})`;
return <>{text}</>;
};
2 changes: 1 addition & 1 deletion src/Components/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const LandingPage = () => {
}, [initialActiveTabKey]);
const handleTabClick = (_event: React.MouseEvent, tabIndex: number) => {
const tabPath = tabsPath[tabIndex];
if (tabPath !== undefined) {
if (tabPath !== '') {
navigate(tabPath);
}
setActiveTabKey(tabIndex);
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/useDebounce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function useDebounce<T>(
if (!isEqual(value, debouncedValue)) {
const timer = setTimeout(
() => setDebouncedValue(value),
value === '' ? 0 : delay !== undefined ? delay : 500 //If value is empty string, instantly return
value === '' ? 0 : delay //If value is empty string, instantly return
);

return () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/fixtures/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const mockSourcesPackagesResults = (
},
];
}
if (search === 'mock' && isDistroPkgSearch) {
if (search === 'mock') {
return [
{
package_name: 'mockPkg',
Expand Down
Loading