Skip to content

Commit 12d603b

Browse files
authored
Merge pull request #12 from mikecao/master
Version bump
2 parents 20be9af + c5d2386 commit 12d603b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2055
-943
lines changed

.github/workflows/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
.
2929
3030
- name: Docker login
31-
env:
32-
CR_PAT: ${{ secrets.CR_PAT }}
33-
run: docker login -u $GITHUB_ACTOR -p $CR_PAT ghcr.io
31+
run: >-
32+
echo "${{ secrets.GITHUB_TOKEN }}"
33+
| docker login -u "${{ github.actor }}" --password-stdin ghcr.io
3434
3535
- name: Push image to GitHub
3636
run: |

components/common/Button.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import ReactTooltip from 'react-tooltip';
34
import classNames from 'classnames';
45
import Icon from './Icon';
56
import styles from './Button.module.css';
67

7-
export default function Button({
8+
function Button({
89
type = 'button',
910
icon,
1011
size,
@@ -43,3 +44,19 @@ export default function Button({
4344
</button>
4445
);
4546
}
47+
48+
Button.propTypes = {
49+
type: PropTypes.oneOf(['button', 'submit', 'reset']),
50+
icon: PropTypes.node,
51+
size: PropTypes.oneOf(['xlarge', 'large', 'medium', 'small', 'xsmall']),
52+
variant: PropTypes.oneOf(['action', 'danger', 'light']),
53+
children: PropTypes.node,
54+
className: PropTypes.string,
55+
tooltip: PropTypes.node,
56+
tooltipId: PropTypes.string,
57+
disabled: PropTypes.bool,
58+
iconRight: PropTypes.bool,
59+
onClick: PropTypes.func,
60+
};
61+
62+
export default Button;

components/common/ButtonGroup.js

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import classNames from 'classnames';
34
import Button from './Button';
45
import styles from './ButtonGroup.module.css';
56

6-
export default function ButtonGroup({
7-
items = [],
8-
selectedItem,
9-
className,
10-
size,
11-
icon,
12-
onClick = () => {},
13-
}) {
7+
function ButtonGroup({ items = [], selectedItem, className, size, icon, onClick = () => {} }) {
148
return (
159
<div className={classNames(styles.group, className)}>
1610
{items.map(item => {
@@ -30,3 +24,19 @@ export default function ButtonGroup({
3024
</div>
3125
);
3226
}
27+
28+
ButtonGroup.propTypes = {
29+
items: PropTypes.arrayOf(
30+
PropTypes.shape({
31+
label: PropTypes.node,
32+
value: PropTypes.any.isRequired,
33+
}),
34+
),
35+
selectedItem: PropTypes.any,
36+
className: PropTypes.string,
37+
size: PropTypes.oneOf(['xlarge', 'large', 'medium', 'small', 'xsmall']),
38+
icon: PropTypes.node,
39+
onClick: PropTypes.func,
40+
};
41+
42+
export default ButtonGroup;

components/common/Calendar.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ import {
1818
} from 'date-fns';
1919
import Button from './Button';
2020
import useLocale from 'hooks/useLocale';
21-
import { dateFormat } from 'lib/lang';
21+
import { dateFormat } from 'lib/date';
2222
import { chunk } from 'lib/array';
23+
import { dateLocales } from 'lib/lang';
2324
import Chevron from 'assets/chevron-down.svg';
2425
import Cross from 'assets/times.svg';
2526
import styles from './Calendar.module.css';
@@ -105,8 +106,8 @@ export default function Calendar({ date, minDate, maxDate, onChange }) {
105106
}
106107

107108
const DaySelector = ({ date, minDate, maxDate, locale, onSelect }) => {
108-
const startWeek = startOfWeek(date);
109-
const startMonth = startOfMonth(date);
109+
const startWeek = startOfWeek(date, { locale: dateLocales[locale] });
110+
const startMonth = startOfMonth(date, { locale: dateLocales[locale] });
110111
const startDay = subDays(startMonth, startMonth.getDay());
111112
const month = date.getMonth();
112113
const year = date.getFullYear();

components/common/Checkbox.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { useRef } from 'react';
2+
import PropTypes from 'prop-types';
23
import Icon from 'components/common/Icon';
34
import Check from 'assets/check.svg';
45
import styles from './Checkbox.module.css';
56

6-
export default function Checkbox({ name, value, label, onChange }) {
7+
function Checkbox({ name, value, label, onChange }) {
78
const ref = useRef();
89

910
return (
@@ -25,3 +26,12 @@ export default function Checkbox({ name, value, label, onChange }) {
2526
</div>
2627
);
2728
}
29+
30+
Checkbox.propTypes = {
31+
name: PropTypes.string,
32+
value: PropTypes.any,
33+
label: PropTypes.node,
34+
onChange: PropTypes.func,
35+
};
36+
37+
export default Checkbox;

components/common/CopyButton.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React, { useState } from 'react';
2+
import PropTypes from 'prop-types';
23
import Button from './Button';
34
import { FormattedMessage } from 'react-intl';
45

56
const defaultText = (
67
<FormattedMessage id="label.copy-to-clipboard" defaultMessage="Copy to clipboard" />
78
);
89

9-
export default function CopyButton({ element, ...props }) {
10+
function CopyButton({ element, ...props }) {
1011
const [text, setText] = useState(defaultText);
1112

1213
function handleClick() {
@@ -24,3 +25,13 @@ export default function CopyButton({ element, ...props }) {
2425
</Button>
2526
);
2627
}
28+
29+
CopyButton.propTypes = {
30+
element: PropTypes.shape({
31+
current: PropTypes.shape({
32+
select: PropTypes.func.isRequired,
33+
}),
34+
}),
35+
};
36+
37+
export default CopyButton;

components/common/DateFilter.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React, { useState } from 'react';
2+
import PropTypes from 'prop-types';
23
import { FormattedMessage } from 'react-intl';
34
import { endOfYear, isSameDay } from 'date-fns';
45
import Modal from './Modal';
56
import DropDown from './DropDown';
67
import DatePickerForm from 'components/forms/DatePickerForm';
78
import useLocale from 'hooks/useLocale';
8-
import { getDateRange } from 'lib/date';
9-
import { dateFormat } from 'lib/lang';
9+
import { getDateRange, dateFormat } from 'lib/date';
1010
import Calendar from 'assets/calendar-alt.svg';
1111
import Icon from './Icon';
1212

@@ -54,7 +54,8 @@ const filterOptions = [
5454
},
5555
];
5656

57-
export default function DateFilter({ value, startDate, endDate, onChange, className }) {
57+
function DateFilter({ value, startDate, endDate, onChange, className }) {
58+
const [locale] = useLocale();
5859
const [showPicker, setShowPicker] = useState(false);
5960
const displayValue =
6061
value === 'custom' ? (
@@ -68,7 +69,7 @@ export default function DateFilter({ value, startDate, endDate, onChange, classN
6869
setShowPicker(true);
6970
return;
7071
}
71-
onChange(getDateRange(value));
72+
onChange(getDateRange(value, locale));
7273
}
7374

7475
function handlePickerChange(value) {
@@ -117,3 +118,13 @@ const CustomRange = ({ startDate, endDate, onClick }) => {
117118
</>
118119
);
119120
};
121+
122+
DateFilter.propTypes = {
123+
value: PropTypes.string,
124+
startDate: PropTypes.instanceOf(Date),
125+
endDate: PropTypes.instanceOf(Date),
126+
onChange: PropTypes.func,
127+
className: PropTypes.string,
128+
};
129+
130+
export default DateFilter;

components/common/Dot.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import classNames from 'classnames';
34
import styles from './Dot.module.css';
45

5-
export default function Dot({ color, size, className }) {
6+
function Dot({ color, size, className }) {
67
return (
78
<div className={styles.wrapper}>
89
<div
@@ -15,3 +16,11 @@ export default function Dot({ color, size, className }) {
1516
</div>
1617
);
1718
}
19+
20+
Dot.propTypes = {
21+
color: PropTypes.string,
22+
size: PropTypes.oneOf(['small', 'large']),
23+
className: PropTypes.string,
24+
};
25+
26+
export default Dot;

components/common/DropDown.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import React, { useState, useRef } from 'react';
2+
import PropTypes from 'prop-types';
23
import classNames from 'classnames';
34
import Menu from './Menu';
45
import useDocumentClick from 'hooks/useDocumentClick';
56
import Chevron from 'assets/chevron-down.svg';
67
import styles from './Dropdown.module.css';
78
import Icon from './Icon';
89

9-
export default function DropDown({
10-
value,
11-
className,
12-
menuClassName,
13-
options = [],
14-
onChange = () => {},
15-
}) {
10+
function DropDown({ value, className, menuClassName, options = [], onChange = () => {} }) {
1611
const [showMenu, setShowMenu] = useState(false);
1712
const ref = useRef();
1813
const selectedOption = options.find(e => e.value === value);
@@ -52,3 +47,18 @@ export default function DropDown({
5247
</div>
5348
);
5449
}
50+
51+
DropDown.propTypes = {
52+
value: PropTypes.any,
53+
className: PropTypes.string,
54+
menuClassName: PropTypes.string,
55+
options: PropTypes.arrayOf(
56+
PropTypes.shape({
57+
value: PropTypes.any.isRequired,
58+
label: PropTypes.node,
59+
}),
60+
),
61+
onChange: PropTypes.func,
62+
};
63+
64+
export default DropDown;

components/common/EmptyPlaceholder.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import Icon from 'components/common/Icon';
34
import Logo from 'assets/logo.svg';
45
import styles from './EmptyPlaceholder.module.css';
56

6-
export default function EmptyPlaceholder({ msg, children }) {
7+
function EmptyPlaceholder({ msg, children }) {
78
return (
89
<div className={styles.placeholder}>
910
<Icon className={styles.icon} icon={<Logo />} size="xlarge" />
10-
<h2>{msg}</h2>
11+
<h2 className={styles.msg}>{msg}</h2>
1112
{children}
1213
</div>
1314
);
1415
}
16+
17+
EmptyPlaceholder.propTypes = {
18+
msg: PropTypes.node,
19+
children: PropTypes.node,
20+
};
21+
22+
export default EmptyPlaceholder;

components/common/EmptyPlaceholder.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@
99
.icon {
1010
margin-bottom: 30px;
1111
}
12+
13+
.msg {
14+
margin-bottom: 15px;
15+
}

components/common/Favicon.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import styles from './Favicon.module.css';
34

45
function getHostName(url) {
56
const match = url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:/\n?=]+)/im);
67
return match && match.length > 1 ? match[1] : null;
78
}
89

9-
export default function Favicon({ domain, ...props }) {
10+
function Favicon({ domain, ...props }) {
1011
const hostName = domain ? getHostName(domain) : null;
1112

1213
return hostName ? (
@@ -19,3 +20,9 @@ export default function Favicon({ domain, ...props }) {
1920
/>
2021
) : null;
2122
}
23+
24+
Favicon.propTypes = {
25+
domain: PropTypes.string,
26+
};
27+
28+
export default Favicon;

components/common/FilterButtons.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import ButtonLayout from 'components/layout/ButtonLayout';
34
import ButtonGroup from './ButtonGroup';
45

5-
export default function FilterButtons({ buttons, selected, onClick }) {
6+
function FilterButtons({ buttons, selected, onClick }) {
67
return (
78
<ButtonLayout>
89
<ButtonGroup size="xsmall" items={buttons} selectedItem={selected} onClick={onClick} />
910
</ButtonLayout>
1011
);
1112
}
13+
14+
FilterButtons.propTypes = {
15+
buttons: PropTypes.arrayOf(
16+
PropTypes.shape({
17+
label: PropTypes.node,
18+
value: PropTypes.any.isRequired,
19+
}),
20+
),
21+
selected: PropTypes.any,
22+
onClick: PropTypes.func,
23+
};
24+
25+
export default FilterButtons;

components/common/Icon.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import classNames from 'classnames';
34
import styles from './Icon.module.css';
45

5-
export default function Icon({ icon, className, size = 'medium', ...props }) {
6+
function Icon({ icon, className, size = 'medium', ...props }) {
67
return (
78
<div
89
className={classNames(styles.icon, className, {
@@ -18,3 +19,11 @@ export default function Icon({ icon, className, size = 'medium', ...props }) {
1819
</div>
1920
);
2021
}
22+
23+
Icon.propTypes = {
24+
className: PropTypes.string,
25+
icon: PropTypes.node.isRequired,
26+
size: PropTypes.oneOf(['xlarge', 'large', 'medium', 'small', 'xsmall']),
27+
};
28+
29+
export default Icon;

0 commit comments

Comments
 (0)