From 39fb8bbc2fea732a0f20bccff629f137da374e34 Mon Sep 17 00:00:00 2001 From: tom goriunov Date: Tue, 31 Oct 2023 09:22:26 -0300 Subject: [PATCH] Suave field rename and ENV for hiding indexing alert in the header (#1312) * Suave chain: rename "Computor" to "Kettle" Fixes #1311 * ENV for hiding indexing alert in the header --- configs/app/ui.ts | 7 ++++++- deploy/tools/envs-validator/schema.ts | 3 ++- deploy/tools/envs-validator/test/.env.base | 3 ++- docs/ENVS.md | 5 +++-- lib/metadata/getPageOgType.ts | 2 +- lib/metadata/templates/description.ts | 2 +- lib/metadata/templates/title.ts | 2 +- lib/mixpanel/getPageType.ts | 2 +- nextjs/nextjs-routes.d.ts | 2 +- pages/txs/{computor => kettle}/[hash].tsx | 6 +++--- ui/pages/{ComputorTxs.tsx => KettleTxs.tsx} | 4 ++-- ui/snippets/footer/Footer.tsx | 2 +- ui/snippets/header/alerts/IndexingBlocksAlert.tsx | 15 ++++++++++++--- ui/tx/TxDetails.tsx | 4 ++-- 14 files changed, 38 insertions(+), 21 deletions(-) rename pages/txs/{computor => kettle}/[hash].tsx (69%) rename ui/pages/{ComputorTxs.tsx => KettleTxs.tsx} (95%) diff --git a/configs/app/ui.ts b/configs/app/ui.ts index ecb35ca1ec..9542917fe9 100644 --- a/configs/app/ui.ts +++ b/configs/app/ui.ts @@ -53,7 +53,12 @@ const UI = Object.freeze({ }, views, indexingAlert: { - isHidden: getEnvValue('NEXT_PUBLIC_HIDE_INDEXING_ALERT'), + blocks: { + isHidden: getEnvValue('NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS') === 'true' ? true : false, + }, + intTxs: { + isHidden: getEnvValue('NEXT_PUBLIC_HIDE_INDEXING_ALERT_INT_TXS') === 'true' ? true : false, + }, }, maintenanceAlert: { message: getEnvValue('NEXT_PUBLIC_MAINTENANCE_ALERT_MESSAGE'), diff --git a/deploy/tools/envs-validator/schema.ts b/deploy/tools/envs-validator/schema.ts index c327e40b1f..77c9f2b394 100644 --- a/deploy/tools/envs-validator/schema.ts +++ b/deploy/tools/envs-validator/schema.ts @@ -408,7 +408,8 @@ const schema = yup .transform(replaceQuotes) .json() .of(networkExplorerSchema), - NEXT_PUBLIC_HIDE_INDEXING_ALERT: yup.boolean(), + NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS: yup.boolean(), + NEXT_PUBLIC_HIDE_INDEXING_ALERT_INT_TXS: yup.boolean(), NEXT_PUBLIC_MAINTENANCE_ALERT_MESSAGE: yup.string(), // 5. Features configuration diff --git a/deploy/tools/envs-validator/test/.env.base b/deploy/tools/envs-validator/test/.env.base index bd90533eff..578d5f91f6 100644 --- a/deploy/tools/envs-validator/test/.env.base +++ b/deploy/tools/envs-validator/test/.env.base @@ -13,7 +13,8 @@ NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://example.com NEXT_PUBLIC_FEATURED_NETWORKS=https://example.com NEXT_PUBLIC_FOOTER_LINKS=https://example.com NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0xf7d4972356e6ae44ae948d0cf19ef2beaf0e574c180997e969a2837da15e349d -NEXT_PUBLIC_HIDE_INDEXING_ALERT=false +NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS=false +NEXT_PUBLIC_HIDE_INDEXING_ALERT_INT_TXS=false NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs'] NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR='#fff' NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND='rgb(255, 145, 0)' diff --git a/docs/ENVS.md b/docs/ENVS.md index 3926721855..42e08940fc 100644 --- a/docs/ENVS.md +++ b/docs/ENVS.md @@ -252,7 +252,8 @@ Settings for meta tags and OG tags | Variable | Type| Description | Compulsoriness | Default value | Example value | | --- | --- | --- | --- | --- | --- | | NEXT_PUBLIC_NETWORK_EXPLORERS | `Array` where `NetworkExplorer` can have following [properties](#network-explorer-configuration-properties) | Used to build up links to transactions, blocks, addresses in other chain explorers. | - | - | `[{'title':'Anyblock','baseUrl':'https://explorer.anyblock.tools','paths':{'tx':'/ethereum/poa/core/tx'}}]` | -| NEXT_PUBLIC_HIDE_INDEXING_ALERT | `boolean` | Set to `true` to hide indexing alert, if the chain indexing isn't completed | - | `false` | `true` | +| NEXT_PUBLIC_HIDE_INDEXING_ALERT_BLOCKS | `boolean` | Set to `true` to hide indexing alert in the page header about indexing chain's blocks | - | `false` | `true` | +| NEXT_PUBLIC_HIDE_INDEXING_ALERT_INT_TXS | `boolean` | Set to `true` to hide indexing alert in the page footer about indexing block's internal transactions | - | `false` | `true` | | NEXT_PUBLIC_MAINTENANCE_ALERT_MESSAGE | `string` | Used for displaying custom announcements or alerts in the header of the site. Could be a regular string or a HTML code. | - | - | `Hello world! 🤪` | #### Network explorer configuration properties @@ -515,7 +516,7 @@ For the smart contract addresses which are [Safe{Core} accounts](https://safe.gl ### SUAVE chain -For blockchains that implementing SUAVE architecture additional fields will be shown on the transaction page ("Allowed peekers", "Computor"). Users also will be able to see the list of all transaction for a particular Computor in the separate view. +For blockchains that implementing SUAVE architecture additional fields will be shown on the transaction page ("Allowed peekers", "Kettle"). Users also will be able to see the list of all transaction for a particular Kettle in the separate view. | Variable | Type| Description | Compulsoriness | Default value | Example value | | --- | --- | --- | --- | --- | --- | diff --git a/lib/metadata/getPageOgType.ts b/lib/metadata/getPageOgType.ts index f575ecad59..5da92870b1 100644 --- a/lib/metadata/getPageOgType.ts +++ b/lib/metadata/getPageOgType.ts @@ -5,7 +5,7 @@ type OGPageType = 'Homepage' | 'Root page' | 'Regular page'; const OG_TYPE_DICT: Record = { '/': 'Homepage', '/txs': 'Root page', - '/txs/computor/[hash]': 'Regular page', + '/txs/kettle/[hash]': 'Regular page', '/tx/[hash]': 'Regular page', '/blocks': 'Root page', '/block/[height_or_hash]': 'Regular page', diff --git a/lib/metadata/templates/description.ts b/lib/metadata/templates/description.ts index a90525adc7..25ced418dd 100644 --- a/lib/metadata/templates/description.ts +++ b/lib/metadata/templates/description.ts @@ -8,7 +8,7 @@ const DEFAULT_TEMPLATE = 'Blockscout is the #1 open-source blockchain explorer a const TEMPLATE_MAP: Record = { '/': DEFAULT_TEMPLATE, '/txs': DEFAULT_TEMPLATE, - '/txs/computor/[hash]': DEFAULT_TEMPLATE, + '/txs/kettle/[hash]': DEFAULT_TEMPLATE, '/tx/[hash]': 'View transaction %hash% on %network_title%', '/blocks': DEFAULT_TEMPLATE, '/block/[height_or_hash]': 'View the transactions, token transfers, and uncles for block %height_or_hash%', diff --git a/lib/metadata/templates/title.ts b/lib/metadata/templates/title.ts index aec42fb6e9..a47e94cf5e 100644 --- a/lib/metadata/templates/title.ts +++ b/lib/metadata/templates/title.ts @@ -3,7 +3,7 @@ import type { Route } from 'nextjs-routes'; const TEMPLATE_MAP: Record = { '/': 'blockchain explorer', '/txs': 'transactions', - '/txs/computor/[hash]': 'computor %hash% transactions', + '/txs/kettle/[hash]': 'kettle %hash% transactions', '/tx/[hash]': 'transaction %hash%', '/blocks': 'blocks', '/block/[height_or_hash]': 'block %height_or_hash%', diff --git a/lib/mixpanel/getPageType.ts b/lib/mixpanel/getPageType.ts index d09caee670..dec0e8dc30 100644 --- a/lib/mixpanel/getPageType.ts +++ b/lib/mixpanel/getPageType.ts @@ -3,7 +3,7 @@ import type { Route } from 'nextjs-routes'; export const PAGE_TYPE_DICT: Record = { '/': 'Homepage', '/txs': 'Transactions', - '/txs/computor/[hash]': 'Computor transactions', + '/txs/kettle/[hash]': 'Kettle transactions', '/tx/[hash]': 'Transaction details', '/blocks': 'Blocks', '/block/[height_or_hash]': 'Block details', diff --git a/nextjs/nextjs-routes.d.ts b/nextjs/nextjs-routes.d.ts index 92bc5e56f9..a39e9e3884 100644 --- a/nextjs/nextjs-routes.d.ts +++ b/nextjs/nextjs-routes.d.ts @@ -42,8 +42,8 @@ declare module "nextjs-routes" { | DynamicRoute<"/token/[hash]/instance/[id]", { "hash": string; "id": string }> | StaticRoute<"/tokens"> | DynamicRoute<"/tx/[hash]", { "hash": string }> - | DynamicRoute<"/txs/computor/[hash]", { "hash": string }> | StaticRoute<"/txs"> + | DynamicRoute<"/txs/kettle/[hash]", { "hash": string }> | StaticRoute<"/verified-contracts"> | StaticRoute<"/visualize/sol2uml"> | StaticRoute<"/withdrawals"> diff --git a/pages/txs/computor/[hash].tsx b/pages/txs/kettle/[hash].tsx similarity index 69% rename from pages/txs/computor/[hash].tsx rename to pages/txs/kettle/[hash].tsx index eb79606c0f..9b62f6dd0d 100644 --- a/pages/txs/computor/[hash].tsx +++ b/pages/txs/kettle/[hash].tsx @@ -5,12 +5,12 @@ import React from 'react'; import type { Props } from 'nextjs/getServerSideProps'; import PageNextJs from 'nextjs/PageNextJs'; -const ComputorTxs = dynamic(() => import('ui/pages/ComputorTxs'), { ssr: false }); +const KettleTxs = dynamic(() => import('ui/pages/KettleTxs'), { ssr: false }); const Page: NextPage = (props: Props) => { return ( - - + + ); }; diff --git a/ui/pages/ComputorTxs.tsx b/ui/pages/KettleTxs.tsx similarity index 95% rename from ui/pages/ComputorTxs.tsx rename to ui/pages/KettleTxs.tsx index 7dfbb9dfca..0e2444dc4e 100644 --- a/ui/pages/ComputorTxs.tsx +++ b/ui/pages/KettleTxs.tsx @@ -9,7 +9,7 @@ import PageTitle from 'ui/shared/Page/PageTitle'; import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages'; import TxsContent from 'ui/txs/TxsContent'; -const ComputorTxs = () => { +const KettleTxs = () => { const router = useRouter(); const hash = getQueryParamString(router.query.hash); @@ -39,4 +39,4 @@ const ComputorTxs = () => { ); }; -export default ComputorTxs; +export default KettleTxs; diff --git a/ui/snippets/footer/Footer.tsx b/ui/snippets/footer/Footer.tsx index e6982c9c35..1aa40a776a 100644 --- a/ui/snippets/footer/Footer.tsx +++ b/ui/snippets/footer/Footer.tsx @@ -117,7 +117,7 @@ const Footer = () => { - { !config.UI.indexingAlert.isHidden && } + { !config.UI.indexingAlert.intTxs.isHidden && } diff --git a/ui/snippets/header/alerts/IndexingBlocksAlert.tsx b/ui/snippets/header/alerts/IndexingBlocksAlert.tsx index 2ababa5df5..888c1bbbd2 100644 --- a/ui/snippets/header/alerts/IndexingBlocksAlert.tsx +++ b/ui/snippets/header/alerts/IndexingBlocksAlert.tsx @@ -5,6 +5,7 @@ import React from 'react'; import type { SocketMessage } from 'lib/socket/types'; import type { IndexingStatus } from 'types/api/indexingStatus'; +import config from 'configs/app'; import useApiQuery, { getResourceKey } from 'lib/api/useApiQuery'; import { useAppContext } from 'lib/contexts/app'; import * as cookies from 'lib/cookies'; @@ -17,7 +18,11 @@ const IndexingBlocksAlert = () => { const cookiesString = appProps.cookies; const [ hasAlertCookie ] = React.useState(cookies.get(cookies.NAMES.INDEXING_ALERT, cookiesString) === 'true'); - const { data, isError, isLoading } = useApiQuery('homepage_indexing_status'); + const { data, isError, isLoading } = useApiQuery('homepage_indexing_status', { + queryOptions: { + enabled: !config.UI.indexingAlert.blocks.isHidden, + }, + }); React.useEffect(() => { if (!isLoading && !isError) { @@ -40,7 +45,7 @@ const IndexingBlocksAlert = () => { const blockIndexingChannel = useSocketChannel({ topic: 'blocks:indexing', - isDisabled: !data || data.finished_indexing_blocks, + isDisabled: !data || data.finished_indexing_blocks || config.UI.indexingAlert.blocks.isHidden, }); useSocketMessage({ @@ -49,12 +54,16 @@ const IndexingBlocksAlert = () => { handler: handleBlocksIndexStatus, }); + if (config.UI.indexingAlert.blocks.isHidden) { + return null; + } + if (isError) { return null; } if (isLoading) { - return hasAlertCookie ? : null; + return hasAlertCookie ? : null; } if (data.finished_indexing_blocks !== false) { diff --git a/ui/tx/TxDetails.tsx b/ui/tx/TxDetails.tsx index fbbbd29da2..8612d8ba57 100644 --- a/ui/tx/TxDetails.tsx +++ b/ui/tx/TxDetails.tsx @@ -225,13 +225,13 @@ const TxDetails = () => { ) } { data.execution_node && ( ) }