Skip to content

Commit

Permalink
replace old explorer url with the new one and remove edit option #1766 (
Browse files Browse the repository at this point in the history
  • Loading branch information
bassemmagdy authored Nov 25, 2021
1 parent a112dc7 commit 5fd4ef0
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 218 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/components/AccountLinks/AccountLinksTs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import { Component, Prop, Vue } from 'vue-property-decorator';
// internal dependencies
import { AccountModel } from '@/core/database/entities/AccountModel';
import { mapGetters } from 'vuex';
import { networkConfig } from '@/config';
import { NetworkType } from 'symbol-sdk';

@Component({
computed: {
...mapGetters({
explorerBaseUrl: 'app/explorerUrl',
faucetBaseUrl: 'app/faucetUrl',
networkType: 'network/networkType',
}),
},
})
Expand All @@ -35,14 +37,13 @@ export class AccountLinksTs extends Vue {
@Prop({ default: '' }) link: string;
@Prop({ default: '' }) icon: string;

public explorerBaseUrl: string;
public faucetBaseUrl: string;

private networkType: NetworkType;
/// region computed properties getter/setter
/// end-region computed properties getter/setter

public get explorerUrl() {
return this.explorerBaseUrl.replace(/\/+$/, '') + '/accounts/' + this.account.address;
return networkConfig[this.networkType].explorerUrl.replace(/\/+$/, '') + '/accounts/' + this.account.address;
}

public get faucetUrl() {
Expand Down
55 changes: 0 additions & 55 deletions src/components/ExplorerUrlSetter/ExplorerUrlSetter.vue

This file was deleted.

99 changes: 0 additions & 99 deletions src/components/ExplorerUrlSetter/ExplorerUrlSetterTs.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,24 @@ import PaidFeeDisplay from '@/components/PaidFeeDisplay/PaidFeeDisplay.vue';
// @ts-ignore
import MessageDisplay from '@/components/MessageDisplay/MessageDisplay.vue';
import { TransactionDetailItem } from '@/core/transactions/TransactionDetailItem';
import { NetworkType } from 'symbol-sdk';
import { networkConfig } from '@/config';
@Component({
components: { MosaicAmountDisplay, AddressDisplay, PaidFeeDisplay, MessageDisplay },
computed: mapGetters({ explorerBaseUrl: 'app/explorerUrl' }),
computed: mapGetters({ networkType: 'network/networkType' }),
})
export default class TransactionDetailRow extends Vue {
@Prop({ required: true }) item: TransactionDetailItem;
private networkType: NetworkType;
private get label(): string {
return (this.item && this.item.key) || '';
}
/**
* Explorer base path
*/
protected explorerBaseUrl: string;
/**
* Returns the explorer url
*/
public get explorerUrl() {
return this.explorerBaseUrl.replace(/\/+$/, '') + '/transactions/' + this.item.value;
return networkConfig[this.networkType].explorerUrl.replace(/\/+$/, '') + '/transactions/' + this.item.value;
}
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import { ProfileModel } from '@/core/database/entities/ProfileModel';
import { AccountModel } from '@/core/database/entities/AccountModel';
import { TransactionStatus as TransactionStatusEnum } from '@/core/transactions/TransactionStatus';
import { MultisigService } from '@/services/MultisigService';
import { networkConfig } from '@/config';

export interface TooltipMosaics {
name: string;
Expand All @@ -62,7 +63,6 @@ export interface TooltipMosaics {
},
computed: mapGetters({
networkMosaic: 'mosaic/networkMosaic',
explorerBaseUrl: 'app/explorerUrl',
networkConfiguration: 'network/networkConfiguration',
currentProfile: 'profile/currentProfile',
currentAccount: 'account/currentAccount',
Expand All @@ -84,11 +84,6 @@ export class TransactionRowTs extends Vue {
*/
public currentProfile: ProfileModel;

/**
* Explorer base path
*/
protected explorerBaseUrl: string;

/**
* Network mosaic id
* @private
Expand Down Expand Up @@ -457,7 +452,11 @@ export class TransactionRowTs extends Vue {
* Returns the explorer url
*/
public get explorerUrl() {
return this.explorerBaseUrl.replace(/\/+$/, '') + '/transactions/' + this.transaction.transactionInfo.hash;
return (
networkConfig[this.currentProfile.networkType].explorerUrl.replace(/\/+$/, '') +
'/transactions/' +
this.transaction.transactionInfo.hash
);
}

public get date(): string {
Expand Down
1 change: 0 additions & 1 deletion src/core/database/entities/SettingsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ export class SettingsModel {
public readonly language: string,
public readonly defaultFee: number,
public readonly defaultAccount: string,
public readonly explorerUrl: string,
) {}
}
4 changes: 4 additions & 0 deletions src/core/database/storage/SettingsModelStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export class SettingsModelStorage extends VersionedObjectStorage<Record<string,
description: 'Reset for fees update.',
migrate: () => undefined,
},
{
description: 'Reset for explorer url update.',
migrate: () => undefined,
},
],
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/language/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@
"sender": "From",
"set_account_name": "Enter a profile name",
"set_default_explorer": "The URL entered is not valid, a default URL has been set for you.",
"set_explorer_link": "Explorer URL",
"form_label_explorer_link": "Explorer URL",
"set_network_type": "Select a network type",
"SET_UP": "Node selection",
"settings": "Settings",
Expand Down
2 changes: 1 addition & 1 deletion src/language/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@
"sender": "送信者",
"set_account_name": "プロファイル名の入力",
"set_default_explorer": "入力されたURLは無効です。既定のURLが設定されています。",
"set_explorer_link": "エクスプローラリンクの設定",
"form_label_explorer_link": "エクスプローラリンクの設定",
"set_network_type": "ネットワークタイプ選択",
"SET_UP": "ノード選択",
"settings": "設定",
Expand Down
2 changes: 1 addition & 1 deletion src/language/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@
"sender": "Отправитель",
"set_account_name": "Введите имя профиля",
"set_default_explorer": "Введенный URL недействителен, для вас был установлен URL по умолчанию.",
"set_explorer_link": "Эксплорер URL",
"form_label_explorer_link": "Эксплорер URL",
"set_network_type": "Выберите тип сети",
"SET_UP": "Выбор ноды",
"settings": "Настройки",
Expand Down
2 changes: 1 addition & 1 deletion src/language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@
"sender": "发送者",
"set_account_name": "设置账户名",
"set_default_explorer": "输入的url不合法,已为您设置默认url",
"set_explorer_link": "默认区块浏览器",
"form_label_explorer_link": "默认区块浏览器",
"set_network_type": "设置网络类型",
"SET_UP": "节点选择",
"settings": "设置",
Expand Down
18 changes: 7 additions & 11 deletions src/services/SettingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
*
*/
import { SettingsModel } from '@/core/database/entities/SettingsModel';

import { feesConfig } from '@/config';
import { appConfig } from '@/config';
import { networkConfig } from '@/config';
import { appConfig, feesConfig } from '@/config';
import i18n from '@/language';
import { SettingsModelStorage } from '@/core/database/storage/SettingsModelStorage';
import { NetworkType } from 'symbol-sdk';

/**
* Service in charge of loading and storing the SettingsModel from local storage.
Expand All @@ -31,28 +27,28 @@ export class SettingService {
*/
private readonly storage = SettingsModelStorage.INSTANCE;

public getProfileSettings(profileName: string, networkType: NetworkType): SettingsModel {
public getProfileSettings(profileName: string): SettingsModel {
const storedData = this.storage.get() || {};
return {
...this.createDefaultSettingsModel(profileName, networkType),
...this.createDefaultSettingsModel(profileName),
...(storedData[profileName] || {}),
};
}

public changeProfileSettings(profileName: string, newConfigs: any, networkType: NetworkType): SettingsModel {
public changeProfileSettings(profileName: string, newConfigs: any): SettingsModel {
const storedData = this.storage.get() || {};
storedData[profileName] = {
...this.getProfileSettings(profileName, networkType),
...this.getProfileSettings(profileName),
...newConfigs,
};
this.storage.set(storedData);
return storedData[profileName];
}

public createDefaultSettingsModel(profileName: string, networkType: NetworkType): SettingsModel {
public createDefaultSettingsModel(profileName: string): SettingsModel {
const browserLocale = i18n.locale;
const language = appConfig.languages.find((l) => l.value == browserLocale) ? browserLocale : appConfig.languages[0].value;
return new SettingsModel(profileName, language, feesConfig.slowest, '', networkConfig[networkType].explorerUrl);
return new SettingsModel(profileName, language, feesConfig.slowest, '');
}

public deleteProfileSettings(profileName: string): void {
Expand Down
Loading

0 comments on commit 5fd4ef0

Please sign in to comment.