Skip to content

Commit

Permalink
fix: code smells
Browse files Browse the repository at this point in the history
Signed-off-by: Soham <[email protected]>
  • Loading branch information
4nalog committed Jun 29, 2023
1 parent 72a4496 commit a7bcf4c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 65 deletions.
27 changes: 11 additions & 16 deletions packages/console/src/components/Entities/EntityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { EntityExecutionsBarChart } from './EntityExecutionsBarChart';

const useStyles = makeStyles((theme: Theme) => ({
entityDetailsWrapper: {
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
px: theme.spacing(2),
minHeight: '100vh',
},
metadataContainer: {
Expand Down Expand Up @@ -78,29 +77,29 @@ export const EntityDetails: React.FC<EntityDetailsProps> = ({ id }) => {
/>

<div className={styles.metadataContainer}>
{sections.description ? (
{!!sections.description && (
<div className={styles.descriptionContainer}>
<EntityDescription id={id} />
</div>
) : null}
{!sections.inputs && sections.schedules ? (
)}
{!sections.inputs && sections.schedules && (
<div className={styles.schedulesContainer}>
<EntitySchedules id={id} />
</div>
) : null}
)}
</div>

{sections.inputs ? (
{!!sections.inputs && (
<div className={styles.inputsContainer}>

Check warning on line 93 in packages/console/src/components/Entities/EntityDetails.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Entities/EntityDetails.tsx#L93

Added line #L93 was not covered by tests
<EntityInputs id={id} />
</div>
) : null}
)}

{sections.versions ? (
{!!sections.versions && (
<div className={styles.versionsContainer}>
<EntityVersions id={id} />
</div>
) : null}
)}

<EntityExecutionsBarChart
onToggle={onToggle}
Expand All @@ -117,15 +116,11 @@ export const EntityDetails: React.FC<EntityDetailsProps> = ({ id }) => {
/>
</div>
) : (
<>
<LoadingSpinner />
</>
<LoadingSpinner />

Check warning on line 119 in packages/console/src/components/Entities/EntityDetails.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Entities/EntityDetails.tsx#L119

Added line #L119 was not covered by tests
)}
</>
) : (
<>
<LoadingSpinner />
</>
<LoadingSpinner />
)}
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useStyles = makeStyles<Theme, StyleProps>((theme: Theme) => ({
flexWrap: 'nowrap',
overflow: 'hidden',
height: `calc(100vh - ${theme.spacing(17)}px)`,
padding: `0 ${theme.spacing(2)}`,
padding: theme.spacing(0, 2),
},
staticGraphContainer: {
display: 'flex',
Expand All @@ -42,12 +42,12 @@ const useStyles = makeStyles<Theme, StyleProps>((theme: Theme) => ({
width: '100%',
flex: '1',
overflowY: 'scroll',
padding: `0 ${theme.spacing(2)}`,
padding: theme.spacing(0, 2),
},
versionsContainer: {
display: 'flex',
flex: '0 1 auto',
padding: `0 ${theme.spacing(2)}`,
padding: theme.spacing(0, 2),
height: ({ resourceType }) =>
resourceType === ResourceType.LAUNCH_PLAN ? '100%' : '40%',
flexDirection: 'column',
Expand Down Expand Up @@ -89,39 +89,35 @@ const EntityVersionsDetailsContainerImpl: React.FC<
const [project] = useProject(workflowId.project);

Check warning on line 89 in packages/console/src/components/Entities/VersionDetails/EntityVersionDetailsContainer.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Entities/VersionDetails/EntityVersionDetailsContainer.tsx#L89

Added line #L89 was not covered by tests
const styles = useStyles({ resourceType: id.resourceType });

if (!project?.id) {
return <LoadingSpinner />;

Check warning on line 93 in packages/console/src/components/Entities/VersionDetails/EntityVersionDetailsContainer.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Entities/VersionDetails/EntityVersionDetailsContainer.tsx#L92-L93

Added lines #L92 - L93 were not covered by tests
}

return (
<>
{project?.id ? (
<>
<Box pl={2} pr={2}>
<EntityDetailsHeader
project={project.value}
id={id}
launchable={sections.launch}
backToWorkflow
/>
</Box>
<div className={styles.verionDetailsContainer}>
{versionsSections.details && (
<div className={styles.versionDetailsContainer}>
<EntityVersionDetails id={id} />
</div>
)}
{versionsSections.graph && (
<div className={styles.staticGraphContainer}>
<StaticGraphContainer workflowId={workflowId} />
</div>
)}
<div className={styles.versionsContainer}>
<EntityVersions id={id} showAll />
</div>
<Box pl={2} pr={2}>
<EntityDetailsHeader
project={project.value}
id={id}
launchable={sections.launch}
backToWorkflow
/>
</Box>
<div className={styles.verionDetailsContainer}>
{versionsSections.details && (
<div className={styles.versionDetailsContainer}>
<EntityVersionDetails id={id} />
</div>
)}
{versionsSections.graph && (
<div className={styles.staticGraphContainer}>
<StaticGraphContainer workflowId={workflowId} />
</div>
</>
) : (
<>
<LoadingSpinner />
</>
)}
)}
<div className={styles.versionsContainer}>
<EntityVersions id={id} showAll />
</div>
</div>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const getOperationsFromWorkflowExecutionMetrics = (
const operationIds = uniq(
traverse(data)
.paths()
.filter(path => path[path.length - 1] === 'operationId')
.filter(path => path.at(-1) === 'operationId')
.map(path => get(data, path)),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
const isGAEnabled = env.ENABLE_GA === 'true' && env.GA_TRACKING_ID !== '';

const handleSideNavToggle = React.useCallback(() => {
if (isSideNavOpen) {
closeSideNav();
} else {
openSideNav();
}
return isSideNavOpen ? closeSideNav() : openSideNav();

Check warning on line 48 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L47-L48

Added lines #L47 - L48 were not covered by tests
}, [isSideNavOpen, openSideNav, closeSideNav]);

const theme = useTheme();

Check warning on line 51 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L51

Added line #L51 was not covered by tests
Expand All @@ -62,11 +58,9 @@ export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
showMobileNav();
closeSideNav();

Check warning on line 59 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L54-L59

Added lines #L54 - L59 were not covered by tests
}
} else {
if (isMobileNav) {
hideMobileNav();
closeSideNav();
}
} else if (isMobileNav) {
hideMobileNav();
closeSideNav();

Check warning on line 63 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L61-L63

Added lines #L61 - L63 were not covered by tests
}
};
handleResize();
Expand Down Expand Up @@ -112,7 +106,7 @@ export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
const styles = makeStyles(() => ({

Check warning on line 106 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L106

Added line #L106 was not covered by tests
wordmark: {
position: 'relative',
paddingTop: '22px',
paddingTop: theme.spacing(2.75),
'& > svg': {
height: '22px',
transform: 'translateX(-34px)',
Expand Down Expand Up @@ -171,10 +165,8 @@ export const DefaultAppBarContent = (props: DefaultAppBarProps) => {
</Box>
)}
</Link>
{props.items?.length > 0 ? (
{props.items?.length > 0 && (
<NavigationDropdown items={props.items} console={props.console} />

Check warning on line 169 in packages/console/src/components/Navigation/DefaultAppBarContent.tsx

View check run for this annotation

Codecov / codecov/patch

packages/console/src/components/Navigation/DefaultAppBarContent.tsx#L168-L169

Added lines #L168 - L169 were not covered by tests
) : (
false
)}
</Grid>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion packages/console/src/components/Navigation/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const NavBar = (props: NavBarProps) => {
inset: '0',
},
inlineToolBar: {
padding: `${theme.spacing(2)}px 0 ${theme.spacing(4)}px 0`,
padding: theme.spacing(2, 0, 4, 0),
height: '100%',
},
}))();
Expand Down

0 comments on commit a7bcf4c

Please sign in to comment.