Skip to content

Commit 4917b38

Browse files
authored
Upgrade UI libs, fix linting issues (#218)
* remove redundant component * upgrade various libraries sort linting issues issues regarding redeclaring types WRT contexts
1 parent 3ecdc27 commit 4917b38

15 files changed

+6107
-3862
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
/lib/framework/WWWData.h
77
/interface/build
88
/interface/node_modules
9+
/interface/.eslintcache
910
.vscode

interface/package-lock.json

+6,065-3,802
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

interface/package.json

+12-13
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,31 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@material-ui/core": "^4.11.0",
7-
"@material-ui/icons": "^4.9.1",
8-
"@types/jwt-decode": "^3.1.0",
6+
"@material-ui/core": "^4.11.2",
7+
"@material-ui/icons": "^4.11.2",
98
"@types/lodash": "^4.14.165",
109
"@types/node": "^12.12.32",
11-
"@types/react": "^16.9.56",
12-
"@types/react-dom": "^16.9.9",
10+
"@types/react": "^17.0.0",
11+
"@types/react-dom": "^17.0.0",
1312
"@types/react-material-ui-form-validator": "^2.1.0",
1413
"@types/react-router": "^5.1.8",
1514
"@types/react-router-dom": "^5.1.6",
1615
"compression-webpack-plugin": "^4.0.0",
17-
"jwt-decode": "^3.1.1",
16+
"jwt-decode": "^3.1.2",
1817
"lodash": "^4.17.20",
19-
"mime-types": "^2.1.27",
18+
"mime-types": "^2.1.28",
2019
"moment": "^2.29.1",
21-
"notistack": "^1.0.1",
22-
"react": "^16.14.0",
23-
"react-dom": "^16.14.0",
20+
"notistack": "^1.0.3",
21+
"react": "^17.0.1",
22+
"react-dom": "^17.0.1",
2423
"react-dropzone": "^11.2.4",
2524
"react-form-validator-core": "^1.0.0",
2625
"react-material-ui-form-validator": "^2.1.1",
2726
"react-router": "^5.2.0",
2827
"react-router-dom": "^5.2.0",
29-
"react-scripts": "3.4.4",
28+
"react-scripts": "4.0.1",
3029
"sockette": "^2.0.6",
31-
"typescript": "^4.0.2",
30+
"typescript": "4.0.5",
3231
"zlib": "^1.0.5"
3332
},
3433
"scripts": {
@@ -52,6 +51,6 @@
5251
]
5352
},
5453
"devDependencies": {
55-
"react-app-rewired": "^2.1.6"
54+
"react-app-rewired": "^2.1.8"
5655
}
5756
}

interface/src/ap/APSettingsForm.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type APSettingsFormProps = RestFormProps<APSettings>;
1717

1818
class APSettingsForm extends React.Component<APSettingsFormProps> {
1919

20-
componentWillMount() {
20+
componentDidMount() {
2121
ValidatorForm.addValidationRule('isIP', isIP);
2222
}
2323

interface/src/authentication/AuthenticatedRoute.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Redirect, Route, RouteProps, RouteComponentProps } from "react-router-d
33
import { withSnackbar, WithSnackbarProps } from 'notistack';
44

55
import * as Authentication from './Authentication';
6-
import { withAuthenticationContext, AuthenticationContextProps, AuthenticatedContext } from './AuthenticationContext';
6+
import { withAuthenticationContext, AuthenticationContextProps, AuthenticatedContext, AuthenticatedContextValue } from './AuthenticationContext';
77

88
type ChildComponent = React.ComponentType<RouteComponentProps<any>> | React.ComponentType<any>;
99

@@ -21,7 +21,7 @@ export class AuthenticatedRoute extends React.Component<AuthenticatedRouteProps>
2121
const renderComponent: RenderComponent = (props) => {
2222
if (authenticationContext.me) {
2323
return (
24-
<AuthenticatedContext.Provider value={authenticationContext as AuthenticatedContext}>
24+
<AuthenticatedContext.Provider value={authenticationContext as AuthenticatedContextValue}>
2525
<Component {...props} />
2626
</AuthenticatedContext.Provider>
2727
);

interface/src/authentication/AuthenticationContext.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ export interface Me {
55
admin: boolean;
66
}
77

8-
export interface AuthenticationContext {
8+
export interface AuthenticationContextValue {
99
refresh: () => void;
1010
signIn: (accessToken: string) => void;
1111
signOut: () => void;
1212
me?: Me;
1313
}
1414

15-
const AuthenticationContextDefaultValue = {} as AuthenticationContext
15+
const AuthenticationContextDefaultValue = {} as AuthenticationContextValue
1616
export const AuthenticationContext = React.createContext(
1717
AuthenticationContextDefaultValue
1818
);
1919

2020
export interface AuthenticationContextProps {
21-
authenticationContext: AuthenticationContext;
21+
authenticationContext: AuthenticationContextValue;
2222
}
2323

2424
export function withAuthenticationContext<T extends AuthenticationContextProps>(Component: React.ComponentType<T>) {
@@ -33,17 +33,17 @@ export function withAuthenticationContext<T extends AuthenticationContextProps>(
3333
};
3434
}
3535

36-
export interface AuthenticatedContext extends AuthenticationContext {
36+
export interface AuthenticatedContextValue extends AuthenticationContextValue {
3737
me: Me;
3838
}
3939

40-
const AuthenticatedContextDefaultValue = {} as AuthenticatedContext
40+
const AuthenticatedContextDefaultValue = {} as AuthenticatedContextValue
4141
export const AuthenticatedContext = React.createContext(
4242
AuthenticatedContextDefaultValue
4343
);
4444

4545
export interface AuthenticatedContextProps {
46-
authenticatedContext: AuthenticatedContext;
46+
authenticatedContext: AuthenticatedContextValue;
4747
}
4848

4949
export function withAuthenticatedContext<T extends AuthenticatedContextProps>(Component: React.ComponentType<T>) {

interface/src/authentication/AuthenticationWrapper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import jwtDecode from 'jwt-decode';
55
import history from '../history'
66
import { VERIFY_AUTHORIZATION_ENDPOINT } from '../api';
77
import { ACCESS_TOKEN, authorizedFetch, getStorage } from './Authentication';
8-
import { AuthenticationContext, Me } from './AuthenticationContext';
8+
import { AuthenticationContext, AuthenticationContextValue, Me } from './AuthenticationContext';
99
import FullScreenLoading from '../components/FullScreenLoading';
1010
import { withFeatures, WithFeaturesProps } from '../features/FeaturesContext';
1111

1212
export const decodeMeJWT = (accessToken: string): Me => jwtDecode(accessToken) as Me;
1313

1414
interface AuthenticationWrapperState {
15-
context: AuthenticationContext;
15+
context: AuthenticationContextValue;
1616
initialized: boolean;
1717
}
1818

interface/src/features/ApplicationContext.tsx

-23
This file was deleted.

interface/src/features/FeaturesContext.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { Features } from './types';
33

4-
export interface FeaturesContext {
4+
export interface FeaturesContextValue {
55
features: Features;
66
}
77

8-
const FeaturesContextDefaultValue = {} as FeaturesContext
8+
const FeaturesContextDefaultValue = {} as FeaturesContextValue
99
export const FeaturesContext = React.createContext(
1010
FeaturesContextDefaultValue
1111
);

interface/src/validators/optional.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export default (validator: (value: any) => boolean) => (value: any) => !value || validator(value);
1+
const OPTIONAL = (validator: (value: any) => boolean) => (value: any) => !value || validator(value);
2+
3+
export default OPTIONAL;

interface/src/validators/or.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
export default (validator1: (value: any) => boolean, validator2: (value: any) => boolean) => {
1+
const OR = (validator1: (value: any) => boolean, validator2: (value: any) => boolean) => {
22
return (value: any) => validator1(value) || validator2(value);
3-
}
3+
};
4+
5+
export default OR;

interface/src/wifi/WiFiConnection.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { MenuAppBar } from '../components';
99
import WiFiStatusController from './WiFiStatusController';
1010
import WiFiSettingsController from './WiFiSettingsController';
1111
import WiFiNetworkScanner from './WiFiNetworkScanner';
12-
import { WiFiConnectionContext } from './WiFiConnectionContext';
12+
import { WiFiConnectionContext, WiFiConnectionContextValue } from './WiFiConnectionContext';
1313
import { WiFiNetwork } from './types';
1414

1515
type WiFiConnectionProps = AuthenticatedContextProps & RouteComponentProps;
1616

17-
class WiFiConnection extends Component<WiFiConnectionProps, WiFiConnectionContext> {
17+
class WiFiConnection extends Component<WiFiConnectionProps, WiFiConnectionContextValue> {
1818

1919
constructor(props: WiFiConnectionProps) {
2020
super(props);
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
22
import { WiFiNetwork } from './types';
33

4-
export interface WiFiConnectionContext {
4+
export interface WiFiConnectionContextValue {
55
selectedNetwork?: WiFiNetwork;
66
selectNetwork: (network: WiFiNetwork) => void;
77
deselectNetwork: () => void;
88
}
99

10-
const WiFiConnectionContextDefaultValue = {} as WiFiConnectionContext
10+
const WiFiConnectionContextDefaultValue = {} as WiFiConnectionContextValue
1111
export const WiFiConnectionContext = React.createContext(
1212
WiFiConnectionContextDefaultValue
1313
);

interface/src/wifi/WiFiSettingsForm.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import SaveIcon from '@material-ui/icons/Save';
1313
import { RestFormProps, PasswordValidator, BlockFormControlLabel, FormActions, FormButton } from '../components';
1414
import { isIP, isHostname, optional } from '../validators';
1515

16-
import { WiFiConnectionContext } from './WiFiConnectionContext';
16+
import { WiFiConnectionContext, WiFiConnectionContextValue } from './WiFiConnectionContext';
1717
import { isNetworkOpen, networkSecurityMode } from './WiFiSecurityModes';
1818
import { WiFiSettings } from './types';
1919

@@ -24,7 +24,7 @@ class WiFiSettingsForm extends React.Component<WiFiStatusFormProps> {
2424
static contextType = WiFiConnectionContext;
2525
context!: React.ContextType<typeof WiFiConnectionContext>;
2626

27-
constructor(props: WiFiStatusFormProps, context: WiFiConnectionContext) {
27+
constructor(props: WiFiStatusFormProps, context: WiFiConnectionContextValue) {
2828
super(props);
2929

3030
const { selectedNetwork } = context;
@@ -39,7 +39,7 @@ class WiFiSettingsForm extends React.Component<WiFiStatusFormProps> {
3939
}
4040
}
4141

42-
componentWillMount() {
42+
componentDidMount() {
4343
ValidatorForm.addValidationRule('isIP', isIP);
4444
ValidatorForm.addValidationRule('isHostname', isHostname);
4545
ValidatorForm.addValidationRule('isOptionalIP', optional(isIP));

interface/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
1919
"noEmit": true,
20-
"jsx": "react"
20+
"jsx": "react",
21+
"noFallthroughCasesInSwitch": true
2122
},
2223
"include": [
2324
"src"

0 commit comments

Comments
 (0)