Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 986aecb

Browse files
authored
Merge pull request #62 from YashTotale/code-climate-alerts
Fix Code Climate alerts
2 parents a3bb705 + c02440b commit 986aecb

File tree

15 files changed

+274
-332
lines changed

15 files changed

+274
-332
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
77
**Table of Contents**
88

99
- [[Unreleased]](#unreleased)
10-
- [[1.4.2] - (2020-12-04)](#142---2020-12-04)
10+
- [[1.4.2] - (2020-12-18)](#142---2020-12-18)
1111
- [[v1.4.1] - (2020-12-03)](#v141---2020-12-03)
1212
- [Added](#added)
1313
- [Fixed](#fixed)
@@ -43,7 +43,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/), and this
4343

4444
---
4545

46-
## [1.4.2] - (2020-12-04)
46+
## [1.4.2] - (2020-12-18)
4747

4848
---
4949

website/package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@material-ui/icons": "^4.9.1",
3232
"@material-ui/lab": "^4.0.0-alpha.56",
3333
"@octokit/rest": "^18.0.9",
34+
"lodash.mapvalues": "^4.6.0",
3435
"react": "^17.0.1",
3536
"react-dom": "^17.0.1",
3637
"react-redux": "^7.2.1",
@@ -45,16 +46,19 @@
4546
"@testing-library/react": "^11.2.2",
4647
"@testing-library/user-event": "^12.5.0",
4748
"@types/jest": "^26.0.15",
49+
"@types/lodash.mapvalues": "^4.6.6",
4850
"@types/node": "^14.14.10",
4951
"@types/react": "^17.0.0",
5052
"@types/react-dom": "^17.0.0",
5153
"@types/react-redux": "^7.1.9",
54+
"@types/lodash.isequal": "^4.5.5",
5255
"@types/react-router-dom": "^5.1.5",
5356
"@typescript-eslint/eslint-plugin": "^4.9.0",
5457
"@typescript-eslint/parser": "^4.9.0",
5558
"react-hot-loader": "^4.12.21",
5659
"react-scripts": "4.0.1",
5760
"redux-devtools-extension": "^2.13.8",
61+
"lodash.isequal": "^4.5.0",
5862
"typescript": "^4.1.2",
5963
"web-vitals": "^1.0.1",
6064
"workbox-background-sync": "^6.0.2",

website/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "./markdown.css";
55

66
//Redux Imports
77
import { useDispatch } from "react-redux";
8-
import { getDocs } from "./Redux/thunks";
8+
import { getAllDocs } from "./Redux/thunks";
99

1010
//Page Imports
1111
import Readme from "./Pages/Readme";
@@ -43,7 +43,7 @@ const App: React.FC = (props) => {
4343
const classes = useStyles();
4444

4545
useEffect(() => {
46-
dispatch(getDocs());
46+
dispatch(getAllDocs());
4747
});
4848

4949
return (

website/src/Components/Header.tsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useLocation } from "react-router-dom";
66
import { useDispatch } from "react-redux";
77
import { toggleSidebar } from "../Redux/actions";
88
import { onDemandDataRequest } from "../Redux/thunks";
9-
import { Page } from "../Redux/thunks/docs.thunks";
9+
import { DocType } from "../Redux/reducers/docs.reducers";
1010

1111
// Material UI Imports
1212
import {
@@ -38,13 +38,11 @@ const Header: FC<HeaderProps> = () => {
3838

3939
const root = pathname.split("/")[1];
4040

41-
let page: Page | undefined = undefined;
41+
let page: DocType | null = null;
4242

4343
if (root === "readme" || root === "home" || root === "") page = "readme";
44-
45-
if (root === "components") page = "components";
46-
47-
if (root === "changelog") page = "changelog";
44+
else if (root === "components") page = "components";
45+
else if (root === "changelog") page = "changelog";
4846

4947
const isSizeSmall = useMediaQuery<Theme>((theme) =>
5048
theme.breakpoints.down("md")
@@ -60,18 +58,16 @@ const Header: FC<HeaderProps> = () => {
6058
</IconButton>
6159
</Tooltip>
6260
)}
63-
{page && (
64-
<Tooltip title={`Get Data - ${capitalize(page)}`}>
65-
<IconButton
66-
className={classes.refresh}
67-
onClick={() => {
68-
dispatch(onDemandDataRequest(page ?? "components"));
69-
}}
70-
>
71-
<Cached />
72-
</IconButton>
73-
</Tooltip>
74-
)}
61+
<Tooltip title={`Get Data${page && ` - ${capitalize(page)}`}`}>
62+
<IconButton
63+
className={classes.refresh}
64+
onClick={() => {
65+
dispatch(onDemandDataRequest(page));
66+
}}
67+
>
68+
<Cached />
69+
</IconButton>
70+
</Tooltip>
7571
</Toolbar>
7672
</AppBar>
7773
);

website/src/Components/Sidebar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// React Imports
22
import React, { useState } from "react";
33
import { Link } from "react-router-dom";
4+
import isEqual from "lodash.isequal";
45

56
//Redux Imports
67
import { useDispatch, useSelector } from "react-redux";
@@ -88,7 +89,8 @@ const SideBar: React.FC<SideBarProps> = () => {
8889
interface ContentsProps {}
8990

9091
const Contents: React.FC<ContentsProps> = () => {
91-
const components = useSelector(getComponents);
92+
const components = useSelector(getComponents, isEqual);
93+
const componentNames = Object.keys(components);
9294
const classes = useStyles();
9395

9496
return (
@@ -97,10 +99,10 @@ const Contents: React.FC<ContentsProps> = () => {
9799
<Divider />
98100
<List component="nav" className={classes.list}>
99101
<ListLink to="/home" name="Home" />
100-
{components && (
102+
{componentNames.length > 0 && (
101103
<Category
102104
name="Components"
103-
items={Object.keys(components).map((component) => ({
105+
items={componentNames.map((component) => ({
104106
name: component,
105107
to: components[component].url,
106108
}))}

website/src/Pages/Component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Alerter from "../Components/Alerter";
77
//Redux Imports
88
import { useSelector } from "react-redux";
99
import {
10-
getAreComponentsLoading,
10+
getIsComponentsLoading,
1111
getComponents,
1212
getIsComponentsError,
1313
} from "../Redux/selectors";
@@ -34,7 +34,7 @@ interface ComponentProps {}
3434
const Component: FC<ComponentProps> = () => {
3535
const classes = useStyles();
3636
const components = useSelector(getComponents);
37-
const isLoading = useSelector(getAreComponentsLoading);
37+
const isLoading = useSelector(getIsComponentsLoading);
3838
const isError = useSelector(getIsComponentsError);
3939

4040
const { id } = useParams<Params>();
Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,31 @@
1-
import { Components } from "../reducers/docs.reducers";
1+
import { Components, DocType } from "../reducers/docs.reducers";
22

3-
export const LOAD_COMPONENTS_IN_PROGRESS = "LOAD_COMPONENTS_IN_PROGRESS";
4-
export const loadComponentsInProgress = () => ({
5-
type: LOAD_COMPONENTS_IN_PROGRESS,
6-
payload: {},
7-
});
8-
9-
export const LOAD_README_IN_PROGRESS = "LOAD_README_IN_PROGRESS";
10-
export const loadReadmeInProgress = () => ({
11-
type: LOAD_README_IN_PROGRESS,
12-
payload: {},
13-
});
14-
15-
export const LOAD_CHANGELOG_IN_PROGRESS = "LOAD_CHANGELOG_IN_PROGRESS";
16-
export const loadChangelogInProgress = () => ({
17-
type: LOAD_CHANGELOG_IN_PROGRESS,
18-
payload: {},
19-
});
20-
21-
export const LOAD_COMPONENTS_SUCCESS = "LOAD_COMPONENTS_SUCCESS";
22-
export const loadComponentsSuccess = (components: Components) => ({
23-
type: LOAD_COMPONENTS_SUCCESS,
24-
payload: {
25-
components,
26-
},
27-
});
3+
export const LOAD_DOCS_IN_PROGRESS = "LOAD_DOCS_IN_PROGRESS";
284

29-
export const LOAD_README_SUCCESS = "LOAD_README_SUCCESS";
30-
export const loadReadmeSuccess = (readme: string) => ({
31-
type: LOAD_README_SUCCESS,
5+
export const loadDocsInProgress = (docType: DocType) => ({
6+
type: LOAD_DOCS_IN_PROGRESS,
327
payload: {
33-
readme,
8+
docType,
349
},
3510
});
3611

37-
export const LOAD_CHANGELOG_SUCCESS = "LOAD_CHANGELOG_SUCCESS";
38-
export const loadChangelogSuccess = (changelog: string) => ({
39-
type: LOAD_CHANGELOG_SUCCESS,
12+
export const LOAD_DOCS_SUCCESS = "LOAD_DOCS_SUCCESS";
13+
export const loadDocsSuccess = (
14+
docType: DocType,
15+
docs: string | Components
16+
) => ({
17+
type: LOAD_DOCS_SUCCESS,
4018
payload: {
41-
changelog,
19+
docType,
20+
docs,
4221
},
4322
});
4423

4524
export const LOAD_DOCS_ERROR = "LOAD_DOCS_ERROR";
46-
export const loadDocsError = (error: string) => ({
25+
export const loadDocsError = (docType: DocType | null, error: string) => ({
4726
type: LOAD_DOCS_ERROR,
48-
payload: { error },
49-
});
50-
51-
export const LOAD_COMPONENTS_ERROR = "LOAD_COMPONENTS_ERROR";
52-
export const loadComponentsError = (error: string) => ({
53-
type: LOAD_COMPONENTS_ERROR,
54-
payload: { error },
55-
});
56-
57-
export const LOAD_README_ERROR = "LOAD_README_ERROR";
58-
export const loadReadmeError = (error: string) => ({
59-
type: LOAD_README_ERROR,
60-
payload: { error },
61-
});
62-
63-
export const LOAD_CHANGELOG_ERROR = "LOAD_CHANGELOG_ERROR";
64-
export const loadChangelogError = (error: string) => ({
65-
type: LOAD_CHANGELOG_ERROR,
66-
payload: { error },
27+
payload: {
28+
docType,
29+
error,
30+
},
6731
});

website/src/Redux/actions/index.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
export {
22
//In Progress
3-
LOAD_COMPONENTS_IN_PROGRESS,
4-
loadComponentsInProgress,
5-
LOAD_README_IN_PROGRESS,
6-
loadReadmeInProgress,
7-
LOAD_CHANGELOG_IN_PROGRESS,
8-
loadChangelogInProgress,
3+
LOAD_DOCS_IN_PROGRESS,
4+
loadDocsInProgress,
95
//Success
10-
LOAD_COMPONENTS_SUCCESS,
11-
loadComponentsSuccess,
12-
LOAD_CHANGELOG_SUCCESS,
13-
loadChangelogSuccess,
14-
LOAD_README_SUCCESS,
15-
loadReadmeSuccess,
6+
LOAD_DOCS_SUCCESS,
7+
loadDocsSuccess,
168
//Error
179
LOAD_DOCS_ERROR,
1810
loadDocsError,
19-
LOAD_COMPONENTS_ERROR,
20-
loadComponentsError,
21-
LOAD_README_ERROR,
22-
loadReadmeError,
23-
LOAD_CHANGELOG_ERROR,
24-
loadChangelogError,
2511
} from "./docs.actions";
2612
export { TOGGLE_SIDEBAR, toggleSidebar } from "./display.actions";
2713
export {

0 commit comments

Comments
 (0)