mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-06-16 03:01:01 +00:00
Add prefixes to settings (#158)
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import store from 'store';
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
|
||||
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, LANGUAGE_DEFAULT, LANGUAGES, LOCKING_DEFAULT, LOCKING, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES } from './defaults';
|
||||
import { CRYPTOS, ENDPOINT_DEFAULT, ENDPOINTS, LANGUAGE_DEFAULT, LANGUAGES, LOCKING_DEFAULT, LOCKING, UIMODE_DEFAULT, UIMODES, UITHEME_DEFAULT, UITHEMES, PREFIX_DEFAULT } from './defaults';
|
||||
import { Options, SettingsStruct } from './types';
|
||||
|
||||
export class Settings implements SettingsStruct {
|
||||
@@ -14,6 +15,8 @@ export class Settings implements SettingsStruct {
|
||||
|
||||
private _locking: string;
|
||||
|
||||
private _prefix: number;
|
||||
|
||||
private _uiMode: string;
|
||||
|
||||
private _uiTheme: string;
|
||||
@@ -24,6 +27,7 @@ export class Settings implements SettingsStruct {
|
||||
this._apiUrl = settings.apiUrl || process.env.WS_URL || ENDPOINT_DEFAULT;
|
||||
this._i18nLang = settings.i18nLang || LANGUAGE_DEFAULT;
|
||||
this._locking = settings.locking || LOCKING_DEFAULT;
|
||||
this._prefix = isUndefined(settings.prefix) ? PREFIX_DEFAULT : settings.prefix;
|
||||
this._uiMode = settings.uiMode || UIMODE_DEFAULT;
|
||||
this._uiTheme = settings.uiTheme || UITHEME_DEFAULT;
|
||||
}
|
||||
@@ -40,6 +44,10 @@ export class Settings implements SettingsStruct {
|
||||
return this._locking;
|
||||
}
|
||||
|
||||
public get prefix (): number {
|
||||
return this._prefix;
|
||||
}
|
||||
|
||||
public get uiMode (): string {
|
||||
return this._uiMode;
|
||||
}
|
||||
@@ -77,6 +85,7 @@ export class Settings implements SettingsStruct {
|
||||
apiUrl: this._apiUrl,
|
||||
i18nLang: this._i18nLang,
|
||||
locking: this._locking,
|
||||
prefix: this._prefix,
|
||||
uiMode: this._uiMode,
|
||||
uiTheme: this._uiTheme
|
||||
};
|
||||
@@ -86,6 +95,7 @@ export class Settings implements SettingsStruct {
|
||||
this._apiUrl = settings.apiUrl || this._apiUrl;
|
||||
this._i18nLang = settings.i18nLang || this._i18nLang;
|
||||
this._locking = settings.locking || this._locking;
|
||||
this._prefix = isUndefined(settings.prefix) ? this._prefix : settings.prefix;
|
||||
this._uiMode = settings.uiMode || this._uiMode;
|
||||
this._uiTheme = settings.uiTheme || this._uiTheme;
|
||||
|
||||
|
||||
@@ -47,6 +47,13 @@ const LOCKING: Options = [
|
||||
{ text: 'On each transaction', value: 'tx' }
|
||||
];
|
||||
|
||||
const PREFIXES: Options = [
|
||||
{ text: 'Default for the connected node', value: -1 },
|
||||
{ text: 'Substrate (development)', value: 42 },
|
||||
{ text: 'Kusama (canary)', value: 2 },
|
||||
{ text: 'Polkadot (live)', value: 0 }
|
||||
];
|
||||
|
||||
const UIMODES: Options = [
|
||||
{ value: 'full', text: 'Fully featured' },
|
||||
{ value: 'light', text: 'Basic features only' }
|
||||
@@ -61,6 +68,8 @@ const ENDPOINT_DEFAULT = isPolkadot
|
||||
? WSS_NODES.parity.nodes.alex
|
||||
: WSS_NODES.parity.nodes.elm;
|
||||
|
||||
const PREFIX_DEFAULT = -1;
|
||||
|
||||
const UITHEME_DEFAULT = isPolkadot
|
||||
? 'polkadot'
|
||||
: 'substrate';
|
||||
@@ -78,6 +87,8 @@ export {
|
||||
LANGUAGES,
|
||||
LOCKING_DEFAULT,
|
||||
LOCKING,
|
||||
PREFIX_DEFAULT,
|
||||
PREFIXES,
|
||||
UIMODE_DEFAULT,
|
||||
UIMODES,
|
||||
UITHEME_DEFAULT,
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
export type Options = {
|
||||
disabled?: boolean;
|
||||
text: string;
|
||||
value: string;
|
||||
value: string | number;
|
||||
}[]
|
||||
|
||||
export interface SettingsStruct {
|
||||
apiUrl: string;
|
||||
i18nLang: string;
|
||||
locking: string;
|
||||
prefix: number;
|
||||
uiMode: string;
|
||||
uiTheme: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user