Skip to content
Permalink
Browse files

[DDW-615] Move the GPU Safe Mode under "Help and Support" - moving No…

…tifications component to App level. Refactoring old Notification implementation
  • Loading branch information...
DeeJayElly committed May 14, 2019
1 parent d1922a2 commit b0169de73afa679d7f3ab4a0dcd5c17f888bca0e
@@ -13,3 +13,7 @@ export const SCREENS = {
export const ERRORS = {
INVALID_REDEMPTION_CERTIFICATE_ERROR: 'INVALID_REDEMPTION_CERTIFICATE_ERROR',
};

export const NOTIFICATIONS = {
DOWNLOAD_LOGS: 'DOWNLOAD_LOGS_NOTIFICATION',
};
@@ -7,6 +7,8 @@ import { getTranslation } from '../utils/getTranslation';
import { environment } from '../environment';
import { getLocale } from '../utils/getLocale';
import { generateFileNameWithTimestamp } from '../../common/utils/files';
import { showUiPartChannel } from '../ipc/control-ui-parts';
import { NOTIFICATIONS } from '../../common/ipc/constants';

const localesFillForm = {
'en-US': 'English',
@@ -159,13 +161,7 @@ export const osxMenu = (
{
label: translation('helpSupport.downloadLogs'),
click() {
const fileName = generateFileNameWithTimestamp();
const destination = dialog.showSaveDialog({
defaultPath: fileName,
});
if (destination) {
// @todo
}
showUiPartChannel.send(NOTIFICATIONS.DOWNLOAD_LOGS, window);
},
},
{
@@ -7,6 +7,8 @@ import { getTranslation } from '../utils/getTranslation';
import { environment } from '../environment';
import { getLocale } from '../utils/getLocale';
import { generateFileNameWithTimestamp } from '../../common/utils/files';
import { NOTIFICATIONS } from '../../common/ipc/constants';
import { showUiPartChannel } from '../ipc/control-ui-parts';

const localesFillForm = {
'en-US': 'English',
@@ -177,13 +179,7 @@ export const winLinuxMenu = (
{
label: translation('helpSupport.downloadLogs'),
click() {
const fileName = generateFileNameWithTimestamp();
const destination = dialog.showSaveDialog({
defaultPath: fileName,
});
if (destination) {
// @todo
}
showUiPartChannel.send(NOTIFICATIONS.DOWNLOAD_LOGS, window);
},
},
{
@@ -4,7 +4,7 @@ import { Provider, observer } from 'mobx-react';
import { ThemeProvider } from 'react-polymorph/lib/components/ThemeProvider';
import DevTools from 'mobx-react-devtools';
import { Router } from 'react-router';
import { IntlProvider } from 'react-intl';
import { defineMessages, IntlProvider, intlShape } from 'react-intl';
import { Routes } from './Routes';
import { daedalusTheme } from './themes/daedalus';
import { themeOverrides } from './themes/overrides/index.js';
@@ -14,25 +14,57 @@ import type { ActionsMap } from './actions/index';
import ThemeManager from './ThemeManager';
import AboutDialog from './containers/static/AboutDialog';
import NetworkStatusDialog from './containers/status/NetworkStatusDialog';
import GenericNotificationContainer from './containers/notifications/GenericNotificationContainer';
import GenericNotification from './components/notifications/GenericNotification';
import { DOWNLOAD_LOGS_SUCCESS_DURATION } from './config/timingConfig';
import { i18nContext } from './utils/i18nContext';

export const messages = defineMessages({
downloadLogsSuccess: {
id: 'loading.screen.reportIssue.downloadLogsSuccessMessage',
defaultMessage: '!!!Logs successfully downloaded',
description: 'Success message for download logs.',
},
downloadLogsProgress: {
id: 'loading.screen.reportIssue.downloadLogsProgressMessage',
defaultMessage: '!!!Preparing logs for download',
description: 'Progress message for download logs.',
},
});

const DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID =
'loading-page-download-logs-progress';
const DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID =
'loading-page-download-logs-success';

@observer
export default class App extends Component<{
stores: StoresMap,
actions: ActionsMap,
history: Object,
}> {
static contextTypes = {
intl: intlShape.isRequired,
};

componentWillMount() {
// loads app's global environment variables into AppStore via ipc
this.props.actions.app.initAppEnvironment.trigger();
}
render() {
const { stores, actions, history } = this.props;
const { app } = stores;
const { isAboutDialogOpen, isNetworkStatusDialogOpen } = app;
const {
isAboutDialogOpen,
isNetworkStatusDialogOpen,
isNotificationVisible,
} = app;
const locale = stores.profile.currentLocale;
const intl = i18nContext(locale);
const mobxDevTools = global.environment.mobxDevTools ? <DevTools /> : null;
const { currentTheme } = stores.profile;
const themeVars = require(`./themes/daedalus/${currentTheme}.js`).default;
const notificationOrder = 9999;
return (
<Fragment>
<ThemeManager variables={themeVars} />
@@ -46,6 +78,42 @@ export default class App extends Component<{
{mobxDevTools}
{isNetworkStatusDialogOpen && <NetworkStatusDialog />}
{isAboutDialogOpen && <AboutDialog />}
{isNotificationVisible && (
<GenericNotificationContainer>
<GenericNotification
id={DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID
)}
actionToListenAndOpen={actions.profile.downloadLogs}
actionToListenAndClose={
actions.profile.downloadLogsSuccess
}
icon="spinner"
hasEllipsis
hasCloseButton
order={notificationOrder}
>
{intl.formatMessage(messages.downloadLogsProgress)}
</GenericNotification>
<GenericNotification
id={DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID}
duration={DOWNLOAD_LOGS_SUCCESS_DURATION}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID
)}
actionToListenAndOpen={
actions.profile.downloadLogsSuccess
}
actionToListenAndClose={actions.profile.downloadLogs}
icon="success"
hasCloseButton
order={notificationOrder}
>
{intl.formatMessage(messages.downloadLogsSuccess)}
</GenericNotification>
</GenericNotificationContainer>
)}
</Fragment>
</IntlProvider>
</ThemeProvider>
@@ -11,4 +11,5 @@ export default class AppActions {
getGpuStatus: Action<any> = new Action();
initAppEnvironment: Action<any> = new Action();
toggleBlockConsolidationStatusScreen: Action<any> = new Action();
downloadLogs: Action<any> = new Action();
}
@@ -7,11 +7,7 @@ import Loading from '../components/loading/Loading';
import adaLogo from '../assets/images/ada-logo.inline.svg';
import cardanoLogo from '../assets/images/cardano-logo.inline.svg';
import type { InjectedProps } from '../types/injectedPropsType';
import { generateFileNameWithTimestamp } from '../../../common/utils/files';
import { getSupportUrl } from '../utils/network';
import GenericNotificationContainer from './notifications/GenericNotificationContainer';
import GenericNotification from '../components/notifications/GenericNotification';
import { DOWNLOAD_LOGS_SUCCESS_DURATION } from '../config/timingConfig';

export const messages = defineMessages({
loadingWalletData: {
@@ -24,27 +20,12 @@ export const messages = defineMessages({
defaultMessage: '!!!https://iohk.zendesk.com/hc/en-us/requests/new/',
description: 'Link to Open Support page',
},
downloadLogsSuccess: {
id: 'loading.screen.reportIssue.downloadLogsSuccessMessage',
defaultMessage: '!!!Logs successfully downloaded',
description: 'Success message for download logs.',
},
downloadLogsProgress: {
id: 'loading.screen.reportIssue.downloadLogsProgressMessage',
defaultMessage: '!!!Preparing logs for download',
description: 'Progress message for download logs.',
},
});

type State = {
disableDownloadLogs: boolean,
};

const DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID =
'loading-page-download-logs-progress';
const DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID =
'loading-page-download-logs-success';

@inject('stores', 'actions')
@observer
export default class LoadingPage extends Component<InjectedProps, State> {
@@ -65,8 +46,7 @@ export default class LoadingPage extends Component<InjectedProps, State> {
};

render() {
const { stores, actions } = this.props;
const { intl } = this.context;
const { stores } = this.props;
const {
cardanoNodeState,
isNodeResponding,
@@ -130,34 +110,6 @@ export default class LoadingPage extends Component<InjectedProps, State> {
onDownloadLogs={this.handleDownloadLogs}
disableDownloadLogs={this.state.disableDownloadLogs}
/>
<GenericNotificationContainer>
<GenericNotification
id={DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID
)}
actionToListenAndOpen={actions.profile.downloadLogs}
actionToListenAndClose={actions.profile.downloadLogsSuccess}
icon="spinner"
hasEllipsis
hasCloseButton
>
{intl.formatMessage(messages.downloadLogsProgress)}
</GenericNotification>
<GenericNotification
id={DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID}
duration={DOWNLOAD_LOGS_SUCCESS_DURATION}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID
)}
actionToListenAndOpen={actions.profile.downloadLogsSuccess}
actionToListenAndClose={actions.profile.downloadLogs}
icon="success"
hasCloseButton
>
{intl.formatMessage(messages.downloadLogsSuccess)}
</GenericNotification>
</GenericNotificationContainer>
</CenteredLayout>
);
}
@@ -174,15 +126,9 @@ export default class LoadingPage extends Component<InjectedProps, State> {
};

handleDownloadLogs = () => {
const { profile } = this.props.actions;
const fileName = generateFileNameWithTimestamp();
const destination = global.dialog.showSaveDialog({
defaultPath: fileName,
});
if (destination) {
this.toggleDisableDownloadLogs(true);
profile.downloadLogs.trigger({ fileName, destination, fresh: true });
}
const { app } = this.props.actions;
app.downloadLogs.trigger();
this.toggleDisableDownloadLogs(true);
};

toggleDisableDownloadLogs = (disableDownloadLogs: boolean) => {
@@ -1,33 +1,12 @@
// @flow
import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import { intlShape } from 'react-intl';
import SettingsLayout from '../../components/settings/SettingsLayout';
import SettingsMenu from '../../components/settings/menu/SettingsMenu';
import Layout from '../MainLayout';
import { buildRoute } from '../../utils/routing';
import type { InjectedContainerProps } from '../../types/injectedPropsType';
import GenericNotificationContainer from '../notifications/GenericNotificationContainer';
import GenericNotification from '../../components/notifications/GenericNotification';
import { DOWNLOAD_LOGS_SUCCESS_DURATION } from '../../config/timingConfig';

const messages = defineMessages({
downloadLogsSuccess: {
id: 'settings.support.reportProblem.downloadLogsSuccessMessage',
defaultMessage: '!!!Logs successfully downloaded',
description: 'Success message for download logs.',
},
downloadLogsProgress: {
id: 'settings.support.reportProblem.downloadLogsProgressMessage',
defaultMessage: '!!!Preparing logs for download',
description: 'Progress message for download logs.',
},
});

const DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID =
'settings-page-download-logs-progress';
const DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID =
'settings-page-download-logs-success';

@inject('stores', 'actions')
@observer
@@ -47,8 +26,7 @@ export default class Settings extends Component<InjectedContainerProps> {
};

render() {
const { actions, children, stores } = this.props;
const { intl } = this.context;
const { actions, children } = this.props;
const menu = (
<SettingsMenu
onItemClick={route => actions.router.goToRoute.trigger({ route })}
@@ -58,34 +36,6 @@ export default class Settings extends Component<InjectedContainerProps> {
return (
<Layout>
<SettingsLayout menu={menu}>{children}</SettingsLayout>
<GenericNotificationContainer>
<GenericNotification
id={DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_PROGRESS_NOTIFICATION_ID
)}
actionToListenAndOpen={actions.profile.downloadLogs}
actionToListenAndClose={actions.profile.downloadLogsSuccess}
icon="spinner"
hasEllipsis
hasCloseButton
>
{intl.formatMessage(messages.downloadLogsProgress)}
</GenericNotification>
<GenericNotification
id={DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID}
duration={DOWNLOAD_LOGS_SUCCESS_DURATION}
show={stores.uiNotifications.isOpen(
DOWNLOAD_LOGS_SUCCESS_NOTIFICATION_ID
)}
actionToListenAndOpen={actions.profile.downloadLogsSuccess}
actionToListenAndClose={actions.profile.downloadLogs}
icon="success"
hasCloseButton
>
{intl.formatMessage(messages.downloadLogsSuccess)}
</GenericNotification>
</GenericNotificationContainer>
</Layout>
);
}
@@ -58,16 +58,9 @@ export default class SupportSettingsPage extends Component<
};

handleDownloadLogs = () => {
// TODO: refactor this direct access to the dialog api
const fileName = generateFileNameWithTimestamp();
const { profile } = this.props.actions;
const destination = global.dialog.showSaveDialog({
defaultPath: fileName,
});
if (destination) {
this.toggleDisableDownloadLogs(true);
profile.downloadLogs.trigger({ fileName, destination, fresh: true });
}
const { app } = this.props.actions;
app.downloadLogs.trigger();
this.toggleDisableDownloadLogs(true);
};

toggleDisableDownloadLogs = (disableDownloadLogs: boolean) => {
Oops, something went wrong.

0 comments on commit b0169de

Please sign in to comment.
You can’t perform that action at this time.