import { override } from '@microsoft/decorators' ; import { Log } from '@microsoft/sp-core-library' ; import { BaseListViewCommandSet , IListViewCommandSetRefreshEventParameters , IListViewCommandSetExecuteEventParameters } from '@microsoft/sp-listview-extensibility' ; import * as strings from 'helloWorldStrings' ; /**
 * If your command set uses the ClientSideComponentProperties JSON input,
 * it will be deserialized into the BaseExtension.properties object.
 * You can define an interface to describe it.
 */ export interface IHelloWorldCommandSetProperties { disabledCommandIds : string [ ] ; } const LOG_SOURCE = 'HelloWorldCommandSet' ; export default class HelloWorldCommandSet extends BaseListViewCommandSet < IHelloWorldCommandSetProperties > { @ override public onInit ( ) { Log . info ( LOG_SOURCE , 'Initialized HelloWorldCommandSet' ) ; return Promise . resolve < void > ( ) ; } @ override public onRefreshCommand ( event ) { event . visible = true ; if ( this . properties . disabledCommandIds ) { if ( this . properties . disabledCommandIds . indexOf ( event . commandId ) >= 0 ) { Log . info ( LOG_SOURCE , 'Hiding command ' + event . commandId ) ; event . visible = false ; } } } @ override public onExecute ( event ) { switch ( event . commandId ) { case 'COMMAND_1' : alert ( `Clicked ${ strings . Command1 }` ) ; break ; case 'COMMAND_2' : alert ( `Clicked ${ strings . Command2 }` ) ; break ; default : throw new Error ( 'Unknown command' ) ; } } }