You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			145 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
		
		
			
		
	
	
			145 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			TypeScript
		
	
| 
											4 years ago
										 | import React from 'react'; | ||
| 
											4 years ago
										 | import styled from 'styled-components'; | ||
| 
											4 years ago
										 | import { useDispatch, useSelector } from 'react-redux'; | ||
|  | import { disableRecoveryPhrasePrompt } from '../../state/ducks/userConfig'; | ||
|  | import { getShowRecoveryPhrasePrompt } from '../../state/selectors/userConfig'; | ||
| 
											4 years ago
										 | import { recoveryPhraseModal } from '../../state/ducks/modalDialog'; | ||
| 
											4 years ago
										 | import { Flex } from '../basic/Flex'; | ||
| 
											4 years ago
										 | import { getFocusedSection } from '../../state/selectors/section'; | ||
|  | import { SectionType } from '../../state/ducks/section'; | ||
| 
											4 years ago
										 | import { UserUtils } from '../../session/utils'; | ||
| 
											4 years ago
										 | import { SessionButton, SessionButtonType } from '../basic/SessionButton'; | ||
|  | import { SessionIcon } from '../icon'; | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 | const SectionTitle = styled.h1`
 | ||
|  |   padding: 0 var(--margins-sm); | ||
|  |   flex-grow: 1; | ||
|  |   color: var(--color-text); | ||
|  | `;
 | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 | export const LeftPaneSectionHeader = (props: { buttonClicked?: any }) => { | ||
|  |   const showRecoveryPhrasePrompt = useSelector(getShowRecoveryPhrasePrompt); | ||
|  |   const focusedSection = useSelector(getFocusedSection); | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 |   let label: string | undefined; | ||
| 
											6 years ago
										 | 
 | ||
| 
											4 years ago
										 |   const isMessageSection = focusedSection === SectionType.Message; | ||
|  | 
 | ||
|  |   switch (focusedSection) { | ||
|  |     case SectionType.Contact: | ||
|  |       label = window.i18n('contactsHeader'); | ||
|  |       break; | ||
|  |     case SectionType.Settings: | ||
|  |       label = window.i18n('settingsHeader'); | ||
|  |       break; | ||
|  |     case SectionType.Message: | ||
|  |       label = window.i18n('messagesHeader'); | ||
|  |       break; | ||
|  |     default: | ||
|  |   } | ||
| 
											4 years ago
										 | 
 | ||
| 
											5 years ago
										 |   return ( | ||
| 
											4 years ago
										 |     <Flex flexDirection="column"> | ||
| 
											4 years ago
										 |       <div className="module-left-pane__header"> | ||
| 
											4 years ago
										 |         <SectionTitle>{label}</SectionTitle> | ||
|  |         {isMessageSection && ( | ||
|  |           <SessionButton onClick={props.buttonClicked}> | ||
|  |             <SessionIcon iconType="plus" iconSize="small" iconColor="white" /> | ||
| 
											4 years ago
										 |           </SessionButton> | ||
|  |         )} | ||
|  |       </div> | ||
|  |       {showRecoveryPhrasePrompt && <LeftPaneBanner />} | ||
| 
											4 years ago
										 |     </Flex> | ||
| 
											5 years ago
										 |   ); | ||
| 
											5 years ago
										 | }; | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 | const BannerInner = () => { | ||
| 
											4 years ago
										 |   const dispatch = useDispatch(); | ||
|  | 
 | ||
| 
											4 years ago
										 |   const showRecoveryPhraseModal = () => { | ||
| 
											4 years ago
										 |     dispatch(disableRecoveryPhrasePrompt()); | ||
|  |     dispatch(recoveryPhraseModal({})); | ||
| 
											4 years ago
										 |   }; | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 |   return ( | ||
|  |     <StyledBannerInner> | ||
|  |       <p>{window.i18n('recoveryPhraseRevealMessage')}</p> | ||
|  |       <SessionButton | ||
|  |         buttonType={SessionButtonType.Default} | ||
|  |         text={window.i18n('recoveryPhraseRevealButtonText')} | ||
|  |         onClick={showRecoveryPhraseModal} | ||
| 
											4 years ago
										 |         dataTestId="reveal-recovery-phrase" | ||
| 
											4 years ago
										 |       /> | ||
|  |     </StyledBannerInner> | ||
|  |   ); | ||
|  | }; | ||
|  | 
 | ||
|  | export const LeftPaneBanner = () => { | ||
|  |   const section = useSelector(getFocusedSection); | ||
| 
											4 years ago
										 |   const isSignInWithRecoveryPhrase = UserUtils.isSignWithRecoveryPhrase(); | ||
| 
											4 years ago
										 | 
 | ||
| 
											4 years ago
										 |   if (section !== SectionType.Message || isSignInWithRecoveryPhrase) { | ||
| 
											4 years ago
										 |     return null; | ||
|  |   } | ||
|  | 
 | ||
| 
											4 years ago
										 |   return ( | ||
| 
											4 years ago
										 |     <StyledLeftPaneBanner> | ||
| 
											4 years ago
										 |       <StyledProgressBarContainer> | ||
| 
											4 years ago
										 |         <StyledProgressBarInner /> | ||
| 
											4 years ago
										 |       </StyledProgressBarContainer> | ||
| 
											4 years ago
										 |       <StyledBannerTitle> | ||
|  |         {window.i18n('recoveryPhraseSecureTitle')} <span>90%</span> | ||
| 
											4 years ago
										 |       </StyledBannerTitle> | ||
| 
											4 years ago
										 |       <Flex flexDirection="column" justifyContent="space-between" padding={'var(--margins-sm)'}> | ||
| 
											4 years ago
										 |         <BannerInner /> | ||
| 
											4 years ago
										 |       </Flex> | ||
| 
											4 years ago
										 |     </StyledLeftPaneBanner> | ||
| 
											4 years ago
										 |   ); | ||
|  | }; | ||
| 
											4 years ago
										 | 
 | ||
|  | const StyledProgressBarContainer = styled.div`
 | ||
|  |   width: 100%; | ||
|  |   height: 5px; | ||
|  |   flex-direction: row; | ||
| 
											4 years ago
										 |   background: var(--color-session-border); | ||
| 
											4 years ago
										 | `;
 | ||
|  | 
 | ||
|  | const StyledProgressBarInner = styled.div`
 | ||
| 
											4 years ago
										 |   background: var(--color-accent); | ||
| 
											4 years ago
										 |   width: 90%; | ||
| 
											4 years ago
										 |   transition: width 0.5s ease-in; | ||
|  |   height: 100%; | ||
|  | `;
 | ||
|  | 
 | ||
|  | export const StyledBannerTitle = styled.div`
 | ||
|  |   line-height: 1.3; | ||
| 
											4 years ago
										 |   font-size: var(--font-size-md); | ||
| 
											4 years ago
										 |   font-weight: bold; | ||
| 
											4 years ago
										 |   margin: var(--margins-sm) var(--margins-sm) 0 var(--margins-sm); | ||
| 
											4 years ago
										 | 
 | ||
|  |   span { | ||
| 
											4 years ago
										 |     color: var(--color-text-accent); | ||
| 
											4 years ago
										 |   } | ||
| 
											4 years ago
										 | `;
 | ||
|  | 
 | ||
|  | export const StyledLeftPaneBanner = styled.div`
 | ||
| 
											4 years ago
										 |   background: var(--color-recovery-phrase-banner-background); | ||
| 
											4 years ago
										 |   display: flex; | ||
|  |   flex-direction: column; | ||
| 
											4 years ago
										 |   border-bottom: var(--session-border); | ||
| 
											4 years ago
										 | `;
 | ||
|  | 
 | ||
|  | const StyledBannerInner = styled.div`
 | ||
|  |   p { | ||
|  |     margin: 0; | ||
|  |   } | ||
|  | 
 | ||
|  |   .left-pane-banner___phrase { | ||
| 
											4 years ago
										 |     margin-top: var(--margins-md); | ||
| 
											4 years ago
										 |   } | ||
|  | 
 | ||
|  |   .session-button { | ||
| 
											4 years ago
										 |     margin-top: var(--margins-sm); | ||
| 
											4 years ago
										 |   } | ||
|  | `;
 |