Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"pioneer/packages/joy-utils",
"pioneer/packages/joy-members",
"pioneer/packages/joy-pages",
"pioneer/packages/joy-election",
"pioneer/packages/joy-proposals",
"pioneer/packages/joy-roles",
"pioneer/packages/joy-media",
"pioneer/packages/joy-forum",
"utils/api-examples"
],
"resolutions": {
Expand All @@ -37,7 +42,8 @@
"@polkadot/util-crypto": "3.0.1",
"@polkadot/wasm-crypto": "1.2.1",
"babel-core": "^7.0.0-bridge.0",
"typescript": "^3.9.7"
"typescript": "^3.9.7",
"bn.js": "^5.1.2"
},
"devDependencies": {
"husky": "^4.2.5",
Expand Down
5 changes: 0 additions & 5 deletions pioneer/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
**/coverage/*
**/node_modules/*
packages/old-apps/*
packages/joy-election/*
packages/joy-forum/*
packages/joy-help/*
packages/joy-media/*
packages/joy-proposals/*
packages/joy-roles/*
packages/joy-settings/*
packages/joy-utils-old/*
.eslintrc.js
Expand Down
2 changes: 2 additions & 0 deletions pioneer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module.exports = {
'react/jsx-max-props-per-line': 'off',
'sort-destructure-keys/sort-destructure-keys': 'off',
'@typescript-eslint/unbound-method': 'warn', // Doesn't work well with our version of Formik, see: https://github.com/formium/formik/issues/2589
'react-hooks/exhaustive-deps': 'warn', // Causes more issues than it solves currently
'no-void': 'off' // Otherwise we cannot mark unhandles promises
},
// isolate pioneer from monorepo eslint rules
root: true
Expand Down
2 changes: 1 addition & 1 deletion pioneer/.storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ config.module.rules.push({
use: [
{
loader: require.resolve('babel-loader'),
options: require('@polkadot/dev-react/config/babel')
options: require('@polkadot/dev/config/babel')
},
],
});
Expand Down
9 changes: 5 additions & 4 deletions pioneer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"test": "echo \"skipping tests\"",
"vanitygen": "node packages/app-accounts/scripts/vanitygen.js",
"start": "yarn clean && cd packages/apps && webpack --config webpack.config.js",
"generate-schemas": "json2ts -i packages/joy-types/src/schemas/role.schema.json -o packages/joy-types/src/schemas/role.schema.ts",
"build-storybook": "build-storybook -c .storybook",
"storybook": "start-storybook -s ./packages/apps/public -p 3001"
},
Expand All @@ -40,7 +39,7 @@
"@types/chart.js": "^2.9.23",
"@types/file-saver": "^2.0.1",
"@types/i18next": "^13.0.0",
"@types/jest": "^26.0.7",
"@types/jest": "^26.0.10",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-copy-to-clipboard": "^4.3.0",
"@types/react-dom": "^16.9.8",
Expand Down Expand Up @@ -74,11 +73,13 @@
"@storybook/addon-actions": "^5.2.5",
"@storybook/addon-console": "^1.2.1",
"@storybook/react": "^5.2.5",
"json-schema-to-typescript": "^7.1.0",
"storybook-react-router": "^1.0.8",
"typescript": "^3.9.7",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-sort-destructure-keys": "^1.3.5"
"eslint-plugin-sort-destructure-keys": "^1.3.5",
"jest": "^26.4.1",
"ts-jest": "^26.2.0",
"tsconfig-paths-webpack-plugin": "^3.2.0"
},
"dependencies": {
"@types/lodash": "^4.14.138",
Expand Down
15 changes: 15 additions & 0 deletions pioneer/packages/apps-routing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ import transfer from './transfer';
// Joy packages
import members from './joy-members';
import { terms, privacyPolicy } from './joy-pages';
import election from './joy-election';
import proposals from './joy-proposals';
import roles from './joy-roles';
import media from './joy-media';
import forum from './joy-forum';

export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Routes {
return appSettings.uiMode === 'light'
? [
media(t),
members(t),
roles(t),
election(t),
proposals(t),
forum(t),
staking(t),
null,
transfer(t),
Expand All @@ -36,7 +46,12 @@ export default function create (t: <T = string> (key: string, text: string, opti
privacyPolicy(t)
]
: [
media(t),
members(t),
roles(t),
election(t),
proposals(t),
forum(t),
staking(t),
null,
transfer(t),
Expand Down
17 changes: 17 additions & 0 deletions pioneer/packages/apps-routing/src/joy-election.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Route } from './types';

import Election from '@polkadot/joy-election/index';
import SidebarSubtitle from '@polkadot/joy-election/SidebarSubtitle';

export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Route {
return {
Component: Election,
display: {
needsApi: ['query.council.activeCouncil', 'query.councilElection.stage']
},
text: t<string>('nav.election', 'Council', { ns: 'apps-routing' }),
icon: 'university',
name: 'council',
SubtitleComponent: SidebarSubtitle
};
}
15 changes: 15 additions & 0 deletions pioneer/packages/apps-routing/src/joy-forum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Route } from './types';

import Forum from '@polkadot/joy-forum/index';

export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Route {
return {
Component: Forum,
display: {
needsApi: ['query.forum.threadById']
},
text: t<string>('nav.forum', 'Forum', { ns: 'apps-routing' }),
icon: 'comment-dots',
name: 'forum'
};
}
15 changes: 15 additions & 0 deletions pioneer/packages/apps-routing/src/joy-media.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Media from '@polkadot/joy-media/index';

import { Route } from './types';

export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Route {
return {
Component: Media,
display: {
needsApi: ['query.storageWorkingGroup.workerById', 'query.dataObjectStorageRegistry.relationshipsByContentId']
},
text: t<string>('nav.media', 'Media', { ns: 'apps-routing' }),
icon: 'play-circle',
name: 'media'
};
}
16 changes: 16 additions & 0 deletions pioneer/packages/apps-routing/src/joy-proposals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Route } from './types';

import Proposals from '@polkadot/joy-proposals/index';

export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Route {
return {
Component: Proposals,
display: {
needsApi: ['query.proposalsEngine.proposalCount']
},
text: t<string>('nav.proposals', 'Proposals', { ns: 'apps-routing' }),
icon: 'tasks',
name: 'proposals'
// TODO: useCounter with active proposals count? (could be a nice addition)
};
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { Routes } from './types';
import { Route } from './types';

import Roles from '@polkadot/joy-roles/index';

export default ([
{
export default function create (t: <T = string> (key: string, text: string, options: { ns: string }) => T): Route {
return {
Component: Roles,
display: {
needsApi: [
'query.contentWorkingGroup.mint',
'query.storageWorkingGroup.mint'
]
},
i18n: {
defaultValue: 'Working groups'
},
text: t<string>('nav.roles', 'Working groups', { ns: 'apps-routing' }),
icon: 'users',
name: 'working-groups'
}
] as Routes);
};
}
2 changes: 2 additions & 0 deletions pioneer/packages/apps-routing/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface Route {
name: string;
text: string;
useCounter?: () => number | string | null;
// Joystream-specific
SubtitleComponent?: React.ComponentType<any>;
}

export type Routes = (Route | null)[];
1 change: 1 addition & 0 deletions pioneer/packages/apps/public/locales/en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"joy-media.json",
"joy-members.json",
"joy-roles.json",
"joy-utils.json",
"react-components.json",
"react-params.json",
"react-query.json",
Expand Down
5 changes: 4 additions & 1 deletion pioneer/packages/apps/public/locales/en/joy-utils.json
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{}
{
"click to select or drag and drop the file here": "click to select or drag and drop the file here",
"{{name}} ({{size}} bytes)": "{{name}} ({{size}} bytes)"
}
30 changes: 24 additions & 6 deletions pioneer/packages/apps/src/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import { useTranslation } from '../translate';
import NotFound from './NotFound';
import Status from './Status';

// Joystream-specific
// We must use transport provider here instead of /apps/src/index
// to avoid "Cannot create Transport: The Substrate API is not ready yet." error
import { TransportProvider } from '@polkadot/joy-utils/react/context';

interface Props {
className?: string;
}
Expand Down Expand Up @@ -60,11 +65,25 @@ function Content ({ className }: Props): React.ReactElement<Props> {
? <NotFound />
: (
<ErrorBoundary trigger={name}>
<Component
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}
/>
{ needsApi
// Add transport provider for routes that need the api
// (the above condition makes sure it's aleady initialized at this point)
? (
<TransportProvider>
<Component
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}
/>
</TransportProvider>
)
: (
<Component
basePath={`/${name}`}
location={location}
onStatusChange={queueAction}
/>
) }
</ErrorBoundary>
)
}
Expand All @@ -78,7 +97,6 @@ function Content ({ className }: Props): React.ReactElement<Props> {
}

export default React.memo(styled(Content)`
background: rgba(250, 250, 250);
padding: 0 1.5rem;
position: relative;
width: 100%;
Expand Down
7 changes: 5 additions & 2 deletions pioneer/packages/apps/src/SideBar/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ function Item ({ isCollapsed, onClick, route }: Props): React.ReactElement<Props
return null;
}

const { Modal, icon, name, text } = route;
const { Modal, SubtitleComponent, icon, name, text } = route;

const body = (
<>
<Icon icon={icon} />
<span className='text'>{text}</span>
<span className='text'>
{text}
{ SubtitleComponent && <SubtitleComponent/> }
</span>
{!!count && (
<Badge
color='counter'
Expand Down
14 changes: 14 additions & 0 deletions pioneer/packages/apps/webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function createWebpack (ENV, context) {
return alias;
}, {});

// Add @joystream/types as alias to automatically process any changes:
alias['@joystream/types'] = path.resolve(context, '../../../types/src');

return {
context,
entry: ['@babel/polyfill', './src/index.tsx'],
Expand All @@ -69,6 +72,17 @@ function createWebpack (ENV, context) {
}
]
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader'
]
},
{
include: /node_modules/,
test: /\.css$/,
Expand Down
Empty file.
6 changes: 3 additions & 3 deletions pioneer/packages/joy-election/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"author": "Joystream contributors",
"maintainers": [],
"dependencies": {
"@babel/runtime": "^7.7.1",
"@polkadot/react-components": "0.37.0-beta.63",
"@polkadot/react-query": "0.37.0-beta.63",
"@babel/runtime": "^7.10.5",
"@polkadot/react-components": "0.51.1",
"@polkadot/react-query": "0.51.1",
"@polkadot/joy-utils": "^0.1.1"
}
}
15 changes: 9 additions & 6 deletions pioneer/packages/joy-election/src/Applicant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@ import { Table } from 'semantic-ui-react';

import { I18nProps } from '@polkadot/react-components/types';
import { ApiProps } from '@polkadot/react-api/types';
import { withCalls } from '@polkadot/react-api/with';
import { withCalls } from '@polkadot/react-api/hoc';
import { AccountId } from '@polkadot/types/interfaces';
import { formatBalance } from '@polkadot/util';
import CandidatePreview from './CandidatePreview';

import translate from './translate';
import { calcTotalStake } from '@polkadot/joy-utils/index';
import { calcTotalStake } from '@polkadot/joy-utils/functions/misc';
import { ElectionStake } from '@joystream/types/council';

type Props = ApiProps & I18nProps & {
index: number;
accountId: AccountId;
stake?: ElectionStake;
isVotingStage: boolean;
};

class Applicant extends React.PureComponent<Props> {
render () {
const { index, accountId, stake } = this.props;
const { index, accountId, stake, isVotingStage } = this.props;
const voteUrl = `/council/votes?applicantId=${accountId.toString()}`;

return (
Expand All @@ -33,9 +34,11 @@ class Applicant extends React.PureComponent<Props> {
<Table.Cell style={{ textAlign: 'right' }}>
{formatBalance(calcTotalStake(stake))}
</Table.Cell>
<Table.Cell>
<Link to={voteUrl} className='ui button primary inverted'>Vote</Link>
</Table.Cell>
{ isVotingStage && (
<Table.Cell>
<Link to={voteUrl} className='ui button primary inverted'>Vote</Link>
</Table.Cell>
) }
</Table.Row>
);
}
Expand Down
Loading