From 0c6227a99e72d1de4bb9cc98bfbfcff9c6dde67a Mon Sep 17 00:00:00 2001
From: Johannes Millan
Date: Mon, 19 Feb 2018 18:40:22 +0100
Subject: [PATCH] fix: pulling from wrong repository by getting git settings
each time #55
---
app-src/scripts/constants.js | 2 +-
.../scripts/daily-planner/daily-planner-d.js | 2 +-
.../dialogs/help/help-daily-planner.html | 4 +-
.../scripts/dialogs/help/help-task-list.html | 2 +-
.../scripts/dialogs/welcome/welcome-c.html | 2 +-
.../scripts/main-header/main-header-d.html | 2 +-
app-src/scripts/main/global-services/git-s.js | 43 ++++++++++++++-----
app-src/scripts/routes.js | 2 +-
8 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/app-src/scripts/constants.js b/app-src/scripts/constants.js
index c3104630d3..c3a9373013 100644
--- a/app-src/scripts/constants.js
+++ b/app-src/scripts/constants.js
@@ -81,7 +81,7 @@
git: {
isShowIssuesFromGit: false,
isAutoImportToBacklog: false,
- repo: undefined,
+ repo: '',
projectDir: undefined,
prPrefix: 'Check PR: '
},
diff --git a/app-src/scripts/daily-planner/daily-planner-d.js b/app-src/scripts/daily-planner/daily-planner-d.js
index 31d5d7322f..e3898ef5fd 100644
--- a/app-src/scripts/daily-planner/daily-planner-d.js
+++ b/app-src/scripts/daily-planner/daily-planner-d.js
@@ -43,7 +43,7 @@
// add new git tasks
Git.checkForNewAndAddToBacklog();
- if (Git.isSufficientSettings() && $rootScope.r.git.isShowIssuesFromGit) {
+ if (Git.isRepoConfigured() && $rootScope.r.git.isShowIssuesFromGit) {
Git.getIssueList()
.then((res) => {
vm.taskSuggestions = vm.taskSuggestions.concat(res.data);
diff --git a/app-src/scripts/dialogs/help/help-daily-planner.html b/app-src/scripts/dialogs/help/help-daily-planner.html
index 548a869e02..a8bce76fc4 100644
--- a/app-src/scripts/dialogs/help/help-daily-planner.html
+++ b/app-src/scripts/dialogs/help/help-daily-planner.html
@@ -8,7 +8,7 @@
.
If Jira integration is enabled (you can enable it on the
+ ui-sref="xxxxxxxxxxxxxxxxxxxxx">
settings page) you can use the input the top also for importing tasks from Jira. Just enter the issue number or the issue summary and select the issue you from the auto suggestions. You can
identify a successfully imported Jira issue by the link icon
@@ -20,7 +20,7 @@
meant to store tasks for later use below the list for your todays tasks. You can move tasks via drag and drop between the two lists. Or use the globally
+ ui-sref="xxxxxxxxxxxxxxxxxxxxx">
configurable keyboard shortcuts.
diff --git a/app-src/scripts/dialogs/help/help-task-list.html b/app-src/scripts/dialogs/help/help-task-list.html
index e96d561309..6251c72496 100644
--- a/app-src/scripts/dialogs/help/help-task-list.html
+++ b/app-src/scripts/dialogs/help/help-task-list.html
@@ -9,7 +9,7 @@
There are also several other keyboard shortcuts available. Check them out in the
+ ui-sref="xxxxxxxxxxxxxxxxxxxxx">
settings section.
diff --git a/app-src/scripts/dialogs/welcome/welcome-c.html b/app-src/scripts/dialogs/welcome/welcome-c.html
index b8f6e5ee71..be1039cdd8 100644
--- a/app-src/scripts/dialogs/welcome/welcome-c.html
+++ b/app-src/scripts/dialogs/welcome/welcome-c.html
@@ -17,7 +17,7 @@
Happy to see you try out Super Productivity!
After familiarizing you with the basic functionality, you might want head over to
-
diff --git a/app-src/scripts/main-header/main-header-d.html b/app-src/scripts/main-header/main-header-d.html
index ce44159850..8e617478ad 100644
--- a/app-src/scripts/main-header/main-header-d.html
+++ b/app-src/scripts/main-header/main-header-d.html
@@ -86,7 +86,7 @@
+ ui-sref="xxxxxxxxxxxxxxxxxxxxx">
Go to settings
diff --git a/app-src/scripts/main/global-services/git-s.js b/app-src/scripts/main/global-services/git-s.js
index cf62794ca7..f53be93f83 100644
--- a/app-src/scripts/main/global-services/git-s.js
+++ b/app-src/scripts/main/global-services/git-s.js
@@ -17,7 +17,7 @@
function Git($http, $rootScope, $injector, $q, Notifier, SimpleToast) {
const TYPE = 'GITHUB';
const BASE_URL = 'https://api.github.com/';
- const settings = $rootScope.r && $rootScope.r.git;
+ const that = this;
// PRIVATE HELPER FUNCTIONS
// ------------------------
@@ -30,7 +30,7 @@
}
if (issue.pull_request) {
- title = `${settings.prPrefix} #${issue.number}: ${issue.title}`;
+ title = `${that.getSettings().prPrefix} #${issue.number}: ${issue.title}`;
} else {
title = `#${issue.number} ${issue.title}`;
}
@@ -117,27 +117,48 @@
return task && task.originalId && task.originalType === TYPE;
};
+ this.isRepoConfigured = () => {
+ const settings = this.getSettings();
+ return settings && settings.repo && settings.repo.trim() !== '';
+ };
+
+ this.getSettings = () => {
+ return $rootScope.r && $rootScope.r.git;
+ };
+
// API METHODS
// -----------
- this.getLatestSpRelease= () => {
+ this.getLatestSpRelease = () => {
const SP_REPO_STR = BASE_URL + 'repos/johannesjo/super-productivity/releases/latest';
return $http.get(SP_REPO_STR);
};
this.getIssueList = () => {
- return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues', {
+ if (!this.isRepoConfigured()) {
+ return $q.reject();
+ }
+
+ return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues', {
transformResponse: [transformIssueList]
});
};
this.getCommentListForIssue = (issueNumber) => {
- return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues/' + issueNumber + '/comments', {
+ if (!this.isRepoConfigured()) {
+ return $q.reject();
+ }
+
+ return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues/' + issueNumber + '/comments', {
transformResponse: [transformComments]
});
};
this.getIssueById = (issueNumber) => {
- return $http.get(BASE_URL + 'repos/' + settings.repo + '/issues/' + issueNumber, {
+ if (!this.isRepoConfigured()) {
+ return $q.reject();
+ }
+
+ return $http.get(BASE_URL + 'repos/' + this.getSettings().repo + '/issues/' + issueNumber, {
transformResponse: [transformIssue]
});
};
@@ -145,6 +166,10 @@
// COMPLEXER WRAPPER METHODS
// -------------------------
this.checkAndUpdateTasks = (tasks) => {
+ if (!this.isRepoConfigured()) {
+ return $q.reject();
+ }
+
const TasksUtil = $injector.get('TasksUtil');
const defer = $q.defer();
@@ -196,14 +221,10 @@
return defer.promise;
};
- this.isSufficientSettings = () => {
- return $rootScope.r.git && $rootScope.r.git.repo;
- };
-
this.checkForNewAndAddToBacklog = () => {
const Tasks = $injector.get('Tasks');
- if (this.isSufficientSettings() && $rootScope.r.git.isAutoImportToBacklog) {
+ if (this.isRepoConfigured() && $rootScope.r.git.isAutoImportToBacklog) {
this.getIssueList()
.then((res) => {
const issues = res.data;
diff --git a/app-src/scripts/routes.js b/app-src/scripts/routes.js
index 784a7260ac..3f34ceb00a 100644
--- a/app-src/scripts/routes.js
+++ b/app-src/scripts/routes.js
@@ -28,7 +28,7 @@
url: '/work-view',
template: ''
})
- .state('settings', {
+ .state('xxxxxxxxxxxxxxxxxxxxx', {
url: '/settings',
controller: 'SettingsCtrl',
controllerAs: 'vm',