Skip to content

Commit 2496027

Browse files
committed
client/modules/User/components/APIKeyList: add types, remove extra PropType & update to named export
1 parent 7a55433 commit 2496027

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

client/modules/User/components/APIKeyForm.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1-
import PropTypes from 'prop-types';
21
import React, { useState } from 'react';
32
import { useTranslation } from 'react-i18next';
43
import { useDispatch, useSelector } from 'react-redux';
54
import { Button, ButtonTypes } from '../../../common/Button';
65
import { PlusIcon } from '../../../common/icons';
76
import CopyableInput from '../../IDE/components/CopyableInput';
87
import { createApiKey, removeApiKey } from '../actions';
9-
10-
import APIKeyList from './APIKeyList';
8+
import { APIKeyList } from './APIKeyList';
119
import { RootState } from '../../../reducers';
1210
import { SanitisedApiKey } from '../../../../common/types';
1311

14-
export const APIKeyPropType = PropTypes.shape({
15-
id: PropTypes.string.isRequired,
16-
token: PropTypes.string,
17-
label: PropTypes.string.isRequired,
18-
createdAt: PropTypes.string.isRequired,
19-
lastUsedAt: PropTypes.string
20-
});
21-
2212
export const APIKeyForm = () => {
2313
const { t } = useTranslation();
2414
const apiKeys = useSelector((state: RootState) => state.user.apiKeys) ?? [];

client/modules/User/components/APIKeyList.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import { orderBy } from 'lodash';
43
import { useTranslation } from 'react-i18next';
5-
6-
import { APIKeyPropType } from './APIKeyForm';
7-
4+
import type { SanitisedApiKey } from '../../../../common/types';
85
import {
96
distanceInWordsToNow,
107
formatDateToString
118
} from '../../../utils/formatDate';
129
import TrashCanIcon from '../../../images/trash-can.svg';
1310

14-
function APIKeyList({ apiKeys, onRemove }) {
11+
export interface APIKeyListProps {
12+
apiKeys: SanitisedApiKey[];
13+
onRemove: (key: SanitisedApiKey) => void;
14+
}
15+
export function APIKeyList({ apiKeys, onRemove }: APIKeyListProps) {
1516
const { t } = useTranslation();
1617
return (
1718
<table className="api-key-list">
@@ -50,10 +51,3 @@ function APIKeyList({ apiKeys, onRemove }) {
5051
</table>
5152
);
5253
}
53-
54-
APIKeyList.propTypes = {
55-
apiKeys: PropTypes.arrayOf(PropTypes.shape(APIKeyPropType)).isRequired,
56-
onRemove: PropTypes.func.isRequired
57-
};
58-
59-
export default APIKeyList;

0 commit comments

Comments
 (0)