Skip to content

Commit b6d7c6f

Browse files
authored
Merge pull request #133 from leonhartX/icon
log improve
2 parents d027ae1 + 8ec17ea commit b6d7c6f

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

content/alert.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="qGW0q" jsname="x0irnb">
55
<div>
66
<div class="gwHZe" aria-label="Logs" jsname="ikTLpc" tabindex="0" role="list">
7-
<div tabindex="0" role="listitem" class="fHhrY ptNZqd" jsname="HYltEe">
7+
<div tabindex="0" role="listitem" class="fHhrY _COLOR_CLASS_" jsname="HYltEe">
88
<div class="Akkarb lNXgjb" id="alerttime">_TIMESTAMP_</div>
99
<div class="ACpDpe lNXgjb" id="alertLevel">_LEVEL_</div>
1010
<div class="BjuRcd lNXgjb">[github assistant] _MESSAGE_</div>

content/modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ <h2 class="VfPpkd-k2Wrsb">Config sync options</h2>
130130
placeholder="Ignore patterns"></label>
131131
<div class="VfPpkd-fmcmS-yrriRe-W0vJo-RWgCYc">
132132
<p class="VfPpkd-fmcmS-yrriRe-W0vJo-fmcmS VfPpkd-fmcmS-yrriRe-W0vJo-fmcmS-OWXEXe-zvnfze">Use regex
133-
separated by ';'/p>
133+
separated by ';'</p>
134134
</div>
135135
</div>
136136
</div>

icon/icon.png

-1.12 KB
Loading

manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "5.0.0",
2+
"version": "5.0.1",
33
"manifest_version": 2,
44
"default_locale": "en",
55
"name": "__MSG_appName__",
@@ -54,7 +54,6 @@
5454
],
5555
"permissions": [
5656
"https://script.google.com/*",
57-
"https://www.googleapis.com/oauth2/v4/token",
5857
"https://gitlab.com/*",
5958
"identity",
6059
"storage",

src/gas-hub.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ let currentUrl;
55
let gas;
66
let scm;
77
let context = {};
8-
const LEVEL_ERROR = 'Warning';
9-
const LEVEL_WARN = 'Info';
8+
const LEVEL_ERROR = 'Error';
9+
const LEVEL_WARN = 'Warn';
1010
const LEVEL_INFO = 'Notice';
1111
const observer = new MutationObserver((e) => {
1212
let url = window.location.href;
@@ -57,10 +57,6 @@ function load() {
5757
break;
5858
case 'nothing':
5959
break;
60-
case 'need relogin':
61-
initLoginContent();
62-
showLog('Extension has been updated, please relogin', LEVEL_WARN);
63-
break;
6460
default:
6561
showLog(err, LEVEL_ERROR);
6662
break;
@@ -351,14 +347,19 @@ function auth() {
351347
context.gapiToken = token;
352348
chrome.storage.sync.set({
353349
"gapiToken": token
354-
});
350+
});
355351
resolve(token);
356352
}
357353
});
358354
});
359355
}
360356

361357
function prepareCode() {
358+
if (!getRepo()) {
359+
return new Promise((resolve, reject) => {
360+
reject(new Error("Repository is not set"));
361+
})
362+
}
362363
return Promise.all([gas.getGasCode(), scm.getCode()])
363364
.then((data) => {
364365
return {
@@ -370,7 +371,7 @@ function prepareCode() {
370371

371372
function showDiff(code, type) {
372373
if (Object.keys(code.scm).length === 0 && type === 'pull') {
373-
showLog('There is nothing to pull', LEVEL_WARN);
374+
showLog('There is nothing to pull', LEVEL_INFO);
374375
return;
375376
}
376377
//setting the diff model
@@ -417,7 +418,7 @@ function showDiff(code, type) {
417418
}, '');
418419

419420
if (diff === '') {
420-
showLog('Everything already up-to-date', LEVEL_WARN);
421+
showLog('Everything already up-to-date', LEVEL_INFO);
421422
return;
422423
}
423424

@@ -529,7 +530,7 @@ function updateBranch() {
529530
if (branches.length === 0) {
530531
branch = '';
531532
if (scm.name === 'github') {
532-
showLog('This repository is empty, try to create a new branch such as [master] in Github', LEVEL_WARN);
533+
showLog('This repository is empty, try to create a new branch such as [main] in Github', LEVEL_WARN);
533534
} else {
534535
showLog('This repository is empty, first create a new branch', LEVEL_WARN);
535536
}
@@ -621,9 +622,16 @@ function showLog(message, level = LEVEL_INFO) {
621622

622623
$.get(chrome.runtime.getURL('content/alert.html'))
623624
.then((content) => {
625+
const colorClass = level == LEVEL_ERROR ? "nN3Fac" : "ptNZqd";
624626
$("[jsname=cFQkCb]").removeClass("LcqFFc");
625-
$("[jsname=cFQkCb] > [jsname=NR4lfb]").css("flex-basis", "150px")
626-
$('.Vod31b').html(content.replace(/_TIMESTAMP_/g, new Date().toLocaleTimeString()).replace(/_LEVEL_/g, level).replace(/_MESSAGE_/, message));
627+
const currentOffset = $("[jsname=cFQkCb] > [jsname=NR4lfb]").css("flex-basis");
628+
const offset = (currentOffset === "0px" || currentOffset === "auto") ? "150px" : currentOffset;
629+
$("[jsname=cFQkCb] > [jsname=NR4lfb]").css("flex-basis", offset);
630+
$('.Vod31b').html(content
631+
.replace(/_COLOR_CLASS_/, colorClass)
632+
.replace(/_TIMESTAMP_/g, new Date().toLocaleTimeString())
633+
.replace(/_LEVEL_/g, level)
634+
.replace(/_MESSAGE_/, message));
627635
})
628636
}
629637

src/scm/github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Github {
4848
})
4949
});
5050
if (changed.length === 0) {
51-
showLog('Nothing to do', LEVEL_WARN);
51+
showLog('Nothing to do', LEVEL_INFO);
5252
return;
5353
}
5454

@@ -151,7 +151,7 @@ class Github {
151151
pushToGist(code) {
152152
const files = $('.diff-file:checked').toArray().map((elem) => elem.value);
153153
if (files.length === 0) {
154-
showLog('Nothing to do', LEVEL_WARN);
154+
showLog('Nothing to do', LEVEL_INFO);
155155
return;
156156
}
157157
const payload = {

0 commit comments

Comments
 (0)