diff --git a/packages/apps-config/src/settings/endpoints.ts b/packages/apps-config/src/settings/endpoints.ts index ecfbae6a09..d9756b7f00 100644 --- a/packages/apps-config/src/settings/endpoints.ts +++ b/packages/apps-config/src/settings/endpoints.ts @@ -4,12 +4,15 @@ import { Option } from './types'; -// The available endpoints that will show in the dropdown. For the most part (with the exception of -// Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor -// info: The chain logo name as defined in ../logos, specifically in namedLogos -// text: The text to display on teh dropdown -// value: The actual hosted secure websocket endpoint -export default [ +const DEV: Option[] = [ + { + info: 'local', + text: 'Local Node (Own, 127.0.0.1:9944)', + value: 'ws://127.0.0.1:9944/' + } +]; + +const LIVE: Option[] = [ { info: 'kusama', text: 'Kusama (Polkadot Canary, hosted by Parity)', @@ -20,16 +23,24 @@ export default [ text: 'Kusama (Polkadot Canary, hosted by Web3 Foundation)', value: 'wss://cc3-5.kusama.network/' }, - { - info: 'westend', - text: 'Westend (Polkadot Testnet, hosted by Parity)', - value: 'wss://westend-rpc.polkadot.io' - }, { info: 'edgeware', text: 'Edgeware (Edgeware Mainnet, hosted by Commonwealth Labs)', value: 'wss://mainnet1.edgewa.re' }, + { + info: 'substrate', + text: 'Kulupu (Kulupu Mainnet, hosted by Kulupu)', + value: 'wss://rpc.kulupu.network/ws' + } +]; + +const TEST: Option[] = [ + { + info: 'westend', + text: 'Westend (Polkadot Testnet, hosted by Parity)', + value: 'wss://westend-rpc.polkadot.io' + }, { info: 'edgeware', text: 'Berlin (Edgeware Testnet, hosted by Commonwealth Labs)', @@ -39,15 +50,31 @@ export default [ info: 'substrate', text: 'Flaming Fir (Substrate Testnet, hosted by Parity)', value: 'wss://substrate-rpc.parity.io/' - }, - { - info: 'substrate', - text: 'Kulupu (Kulupu Mainnet, hosted by Kulupu)', - value: 'wss://rpc.kulupu.network/ws' - }, - { - info: 'local', - text: 'Local Node (Own, 127.0.0.1:9944)', - value: 'ws://127.0.0.1:9944/' } +]; + +// The available endpoints that will show in the dropdown. For the most part (with the exception of +// Polkadot) we try to keep this to live chains only, with RPCs hosted by the community/chain vendor +// info: The chain logo name as defined in ../logos, specifically in namedLogos +// text: The text to display on teh dropdown +// value: The actual hosted secure websocket endpoint +export default [ + { + isHeader: true, + text: 'Live networks', + value: -1 + }, + ...LIVE, + { + isHeader: true, + text: 'Test networks', + value: -1 + }, + ...TEST, + { + isHeader: true, + text: 'Development', + value: -1 + }, + ...DEV ].map((option): Option => ({ ...option, withI18n: true })); diff --git a/packages/apps-config/src/settings/types.ts b/packages/apps-config/src/settings/types.ts index de14a07825..90c087817a 100644 --- a/packages/apps-config/src/settings/types.ts +++ b/packages/apps-config/src/settings/types.ts @@ -4,6 +4,7 @@ export interface Option { info?: string; + isHeader?: boolean; text: React.ReactNode; value: string | number; withI18n?: boolean; diff --git a/packages/page-settings/src/General.tsx b/packages/page-settings/src/General.tsx index d072d50979..a573588fdb 100644 --- a/packages/page-settings/src/General.tsx +++ b/packages/page-settings/src/General.tsx @@ -30,8 +30,8 @@ export default function General ({ className, isModalContent, onClose }: Props): const iconOptions = useMemo((): Option[] => { return uiSettings.availableIcons.map((o): Option => createIdenticon(t, o, ['default'])); }, [t]); - const prefixOptions = useMemo((): Option[] => { - return availableSs58.map((o): Option => createOption(t, o, ['default'])); + const prefixOptions = useMemo((): (Option | React.ReactNode)[] => { + return availableSs58.map((o): Option | React.ReactNode => createOption(t, o, ['default'])); }, [t]); const translateLanguages = useMemo((): Option[] => { return availableLanguages.map(({ text, value, withI18n }) => ({ diff --git a/packages/page-settings/src/SelectUrl.tsx b/packages/page-settings/src/SelectUrl.tsx index 2815c6d52a..5682fc15e2 100644 --- a/packages/page-settings/src/SelectUrl.tsx +++ b/packages/page-settings/src/SelectUrl.tsx @@ -64,7 +64,7 @@ function SelectUrl ({ className, onChange }: Props): React.ReactElement { const help = t('Select the remote endpoint, either from the dropdown on manual entered via the custom toggle'); const label = t('remote node/endpoint to connect to'); const translatedEndpoints = useMemo(() => { - return availableEndpoints.map((option): Option => createOption(t, option, ['local'])); + return availableEndpoints.map((option): Option | React.ReactNode => createOption(t, option, ['local'])); }, [t]); useEffect((): void => { diff --git a/packages/page-settings/src/util.tsx b/packages/page-settings/src/util.tsx index fbc86ca561..56c9295008 100644 --- a/packages/page-settings/src/util.tsx +++ b/packages/page-settings/src/util.tsx @@ -6,10 +6,16 @@ import { Option } from '@polkadot/apps-config/settings/types'; import { SettingsStruct } from '@polkadot/ui-settings/types'; import React from 'react'; -import { ChainImg, IdentityIcon } from '@polkadot/react-components'; +import { ChainImg, Dropdown, IdentityIcon } from '@polkadot/react-components'; import uiSettings from '@polkadot/ui-settings'; -export function createOption (t: (input: any) => string, { info, text, value, withI18n }: Option, overrides: string[] = [], override = 'empty'): Option { +export function createOption (t: (input: any) => string, { info, isHeader, text, value, withI18n }: Option, overrides: string[] = [], override = 'empty'): Option | React.ReactNode { + if (isHeader) { + return ( + + ); + } + return { text: (
extends BareProps { withLabel?: boolean; } +export type IDropdown