Skip to content

Commit

Permalink
Merge branch 'develop' into fix/ddw-746-small-ui-and-copy-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Jul 11, 2019
2 parents e4a1473 + 06c7b3a commit fe6b287
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -54,6 +54,7 @@ Changelog


### Chores ### Chores


- Improved the "Ada redemption" menu item UX by disabling the option while Daedalus is out of sync ([PR 1458](https://github.com/input-output-hk/daedalus/pull/1458))
- Added `themes:check` script for checking missing definitions on createTheme object ([PR 1424](https://github.com/input-output-hk/daedalus/pull/1424)) - Added `themes:check` script for checking missing definitions on createTheme object ([PR 1424](https://github.com/input-output-hk/daedalus/pull/1424))
- Refactored the Loading screen, adding containers for each overlay ([PR 1446](https://github.com/input-output-hk/daedalus/pull/1446)) - Refactored the Loading screen, adding containers for each overlay ([PR 1446](https://github.com/input-output-hk/daedalus/pull/1446))
- Added button to open local state directory on Daedalus Diagnostics Screen ([PR 1438](https://github.com/input-output-hk/daedalus/pull/1438)) - Added button to open local state directory on Daedalus Diagnostics Screen ([PR 1438](https://github.com/input-output-hk/daedalus/pull/1438))
Expand Down
2 changes: 2 additions & 0 deletions source/main/menus/osx.js
Expand Up @@ -18,6 +18,7 @@ export const osxMenu = (
actions: MenuActions, actions: MenuActions,
translations: {}, translations: {},
supportRequestData: SupportRequests, supportRequestData: SupportRequests,
isNodeInSync: boolean,
translation: Function = getTranslation(translations, id) translation: Function = getTranslation(translations, id)
) => [ ) => [
{ {
Expand All @@ -31,6 +32,7 @@ export const osxMenu = (
}, },
{ {
label: translation('daedalus.adaRedemption'), label: translation('daedalus.adaRedemption'),
enabled: isNodeInSync,
click() { click() {
actions.openAdaRedemptionScreen(); actions.openAdaRedemptionScreen();
}, },
Expand Down
2 changes: 2 additions & 0 deletions source/main/menus/win-linux.js
Expand Up @@ -18,6 +18,7 @@ export const winLinuxMenu = (
actions: MenuActions, actions: MenuActions,
translations: {}, translations: {},
supportRequestData: SupportRequests, supportRequestData: SupportRequests,
isNodeInSync: boolean,
translation: Function = getTranslation(translations, id) translation: Function = getTranslation(translations, id)
) => [ ) => [
{ {
Expand All @@ -31,6 +32,7 @@ export const winLinuxMenu = (
}, },
{ {
label: translation('daedalus.adaRedemption'), label: translation('daedalus.adaRedemption'),
enabled: isNodeInSync,
click() { click() {
actions.openAdaRedemptionScreen(); actions.openAdaRedemptionScreen();
}, },
Expand Down
14 changes: 12 additions & 2 deletions source/main/utils/buildAppMenus.js
@@ -1,5 +1,6 @@
// @flow // @flow
import { app, globalShortcut, Menu, BrowserWindow } from 'electron'; import { app, globalShortcut, Menu, BrowserWindow } from 'electron';
import { get } from 'lodash';
import { environment } from '../environment'; import { environment } from '../environment';
import { winLinuxMenu } from '../menus/win-linux'; import { winLinuxMenu } from '../menus/win-linux';
import { osxMenu } from '../menus/osx'; import { osxMenu } from '../menus/osx';
Expand Down Expand Up @@ -92,9 +93,17 @@ export const buildAppMenus = async (


// Build app menus // Build app menus
let menu; let menu;
const isNodeInSync = get(cardanoNode, 'status.isNodeInSync', false);
if (isMacOS) { if (isMacOS) {
menu = Menu.buildFromTemplate( menu = Menu.buildFromTemplate(
osxMenu(app, mainWindow, menuActions, translations, supportRequestData) osxMenu(
app,
mainWindow,
menuActions,
translations,
supportRequestData,
isNodeInSync
)
); );
Menu.setApplicationMenu(menu); Menu.setApplicationMenu(menu);
} else { } else {
Expand All @@ -104,7 +113,8 @@ export const buildAppMenus = async (
mainWindow, mainWindow,
menuActions, menuActions,
translations, translations,
supportRequestData supportRequestData,
isNodeInSync
) )
); );
mainWindow.setMenu(menu); mainWindow.setMenu(menu);
Expand Down
32 changes: 22 additions & 10 deletions source/renderer/app/components/status/DaedalusDiagnostics.js
Expand Up @@ -482,7 +482,6 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
networkBlockHeight, networkBlockHeight,
latestLocalBlockTimestamp, latestLocalBlockTimestamp,
latestNetworkBlockTimestamp, latestNetworkBlockTimestamp,
onForceCheckLocalTimeDifference,
onOpenStateDirectory, onOpenStateDirectory,
onClose, onClose,
onCopyStateDirectoryPath, onCopyStateDirectoryPath,
Expand Down Expand Up @@ -578,8 +577,8 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
<table className={styles.table}> <table className={styles.table}>
<tbody> <tbody>
<tr> <tr>
<th colSpan={2}> <th className={styles.sectionTitle} colSpan={2}>
{intl.formatMessage(messages.systemInfo)} <span>{intl.formatMessage(messages.systemInfo)}</span>
<hr /> <hr />
</th> </th>
</tr> </tr>
Expand Down Expand Up @@ -608,8 +607,8 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
</tbody> </tbody>
<tbody> <tbody>
<tr> <tr>
<th colSpan={2}> <th className={styles.sectionTitle} colSpan={2}>
{intl.formatMessage(messages.coreInfo)} <span>{intl.formatMessage(messages.coreInfo)}</span>
<hr /> <hr />
</th> </th>
</tr> </tr>
Expand Down Expand Up @@ -701,8 +700,8 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
<table className={styles.table}> <table className={styles.table}>
<tbody> <tbody>
<tr> <tr>
<th colSpan={2}> <th className={styles.sectionTitle} colSpan={2}>
{intl.formatMessage(messages.daedalusStatus)} <span>{intl.formatMessage(messages.daedalusStatus)}</span>
<hr /> <hr />
</th> </th>
</tr> </tr>
Expand Down Expand Up @@ -760,7 +759,7 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
<th>{intl.formatMessage(messages.localTimeDifference)}:</th> <th>{intl.formatMessage(messages.localTimeDifference)}:</th>
<td className={styles.localTimeDifferenceItem}> <td className={styles.localTimeDifferenceItem}>
<button <button
onClick={() => onForceCheckLocalTimeDifference()} onClick={() => this.checkTime()}
disabled={isForceCheckingNodeTime || !isConnected} disabled={isForceCheckingNodeTime || !isConnected}
> >
{isForceCheckingNodeTime {isForceCheckingNodeTime
Expand Down Expand Up @@ -803,8 +802,8 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
</tbody> </tbody>
<tbody> <tbody>
<tr> <tr>
<th colSpan={2}> <th className={styles.sectionTitle} colSpan={2}>
{intl.formatMessage(messages.cardanoNodeStatus)} <span>{intl.formatMessage(messages.cardanoNodeStatus)}</span>
<button <button
className={styles.statusBtn} className={styles.statusBtn}
onClick={() => this.restartNode()} onClick={() => this.restartNode()}
Expand Down Expand Up @@ -937,9 +936,22 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
return localisationKey; return localisationKey;
}; };


restoreDialogCloseOnEscKey = () => {
// This method is to be used on buttons which get disabled after click
// as without it the ReactModal is not closing if you press the ESC key
// even after the button is later re-enabled
document.getElementsByClassName('ReactModal__Content')[0].focus();
};

checkTime = () => {
this.props.onForceCheckLocalTimeDifference();
this.restoreDialogCloseOnEscKey();
};

restartNode = () => { restartNode = () => {
this.setState({ isNodeRestarting: true }); this.setState({ isNodeRestarting: true });
this.props.onRestartNode.trigger(); this.props.onRestartNode.trigger();
this.restoreDialogCloseOnEscKey();
}; };


getClass = (isTrue: boolean) => getClass = (isTrue: boolean) =>
Expand Down
14 changes: 10 additions & 4 deletions source/renderer/app/components/status/DaedalusDiagnostics.scss
Expand Up @@ -83,19 +83,26 @@
font-weight: normal; font-weight: normal;
line-height: 2; line-height: 2;
letter-spacing: normal; letter-spacing: normal;
opacity: 0.7;


.safeMode { .safeMode {
max-width: 100px; max-width: 100px;
} }
} }


th { th {
opacity: 0.7;
white-space: nowrap; white-space: nowrap;

&.sectionTitle {
opacity: 1;

*:not(button) {
opacity: 0.7;
}
}
} }


td { td {
opacity: 1;
text-align: right; text-align: right;
user-select: text; user-select: text;


Expand Down Expand Up @@ -300,8 +307,7 @@
} }


&.stateDirectoryOpenBtn { &.stateDirectoryOpenBtn {
margin: 4px 16px 0 0; margin-right: 16px;
padding-top: 0;
} }
} }


Expand Down
5 changes: 5 additions & 0 deletions source/renderer/app/stores/NetworkStatusStore.js
Expand Up @@ -33,6 +33,7 @@ import type { NodeInfoQueryParams } from '../api/nodes/requests/getNodeInfo';
import type { CheckDiskSpaceResponse } from '../../../common/types/no-disk-space.types'; import type { CheckDiskSpaceResponse } from '../../../common/types/no-disk-space.types';
import { TlsCertificateNotValidError } from '../api/nodes/errors'; import { TlsCertificateNotValidError } from '../api/nodes/errors';
import { openLocalDirectoryChannel } from '../ipc/open-local-directory'; import { openLocalDirectoryChannel } from '../ipc/open-local-directory';
import { rebuildApplicationMenu } from '../ipc/rebuild-application-menu';


// DEFINE CONSTANTS ------------------------- // DEFINE CONSTANTS -------------------------
const NETWORK_STATUS = { const NETWORK_STATUS = {
Expand Down Expand Up @@ -192,6 +193,10 @@ export default class NetworkStatusStore extends Store {
try { try {
Logger.info('NetworkStatusStore: Updating node status'); Logger.info('NetworkStatusStore: Updating node status');
await setCachedCardanoStatusChannel.send(this._extractNodeStatus(this)); await setCachedCardanoStatusChannel.send(this._extractNodeStatus(this));
// Force application menu rebuild in order to disable/enable
// "Ada redemption" option based on isNodeInSync variable value
// which was sent to the main process via setCachedCardanoStatusChannel
await rebuildApplicationMenu.send();
} catch (error) { } catch (error) {
Logger.error('NetworkStatusStore: Error while updating node status', { Logger.error('NetworkStatusStore: Error while updating node status', {
error, error,
Expand Down

0 comments on commit fe6b287

Please sign in to comment.