From 023487e57438a357625896fdebc5d2fddcf5d7aa Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 19 May 2020 12:30:48 +0200 Subject: [PATCH] Tabs aliasses (#2773) * Tabs aliasses * Dummy build:electron & release steps * Bump UI --- .github/workflows/pr-any.yml | 2 +- .github/workflows/push-master.yml | 2 +- package.json | 5 ++- packages/page-accounts/package.json | 2 +- packages/page-staking/src/index.tsx | 1 + packages/react-components/package.json | 6 +-- packages/react-components/src/Tabs.tsx | 25 ++++++++++-- packages/react-signer/package.json | 2 +- yarn.lock | 54 +++++++++++++------------- 9 files changed, 61 insertions(+), 38 deletions(-) diff --git a/.github/workflows/pr-any.yml b/.github/workflows/pr-any.yml index d4b46ac63bfe..f5d857661c09 100644 --- a/.github/workflows/pr-any.yml +++ b/.github/workflows/pr-any.yml @@ -5,7 +5,7 @@ jobs: pr: strategy: matrix: - step: ['lint', 'lint:css', 'test', 'build:code', 'build:i18n'] + step: ['lint', 'lint:css', 'test', 'build:code', 'build:i18n', 'build:electron'] name: ${{ matrix.step }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 74dac8b15b92..aea798876998 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -8,7 +8,7 @@ jobs: master: strategy: matrix: - step: ['build:release'] + step: ['build:release:www', 'build:release:electron', 'build:release:ipfs'] name: ${{ matrix.step }} if: "! contains(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/apps'" runs-on: ubuntu-latest diff --git a/package.json b/package.json index c7725badc4d6..ac68f61c95b0 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,11 @@ "analyze": "yarn run build && cd packages/apps && yarn run source-map-explorer build/main.*.js", "build": "yarn run build:i18n && yarn run build:code", "build:code": "NODE_ENV=production node_modules/@polkadot/dev/scripts/polkadot-dev-build-ts.js", + "build:electron": "echo \"Dummy\"", "build:i18n": "i18next-scanner --config i18next-scanner.config.js && node ./scripts/i18nSort.js", - "build:release": "yarn polkadot-ci-ghact-build && yarn polkadot-ci-ghact-docs", + "build:release:electron": "echo \"Dummy\"", + "build:release:ipfs": "echo \"Dummy\"", + "build:release:www": "yarn polkadot-ci-ghact-build && yarn polkadot-ci-ghact-docs", "build:www": "rm -rf packages/apps/build && mkdir -p packages/apps/build && yarn run build:i18n && cd packages/apps && NODE_ENV=production webpack --config webpack.config.js", "docs": "echo \"skipping docs\"", "clean": "polkadot-dev-clean-build", diff --git a/packages/page-accounts/package.json b/packages/page-accounts/package.json index c8aed4ada2d7..2bb21406b625 100644 --- a/packages/page-accounts/package.json +++ b/packages/page-accounts/package.json @@ -13,7 +13,7 @@ "dependencies": { "@babel/runtime": "^7.9.6", "@polkadot/react-components": "0.42.0-beta.143", - "@polkadot/react-qr": "^0.54.0-beta.0", + "@polkadot/react-qr": "^0.54.0-beta.1", "@polkadot/vanitygen": "^0.12.1", "detect-browser": "^5.1.0", "file-saver": "^2.0.2" diff --git a/packages/page-staking/src/index.tsx b/packages/page-staking/src/index.tsx index f460e16e006b..6d578c3f688d 100644 --- a/packages/page-staking/src/index.tsx +++ b/packages/page-staking/src/index.tsx @@ -70,6 +70,7 @@ function StakingApp ({ basePath, className }: Props): React.ReactElement } : null, { + alias: 'returns', name: 'targets', text: t('Targets') }, diff --git a/packages/react-components/package.json b/packages/react-components/package.json index a93a3d24128c..b3ee8854333a 100644 --- a/packages/react-components/package.json +++ b/packages/react-components/package.json @@ -13,10 +13,10 @@ "@babel/runtime": "^7.9.6", "@polkadot/keyring": "^2.10.1", "@polkadot/react-api": "0.42.0-beta.143", - "@polkadot/react-identicon": "^0.54.0-beta.0", + "@polkadot/react-identicon": "^0.54.0-beta.1", "@polkadot/react-query": "0.42.0-beta.143", - "@polkadot/ui-keyring": "^0.54.0-beta.0", - "@polkadot/ui-settings": "^0.54.0-beta.0", + "@polkadot/ui-keyring": "^0.54.0-beta.1", + "@polkadot/ui-settings": "^0.54.0-beta.1", "chart.js": "^2.9.3", "codeflask": "^1.4.1", "i18next": "^19.4.4", diff --git a/packages/react-components/src/Tabs.tsx b/packages/react-components/src/Tabs.tsx index e2d35a24eebf..77f102a9b050 100644 --- a/packages/react-components/src/Tabs.tsx +++ b/packages/react-components/src/Tabs.tsx @@ -4,8 +4,8 @@ import { BareProps } from './types'; -import React from 'react'; -import { NavLink } from 'react-router-dom'; +import React, { useEffect } from 'react'; +import { NavLink, useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { classes } from './util'; @@ -19,6 +19,7 @@ const MyIcon = styled(Icon)` `; export interface TabItem { + alias?: string; hasParams?: boolean; isExact?: boolean; isRoot?: boolean; @@ -62,7 +63,25 @@ function renderItem ({ basePath, isSequence, items }: Props): (tabItem: TabItem, } function Tabs (props: Props): React.ReactElement { - const { className, hidden = [], items, style } = props; + const location = useLocation(); + const { className, basePath, hidden = [], items, style } = props; + + // redirect on invalid tabs + useEffect((): void => { + if (location.pathname !== basePath) { + // Has the form /staking/query/ + const [,, section] = location.pathname.split('/'); + const alias = items.find(({ alias }) => alias === section); + + if (alias) { + window.location.hash = alias.isRoot + ? basePath + : `${basePath}/${alias.name}`; + } else if (hidden.includes(section) || !items.some(({ isRoot, name }) => !isRoot && name === section)) { + window.location.hash = basePath; + } + } + }, [basePath, hidden, items, location]); return (