Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves 4 jira issues, plus more Cordova offset adjustments for iOS and Android, will be Cordova release 2.4.1 #3761

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions node/buildSrcCordova.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@ function addUShowStylesImport (fileTxt, path) {
return ret;
}

function fileRewriterForCordova (path) {
function getVersionFromConfigXML () {
const path = '../WeVoteCordova/config.xml';
const data = fs.readFileSync(path, 'utf-8');
const regex = /version="(.*?)"/;
const found = data.match(regex);
if (found.length > 0) {
console.log('version from config.xml: ', found[1]);
return found[1];
} else {
console.log('version from config.xml: error');
return 'error';
}
}

function fileRewriterForCordova (path, version) {
// console.log('Do ', path);
if (path.endsWith('.css') || path.endsWith('cordovaOffsets.js')) {
return;
Expand Down Expand Up @@ -125,22 +139,28 @@ function fileRewriterForCordova (path) {
// append an import of cordovaFriendlyUShowStyles.js at top of each file where needed
newValue = addUShowStylesImport(newValue, path);

// Inject version string
newValue = newValue.replace(/{window\.weVoteAppVersion}/, version);

fs.writeFile(path, newValue, 'utf-8', (err2) => {
if (err2) throw err2;
// console.log('Done! with ', path);
});
});
}

// Inline node

console.log('> Cordova: Preparing to set up parallel /srcCordova directory.');
const version = getVersionFromConfigXML();
fs.remove('./build').then(() => {
console.log('> Cordova: Removed build directory');
fs.remove('./srcCordova').then(() => {
console.log('> Cordova: Removed /srcCordova directory, if it existed');
try {
fs.copy('./src', './srcCordova', () => {
console.log('> Cordova: Copied the /src dir to a newly created /srcCordova directory');
exec('egrep -rl "React.lazy|BrowserRouter|initializeMoment|Suspense|u-show-desktop-tablet|u-show-mobile|uShowMobile|uShowDesktopTablet" ./srcCordova', (error, stdout, stderr) => {
exec('egrep -rl "React.lazy|BrowserRouter|initializeMoment|Suspense|u-show-desktop-tablet|u-show-mobile|uShowMobile|uShowDesktopTablet|window.weVoteAppVersion" ./srcCordova', (error, stdout, stderr) => {
if (error) {
console.log(`> Cordova bldSrcCordova error: ${error.message}`);
return;
Expand All @@ -156,7 +176,7 @@ fs.remove('./build').then(() => {
const path = listOfFiles[i];
// console.log(`path: ${path}`);
if (path.length) {
fileRewriterForCordova(path);
fileRewriterForCordova(path, version);
}
}
console.log(`> Cordova: ${listOfFiles.length} files in ./srcCordova, rewritten without React.lazy`);
Expand Down
14 changes: 14 additions & 0 deletions node/unSymLinkIOS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This suddenly become necessary with XCode 15 and iOS 17, on October 25, 2023
echo 'copying files and removing symlinks in WeVoteCordova/platforms/ios/www (new in Oct 2023)'
cd ../WeVoteCordova/platforms/ios/www || exit
rm bundle.js
cp ../../../../WebApp/build/bundle.js .
rm bundle.js.map
cp ../../../../WebApp/build/bundle.js.map .
rm css
cp -r ../../../../WebApp/build/css .
rm img
cp -r ../../../../WebApp/build/img .
rm index.html
cp ../../../www/index.html .

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"wdio:upgrade": "ncu -u *wdio* webdriver*",
"build": "node node/buildDateFile.js && MINIMIZED=1 webpack --mode production",
"buildCordova": "node node/buildDateFile.js && node node/buildSrcCordova && CORDOVA=1 && webpack --mode development && node node/logCompileDate.js",
"buildCordovaAndLinks": "node node/buildDateFile.js && node node/buildSrcCordova && CORDOVA=1 && webpack --mode development && node node/buildSymLinksRemote.js && node node/logCompileDate.js",
"buildCordovaAndLinks": "node node/buildDateFile.js && node node/buildSrcCordova && CORDOVA=1 && webpack --mode development && node node/buildSymLinksRemote.js && node node/logCompileDate.js && bash ./node/unSymLinkIOS.sh",
"lint": "eslint --format stylish --ext .jsx --ext .js src/js",
"lintCordova": "eslint --format stylish --ext .jsx --ext .js srcCordova/js",
"prod": "node node/buildDateFile.js && MINIMIZED=1 webpack --mode production",
Expand Down
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class App extends Component {
// console.log('normalizedHrefPage in App.js componentDidMount: ', normalizedHref());
const onWeVoteUS = (hostname && (hostname.toLowerCase() === 'wevote.us'));
const onMobileApp = false;
if (onWeVoteUS || onMobileApp) {
if ((onWeVoteUS || onMobileApp) && isWebApp()) {
if (webAppConfig.FULL_STORY_ORG) {
setTimeout(() => {
console.log('FullStory ENABLED');
Expand Down
27 changes: 14 additions & 13 deletions src/js/common/components/SignIn/SignInOptionsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import FacebookActions from '../../../actions/FacebookActions';
import TwitterActions from '../../../actions/TwitterActions';
import VoterActions from '../../../actions/VoterActions';
import VoterSessionActions from '../../../actions/VoterSessionActions';
import LoadingWheel from '../Widgets/LoadingWheel';
import { isAndroid, restoreStylesAfterCordovaKeyboard } from '../../utils/cordovaUtils';
import historyPush from '../../utils/historyPush';
import { normalizedHref } from '../../utils/hrefUtils';
import { isWebApp } from '../../utils/isCordovaOrWebApp';
import Cookies from '../../utils/js-cookie/Cookies';
import { oAuthLog, renderLog } from '../../utils/logging';
import stringContains from '../../utils/stringContains';
import AppObservableStore, { messageService } from '../../stores/AppObservableStore';
import FacebookStore from '../../../stores/FacebookStore';
import VoterStore from '../../../stores/VoterStore';
import initializeAppleSDK from '../../../utils/initializeAppleSDK';
import initializeFacebookSDK from '../../../utils/initializeFacebookSDK';
import AppleSignIn from '../../../components/Apple/AppleSignIn';
import FacebookSignIn from '../../../components/Facebook/FacebookSignIn';
import VoterEmailAddressEntry from '../../../components/Settings/VoterEmailAddressEntry';
import VoterPhoneVerificationEntry from '../../../components/Settings/VoterPhoneVerificationEntry';
import TwitterSignIn from '../../../components/Twitter/TwitterSignIn';
import BrowserPushMessage from '../../../components/Widgets/BrowserPushMessage';
import FacebookStore from '../../../stores/FacebookStore';
import VoterStore from '../../../stores/VoterStore';
import initializeAppleSDK from '../../../utils/initializeAppleSDK';
import initializeFacebookSDK from '../../../utils/initializeFacebookSDK';
import AppObservableStore, { messageService } from '../../stores/AppObservableStore';
import { isAndroid, restoreStylesAfterCordovaKeyboard } from '../../utils/cordovaUtils';
import historyPush from '../../utils/historyPush';
import { normalizedHref } from '../../utils/hrefUtils';
import { isCordova, isWebApp } from '../../utils/isCordovaOrWebApp';
import Cookies from '../../utils/js-cookie/Cookies';
import { oAuthLog, renderLog } from '../../utils/logging';
import stringContains from '../../utils/stringContains';
import LoadingWheel from '../Widgets/LoadingWheel';
import signInModalGlobalState from '../Widgets/signInModalGlobalState';
import SnackNotifier, { openSnackbar } from '../Widgets/SnackNotifier';

Expand Down Expand Up @@ -685,6 +685,7 @@ const SignInOptionsPanelWrapper = styled('div')`
display: flex;
justify-content: center;
width: 100%;
${() => (isCordova() ? { paddingTop: '10px' } : {})}
`;

const SignInSubtitle = styled('p')`
Expand Down
1 change: 0 additions & 1 deletion src/js/common/components/Style/CampaignDetailsStyles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ export const SupportButtonFooterWrapperAboveFooterButtons = styled('div')`
if (isAndroid()) return '68px';
return '88px';
}};
display: ${() => (isCordova() ? 'none' : 'block')};
`;

export const SupportButtonPanel = styled('div')`
Expand Down
4 changes: 3 additions & 1 deletion src/js/common/components/Style/CampaignSupportStyles.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from 'styled-components';
import { isCordova, isWebApp } from '../../utils/isCordovaOrWebApp';

export const CampaignSupportDesktopButtonPanel = styled('div')`
background-color: #fff;
Expand Down Expand Up @@ -60,11 +61,12 @@ export const CampaignSupportSectionWrapper = styled('div', {

export const SkipForNowButtonPanel = styled('div')`
background-color: #fff;
margin-top: 40px;
margin-top: ${isWebApp() ? '40px' : ''};
`;

export const SkipForNowButtonWrapper = styled('div')`
display: flex;
justify-content: center;
width: 100%;
${isCordova() ? 'padding-bottom: 16px' : ''};
`;
2 changes: 2 additions & 0 deletions src/js/common/components/Style/stepDisplayStyles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from 'styled-components';
import { isCordova } from '../../utils/isCordovaOrWebApp';

export const InnerWrapper = styled('div')`
display: flex;
Expand Down Expand Up @@ -39,6 +40,7 @@ export const OuterWrapperStepsOff = styled('div')(({ theme }) => (`
export const PageWrapper = styled('div')`
margin: 0 auto;
max-width: 960px;
${isCordova() ? 'padding-top: 14px' : ''};
@media (max-width: 1005px) {
// Switch to 15px left/right margin when auto is too small
margin: 0 15px;
Expand Down
15 changes: 11 additions & 4 deletions src/js/common/pages/Settings/CompleteYourProfileMobile.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Close } from '@mui/icons-material';
import { IconButton } from '@mui/material';
import styled from 'styled-components';
import withStyles from '@mui/styles/withStyles';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Helmet } from 'react-helmet-async';
import styled from 'styled-components';
import CompleteYourProfile from '../../components/Settings/CompleteYourProfile';
import { OuterWrapper } from '../../components/Style/stepDisplayStyles';
import AppObservableStore, { messageService } from '../../stores/AppObservableStore';
import historyPush from '../../utils/historyPush';
import { isCordova, isWebApp } from '../../utils/isCordovaOrWebApp';
import { renderLog } from '../../utils/logging';
import CompleteYourProfile from '../../components/Settings/CompleteYourProfile';
import AppObservableStore, { messageService } from '../../stores/AppObservableStore';


class CompleteYourProfileMobile extends Component {
Expand Down Expand Up @@ -116,7 +117,7 @@ class CompleteYourProfileMobile extends Component {
{completeProfileTitle}
<IconButton
aria-label="Close"
classes={{ root: classes.closeButton }}
classes={isWebApp() ? { root: classes.closeButton } : { root: classes.closeButtonCordova }}
onClick={() => { this.cancelFunction(); }}
id="completeYourProfileMobileClose"
size="large"
Expand Down Expand Up @@ -158,6 +159,11 @@ const styles = () => ({
right: 0,
top: 0,
},
closeButtonCordova: {
position: 'absolute',
right: 5,
top: 50,
},
});

const ContentTitle = styled('h1')(({ theme }) => (`
Expand All @@ -175,6 +181,7 @@ const InnerWrapper = styled('div')`
const PageWrapperComplete = styled('div')`
margin: 0 auto;
max-width: 480px;
${() => (isCordova() ? 'padding: 28px 0 100px 0;' : '')};
`;

export default withStyles(styles)(CompleteYourProfileMobile);
34 changes: 11 additions & 23 deletions src/js/components/Friends/FindFriendsStart.jsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import withStyles from '@mui/styles/withStyles';
import { Button } from '@mui/material';
import withStyles from '@mui/styles/withStyles';
import { filter } from 'lodash-es';
import PropTypes from 'prop-types';
import React, { Component, Suspense } from 'react';
import styled from 'styled-components';
import FriendActions from '../../actions/FriendActions';
import BallotActions from '../../actions/BallotActions';
import FriendActions from '../../actions/FriendActions';
import VoterActions from '../../actions/VoterActions';
// import NextStepButtons from '../FriendIntro/NextStepButtons';
import AppObservableStore from '../../common/stores/AppObservableStore';
import apiCalming from '../../common/utils/apiCalming';
import { isCordovaWide } from '../../common/utils/cordovaUtils';
import historyPush from '../../common/utils/historyPush';
import { isWebApp } from '../../common/utils/isCordovaOrWebApp';
import { renderLog } from '../../common/utils/logging';
import normalizedImagePath from '../../common/utils/normalizedImagePath';
import VoterStore from '../../stores/VoterStore';
import DownloadAppsButtons from '../Remind/DownloadAppsButtons';
import Reassurance from '../SetUpAccount/Reassurance';
import { reassuranceTextRemindContacts } from '../Remind/reassuranceTextRemindContacts';
// import NextStepButtons from '../FriendIntro/NextStepButtons';
import AppObservableStore from '../../common/stores/AppObservableStore';
import VoterStore from '../../stores/VoterStore';
import {
DesktopNextButtonsInnerWrapper, DesktopNextButtonsOuterWrapperUShowDesktopTablet,
} from '../Style/NextButtonStyles';
import Reassurance from '../SetUpAccount/Reassurance';
import { DesktopNextButtonsInnerWrapper, DesktopNextButtonsOuterWrapperUShowDesktopTablet } from '../Style/NextButtonStyles';
import { RemindContactsImportText, RemindMainImageImg } from '../Style/RemindStyles';
import {
SetUpAccountContactsText,
SetUpAccountContactsTextWrapper,
SetUpAccountTitle, SetUpAccountTop,
} from '../Style/SetUpAccountStyles';
import { SetUpAccountContactsText, SetUpAccountContactsTextWrapper, SetUpAccountTitle, SetUpAccountTop } from '../Style/SetUpAccountStyles';
import { SetUpSignInOptionsPanelWrapper } from '../Style/SignInStyles';

const AddContactsFromGoogleButton = React.lazy(() => import(/* webpackChunkName: 'AddContactsFromGoogleButton' */ '../SetUpAccount/AddContactsFromGoogleButton'));
const ContactsImportedPreview = React.lazy(() => import(/* webpackChunkName: 'ContactsImportedPreview' */ './ContactsImportedPreview'));
Expand Down Expand Up @@ -149,14 +144,14 @@ class FindFriendsStart extends Component {
<Suspense fallback={<></>}>
<ContactsImportedPreview showOnlyContactsWithAccounts />
</Suspense>
<SignInOptionsPanelWrapper>
<SetUpSignInOptionsPanelWrapper>
<Suspense fallback={<></>}>
<SignInOptionsPanel
pleaseSignInTitle={(contactsWithAccountCount > 0) ? 'Sign in to connect with your friends' : ''}
pleaseSignInSubTitle={(contactsWithAccountCount > 0) ? 'After you sign in, you will be able to choose which friends to collaborate with.' : ''}
/>
</Suspense>
</SignInOptionsPanelWrapper>
</SetUpSignInOptionsPanelWrapper>
</FindFriendsStartWithContactsWrapper>
) : (
<FindFriendsStartWrapper>
Expand Down Expand Up @@ -252,11 +247,4 @@ const FindFriendsStartWrapper = styled('div')`
margin-top: 36px;
`;

const SignInOptionsPanelWrapper = styled('div')(({ theme }) => (`
margin-top: 32px;
${theme.breakpoints.up('sm')} {
min-width: 500px;
}
`));

export default withStyles(styles)(FindFriendsStart);
1 change: 1 addition & 0 deletions src/js/components/Navigation/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const FooterMainWrapper = styled('div')`
`;

const FooterWrapper = styled('div')`
// In Cordova, display=none, can be set in prepareForCordovaKeyboard()
`;

export default withStyles(styles)(Footer);
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { Suspense } from 'react';
import styled from 'styled-components';
import VoterActions from '../../actions/VoterActions';
import apiCalming from '../../common/utils/apiCalming';
import { SetUpSignInOptionsPanelWrapper } from '../Style/SignInStyles';
import { renderLog } from '../../common/utils/logging';
import VoterStore from '../../stores/VoterStore';
import {
Expand Down Expand Up @@ -144,14 +145,14 @@ class SetUpAccountInviteContactsSignIn extends React.Component {
<Suspense fallback={<></>}>
<ContactsImportedPreview showOnlyContactsWithAccounts />
</Suspense>
<SignInOptionsPanelWrapper>
<SetUpSignInOptionsPanelWrapper>
<Suspense fallback={<></>}>
<SignInOptionsPanel
pleaseSignInTitle={(contactsWithAccountCount > 0) ? 'Sign in to connect with your friends' : ''}
pleaseSignInSubTitle={(contactsWithAccountCount > 0) ? 'After you sign in, you will be able to choose which friends to collaborate with.' : ''}
/>
</Suspense>
</SignInOptionsPanelWrapper>
</SetUpSignInOptionsPanelWrapper>
</StepCenteredWrapper>
);
}
Expand All @@ -165,11 +166,5 @@ const CircularProgressWrapper = styled('div')`
margin-top: 12px;
`;

const SignInOptionsPanelWrapper = styled('div')(({ theme }) => (`
margin-top: 32px;
${theme.breakpoints.up('sm')} {
min-width: 500px;
}
`));

export default SetUpAccountInviteContactsSignIn;
Loading