async removeContextMenuCommand()

in src/report.ts [759:779]


  async removeContextMenuCommand(commandName: string, contextMenuTitle: string): Promise<IHttpPostMessageResponse<void>> {
    if (isRDLEmbed(this.config.embedUrl)) {
      return Promise.reject(APINotSupportedForRDLError);
    }

    const commandCopy = JSON.parse(JSON.stringify(this.commands)) as ICommandExtension[];
    const indexOfCommand: number = this.findCommandMenuIndex("visualContextMenu", commandCopy, commandName, contextMenuTitle);
    if (indexOfCommand === -1) {
      throw CommonErrorCodes.NotFound;
    }

    // Delete the context menu and not the entire command, since command can have option menu as well.
    delete commandCopy[indexOfCommand].extend.visualContextMenu;
    const newSetting: ISettings = {
      extensions: {
        commands: commandCopy,
        groups: this.groups
      }
    };
    return await this.updateSettings(newSetting);
  }