Skip to content

Commit

Permalink
Upgrade ooni-components
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Jun 29, 2023
1 parent 209030f commit 43a3717
Show file tree
Hide file tree
Showing 18 changed files with 593 additions and 1,294 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"prettier.semi": false,
"prettier.singleQuote": true
}
2 changes: 1 addition & 1 deletion components/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const TestGroupBadge = ({ testName, ...props }) => {
export const CategoryBadge = ({ categoryCode }) => {
let IconComponent
try {
IconComponent = require(`ooni-components/dist/icons/CategoryCode${categoryCode}`).default
IconComponent = require(`ooni-components/icons/CategoryCode${categoryCode}`).default
} catch {
IconComponent = null
}
Expand Down
2 changes: 1 addition & 1 deletion components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import { Flex, Box, Container, Link } from 'ooni-components'
import ExplorerLogo from 'ooni-components/components/svgs/logos/OONI-HorizontalMonochromeInverted.svg'
import ExplorerLogo from 'ooni-components/svgs/logos/OONI-HorizontalMonochromeInverted.svg'
import { useIntl } from 'react-intl'
import dayjs from 'dayjs'

Expand Down
6 changes: 4 additions & 2 deletions components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import NLink from 'next/link'
import styled from 'styled-components'
import { FormattedMessage, useIntl } from 'react-intl'
import { getLocalisedLanguageName } from 'utils/i18nCountries'
import ExplorerLogo from 'ooni-components/components/svgs/logos/Explorer-HorizontalMonochromeInverted.svg'
import ExplorerLogo from 'ooni-components/svgs/logos/Explorer-HorizontalMonochromeInverted.svg'
import {
Link,
Flex,
Expand Down Expand Up @@ -102,7 +102,9 @@ export const NavBar = ({color}) => {
>
<Box style={{zIndex: 1}}>
<NLink href='/' passHref>
<Link><ExplorerLogo height='26px' /></Link>
<Link>
<ExplorerLogo height='26px' />
</Link>
</NLink>
</Box>
<Box mt={[2, 0]}>
Expand Down
2 changes: 1 addition & 1 deletion components/aggregation/mat/ChartHeader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Flex, Heading, Text } from 'ooni-components'
import OONILogo from 'ooni-components/components/svgs/logos/OONI-HorizontalMonochrome.svg'
import OONILogo from 'ooni-components/svgs/logos/OONI-HorizontalMonochrome.svg'
import { useIntl } from 'react-intl'

import { colorMap } from './colorMap'
Expand Down
56 changes: 11 additions & 45 deletions components/aggregation/mat/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import { useRouter } from 'next/router'
const DAY_GRAIN_THRESHOLD_IN_MONTHS = 12
const WEEK_GRAIN_THRESHOLD_IN_MONTHS = 36

export const StyledLabel = styled(Label).attrs({
my: 2,
color: 'blue5',
})`
`

const messages = defineMessages({
'measurement_start_day': {
id: 'MAT.Form.Label.AxisOption.measurement_start_day',
Expand Down Expand Up @@ -253,12 +247,9 @@ export const Form = ({ onSubmit, query }) => {
<ConfirmationModal show={showConfirmation} onConfirm={onConfirm} onCancel={onCancel} />
<Flex my={2} alignItems='center' flexDirection={['column', 'row']}>
<Box width={[1, 3/12]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.Country' />
</StyledLabel>
<Controller
render={({field}) => (
<Select {...field} width={1}>
<Select {...field} label={intl.formatMessage({id: 'Search.Sidebar.Country'})} width={1}>
<option value=''>{intl.formatMessage({id: 'MAT.Form.AllCountries'})}</option>
{sortedCountries.map((c, idx) =>(
<option key={idx} value={c.iso3166_alpha2}>{c.localisedCountryName}</option>
Expand All @@ -270,15 +261,13 @@ export const Form = ({ onSubmit, query }) => {
/>
</Box>
<Box width={[1, 1/12]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.ASN' />
</StyledLabel>
<Controller
name='probe_asn'
control={control}
render={({field}) => (
<Input
placeholder='AS1234'
label={intl.formatMessage({id: 'Search.Sidebar.ASN'})}
{...field}
/>
)}
Expand All @@ -287,31 +276,27 @@ export const Form = ({ onSubmit, query }) => {
<Box width={[1, 2/12]} mx={[0, 2]}>
<Flex>
<Box width={1} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.From' />
</StyledLabel>
<Controller
name='since'
control={control}
render={({field}) => (
<Input
{...field}
label={intl.formatMessage({id: 'Search.Sidebar.From'})}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
/>
)}
/>
</Box>
<Box width={1} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.Until' />
</StyledLabel>
<Controller
name='until'
control={control}
render={({field}) => (
<Input
{...field}
label={intl.formatMessage({id: 'Search.Sidebar.Until'})}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
/>
Expand All @@ -328,14 +313,11 @@ export const Form = ({ onSubmit, query }) => {
}
</Box>
<Box width={[1, 2/12]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='MAT.Form.Label.TimeGrain' />
</StyledLabel>
<Controller
name='time_grain'
control={control}
render={({field}) => (
<Select {...field} width={1}>
<Select {...field} label={intl.formatMessage({id: 'MAT.Form.Label.TimeGrain'})} width={1}>
{timeGrainOptions.map((option, idx) => (
<option key={idx} value={option}>{intl.formatMessage(messages[option])}</option>
))}
Expand All @@ -344,14 +326,11 @@ export const Form = ({ onSubmit, query }) => {
/>
</Box>
<Box width={[1, 2/12]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='MAT.Form.Label.XAxis' />
</StyledLabel>
<Controller
name='axis_x'
control={control}
render={({field}) => (
<Select {...field} width={1}>
<Select {...field} label={intl.formatMessage({id: 'MAT.Form.Label.XAxis'})} width={1}>
{xAxisOptionsFiltered.map((option, idx) => (
<option key={idx} value={option}>{option.length > 0 ? intl.formatMessage(messages[option]) : option}</option>
))}
Expand All @@ -360,14 +339,11 @@ export const Form = ({ onSubmit, query }) => {
/>
</Box>
<Box width={[1, 2/12]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='MAT.Form.Label.YAxis' />
</StyledLabel>
<Controller
name='axis_y'
control={control}
render={({field}) => (
<Select {...field} width={1}>
<Select {...field} label={intl.formatMessage({id: 'MAT.Form.Label.YAxis'})} width={1}>
{yAxisOptionsFiltered.map((option, idx) => (
<option key={idx} value={option}>{option.length > 0 ? intl.formatMessage(messages[option]) : option}</option>
))}
Expand All @@ -378,14 +354,11 @@ export const Form = ({ onSubmit, query }) => {
</Flex>
<Flex my={2} flexDirection={['column', 'row']}>
<Box width={[1, 1/5]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.TestName' />
</StyledLabel>
<Controller
name='test_name'
control={control}
render={({field}) => (
<Select {...field} width={1}>
<Select {...field} label={intl.formatMessage({id: 'Search.Sidebar.TestName'})} width={1}>
<TestNameOptions includeAllOption={false} />
</Select>
)}
Expand All @@ -394,44 +367,37 @@ export const Form = ({ onSubmit, query }) => {
{showWebConnectivityFilters &&
<>
<Box width={[1, 1/5]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.Domain' />
</StyledLabel>
<Controller
name='domain'
control={control}
render={({field}) => (
<Input
label={intl.formatMessage({id: 'Search.Sidebar.Domain'})}
placeholder='twitter.com'
{...field}
/>
)}
/>
</Box>
<Box width={[1, 1/5]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.Input' />
</StyledLabel>
<Controller
name='input'
control={control}
render={({field}) => (
<Input
label={intl.formatMessage({id: 'Search.Sidebar.Input'})}
placeholder='https://fbcdn.net/robots.txt'
{...field}
/>
)}
/>
</Box>
<Box width={[1, 1/5]} mx={[0, 2]}>
<StyledLabel>
<FormattedMessage id='Search.Sidebar.Categories' />
</StyledLabel>
<Controller
name='category_code'
control={control}
render={({field}) => (
<Select {...field}>
<Select label={intl.formatMessage({id: 'Search.Sidebar.Categories'})} {...field}>
<option value="">{intl.formatMessage({id: 'MAT.Form.All'})}</option>
{categoryCodes
.sort((a, b) => a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0)
Expand Down
5 changes: 2 additions & 3 deletions components/as/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useIntl } from 'react-intl'
import dayjs from 'services/dayjs'
import { format } from 'date-fns'

import { StyledLabel } from '../aggregation/mat/Form'
import DateRangePicker from '../DateRangePicker'

const Form = ({ onSubmit, since, until }) => {
Expand Down Expand Up @@ -52,27 +51,27 @@ const Form = ({ onSubmit, since, until }) => {
<Box width={[1, 1/5]}>
<Flex>
<Box width={2/3} mr={3}>
<StyledLabel>{intl.formatMessage({id: 'Search.Sidebar.From'})}</StyledLabel>
<Controller
name='since'
control={control}
render={({field}) => (
<Input
{...field}
label={intl.formatMessage({id: 'Search.Sidebar.From'})}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
/>
)}
/>
</Box>
<Box width={2/3} mr={3}>
<StyledLabel>{intl.formatMessage({id: 'Search.Sidebar.Until'})}</StyledLabel>
<Controller
name='until'
control={control}
render={({field}) => (
<Input
{...field}
label={intl.formatMessage({id: 'Search.Sidebar.Until'})}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
/>
Expand Down
7 changes: 3 additions & 4 deletions components/dashboard/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import dayjs from 'services/dayjs'
import { format } from 'date-fns'
import { getLocalisedRegionName } from '../../utils/i18nCountries'

import { StyledLabel } from '../aggregation/mat/Form'
import DateRangePicker from '../DateRangePicker'

const tomorrow = dayjs.utc().add(1, 'day').format('YYYY-MM-DD')
Expand Down Expand Up @@ -95,7 +94,7 @@ export const Form = ({ onChange, query, availableCountries }) => {
<form>
<Flex alignItems={['center']} flexDirection={['column', 'row']}>
<Box width={[1, 1/4]} mr={3} sx={{ zIndex: 2 }}>
<StyledLabel>{intl.formatMessage({id: 'Search.Sidebar.Country'})}</StyledLabel>
{intl.formatMessage({id: 'Search.Sidebar.Country'})}
{<Controller
render={({field}) => (
<MultiSelect
Expand All @@ -113,13 +112,13 @@ export const Form = ({ onChange, query, availableCountries }) => {
<Box width={[1, 1/5]}>
<Flex>
<Box width={1/2} mr={3}>
<StyledLabel>{intl.formatMessage({id: 'Search.Sidebar.From'})}</StyledLabel>
<Controller
name='since'
control={control}
render={({field}) => (
<Input
{...field}
label={intl.formatMessage({id: 'Search.Sidebar.From'})}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
name={field.name}
Expand All @@ -130,12 +129,12 @@ export const Form = ({ onChange, query, availableCountries }) => {
/>
</Box>
<Box width={1/2} mr={3}>
<StyledLabel>{intl.formatMessage({id: 'Search.Sidebar.Until'})}</StyledLabel>
<Controller
name='until'
control={control}
render={({field}) => (
<Input
label={intl.formatMessage({id: 'Search.Sidebar.Until'})}
{...field}
onFocus={() => setShowDatePicker(true)}
onKeyDown={() => setShowDatePicker(false)}
Expand Down
Loading

0 comments on commit 43a3717

Please sign in to comment.