Browse Source

Reintorduce explorer + back to light/full mode

Leszek Wiesner 4 years ago
parent
commit
f4feb7b0aa

+ 1 - 5
packages/app-staking/src/Overview/CurrentList.tsx

@@ -85,11 +85,7 @@ function CurrentList(props: Props): React.ReactElement<Props> {
 
   return (
     <div>
-      <FilterOverlay
-        style={{
-          top: myAccounts.length ? '5.5rem' : '5px'
-        }}
-      >
+      <FilterOverlay>
         <Dropdown
           onChange={setFilter}
           options={[

+ 23 - 7
packages/apps-routing/src/index.ts

@@ -4,7 +4,7 @@
 
 import { Routing, Routes } from './types';
 
-// import appSettings from '@polkadot/joy-settings/';
+import appSettings from '@polkadot/joy-settings/';
 
 import election from './joy-election';
 import forum from './joy-forum';
@@ -24,7 +24,7 @@ import addressbook from './addressbook';
 // import council from './council';
 // import dashboard from './dashboard';
 // import democracy from './democracy';
-// import explorer from './explorer';
+import explorer from './explorer';
 import extrinsics from './extrinsics';
 // import genericAsset from './generic-asset';
 // import js from './js';
@@ -37,7 +37,14 @@ import sudo from './sudo';
 import transfer from './transfer';
 // import treasury from './treasury';
 
-const routes: Routes = ([] as Routes).concat(
+let routes: Routes = ([] as Routes);
+
+if (appSettings.isFullMode) {
+  routes = routes.concat(explorer);
+}
+
+// Basic routes
+routes = routes.concat(
   staking,
   roles,
   storageRoles,
@@ -51,14 +58,23 @@ const routes: Routes = ([] as Routes).concat(
   null,
   election,
   proposals,
-  null,
-  storage,
-  extrinsics,
-  sudo,
+  null
+);
+
+if (appSettings.isFullMode) {
+  routes = routes.concat(
+    storage,
+    extrinsics,
+    sudo
+  )
+}
+
+routes = routes.concat(
   settings,
   null,
   pages
 );
+
 const setup: Routing = {
   default: 'staking',
   routes

+ 7 - 0
packages/apps/src/index.tsx

@@ -33,6 +33,13 @@ const rootElement = document.getElementById(rootId);
       apiUrl
     });
 
+    window.location.reload();
+  },
+  setAdvancedUI: (flag: boolean) => {
+    settings.set({
+      uiMode: flag ? 'full' : 'light'
+    });
+
     window.location.reload();
   }
 };

+ 1 - 3
packages/joy-settings/src/defaults/ui.ts

@@ -8,9 +8,7 @@ import { isPolkadot } from './type';
 
 const LANGUAGE_DEFAULT = 'default';
 
-const UIMODE_DEFAULT = !isPolkadot && typeof window !== 'undefined' && window.location.host.includes('ui-light')
-  ? 'light'
-  : 'full';
+const UIMODE_DEFAULT = 'light';
 
 const UIMODES: Option[] = [
   {

+ 5 - 1
packages/react-components/src/FilterOverlay.tsx

@@ -6,6 +6,7 @@ import { BareProps } from './types';
 
 import React from 'react';
 import styled from 'styled-components';
+import { useMyMembership } from '@polkadot/joy-utils/MyMembershipContext';
 
 import media from './media';
 
@@ -13,7 +14,10 @@ interface Props extends BareProps {
   children: React.ReactNode;
 }
 
-function FilterOverlay({ children, className, style }: Props): React.ReactElement<Props> {
+function FilterOverlay({ children, className }: Props): React.ReactElement<Props> {
+  const { allAccounts } = useMyMembership();
+  const hasAccount = allAccounts && Object.keys(allAccounts).length;
+  const style = { top: hasAccount ? '5.5rem' : '5px' };
   return (
     <div className={className} style={style}>
       {children}