Browse Source

fix stage

Joystream Stats 4 years ago
parent
commit
076cf904c3

+ 6 - 2
src/App.tsx

@@ -35,7 +35,7 @@ const initialState = {
   blocks: [],
   now: 0,
   block: 0,
-  termEndsAt: 0,
+
   loading: true,
   nominators: [],
   validators: [],
@@ -51,6 +51,8 @@ const initialState = {
   members: [],
   proposalPosts,
   reports: {},
+  termEndsAt: 0,
+  stage: {},
 };
 
 class App extends React.Component<IProps, IState> {
@@ -69,6 +71,7 @@ class App extends React.Component<IProps, IState> {
       (await api.query.councilElection.round()).toJSON()
     );
     let stage: any = await api.query.councilElection.stage();
+    this.save("stage", stage);
     let councilElection = { termEndsAt, stage: stage.toJSON(), round };
     this.setState({ councilElection });
     let stageEndsAt: number = termEndsAt;
@@ -584,7 +587,8 @@ class App extends React.Component<IProps, IState> {
     await this.loadReports();
     const block = this.load("block");
     const now = this.load("now");
-    this.setState({ block, now, termEndsAt, loading: false });
+    const stage = this.load("stage");
+    this.setState({ block, now, stage, termEndsAt, loading: false });
     console.debug(`Finished loading.`);
   }
 

+ 5 - 2
src/components/Council/ElectionStatus.tsx

@@ -7,6 +7,7 @@ const ElectionStage = (props: {
   stage?: any;
 }) => {
   const { block, stage, termEndsAt } = props;
+  console.log(`stage`, stage);
 
   if (!stage) {
     if (!block || !termEndsAt) return <div />;
@@ -36,14 +37,16 @@ const ElectionStage = (props: {
 const ElectionStatus = (props: {
   councilElection?: { termEndsAt: number; round: number; stage: any };
   block: number;
-  termEndsAt: number;
   show: boolean;
+  stage?: any;
+  termEndsAt: number;
 }) => {
-  const { councilElection, block, termEndsAt, show } = props;
+  const { councilElection, block, termEndsAt, show, stage } = props;
   if (!show) return <div />;
   return (
     <div className="position-absolute text-left text-light">
       <ElectionStage
+        stage={stage}
         termEndsAt={termEndsAt}
         block={block}
         {...councilElection}

+ 2 - 0
src/components/Council/index.tsx

@@ -18,6 +18,7 @@ const Council = (props: {
   council: Member[];
   councilElection?: any;
   block: number;
+  stage?: any;
   termEndsAt: number;
 }) => {
   const { council, block, councilElection, termEndsAt } = props;
@@ -28,6 +29,7 @@ const Council = (props: {
     <div className="box">
       <ElectionStatus
         show={show}
+        stage={props.stage}
         termEndsAt={termEndsAt}
         block={block}
         {...councilElection}

+ 1 - 0
src/components/Dashboard/index.tsx

@@ -38,6 +38,7 @@ const Dashboard = (props: IState) => {
         councilElection={props.councilElection}
         block={block}
         termEndsAt={props.termEndsAt}
+        stage={props.stage}
       />
       <div className="d-flex flex-row">
         <Validators validators={props.validators} handles={handles} />

+ 2 - 0
src/components/Members/Member.tsx

@@ -13,6 +13,7 @@ const MemberBox = (props: {
   posts: Post[];
   block: number;
   now: number;
+  validators: string[];
 }) => {
   const { block, now, councils, members, posts, proposals } = props;
   const handle = props.match.params.handle;
@@ -42,6 +43,7 @@ const MemberBox = (props: {
           posts={posts}
           proposals={proposals}
           startTime={now - block * 6000}
+          validators={props.validators}
         />
       </div>
     </div>

+ 2 - 0
src/components/Members/MemberBox.tsx

@@ -14,6 +14,7 @@ const MemberBox = (props: {
   handle: string;
   startTime: number;
   placement: "left" | "bottom" | "right" | "top";
+  validators: string[];
 }) => {
   const { councils, handle, members, posts, placement, proposals } = props;
   return (
@@ -28,6 +29,7 @@ const MemberBox = (props: {
             proposals={proposals}
             posts={posts}
             startTime={props.startTime}
+            validators={props.validators}
           />
         </Tooltip>
       }

+ 2 - 0
src/components/Members/MemberOverlay.tsx

@@ -11,6 +11,7 @@ const MemberBox = (props: {
   proposals: ProposalDetail[];
   posts: Post[];
   startTime: number;
+  validators: string[];
 }) => {
   const { councils, handle, members, posts, proposals, startTime } = props;
   const member = members.find((m) => m.handle === handle);
@@ -34,6 +35,7 @@ const MemberBox = (props: {
         posts={posts}
         proposals={proposals}
         startTime={startTime}
+        validators={props.validators}
       />
     </div>
   );

+ 10 - 0
src/components/Members/Summary/index.tsx

@@ -1,5 +1,6 @@
 import React from "react";
 import { Member, Post, ProposalDetail } from "../../../types";
+import { domain } from "../../../config";
 
 import About from "./About";
 import Posts from "./Posts";
@@ -20,6 +21,7 @@ const Summary = (props: {
   posts: Post[];
   proposals: ProposalDetail[];
   startTime: number;
+  validators: string[];
 }) => {
   const { councils, handle, member, proposals, startTime } = props;
 
@@ -43,12 +45,20 @@ const Summary = (props: {
     ? date.format("DD/MM/YYYY HH:mm")
     : member.registeredAt;
 
+  const runsValidator = props.validators.includes(member.account);
+
   return (
     <div className="text-left">
       <div className="my-1">
         Registered on {created} (id {member.id})
       </div>
 
+      {runsValidator && (
+        <div className="my-1">
+          This user runs a <a href={`${domain}/#/staking`}>validator node</a>.
+        </div>
+      )}
+
       <Councils onCouncil={onCouncil.length} votes={votes.length} />
       <Proposals
         proposals={createdProposals.length}

+ 2 - 0
src/components/Members/index.tsx

@@ -12,6 +12,7 @@ interface IProps {
   posts: Post[];
   now: number;
   block: number;
+  validators: string[];
 }
 
 interface IState {
@@ -65,6 +66,7 @@ class Members extends React.Component<IProps, IState> {
                   placement={index === 3 ? "left" : "bottom"}
                   posts={posts}
                   startTime={startTime}
+                  validators={this.props.validators}
                 />
               ))}
             </div>

+ 2 - 0
src/components/Proposals/ProposalTable.tsx

@@ -15,6 +15,7 @@ interface IProps {
   // author overlay
   councils: number[][];
   posts: Post[];
+  validators: string[];
 }
 interface IState {
   author: string;
@@ -174,6 +175,7 @@ class ProposalTable extends React.Component<IProps, IState> {
               councils={councils}
               forumPosts={posts}
               proposals={this.props.proposals}
+              validators={this.props.validators}
             />
           ))}
         </div>

+ 2 - 0
src/components/Proposals/Row.tsx

@@ -47,6 +47,7 @@ const ProposalRow = (props: {
   councils: number[][];
   forumPosts: Post[];
   proposals: ProposalDetail[];
+  validators: string[];
 }) => {
   const {
     block,
@@ -99,6 +100,7 @@ const ProposalRow = (props: {
               proposals={props.proposals}
               posts={props.forumPosts}
               startTime={props.startTime}
+              validators={props.validators}
             />
           </Tooltip>
         }

+ 2 - 0
src/components/Proposals/index.tsx

@@ -13,6 +13,7 @@ const Proposals = (props: {
   // author overlay
   councils: number[][];
   posts: Post[];
+  validators: string[];
 }) => {
   const { proposalPosts, block, now, members } = props;
   const startTime: number = now - block * 6000;
@@ -43,6 +44,7 @@ const Proposals = (props: {
       startTime={startTime}
       councils={props.councils}
       posts={props.posts}
+      validators={props.validators}
     />
   );
 };

+ 1 - 1
src/types.ts

@@ -61,7 +61,7 @@ export interface ProposalDetail {
   finalizedAt: number;
   message: string;
   parameters: ProposalParameters;
-  stage: string;
+  stage: any;
   result: string;
   exec: any;
   id: number;