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

Custom Labels Step 2 #1120

Merged
merged 49 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1b57f5e
show customized modes (used dummy data for now)
jiji14 Dec 1, 2023
cad2d7c
fix prettier issu
jiji14 Dec 1, 2023
74e2dfe
fetch post/mode
jiji14 Dec 4, 2023
0402a34
use displayErrorMsg
jiji14 Dec 4, 2023
09b56ee
Done with fetching data to server
jiji14 Dec 7, 2023
a3cb1f2
update mode - old mode and new mode
jiji14 Dec 8, 2023
abc7f8a
Change modes type to string array and call it when modal opens
jiji14 Dec 11, 2023
cb1c491
add comments
jiji14 Dec 11, 2023
0a7a4ba
change mode text in a desired format (ex) my_car => My Car
jiji14 Dec 12, 2023
8ba3fb6
add default mode & custom mode label
jiji14 Dec 13, 2023
aa18e98
noted that getModes & updateMode need to be tested after e2e testing …
jiji14 Dec 14, 2023
7548de7
reuse existing common function and delete the original function
jiji14 Dec 18, 2023
01c1afe
use dynamic color
jiji14 Dec 18, 2023
b5a63be
change logic for showing custom modes before 'other' option
jiji14 Dec 18, 2023
f64d719
change function names more descriptive
jiji14 Dec 18, 2023
14c4438
delete unnecessary variable and change variable names more intuitive
jiji14 Dec 18, 2023
447e7e2
add new translation entry
jiji14 Dec 18, 2023
0509d5e
Fetch custom modes on initial rendering to prevent unnecessary api calls
jiji14 Dec 27, 2023
23f4758
add 'custom modes' tab in Profile
jiji14 Dec 27, 2023
0ef37b4
Move customModes state to AppContext to be shared between the 'Label'…
jiji14 Dec 27, 2023
de9008f
separate the component for clean code
jiji14 Dec 27, 2023
07f4534
Add insert user custom mode feature
jiji14 Dec 29, 2023
189f79d
check if inputType is 'MODE' for custom mode label
jiji14 Jan 3, 2024
643ae90
Modify the mode functions to encompass all types of labels (purpose, …
jiji14 Jan 5, 2024
315561e
Merge branch 'customize-modes' into customize-modes-step2
jiji14 Jan 8, 2024
939480f
fix merge conflict related to LabelTabContext
jiji14 Jan 9, 2024
bf3754d
Done with "manage custom labels" in profile setting tab
jiji14 Jan 9, 2024
01a3729
fix radio button issue when 'other' option is selected
jiji14 Jan 9, 2024
8cec495
change variable names for better understanding
jiji14 Jan 9, 2024
606816b
update radio button comment
jiji14 Jan 9, 2024
2d7352b
combine replaced_mode and mode
jiji14 Jan 11, 2024
32e5708
Merge branch 'customize-modes' into customize-modes-step2
jiji14 Jan 11, 2024
5f87ab3
update merge changes
jiji14 Jan 11, 2024
d02d7aa
combine mode and replaced_mode for Label Setting
jiji14 Jan 11, 2024
f5f5551
error handling for empty label array
jiji14 Jan 12, 2024
4192269
add skipped test functions
jiji14 Jan 12, 2024
0e0569e
Change list title "edit custom labels" -> "manage custom labels""
jiji14 Jan 12, 2024
7eb31dd
Merge branch 'service_rewrite_2023' into customize-modes-step2
jiji14 Jan 12, 2024
2a1a12c
Merge branch 'customize-modes' of https://github.com/jiji14/e-mission…
JGreenlee Feb 9, 2024
0c87797
bump 'react-native-paper' to ^5.11.0
JGreenlee Feb 9, 2024
7e09923
Merge branch 'master' into customize-modes-step2
jiji14 Feb 9, 2024
ae66eff
fix label context issue after merge
jiji14 Feb 15, 2024
3453205
ignore commHelper from coverage report
jiji14 Feb 15, 2024
26264ce
delete not operator
jiji14 Feb 16, 2024
cba51b8
add comment why we need to ingnore commHelper in coverage report
jiji14 Feb 17, 2024
96386a3
delete duplicated code
jiji14 Feb 17, 2024
15c994a
show customLabel setting conditionally
jiji14 Feb 17, 2024
45bfc2d
Merge branch 'master' into customize-modes-step2
JGreenlee Mar 25, 2024
52b0fb9
Merge branch 'master' of https://github.com/e-mission/e-mission-phone…
JGreenlee Jul 12, 2024
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
Prev Previous commit
Merge branch 'master' of https://github.com/e-mission/e-mission-phone
…into customize-modes-step2
  • Loading branch information
JGreenlee committed Jul 12, 2024
commit 52b0fb9e40aefb0b483e578eefb22bd06e51dadd
3 changes: 2 additions & 1 deletion .github/workflows/android-automated-sdk-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ on:
push:
paths:
- 'setup/prereq_android_sdk_install.sh'
- 'setup/android_sdk_packages'
- '.github/workflows/android-automated-sdk-install.yml'
pull_request:
paths:
- 'setup/prereq_android_sdk_install.sh'
- 'setup/android_sdk_packages'
- '.github/workflows/android-automated-sdk-install.yml'
schedule:
# * is a special character in YAML so you have to quote this string
Expand Down Expand Up @@ -64,7 +66,6 @@ jobs:
ls -al $ANDROID_SDK_ROOT
if [ ! -d $ANDROID_SDK_ROOT/emulator ]; then exit 1; fi
if [ ! -d $ANDROID_SDK_ROOT/build-tools ]; then exit 1; fi
if [ ! -d $ANDROID_SDK_ROOT/patcher ]; then exit 1; fi
if [ ! -d $ANDROID_SDK_ROOT/extras ]; then exit 1; fi
if [ ! -d $ANDROID_SDK_ROOT/platforms ]; then exit 1; fi
if [ ! -d $ANDROID_SDK_ROOT/platform-tools ]; then exit 1; fi
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,24 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: macos-14

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Prints related environment variables so that we can know what to set
run: env | egrep "JAVA|PATH|ANDROID"

# Runs a single command using the runners shell
- name: Print the java and gradle versions
run: |
echo "Default java version"
java -version
echo "Setting to Java 11 instead"
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_arm64
java -version
echo "Checking gradle"
which gradle
Expand All @@ -49,13 +53,13 @@ jobs:
- name: Setup the cordova environment
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_arm64
bash setup/setup_android_native.sh

- name: Check tool versions
shell: bash -l {0}
run: |
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_arm64
source setup/activate_native.sh
echo "cordova version"
npx cordova -version
Expand All @@ -73,7 +77,7 @@ jobs:
gradle -version
echo "Let's rerun the activation"
source setup/activate_native.sh
export JAVA_HOME=$JAVA_HOME_11_X64
export JAVA_HOME=$JAVA_HOME_17_arm64
echo $PATH
which gradle
gradle --version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jobs:
npx jest

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
flags: unit
fail_ci_if_error: ${{ github.repository == 'e-mission/e-mission-phone' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: macos-14

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ https://github.com/e-mission/e-mission-docs/tree/master/docs/e-mission-phone

Updating the UI only
---
[![osx-serve-install](https://github.com/e-mission/e-mission-phone/workflows/osx-serve-install/badge.svg)](https://github.com/e-mission/e-mission-phone/actions?query=workflow%3Aosx-serve-install)
[![osx-serve-install](https://github.com/e-mission/e-mission-phone/workflows/osx-serve-install/badge.svg?branch=master&event=push)](https://github.com/e-mission/e-mission-phone/actions?query=workflow%3Aosx-serve-install)

If you want to make only UI changes, (as opposed to modifying the existing plugins, adding new plugins, etc), you can use the **new and improved** (as of June 2018) [e-mission dev app](https://github.com/e-mission/e-mission-devapp/) and install the most recent version from [releases](https://github.com/e-mission/e-mission-devapp/releases).

Expand Down Expand Up @@ -87,9 +87,9 @@ If you wish to connect to a different server, create your own config file accord

Updating the e-mission-\* plugins or adding new plugins
---
[![osx-build-ios](https://github.com/e-mission/e-mission-phone/actions/workflows/ios-build.yml/badge.svg)](https://github.com/e-mission/e-mission-phone/actions/workflows/ios-build.yml)
[![osx-build-android](https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml/badge.svg)](https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml)
[![osx-android-prereq-sdk-install](https://github.com/e-mission/e-mission-phone/actions/workflows/android-automated-sdk-install.yml/badge.svg)](https://github.com/e-mission/e-mission-phone/actions/workflows/android-automated-sdk-install.yml)
[![osx-build-ios](https://github.com/e-mission/e-mission-phone/actions/workflows/ios-build.yml/badge.svg?branch=master&event=push)](https://github.com/e-mission/e-mission-phone/actions/workflows/ios-build.yml?event-push)
[![osx-build-android](https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml/badge.svg?branch=master&event=push)](https://github.com/e-mission/e-mission-phone/actions/workflows/android-build.yml?event=push)
[![osx-android-prereq-sdk-install](https://github.com/e-mission/e-mission-phone/actions/workflows/android-automated-sdk-install.yml/badge.svg?branch=master&event=push)](https://github.com/e-mission/e-mission-phone/actions/workflows/android-automated-sdk-install.yml?event=push)

Pre-requisites
---
Expand Down
2 changes: 2 additions & 0 deletions config.cordovabuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<platform name="ios">
<preference name="deployment-target" value="13.0"/>
<hook src="hooks/before_build/ios/ios_change_deployment.js" type="before_build" />
<hook src="hooks/after_platform_add/ios/ios_copy_locales.js" type="after_platform_add" />
<resource-file src="GoogleService-Info.plist" />
<preference name="WKWebViewOnly" value="true" />
Expand Down
37 changes: 37 additions & 0 deletions hooks/before_build/ios/ios_change_deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs');
const path = require('path');

function findFilePathsByFilename(directory, filename) {
const files = fs.readdirSync(directory);
const filePaths = [];

for (const file of files) {
const filePath = path.join(directory, file);
const stats = fs.statSync(filePath);

if (stats.isDirectory()) {
// Recursively search in subdirectories
const subdirectoryFilePaths = findFilePathsByFilename(filePath, filename);
filePaths.push(...subdirectoryFilePaths);
} else if (stats.isFile() && file === filename) {
// If the file matches the filename, add its path to the result
filePaths.push(filePath);
}
}
return filePaths;
}


const paths1 = findFilePathsByFilename('.', 'project.pbxproj');
const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj');
const paths = paths1.concat(paths2)

console.log('Apply patch to', paths);

for (let path of paths) {
let content = fs.readFileSync(path, { encoding: 'utf-8' });
content = content.replace(/IPHONEOS_DEPLOYMENT_TARGET = [0-9]+.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 13.0;');
fs.writeFileSync(path, content);
}

console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET');
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ module.exports = {
"^.+\\.(ts|tsx|js|jsx)$": "babel-jest"
},
transformIgnorePatterns: [
"node_modules/(?!((enketo-transformer/dist/enketo-transformer/web)|(jest-)?react-native(-.*)?|@react-native(-community)?)/)",
"node_modules/(?!((enketo-transformer/dist/enketo-transformer/web)|(jest-)?react-native(-.*)?|@react-native(-community)?|e-mission-common)/)"
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
moduleDirectories: ["node_modules", "src"],
globals: {"__DEV__": false},
collectCoverage: true,
collectCoverageFrom: [
"www/js/**/*.{ts,tsx,js,jsx}",
"!www/js/**/index.{ts,tsx,js,jsx}",
"!www/js/types/**/*.{ts,tsx,js,jsx}",
],
// several functions in commHelper do not have unit tests; see note in commHelper.test.ts
coveragePathIgnorePatterns: ['www/js/services/commHelper.ts'],
};
15 changes: 7 additions & 8 deletions package.cordovabuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@babel/preset-typescript": "^7.21.4",
"@ionic/cli": "6.20.8",
"@types/luxon": "^3.3.0",
"@types/react": "^18.2.20",
"@types/react": "~18.2.0",
"babel-loader": "^9.1.2",
"babel-plugin-optional-require": "^0.3.1",
"concurrently": "^8.0.1",
Expand Down Expand Up @@ -67,7 +67,6 @@
"ANDROID_HOST": " ",
"ANDROID_PATHPREFIX": "/"
},
"cordova-plugin-email-composer": {},
"cordova-plugin-x-socialsharing": {
"PHOTO_LIBRARY_ADD_USAGE_DESCRIPTION": "This app requires photo library access to share photos on social media.",
"PHOTO_LIBRARY_USAGE_DESCRIPTION": "This app requires photo library access to share photos on social media."
Expand Down Expand Up @@ -121,14 +120,13 @@
"cordova-plugin-app-version": "0.1.14",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-device": "2.1.0",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.8.3",
"cordova-plugin-em-datacollection": "git+https://github.com/e-mission/e-mission-data-collection.git#v1.8.8",
"cordova-plugin-em-opcodeauth": "git+https://github.com/e-mission/cordova-jwt-auth.git#v1.7.2",
"cordova-plugin-em-server-communication": "git+https://github.com/e-mission/cordova-server-communication.git#v1.2.6",
"cordova-plugin-em-serversync": "git+https://github.com/e-mission/cordova-server-sync.git#v1.3.2",
"cordova-plugin-em-settings": "git+https://github.com/e-mission/cordova-connection-settings.git#v1.2.3",
"cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.6",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.8",
"cordova-plugin-email-composer": "git+https://github.com/katzer/cordova-plugin-email-composer.git#0.10.1",
"cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.9",
"cordova-plugin-file": "8.0.0",
"cordova-plugin-inappbrowser": "5.0.0",
"cordova-plugin-ionic-keyboard": "2.2.0",
Expand All @@ -139,6 +137,7 @@
"cordova-custom-config": "^5.1.1",
"cordova-plugin-ibeacon": "git+https://github.com/louisg1337/cordova-plugin-ibeacon.git",
"core-js": "^2.5.7",
"e-mission-common": "github:JGreenlee/e-mission-common#semver:0.5.1",
"enketo-core": "^6.1.7",
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
Expand All @@ -150,11 +149,11 @@
"leaflet": "^1.9.4",
"luxon": "^3.3.0",
"npm": "^9.6.3",
"phonegap-plugin-barcodescanner": "git+https://github.com/phonegap/phonegap-plugin-barcodescanner#v8.1.0",
"phonegap-plugin-barcodescanner": "git+https://github.com/e-mission/phonegap-plugin-barcodescanner.git",
"prop-types": "^15.8.1",
"react": "^18.2.*",
"react": "~18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.*",
"react-dom": "~18.2.0",
"react-i18next": "^13.5.0",
"react-native-paper": "^5.11.0",
"react-native-paper-dates": "^0.18.12",
Expand Down
8 changes: 5 additions & 3 deletions package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@ionic/cli": "6.20.8",
"@testing-library/react-native": "^12.3.0",
"@types/luxon": "^3.3.0",
"@types/react": "^18.2.20",
"@types/react": "~18.2.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.2",
"babel-plugin-optional-require": "^0.3.1",
Expand All @@ -40,6 +40,7 @@
"jest-environment-jsdom": "^29.7.0",
"phonegap": "9.0.0+cordova.9.0.0",
"process": "^0.11.10",
"react-test-renderer": "~18.2.0",
"sass": "^1.62.1",
"sass-loader": "^13.3.1",
"style-loader": "^3.3.3",
Expand All @@ -64,6 +65,7 @@
"chartjs-adapter-luxon": "^1.3.1",
"chartjs-plugin-annotation": "^3.0.1",
"core-js": "^2.5.7",
"e-mission-common": "github:JGreenlee/e-mission-common#semver:0.5.1",
"enketo-core": "^6.1.7",
"enketo-transformer": "^4.0.0",
"fast-xml-parser": "^4.2.2",
Expand All @@ -76,9 +78,9 @@
"luxon": "^3.3.0",
"npm": "^9.6.3",
"prop-types": "^15.8.1",
"react": "^18.2.*",
"react": "~18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.*",
"react-dom": "~18.2.0",
"react-i18next": "^13.5.0",
"react-native-paper": "^5.11.0",
"react-native-paper-dates": "^0.18.12",
Expand Down
2 changes: 1 addition & 1 deletion setup/export_shared_dep_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export NPM_VERSION=9.3.1
# ideally, this would be the same version as the CI
# Looks like brew supports only major and minor, not patch version
export RUBY_VERSION=3.0
export COCOAPODS_VERSION=1.11.3
export COCOAPODS_VERSION=1.12.1
export GRADLE_VERSION=7.6
export OSX_EXP_VERSION=12

Expand Down
4 changes: 3 additions & 1 deletion www/__mocks__/cordovaMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const mockBEMUserCache = (config?) => {
}, 100),
);
} else {
return undefined;
return Promise.resolve([]);
}
},
};
Expand Down Expand Up @@ -229,6 +229,8 @@ export const mockBEMServerCom = () => {
}, 100);
},
};
window['cordova'] ||= {};
window['cordova'].plugins ||= {};
window['cordova'].plugins.BEMServerComm = mockBEMServerCom;
};

Expand Down
26 changes: 26 additions & 0 deletions www/__tests__/Carousel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { View } from 'react-native';
import Carousel from '../js/components/Carousel';

describe('Carousel component', () => {
const child1 = <View testID="child1">Child 1</View>;
const child2 = <View testID="child2">Child 2</View>;
const cardWidth = 100;
const cardMargin = 10;

it('renders children correctly', () => {
const { getByTestId } = render(
<Carousel cardWidth={cardWidth} cardMargin={cardMargin}>
{child1}
{child2}
</Carousel>,
);

const renderedChild1 = getByTestId('child1');
const renderedChild2 = getByTestId('child2');

expect(renderedChild1).toBeTruthy();
expect(renderedChild2).toBeTruthy();
});
});
19 changes: 19 additions & 0 deletions www/__tests__/DateSelect.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, screen } from '@testing-library/react-native';
import DateSelect from '../js/diary/list/DateSelect';

jest.mock('react-native-safe-area-context', () => ({
useSafeAreaInsets: () => ({ bottom: 30, left: 0, right: 0, top: 30 }),
}));
jest.spyOn(React, 'useState').mockImplementation((initialValue) => [initialValue, jest.fn()]);
jest.spyOn(React, 'useEffect').mockImplementation((effect: () => void) => effect());

describe('DateSelect', () => {
it('renders correctly', () => {
const onChooseMock = jest.fn();
const { getByText } = render(<DateSelect mode="range" onChoose={onChooseMock} />);

expect(screen.getByTestId('button-container')).toBeTruthy();
expect(screen.getByTestId('button')).toBeTruthy();
});
});
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.