From ab418e52aa6880154c3e5d4829cfbc53ca308bc4 Mon Sep 17 00:00:00 2001 From: Christopher Sexton Date: Sat, 13 Oct 2018 10:47:30 -0400 Subject: [PATCH 1/2] Add navigation items for issues and pull requests GitHub has added secondary navigation items for issues and pull requests. This extends the plugin to list these under each category. Issues: - Created - Mentioned - Assigned Pull Requests - Created - Mentioned - Assigned - Review Requested Renamed a few options: 1. "My Open Issues" and "My Open Pull Requests" to match the top level navigation items in GitHub web UI. It is now "My Issues" and "My Pull Requests". 2. "View All Issues" and "View All Pull Requests" to match the navigation items above. I the language of "View All Mentioned Pull Requests" or "View All Assigned Issues" seemed a little cumbersome. --- Contents/Scripts/default.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/Contents/Scripts/default.js b/Contents/Scripts/default.js index 9329a2f..2a0b721 100644 --- a/Contents/Scripts/default.js +++ b/Contents/Scripts/default.js @@ -11,14 +11,14 @@ class GitHubLB { actionReturnsItems: true, }, { - title: 'My Open Issues', + title: 'My Issues', icon: 'issueTemplate.png', action: 'openAccountIssues', actionArgument: handle, actionReturnsItems: true, }, { - title: 'My Open Pull Requests', + title: 'My Pull Requests', icon: 'pullRequestTemplate.png', action: 'openAccountPullRequests', actionArgument: handle, @@ -371,9 +371,24 @@ class GitHubLB { } else { return [ { - title: 'View All Pull Requests', + title: 'Created', icon: 'pullRequestTemplate.png', url: 'https://github.com/pulls', + }, + { + title: 'Assigned', + icon: 'pullRequestTemplate.png', + url: 'https://github.com/pulls/assigned', + }, + { + title: 'Mentioned', + icon: 'pullRequestTemplate.png', + url: 'https://github.com/pulls/mentioned', + }, + { + title: 'Review Requests', + icon: 'pullRequestTemplate.png', + url: 'https://github.com/pulls/review-requested', } ].concat(account.pullRequests().map(function(pullRequest) { return pullRequest.toMenuItem(); @@ -390,9 +405,19 @@ class GitHubLB { } else { return [ { - title: 'View All Issues', + title: 'Created', icon: 'issueTemplate.png', url: 'https://github.com/issues', + }, + { + title: 'Assigned', + icon: 'issueTemplate.png', + url: 'https://github.com/issues/assigned', + }, + { + title: 'Mentioned', + icon: 'issueTemplate.png', + url: 'https://github.com/issues/mentioned', } ].concat(account.issues().map(function(issue) { return issue.toMenuItem(); From 130f28470cda5d1305cf5c6ceeeaa9ec36c8f414 Mon Sep 17 00:00:00 2001 From: Christopher Sexton Date: Sat, 13 Oct 2018 10:54:55 -0400 Subject: [PATCH 2/2] Update bundle.min for new navigation items Update the generated code in a separate commit in case the maintainers want to manage the changes separately. --- Contents/Scripts/bundle.min.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Contents/Scripts/bundle.min.js b/Contents/Scripts/bundle.min.js index 4ed0b93..5e35534 100644 --- a/Contents/Scripts/bundle.min.js +++ b/Contents/Scripts/bundle.min.js @@ -1,4 +1,4 @@ -'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw|developer)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^([\w-\.]+)\/([\w-\.]+)#(\d+)?\s*([\w-]+)?$/;var REPOSITORY_FORMAT=/^([\w-\.]+)\/([\w-\.]+)?\s*([\w-]+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^([\w-]+)\s*([\w-]+)?$/;var match=void 0;// Matching: +'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw|developer)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^([\w-\.]+)\/([\w-\.]+)#(\d+)?\s*([\w-]+)?$/;var REPOSITORY_FORMAT=/^([\w-\.]+)\/([\w-\.]+)?\s*([\w-]+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^([\w-]+)\s*([\w-]+)?$/;var match=void 0;// Matching: // https://github.com/bswinnerton/dotfiles/blob/master/ack/ackrc.symlink#L6 if(input.match(GITHUB_LINK_FORMAT)){return[{title:'Shorten link',icon:'linkTemplate.png',action:'shortenLink',actionArgument:input},{title:'Add to things',icon:'thingsTemplate.png',action:'addToThings',actionArgument:input}];}// Matching: // rails/rails#123 @@ -14,7 +14,7 @@ else if(match=input.match(COMMIT_SHA_FORMAT)){var commit=new Commit(match[0]);re else if(match=input.match(ACCOUNT_FORMAT)){var account=new Account(match[1]);return this.openAccountMenu(account,match[2]);}}},{key:'openSettingsMenu',value:function openSettingsMenu(input){return[{title:'Set GitHub access token from clipboard',icon:'keyTemplate.png',action:'setToken',actionArgument:LaunchBar.getClipboardString()}];}},{key:'openIssueMenu',value:function openIssueMenu(issue){if(issue.number){var fetchedIssue=Issue.fetch(issue.repository,issue.number);return[fetchedIssue.toMenuItem()];}else{return[];}}},{key:'openRepositoriesMenu',value:function openRepositoriesMenu(account,selection){if(LaunchBar.options.commandKey==1){var repository=new Repository(account,selection);LaunchBar.openURL(repository.url);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var repositories=account.repositories();if(selection){repositories=repositories.filter(function(repository){var regex=new RegExp(selection,'i');return repository.name.match(regex);});// Sort repositories such that if the exact selection is present, it // floats to the top. repositories=repositories.sort(function(a,b){if(a.name==selection){return-1;}else{return 0;}});}return repositories.map(function(repository){var menuItem=repository.toMenuItem();delete menuItem.url;menuItem.action='openRepositoryMenu';menuItem.actionArgument=repository.nameWithOwner;menuItem.actionReturnsItems=true;return menuItem;});}}},{key:'openRepositoryMenu',value:function openRepositoryMenu(repository,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.url);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var repositoryMenuItems=[{title:'View Repository',subtitle:repository.nameWithOwner,alwaysShowsSubtitle:true,icon:'repoTemplate.png',url:repository.url},{title:'View Issues',icon:'issueTemplate.png',action:'openRepositoryIssues',actionArgument:repository.nameWithOwner,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openRepositoryPullRequests',actionArgument:repository.nameWithOwner,actionReturnsItems:true}];if(secondarySelection){return repositoryMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return repositoryMenuItems;}}}},{key:'openRepositoryPullRequests',value:function openRepositoryPullRequests(repository){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.pullRequestsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Pull Requests',icon:'pullRequestTemplate.png',url:repository.pullRequestsURL}].concat(repository.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openRepositoryIssues',value:function openRepositoryIssues(repository){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.issuesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Issues',icon:'issueTemplate.png',url:repository.issuesURL}].concat(repository.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openCommitPullRequestsMenu',value:function openCommitPullRequestsMenu(commit){var pullRequests=commit.pullRequests();if(pullRequests.length>1){return pullRequests.map(function(pr){return pr.toMenuItem();});}else if(pullRequests.length===1){return[pullRequests[0].toMenuItem()];}else{return[{title:'Search for commit: '+commit.sha,url:commit.searchURL,icon:'commitTemplate.png'//TODO -}];}}},{key:'openAccountMenu',value:function openAccountMenu(account,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.profileURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var accountMenuItems=[{title:'View Profile',subtitle:account.handle,alwaysShowsSubtitle:true,icon:'personTemplate.png',url:account.profileURL},{title:'View Repositories',icon:'repoTemplate.png',action:'openAccountRepositories',actionArgument:account.login,actionReturnsItems:true},{title:'View Issues',icon:'issueTemplate.png',action:'openAccountIssues',actionArgument:account.login,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openAccountPullRequests',actionArgument:account.login,actionReturnsItems:true},{title:'View Gists',icon:'gistTemplate.png',action:'openAccountGists',actionArgument:account.login,actionReturnsItems:true},{title:'View Projects',icon:'projectTemplate.png',action:'openOrganizationProjects',actionArgument:account.login,actionReturnsItems:true}];if(secondarySelection){return accountMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return accountMenuItems;}}}},{key:'openAccountRepositoriesMenu',value:function openAccountRepositoriesMenu(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.repositoriesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Repositories',icon:'reposTemplate.png',url:account.repositoriesURL}].concat(account.repositories().map(function(repository){return repository.toMenuItem();}));}}},{key:'openAccountPullRequests',value:function openAccountPullRequests(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/pulls');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Pull Requests',icon:'pullRequestTemplate.png',url:'https://github.com/pulls'}].concat(account.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openAccountIssues',value:function openAccountIssues(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/issues');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Issues',icon:'issueTemplate.png',url:'https://github.com/issues'}].concat(account.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openAccountGists',value:function openAccountGists(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://gist.github.com');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Gists',icon:'gistTemplate.png',url:'https://gist.github.com'}].concat(account.gists().map(function(gist){return gist.toMenuItem();}));}}},{key:'openOrganizationProjects',value:function openOrganizationProjects(login){var org=new Organization(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(org.projectsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Projects',icon:'projectTemplate.png',url:org.projectsURL}].concat(org.projects().map(function(project){return project.toMenuItem();}));}}},{key:'shortenLink',value:function shortenLink(link){var linkShortener=new LinkShortener(link);var shortLink=linkShortener.run();LaunchBar.setClipboardString(shortLink);LaunchBar.displayNotification({title:'Copied '+shortLink+' to your clipboard'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}},{key:'addToThings',value:function addToThings(link){var resource=new Resource(link).toObject();var title=resource.title;var todo=encodeURIComponent('Review "'+title+'"');var url=encodeURIComponent(resource.url);LaunchBar.openURL('things:///add?show-quick-entry=true&title='+todo+'¬es='+url);}},{key:'setToken',value:function setToken(token){Action.preferences.token=token;var result=GraphQL.execute('query { viewer { login } }');if(result.data){var handle=result.data.viewer.login;Action.preferences.viewerHandle=handle;LaunchBar.displayNotification({title:'👋 Hi @'+handle,string:'Your access token was set successfully.'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{LaunchBar.displayNotification({title:'That looks like an invalid token',string:'Please try again by going back to settings.'});}}}]);return GitHubLB;}();GitHubLB.VERSION='v'+Action.version+'-'+LaunchBar.version;var app=new GitHubLB();function run(argument){return app.run(argument);}function runWithString(string){return app.run(string);}function runWithURL(url,details){if(details.path.endsWith('setToken')){return app.setToken(details.queryParameters.token);}else{return app.run(url,details);}}// Unfortunately when the script output uses an action argument (like +}];}}},{key:'openAccountMenu',value:function openAccountMenu(account,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.profileURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var accountMenuItems=[{title:'View Profile',subtitle:account.handle,alwaysShowsSubtitle:true,icon:'personTemplate.png',url:account.profileURL},{title:'View Repositories',icon:'repoTemplate.png',action:'openAccountRepositories',actionArgument:account.login,actionReturnsItems:true},{title:'View Issues',icon:'issueTemplate.png',action:'openAccountIssues',actionArgument:account.login,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openAccountPullRequests',actionArgument:account.login,actionReturnsItems:true},{title:'View Gists',icon:'gistTemplate.png',action:'openAccountGists',actionArgument:account.login,actionReturnsItems:true},{title:'View Projects',icon:'projectTemplate.png',action:'openOrganizationProjects',actionArgument:account.login,actionReturnsItems:true}];if(secondarySelection){return accountMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return accountMenuItems;}}}},{key:'openAccountRepositoriesMenu',value:function openAccountRepositoriesMenu(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.repositoriesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Repositories',icon:'reposTemplate.png',url:account.repositoriesURL}].concat(account.repositories().map(function(repository){return repository.toMenuItem();}));}}},{key:'openAccountPullRequests',value:function openAccountPullRequests(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/pulls');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'Created',icon:'pullRequestTemplate.png',url:'https://github.com/pulls'},{title:'Assigned',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/assigned'},{title:'Mentioned',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/mentioned'},{title:'Review Requests',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/review-requested'}].concat(account.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openAccountIssues',value:function openAccountIssues(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/issues');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'Created',icon:'issueTemplate.png',url:'https://github.com/issues'},{title:'Assigned',icon:'issueTemplate.png',url:'https://github.com/issues/assigned'},{title:'Mentioned',icon:'issueTemplate.png',url:'https://github.com/issues/mentioned'}].concat(account.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openAccountGists',value:function openAccountGists(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://gist.github.com');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Gists',icon:'gistTemplate.png',url:'https://gist.github.com'}].concat(account.gists().map(function(gist){return gist.toMenuItem();}));}}},{key:'openOrganizationProjects',value:function openOrganizationProjects(login){var org=new Organization(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(org.projectsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Projects',icon:'projectTemplate.png',url:org.projectsURL}].concat(org.projects().map(function(project){return project.toMenuItem();}));}}},{key:'shortenLink',value:function shortenLink(link){var linkShortener=new LinkShortener(link);var shortLink=linkShortener.run();LaunchBar.setClipboardString(shortLink);LaunchBar.displayNotification({title:'Copied '+shortLink+' to your clipboard'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}},{key:'addToThings',value:function addToThings(link){var resource=new Resource(link).toObject();var title=resource.title;var todo=encodeURIComponent('Review "'+title+'"');var url=encodeURIComponent(resource.url);LaunchBar.openURL('things:///add?show-quick-entry=true&title='+todo+'¬es='+url);}},{key:'setToken',value:function setToken(token){Action.preferences.token=token;var result=GraphQL.execute('query { viewer { login } }');if(result.data){var handle=result.data.viewer.login;Action.preferences.viewerHandle=handle;LaunchBar.displayNotification({title:'👋 Hi @'+handle,string:'Your access token was set successfully.'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{LaunchBar.displayNotification({title:'That looks like an invalid token',string:'Please try again by going back to settings.'});}}}]);return GitHubLB;}();GitHubLB.VERSION='v'+Action.version+'-'+LaunchBar.version;var app=new GitHubLB();function run(argument){return app.run(argument);}function runWithString(string){return app.run(string);}function runWithURL(url,details){if(details.path.endsWith('setToken')){return app.setToken(details.queryParameters.token);}else{return app.run(url,details);}}// Unfortunately when the script output uses an action argument (like // openAccount does), it needs to be able to find the function from the global // scope. The following functions are workarounds to the appropriate actions. // @@ -25,7 +25,7 @@ function openAccountRepositories(string){return app.openAccountRepositoriesMenu( var Cache=function Cache(){_classCallCheck(this,Cache);};Cache.fetch=function(key,ttl,func){var results=Cache.read(key);if(results){return results;}else{return Cache.write(key,ttl,func);}};Cache.read=function(key){var path=Cache.filePath(key);if(File.exists(path)){var cacheData=File.readJSON(path);var currentTime=Math.floor(new Date()/1000);if(currentTime0){writeFile.call(this);}else if(Object.keys(results).length>0&&results.constructor===Object){writeFile.call(this);}return results;};Cache.filePath=function(key){return Action.cachePath+'/'+Action.version+'-'+key+'.json';};if(typeof module!=='undefined'){module.exports.Cache=Cache;} 'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw|developer)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^([\w-\.]+)\/([\w-\.]+)#(\d+)?\s*([\w-]+)?$/;var REPOSITORY_FORMAT=/^([\w-\.]+)\/([\w-\.]+)?\s*([\w-]+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^([\w-]+)\s*([\w-]+)?$/;var match=void 0;// Matching: +'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i0){var matchedDefaultMenuItems=this.matchingDefaultMenuItems(input);if(matchedDefaultMenuItems.length>0){return matchedDefaultMenuItems.concat(this.conflictingHandleMenuItem(input));}else{return this.displayMenuItemFor(input);}}else{return this.defaultMenuItems;}}},{key:'matchingDefaultMenuItems',value:function matchingDefaultMenuItems(input){return this.defaultMenuItems.filter(function(item){var regex=new RegExp(input,'i');return item.title.match(regex);});}},{key:'conflictingHandleMenuItem',value:function conflictingHandleMenuItem(handle){return[{title:'@'+handle,subtitle:'Looking for the user @'+handle+'?',alwaysShowsSubtitle:true,icon:'personTemplate.png',action:'openAccountMenu',actionArgument:handle}];}},{key:'displayMenuItemFor',value:function displayMenuItemFor(input){var GITHUB_LINK_FORMAT=/^https?:\/\/((www|gist|raw|developer)\.)?github\.(io|com)/;var ISSUE_OR_PR_FORMAT=/^([\w-\.]+)\/([\w-\.]+)#(\d+)?\s*([\w-]+)?$/;var REPOSITORY_FORMAT=/^([\w-\.]+)\/([\w-\.]+)?\s*([\w-]+)?$/;var COMMIT_SHA_FORMAT=/^\b[0-9a-f]{5,40}\b$/;var ACCOUNT_FORMAT=/^([\w-]+)\s*([\w-]+)?$/;var match=void 0;// Matching: // https://github.com/bswinnerton/dotfiles/blob/master/ack/ackrc.symlink#L6 if(input.match(GITHUB_LINK_FORMAT)){return[{title:'Shorten link',icon:'linkTemplate.png',action:'shortenLink',actionArgument:input},{title:'Add to things',icon:'thingsTemplate.png',action:'addToThings',actionArgument:input}];}// Matching: // rails/rails#123 @@ -41,7 +41,7 @@ else if(match=input.match(COMMIT_SHA_FORMAT)){var commit=new Commit(match[0]);re else if(match=input.match(ACCOUNT_FORMAT)){var account=new Account(match[1]);return this.openAccountMenu(account,match[2]);}}},{key:'openSettingsMenu',value:function openSettingsMenu(input){return[{title:'Set GitHub access token from clipboard',icon:'keyTemplate.png',action:'setToken',actionArgument:LaunchBar.getClipboardString()}];}},{key:'openIssueMenu',value:function openIssueMenu(issue){if(issue.number){var fetchedIssue=Issue.fetch(issue.repository,issue.number);return[fetchedIssue.toMenuItem()];}else{return[];}}},{key:'openRepositoriesMenu',value:function openRepositoriesMenu(account,selection){if(LaunchBar.options.commandKey==1){var repository=new Repository(account,selection);LaunchBar.openURL(repository.url);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var repositories=account.repositories();if(selection){repositories=repositories.filter(function(repository){var regex=new RegExp(selection,'i');return repository.name.match(regex);});// Sort repositories such that if the exact selection is present, it // floats to the top. repositories=repositories.sort(function(a,b){if(a.name==selection){return-1;}else{return 0;}});}return repositories.map(function(repository){var menuItem=repository.toMenuItem();delete menuItem.url;menuItem.action='openRepositoryMenu';menuItem.actionArgument=repository.nameWithOwner;menuItem.actionReturnsItems=true;return menuItem;});}}},{key:'openRepositoryMenu',value:function openRepositoryMenu(repository,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.url);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var repositoryMenuItems=[{title:'View Repository',subtitle:repository.nameWithOwner,alwaysShowsSubtitle:true,icon:'repoTemplate.png',url:repository.url},{title:'View Issues',icon:'issueTemplate.png',action:'openRepositoryIssues',actionArgument:repository.nameWithOwner,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openRepositoryPullRequests',actionArgument:repository.nameWithOwner,actionReturnsItems:true}];if(secondarySelection){return repositoryMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return repositoryMenuItems;}}}},{key:'openRepositoryPullRequests',value:function openRepositoryPullRequests(repository){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.pullRequestsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Pull Requests',icon:'pullRequestTemplate.png',url:repository.pullRequestsURL}].concat(repository.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openRepositoryIssues',value:function openRepositoryIssues(repository){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(repository.issuesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Issues',icon:'issueTemplate.png',url:repository.issuesURL}].concat(repository.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openCommitPullRequestsMenu',value:function openCommitPullRequestsMenu(commit){var pullRequests=commit.pullRequests();if(pullRequests.length>1){return pullRequests.map(function(pr){return pr.toMenuItem();});}else if(pullRequests.length===1){return[pullRequests[0].toMenuItem()];}else{return[{title:'Search for commit: '+commit.sha,url:commit.searchURL,icon:'commitTemplate.png'//TODO -}];}}},{key:'openAccountMenu',value:function openAccountMenu(account,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.profileURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var accountMenuItems=[{title:'View Profile',subtitle:account.handle,alwaysShowsSubtitle:true,icon:'personTemplate.png',url:account.profileURL},{title:'View Repositories',icon:'repoTemplate.png',action:'openAccountRepositories',actionArgument:account.login,actionReturnsItems:true},{title:'View Issues',icon:'issueTemplate.png',action:'openAccountIssues',actionArgument:account.login,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openAccountPullRequests',actionArgument:account.login,actionReturnsItems:true},{title:'View Gists',icon:'gistTemplate.png',action:'openAccountGists',actionArgument:account.login,actionReturnsItems:true},{title:'View Projects',icon:'projectTemplate.png',action:'openOrganizationProjects',actionArgument:account.login,actionReturnsItems:true}];if(secondarySelection){return accountMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return accountMenuItems;}}}},{key:'openAccountRepositoriesMenu',value:function openAccountRepositoriesMenu(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.repositoriesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Repositories',icon:'reposTemplate.png',url:account.repositoriesURL}].concat(account.repositories().map(function(repository){return repository.toMenuItem();}));}}},{key:'openAccountPullRequests',value:function openAccountPullRequests(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/pulls');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Pull Requests',icon:'pullRequestTemplate.png',url:'https://github.com/pulls'}].concat(account.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openAccountIssues',value:function openAccountIssues(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/issues');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Issues',icon:'issueTemplate.png',url:'https://github.com/issues'}].concat(account.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openAccountGists',value:function openAccountGists(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://gist.github.com');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Gists',icon:'gistTemplate.png',url:'https://gist.github.com'}].concat(account.gists().map(function(gist){return gist.toMenuItem();}));}}},{key:'openOrganizationProjects',value:function openOrganizationProjects(login){var org=new Organization(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(org.projectsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Projects',icon:'projectTemplate.png',url:org.projectsURL}].concat(org.projects().map(function(project){return project.toMenuItem();}));}}},{key:'shortenLink',value:function shortenLink(link){var linkShortener=new LinkShortener(link);var shortLink=linkShortener.run();LaunchBar.setClipboardString(shortLink);LaunchBar.displayNotification({title:'Copied '+shortLink+' to your clipboard'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}},{key:'addToThings',value:function addToThings(link){var resource=new Resource(link).toObject();var title=resource.title;var todo=encodeURIComponent('Review "'+title+'"');var url=encodeURIComponent(resource.url);LaunchBar.openURL('things:///add?show-quick-entry=true&title='+todo+'¬es='+url);}},{key:'setToken',value:function setToken(token){Action.preferences.token=token;var result=GraphQL.execute('query { viewer { login } }');if(result.data){var handle=result.data.viewer.login;Action.preferences.viewerHandle=handle;LaunchBar.displayNotification({title:'👋 Hi @'+handle,string:'Your access token was set successfully.'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{LaunchBar.displayNotification({title:'That looks like an invalid token',string:'Please try again by going back to settings.'});}}}]);return GitHubLB;}();GitHubLB.VERSION='v'+Action.version+'-'+LaunchBar.version;var app=new GitHubLB();function run(argument){return app.run(argument);}function runWithString(string){return app.run(string);}function runWithURL(url,details){if(details.path.endsWith('setToken')){return app.setToken(details.queryParameters.token);}else{return app.run(url,details);}}// Unfortunately when the script output uses an action argument (like +}];}}},{key:'openAccountMenu',value:function openAccountMenu(account,secondarySelection){if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.profileURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{var accountMenuItems=[{title:'View Profile',subtitle:account.handle,alwaysShowsSubtitle:true,icon:'personTemplate.png',url:account.profileURL},{title:'View Repositories',icon:'repoTemplate.png',action:'openAccountRepositories',actionArgument:account.login,actionReturnsItems:true},{title:'View Issues',icon:'issueTemplate.png',action:'openAccountIssues',actionArgument:account.login,actionReturnsItems:true},{title:'View Pull Requests',icon:'pullRequestTemplate.png',action:'openAccountPullRequests',actionArgument:account.login,actionReturnsItems:true},{title:'View Gists',icon:'gistTemplate.png',action:'openAccountGists',actionArgument:account.login,actionReturnsItems:true},{title:'View Projects',icon:'projectTemplate.png',action:'openOrganizationProjects',actionArgument:account.login,actionReturnsItems:true}];if(secondarySelection){return accountMenuItems.filter(function(item){var regex=new RegExp(secondarySelection,'i');return item.title.match(regex);});}else{return accountMenuItems;}}}},{key:'openAccountRepositoriesMenu',value:function openAccountRepositoriesMenu(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(account.repositoriesURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Repositories',icon:'reposTemplate.png',url:account.repositoriesURL}].concat(account.repositories().map(function(repository){return repository.toMenuItem();}));}}},{key:'openAccountPullRequests',value:function openAccountPullRequests(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/pulls');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'Created',icon:'pullRequestTemplate.png',url:'https://github.com/pulls'},{title:'Assigned',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/assigned'},{title:'Mentioned',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/mentioned'},{title:'Review Requests',icon:'pullRequestTemplate.png',url:'https://github.com/pulls/review-requested'}].concat(account.pullRequests().map(function(pullRequest){return pullRequest.toMenuItem();}));}}},{key:'openAccountIssues',value:function openAccountIssues(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://github.com/issues');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'Created',icon:'issueTemplate.png',url:'https://github.com/issues'},{title:'Assigned',icon:'issueTemplate.png',url:'https://github.com/issues/assigned'},{title:'Mentioned',icon:'issueTemplate.png',url:'https://github.com/issues/mentioned'}].concat(account.issues().map(function(issue){return issue.toMenuItem();}));}}},{key:'openAccountGists',value:function openAccountGists(login){var account=new Account(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL('https://gist.github.com');LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Gists',icon:'gistTemplate.png',url:'https://gist.github.com'}].concat(account.gists().map(function(gist){return gist.toMenuItem();}));}}},{key:'openOrganizationProjects',value:function openOrganizationProjects(login){var org=new Organization(login);if(LaunchBar.options.commandKey==1){LaunchBar.openURL(org.projectsURL);LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{return[{title:'View All Projects',icon:'projectTemplate.png',url:org.projectsURL}].concat(org.projects().map(function(project){return project.toMenuItem();}));}}},{key:'shortenLink',value:function shortenLink(link){var linkShortener=new LinkShortener(link);var shortLink=linkShortener.run();LaunchBar.setClipboardString(shortLink);LaunchBar.displayNotification({title:'Copied '+shortLink+' to your clipboard'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}},{key:'addToThings',value:function addToThings(link){var resource=new Resource(link).toObject();var title=resource.title;var todo=encodeURIComponent('Review "'+title+'"');var url=encodeURIComponent(resource.url);LaunchBar.openURL('things:///add?show-quick-entry=true&title='+todo+'¬es='+url);}},{key:'setToken',value:function setToken(token){Action.preferences.token=token;var result=GraphQL.execute('query { viewer { login } }');if(result.data){var handle=result.data.viewer.login;Action.preferences.viewerHandle=handle;LaunchBar.displayNotification({title:'👋 Hi @'+handle,string:'Your access token was set successfully.'});LaunchBar.executeAppleScript('tell application "LaunchBar" to hide');}else{LaunchBar.displayNotification({title:'That looks like an invalid token',string:'Please try again by going back to settings.'});}}}]);return GitHubLB;}();GitHubLB.VERSION='v'+Action.version+'-'+LaunchBar.version;var app=new GitHubLB();function run(argument){return app.run(argument);}function runWithString(string){return app.run(string);}function runWithURL(url,details){if(details.path.endsWith('setToken')){return app.setToken(details.queryParameters.token);}else{return app.run(url,details);}}// Unfortunately when the script output uses an action argument (like // openAccount does), it needs to be able to find the function from the global // scope. The following functions are workarounds to the appropriate actions. //