From 7c333902f6acb359555b5903d431c6175746b344 Mon Sep 17 00:00:00 2001 From: Brooks Swinnerton Date: Sun, 26 Feb 2017 20:33:56 -0500 Subject: [PATCH] Don't open browser when no token is set --- Contents/Scripts/bundle.min.js | 2 +- Contents/Scripts/graphql.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Contents/Scripts/bundle.min.js b/Contents/Scripts/bundle.min.js index 9dfaeec..fa8f71e 100644 --- a/Contents/Scripts/bundle.min.js +++ b/Contents/Scripts/bundle.min.js @@ -40,7 +40,7 @@ else if(match=input.match(ACCOUNT_FORMAT)){var account=new Account(match[1]);ret // // https://developer.obdev.at/launchbar-developer-documentation/#/script-output. function openAccountRepositories(string){return app.openAccountRepositoriesMenu(string);}function openAccountMenu(string){return app.openAccountMenu(string);}function shortenLink(link,details){return app.shortenLink(link);}function openSettingsMenu(){return app.openSettingsMenu();}function setToken(token){return app.setToken(token);}function openRepositoryMenu(nameWithOwner){var match=nameWithOwner.match(/^(.*)\/(.*)$/);var owner=new Account(match[1]);var repository=new Repository(owner,match[2]);return app.openRepositoryMenu(repository);} -"use strict";var GraphQL={};GraphQL.execute=function(query,variables){if(!Action.preferences.token){LaunchBar.openURL('https://github.com/settings/tokens');LaunchBar.alert("It looks like this is the first time you're using "+"this action.\n\nPlease go to https://github.com/settings/tokens "+"and create token with 'repo' and 'user' scope and set it by invoking "+"the github action and going to settings.");return;}var requestHeaders={authorization:'token '+Action.preferences.token};var requestBody={query:query,variables:variables};var result=HTTP.post('https://api.github.com/graphql',{headerFields:requestHeaders,body:JSON.stringify(requestBody)});LaunchBar.debugLog('action=launchbar-github request='+JSON.stringify(requestBody));LaunchBar.debugLog('action=launchbar-github response='+JSON.stringify(result));if(result.data){var body=JSON.parse(result.data);if(body.data){return body;}else{if(body.message){LaunchBar.displayNotification({title:"Couldn't access the GitHub API",string:body.message});}else{LaunchBar.displayNotification({title:"Couldn't access the GitHub API"});}return[];}}};if(typeof module!=='undefined'){module.exports.GraphQL=GraphQL;} +"use strict";var GraphQL={};GraphQL.execute=function(query,variables){if(!Action.preferences.token){LaunchBar.alert("It looks like this is the first time you're using "+"this action.\n\nPlease go to https://github.com/settings/tokens "+"and create token with 'repo' and 'user' scope and set it by invoking "+"the github action and going to settings.");}var requestHeaders={authorization:'token '+Action.preferences.token};var requestBody={query:query,variables:variables};var result=HTTP.post('https://api.github.com/graphql',{headerFields:requestHeaders,body:JSON.stringify(requestBody)});LaunchBar.debugLog('action=launchbar-github request='+JSON.stringify(requestBody));LaunchBar.debugLog('action=launchbar-github response='+JSON.stringify(result));if(result.data){var body=JSON.parse(result.data);if(body.data){return body;}else{if(body.message){LaunchBar.displayNotification({title:"Couldn't access the GitHub API",string:body.message});}else{LaunchBar.displayNotification({title:"Couldn't access the GitHub API"});}return[];}}};if(typeof module!=='undefined'){module.exports.GraphQL=GraphQL;} 'use strict';var _createClass=function(){function defineProperties(target,props){for(var i=0;i