Remove usage of the PropTypes dependency (#2723)
* Remove usage of the PropTypes dependency * Prettified Code! --------- Co-authored-by: dhanusaputra <dhanusaputra@users.noreply.github.com>
This commit is contained in:
parent
0c08f865bc
commit
0a653aaba7
@ -1,9 +1,8 @@
|
|||||||
import PropTypes from 'prop-types';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
export type ColorProps = {
|
export type ColorProps = {
|
||||||
color: any; // TODO specify better type
|
color: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Color: FC<ColorProps> = ({ color }) => {
|
export const Color: FC<ColorProps> = ({ color }) => {
|
||||||
@ -55,10 +54,6 @@ export const Color: FC<ColorProps> = ({ color }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Color.propTypes = {
|
|
||||||
color: PropTypes.string.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
const rowStyle = {
|
const rowStyle = {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'row' as 'row',
|
flexDirection: 'row' as 'row',
|
||||||
@ -66,7 +61,11 @@ const rowStyle = {
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ColorRow = props => {
|
export type ColorRowProps = {
|
||||||
|
colors: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ColorRow: FC<ColorRowProps> = (props: ColorRowProps) => {
|
||||||
const { colors } = props;
|
const { colors } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -78,10 +77,6 @@ export const ColorRow = props => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ColorRow.propTypes = {
|
|
||||||
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getColor = color => {
|
export const getColor = color => {
|
||||||
const colorValue = getComputedStyle(document.documentElement).getPropertyValue(`--${color}`);
|
const colorValue = getComputedStyle(document.documentElement).getPropertyValue(`--${color}`);
|
||||||
return { [color]: colorValue };
|
return { [color]: colorValue };
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { FC, ReactNode, useContext, useEffect, useState } from 'react';
|
import React, { FC, ReactNode, useContext, useEffect, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import { differenceInSeconds } from 'date-fns';
|
import { differenceInSeconds } from 'date-fns';
|
||||||
@ -338,7 +337,3 @@ export const MainLayout: FC<MainLayoutProps> = ({ children }) => {
|
|||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
MainLayout.propTypes = {
|
|
||||||
children: PropTypes.element.isRequired,
|
|
||||||
};
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable react/no-unescaped-entities */
|
/* eslint-disable react/no-unescaped-entities */
|
||||||
import { Typography, Modal, Button, Row, Col, Alert } from 'antd';
|
import { Typography, Modal, Button, Row, Col, Alert } from 'antd';
|
||||||
import React, { ReactElement, useContext, useEffect, useState } from 'react';
|
import React, { ReactElement, useContext, useEffect, useState, FC } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import {
|
import {
|
||||||
TEXTFIELD_TYPE_TEXT,
|
TEXTFIELD_TYPE_TEXT,
|
||||||
TEXTFIELD_TYPE_TEXTAREA,
|
TEXTFIELD_TYPE_TEXTAREA,
|
||||||
@ -29,7 +28,12 @@ import { createInputStatus, STATUS_ERROR, STATUS_SUCCESS } from '../../utils/inp
|
|||||||
|
|
||||||
import { AdminLayout } from '../../components/layouts/AdminLayout';
|
import { AdminLayout } from '../../components/layouts/AdminLayout';
|
||||||
|
|
||||||
const FederationInfoModal = ({ cancelPressed, okPressed }) => (
|
export type FederationInfoModalProps = {
|
||||||
|
cancelPressed: () => void;
|
||||||
|
okPressed: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FederationInfoModal: FC<FederationInfoModalProps> = ({ cancelPressed, okPressed }) => (
|
||||||
<Modal
|
<Modal
|
||||||
width="70%"
|
width="70%"
|
||||||
title="Enable Social Features"
|
title="Enable Social Features"
|
||||||
@ -87,11 +91,6 @@ const FederationInfoModal = ({ cancelPressed, okPressed }) => (
|
|||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
||||||
FederationInfoModal.propTypes = {
|
|
||||||
cancelPressed: PropTypes.func.isRequired,
|
|
||||||
okPressed: PropTypes.func.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
const ConfigFederation = () => {
|
const ConfigFederation = () => {
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
const [formDataValues, setFormDataValues] = useState(null);
|
const [formDataValues, setFormDataValues] = useState(null);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState, FC, ReactElement } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
export const AlertMessageContext = React.createContext({
|
export const AlertMessageContext = React.createContext({
|
||||||
message: null,
|
message: null,
|
||||||
@ -7,7 +6,11 @@ export const AlertMessageContext = React.createContext({
|
|||||||
setMessage: (text?: string) => null,
|
setMessage: (text?: string) => null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const AlertMessageProvider = ({ children }) => {
|
export type AlertMessageProviderProps = {
|
||||||
|
children: ReactElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
const AlertMessageProvider: FC<AlertMessageProviderProps> = ({ children }) => {
|
||||||
const [message, setMessage] = useState('');
|
const [message, setMessage] = useState('');
|
||||||
|
|
||||||
const providerValue = {
|
const providerValue = {
|
||||||
@ -19,8 +22,4 @@ const AlertMessageProvider = ({ children }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
AlertMessageProvider.propTypes = {
|
|
||||||
children: PropTypes.element.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AlertMessageProvider;
|
export default AlertMessageProvider;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// TODO: add a notication after updating info that changes will take place either on a new stream or server restart. may be different for each field.
|
// TODO: add a notication after updating info that changes will take place either on a new stream or server restart. may be different for each field.
|
||||||
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, FC, ReactElement } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import { STATUS, fetchData, FETCH_INTERVAL, SERVER_CONFIG } from './apis';
|
import { STATUS, fetchData, FETCH_INTERVAL, SERVER_CONFIG } from './apis';
|
||||||
import { ConfigDetails, UpdateArgs } from '../types/config-section';
|
import { ConfigDetails, UpdateArgs } from '../types/config-section';
|
||||||
@ -101,7 +100,11 @@ export const ServerStatusContext = React.createContext({
|
|||||||
setFieldInConfigState: (args: UpdateArgs) => null,
|
setFieldInConfigState: (args: UpdateArgs) => null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const ServerStatusProvider = ({ children }) => {
|
export type ServerStatusProviderProps = {
|
||||||
|
children: ReactElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ServerStatusProvider: FC<ServerStatusProviderProps> = ({ children }) => {
|
||||||
const [status, setStatus] = useState(initialServerStatusState);
|
const [status, setStatus] = useState(initialServerStatusState);
|
||||||
const [config, setConfig] = useState(initialServerConfigState);
|
const [config, setConfig] = useState(initialServerConfigState);
|
||||||
|
|
||||||
@ -164,8 +167,4 @@ const ServerStatusProvider = ({ children }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
ServerStatusProvider.propTypes = {
|
|
||||||
children: PropTypes.element.isRequired,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ServerStatusProvider;
|
export default ServerStatusProvider;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user