Browse Source

WorkingGroupKeys => WorkingGroupKey

Leszek Wiesner 4 years ago
parent
commit
9b33f9ca4b

+ 6 - 6
pioneer/packages/joy-proposals/src/Proposal/Body.tsx

@@ -20,7 +20,7 @@ import {
   ActivateOpeningAt,
   ActivateOpeningAtKeys
 } from '@joystream/types/hiring';
-import { WorkingGroup, WorkingGroupKeys } from '@joystream/types/common';
+import { WorkingGroup, WorkingGroupKey } from '@joystream/types/common';
 import { ApplicationsDetailsByOpening } from '@polkadot/joy-utils/react/components/working-groups/ApplicationDetails';
 import { LeadInfoFromId } from '@polkadot/joy-utils/react/components/working-groups/LeadInfo';
 import { formatReward } from '@polkadot/joy-utils/functions/format';
@@ -207,24 +207,24 @@ const paramParsers: { [x in ProposalType]: (params: any[]) => ParsedParams} = {
         <ApplicationsDetailsByOpening
           openingId={opening_id}
           acceptedIds={[successful_application_id]}
-          group={(new WorkingGroup(working_group)).type as WorkingGroupKeys}/>
+          group={(new WorkingGroup(working_group)).type as WorkingGroupKey}/>
       )
     };
   },
   SlashWorkingGroupLeaderStake: ([leadId, amount, group]) => ({
     'Working group': (new WorkingGroup(group)).type,
     'Slash amount': formatBalance(amount),
-    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKeys)} leadId={leadId}/>)
+    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKey)} leadId={leadId}/>)
   }),
   DecreaseWorkingGroupLeaderStake: ([leadId, amount, group]) => ({
     'Working group': (new WorkingGroup(group)).type,
     'Decrease amount': formatBalance(amount),
-    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKeys)} leadId={leadId}/>)
+    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKey)} leadId={leadId}/>)
   }),
   SetWorkingGroupLeaderReward: ([leadId, amount, group]) => ({
     'Working group': (new WorkingGroup(group)).type,
     'New reward amount': formatBalance(amount),
-    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKeys)} leadId={leadId}/>)
+    Lead: new FullWidthParam(<LeadInfoFromId group={(new WorkingGroup(group).type as WorkingGroupKey)} leadId={leadId}/>)
   }),
   TerminateWorkingGroupLeaderRole: ([params]) => {
     const paramsObj = new TerminateRoleParameters(params);
@@ -233,7 +233,7 @@ const paramParsers: { [x in ProposalType]: (params: any[]) => ParsedParams} = {
       'Working group': workingGroup.type,
       Rationale: new FullWidthParam(bytesToString(rationale)),
       'Slash stake': slash.isTrue ? 'YES' : 'NO',
-      Lead: new FullWidthParam(<LeadInfoFromId group={workingGroup.type as WorkingGroupKeys} leadId={leadId.toNumber()}/>)
+      Lead: new FullWidthParam(<LeadInfoFromId group={workingGroup.type as WorkingGroupKey} leadId={leadId.toNumber()}/>)
     };
   }
 };

+ 2 - 2
pioneer/packages/joy-proposals/src/forms/AddWorkingGroupOpeningForm.tsx

@@ -23,7 +23,7 @@ import { formatBalance } from '@polkadot/util';
 import _ from 'lodash';
 import { IWorkingGroupOpeningPolicyCommitment } from '@joystream/types/working-group';
 import { IAddOpeningParameters } from '@joystream/types/proposals';
-import { WorkingGroupKeys, InputValidationLengthConstraint } from '@joystream/types/common';
+import { WorkingGroupKey, InputValidationLengthConstraint } from '@joystream/types/common';
 import { BlockNumber } from '@polkadot/types/interfaces';
 import { withCalls } from '@polkadot/react-api';
 import { SimplifiedTypeInterface } from '@polkadot/joy-utils/types/common';
@@ -64,7 +64,7 @@ const defaultValues: FormValues = {
   humanReadableText: ''
 };
 
-const HRTDefault: (memberHandle: string, group: WorkingGroupKeys) => GenericJoyStreamRoleSchema =
+const HRTDefault: (memberHandle: string, group: WorkingGroupKey) => GenericJoyStreamRoleSchema =
   (memberHandle, group) => ({
     version: 1,
     headline: `Looking for ${group} Working Group Leader!`,

+ 2 - 2
pioneer/packages/joy-proposals/src/forms/GenericWorkingGroupProposalForm.tsx

@@ -10,7 +10,7 @@ import {
 } from './GenericProposalForm';
 import { FormField } from './FormFields';
 import { ProposalType } from '@polkadot/joy-utils/types/proposals';
-import { WorkingGroupKeys, WorkingGroupDef } from '@joystream/types/common';
+import { WorkingGroupKey, WorkingGroupDef } from '@joystream/types/common';
 import './forms.css';
 import { Dropdown, Message } from 'semantic-ui-react';
 import { usePromise, useTransport } from '@polkadot/joy-utils/react/hooks';
@@ -19,7 +19,7 @@ import { WorkerData } from '@polkadot/joy-utils/types/workingGroups';
 import { LeadInfo } from '@polkadot/joy-utils/react/components/working-groups/LeadInfo';
 
 export type FormValues = GenericFormValues & {
-  workingGroup: WorkingGroupKeys;
+  workingGroup: WorkingGroupKey;
 };
 
 export const defaultValues: FormValues = {

+ 2 - 2
pioneer/packages/joy-utils/src/consts/workingGroups.ts

@@ -1,4 +1,4 @@
-import { WorkingGroupKeys } from '@joystream/types/common';
-export const apiModuleByGroup: { [k in WorkingGroupKeys]: string } = {
+import { WorkingGroupKey } from '@joystream/types/common';
+export const apiModuleByGroup: { [k in WorkingGroupKey]: string } = {
   Storage: 'storageWorkingGroup'
 };

+ 3 - 3
pioneer/packages/joy-utils/src/react/components/working-groups/ApplicationDetails.tsx

@@ -4,7 +4,7 @@ import { ProfilePreviewFromStruct as MemberPreview } from '../../../MemberProfil
 import { useTransport, usePromise } from '../../hooks';
 import { Item, Label, Button } from 'semantic-ui-react';
 import { formatBalance } from '@polkadot/util';
-import { WorkingGroupKeys } from '@joystream/types/common';
+import { WorkingGroupKey } from '@joystream/types/common';
 import PromiseComponent from '../PromiseComponent';
 
 type ApplicationsDetailsProps = {
@@ -59,7 +59,7 @@ export const ApplicationsDetails = ({ applications, acceptedIds }: ApplicationsD
 };
 
 type ApplicationsDetailsByIdsProps = {
-  group: WorkingGroupKeys;
+  group: WorkingGroupKey;
   ids: number[];
   acceptedIds?: number[];
 };
@@ -80,7 +80,7 @@ export const ApplicationsDetailsByIds = ({ group, ids, acceptedIds }: Applicatio
 };
 
 type ApplicationsDetailsByOpeningProps = {
-  group: WorkingGroupKeys;
+  group: WorkingGroupKey;
   openingId: number;
   acceptedIds?: number[];
 };

+ 3 - 3
pioneer/packages/joy-utils/src/react/components/working-groups/LeadInfo.tsx

@@ -3,14 +3,14 @@ import { WorkerData } from '../../../types/workingGroups';
 import { ProfilePreviewFromStruct as MemberPreview } from '../../../MemberProfilePreview';
 import { Label, Message } from 'semantic-ui-react';
 import { formatBalance } from '@polkadot/util';
-import { WorkingGroupKeys } from '@joystream/types/common';
+import { WorkingGroupKey } from '@joystream/types/common';
 import { useTransport, usePromise } from '../../hooks';
 import PromiseComponent from '../PromiseComponent';
 import { formatReward } from '@polkadot/joy-utils/functions/format';
 
 type LeadInfoProps = {
   lead: WorkerData | null;
-  group?: WorkingGroupKeys;
+  group?: WorkingGroupKey;
   header?: boolean;
   emptyMessage?: string;
 };
@@ -37,7 +37,7 @@ export const LeadInfo = ({ lead, group, header = false, emptyMessage = 'NONE' }:
 
 type LeadInfoFromIdProps = {
   leadId: number;
-  group: WorkingGroupKeys;
+  group: WorkingGroupKey;
 };
 
 export const LeadInfoFromId = ({ leadId, group }: LeadInfoFromIdProps) => {

+ 10 - 10
pioneer/packages/joy-utils/src/transport/workingGroups.ts

@@ -6,7 +6,7 @@ import MembersTransport from './members';
 import { SingleLinkedMapEntry } from '../index';
 import { Worker, WorkerId, Opening as WGOpening, Application as WGApplication } from '@joystream/types/working-group';
 import { apiModuleByGroup } from '../consts/workingGroups';
-import { WorkingGroupKeys } from '@joystream/types/common';
+import { WorkingGroupKey } from '@joystream/types/common';
 import { WorkerData, OpeningData, ParsedApplication } from '../types/workingGroups';
 import { OpeningId, ApplicationId, Opening, Application, ActiveOpeningStageKey } from '@joystream/types/hiring';
 import { MultipleLinkedMapEntry } from '../LinkedMapEntry';
@@ -21,12 +21,12 @@ export default class WorkingGroupsTransport extends BaseTransport {
     this.membersT = membersTransport;
   }
 
-  protected queryByGroup (group: WorkingGroupKeys) {
+  protected queryByGroup (group: WorkingGroupKey) {
     const module = apiModuleByGroup[group];
     return this.api.query[module];
   }
 
-  public async groupMemberById (group: WorkingGroupKeys, workerId: number): Promise<WorkerData | null> {
+  public async groupMemberById (group: WorkingGroupKey, workerId: number): Promise<WorkerData | null> {
     const workerLink = new SingleLinkedMapEntry(
       Worker,
       await this.queryByGroup(group).workerById(workerId)
@@ -50,7 +50,7 @@ export default class WorkingGroupsTransport extends BaseTransport {
     return { group, workerId, worker, profile, stake, reward };
   }
 
-  public async currentLead (group: WorkingGroupKeys): Promise<WorkerData | null> {
+  public async currentLead (group: WorkingGroupKey): Promise<WorkerData | null> {
     const optLeadId = (await this.queryByGroup(group).currentLead()) as Option<WorkerId>;
 
     if (!optLeadId.isSome) {
@@ -62,7 +62,7 @@ export default class WorkingGroupsTransport extends BaseTransport {
     return this.groupMemberById(group, leadWorkerId);
   }
 
-  public async allOpenings (group: WorkingGroupKeys): Promise<OpeningData[]> {
+  public async allOpenings (group: WorkingGroupKey): Promise<OpeningData[]> {
     const nextId = (await this.queryByGroup(group).nextOpeningId()) as OpeningId;
 
     if (nextId.eq(0)) {
@@ -83,7 +83,7 @@ export default class WorkingGroupsTransport extends BaseTransport {
     return openingsData;
   }
 
-  public async activeOpenings (group: WorkingGroupKeys, substage?: ActiveOpeningStageKey) {
+  public async activeOpenings (group: WorkingGroupKey, substage?: ActiveOpeningStageKey) {
     return (await this.allOpenings(group))
       .filter(od =>
         od.hiringOpening.stage.isOfType('Active') &&
@@ -91,7 +91,7 @@ export default class WorkingGroupsTransport extends BaseTransport {
       );
   }
 
-  async wgApplicationById (group: WorkingGroupKeys, wgApplicationId: number | ApplicationId): Promise<WGApplication> {
+  async wgApplicationById (group: WorkingGroupKey, wgApplicationId: number | ApplicationId): Promise<WGApplication> {
     const nextAppId = await this.queryByGroup(group).nextApplicationId() as ApplicationId;
 
     if (wgApplicationId < 0 || wgApplicationId >= nextAppId.toNumber()) {
@@ -145,12 +145,12 @@ export default class WorkingGroupsTransport extends BaseTransport {
     };
   }
 
-  async parsedApplicationById (group: WorkingGroupKeys, wgApplicationId: number): Promise<ParsedApplication> {
+  async parsedApplicationById (group: WorkingGroupKey, wgApplicationId: number): Promise<ParsedApplication> {
     const wgApplication = await this.wgApplicationById(group, wgApplicationId);
     return this.parseApplication(wgApplicationId, wgApplication);
   }
 
-  async openingApplications (group: WorkingGroupKeys, wgOpeningId: number): Promise<ParsedApplication[]> {
+  async openingApplications (group: WorkingGroupKey, wgOpeningId: number): Promise<ParsedApplication[]> {
     const applications: ParsedApplication[] = [];
 
     const nextAppId = await this.queryByGroup(group).nextApplicationId() as ApplicationId;
@@ -165,7 +165,7 @@ export default class WorkingGroupsTransport extends BaseTransport {
     return applications;
   }
 
-  async openingActiveApplications (group: WorkingGroupKeys, wgOpeningId: number): Promise<ParsedApplication[]> {
+  async openingActiveApplications (group: WorkingGroupKey, wgOpeningId: number): Promise<ParsedApplication[]> {
     return (await this.openingApplications(group, wgOpeningId))
       .filter(a => a.stage.isOfType('Active'));
   }

+ 2 - 2
pioneer/packages/joy-utils/src/types/workingGroups.ts

@@ -2,7 +2,7 @@ import { Worker, Opening as WGOpening } from '@joystream/types/working-group';
 import { Profile } from '@joystream/types/members';
 import { OpeningId, Opening, ApplicationStage } from '@joystream/types/hiring';
 import { AccountId } from '@polkadot/types/interfaces';
-import { WorkingGroupKeys } from '@joystream/types/common';
+import { WorkingGroupKey } from '@joystream/types/common';
 import { RewardRelationship } from '@joystream/types/recurring-rewards';
 
 export type WorkerData = {
@@ -11,7 +11,7 @@ export type WorkerData = {
   profile: Profile;
   stake?: number;
   reward?: RewardRelationship;
-  group: WorkingGroupKeys;
+  group: WorkingGroupKey;
 };
 
 export type OpeningData = {

+ 1 - 1
types/src/common.ts

@@ -119,7 +119,7 @@ export class InputValidationLengthConstraint extends JoyStruct<InputValidationLe
 export const WorkingGroupDef = {
   Storage: Null
 } as const;
-export type WorkingGroupKeys = keyof typeof WorkingGroupDef;
+export type WorkingGroupKey = keyof typeof WorkingGroupDef;
 export class WorkingGroup extends JoyEnum(WorkingGroupDef) { };
 
 export function registerCommonTypes() {