diff --git a/README.md b/README.md
index d287046..858183e 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,8 @@
Chrome-extension for manage lambda inline code with github/github enterprise.
+#NOTE: Currently does not work with the new lambda UI
+
#Install
Install this extension from [chrome web store](https://chrome.google.com/webstore/detail/bmjcibkkmbmabejialhgnnmhpmdmijij).
diff --git a/content/alert.html b/content/alert.html
deleted file mode 100644
index 021a246..0000000
--- a/content/alert.html
+++ /dev/null
@@ -1,14 +0,0 @@
-
\ No newline at end of file
diff --git a/content/alert_error.html b/content/alert_error.html
new file mode 100644
index 0000000..da34143
--- /dev/null
+++ b/content/alert_error.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/content/alert_info.html b/content/alert_info.html
new file mode 100644
index 0000000..2b3bda5
--- /dev/null
+++ b/content/alert_info.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/content/alert_warning.html b/content/alert_warning.html
new file mode 100644
index 0000000..3045f5d
--- /dev/null
+++ b/content/alert_warning.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/content/buttons.html b/content/buttons.html
index 3817189..a03b9df 100644
--- a/content/buttons.html
+++ b/content/buttons.html
@@ -1,43 +1,93 @@
-
-
-
-
- Bind Repository
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
- Pull
+
+
+
+
+
+
+ Pull
+
-
-
-
- Push
+
+
+
+ Push
+
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/content/modal.html b/content/modal.html
new file mode 100644
index 0000000..c99ef16
--- /dev/null
+++ b/content/modal.html
@@ -0,0 +1,323 @@
+
+
+
+
+
+
+
+
+
+
+
Create a new repository
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Create a new branch
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Create a new file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/content/model.html b/content/model.html
deleted file mode 100644
index a8a501d..0000000
--- a/content/model.html
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
Create a new repository.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Create a new branch.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Create a new file.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lambda-hub.js b/lambda-hub.js
index 54c75c8..f083f1c 100644
--- a/lambda-hub.js
+++ b/lambda-hub.js
@@ -48,17 +48,17 @@ $(() => {
$(document).on('input propertychange', `#new-${type}-name`, (event) => {
changeButtonState(type, event.target.value);
});
- $(document).on('click', `.github-${type}-model-dismiss`, (event) => {
- changeModelState(type, false);
+ $(document).on('click', `.github-${type}-modal-dismiss`, (event) => {
+ changeModalState(type, false);
});
$(document).on('click', `#github-create-${type}`, (event) => {
- changeModelState(type, false);
+ changeModalState(type, false);
CREATE_FUNC[type]();
});
})
- $(document).on('click', '.github-diff-model-dismiss', () => {
- changeModelState('diff', false);
+ $(document).on('click', '.github-diff-modal-dismiss', () => {
+ changeModalState('diff', false);
})
$(document).on('click', '.github-alert-dismiss', () => {
@@ -82,7 +82,7 @@ $(() => {
$(document).on('click', '.github-repo', (event) => {
if (context.repo && event.target.text === context.repo.name) return;
//update context.repo with name and fullName
- const name = event.target.text;
+ const name = event.target.textContent;
const fullName = event.target.attributes.data.value;
const repo = {
name: name,
@@ -97,31 +97,31 @@ $(() => {
delete context.bindFile[context.functionName];
}
chrome.storage.sync.set({ bindRepo: context.bindRepo }, () => {
- $('#github-bind-repo').text(`Repo: ${name}`);
+ $('#github-bind-repo-text').text(`Repo: ${name}`);
$('.github-repo-dropdown').hide();
updateBranch()
.then(updateFile);
});
});
$(document).on('click', '.github-branch', (event) => {
- if (context.branch && event.target.text === context.branch) return;
+ if (context.branch && event.target.textContent === context.branch) return;
//update context.branch and save to storage
- const branch = event.target.text;
+ const branch = event.target.textContent;
context.branch = branch;
Object.assign(context.bindBranch, { [context.functionName] : branch });
chrome.storage.sync.set({ bindBranch: context.bindBranch }, () => {
- $('#github-bind-branch').text(`Branch: ${branch}`);
+ $('#github-bind-branch-text').text(`Branch: ${branch}`);
$('.github-branch-dropdown').hide();
});
});
$(document).on('click', '.github-file', (event) => {
- if (context.file && event.target.text === context.file) return;
+ if (context.file && event.target.textContent === context.file) return;
//update context.file and save to storage
- const file = event.target.text;
+ const file = event.target.textContent;
context.file = file;
Object.assign(context.bindFile, { [context.functionName] : file });
chrome.storage.sync.set({ bindFile: context.bindFile }, () => {
- $('#github-bind-file').text(`File: ${file}`);
+ $('#github-bind-file-text').text(`File: ${file}`);
$('.github-file-dropdown').hide();
});
});
@@ -166,7 +166,7 @@ function showDiff(type, handler) {
showAlert("There is nothing to pull", LEVEL_WARN);
return;
}
- //setting the diff model
+ //setting the diff modal
const oldCode = type === "Push" ? code.github : code.lambda;
const newCode = type === "Push" ? code.lambda : code.github;
const diff = JsDiff.createPatch(context.file, oldCode, newCode);
@@ -198,10 +198,10 @@ function showDiff(type, handler) {
}
}
$('#github-diff-handler').text(type).off().click(() => {
- changeModelState('diff', false);
+ changeModalState('diff', false);
handler(code);
});
- changeModelState('diff', true);
+ changeModalState('diff', true);
})
.catch((err) => {
if (!context.repo || !context.branch) {
@@ -222,7 +222,7 @@ function githubPush(data) {
encoding: "utf-8"
};
Promise.all([
- $.ajax({
+ $.ajax({
url: `${baseUrl}/repos/${context.repo.fullName}/git/blobs`,
headers: {
"Authorization": `token ${accessToken}`
@@ -422,7 +422,7 @@ function githubCreateBranch() {
function githubCreateFile() {
const file = $('#new-file-name').val();
if (!file || file === "") return;
- $('#github-bind-file').text(`File: ${file}`);
+ $('#github-bind-file-text').text(`File: ${file}`);
//update context and storage
context.file = file;
Object.assign(context.file, { [context.functionName] : file });
@@ -433,7 +433,7 @@ function githubCreateFile() {
function showCreateContent(type) {
$(`.github-${type}-dropdown`).hide();
- changeModelState(type, true);
+ changeModalState(type, true);
}
function initContext() {
@@ -528,45 +528,43 @@ function getGithubRepos() {
}
function initPageContent() {
- const div = $('.awsmob-button-group');
+ const div = $('.awsui-util-f-r.awsui-util-mt-xs');
if($('.github').length !== 0 || div.length === 0 || div.children().length <= 2) {
throw new Error("nothing to do");
}
- $.get(chrome.runtime.getURL('content/model.html'))
+ $.get(chrome.runtime.getURL('content/modal.html'))
.then((content) => {
$('#main').siblings().last().after(content);
});
return $.get(chrome.runtime.getURL('content/buttons.html'))
.then((content) => {
- return div.children().last().after(content);
+ return div.css('clear', 'right').before(content);
});
}
function initLoginContent() {
- const div = $('.awsmob-button-group');
+ const div = $('.awsui-util-f-r.awsui-util-mt-xs');
if($('.github').length !== 0 || div.length === 0 || div.children().length <= 2) {
return;
}
const htmlContent = '\
- \
\
- Login to Github\
+ Login to Github\
\
- \
- ';
+ ';
div.children().last().after(htmlContent);
}
function updateRepo(repos) {
- $('#github-repos').empty().append('Create new repo ');
+ $('#github-repos').empty().append('Create new repo ');
repos.forEach((repo) => {
- let liContent = `${repo.name} `
+ let liContent = `${repo.name} `
$('#github-repos').append(liContent);
});
if (context.repo) {
- $('#github-bind-repo').text(`Repo: ${context.repo.name}`);
+ $('#github-bind-repo-text').text(`Repo: ${context.repo.name}`);
return context.repo.name;
}
return null;
@@ -578,9 +576,9 @@ function updateBranch() {
}
return getAllItems(Promise.resolve({items: [], url: `${baseUrl}/repos/${context.repo.fullName}/branches?access_token=${accessToken}`}))
.then((branches) => {
- $('#github-branches').empty().append('Create new branch ');
+ $('#github-branches').empty().append('Create new branch ');
branches.forEach((branch) => {
- let liContent = `${branch.name} `
+ let liContent = `${branch.name} `
$('#github-branches').append(liContent);
});
let branch = context.bindBranch[context.functionName];
@@ -590,7 +588,7 @@ function updateBranch() {
} else if ($.inArray(branch, branches.map(branch => branch.name)) < 0) {
branch = ($.inArray("master", branches.map(branch => branch.name)) >= 0) ? "master" : branches[0].name;
}
- $('#github-bind-branch').text(`Branch: ${branch}`);
+ $('#github-bind-branch-text').text(`Branch: ${branch}`);
//update context and storage
context.branch = branch;
Object.assign(context.bindBranch, { [context.functionName] : branch });
@@ -614,17 +612,17 @@ function updateFile() {
);
})
.then((trees) => {
- $('#github-files').empty().append('Create new file ');
+ $('#github-files').empty().append('Create new file ');
trees.tree.forEach((file) => {
if (file.type !== 'blob') return;
- let liContent = `${file.path} `
+ let liContent = `${file.path} `
$('#github-files').append(liContent);
});
let file = context.bindFile[context.functionName];
if (!file || $.inArray(file, trees.tree.map(tree => tree.path)) < 0) {
file = context.current.runtime.indexOf("nodejs") >= 0 ? "index.js" : "index.py";
}
- $('#github-bind-file').text(`File: ${file}`);
+ $('#github-bind-file-text').text(`File: ${file}`);
//update context and storage
context.file = file;
Object.assign(context.file, { [context.functionName] : file });
@@ -633,17 +631,11 @@ function updateFile() {
})
}
-function changeModelState(type, toShow) {
+function changeModalState(type, toShow) {
const index = toShow ? 0 : -1;
- const fromClass = toShow ? 'hidden' : 'fadeIn';
- const trasnferClass = toShow ? 'fadeIn' : 'fadeOut';
- const toClass = toShow ? 'showing' : 'hidden';
- $(`.github-${type}-model`).removeClass(`awsui-modal-__state-${fromClass}`).addClass(`awsui-modal-__state-${trasnferClass}`);
- setTimeout(() => {
- $(`.github-${type}-model`).removeClass(`awsui-modal-__state-${trasnferClass}`).addClass(`awsui-modal-__state-${toClass}`);
- },
- 1000
- );
+ const fromClass = toShow ? 'hidden' : 'show';
+ const toClass = toShow ? 'show' : 'hidden';
+ $(`.github-${type}-modal`).removeClass(`awsui-modal-${fromClass}`).addClass(`awsui-modal-${toClass}`);
$(`.github-${type}-modal-dialog`).attr('tabindex', index);
}
@@ -658,9 +650,9 @@ function changeButtonState(type, value) {
//show alert using aws ui
//level: info, warning, error
function showAlert(message, level=LEVEL_INFO) {
- $.get(chrome.runtime.getURL('content/alert.html'))
+ $.get(chrome.runtime.getURL(`content/alert_${level}.html`))
.then((content) => {
- $('.content').before(content.replace(/_INFO_/g, level).replace(/_MESSAGE_/, message));
+ $('.content').before(content.replace(/_MESSAGE_/, message));
});
}
diff --git a/manifest.json b/manifest.json
index 56f6b57..07fce9e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.1",
+ "version": "1.1.2",
"manifest_version": 2,
"default_locale": "en",
"name": "__MSG_appName__",
@@ -42,8 +42,10 @@
"lambda-hub.js",
"options/options.html",
"content/buttons.html",
- "content/model.html",
- "content/alert.html"
+ "content/modal.html",
+ "content/alert_info.html",
+ "content/alert_warning.html",
+ "content/alert_error.html"
],
"permissions": [
"https://*/",