Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
//Get a reference to our command
const command: Command | undefined = this.tryGetCommand("spfxClone");
if (command) {
let allowed = true;
//If Lists is specified, the command should only show up for named lists
if(typeof this.properties.Lists !== "undefined" && this.properties.Lists.length > 0) {
let lists = this.properties.Lists.split(',');
allowed = lists.indexOf(this.context.pageContext.list.title) > -1;
}
//Only show the command if at least 1 row is selected and the user has permission to add list items
command.visible = event.selectedRows.length >= 1 && this.context.pageContext.list.permissions.hasPermission(SPPermission.addListItems) && allowed;
}
}