Make RelinkDialog supersede the NetworkDialog
This commit is contained in:
parent
1b5c36a9a8
commit
752cd75c54
5 changed files with 9 additions and 26 deletions
|
@ -393,9 +393,9 @@ export class LeftPane extends React.Component<PropsType> {
|
|||
{showArchived ? this.renderArchivedHeader() : renderMainHeader()}
|
||||
</div>
|
||||
{renderExpiredBuildDialog()}
|
||||
{renderRelinkDialog()}
|
||||
{renderNetworkStatus()}
|
||||
{renderUpdateDialog()}
|
||||
{renderRelinkDialog()}
|
||||
{showArchived && (
|
||||
<div className="module-left-pane__archive-helper-text" key={0}>
|
||||
{i18n('archiveHelperText')}
|
||||
|
|
|
@ -13,7 +13,6 @@ import { action } from '@storybook/addon-actions';
|
|||
const i18n = setupI18n('en', enMessages);
|
||||
|
||||
const defaultProps = {
|
||||
hasNetworkDialog: false,
|
||||
i18n,
|
||||
isRegistrationDone: true,
|
||||
relinkDevice: action('relink-device'),
|
||||
|
@ -21,31 +20,19 @@ const defaultProps = {
|
|||
|
||||
const permutations = [
|
||||
{
|
||||
title: 'Unlinked (online)',
|
||||
title: 'Unlinked',
|
||||
props: {
|
||||
isRegistrationDone: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Unlinked (offline)',
|
||||
props: {
|
||||
hasNetworkDialog: true,
|
||||
isRegistrationDone: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
storiesOf('Components/RelinkDialog', module)
|
||||
.add('Knobs Playground', () => {
|
||||
const hasNetworkDialog = boolean('hasNetworkDialog', false);
|
||||
const isRegistrationDone = boolean('isRegistrationDone', false);
|
||||
|
||||
return (
|
||||
<RelinkDialog
|
||||
{...defaultProps}
|
||||
hasNetworkDialog={hasNetworkDialog}
|
||||
isRegistrationDone={isRegistrationDone}
|
||||
/>
|
||||
<RelinkDialog {...defaultProps} isRegistrationDone={isRegistrationDone} />
|
||||
);
|
||||
})
|
||||
.add('Iterations', () => {
|
||||
|
|
|
@ -3,19 +3,17 @@ import React from 'react';
|
|||
import { LocalizerType } from '../types/Util';
|
||||
|
||||
export interface PropsType {
|
||||
hasNetworkDialog: boolean;
|
||||
i18n: LocalizerType;
|
||||
isRegistrationDone: boolean;
|
||||
relinkDevice: () => void;
|
||||
}
|
||||
|
||||
export const RelinkDialog = ({
|
||||
hasNetworkDialog,
|
||||
i18n,
|
||||
isRegistrationDone,
|
||||
relinkDevice,
|
||||
}: PropsType): JSX.Element | null => {
|
||||
if (hasNetworkDialog || isRegistrationDone) {
|
||||
if (isRegistrationDone) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ export const hasNetworkDialog = createSelector(
|
|||
{ isOnline, socketStatus, withinConnectingGracePeriod }: NetworkStateType,
|
||||
isRegistrationDone: boolean
|
||||
): boolean =>
|
||||
!isOnline ||
|
||||
!isRegistrationDone ||
|
||||
(socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) ||
|
||||
socketStatus === WebSocket.CLOSED ||
|
||||
socketStatus === WebSocket.CLOSING
|
||||
isRegistrationDone &&
|
||||
(!isOnline ||
|
||||
(socketStatus === WebSocket.CONNECTING && !withinConnectingGracePeriod) ||
|
||||
socketStatus === WebSocket.CLOSED ||
|
||||
socketStatus === WebSocket.CLOSING)
|
||||
);
|
||||
|
|
|
@ -3,12 +3,10 @@ import { mapDispatchToProps } from '../actions';
|
|||
import { RelinkDialog } from '../../components/RelinkDialog';
|
||||
import { StateType } from '../reducer';
|
||||
import { getIntl } from '../selectors/user';
|
||||
import { hasNetworkDialog } from '../selectors/network';
|
||||
import { isDone } from '../../util/registration';
|
||||
|
||||
const mapStateToProps = (state: StateType) => {
|
||||
return {
|
||||
hasNetworkDialog: hasNetworkDialog(state),
|
||||
i18n: getIntl(state),
|
||||
isRegistrationDone: isDone(),
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue