import { Guid } from '@microsoft/sp-core-library' ; import { override } from '@microsoft/decorators' ; import { BaseListViewCommandSet , Command , IListViewCommandSetListViewUpdatedParameters , IListViewCommandSetExecuteEventParameters } from '@microsoft/sp-listview-extensibility' ; import { Dialog } from '@microsoft/sp-dialog' ; import * as strings from 'CustomEcbCommandSetStrings' ; export interface ICustomEcbCommandSetProperties { targetUrl : string ; } export default class CustomEcbCommandSet extends BaseListViewCommandSet < ICustomEcbCommandSetProperties > { @ override public onInit ( ) { return Promise . resolve ( ) ; } @ override public onListViewUpdated ( event ) { const compareOneCommand = this . tryGetCommand ( 'ShowDetails' ) ; if ( compareOneCommand ) { compareOneCommand . visible = event . selectedRows . length === 1 ; } } @ override public onExecute ( event ) { switch ( event . itemId ) { case 'ShowDetails' : const itemId = event . selectedRows [ 0 ] . getValueByName ( "ID" ) ; const listId = this . context . pageContext . list . id ; window . location . replace ( `${ this . properties . targetUrl }?ID=${ itemId }&List=${ listId }` ) ; break ; default : throw new Error ( 'Unknown command' ) ; } } }