Skip to content

Commit

Permalink
Revert "Introduce webview for measurement pages (#972)"
Browse files Browse the repository at this point in the history
This reverts commit 9ad1e63.
  • Loading branch information
majakomel committed Nov 26, 2024
1 parent 9ad1e63 commit 127f461
Show file tree
Hide file tree
Showing 30 changed files with 2,409 additions and 2,408 deletions.
15 changes: 9 additions & 6 deletions components/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,16 @@ const Chart = memo(function Chart({
)}
{error && (
<DetailsBox
collapsed={false}
content={
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
<>
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
</>
}
/>
)}
Expand Down
12 changes: 0 additions & 12 deletions components/ConditionalWrapper.js

This file was deleted.

15 changes: 9 additions & 6 deletions components/DomainChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ const Chart = memo(function Chart({ queryParams = {}, setState }) {
</div>
{error && (
<DetailsBox
collapsed={false}
content={
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
<>
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
</>
}
/>
)}
Expand Down
26 changes: 10 additions & 16 deletions components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { useMemo } from 'react'
import { StyledStickyNavBar } from 'components/SharedStyledComponents'
import { UserProvider } from 'hooks/useUser'
import { useRouter } from 'next/router'
import ConditionalWrapper from './ConditionalWrapper'
import Footer from './Footer'
import Header from './Header'
import NavBar from './NavBar'

const Layout = ({ children, isEmbeddedView }) => {
const Layout = ({ children }) => {
const { pathname } = useRouter()

const navbarColor = useMemo(() => {
Expand All @@ -32,28 +31,23 @@ const Layout = ({ children, isEmbeddedView }) => {

return (
<UserProvider>
<div className="site flex flex-col min-h-[100vh]">
<div className="site text-sm flex flex-col min-h-[100vh]">
<div className="flex-[1_0_auto]">
<Header />
{!isEmbeddedView && (
<ConditionalWrapper
condition={!!navbarSticky}
wrapper={(children) => (
<StyledStickyNavBar>{children}</StyledStickyNavBar>
)}
>
{navbarSticky ? (
<StyledStickyNavBar>
<NavBar color={navbarColor} />
</ConditionalWrapper>
</StyledStickyNavBar>
) : (
<NavBar color={navbarColor} />
)}
<div className={`content ${!navbarColor && 'mt-[-66px]'}`}>
{children}
</div>
</div>
{!isEmbeddedView && (
<div className="flex-shrink-0">
<Footer />
</div>
)}
<div className="flex-shrink-0">
<Footer />
</div>
</div>
</UserProvider>
)
Expand Down
2 changes: 1 addition & 1 deletion components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const NavBar = ({ color }) => {
</div>
)}
<div
className={`flex gap-4 lg:gap-8 text-sm ${showMenu && 'pt-2 flex-col items-start [&>a]:border-black [&>a]:hover:border-black [&>*]:opacity-100 [&>*]:text-black [&>*]:hover:text-black'}`}
className={`flex gap-4 lg:gap-8 ${showMenu && 'pt-2 flex-col items-start [&>a]:border-black [&>a]:hover:border-black [&>*]:opacity-100 [&>*]:text-black [&>*]:hover:text-black'}`}
>
<NavItem
label={<FormattedMessage id="Navbar.Findings" />}
Expand Down
4 changes: 2 additions & 2 deletions components/SocialButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const SocialButtons = ({ url }) => {
const intl = useIntl()

return (
<div className="flex gap-2 items-center">
<div className="flex px-2 items-center">
<MdShare height="20px" width="20px" />
<div>
<div className="pl-2 text-right">
{intl.formatMessage(
{ id: 'SocialButtons.CTA' },
{
Expand Down
5 changes: 4 additions & 1 deletion components/aggregation/mat/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ const Filters = ({ data = [], tableData, setDataForCharts, query }) => {
})

return (
<DetailsBox title={intl.formatMessage({ id: 'MAT.Table.Filters' })}>
<DetailsBox
title={intl.formatMessage({ id: 'MAT.Table.Filters' })}
collapsed={false}
>
<div className="flex flex-col">
<div className="flex mb-4 items-center">
<button
Expand Down
2 changes: 1 addition & 1 deletion components/aggregation/mat/Help.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const boxTitle = (

const Help = () => {
return (
<DetailsBox title={boxTitle}>
<DetailsBox title={boxTitle} collapsed={false}>
<FormattedMarkdown id="MAT.Help.Content" />
<div className="flex flex-col">
{[...getCategoryCodesMap().values()].map(
Expand Down
51 changes: 28 additions & 23 deletions components/country/ConfirmedBlockedCategory.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,32 +56,37 @@ const ConfirmedBlockedCategory = () => {
id: 'Country.Websites.ConfirmedBlockedCategories',
})}
</h3>
{!blockedCategoriesData && !error ? (
<div> Loading ...</div>
) : blockedCategoriesData === null ||
blockedCategoriesData.length === 0 ? (
<h5>
<FormattedMessage id="General.NoData" />
</h5>
) : (
<div className="flex flex-wrap gap-2">
{blockedCategoriesData?.map((category) => (
<CategoryBadge
key={category.category_code}
categoryCode={category.category_code}
/>
))}
</div>
)}
<>
{!blockedCategoriesData && !error ? (
<div> Loading ...</div>
) : blockedCategoriesData === null ||
blockedCategoriesData.length === 0 ? (
<h5>
<FormattedMessage id="General.NoData" />
</h5>
) : (
<div className="flex flex-wrap gap-2">
{blockedCategoriesData?.map((category) => (
<CategoryBadge
key={category.category_code}
categoryCode={category.category_code}
/>
))}
</div>
)}
</>
{error && (
<DetailsBox
collapsed={false}
content={
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
<>
<details>
<summary>
<span>Error: {error.message}</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
</>
}
/>
)}
Expand Down
20 changes: 12 additions & 8 deletions components/dashboard/Charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,19 @@ const Chart = memo(function Chart({ testName }) {
</div>
{error && (
<DetailsBox
collapsed={false}
content={
<details>
<summary>
<span>
{intl.formatMessage({ id: 'General.Error' })}: {error.message}
</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
<>
<details>
<summary>
<span>
{intl.formatMessage({ id: 'General.Error' })}:{' '}
{error.message}
</span>
</summary>
<pre>{JSON.stringify(error, null, 2)}</pre>
</details>
</>
}
/>
)}
Expand Down
87 changes: 46 additions & 41 deletions components/measurement/CommonDetails.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import dynamic from 'next/dynamic'
import { useRouter } from 'next/router'
import { colors } from 'ooni-components'
import PropTypes from 'prop-types'
import { useContext, useState } from 'react'
import { useState } from 'react'
import { FormattedMessage, useIntl } from 'react-intl'

import { EmbeddedViewContext } from '../../pages/m/[measurement_uid]'
import { DetailsBox, DetailsBoxTable } from './DetailsBox'

const LoadingRawData = () => {
Expand All @@ -21,7 +21,7 @@ const ReactJson = dynamic(() => import('react-json-view'), {
})

const JsonViewer = ({ src, collapsed }) => (
<div className="text-xs md:text-sm [&_.string-value]:overflow-ellipsis [&_.string-value]:max-w-[800px] [&_.string-value]:overflow-hidden [&_.string-value]:inline-block">
<div className="[&_.string-value]:overflow-ellipsis [&_.string-value]:max-w-[800px] [&_.string-value]:overflow-hidden [&_.string-value]:inline-block">
<ReactJson collapsed={collapsed} src={src} name={null} indentWidth={2} />
</div>
)
Expand All @@ -45,8 +45,6 @@ const CommonDetails = ({
resolver_network_name,
} = measurement ?? {}

const isEmbeddedView = useContext(EmbeddedViewContext)

const { query } = useRouter()
const queryString = new URLSearchParams(query)
const rawMsmtDownloadURL = `${process.env.NEXT_PUBLIC_OONI_API}/api/v1/raw_measurement?${queryString}`
Expand Down Expand Up @@ -139,35 +137,42 @@ const CommonDetails = ({
return (
<>
{showResolverItems && (
// Resolver data
<DetailsBoxTable
title={
<FormattedMessage id="Measurement.CommonDetails.Label.Resolver" />
}
items={resolverItems}
/>
<div className="flex my-8">
{/* Resolver data */}
<DetailsBoxTable
title={
<FormattedMessage id="Measurement.CommonDetails.Label.Resolver" />
}
items={resolverItems}
/>
</div>
)}
{/* Metadata: platform, probe, MK version etc. */}
<DetailsBoxTable items={items} className="bg-gray-200" />
<div className="flex my-8">
{/* Metadata: platform, probe, MK version etc. */}
<DetailsBoxTable items={items} className="bg-gray-200" />
</div>
{/* User Feedback */}
{!!userFeedbackItems.length && (
<DetailsBoxTable
title={
<FormattedMessage id="Measurement.CommonDetails.Label.UserFeedback" />
}
items={userFeedbackItems}
/>
<div className="flex my-8">
<DetailsBoxTable
title={
<FormattedMessage id="Measurement.CommonDetails.Label.UserFeedback" />
}
items={userFeedbackItems}
/>
</div>
)}
{/* Raw Measurement */}
<DetailsBox
title={
<div className="flex flex-1 justify-between flex-col md:flex-row items-center bg-gray-200">
<div className="self-start">
{intl.formatMessage({
id: 'Measurement.CommonDetails.RawMeasurement.Heading',
})}
</div>
{!isEmbeddedView && (
<div className="flex">
<DetailsBox
collapsed={false}
title={
<div className="flex flex-1 px-4 justify-between flex-col md:flex-row items-center bg-gray-200">
<div>
{intl.formatMessage({
id: 'Measurement.CommonDetails.RawMeasurement.Heading',
})}
</div>
<div className="flex">
<a
className="text-blue-700"
Expand Down Expand Up @@ -196,19 +201,19 @@ const CommonDetails = ({
})}
</button>
</div>
)}
</div>
}
content={
measurement && typeof measurement === 'object' ? (
<div className="flex bg-white" style={{ direction: 'ltr' }}>
<JsonViewer src={measurement} collapsed={collapsed} />
</div>
) : (
<FormattedMessage id="Measurement.CommonDetails.RawMeasurement.Unavailable" />
)
}
/>
}
content={
measurement && typeof measurement === 'object' ? (
<div className="flex bg-white p-4" style={{ direction: 'ltr' }}>
<JsonViewer src={measurement} collapsed={collapsed} />
</div>
) : (
<FormattedMessage id="Measurement.CommonDetails.RawMeasurement.Unavailable" />
)
}
/>
</div>
</>
)
}
Expand Down
Loading

0 comments on commit 127f461

Please sign in to comment.