Skip to content
This repository was archived by the owner on Jul 2, 2023. It is now read-only.

Commit a249d40

Browse files
Merge pull request #97 from AndresMorelos/1.21.1
1.21.1
2 parents ea7c51a + c304f7f commit a249d40

File tree

7 files changed

+93
-35
lines changed

7 files changed

+93
-35
lines changed

app/components/layout/AppUpdate.jsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Circle } from 'rc-progress';
44
import openDialog from '../../renderers/dialog';
55
import i18n from '../../../i18n/i18n';
66
import { Notify } from '../../../helpers/notify';
7-
const ipc = require('electron').ipcRenderer
7+
const ipc = require('electron').ipcRenderer;
88

99
// Styled Components
1010
import styled, { keyframes } from 'styled-components';
@@ -54,10 +54,7 @@ class AppUpdate extends PureComponent {
5454
type: 'info',
5555
title: i18n.t('dialog:appUpdate:available:title'),
5656
message: i18n.t('dialog:appUpdate:available:message'),
57-
buttons: [
58-
i18n.t('common:yes'),
59-
i18n.t('common:noThanks')
60-
],
57+
buttons: [i18n.t('common:yes'), i18n.t('common:noThanks')],
6158
},
6259
'update-download-confirmed'
6360
);
@@ -73,11 +70,21 @@ class AppUpdate extends PureComponent {
7370
});
7471

7572
ipc.on('update-error', (event, error) => {
76-
openDialog({
77-
type: 'warning',
78-
title: i18n.t('dialog:appUpdate:error:title'),
79-
message: error,
80-
});
73+
openDialog(
74+
{
75+
type: 'warning',
76+
title: i18n.t('dialog:appUpdate:error:title'),
77+
message: i18n.t('dialog:appUpdate:error:message'),
78+
buttons: [
79+
i18n.t('common:ok'),
80+
{
81+
message: i18n.t('dialog:appUpdate:error:OpenReleasePage'),
82+
url: `https://github.com/AndresMorelos/Invoncify/releases`,
83+
},
84+
],
85+
},
86+
'update-error-selection'
87+
);
8188
this.hideIndicator();
8289
});
8390

@@ -118,7 +125,7 @@ class AppUpdate extends PureComponent {
118125
message: i18n.t('dialog:appUpdate:downloaded:message'),
119126
buttons: [
120127
i18n.t('dialog:appUpdate:downloaded:quitNow'),
121-
i18n.t('dialog:appUpdate:downloaded:later')
128+
i18n.t('dialog:appUpdate:downloaded:later'),
122129
],
123130
},
124131
'upgrade-confirmed'

app/reducers/ContactFormReducer.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const initialState = {
1111
phone: '',
1212
_id: '',
1313
_rev: '',
14+
address: '',
1415
created_at: new Date().getTime(),
1516
};
1617

@@ -31,12 +32,14 @@ const ContactFormReducer = handleActions(
3132
},
3233

3334
[ACTION_TYPES.CONTACT_FORM_CONTACT_UPDATE]: (state, action) => {
34-
const { company, email, fullname, phone, _id, _rev } = action.payload;
35+
const { company, email, fullname, phone, _id, _rev, address } =
36+
action.payload;
3537
return Object.assign(state, {
3638
company,
3739
email,
3840
fullname,
3941
phone,
42+
address,
4043
_id,
4144
_rev,
4245
});

i18n/en/dialog.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"message": "You're using the latest version of the app"
1010
},
1111
"error": {
12-
"title": "An error has occurred"
12+
"title": "An error has occurred",
13+
"message": "There was an error updating the app. Please try again later or download it manually.",
14+
"OpenReleasePage": "Open release page"
1315
},
1416
"downloaded": {
1517
"title": "Update downloaded",

main/export-data.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ ipcMain.on('export-data', (event, docToExport) => {
1414
`data-export-${moment().format('MM-DD-YYYY')}.invoncifyExport`
1515
);
1616

17-
fs.ensureDir(dirPath);
18-
fs.writeFileSync(filePath, docToExport);
17+
fs.ensureDir(dirPath)
18+
.then(() => {
19+
fs.writeFileSync(filePath, docToExport);
1920

20-
// Show notification
21-
event.sender.send('file-exported', {
22-
title: 'Data Exported',
23-
body: 'Click to reveal file.',
24-
location: filePath,
25-
});
21+
// Show notification
22+
event.sender.send('file-exported', {
23+
title: 'Data Exported',
24+
body: 'Click to reveal file.',
25+
location: filePath,
26+
});
27+
})
28+
.catch((err) => {
29+
console.log(err);
30+
});
2631
});

modal/Dialog.jsx

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Libs
22
import React, { PureComponent } from 'react';
33
import styled from 'styled-components';
4+
import './helpers/external_links';
45
const appConfig = require('@electron/remote').require('electron-settings');
56
const BrowserWindow = require('@electron/remote').BrowserWindow;
67
const ipc = require('electron').ipcRenderer;
78
const mainWindow = BrowserWindow.fromId(appConfig.getSync('mainWindowID'));
89

9-
1010
const Wrapper = styled.div`
1111
display: flex;
1212
width: 100%;
@@ -26,11 +26,11 @@ const Type = styled.div`
2626
i {
2727
font-size: 42px;
2828
}
29-
${props =>
29+
${(props) =>
3030
props.type === 'warning' &&
3131
`
3232
i { color: #f0ad4e; }
33-
`} ${props =>
33+
`} ${(props) =>
3434
props.type === 'info' &&
3535
`
3636
i { color: #0275d8; }
@@ -53,11 +53,11 @@ const Title = styled.h4`
5353
text-transform: uppercase;
5454
font-weight: 600;
5555
letter-spacing: 0;
56-
${props =>
56+
${(props) =>
5757
props.type === 'warning' &&
5858
`
5959
color: #f0ad4e;
60-
`} ${props =>
60+
`} ${(props) =>
6161
props.type === 'info' &&
6262
`
6363
color: #0275d8;
@@ -83,11 +83,11 @@ const Actions = styled.div`
8383
flex-direction: row;
8484
border-top: 1px solid rgba(0, 0, 0, 0.1);
8585
padding: 5px 0;
86-
${props =>
86+
${(props) =>
8787
props.type === 'warning' &&
8888
`
8989
border-top: 4px solid #f0ad4e;
90-
`} ${props =>
90+
`} ${(props) =>
9191
props.type === 'info' &&
9292
`
9393
border-top: 4px solid #0275d8;
@@ -163,19 +163,35 @@ class Dialog extends PureComponent {
163163
}
164164

165165
rendersButtons() {
166-
const { buttons } = this.state
166+
const { buttons } = this.state;
167167
if (!buttons) {
168168
return (
169169
<a href="#" onClick={this.handleClick}>
170170
Ok
171171
</a>
172172
);
173173
}
174-
return buttons.map((button, index) => (
175-
<a href="#" key={index} alt={index} onClick={this.handleClick}>
176-
{button}
177-
</a>
178-
));
174+
return buttons.map((button, index) => {
175+
if (typeof button === 'object' && button.url) {
176+
return (
177+
<a
178+
href={button.url}
179+
key={index}
180+
alt={index}
181+
onClick={this.handleClick}
182+
className="js-external-link"
183+
>
184+
{button.message}
185+
</a>
186+
);
187+
}
188+
189+
return (
190+
<a href="#" key={index} alt={index} onClick={this.handleClick}>
191+
{button}
192+
</a>
193+
);
194+
});
179195
}
180196

181197
render() {

modal/helpers/external_links.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { shell } from '@electron/remote';
2+
3+
const supportExternalLinks = (event) => {
4+
let href;
5+
let isExternal = false;
6+
7+
const checkDomElement = (element) => {
8+
if (element.nodeName === 'A') {
9+
href = element.getAttribute('href');
10+
}
11+
if (element.classList.contains('js-external-link')) {
12+
isExternal = true;
13+
}
14+
if (href && isExternal) {
15+
shell.openExternal(href);
16+
event.preventDefault();
17+
} else if (element.parentElement) {
18+
checkDomElement(element.parentElement);
19+
}
20+
};
21+
22+
checkDomElement(event.target);
23+
};
24+
25+
document.addEventListener('click', supportExternalLinks, false);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "invoncify",
33
"homepage": "https://invoncify.andresmorelos.me",
44
"productName": "Invoncify",
5-
"version": "1.21.0",
5+
"version": "1.21.1",
66
"license": "GPL-3.0",
77
"description": "Flexible invoicing desktop app with beautiful & customizable templates",
88
"author": {

0 commit comments

Comments
 (0)