Allow disabled flag on endpoint entries (#3092)
This commit is contained in:
parent
009a291abf
commit
166eca663b
@ -4,6 +4,8 @@
|
||||
|
||||
import { Option } from './types';
|
||||
|
||||
type TFn = <T= string> (key: string, text: string, options: { ns: string, replace?: Record<string, string> }) => T;
|
||||
|
||||
interface LinkOption extends Option {
|
||||
dnslink?: string;
|
||||
}
|
||||
@ -15,7 +17,7 @@ interface EnvWindow {
|
||||
}
|
||||
}
|
||||
|
||||
function createDev (t: <T= string> (key: string, text: string, options: { ns: string }) => T): LinkOption[] {
|
||||
function createDev (t: TFn): LinkOption[] {
|
||||
return [
|
||||
{
|
||||
dnslink: 'local',
|
||||
@ -26,7 +28,7 @@ function createDev (t: <T= string> (key: string, text: string, options: { ns: st
|
||||
];
|
||||
}
|
||||
|
||||
function createLive (t: <T= string> (key: string, text: string, options: { ns: string }) => T): LinkOption[] {
|
||||
function createLive (t: TFn): LinkOption[] {
|
||||
return [
|
||||
{
|
||||
dnslink: 'polkadot',
|
||||
@ -79,7 +81,7 @@ function createLive (t: <T= string> (key: string, text: string, options: { ns: s
|
||||
];
|
||||
}
|
||||
|
||||
function createTest (t: <T= string> (key: string, text: string, options: { ns: string }) => T): LinkOption[] {
|
||||
function createTest (t: TFn): LinkOption[] {
|
||||
return [
|
||||
{
|
||||
dnslink: 'westend',
|
||||
@ -101,26 +103,46 @@ function createTest (t: <T= string> (key: string, text: string, options: { ns: s
|
||||
info: 'nodle',
|
||||
text: t<string>('rpc.arcadia', 'Arcadia (Nodle Testnet, hosted by Nodle)', { ns: 'apps-config' }),
|
||||
value: 'wss://arcadia1.nodleprotocol.io/'
|
||||
},
|
||||
{
|
||||
info: 'datahighway',
|
||||
isDisabled: true,
|
||||
text: t<string>('rpc.datahighway.harbour', 'Harbour (DataHighway Testnet, hosted by MXC)', { ns: 'apps-config' }),
|
||||
value: 'wss://testnet-harbour.datahighway.com'
|
||||
}
|
||||
// {
|
||||
// info: 'datahighway',
|
||||
// text: t<string>('rpc.datahighway.harbour', 'Harbour (DataHighway Testnet, hosted by MXC)', { ns: 'apps-config' }),
|
||||
// value: 'wss://testnet-harbour.datahighway.com'
|
||||
// }
|
||||
];
|
||||
}
|
||||
|
||||
function createCustom (t: TFn): LinkOption[] {
|
||||
const WS_URL = (
|
||||
(typeof process !== 'undefined' ? process.env?.WS_URL : undefined) ||
|
||||
(typeof window !== 'undefined' ? (window as EnvWindow).process_env?.WS_URL : undefined)
|
||||
);
|
||||
|
||||
return WS_URL
|
||||
? [
|
||||
{
|
||||
isHeader: true,
|
||||
text: t<string>('rpc.custom', 'Custom environment', { ns: 'apps-config' }),
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
info: 'WS_URL',
|
||||
text: t<string>('rpc.custom.entry', 'Custom {{WS_URL}}', { ns: 'apps-config', replace: { WS_URL } }),
|
||||
value: WS_URL
|
||||
}
|
||||
]
|
||||
: [];
|
||||
}
|
||||
|
||||
// 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 function create (t: <T= string> (key: string, text: string, options: { ns: string, replace?: Record<string, string> }) => T): LinkOption[] {
|
||||
const WS_URL = (
|
||||
(typeof process !== 'undefined' ? process.env?.WS_URL : undefined) ||
|
||||
(typeof window !== 'undefined' ? (window as EnvWindow).process_env?.WS_URL : undefined)
|
||||
);
|
||||
const endpoints = [
|
||||
export default function create (t: TFn): LinkOption[] {
|
||||
return [
|
||||
...createCustom(t),
|
||||
{
|
||||
isHeader: true,
|
||||
text: t<string>('rpc.header.live', 'Live networks', { ns: 'apps-config' }),
|
||||
@ -139,20 +161,5 @@ export default function create (t: <T= string> (key: string, text: string, optio
|
||||
value: ''
|
||||
},
|
||||
...createDev(t)
|
||||
];
|
||||
|
||||
return WS_URL
|
||||
? ([
|
||||
{
|
||||
isHeader: true,
|
||||
text: t<string>('rpc.custom', 'Custom environment', { ns: 'apps-config' }),
|
||||
value: ''
|
||||
},
|
||||
{
|
||||
info: 'WS_URL',
|
||||
text: t<string>('rpc.custom.entry', 'Custom {{WS_URL}}', { ns: 'apps-config', replace: { WS_URL } }),
|
||||
value: WS_URL
|
||||
}
|
||||
] as LinkOption[]).concat(endpoints)
|
||||
: endpoints;
|
||||
].filter(({ isDisabled }) => !isDisabled);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
export interface Option {
|
||||
info?: string;
|
||||
isDisabled?: boolean;
|
||||
isHeader?: boolean;
|
||||
text: React.ReactNode;
|
||||
value: string | number;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user