index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import React from 'react';
  2. import { Route, Switch, RouteComponentProps } from 'react-router';
  3. import Tabs from '@polkadot/react-components/Tabs';
  4. import { Link } from 'react-router-dom';
  5. import styled from 'styled-components';
  6. import { Breadcrumb, Message } from 'semantic-ui-react';
  7. import { I18nProps } from '@polkadot/react-components/types';
  8. import { ProposalPreviewList, ProposalFromId, ChooseProposalType } from './Proposal';
  9. import _ from 'lodash';
  10. import translate from './translate';
  11. import NotDone from './NotDone';
  12. import { SignalForm,
  13. SpendingProposalForm,
  14. SetCouncilParamsForm,
  15. SetMaxValidatorCountForm,
  16. RuntimeUpgradeForm,
  17. AddWorkingGroupOpeningForm,
  18. SetWorkingGroupMintCapacityForm,
  19. BeginReviewLeaderApplicationsForm,
  20. FillWorkingGroupLeaderOpeningForm,
  21. DecreaseWorkingGroupLeadStakeFrom,
  22. SlashWorkingGroupLeadStakeForm,
  23. SetWorkingGroupLeadRewardForm,
  24. TerminateWorkingGroupLeaderForm } from './forms';
  25. import { RouteProps as AppMainRouteProps } from '@polkadot/apps-routing/types';
  26. import style from './style';
  27. import { HistoricalProposalFromId } from './Proposal/ProposalFromId';
  28. const ProposalsMain = styled.main`${style}`;
  29. interface Props extends AppMainRouteProps, I18nProps {}
  30. const StyledHeader = styled.header`
  31. text-align: left;
  32. .ui.breadcrumb {
  33. padding: 1.4rem 0 0 .4rem;
  34. font-size: 1.4rem;
  35. }
  36. `;
  37. function App (props: Props): React.ReactElement<Props> {
  38. const { basePath, t } = props;
  39. const tabs = [
  40. {
  41. isRoot: true,
  42. name: 'current',
  43. text: t('Current')
  44. },
  45. {
  46. name: 'historical',
  47. text: t('Historical'),
  48. hasParams: true
  49. }
  50. ];
  51. return (
  52. <ProposalsMain className='proposal--App'>
  53. <StyledHeader>
  54. <Tabs
  55. basePath={basePath}
  56. items={tabs}
  57. />
  58. <Breadcrumb>
  59. <Switch>
  60. <Route path={`${basePath}/new/:type`} render={(props: RouteComponentProps<{ type?: string }>) => (
  61. <>
  62. <Breadcrumb.Section link as={Link} to={basePath}>Proposals</Breadcrumb.Section>
  63. <Breadcrumb.Divider icon='right angle' />
  64. <Breadcrumb.Section link as={Link} to={`${basePath}/new`}>New proposal</Breadcrumb.Section>
  65. <Breadcrumb.Divider icon='right angle' />
  66. <Breadcrumb.Section active>{_.startCase(props.match.params.type)}</Breadcrumb.Section>
  67. </>
  68. )} />
  69. <Route path={`${basePath}/new`}>
  70. <Breadcrumb.Section link as={Link} to={basePath}>Proposals</Breadcrumb.Section>
  71. <Breadcrumb.Divider icon='right angle' />
  72. <Breadcrumb.Section active>New proposal</Breadcrumb.Section>
  73. </Route>
  74. <Route path={`${basePath}/historical`}>
  75. <Breadcrumb.Section active>Historical Proposals</Breadcrumb.Section>
  76. </Route>
  77. <Route>
  78. <Breadcrumb.Section active>Proposals</Breadcrumb.Section>
  79. </Route>
  80. </Switch>
  81. </Breadcrumb>
  82. <Switch>
  83. <Route path={`${basePath}/historical`}>
  84. <Message warning active>
  85. <Message.Header>{"You're in a historical proposals view."}</Message.Header>
  86. <Message.Content>
  87. The data presented here comes from previous Joystream testnet chain, which
  88. means all proposals are read-only and can no longer be interacted with!
  89. </Message.Content>
  90. </Message>
  91. </Route>
  92. </Switch>
  93. </StyledHeader>
  94. <Switch>
  95. <Route exact path={`${basePath}/new`} component={ChooseProposalType} />
  96. <Route exact path={`${basePath}/new/text`} component={SignalForm} />
  97. <Route exact path={`${basePath}/new/runtime-upgrade`} component={RuntimeUpgradeForm} />
  98. <Route exact path={`${basePath}/new/set-election-parameters`} component={SetCouncilParamsForm} />
  99. <Route exact path={`${basePath}/new/spending`} component={SpendingProposalForm} />
  100. <Route exact path={`${basePath}/new/set-validator-count`} component={SetMaxValidatorCountForm} />
  101. <Route exact path={`${basePath}/new/add-working-group-leader-opening`} component={AddWorkingGroupOpeningForm} />
  102. <Route exact path={`${basePath}/new/set-working-group-mint-capacity`} component={SetWorkingGroupMintCapacityForm} />
  103. <Route exact path={`${basePath}/new/begin-review-working-group-leader-application`} component={BeginReviewLeaderApplicationsForm} />
  104. <Route exact path={`${basePath}/new/fill-working-group-leader-opening`} component={FillWorkingGroupLeaderOpeningForm} />
  105. <Route exact path={`${basePath}/new/decrease-working-group-leader-stake`} component={DecreaseWorkingGroupLeadStakeFrom} />
  106. <Route exact path={`${basePath}/new/slash-working-group-leader-stake`} component={SlashWorkingGroupLeadStakeForm} />
  107. <Route exact path={`${basePath}/new/set-working-group-leader-reward`} component={SetWorkingGroupLeadRewardForm} />
  108. <Route exact path={`${basePath}/new/terminate-working-group-leader-role`} component={TerminateWorkingGroupLeaderForm} />
  109. <Route exact path={`${basePath}/active`} component={NotDone} />
  110. <Route exact path={`${basePath}/finalized`} component={NotDone} />
  111. <Route exact path={`${basePath}/historical`} render={() => <ProposalPreviewList historical={true}/>} />
  112. <Route exact path={`${basePath}/historical/:id`} component={HistoricalProposalFromId}/>
  113. <Route exact path={`${basePath}/:id`} component={ProposalFromId}/>
  114. <Route component={ProposalPreviewList} />
  115. </Switch>
  116. </ProposalsMain>
  117. );
  118. }
  119. export default translate(App);