Skip to content

Commit

Permalink
Merge pull request #30 from marekkalnik/hide-incompatible-files
Browse files Browse the repository at this point in the history
Hide incompatible files
  • Loading branch information
leonhartX authored Aug 30, 2017
2 parents 2caab8e + 329d669 commit 4bdf403
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
3 changes: 2 additions & 1 deletion content/modal.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div id="diffModal" class="modal-dialog" tabindex="0" role="dialog" style="left: 274px; top: 180px; display: none;">
<div class="modal-dialog-title modal-dialog-title-draggable">
<span class="modal-dialog-title-text">Diff</span>
<span class="modal-dialog-title-text">(warning, only .gs and .html files will be synced)</span>
<span class="github-diff-modal-close modal-dialog-title-close"></span>
</div>
<div class="modal-dialog-content">
Expand Down Expand Up @@ -133,4 +134,4 @@
<button id="github-create-branch" type="button" class="goog-buttonset-default goog-buttonset-action" disabled="true">Create</button>
<button type="button" class="github-branch-modal-close">Cancel</button>
</div>
</div>
</div>
9 changes: 5 additions & 4 deletions src/gas-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function pull(code) {
}
const name = match[1];
const type = match[2];

if (!code.gas[file]) {
return () => gasCreateFile(name, type)
.then(() => {
Expand All @@ -20,7 +20,8 @@ function pull(code) {
} else {
return () => gasUpdateFile(name, code.github[file]);
}
});
})
.filter(n => n != undefined);

const delete_promises = changed.filter(f => !code.github[f])
.map((file) => {
Expand All @@ -37,7 +38,7 @@ function pull(code) {
showAlert("Nothing to do", LEVEL_WARN);
return;
}

getGasContext()
.then(() => {
return Promise.all(update_promises.map(f => f()))
Expand Down Expand Up @@ -206,4 +207,4 @@ function gasDeleteFile(file) {
reject(new Error('Update file failed'));
});
});
}
}
22 changes: 13 additions & 9 deletions src/gas-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const LEVEL_WARN = "info";
const LEVEL_INFO = "promo";
const observer = new MutationObserver((e) => {
observer.disconnect();
$('.github-alert').remove();
$('.github-alert').remove();
});

$(() => {
Expand Down Expand Up @@ -80,14 +80,14 @@ function initLoginContent() {
$('#login').hover(() => {
$('#login').addClass('goog-toolbar-menu-button-hover');
}, () => {
$('#login').removeClass('goog-toolbar-menu-button-hover');
$('#login').removeClass('goog-toolbar-menu-button-hover');
});
$('#login').click(() => {
if (chrome.runtime.openOptionsPage) {
chrome.runtime.openOptionsPage();
} else {
window.open(chrome.runtime.getURL('options/options.html'));
}
}
});
chrome.runtime.sendMessage({ cmd: "tab" });
});
Expand All @@ -99,7 +99,7 @@ function initPageEvent() {
['repo', 'branch'].forEach((type) => {
const container = $(`.${type}-menu`);
const button = $(`#${type}Select`);
if (!container.is(event.target)
if (!container.is(event.target)
&& !button.is(event.target)
&& container.has(event.target).length === 0
&& button.has(event.target).length == 0) {
Expand Down Expand Up @@ -203,8 +203,8 @@ function initPageEvent() {
break;
default:
return;
}
context[type] = content;
}
context[type] = content;
const bindName = `bind${type.capitalize()}`;
Object.assign(context[bindName], { [context.id] : content });
chrome.storage.sync.set({ [bindName]: context[bindName] }, () => {
Expand Down Expand Up @@ -265,6 +265,10 @@ function showDiff(code, type) {
return gasFiles.indexOf(e) < 0;
})
.concat(gasFiles)
.filter((file) => {
const match = file.match(/(.*?)\.(gs|html)$/);
return match && match[1] && match[2];
})
.reduce((diff, file) => {
let mode = null;
if (!oldCode[file]) {
Expand All @@ -279,7 +283,7 @@ function showDiff(code, type) {
if (mode) {
diffArr.splice(1, 0, mode);
}
fileDiff = diffArr.join('\n');
fileDiff = diffArr.join('\n');
return diff + fileDiff;
}, "");

Expand Down Expand Up @@ -331,7 +335,7 @@ function showDiff(code, type) {
function updateRepo(repos) {
$('.repo-menu').empty().append('<div class="github-new-repo github-item goog-menuitem"><div class="goog-menuitem-content">Create new repo</div></div>');
$('.repo-menu').append('<div class="github-use-gist github-item goog-menuitem"><div class="goog-menuitem-content" github-content="repo" data="gist">Using Gist</div></div>');

repos.forEach((repo) => {
let content = `<div class="github-item goog-menuitem"><div class="goog-menuitem-content" github-content="repo" data="${repo.fullName}">${repo.name}</div></div>`
$('.repo-menu').append(content);
Expand Down Expand Up @@ -442,4 +446,4 @@ function showAlert(message, level=LEVEL_INFO) {

String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
}

0 comments on commit 4bdf403

Please sign in to comment.