Skip to content

Commit 183fbfb

Browse files
committed
Fix save dialog
1 parent 1998548 commit 183fbfb

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

README.md

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
<h1 align="center"> Kube Forwarder</h1>
1414
<h3 align="center">Easy to use Kubernetes port forwarding manager</h3>
1515
<h4 align="center">
16-
<a href="https://kube-forwarder.pixelpoint.io">Visit a Website</a> ·
17-
<a href="https://github.com/pixel-point/kube-forwarder/releases/latest/download/kube-forwarder.dmg">Download for macOS</a> ·
18-
<a href="https://github.com/pixel-point/kube-forwarder/releases/latest/download/kube-forwarder.exe">Download for Windows</a> ·
16+
<a href="https://kube-forwarder.pixelpoint.io">Visit a Website</a> ·
17+
<a href="https://github.com/pixel-point/kube-forwarder/releases/latest/download/kube-forwarder.dmg">Download for macOS</a> ·
18+
<a href="https://github.com/pixel-point/kube-forwarder/releases/latest/download/kube-forwarder.exe">Download for Windows</a> ·
1919
<a href="https://github.com/pixel-point/kube-forwarder/releases/latest/download/kube-forwarder.AppImage">Download for Linux</a>
2020
·
2121
<a href="#install-with-homebrew">Install with Homebrew</a>
2222
</h4>
2323

2424

25-
![Clusters Page](https://user-images.githubusercontent.com/2697570/60103100-524d5d80-975f-11e9-84ab-bcc962be0bb7.png)
25+
![Clusters Page](https://user-images.githubusercontent.com/2697570/60103100-524d5d80-975f-11e9-84ab-bcc962be0bb7.png)
2626

2727
## Features
2828

@@ -51,46 +51,46 @@ Use port-forwarding without installing kubectl and avoid explanations to develop
5151

5252
### Add a cluster(s)
5353

54-
Before you start forwarding internal resources to your local machine, you have to add cluster configuration.
54+
Before you start forwarding internal resources to your local machine, you have to add cluster configuration.
5555
To do this we have 3 different options in the app:
5656

5757
1) Auto-detection of ~/.kube/config file and parsing settings from it
5858
1) Manual adding of Kubernetes config by selecting a file(s)
5959
1) Manual adding of Kubernetes config by pasting a text
6060
1) Import of the JSON file that could be generated via Kube Forwarder export functionality
6161

62-
When you add a new cluster via auto-detection (option 1) or manually using a file(a) selection (option 2), we could parse
63-
configs and if there are multiple contexts inside we will suggest you to add multiple clusters to the app.
62+
When you add a new cluster via auto-detection (option 1) or manually using a file(a) selection (option 2), we could parse
63+
configs and if there are multiple contexts inside we will suggest you to add multiple clusters to the app.
6464
Few examples of yaml files we expect to have you could find [there](https://github.com/pixel-point/kube-forwarder/issues/7)
6565

6666
Also, you could add a cluster by filling a form manually (option 3). The form has the following fields:
6767
* Name - the name of a cluster withing Kube Forwarder app.
6868
* Storing method (Set destination to your kube config or paste it as a text) - the method of storing a config It has two options:
6969
* `Set a path` - storing a path to the config file. It will be read every time when you forwarding a port. It allows
70-
a user to don't do any changes in Kube Forwarder's settings when a third-party app updates the config file.
70+
a user to don't do any changes in Kube Forwarder's settings when a third-party app updates the config file.
7171
For example, when `azure-cli` updates an access token (#13).
7272
* `Paste as a text` - storing a config just as a yml text.
7373
* Path (if storing method is `Set a path`) - the path to a config file.
7474
* Content (if storing method is `Paste as a text`) - Yml config as a text.
7575
* Current Context (if storing method is `Set a path`) - When you use `Set a path`, you must select a context from a file
7676
which will be used to connect to a resource. Let's see an example of a problem that the field solves.
7777
1) Let's say we don't have `Current context` field.
78-
1) A user has a config file with two contexts: `local-cluster` and `remote-cluster`.
78+
1) A user has a config file with two contexts: `local-cluster` and `remote-cluster`.
7979
`current-context` in the yml file is `local-cluster`.
8080
1) The user configured a cluster in Kube Forwarder with `Set a path` option.
8181
1) The user created a resource `postgres` and successfully forwarded ports for some time.
8282
1) Then the user executed `kubectl config use-context remote-cluster`
8383
1) If the user tries to forward the resource in Kube Forwarder again, most likely there will be an error
8484
since a connection will be established with `remote-cluster`, not `local-cluster` as the user expected,
8585
and `remote-cluster` couldn't have `postgres` resource.
86-
87-
So, to avoid the error we should store the current context in a separate field.
86+
87+
So, to avoid the error we should store the current context in a separate field.
8888

8989
<a target="_blank" href="https://user-images.githubusercontent.com/2697570/60754775-58a4ca80-9fe6-11e9-8d67-d15a1423b506.png"><img width="320" alt="Screenshot 2019-07-06 at 12 04 45" src="https://user-images.githubusercontent.com/2697570/60754775-58a4ca80-9fe6-11e9-8d67-d15a1423b506.png"></a>
9090

9191
### Add a resource
9292

93-
Kube Forwarder supports forwarding of all types of resources that supported by `kubectl` – Pod, Deployment, Service.
93+
Kube Forwarder supports forwarding of all types of resources that supported by `kubectl` – Pod, Deployment, Service.
9494

9595
We ask you to fill the form with the following fields:
9696

@@ -104,21 +104,21 @@ We ask you to fill the form with the following fields:
104104

105105
**Alias** - alternative name of the resource that will be displayed on the homepage(optional)
106106

107-
**Port Forwarding**
108-
107+
**Port Forwarding**
108+
109109
- **Local port** - port from your local machine where the resource will be forwarded. Note that ports <= 1024 are
110110
restricted to user `root`
111-
- **Resource port** - port of the resource from the Kubernetes cluster
111+
- **Resource port** - port of the resource from the Kubernetes cluster
112112

113113
**Use Custom Local Address** - Check this and put an IP address or hostname into the text field to
114-
use a different listen address. Putting each service on its own address avoids sharing/collisions between
115-
services on cookies and port number. Specify a loopback address like `127.0.x.x` or add entries to your
114+
use a different listen address. Putting each service on its own address avoids sharing/collisions between
115+
services on cookies and port number. Specify a loopback address like `127.0.x.x` or add entries to your
116116
hosts file like `127.0.1.1 dashboard.production.kbf` and put the assigned name in this column. If blank or
117117
unchecked, `localhost` / `127.0.0.1` will be used.
118118

119119
<a target="_blank" href="https://user-images.githubusercontent.com/2697570/60754738-e207cd00-9fe5-11e9-95b3-8f4704ca3dce.png"><img width="320" alt="Port Forwarding Form" src="https://user-images.githubusercontent.com/2697570/60754738-e207cd00-9fe5-11e9-95b3-8f4704ca3dce.png"></a>
120120

121-
### Import/Export
121+
### Import/Export
122122

123123
Kube Forwarder allows you export cluster configuration in JSON that you could use to share with your team members or for the backup purpose. You could easily store it on Github. When you export cluster, you could export it with or without confidential information.
124124

@@ -134,8 +134,8 @@ brew cask install kube-forwarder
134134

135135
We encourage you to contribute to Kube Forwarder!
136136

137-
We expect contributors to abide by our underlying [code of conduct](./.github/CODE_OF_CONDUCT.md).
138-
All conversations and discussions on GitHub (issues, pull requests)
137+
We expect contributors to abide by our underlying [code of conduct](./.github/CODE_OF_CONDUCT.md).
138+
All conversations and discussions on GitHub (issues, pull requests)
139139
must be respectful and harassment-free.
140140

141141
This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[8fae476](https://github.com/SimulatedGREG/electron-vue/tree/8fae4763e9d225d3691b627e83b9e09b56f6c935) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html).
@@ -200,7 +200,7 @@ npm run build:dist
200200
npm run build:target -- --win
201201
```
202202

203-
A built version will be appear in `build` directory.
203+
A built version will be appear in `build` directory.
204204

205205
## Running the tests
206206

@@ -224,6 +224,14 @@ npm run test:cypress:onhost
224224
npm run test:cypress:open
225225
```
226226

227+
## Troubleshooting
228+
229+
Q) Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 12.x
230+
A) `npm rebuild node-sass`
231+
232+
Q) Error: spawn .../kube-forwarder/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron ENOENT
233+
A) Reinstall node_modules: `rm -rf node_modules && npm i`
234+
227235
## Release guide
228236

229237
### Configure environment
@@ -236,18 +244,18 @@ Also, this steps could be used to configure CI environment.
236244

237245
1) Update the version in `package.json` and Push to `release` branch.
238246
1) Run `npm run release` on a Mac computer to build packages. They will be automatically pushed to releases at Github.
239-
1) Go to [Releases](https://github.com/pixel-point/kube-forwarder/releases) in the repository.
247+
1) Go to [Releases](https://github.com/pixel-point/kube-forwarder/releases) in the repository.
240248
Make sure that the created draft is OK and release it (Edit -> Release).
241249
1) Run `cask-repair kube-forwarder` to update the cask version.
242-
([https://github.com/Homebrew/homebrew-cask/blob/master/CONTRIBUTING.md#updating-a-cask](About cask-repair))
250+
([https://github.com/Homebrew/homebrew-cask/blob/master/CONTRIBUTING.md#updating-a-cask](About cask-repair))
243251

244-
Notes:
252+
Notes:
245253
1) A release tag (for example: `v1.0.3`) will be added to GIT automatically by Github when you release your draft.
246254

247255
## Development tips
248256

249257
Use `tiffutil -cathidpicheck bg.png [email protected] -out bg.tiff` to build a tiff
250-
background for .DMG
258+
background for .DMG
251259

252260
## Supported by
253261
<table>
@@ -258,7 +266,7 @@ background for .DMG
258266
<td valign="middle"><a href="https://sentry.io/"><img width="200px" src="https://user-images.githubusercontent.com/2697570/60827162-dd8f1000-a1af-11e9-9536-0bba6c71778c.png"/></a></td>
259267
</tbody>
260268
</table>
261-
269+
262270

263271
## License
264272

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"cypress-image-snapshot": "^3.1.0",
125125
"del": "^3.0.0",
126126
"devtron": "^1.4.0",
127-
"electron": "9.4.0",
127+
"electron": "12.0.2",
128128
"electron-builder": "20.41.0",
129129
"electron-debug": "^3.0.0",
130130
"electron-devtools-installer": "^2.2.4",

src/renderer/lib/helpers/ui.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
const { dialog, app } = require('electron').remote
22

33
// @param options.details
4-
export function showMessageBox(message, options = {}) {
4+
export async function showMessageBox(message, options = {}) {
55
const { details } = options
66
const detailsLabel = 'Details'
77
const buttons = options.buttons ? options.buttons.slice(0) : ['OK']
88
if (details) buttons.push(detailsLabel)
99

10-
return new Promise((resolve) => {
11-
dialog.showMessageBox({ title: 'Message', message, buttons, ...options }, (...args) => resolve(args))
12-
}).then(args => {
13-
const index = args ? args[0] : null
14-
if (details && index === buttons.indexOf(detailsLabel)) {
15-
return showMessageBox(details)
16-
}
10+
const args = await dialog.showMessageBox({ title: 'Message', message, buttons, ...options });
11+
const {checkboxChecked, response: index} = args;
12+
if (details && index === buttons.indexOf(detailsLabel)) {
13+
return showMessageBox(details)
14+
}
1715

18-
return args
19-
})
16+
return [index, checkboxChecked];
2017
}
2118

2219
export async function showConfirmBox(message, options = {}) {
@@ -33,12 +30,10 @@ export function showErrorBox(message, title = 'Error') {
3330
dialog.showErrorBox(title, message)
3431
}
3532

36-
export function showSaveDialog(options = {}) {
33+
export async function showSaveDialog(options = {}) {
3734
const defaultPath = options.defaultName ? `${app.getPath('documents')}/${options.defaultName}` : undefined
38-
39-
return new Promise(resolve => {
40-
dialog.showSaveDialog({ defaultPath, ...options }, resolve)
41-
})
35+
const {filePath} = await dialog.showSaveDialog({ defaultPath, ...options });
36+
return filePath;
4237
}
4338

4439
export function showOpenDialog(options = {}) {

0 commit comments

Comments
 (0)