Skip to content

Commit

Permalink
Feature - introduce ambassador Base (Members and Referenda) (#10838)
Browse files Browse the repository at this point in the history
* Ambassador Base (Members and Referenda)

* Minor fixes
  • Loading branch information
wirednkod authored Aug 15, 2024
1 parent 9804459 commit f387340
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/apps-config/src/links/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface LinkPath {

// governance 2
fellowshipReferenda?: string;
ambassadorReferenda?: string;
rankedPolls?: string;
referenda?: string;
}
Expand Down
25 changes: 25 additions & 0 deletions packages/apps-routing/src/ambassador.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2017-2024 @polkadot/apps-routing authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { Route, TFunction } from './types.js';

import Component, { useCounter } from '@polkadot/app-ambassador';

export default function create (t: TFunction): Route {
return {
Component,
display: {
needsAccounts: true,
needsApi: [
'tx.ambassadorCollective.vote',
'tx.ambassadorReferenda.submit',
'consts.ambassadorReferenda.tracks'
]
},
group: 'governance',
icon: 'user-friends',
name: 'ambassador',
text: t('nav.ambassador', 'Ambassador', { ns: 'apps-routing' }),
useCounter
};
}
2 changes: 2 additions & 0 deletions packages/apps-routing/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Routes, TFunction } from './types.js';
import accounts from './accounts.js';
import addresses from './addresses.js';
import alliance from './alliance.js';
import ambassador from './ambassador.js';
import assets from './assets.js';
import bounties from './bounties.js';
import calendar from './calendar.js';
Expand Down Expand Up @@ -64,6 +65,7 @@ export default function create (t: TFunction): Routes {
referenda(t),
membership(t),
alliance(t),
ambassador(t),
fellowship(t),
ranked(t),
preimages(t),
Expand Down
1 change: 1 addition & 0 deletions packages/apps-routing/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{ "path": "../page-accounts/tsconfig.build.json" },
{ "path": "../page-addresses/tsconfig.build.json" },
{ "path": "../page-alliance/tsconfig.build.json" },
{ "path": "../page-ambassador/tsconfig.build.json" },
{ "path": "../page-assets/tsconfig.build.json" },
{ "path": "../page-bounties/tsconfig.build.json" },
{ "path": "../page-calendar/tsconfig.build.json" },
Expand Down
1 change: 1 addition & 0 deletions packages/apps/public/locales/en/app-ambassador.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions packages/apps/public/locales/en/apps-routing.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"nav.accounts": "Accounts",
"nav.addresses": "Address book",
"nav.alliance": "Alliance",
"nav.ambassador": "Ambassador",
"nav.assets": "Assets",
"nav.bounties": "Bounties",
"nav.calendar": "Event calendar",
Expand Down
Empty file.
Empty file.
1 change: 1 addition & 0 deletions packages/page-ambassador/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# @polkadot/app-ambassador
23 changes: 23 additions & 0 deletions packages/page-ambassador/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"bugs": "https://github.com/polkadot-js/apps/issues",
"engines": {
"node": ">=18"
},
"homepage": "https://github.com/polkadot-js/apps/tree/master/packages/page-ambassador#readme",
"license": "Apache-2.0",
"name": "@polkadot/app-ambassador",
"private": true,
"repository": {
"directory": "packages/page-ambassador",
"type": "git",
"url": "https://github.com/polkadot-js/apps.git"
},
"sideEffects": false,
"type": "module",
"version": "0.142.2-25-x",
"peerDependencies": {
"react": "*",
"react-dom": "*",
"react-is": "*"
}
}
26 changes: 26 additions & 0 deletions packages/page-ambassador/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2017-2024 @polkadot/app-fellowship authors & contributors
// SPDX-License-Identifier: Apache-2.0

import React from 'react';

import Main from '@polkadot/app-ranked/App';

export { default as useCounter } from './useCounter.js';

interface Props {
basePath: string;
className?: string;
}

function App ({ basePath, className }: Props): React.ReactElement<Props> {
return (
<Main
basePath={basePath}
className={className}
palletColl='ambassadorCollective'
palletPoll='ambassadorReferenda'
/>
);
}

export default React.memo(App);
11 changes: 11 additions & 0 deletions packages/page-ambassador/src/useCounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017-2024 @polkadot/app-ranked authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { useCounterNamed } from '@polkadot/app-referenda/useCounter';
import { createNamedHook } from '@polkadot/react-hooks';

function useCounterImpl (): number {
return useCounterNamed('ambassadorReferenda');
}

export default createNamedHook('useCounter', useCounterImpl);
12 changes: 12 additions & 0 deletions packages/page-ambassador/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "..",
"outDir": "./build",
"rootDir": "./src"
},
"references": [
{ "path": "../page-ranked/tsconfig.build.json" },
{ "path": "../react-components/tsconfig.build.json" }
]
}
4 changes: 2 additions & 2 deletions packages/page-ranked/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import type { PalletRankedCollectiveMemberRecord } from '@polkadot/types/lookup';

export type PalletColl = 'rankedCollective' | 'fellowshipCollective';
export type PalletColl = 'rankedCollective' | 'fellowshipCollective' | 'ambassadorCollective';

export type PalletPoll = 'rankedPolls' | 'fellowshipReferenda';
export type PalletPoll = 'rankedPolls' | 'fellowshipReferenda' | 'ambassadorReferenda';

export interface Member {
accountId: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/page-referenda/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import type { PalletReferendaReferendumInfoConvictionVotingTally, PalletReferendaReferendumInfoRankedCollectiveTally, PalletReferendaTrackInfo } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';

export type PalletReferenda = 'referenda' | 'rankedPolls' | 'fellowshipReferenda';
export type PalletReferenda = 'referenda' | 'rankedPolls' | 'fellowshipReferenda'| 'ambassadorReferenda';

export type PalletVote = 'convictionVoting' | 'rankedCollective' | 'fellowshipCollective';
export type PalletVote = 'convictionVoting' | 'rankedCollective' | 'fellowshipCollective' | 'ambassadorCollective';

export interface ReferendaGroup {
key: string;
Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@polkadot/app-accounts": ["page-accounts/src/index.tsx"],
"@polkadot/app-addresses": ["page-addresses/src/index.tsx"],
"@polkadot/app-alliance": ["page-alliance/src/index.tsx"],
"@polkadot/app-ambassador": ["page-ambassador/src/index.tsx"],
"@polkadot/app-assets": ["page-assets/src/index.tsx"],
"@polkadot/app-bounties": ["page-bounties/src/index.tsx"],
"@polkadot/app-calendar": ["page-calendar/src/index.tsx"],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{ "path": "./packages/page-addresses/tsconfig.spec.json" },
{ "path": "./packages/page-addresses/tsconfig.test.json" },
{ "path": "./packages/page-alliance/tsconfig.build.json" },
{ "path": "./packages/page-ambassador/tsconfig.build.json" },
{ "path": "./packages/page-assets/tsconfig.build.json" },
{ "path": "./packages/page-bounties/tsconfig.build.json" },
{ "path": "./packages/page-bounties/tsconfig.spec.json" },
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,16 @@ __metadata:
languageName: unknown
linkType: soft

"@polkadot/app-ambassador@workspace:packages/page-ambassador":
version: 0.0.0-use.local
resolution: "@polkadot/app-ambassador@workspace:packages/page-ambassador"
peerDependencies:
react: "*"
react-dom: "*"
react-is: "*"
languageName: unknown
linkType: soft

"@polkadot/app-assets@workspace:packages/page-assets":
version: 0.0.0-use.local
resolution: "@polkadot/app-assets@workspace:packages/page-assets"
Expand Down

0 comments on commit f387340

Please sign in to comment.