Skip to content

Commit

Permalink
Merge pull request #1 from Hobart2967/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
Marco Klein authored Aug 13, 2021
2 parents f2d9235 + e53b9a7 commit e159c42
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

trigger:
- main
- devel

variables:
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
Expand Down Expand Up @@ -32,5 +33,4 @@ steps:
yarn
displayName: 'Install NPM Packages'
- script: |
GH_TOKEN=$(GH_TOKEN) yarn dist -m -w -l
GH_TOKEN=$(GH_TOKEN) yarn compile
File renamed without changes.
23 changes: 0 additions & 23 deletions .circleci/config.yml

This file was deleted.

Binary file added build/icon.icns
Binary file not shown.
Binary file added build/icon.ico
Binary file not shown.
Binary file added build/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
},
"electronWebpack": {
"renderer": {
"template": "src/renderer/index.html"
"template": "src/renderer/index.html",
"webpackConfig": "webpack.renderer.additions.js"
}
},
"dependencies": {
"source-map-support": "0.5.19"
},
"devDependencies": {
"copy-webpack-plugin": "^9.0.1",
"copy-webpack-plugin": "6.3.2",
"electron": "^13.1.8",
"electron-builder": "^22.10.5",
"electron-webpack": "^2.8.2",
Expand Down
8 changes: 7 additions & 1 deletion src/main/services/identity-provider-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ export class IdentityProviderSession {

return await this._extractCookies(loginWindow.browserWindow);
}

public applyLastCookieSet(cookies: Cookie[]) {
this._cookies.splice(0, this._cookies.length);

this._cookies.push(...cookies);
}
//#endregion

//#region Private Methods
async _extractCookies(window: BrowserWindow) {
private async _extractCookies(window: BrowserWindow) {
const cookies = await window.webContents.session.cookies.get({});
const idpCookies = cookies.filter(x => this._idpChecks.some(regex => regex.test(x.domain || '')));
this._cookies.push(...idpCookies);
Expand Down
8 changes: 8 additions & 0 deletions src/main/window/start-page.window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class StartPageWindow extends BaseWindow {
}

this.browserWindow.webContents.send('login-succeeded', true);
this.browserWindow.webContents.send('saveCookies', this._identityProviderSession.cookies);
}

@ipcMainTarget()
Expand All @@ -64,6 +65,13 @@ export class StartPageWindow extends BaseWindow {
this._awsConsoleConfiguration.favoriteServices = favoriteServices;
}

@ipcMainTarget()
public async applyPersistedCookies(cookies: Cookie[]): Promise<void> {
console.log(`Applied ${cookies.length} cookies from last session`);
this._identityProviderSession.applyLastCookieSet(cookies);
this.browserWindow.webContents.send('login-succeeded', true);
}

@ipcMainTarget()
public async chooseFavoriteServices(baseUrl: string): Promise<void> {
const awsEnvironmentWindow = new AwsEnvironmentWindow(
Expand Down
Binary file added src/renderer/assets/pro-tip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions src/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
box-shadow: 0 0 0 1px #00a1c9;
}

.pro-tip {
max-width: 50%;
margin: 0 auto;
}

body {
background: whitesmoke;
Expand Down Expand Up @@ -74,6 +78,18 @@
border-color: transparent;
}

pre {
display: inline-block;
margin: 0;
line-height: 1;
vertical-align: middle;
border: 1px #ccc solid;
padding: 5px;
border-radius: 3px;
margin: 0 5px;
color: #fb8d59;
}

.btn {
transition: none;
border-radius: 2px;
Expand Down Expand Up @@ -180,6 +196,25 @@ <h5 class="card-title">Favorite Services!</h5>
</div>

</div>
<div class="d-flex multi-card">
<div class="col">
<div class="card mb-3">
<div class="card-body">
<h5 class="card-title">Pro Tip!</h5>
<div class="card-text">
<div>
<div class="mb-2">You are using a Mac System? You can enable tabbed windows and set them as default, to have <b>all environments attached to this window as tabs.</b></div>
<div class="mb-2">Just visit <pre>Mac OS System Preferences</pre> > <pre>General</pre></div>
<div class="mb-2">And set <pre>Prefer Tabs</pre> to <pre>Always</pre></div>
<div class="mt-3">
<img src="/assets/pro-tip.png" class="pro-tip d-block">
</div>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
18 changes: 18 additions & 0 deletions src/renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const { ipcRenderer } = require('electron');
ipcRenderer.send('openAwsEnvironment', baseUrl)
}

function applyPersistedCookies(cookies) {
ipcRenderer.send('applyPersistedCookies', cookies)
}

function chooseFavoriteServices(baseUrl) {
ipcRenderer.send('chooseFavoriteServices', baseUrl)
}
Expand Down Expand Up @@ -60,8 +64,18 @@ const { ipcRenderer } = require('electron');
favoritesList = favoritesList || [];
}

function loadPersistedCookies() {
const persistedCookies = localStorage.getItem('loginCookies');
if (!persistedCookies) {
return;
}

applyPersistedCookies(JSON.parse(persistedCookies));
}

function main() {
loadPersistedFavoritesList(updateFavoritesList);
loadPersistedCookies();

const baseUrl = document.getElementById('awsSsoBaseUrl');
baseUrl.value = localStorage.getItem('awsSsoBaseUrl');
Expand Down Expand Up @@ -96,6 +110,10 @@ const { ipcRenderer } = require('electron');
alert.remove();
});


ipcRenderer.on('saveCookies', (event, cookies) => {
localStorage.setItem('loginCookies', JSON.stringify(cookies.map(x => ({ ...x }))));
})
}

main();
Expand Down
13 changes: 8 additions & 5 deletions webpack.config.js → webpack.renderer.additions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
target: "electron-main",
entry: {
main: "./src/main/index.js"
module: {
rules: [{
test: /\.png$/,
use: 'raw-loader'
}],

},
plugins: [
new CopyPlugin({
patterns: [
{ from: "./src/main/index.html", to: "./index.html" },
{ from: "./src/renderer/assets", to: "./assets/" },
],
})
]
};
}
Loading

0 comments on commit e159c42

Please sign in to comment.