Browse Source

Terminate application + better status messages

Leszek Wiesner 4 years ago
parent
commit
fe66a2c75a

+ 4 - 2
cli/src/commands/working-groups/createOpening.ts

@@ -71,8 +71,10 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
                     true
                 );
 
+                this.log(chalk.green('Opening succesfully created!'));
+
                 saveDraft = await this.simplePrompt({
-                    message: 'Do you wish to save this opportunity as draft?',
+                    message: 'Do you wish to save this opening as draft?',
                     type: 'confirm'
                 });
             }
@@ -91,4 +93,4 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
             this.log(chalk.green('Opening succesfully created!'));
         }
     }
-  }
+}

+ 10 - 3
cli/src/commands/working-groups/fillOpening.ts

@@ -5,6 +5,7 @@ import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
 import { WorkerOpeningId, WorkerApplicationIdSet } from '@joystream/types/lib/working-group';
 import { RewardPolicy } from '@joystream/types/lib/content-working-group';
+import chalk from 'chalk';
 
 export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
     static description = 'Allows filling worker opening that\'s currently in review. Requires lead access.';
@@ -32,7 +33,7 @@ export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
             this.error('This opening is not in the Review stage!', { exit: ExitCodes.InvalidInput });
         }
 
-        const applications = await this.promptForApplicationsToAccept(opening);
+        const applicationIds = await this.promptForApplicationsToAccept(opening);
         const rewardPolicyOpt = await this.promptForParam(`Option<${RewardPolicy.name}>`, 'RewardPolicy');
 
         await this.requestAccountDecoding(account);
@@ -43,9 +44,15 @@ export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
             'fillWorkerOpening',
             [
                 new WorkerOpeningId(opening.workerOpeningId),
-                new WorkerApplicationIdSet(applications),
+                new WorkerApplicationIdSet(applicationIds),
                 rewardPolicyOpt
             ]
         );
+
+        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} succesfully filled!`));
+        this.log(
+            chalk.green('Accepted worker application IDs: ') +
+            chalk.white(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
+        );
     }
-  }
+}

+ 4 - 1
cli/src/commands/working-groups/startAcceptingApplications.ts

@@ -4,6 +4,7 @@ import { OpeningStatus } from '../../Types';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
 import { WorkerOpeningId } from '@joystream/types/lib/working-group';
+import chalk from 'chalk';
 
 export default class WorkingGroupsStartAcceptingApplications extends WorkingGroupsCommandBase {
     static description = 'Changes the status of pending opening to "Accepting applications". Requires lead access.';
@@ -39,5 +40,7 @@ export default class WorkingGroupsStartAcceptingApplications extends WorkingGrou
             'acceptWorkerApplications',
             [ new WorkerOpeningId(opening.workerOpeningId) ]
         );
+
+        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} status changed to: ${ chalk.white('Accepting Applications') }`));
     }
-  }
+}

+ 4 - 1
cli/src/commands/working-groups/startReviewPeriod.ts

@@ -4,6 +4,7 @@ import { OpeningStatus } from '../../Types';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
 import { WorkerOpeningId } from '@joystream/types/lib/working-group';
+import chalk from 'chalk';
 
 export default class WorkingGroupsStartReviewPeriod extends WorkingGroupsCommandBase {
     static description = 'Changes the status of active opening to "In review". Requires lead access.';
@@ -39,5 +40,7 @@ export default class WorkingGroupsStartReviewPeriod extends WorkingGroupsCommand
             'beginWorkerApplicantReview',
             [ new WorkerOpeningId(opening.workerOpeningId) ]
         );
+
+        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} status changed to: ${ chalk.white('In Review') }`));
     }
-  }
+}

+ 46 - 0
cli/src/commands/working-groups/terminateApplication.ts

@@ -0,0 +1,46 @@
+import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase';
+import _ from 'lodash';
+import ExitCodes from '../../ExitCodes';
+import { apiModuleByGroup } from '../../Api';
+import { WorkerApplicationId } from '@joystream/types/lib/working-group';
+import { ApplicationStageKeys } from '@joystream/types/lib/hiring';
+import chalk from 'chalk';
+
+export default class WorkingGroupsTerminateApplication extends WorkingGroupsCommandBase {
+    static description = 'Terminates given worker application. Requires lead access.';
+    static args = [
+        {
+            name: 'workerApplicationId',
+            required: true,
+            description: 'Worker Application ID'
+        },
+    ]
+    static flags = {
+        ...WorkingGroupsCommandBase.flags,
+    };
+
+    async run() {
+        const { args } = this.parse(WorkingGroupsTerminateApplication);
+
+        const account = await this.getRequiredSelectedAccount();
+        // Lead-only gate
+        await this.getRequiredLead();
+
+        const application = await this.getApi().groupApplication(this.group, parseInt(args.workerApplicationId));
+
+        if (application.stage !== ApplicationStageKeys.Active) {
+            this.error('This application is not active!', { exit: ExitCodes.InvalidInput });
+        }
+
+        await this.requestAccountDecoding(account);
+
+        await this.sendAndFollowExtrinsic(
+            account,
+            apiModuleByGroup[this.group],
+            'terminateWorkerApplication',
+            [new WorkerApplicationId(application.workerApplicationId)]
+        );
+
+        this.log(chalk.green(`Application ${chalk.white(application.workerApplicationId)} has been succesfully terminated!`));
+    }
+}