diff --git a/.env.example b/.env.example
index da38ca1c0b..afc4dc09a6 100644
--- a/.env.example
+++ b/.env.example
@@ -7,6 +7,7 @@ PHRASE_API_KEY_DEV=
# [Optional] Mudita Center Server URL to access to external services via proxy
MUDITA_CENTER_SERVER_URL=
+MUDITA_CENTER_SERVER_V2_URL=
# [Optional] Rollbar Token needed to connect user’s app with Rollbar account.
ROLLBAR_TOKEN=
@@ -55,20 +56,14 @@ FEATURE_TOGGLE_RELEASE_ENVIRONMENT=
# [Optional] Enable Mudita Center prerelease feature. Disabled by default, set "1" to enable
MUDITA_CENTER_PRERELEASE_ENABLED=
-# [Optional] Path to your Google service account key file. Required for authentication with the Google Sheets API.
-MATOMO_TO_GSHEET_KEYFILEPATH=
-
-# [Optional] The ID of the Google Sheet where Matomo data will be written. Found in the URL of your Google Sheet.
-MATOMO_TO_GSHEET_SPREADSHEET_ID=
-
-# [Optional] The base URL for the Matomo API. This is where API requests will be sent to fetch analytics data.
-MATOMO_TO_GSHEET_API_URL=
+# [Optional] Set 1 run application with mock server
+MOCK_SERVICE_ENABLED=
-# [Optional] Your Matomo API token. Required for accessing data from your Matomo account through the API.
-MATOMO_TO_GSHEET_TOKEN=
+# [Optional] Enable shortcut for opening DevTools. Disabled by default, set "1" to enable
+DEV_TOOLS_SHORTCUT_ENABLED=
-# [Optional] The site ID for your website as registered in Matomo. Used to specify which site's data to fetch.
-MATOMO_TO_GSHEET_SITE_ID=
+# [Optional] Automatically open DevTools on startup. Disabled by default, set "1" to enable
+DEV_TOOLS_AUTO_OPEN_ENABLED=
-# [Optional] Set 1 run application with mock server
-MOCK_SERVICE_ENABLED=
+# [Optional] Allows to show unpublished content in Help. Disabled by default, set a secret token to enable
+DEV_HELP_PREVIEW_TOKEN=
diff --git a/.github/workflows/e2e-development.yml b/.github/workflows/e2e-development.yml
index f12cf2cf71..fcbb2308ec 100644
--- a/.github/workflows/e2e-development.yml
+++ b/.github/workflows/e2e-development.yml
@@ -24,6 +24,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -54,4 +55,4 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- npm run e2e:test:linux
+ npm run e2e:test:cicd:standalone
diff --git a/.github/workflows/e2e-feature-branch.yml b/.github/workflows/e2e-feature-branch.yml
index 86754f01e7..3961132b44 100644
--- a/.github/workflows/e2e-feature-branch.yml
+++ b/.github/workflows/e2e-feature-branch.yml
@@ -25,6 +25,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -55,4 +56,4 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- npm run e2e:test:linux
+ npm run e2e:test:cicd:standalone
diff --git a/.github/workflows/e2e-pre-production.yml b/.github/workflows/e2e-pre-production.yml
index 2ab98c7cad..751c6b8648 100644
--- a/.github/workflows/e2e-pre-production.yml
+++ b/.github/workflows/e2e-pre-production.yml
@@ -26,6 +26,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -56,4 +57,4 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- npm run e2e:test:linux
+ npm run e2e:test:cicd:standalone
diff --git a/.github/workflows/e2e-production.yml b/.github/workflows/e2e-production.yml
index 1eadf059a9..317bb4e03c 100644
--- a/.github/workflows/e2e-production.yml
+++ b/.github/workflows/e2e-production.yml
@@ -26,6 +26,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -56,4 +57,4 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y xvfb
- npm run e2e:test:linux
+ npm run e2e:test:cicd:standalone
diff --git a/.github/workflows/nexus-development.yml b/.github/workflows/nexus-development.yml
index 9ad74baf69..a2a089d3d3 100644
--- a/.github/workflows/nexus-development.yml
+++ b/.github/workflows/nexus-development.yml
@@ -26,6 +26,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -43,6 +44,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
LOCALAPPDATA: ""
shell: cmd
run: |
@@ -55,6 +57,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -72,6 +75,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
run: |
printenv > .env
- name: Setup Env for Linux
@@ -81,6 +85,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -98,6 +103,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
run: |
printenv > .env
- name: Changing app version in packages.json for Linux
diff --git a/.github/workflows/nexus-feature-branch.yml b/.github/workflows/nexus-feature-branch.yml
index 224e482a63..05fe3307ab 100644
--- a/.github/workflows/nexus-feature-branch.yml
+++ b/.github/workflows/nexus-feature-branch.yml
@@ -26,6 +26,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -43,6 +44,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
LOCALAPPDATA: ""
shell: cmd
run: |
@@ -55,6 +57,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -72,6 +75,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
run: |
printenv > .env
- name: Setup Env for Linux
@@ -81,6 +85,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -98,6 +103,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
run: |
printenv > .env
- name: Changing app version in packages.json for Linux
diff --git a/.github/workflows/nexus-mass-update.yml b/.github/workflows/nexus-mass-update.yml
index d5b89e3a00..955b5abfdc 100644
--- a/.github/workflows/nexus-mass-update.yml
+++ b/.github/workflows/nexus-mass-update.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -57,6 +58,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -83,6 +85,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
diff --git a/.github/workflows/nexus-mock-development.yml b/.github/workflows/nexus-mock-development.yml
index dcfb923f8b..12a1f29e2a 100644
--- a/.github/workflows/nexus-mock-development.yml
+++ b/.github/workflows/nexus-mock-development.yml
@@ -26,6 +26,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -43,6 +44,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
LOCALAPPDATA: ""
MOCK_SERVICE_ENABLED: "1"
shell: cmd
@@ -56,6 +58,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -73,6 +76,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
MOCK_SERVICE_ENABLED: "1"
run: |
printenv > .env
@@ -83,6 +87,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -101,6 +106,7 @@ jobs:
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
MOCK_SERVICE_ENABLED: "1"
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
run: |
printenv > .env
- name: Changing app version in packages.json for Linux
diff --git a/.github/workflows/nexus-mock-pre-production.yml b/.github/workflows/nexus-mock-pre-production.yml
index d32697c93a..6c357357fc 100644
--- a/.github/workflows/nexus-mock-pre-production.yml
+++ b/.github/workflows/nexus-mock-pre-production.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -45,6 +46,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
LOCALAPPDATA: ""
MOCK_SERVICE_ENABLED: "1"
shell: cmd
@@ -58,6 +60,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -75,6 +78,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
MOCK_SERVICE_ENABLED: "1"
run: |
printenv > .env
diff --git a/.github/workflows/nexus-mock-production.yml b/.github/workflows/nexus-mock-production.yml
index febb639529..a779823660 100644
--- a/.github/workflows/nexus-mock-production.yml
+++ b/.github/workflows/nexus-mock-production.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -45,6 +46,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
LOCALAPPDATA: ""
MOCK_SERVICE_ENABLED: "1"
shell: cmd
@@ -58,6 +60,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -75,6 +78,7 @@ jobs:
DEV_DEVICE_LOGGER_ENABLED: ${{ secrets.DEV_DEVICE_LOGGER_ENABLED }}
FEATURE_TOGGLE_RELEASE_ENVIRONMENT: ${{ secrets.FEATURE_TOGGLE_RELEASE_ENVIRONMENT }}
MUDITA_CENTER_PRERELEASE_ENABLED: ${{ secrets.MUDITA_CENTER_PRERELEASE_ENABLED }}
+ DEV_TOOLS_SHORTCUT_ENABLED: "1"
MOCK_SERVICE_ENABLED: "1"
run: |
printenv > .env
diff --git a/.github/workflows/nexus-pre-production-latest.yml b/.github/workflows/nexus-pre-production-latest.yml
index 1a960e842a..a1dbfe02aa 100644
--- a/.github/workflows/nexus-pre-production-latest.yml
+++ b/.github/workflows/nexus-pre-production-latest.yml
@@ -29,6 +29,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -58,6 +59,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -84,6 +86,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
diff --git a/.github/workflows/nexus-pre-production.yml b/.github/workflows/nexus-pre-production.yml
index 2edea49b76..1373c40d7f 100644
--- a/.github/workflows/nexus-pre-production.yml
+++ b/.github/workflows/nexus-pre-production.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -57,6 +58,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
diff --git a/.github/workflows/nexus-production-with-os-rc.yml b/.github/workflows/nexus-production-with-os-rc.yml
index 8512e2a224..8742ecad96 100644
--- a/.github/workflows/nexus-production-with-os-rc.yml
+++ b/.github/workflows/nexus-production-with-os-rc.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -57,6 +58,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -83,6 +85,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
diff --git a/.github/workflows/nexus-production.yml b/.github/workflows/nexus-production.yml
index bac9443461..ed3e0b0423 100644
--- a/.github/workflows/nexus-production.yml
+++ b/.github/workflows/nexus-production.yml
@@ -28,6 +28,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
@@ -57,6 +58,7 @@ jobs:
PHRASE_API_URL: ${{ secrets.PHRASE_API_URL }}
PHRASE_API_KEY_DEV: ${{ secrets.PHRASE_API_KEY_DEV }}
MUDITA_CENTER_SERVER_URL: ${{ secrets.MUDITA_CENTER_SERVER_URL }}
+ MUDITA_CENTER_SERVER_V2_URL: ${{ secrets.MUDITA_CENTER_SERVER_V2_URL }}
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}
RELEASES_REPOSITORY_NAME: ${{ secrets.RELEASES_REPOSITORY_NAME }}
PRERELEASES_ENABLED: ${{ secrets.PRERELEASES_ENABLED }}
diff --git a/.stylelintrc.js b/.stylelintrc.js
index c7f62c7eff..15c8f88fcc 100644
--- a/.stylelintrc.js
+++ b/.stylelintrc.js
@@ -2,6 +2,7 @@ module.exports = {
extends: "@mudita/stylelint-config",
rules: {
"no-descending-specificity": null,
+ "value-no-vendor-prefix": null,
"selector-type-no-unknown": [true, { ignoreTypes: ["$dummyValue"] }],
},
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c1050783b4..28f7b93eec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Here we write upgrading notes for brands. It's a team effort to make them as
straightforward as possible.
+## [2.4.0] - 2024-09-16
+
+In this release, we have updated the Help section in the Mudita Center application. As of version 2.4.0, users can benefit from a refreshed help section with intuitive navigation. The article search functionality is also available. In addition, we have fixed two bugs occurring in our software.
+
+### Added
+
+- Added new Help section.
+
+### Changed
+
+- Removed old help functionality.
+- Configured CMS for Help section in Mudita Center.
+
+### Fixed
+
+- Fixed not displayed newly added file on Manage Sounds.
+- Fixed renaming of AppImage file when App Update.
+- Fixed bypassing force update.
+- Fixed broken layout in Contacts Search.
+- Fixed ignoring of opening connected device Overview page, when News is current active tab.
+- Fixed unexpected MDS behavior for Back and Forward mouse buttons.
+- Fixed type in update checking failed window copy.
+
## [2.3.0] - 2024-05-22
In this update, we have released the functionality of Multidevice support, the feature allows to support multiple Mudita devices in the Mudita Center application simultaneously without switching it. Moreover, we've successfully addressed 20 bugs across various features.
diff --git a/libs/core/__mocks__/p-queue.ts b/__mocks__/p-queue.ts
similarity index 100%
rename from libs/core/__mocks__/p-queue.ts
rename to __mocks__/p-queue.ts
diff --git a/apps/mudita-center-e2e/package.json b/apps/mudita-center-e2e/package.json
index 7d748dbd33..42d116da1d 100644
--- a/apps/mudita-center-e2e/package.json
+++ b/apps/mudita-center-e2e/package.json
@@ -18,7 +18,8 @@
},
"scripts": {
"e2e:test": "npm run validate-test-paths && npx wdio run wdio.conf.ts",
- "e2e:test:cicd": "npm run validate-test-paths && npx wdio run wdio.conf.ts --suite cicd",
+ "e2e:test:cicd:standalone": "npm run validate-test-paths && npx wdio run wdio.conf.ts --suite cicdStandalone",
+ "e2e:test:cicd:mock": "npm run validate-test-paths && npx wdio run wdio.conf.ts --suite cicdMock",
"e2e:test:mock": "npm run validate-test-paths && npx wdio run wdio.conf.ts --suite mock",
"e2e:test:standalone": "npm run validate-test-paths && npx wdio run wdio.conf.ts --suite standalone",
"lint:typecheck:to-fix": "tsc --noEmit",
diff --git a/apps/mudita-center-e2e/src/consts/regex-const.ts b/apps/mudita-center-e2e/src/consts/regex-const.ts
index e5740a4bea..041cc83915 100644
--- a/apps/mudita-center-e2e/src/consts/regex-const.ts
+++ b/apps/mudita-center-e2e/src/consts/regex-const.ts
@@ -6,6 +6,8 @@
export const linkRegex: RegExp =
/^(https?:\/\/)(mudita.com\/community|forum.mudita.com\/t).*$/
export const newsImageRegex: RegExp = /(^data:image;base64)/
+export const kompaktImageRegex: RegExp = /(^data:image\/png;base64)/
export const newsDateRegex: RegExp =
/^(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(\s{1})([1-9]|[12][0-9]|3[01])(,{1})(\s{1})([2-9][0-9][0-9][0-9])$/
export const commentsRegex: RegExp = /^(\d+)(\s{1})(COMMENTS|COMMENT)$/
+export const kompaktImeiRegex: RegExp = /^[0-9]{1,15}$/
diff --git a/apps/mudita-center-e2e/src/helpers/tests.helper.ts b/apps/mudita-center-e2e/src/helpers/tests.helper.ts
index b5277d67f7..9e9d8f74e5 100644
--- a/apps/mudita-center-e2e/src/helpers/tests.helper.ts
+++ b/apps/mudita-center-e2e/src/helpers/tests.helper.ts
@@ -10,8 +10,6 @@
class TestHelper {
isLinux() {
if (process.platform === "linux") {
- console.log("CURRENT PLATFORM: " + process.platform)
- console.log(process.platform + " = Test Skipped ")
return true
}
return false
diff --git a/apps/mudita-center-e2e/src/page-objects/about-kompakt.page.ts b/apps/mudita-center-e2e/src/page-objects/about-kompakt.page.ts
new file mode 100644
index 0000000000..93838258fb
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/about-kompakt.page.ts
@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+class AboutKompaktPage extends Page {
+ public get aboutHeader() {
+ return $("h3*=About your device")
+ }
+
+ public get aboutSubtitle() {
+ return $("p*=Device details")
+ }
+
+ public get backToOverviewIcon() {
+ return $('[data-testid="icon-ArrowLongLeft"]')
+ }
+
+ public get backToOverviewLabel() {
+ return $('[data-testid="location"]')
+ }
+
+ public get serialNumberLabel() {
+ return $('[data-testid="about-data-box-label-serial-number"]')
+ }
+
+ public get serialNumberValue() {
+ return $('[data-testid="about-data-box-value-serial-number"]')
+ }
+
+ public get imei1Label() {
+ return $('[data-testid="about-data-box-label-imei-(sim-slot-1)"]')
+ }
+
+ public get imei1Value() {
+ return $('[data-testid="about-data-box-value-imei-(sim-slot-1)"]')
+ }
+
+ public get imei2Label() {
+ return $('[data-testid="about-data-box-label-imei-(sim-slot-2)"]')
+ }
+
+ public get imei2Value() {
+ return $('[data-testid="about-data-box-value-imei-(sim-slot-2)"]')
+ }
+
+ public get sarLabel() {
+ return $('[data-testid="about-data-box-label-sar"]')
+ }
+
+ public get sarButton() {
+ return $('[data-testid="button-text_sarmodal-button"]')
+ }
+
+ public get sarHeader() {
+ return $("h3*=SAR")
+ }
+}
+export default new AboutKompaktPage()
diff --git a/apps/mudita-center-e2e/src/page-objects/drawer.page.ts b/apps/mudita-center-e2e/src/page-objects/drawer.page.ts
new file mode 100644
index 0000000000..ffe98fe835
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/drawer.page.ts
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+export class DrawerPage extends Page {
+ public get deviceSelectDrawer() {
+ return $('[data-testid="device-select-drawer-content"]')
+ }
+
+ public getDeviceOnDrawer(serialNumber: string) {
+ return $(`//*[@data-testid="drawer-device-wrapper-${serialNumber}"]`)
+ }
+
+ public get deviceImageOnDrawer() {
+ return $('[data-testid="drawer-device-image"]')
+ }
+ public get drawerDeviceSerialNumber() {
+ return $$('[data-testid="drawer-device-serial-number-value"]')
+ }
+
+ public get drawerDeviceName() {
+ return $$('[data-testid="drawer-device-type"]')
+ }
+}
+
+export default new DrawerPage()
diff --git a/apps/mudita-center-e2e/src/page-objects/mc-update-modal.page.ts b/apps/mudita-center-e2e/src/page-objects/mc-update-modal.page.ts
index cb8715c3f0..823868ef96 100644
--- a/apps/mudita-center-e2e/src/page-objects/mc-update-modal.page.ts
+++ b/apps/mudita-center-e2e/src/page-objects/mc-update-modal.page.ts
@@ -27,7 +27,7 @@ class ModalPage extends Page {
}
get checkingFailedUpdateBody() {
- return $("p*=Opps, something went wrong.")
+ return $("p*=Oops, something went wrong.")
}
}
diff --git a/apps/mudita-center-e2e/src/page-objects/menu.page.ts b/apps/mudita-center-e2e/src/page-objects/menu.page.ts
new file mode 100644
index 0000000000..db963382e8
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/menu.page.ts
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+export class Menu extends Page {
+ public get newsLink() {
+ return $(`//a[@href="#/news"]`)
+ }
+
+ public get kompaktLabel() {
+ return $('[data-testid="Kompakt"]')
+ }
+
+ public get overviewLink() {
+ return $(`//a[@href="#/generic/mc-overview"]`)
+ }
+
+ public get muditaCenterLabel() {
+ return $('[data-testid="component.menuHeaderDesktopApp"]')
+ }
+
+ public get settingsLink() {
+ return $(`//a[@href="#/settings"]`)
+ }
+
+ public get helpLink() {
+ return $(`//a[@href="#/help"]`)
+ }
+}
+
+export default new Menu()
diff --git a/apps/mudita-center-e2e/src/page-objects/modal-app-update-error.page.ts b/apps/mudita-center-e2e/src/page-objects/modal-app-update-error.page.ts
new file mode 100644
index 0000000000..9c6f61e2a5
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/modal-app-update-error.page.ts
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+class ModalAppUpdateError extends Page {
+ public get infoIcon() {
+ return $('[data-testid="icon-Info"]')
+ }
+
+ public get errorLabel() {
+ return $("h4*=Error")
+ }
+
+ public get pleaseRestartParagraph() {
+ return $("p*=Please restart the app")
+ }
+
+ public get closeButton() {
+ return $('[data-testid="close-bottom-button"]')
+ }
+}
+
+export default new ModalAppUpdateError()
diff --git a/apps/mudita-center-e2e/src/page-objects/modal-app-update-later.page.ts b/apps/mudita-center-e2e/src/page-objects/modal-app-update-later.page.ts
new file mode 100644
index 0000000000..b2a19e37ee
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/modal-app-update-later.page.ts
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+class ModalAppUpdateLater extends Page {
+ get modalHeader() {
+ return $('[data-testid="modal-title"]')
+ }
+
+ get modalCloseButton() {
+ return $('[data-testid="close-modal-button"]')
+ }
+
+ get appUpdateFlowContainer() {
+ return $('[data-testid="app-update-flow-container"]')
+ }
+
+ get paragraphAvailableVersion() {
+ return $("h4*=Update Mudita Center to")
+ }
+
+ get paragraphUpdateLaterPrivacyPolicy() {
+ return $(
+ "p*=To be able to fully use the application, please agree to the Privacy Policy and update Mudita Center."
+ )
+ }
+
+ get buttonUpdateLater() {
+ return $('[data-testid="close-bottom-button"]')
+ }
+ get buttonUpdate() {
+ return $('[data-testid="modal-action-button"]')
+ }
+}
+
+export default new ModalAppUpdateLater()
diff --git a/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts b/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts
new file mode 100644
index 0000000000..d91a40c96b
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+class ModalAppUpdate extends Page {
+ get modalHeader() {
+ return $('[data-testid="modal-title"]')
+ }
+
+ public get paragraphAvailableVersion() {
+ return $("h4*=Update Mudita Center to")
+ }
+
+ public get paragraphCurrentVersion() {
+ return $("p*=Update it to use")
+ }
+
+ public get paragraphPrivacyPolicy() {
+ return $(
+ "p*=Please accept the Privacy Policy to start updating Mudita Center."
+ )
+ }
+
+ public get linkPrivacyPolicy() {
+ return $("a=Privacy Policy")
+ }
+
+ public get checkboxPrivacyPolicy() {
+ return $('[data-testid="privacy-policy-checkbox"]')
+ }
+
+ public get buttonUpdate() {
+ return $('[data-testid="modal-action-button"]')
+ }
+
+ public get paragraphUpdatingMuditaCenter() {
+ return $("h4*=Updating Mudita Center")
+ }
+
+ public get spinnerLoader() {
+ return $('[data-testid="loader-spinner"]')
+ }
+
+ public get paragraphPleaseWait() {
+ return $("p*=Please wait while Mudita Center is being updated.")
+ }
+}
+
+export default new ModalAppUpdate()
diff --git a/apps/mudita-center-e2e/src/page-objects/modal-sar.page.ts b/apps/mudita-center-e2e/src/page-objects/modal-sar.page.ts
new file mode 100644
index 0000000000..3716cb1156
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/modal-sar.page.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import Page from "./page"
+
+class AboutKompaktPage extends Page {
+ public get sarHeader() {
+ return $("h3*=SAR")
+ }
+
+ public get modalCloseButton() {
+ return $('[data-testid="icon-close"]')
+ }
+}
+export default new AboutKompaktPage()
diff --git a/apps/mudita-center-e2e/src/page-objects/overview-kompakt.page.ts b/apps/mudita-center-e2e/src/page-objects/overview-kompakt.page.ts
index 606b247560..79ccf96a76 100644
--- a/apps/mudita-center-e2e/src/page-objects/overview-kompakt.page.ts
+++ b/apps/mudita-center-e2e/src/page-objects/overview-kompakt.page.ts
@@ -3,9 +3,81 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { ChainablePromiseElement } from "webdriverio"
-import OverviewPage from "./overview.page"
+import { OverviewPage } from "./overview.page"
-class OverviewKompaktPage extends OverviewPage {}
+class OverviewKompaktPage extends OverviewPage {
+ public get header() {
+ return $('[data-testid="location"]')
+ }
+ public get aboutYourDevice() {
+ return $('[data-testid="button-text_summary-about"]')
+ }
+
+ public get sarInformationButtonKompakt() {
+ return $('[data-testid="button-text_sarmodal-button"]')
+ }
+
+ public get sarInformationPopup() {
+ return $('[data-testid="button-text_sarmodal-button"]')
+ }
+
+ public get sarInformationPopupCloseButton() {
+ return $('[data-testid="icon-close"]')
+ }
+
+ public get backArrowButton() {
+ return $('[data-testid="icon-ArrowLongLeft"]')
+ }
+
+ public get backupInfo() {
+ return $(`//div[@data-testid="block-box-backup"]//p`)
+ }
+
+ public get serialNumberLabel() {
+ return $(`//div[@componentkey="summary-serial-number"]/p[1]`)
+ }
+
+ public get serialNumberValue() {
+ return $(`//div[@componentkey="summary-serial-number"]/p[2]`)
+ }
+
+ public get kompaktImage() {
+ return $('[data-testid="generic-view-image"]')
+ }
+
+ public get kompaktSignalIcon() {
+ return $('[data-testid="icon-network-signal-2"]')
+ }
+
+ public getStatusRow(rowIndex: number) {
+ return $(
+ `(//div[@data-testid="block-box-status"]/..//h4[@data-testid="icon-text"])[${rowIndex}]`
+ )
+ }
+
+ public get kompaktNetworkName() {
+ return this.getStatusRow(2)
+ }
+
+ public get kompaktBatteryIcon() {
+ return $('//div[@data-testid="icon-battery-charging-5"]')
+ }
+
+ public get kompaktBatteryLevelValue() {
+ return this.getStatusRow(1)
+ }
+
+ public get kompaktSimCard1Subtext() {
+ return this.getStatusRow(2).$(`//*[@data-testid="icon-subtext"]`)
+ }
+
+ public get kompaktOsVersion() {
+ return $('[data-testid="version"]')
+ }
+
+ public get kompaktOsVersionLabel() {
+ return $('[data-testid="version-label"]')
+ }
+}
export default new OverviewKompaktPage()
diff --git a/apps/mudita-center-e2e/src/page-objects/overview.page.ts b/apps/mudita-center-e2e/src/page-objects/overview.page.ts
index 4aae54d5d6..ece1accf18 100644
--- a/apps/mudita-center-e2e/src/page-objects/overview.page.ts
+++ b/apps/mudita-center-e2e/src/page-objects/overview.page.ts
@@ -3,212 +3,147 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { ChainablePromiseElement } from "webdriverio"
import Page from "./page"
-class OverviewPage extends Page {
- public get currentDeviceVersion(): ChainablePromiseElement<
- Promise
- > {
+export class OverviewPage extends Page {
+ public get currentDeviceVersion() {
return $("p*=MuditaOS")
}
- public get checkingForUpdateLoader(): ChainablePromiseElement<
- Promise
- > {
+ public get checkingForUpdateLoader() {
return $("h4*=Checking for MuditaOS update...")
}
- public get downloadUpdateLoader(): ChainablePromiseElement<
- Promise
- > {
+ public get downloadUpdateLoader() {
return $("*=Downloading update...")
}
- public get updateStatusLoader(): ChainablePromiseElement<
- Promise
- > {
+ public get updateStatusLoader() {
return $("p*=Updating MuditaOS…")
}
- public get updateCompletedStatus(): ChainablePromiseElement<
- Promise
- > {
+ public get updateCompletedStatus() {
return $("p*=Update completed!")
}
- public get checkForUpdateButton(): ChainablePromiseElement<
- Promise
- > {
+ public get checkForUpdateButton() {
return $("button*=Check for updates")
}
- public get downloadUpdateNowButton(): ChainablePromiseElement<
- Promise
- > {
+ public get downloadUpdateNowButton() {
return $('[data-testid="modal-action-button"]*=Download now')
}
- public get updateNowButton(): ChainablePromiseElement<
- Promise
- > {
+ public get updateNowButton() {
return $('[data-testid="modal-action-button"]*=Update now')
}
- public get aboutYourPureButton(): ChainablePromiseElement<
- Promise
- > {
+ public get aboutYourPureButton() {
return $("p*=About your Pure")
}
- public get checkSARInformationButton(): ChainablePromiseElement<
- Promise
- > {
+ public get checkSARInformationButton() {
return $("p*=Check SAR information")
}
- public get sarWrapper(): ChainablePromiseElement<
- Promise
- > {
+ public get sarWrapper() {
return $('[data-testid="sar-wrapper"]')
}
- public get backToOverviewButton(): ChainablePromiseElement<
- Promise
- > {
+ public get backToOverviewButton() {
return $("p*=Back to Overview")
}
- public get createBackupButton(): ChainablePromiseElement<
- Promise
- > {
- return $("p*=Create backup")
+ public get createBackupButton() {
+ return $('//button[@type="button" and .//span[text()="Create backup"]]')
}
- public get restoreBackupButton(): ChainablePromiseElement<
- Promise
- > {
+ public get restoreBackupButton() {
return $("p*=Restore last backup")
}
- public get locationTextLabel(): ChainablePromiseElement<
- Promise
- > {
+ public get locationTextLabel() {
return $('[data-testid="location"]')
}
- public get batteryLevel(): ChainablePromiseElement<
- Promise
- > {
+ public get batteryLevel() {
return $('[data-testid="battery-level"]')
}
- public get fullBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get fullBatteryIcon() {
return $('[data-testid="icon-FullBattery"]')
}
- public get veryHighBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get veryHighBatteryIcon() {
return $('[data-testid="icon-VeryHighBattery"]')
}
- public get highBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get highBatteryIcon() {
return $('[data-testid="icon-HighBattery"]')
}
- public get mediumBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get mediumBatteryIcon() {
return $('[data-testid="icon-MediumBattery"]')
}
- public get lowBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get lowBatteryIcon() {
return $('[data-testid="icon-LowBattery"]')
}
- public get veryLowBatteryIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get veryLowBatteryIcon() {
return $('[data-testid="icon-VeryLowBattery"]')
}
- public get noRangeIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get noRangeIcon() {
return $('[data-testid="icon-NoRange"]')
}
- public get LowRangeIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get LowRangeIcon() {
return $('[data-testid="icon-LowRange"]')
}
- public get MediumRangeIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get MediumRangeIcon() {
return $('[data-testid="icon-MediumRange"]')
}
- public get HighRangeIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get HighRangeIcon() {
return $('[data-testid="icon-HighRange"]')
}
- public get VeryHighRangeIcon(): ChainablePromiseElement<
- Promise
- > {
+ public get VeryHighRangeIcon() {
return $('[data-testid="icon-VeryHighRange"]')
}
- public get disconnectButton(): ChainablePromiseElement<
- Promise
- > {
+ public get disconnectButton() {
return $('[data-testid="disconnect-button"]')
}
- public get networkName(): ChainablePromiseElement<
- Promise
- > {
+ public get networkName() {
return $('[data-testid="network-name"]')
}
- public get pureGrayImage(): ChainablePromiseElement<
- Promise
- > {
+ public get pureGrayImage() {
return $('[data-testid="pure-gray"]')
}
- public get pureBlackImage(): ChainablePromiseElement<
- Promise
- > {
+ public get pureBlackImage() {
return $('[data-testid="pure-black"]')
}
- public get aboutYourPureSerialNumber(): ChainablePromiseElement<
- Promise
- > {
+ public get aboutYourPureSerialNumber() {
return $('[data-testid="serial-number-value"]')
}
- public get overviewSerialNumber(): ChainablePromiseElement<
- Promise
- > {
+ public get overviewSerialNumber() {
return $('[data-testid="device-serial-number"]')
}
- public get muditaOSVersion(): ChainablePromiseElement<
- Promise
- > {
+ public get muditaOSVersion() {
return $('[data-testid="os-version"]')
}
+
+ public get selectConnectedDevices() {
+ return $('[data-testid="icon-DotsInBox"]')
+ }
}
export default new OverviewPage()
diff --git a/apps/mudita-center-e2e/src/page-objects/select-device.page.ts b/apps/mudita-center-e2e/src/page-objects/select-device.page.ts
new file mode 100644
index 0000000000..6c6341126b
--- /dev/null
+++ b/apps/mudita-center-e2e/src/page-objects/select-device.page.ts
@@ -0,0 +1,29 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { index } from "@orama/orama/dist/components"
+import Page from "./page"
+
+class SelectDevicePage extends Page {
+ public get devicesList() {
+ return $("[data-testid='devices-list']")
+ }
+ public get availableDevices() {
+ return $$('[data-testid="available-device"]')
+ }
+ public get selectDeviceSerialNumber() {
+ return $$('[data-testid="available-device-serial-number"]')
+ }
+ public get selectDeviceName() {
+ return $$('[data-testid="available-device-name"]')
+ }
+ public get selectADeviceToContinueTitle() {
+ return $("h1*=Select a device to continue")
+ }
+ public getDeviceOnSelectModal(index: number) {
+ return $(`(//p[@data-testid="available-device-serial-number"])[${index}]`)
+ }
+}
+export default new SelectDevicePage()
diff --git a/apps/mudita-center-e2e/src/page-objects/tabs.page.ts b/apps/mudita-center-e2e/src/page-objects/tabs.page.ts
index 18481f4abd..795cb7a1d1 100644
--- a/apps/mudita-center-e2e/src/page-objects/tabs.page.ts
+++ b/apps/mudita-center-e2e/src/page-objects/tabs.page.ts
@@ -7,15 +7,11 @@ import { ChainablePromiseElement } from "webdriverio"
import Page from "./page"
class NavigationTabs extends Page {
- public get muditaNewsTab(): ChainablePromiseElement<
- Promise
- > {
+ public get muditaNewsTab() {
return $('[data-testid="icon-MenuNews"]')
}
- public get overviewTab(): ChainablePromiseElement<
- Promise
- > {
+ public get overviewTab() {
return $('[data-testid="overview-link"]')
}
@@ -23,9 +19,11 @@ class NavigationTabs extends Page {
await this.overviewTab.click()
}
- public get messagesTab(): ChainablePromiseElement<
- Promise
- > {
+ public get overviewKompaktTab() {
+ return $('[data-testid="icon-MenuOverview"]')
+ }
+
+ public get messagesTab() {
return $('[data-testid="overview-menu-link"]')
}
@@ -34,9 +32,7 @@ class NavigationTabs extends Page {
await this.messagesTab.click()
}
- public get contactsTab(): ChainablePromiseElement<
- Promise
- > {
+ public get contactsTab() {
return $('[data-testid="contacts-menu-link"]')
}
@@ -45,9 +41,7 @@ class NavigationTabs extends Page {
await this.contactsTab.click()
}
- public get settingsTab(): ChainablePromiseElement<
- Promise
- > {
+ public get settingsTab() {
return $('[data-testid="icon-MenuSettings"]')
}
@@ -55,7 +49,7 @@ class NavigationTabs extends Page {
await this.settingsTab.click()
}
- public get helpTab(): ChainablePromiseElement> {
+ public get helpTab() {
return $('[data-testid="help-menu-button"]')
}
diff --git a/apps/mudita-center-e2e/src/specs/news/news-check-offline.e2e.ts b/apps/mudita-center-e2e/src/specs/news/news-check-offline.e2e.ts
index 30986448a1..5392cb08cc 100644
--- a/apps/mudita-center-e2e/src/specs/news/news-check-offline.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/news/news-check-offline.e2e.ts
@@ -7,9 +7,16 @@ import {
newsImageRegex,
} from "../../consts/regex-const"
import testsHelper from "../../helpers/tests.helper"
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
describe("News Page Check in Offline Mode", () => {
before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
// Clear browser cache
await browser.deleteAllCookies()
await browser.execute("window.localStorage.clear();")
@@ -114,6 +121,9 @@ describe("News Page Check in Offline Mode", () => {
})
after(async () => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+
// Switch back to online mode after finishing the tests
await browser.setNetworkConditions({
offline: false,
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-match.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-match.e2e.ts
new file mode 100644
index 0000000000..5311981766
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-match.e2e.ts
@@ -0,0 +1,75 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ apiConfigWithContacts,
+ contactsConfig,
+ contactsData,
+ menuWithContacts,
+} from "../../../../../libs/e2e-mock/responses/src"
+
+describe("E2E mock match sample", () => {
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it.only("Connect device with two different responses for one endpoint", async () => {
+ // if body of FEATURE_CONFIGURATION request is equal to { feature: "contacts", lang: "en-US" } then return body: contactsConfig.
+ // in other cases return response without match filed
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: contactsConfig,
+ endpoint: "FEATURE_CONFIGURATION",
+ method: "GET",
+ status: 200,
+ match: {
+ expected: { feature: "contacts", lang: "en-US" },
+ },
+ })
+ // if body of FEATURE_DATA request is equal to { feature: "contacts", lang: "en-US" } then return body: contactsConfig.
+ // in other cases return response without match filed
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: contactsData,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ match: {
+ expected: { feature: "contacts", lang: "en-US" },
+ },
+ })
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: apiConfigWithContacts,
+ endpoint: "API_CONFIGURATION",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: menuWithContacts,
+ endpoint: "MENU_CONFIGURATION",
+ method: "GET",
+ status: 200,
+ })
+
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: "first-serial-number",
+ })
+ await browser.pause(6000)
+ const menuItem = await $(`//a[@href="#/generic/contacts"]`)
+
+ await menuItem.waitForDisplayed({ timeout: 10000 })
+ await expect(menuItem).toBeDisplayed()
+
+ await browser.pause(10000)
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts
new file mode 100644
index 0000000000..f43688c3be
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts
@@ -0,0 +1,149 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import modalAppUpdatePage from "../../page-objects/modal-app-update.page"
+import ModalPage from "../../page-objects/modal.page"
+import packageInfo from "../../../../mudita-center/package.json"
+
+describe("Force Update MC - Successful Download", () => {
+ const newestAvailableVersion = "9.9.9"
+
+ before(async function () {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
+ E2EMockClient.setMockUpdateState({
+ available: true,
+ version: newestAvailableVersion,
+ })
+
+ E2EMockClient.mockHttpResponse({
+ url: "v2-app-configuration",
+ method: "GET",
+ status: 200,
+ data: {
+ centerVersion: "999.0.0",
+ productVersions: {
+ MuditaHarmony: "1.0.0",
+ MuditaPure: "1.0.0",
+ APIDevice: "1.0.0",
+ },
+ },
+ })
+ })
+
+ it("Check update modal sections ", async () => {
+ console.log("PACKAGE INFO VERSION:" + packageInfo.version)
+
+ // Header
+ const modalHeader = await modalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ // Available version
+ const paragraphAvailableVersion =
+ await modalAppUpdatePage.paragraphAvailableVersion
+ await expect(paragraphAvailableVersion).toBeDisplayed()
+ await expect(paragraphAvailableVersion).toHaveTextContaining(
+ "Update Mudita Center to"
+ )
+ const textParagraphAvailableVersion =
+ await paragraphAvailableVersion.getText()
+ const availableAppVersion = textParagraphAvailableVersion.split("to ").pop()
+ console.log("AVAILABLE VERSION:" + availableAppVersion)
+ await expect(availableAppVersion).toBe(newestAvailableVersion)
+
+ // Current version
+ const paragraphCurrentVersion =
+ await modalAppUpdatePage.paragraphCurrentVersion
+ await expect(paragraphCurrentVersion).toBeDisplayed()
+ await expect(paragraphCurrentVersion).toHaveTextContaining(
+ "Update it to use the full version of the Mudita Center. Your current version:"
+ )
+ const textParagraphCurrentVersion = await paragraphCurrentVersion.getText()
+ const currentAppVersion = textParagraphCurrentVersion.split(": ").pop()
+ console.log("CURRENT VERSION:" + currentAppVersion)
+
+ // Privacy policy
+ const paragraphPrivacyPolicy =
+ await modalAppUpdatePage.paragraphPrivacyPolicy
+ await expect(paragraphPrivacyPolicy).toBeDisplayed()
+ await expect(paragraphPrivacyPolicy).toHaveText(
+ "Please accept the Privacy Policy to start updating Mudita Center."
+ )
+
+ const linkPrivacyPolicy = await modalAppUpdatePage.linkPrivacyPolicy
+ await expect(linkPrivacyPolicy).toBeDisplayed()
+ await expect(linkPrivacyPolicy).toHaveText("Privacy Policy")
+
+ const linkColor = await linkPrivacyPolicy.getCSSProperty("color")
+ await expect(linkColor.value).toBe("rgba(109,155,188,1)")
+ const linkDecoration = await linkPrivacyPolicy.getCSSProperty(
+ "text-decoration"
+ )
+ await expect(linkDecoration.value).toBe(
+ "underline solid rgb(109, 155, 188)"
+ )
+
+ const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+ await expect(checkboxPrivacyPolicy).not.toBeChecked()
+
+ // Button: UPDATE
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate.isDisplayed())
+ await expect(buttonUpdate).not.toBeClickable()
+
+ // Close modal button
+ const modalCloseButton = await ModalPage.modalCloseButton
+ await expect(modalCloseButton).not.toBeDisplayed()
+ })
+
+ it("Button UPDATE is clickable after selecting the checkbox", async () => {
+ const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await expect(buttonUpdate).not.toBeClickable()
+
+ await checkboxPrivacyPolicy.click()
+ await expect(checkboxPrivacyPolicy).toBeChecked()
+
+ await expect(buttonUpdate).toBeClickable()
+ })
+
+ it("Check Updating Mudita Center modal", async () => {
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await buttonUpdate.click()
+
+ const modalHeader = await modalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const paragraphUpdatingMuditaCenter =
+ await modalAppUpdatePage.paragraphUpdatingMuditaCenter
+ await expect(paragraphUpdatingMuditaCenter).toBeDisplayed()
+ await expect(paragraphUpdatingMuditaCenter).toHaveText(
+ "Updating Mudita Center"
+ )
+
+ const spinnerLoader = await modalAppUpdatePage.spinnerLoader
+ await expect(spinnerLoader).toBeDisplayed()
+ const spinnerColor = await spinnerLoader.getCSSProperty("color")
+ await expect(spinnerColor.value).toBe("rgba(109,155,188,1)")
+
+ const spinnerAnimation = await spinnerLoader.getCSSProperty("animation")
+ await expect(spinnerAnimation.value).toBe(
+ "chase 2.5s linear 0s infinite normal both running"
+ )
+
+ const paragraphPleaseWait = await modalAppUpdatePage.paragraphPleaseWait
+ await expect(paragraphPleaseWait).toBeDisplayed()
+ await expect(paragraphPleaseWait).toHaveText(
+ "Please wait while Mudita Center is being updated."
+ )
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-error.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-error.e2e.ts
new file mode 100644
index 0000000000..516db66ab5
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-error.e2e.ts
@@ -0,0 +1,149 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import ModalPage from "../../page-objects/modal.page"
+import modalAppUpdatePage from "../../page-objects/modal-app-update.page"
+import modalAppUpdateErrorPage from "../../page-objects/modal-app-update-error.page"
+import packageInfo from "../../../../mudita-center/package.json"
+
+describe("Force Update MC - Unsuccessful Download", () => {
+ const newestAvailableVersion = "9.9.9"
+
+ before(async function () {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
+ E2EMockClient.setMockUpdateState({
+ available: true,
+ downloaded: false,
+ version: newestAvailableVersion,
+ })
+
+ E2EMockClient.mockHttpResponse({
+ url: "v2-app-configuration",
+ method: "GET",
+ status: 200,
+ data: {
+ centerVersion: "999.0.0",
+ productVersions: {
+ MuditaHarmony: "1.0.0",
+ MuditaPure: "1.0.0",
+ APIDevice: "1.0.0",
+ },
+ },
+ })
+ })
+
+ it("Check update modal sections ", async () => {
+ console.log("PACKAGE INFO VERSION:" + packageInfo.version)
+
+ // Header
+ const modalHeader = await modalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ // Available version
+ const paragraphAvailableVersion =
+ await modalAppUpdatePage.paragraphAvailableVersion
+ await expect(paragraphAvailableVersion).toBeDisplayed()
+ await expect(paragraphAvailableVersion).toHaveTextContaining(
+ "Update Mudita Center to"
+ )
+ const textParagraphAvailableVersion =
+ await paragraphAvailableVersion.getText()
+ const availableAppVersion = textParagraphAvailableVersion.split("to ").pop()
+ console.log("AVAILABLE VERSION:" + availableAppVersion)
+ await expect(availableAppVersion).toBe(newestAvailableVersion)
+
+ // Current version
+ const paragraphCurrentVersion =
+ await modalAppUpdatePage.paragraphCurrentVersion
+ await expect(paragraphCurrentVersion).toBeDisplayed()
+ await expect(paragraphCurrentVersion).toHaveTextContaining(
+ "Update it to use the full version of the Mudita Center. Your current version:"
+ )
+ const textParagraphCurrentVersion = await paragraphCurrentVersion.getText()
+ const currentAppVersion = textParagraphCurrentVersion.split(": ").pop()
+ console.log("CURRENT VERSION:" + currentAppVersion)
+
+ // Privacy policy
+ const paragraphPrivacyPolicy =
+ await modalAppUpdatePage.paragraphPrivacyPolicy
+ await expect(paragraphPrivacyPolicy).toBeDisplayed()
+ await expect(paragraphPrivacyPolicy).toHaveText(
+ "Please accept the Privacy Policy to start updating Mudita Center."
+ )
+
+ const linkPrivacyPolicy = await modalAppUpdatePage.linkPrivacyPolicy
+ await expect(linkPrivacyPolicy).toBeDisplayed()
+ await expect(linkPrivacyPolicy).toHaveText("Privacy Policy")
+
+ const linkColor = await linkPrivacyPolicy.getCSSProperty("color")
+ await expect(linkColor.value).toBe("rgba(109,155,188,1)")
+ const linkDecoration = await linkPrivacyPolicy.getCSSProperty(
+ "text-decoration"
+ )
+ await expect(linkDecoration.value).toBe(
+ "underline solid rgb(109, 155, 188)"
+ )
+
+ const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+ await expect(checkboxPrivacyPolicy).not.toBeChecked()
+
+ // Button: UPDATE
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate.isDisplayed())
+ await expect(buttonUpdate).not.toBeClickable()
+
+ // Close modal button
+ const modalCloseButton = await ModalPage.modalCloseButton
+ await expect(modalCloseButton).not.toBeDisplayed()
+ })
+
+ it("Button UPDATE is clickable after selecting the checkbox", async () => {
+ const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await expect(buttonUpdate).not.toBeClickable()
+
+ await checkboxPrivacyPolicy.click()
+ await expect(checkboxPrivacyPolicy).toBeChecked()
+
+ await expect(buttonUpdate).toBeClickable()
+ })
+
+ it("Check Error modal", async () => {
+ const buttonUpdate = await modalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await buttonUpdate.click()
+
+ const modalHeader = await modalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const infoIcon = await modalAppUpdateErrorPage.infoIcon
+ await expect(infoIcon).toBeDisplayed()
+ const infoIconSize = await infoIcon.getSize()
+ await expect(infoIconSize.width).toBe(48)
+ await expect(infoIconSize.height).toBe(48)
+
+ const errorLabel = await modalAppUpdateErrorPage.errorLabel
+ await expect(errorLabel).toBeDisplayed()
+ await expect(errorLabel).toHaveText("Error")
+
+ const paragraphPleaseRestart =
+ await modalAppUpdateErrorPage.pleaseRestartParagraph
+ await expect(paragraphPleaseRestart).toBeDisplayed()
+ await expect(paragraphPleaseRestart).toHaveText(
+ "Please restart the app or update it manually."
+ )
+
+ const buttonClose = await modalAppUpdateErrorPage.closeButton
+ await expect(buttonClose).toBeDisplayed()
+ await expect(buttonClose).toHaveText("CLOSE")
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-available.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-available.e2e.ts
new file mode 100644
index 0000000000..b09e01abdb
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-available.e2e.ts
@@ -0,0 +1,197 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import ModalAppUpdatePage from "../../page-objects/modal-app-update.page"
+import ModalAppUpdateLaterPage from "../../page-objects/modal-app-update-later.page"
+import ModalPage from "../../page-objects/modal.page"
+import packageInfo from "../../../../mudita-center/package.json"
+import { sleep } from "../../helpers/sleep.helper"
+import HomePage from "../../page-objects/home.page"
+import SettingsPage from "../../page-objects/settings.page"
+import NavigationTabs from "../../page-objects/tabs.page"
+
+describe("Soft Update MC - Successful Download", () => {
+ const newestAvailableVersion = "9.9.9"
+
+ before(async function () {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
+ E2EMockClient.setMockUpdateState({
+ available: true,
+ version: newestAvailableVersion,
+ })
+
+ E2EMockClient.mockHttpResponse({
+ url: "v2-app-configuration",
+ method: "GET",
+ status: 200,
+ data: {
+ centerVersion: "0.0.1",
+ productVersions: {
+ MuditaHarmony: "1.0.0",
+ MuditaPure: "1.0.0",
+ APIDevice: "1.0.0",
+ },
+ },
+ })
+ })
+
+ it("Check update modal sections ", async () => {
+ console.log("PACKAGE INFO VERSION:" + packageInfo.version)
+
+ const modalHeader = await ModalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const paragraphAvailableVersion =
+ await ModalAppUpdatePage.paragraphAvailableVersion
+ await expect(paragraphAvailableVersion).toBeDisplayed()
+ await expect(paragraphAvailableVersion).toHaveTextContaining(
+ "Update Mudita Center to"
+ )
+ const textParagraphAvailableVersion =
+ await paragraphAvailableVersion.getText()
+ const availableAppVersion = textParagraphAvailableVersion.split("to ").pop()
+ console.log("AVAILABLE VERSION:" + availableAppVersion)
+ await expect(availableAppVersion).toBe(newestAvailableVersion)
+
+ const paragraphCurrentVersion =
+ await ModalAppUpdatePage.paragraphCurrentVersion
+ await expect(paragraphCurrentVersion).toBeDisplayed()
+ await expect(paragraphCurrentVersion).toHaveTextContaining(
+ "Update it to use the full version of the Mudita Center. Your current version:"
+ )
+ const textParagraphCurrentVersion = await paragraphCurrentVersion.getText()
+ const currentAppVersion = textParagraphCurrentVersion.split(": ").pop()
+ console.log("CURRENT VERSION:" + currentAppVersion)
+
+ // Privacy policy
+ const paragraphPrivacyPolicy =
+ await ModalAppUpdatePage.paragraphPrivacyPolicy
+ await expect(paragraphPrivacyPolicy).toBeDisplayed()
+ await expect(paragraphPrivacyPolicy).toHaveText(
+ "Please accept the Privacy Policy to start updating Mudita Center."
+ )
+
+ const linkPrivacyPolicy = await ModalAppUpdatePage.linkPrivacyPolicy
+ await expect(linkPrivacyPolicy).toBeDisplayed()
+ await expect(linkPrivacyPolicy).toHaveText("Privacy Policy")
+
+ const linkColor = await linkPrivacyPolicy.getCSSProperty("color")
+ await expect(linkColor.value).toBe("rgba(109,155,188,1)")
+ const linkDecoration = await linkPrivacyPolicy.getCSSProperty(
+ "text-decoration"
+ )
+ await expect(linkDecoration.value).toBe(
+ "underline solid rgb(109, 155, 188)"
+ )
+
+ const checkboxPrivacyPolicy = await ModalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+ await expect(checkboxPrivacyPolicy).not.toBeChecked()
+
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate.isDisplayed())
+ await expect(buttonUpdate).not.toBeClickable()
+
+ const modalCloseButton = await ModalPage.modalCloseButton
+ await expect(modalCloseButton).toBeDisplayed()
+ await modalCloseButton.click()
+ })
+ it("Check update later modal", async () => {
+ const modalHeader = await ModalAppUpdateLaterPage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+ const paragraphAvailableVersion =
+ await ModalAppUpdateLaterPage.paragraphAvailableVersion
+ await expect(paragraphAvailableVersion).toBeDisplayed()
+ await expect(paragraphAvailableVersion).toHaveTextContaining(
+ "Update Mudita Center to"
+ )
+ const paragraphUpdateLaterPrivacyPolicy =
+ await ModalAppUpdateLaterPage.paragraphUpdateLaterPrivacyPolicy
+ await expect(paragraphUpdateLaterPrivacyPolicy).toBeDisplayed()
+ await expect(paragraphUpdateLaterPrivacyPolicy).toHaveTextContaining(
+ "To be able to fully use the application, please agree to the Privacy Policy and update Mudita Center."
+ )
+
+ const buttonUpdateLater = await ModalAppUpdateLaterPage.buttonUpdateLater
+ await expect(buttonUpdateLater).toBeDisplayed()
+ await expect(buttonUpdateLater).toHaveText("UPDATE LATER")
+ await expect(buttonUpdateLater).toBeClickable()
+
+ const modalCloseButton = await ModalAppUpdateLaterPage.modalCloseButton
+ await expect(modalCloseButton).toBeDisplayed()
+ await modalCloseButton.click()
+
+ const homeHeader = await HomePage.homeHeader
+ await expect(homeHeader).toBeDisplayed()
+ await expect(homeHeader).toHaveText("Welcome to Mudita Center")
+ const notNowButton = await HomePage.notNowButton
+ await expect(notNowButton).toBeDisplayed()
+ await notNowButton.click()
+ })
+ it("Go back to Soft Update Modal.", async () => {
+ const settingsTab = await NavigationTabs.settingsTab
+ await settingsTab.waitForDisplayed()
+ await settingsTab.click()
+
+ const aboutTab = await SettingsPage.aboutTab
+ await aboutTab.waitForDisplayed()
+ await aboutTab.click()
+
+ const aboutCheckForUpdatesButton =
+ await SettingsPage.aboutCheckForUpdatesButton
+ await aboutCheckForUpdatesButton.waitForDisplayed()
+ await aboutCheckForUpdatesButton.click()
+ })
+
+ it("Button UPDATE is clickable after selecting the checkbox", async () => {
+ const checkboxPrivacyPolicy = await ModalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await expect(buttonUpdate).not.toBeClickable()
+
+ await checkboxPrivacyPolicy.click()
+ await expect(checkboxPrivacyPolicy).toBeChecked()
+
+ await expect(buttonUpdate).toBeClickable()
+ })
+
+ it("Soft Update the app", async () => {
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await buttonUpdate.click()
+
+ const modalHeader = await ModalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const paragraphUpdatingMuditaCenter =
+ await ModalAppUpdatePage.paragraphUpdatingMuditaCenter
+ await expect(paragraphUpdatingMuditaCenter).toBeDisplayed()
+ await expect(paragraphUpdatingMuditaCenter).toHaveText(
+ "Updating Mudita Center"
+ )
+
+ const spinnerLoader = await ModalAppUpdatePage.spinnerLoader
+ await expect(spinnerLoader).toBeDisplayed()
+ const spinnerColor = await spinnerLoader.getCSSProperty("color")
+ await expect(spinnerColor.value).toBe("rgba(109,155,188,1)")
+
+ const spinnerAnimation = await spinnerLoader.getCSSProperty("animation")
+ await expect(spinnerAnimation.value).toBe(
+ "chase 2.5s linear 0s infinite normal both running"
+ )
+
+ const paragraphPleaseWait = await ModalAppUpdatePage.paragraphPleaseWait
+ await expect(paragraphPleaseWait).toBeDisplayed()
+ await expect(paragraphPleaseWait).toHaveText(
+ "Please wait while Mudita Center is being updated."
+ )
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-error.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-error.e2e.ts
new file mode 100644
index 0000000000..b3d5103c8b
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-soft-update-error.e2e.ts
@@ -0,0 +1,144 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import ModalAppUpdatePage from "../../page-objects/modal-app-update.page"
+import modalAppUpdateErrorPage from "../../page-objects/modal-app-update-error.page"
+import ModalPage from "../../page-objects/modal.page"
+import packageInfo from "../../../../mudita-center/package.json"
+
+describe("Soft Update MC - Unsuccessful Download", () => {
+ const newestAvailableVersion = "9.9.9"
+
+ before(async function () {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
+ E2EMockClient.setMockUpdateState({
+ available: true,
+ downloaded: false,
+ version: newestAvailableVersion,
+ })
+
+ E2EMockClient.mockHttpResponse({
+ url: "v2-app-configuration",
+ method: "GET",
+ status: 200,
+ data: {
+ centerVersion: "0.0.1",
+ productVersions: {
+ MuditaHarmony: "1.0.0",
+ MuditaPure: "1.0.0",
+ APIDevice: "1.0.0",
+ },
+ },
+ })
+ })
+
+ it("Check update modal sections ", async () => {
+ console.log("PACKAGE INFO VERSION:" + packageInfo.version)
+
+ const modalHeader = await ModalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const paragraphAvailableVersion =
+ await ModalAppUpdatePage.paragraphAvailableVersion
+ await expect(paragraphAvailableVersion).toBeDisplayed()
+ await expect(paragraphAvailableVersion).toHaveTextContaining(
+ "Update Mudita Center to"
+ )
+ const textParagraphAvailableVersion =
+ await paragraphAvailableVersion.getText()
+ const availableAppVersion = textParagraphAvailableVersion.split("to ").pop()
+ console.log("AVAILABLE VERSION:" + availableAppVersion)
+ await expect(availableAppVersion).toBe(newestAvailableVersion)
+
+ const paragraphCurrentVersion =
+ await ModalAppUpdatePage.paragraphCurrentVersion
+ await expect(paragraphCurrentVersion).toBeDisplayed()
+ await expect(paragraphCurrentVersion).toHaveTextContaining(
+ "Update it to use the full version of the Mudita Center. Your current version:"
+ )
+ const textParagraphCurrentVersion = await paragraphCurrentVersion.getText()
+ const currentAppVersion = textParagraphCurrentVersion.split(": ").pop()
+ console.log("CURRENT VERSION:" + currentAppVersion)
+
+ // Privacy policy
+ const paragraphPrivacyPolicy =
+ await ModalAppUpdatePage.paragraphPrivacyPolicy
+ await expect(paragraphPrivacyPolicy).toBeDisplayed()
+ await expect(paragraphPrivacyPolicy).toHaveText(
+ "Please accept the Privacy Policy to start updating Mudita Center."
+ )
+
+ const linkPrivacyPolicy = await ModalAppUpdatePage.linkPrivacyPolicy
+ await expect(linkPrivacyPolicy).toBeDisplayed()
+ await expect(linkPrivacyPolicy).toHaveText("Privacy Policy")
+
+ const linkColor = await linkPrivacyPolicy.getCSSProperty("color")
+ await expect(linkColor.value).toBe("rgba(109,155,188,1)")
+ const linkDecoration = await linkPrivacyPolicy.getCSSProperty(
+ "text-decoration"
+ )
+ await expect(linkDecoration.value).toBe(
+ "underline solid rgb(109, 155, 188)"
+ )
+
+ const checkboxPrivacyPolicy = await ModalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+ await expect(checkboxPrivacyPolicy).not.toBeChecked()
+
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate.isDisplayed())
+ await expect(buttonUpdate).not.toBeClickable()
+
+ const modalCloseButton = await ModalPage.modalCloseButton
+ await expect(modalCloseButton).toBeDisplayed()
+ })
+
+ it("Button UPDATE is clickable after selecting the checkbox", async () => {
+ const checkboxPrivacyPolicy = await ModalAppUpdatePage.checkboxPrivacyPolicy
+ await expect(checkboxPrivacyPolicy).toBeDisplayed()
+
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await expect(buttonUpdate).not.toBeClickable()
+
+ await checkboxPrivacyPolicy.click()
+ await expect(checkboxPrivacyPolicy).toBeChecked()
+
+ await expect(buttonUpdate).toBeClickable()
+ })
+
+ it("Check Error modal", async () => {
+ const buttonUpdate = await ModalAppUpdatePage.buttonUpdate
+ await expect(buttonUpdate).toBeDisplayed()
+ await buttonUpdate.click()
+
+ const modalHeader = await ModalAppUpdatePage.modalHeader
+ await expect(modalHeader).toBeDisplayed()
+ await expect(modalHeader).toHaveText("Mudita Center")
+
+ const infoIcon = await modalAppUpdateErrorPage.infoIcon
+ await expect(infoIcon).toBeDisplayed()
+ const infoIconSize = await infoIcon.getSize()
+ await expect(infoIconSize.width).toBe(48)
+ await expect(infoIconSize.height).toBe(48)
+
+ const errorLabel = await modalAppUpdateErrorPage.errorLabel
+ await expect(errorLabel).toBeDisplayed()
+ await expect(errorLabel).toHaveText("Error")
+
+ const paragraphPleaseRestart =
+ await modalAppUpdateErrorPage.pleaseRestartParagraph
+ await expect(paragraphPleaseRestart).toBeDisplayed()
+ await expect(paragraphPleaseRestart).toHaveText(
+ "Please restart the app or update it manually."
+ )
+
+ const buttonClose = await modalAppUpdateErrorPage.closeButton
+ await expect(buttonClose).toBeDisplayed()
+ await expect(buttonClose).toHaveText("CLOSE")
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts
index e069538b85..228385d794 100644
--- a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts
@@ -74,6 +74,54 @@ describe("E2E mock sample - overview view", () => {
await expect(drawerHeader).toBeDisplayed()
})
+ it("Add third device", async () => {
+ E2EMockClient.addDevice({
+ path: "path-3",
+ serialNumber: "third-serial-number",
+ })
+ await browser.pause(6000)
+
+ const drawerHeader = $(`//*[text()='Select a device']`)
+ await drawerHeader.waitForDisplayed()
+ await expect(drawerHeader).toBeDisplayed()
+ })
+
+ it("Add fourth device", async () => {
+ E2EMockClient.addDevice({
+ path: "path-4",
+ serialNumber: "fourth-serial-number",
+ })
+ await browser.pause(6000)
+
+ const drawerHeader = $(`//*[text()='Select a device']`)
+ await drawerHeader.waitForDisplayed()
+ await expect(drawerHeader).toBeDisplayed()
+ })
+
+ it("Add fifth device", async () => {
+ E2EMockClient.addDevice({
+ path: "path-5",
+ serialNumber: "fifth-serial-number",
+ })
+ await browser.pause(6000)
+
+ const drawerHeader = $(`//*[text()='Select a device']`)
+ await drawerHeader.waitForDisplayed()
+ await expect(drawerHeader).toBeDisplayed()
+ })
+
+ it("Add sixth device", async () => {
+ E2EMockClient.addDevice({
+ path: "path-6",
+ serialNumber: "sixth-serial-number",
+ })
+ await browser.pause(6000)
+
+ const drawerHeader = $(`//*[text()='Select a device']`)
+ await drawerHeader.waitForDisplayed()
+ await expect(drawerHeader).toBeDisplayed()
+ })
+
it("Remove first device", async () => {
E2EMockClient.removeDevice("path-1")
await browser.pause(6000)
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-overview.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-overview.e2e.ts
new file mode 100644
index 0000000000..4d2ccbc4c4
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-overview.e2e.ts
@@ -0,0 +1,86 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ outboxReloadOverview,
+ overviewDataWithOneSimCard
+} from "../../../../../libs/e2e-mock/responses/src"
+import screenshotHelper from "../../helpers/screenshot.helper"
+
+describe("E2E reset mock sample - overview view", () => {
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect device", async () => {
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: "first-serial-number",
+ })
+
+ await browser.pause(6000)
+ const menuItem = await $(`//a[@href="#/generic/mc-overview"]`)
+
+ await menuItem.waitForDisplayed({ timeout: 10000 })
+ await expect(menuItem).toBeDisplayed()
+ })
+
+ it("Overwrite device response", async () => {
+
+ // overwrite default response for given device
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ // overwrite newest response for given device
+ E2EMockClient.mockResponseOnce({
+ path: "path-1",
+ body: outboxReloadOverview,
+ endpoint: "OUTBOX",
+ method: "GET",
+ status: 200,
+ })
+
+
+ await browser.pause(30000)
+ })
+
+ it("Reset mock", async () => {
+ E2EMockClient.mockReset({
+ path: "path-1",
+ requests: [
+ { endpoint: "FEATURE_DATA", method: "GET" },
+ {
+ endpoint: "FEATURE_CONFIGURATION",
+ method: "GET",
+ },
+ {
+ endpoint: "MENU_CONFIGURATION",
+ method: "GET",
+ },
+ {
+ endpoint: "OUTBOX",
+ method: "GET",
+ },
+ ],
+ })
+
+
+ await browser.pause(30000)
+ })
+
+ it("Remove first device", async () => {
+ E2EMockClient.removeDevice("path-1")
+ await browser.pause(6000)
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-sample.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-sample.e2e.ts
new file mode 100644
index 0000000000..34268246af
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/e2e-reset-mock-sample.e2e.ts
@@ -0,0 +1,88 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ outboxReloadOverview,
+ overviewDataWithoutBadge,
+} from "../../../../../libs/e2e-mock/responses/src"
+import screenshotHelper from "../../helpers/screenshot.helper"
+
+describe("E2E reset mock sample", () => {
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect locked device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: {},
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 423,
+ })
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: {},
+ endpoint: "FEATURE_CONFIGURATION",
+ method: "GET",
+ status: 423,
+ })
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: {},
+ endpoint: "MENU_CONFIGURATION",
+ method: "GET",
+ status: 423,
+ })
+
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: {},
+ endpoint: "OUTBOX",
+ method: "GET",
+ status: 423,
+ })
+
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: "first-serial-number",
+ })
+
+ await browser.pause(10000)
+ const lockScreen = await $(`//*[text()="Unlock your phone"]`)
+
+ await lockScreen.waitForDisplayed({ timeout: 10000 })
+ await expect(lockScreen).toBeDisplayed()
+ await browser.pause(2000)
+ })
+
+ it("Unlock device", async () => {
+ E2EMockClient.mockReset({
+ path: "path-1",
+ requests: [
+ { endpoint: "FEATURE_DATA", method: "GET" },
+ {
+ endpoint: "FEATURE_CONFIGURATION",
+ method: "GET",
+ },
+ {
+ endpoint: "MENU_CONFIGURATION",
+ method: "GET",
+ },
+ {
+ endpoint: "OUTBOX",
+ method: "GET",
+ },
+ ],
+ })
+
+ await browser.pause(10000)
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/home-page-device-not-connecting.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/home-page-device-not-connecting.e2e.ts
index e4ae33070e..a02f2785d1 100644
--- a/apps/mudita-center-e2e/src/specs/overview/home-page-device-not-connecting.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/overview/home-page-device-not-connecting.e2e.ts
@@ -46,7 +46,6 @@ describe("Home Screen Page", () => {
await tryAgainParagraph.click()
})
it("Click Contact Support & Verify Contents", async () => {
- screenshotHelper.makeViewScreenshot()
const contactSupportButton = await HomePage.contactSupportButton
const muditaCenterSupportModalHeader =
await HomePage.muditaCenterSupportModalHeader
diff --git a/apps/mudita-center-e2e/src/specs/overview/kompakt-about.ts b/apps/mudita-center-e2e/src/specs/overview/kompakt-about.ts
new file mode 100644
index 0000000000..dce12565fe
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/kompakt-about.ts
@@ -0,0 +1,128 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import { overviewDataWithOneSimCard } from "../../../../../libs/e2e-mock/responses/src"
+import homePage from "../../page-objects/home.page"
+import menu from "../../page-objects/menu.page"
+import overviewKompaktPage from "../../page-objects/overview-kompakt.page"
+import aboutKompaktPage from "../../page-objects/about-kompakt.page"
+import modalSarPage from "../../page-objects/modal-sar.page"
+import { kompaktImeiRegex } from "../../consts/regex-const"
+
+describe("Checking About your Kompakt", () => {
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ it("Connect device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: "first-serial-number",
+ })
+
+ await browser.pause(6000)
+ const menuOverviewLink = await menu.overviewLink
+ await menuOverviewLink.waitForDisplayed({ timeout: 10000 })
+ await expect(menuOverviewLink).toBeDisplayed()
+ })
+
+ it("Check SN", async () => {
+ const serialNumberValue = await overviewKompaktPage.serialNumberValue
+ await expect(serialNumberValue).toHaveText(
+ overviewDataWithOneSimCard.summary.about.serialNumber.text
+ )
+ })
+
+ it("Go to ABOUT YOUR DEVICE", async () => {
+ const aboutYourDevice = await overviewKompaktPage.aboutYourDevice
+ await aboutYourDevice.waitForClickable()
+ await aboutYourDevice.click()
+
+ // Header
+ const aboutHeader = await aboutKompaktPage.aboutHeader
+ await expect(aboutHeader).toBeDisplayed()
+ await expect(aboutHeader).toHaveText("About your device")
+ })
+
+ it("Verify About Your Device page", async () => {
+ // Subtitle
+ const aboutSubtitle = await aboutKompaktPage.aboutSubtitle
+ await expect(aboutSubtitle).toHaveText("Device details")
+ // SN
+ const serialNumberLabel = await aboutKompaktPage.serialNumberLabel
+ await expect(serialNumberLabel).toHaveText("Serial number")
+ const serialNumberValue = await aboutKompaktPage.serialNumberValue
+ await expect(serialNumberValue).toHaveText(
+ overviewDataWithOneSimCard.summary.about.serialNumber.text
+ )
+ // IMEI 1
+ const imei1Label = await aboutKompaktPage.imei1Label
+ await expect(imei1Label).toHaveText("IMEI (sim slot 1)")
+ const imei1Value = await aboutKompaktPage.imei1Value
+ const imei1 = await imei1Value.getText()
+ await expect(imei1Value).toHaveText(kompaktImeiRegex)
+ // IMEI 2
+ const imei2Label = await aboutKompaktPage.imei2Label
+ await expect(imei2Label).toHaveText("IMEI (sim slot 2)")
+ const imei2Value = await aboutKompaktPage.imei2Value
+ const imei2 = await imei2Value.getText()
+ await expect(imei2Value).toHaveText(kompaktImeiRegex)
+ //SAR
+ const sarLabel = await aboutKompaktPage.sarLabel
+ await expect(sarLabel).toHaveText("SAR")
+ const sarButton = await aboutKompaktPage.sarButton
+ await expect(sarButton).toHaveText("Check SAR information")
+ await expect(sarButton).toBeClickable()
+ })
+
+ it("Go to SAR information", async () => {
+ const sarButton = await aboutKompaktPage.sarButton
+ await sarButton.waitForClickable()
+ await sarButton.click()
+ const sarHeader = await aboutKompaktPage.sarHeader
+ await expect(sarHeader).toHaveText("SAR")
+ // TBD: SAR content + scroll
+ })
+
+ it("Close SAR information", async () => {
+ const modalCloseButton = await modalSarPage.modalCloseButton
+ await expect(modalCloseButton).toBeDisplayed()
+ await modalCloseButton.click()
+ })
+
+ it("Go to Overview", async () => {
+ const backToOverviewIcon = await aboutKompaktPage.backToOverviewIcon
+ await backToOverviewIcon.isDisplayed()
+
+ const backToOverviewLabel = await aboutKompaktPage.backToOverviewLabel
+ await backToOverviewLabel.isDisplayed()
+ backToOverviewLabel.click()
+
+ const header = await overviewKompaktPage.header
+ await header.isDisplayed()
+
+ const menuOverviewLink = await menu.overviewLink
+ await expect(menuOverviewLink).not.toBeClickable()
+ })
+
+ it("Disconnect the device and check if Welcome screen is present", async () => {
+ E2EMockClient.removeDevice("path-1")
+ const homeHeader = await homePage.homeHeader
+ await expect(homeHeader).toBeDisplayed()
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/kompakt-overview.ts b/apps/mudita-center-e2e/src/specs/overview/kompakt-overview.ts
new file mode 100644
index 0000000000..f01325dcf7
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/kompakt-overview.ts
@@ -0,0 +1,134 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import { overviewDataWithOneSimCard } from "../../../../../libs/e2e-mock/responses/src"
+import OverviewPage from "../../page-objects/overview.page"
+import OverviewKompaktPage from "../../page-objects/overview-kompakt.page"
+import HomePage from "../../page-objects/home.page"
+import tabsPage from "../../page-objects/tabs.page"
+import { kompaktImageRegex } from "../../consts/regex-const"
+
+describe("E2E mock sample - overview view", () => {
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: "first-serial-number",
+ })
+
+ await browser.pause(6000)
+ const menuItem = await $(`//a[@href="#/generic/mc-overview"]`)
+
+ await menuItem.waitForDisplayed({ timeout: 10000 })
+ await expect(menuItem).toBeDisplayed()
+ })
+
+ it("Verify Overview Page", async () => {
+ const kompaktImage = await OverviewKompaktPage.kompaktImage
+ await expect(kompaktImage).toBeDisplayed()
+ await expect(kompaktImage).toHaveAttribute("src", kompaktImageRegex)
+
+ const kompaktOsVersion = await OverviewKompaktPage.kompaktOsVersion
+ await expect(kompaktOsVersion).toBeDisplayed()
+ await expect(kompaktOsVersion).toHaveText("Mudita OS")
+
+ const kompaktOsVersionLabel =
+ await OverviewKompaktPage.kompaktOsVersionLabel
+ await expect(kompaktOsVersionLabel).toBeDisplayed()
+ await expect(kompaktOsVersionLabel).toHaveText("Current version:")
+
+ const serialNumberLabel = await OverviewKompaktPage.serialNumberLabel
+ const serialNumberValue = await OverviewKompaktPage.serialNumberValue
+ await expect(serialNumberLabel).toHaveText("Serial number")
+ await expect(serialNumberValue).toHaveText(
+ overviewDataWithOneSimCard.summary.about.serialNumber.text.toString()
+ )
+
+ const aboutYourDevice = await OverviewKompaktPage.aboutYourDevice
+ await expect(aboutYourDevice).toBeDisplayed()
+ await expect(aboutYourDevice).toBeClickable
+ await aboutYourDevice.click()
+
+ const sarInformationButtonKompakt =
+ await OverviewKompaktPage.sarInformationButtonKompakt
+ const sarInformationPopup = await OverviewKompaktPage.sarInformationPopup
+ await expect(sarInformationButtonKompakt).toBeDisplayed()
+ await sarInformationButtonKompakt.click()
+ await expect(sarInformationPopup).toBeDisplayed()
+
+ const sarInformationPopupCloseButton =
+ await OverviewKompaktPage.sarInformationPopupCloseButton
+ await sarInformationPopupCloseButton.waitForClickable()
+ await sarInformationPopupCloseButton.click()
+
+ const backArrowButton = OverviewKompaktPage.backArrowButton
+ await backArrowButton.waitForClickable()
+ await backArrowButton.click()
+
+ const createBackupButton = await OverviewPage.createBackupButton
+ await expect(createBackupButton).toBeDisplayed()
+ await expect(createBackupButton).toBeClickable()
+
+ const backupInfo = await OverviewKompaktPage.backupInfo
+ await expect(backupInfo).toBeDisplayed()
+ await expect(backupInfo).toHaveTextContaining(
+ "You haven’t backed up your device yet.\nCreate a backup file to protect against data loss."
+ )
+
+ const kompaktBatteryIcon = await OverviewKompaktPage.kompaktBatteryIcon
+ await expect(kompaktBatteryIcon).toBeDisplayed()
+
+ const kompaktBatteryLevelValue =
+ await OverviewKompaktPage.kompaktBatteryLevelValue
+ await expect(kompaktBatteryLevelValue).toBeDisplayed()
+ await expect(kompaktBatteryLevelValue).toHaveText("100%")
+
+ const kompaktNetworkName = await OverviewKompaktPage.kompaktNetworkName
+ await expect(kompaktNetworkName).toBeDisplayed()
+ await expect(kompaktNetworkName).toHaveText("T-Mobile")
+
+ const kompaktSignalIcon = await OverviewKompaktPage.kompaktSignalIcon
+ await expect(kompaktSignalIcon).toBeDisplayed()
+ await expect(kompaktSignalIcon).toHaveAttributeContaining(
+ "data-testid",
+ "icon-network-signal-2"
+ )
+
+ const kompaktSimCard1Subtext =
+ await OverviewKompaktPage.kompaktSimCard1Subtext
+ await expect(kompaktSimCard1Subtext).toBeDisplayed()
+ await expect(kompaktSimCard1Subtext).toHaveText("SIM 1")
+ })
+
+ it("Click between Tabs and check them", async () => {
+ const muditaNewsTab = await tabsPage.muditaNewsTab
+ await muditaNewsTab.waitForClickable()
+ await muditaNewsTab.click()
+
+ const overviewKompaktTab = await tabsPage.overviewKompaktTab
+ await overviewKompaktTab.waitForClickable()
+ await overviewKompaktTab.click()
+ })
+
+ it("Disconnect the device and check if Welcome screen is present", async () => {
+ E2EMockClient.removeDevice("path-1")
+ await HomePage.homeHeader.waitForDisplayed()
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/overview/kompakt-switching-devices.ts b/apps/mudita-center-e2e/src/specs/overview/kompakt-switching-devices.ts
new file mode 100644
index 0000000000..ad35d88fe8
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/overview/kompakt-switching-devices.ts
@@ -0,0 +1,149 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ overviewDataWithOneSimCard,
+ overviewDataWithOneSimCard2nd,
+} from "../../../../../libs/e2e-mock/responses/src"
+import OverviewKompaktPage from "../../page-objects/overview-kompakt.page"
+import HomePage from "../../page-objects/home.page"
+import { kompaktImageRegex } from "../../consts/regex-const"
+import overviewPage from "../../page-objects/overview.page"
+import drawerPage from "../../page-objects/drawer.page"
+
+describe("Kompakt switching devices", () => {
+ const firstSerialNumber = "KOM1234567890"
+ const secondSerialNumber = "KOM1234567892"
+
+ before(async () => {
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: "path-1",
+ serialNumber: firstSerialNumber,
+ })
+
+ await browser.pause(6000)
+ const menuItem = await $(`//a[@href="#/generic/mc-overview"]`)
+
+ await menuItem.waitForDisplayed({ timeout: 10000 })
+ await expect(menuItem).toBeDisplayed()
+ })
+
+ it("Verify Overview Page", async () => {
+ const kompaktImage = await OverviewKompaktPage.kompaktImage
+ await expect(kompaktImage).toBeDisplayed()
+ await expect(kompaktImage).toHaveAttribute("src", kompaktImageRegex)
+
+ const kompaktOsVersion = await OverviewKompaktPage.kompaktOsVersion
+ await expect(kompaktOsVersion).toBeDisplayed()
+
+ const kompaktSimCard1Subtext =
+ await OverviewKompaktPage.kompaktSimCard1Subtext
+ await expect(kompaktSimCard1Subtext).toHaveText("SIM 1")
+
+ const kompaktNetworkName = await OverviewKompaktPage.kompaktNetworkName
+ await expect(kompaktNetworkName).toBeDisplayed()
+ await expect(kompaktNetworkName).toHaveText("T-Mobile")
+
+ const kompaktBatteryLevelValue =
+ await OverviewKompaktPage.kompaktBatteryLevelValue
+ await expect(kompaktBatteryLevelValue).toBeDisplayed()
+ await expect(kompaktBatteryLevelValue).toHaveText("100%")
+ })
+
+ it("Connect 2nd device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-2",
+ body: overviewDataWithOneSimCard2nd,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: "path-2",
+ serialNumber: secondSerialNumber,
+ })
+
+ await browser.pause(6000)
+ })
+
+ it("Check Drawer Modal and Switch to 2nd device", async () => {
+ const deviceSelectDrawer = await drawerPage.deviceSelectDrawer
+ await expect(deviceSelectDrawer).toBeDisplayed()
+
+ const deviceImageOnDrawer = await drawerPage.deviceImageOnDrawer
+ await expect(deviceImageOnDrawer).toBeDisplayed()
+
+ const firstDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ firstSerialNumber
+ )
+ await expect(firstDeviceOnDrawer).toBeDisplayed()
+ const secondDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ secondSerialNumber
+ )
+ await expect(secondDeviceOnDrawer).toBeDisplayed()
+ await secondDeviceOnDrawer.waitForClickable()
+ await secondDeviceOnDrawer.click()
+ })
+
+ it("Verify Overview Page for 2nd device", async () => {
+ const kompaktImage = await OverviewKompaktPage.kompaktImage
+ await expect(kompaktImage).toBeDisplayed()
+ await expect(kompaktImage).toHaveAttribute("src", kompaktImageRegex)
+
+ const kompaktOsVersion = await OverviewKompaktPage.kompaktOsVersion
+ await expect(kompaktOsVersion).toBeDisplayed()
+
+ const kompaktSimCard1Subtext =
+ await OverviewKompaktPage.kompaktSimCard1Subtext
+ await expect(kompaktSimCard1Subtext).toHaveText("SIM 1")
+
+ const kompaktNetworkName = await OverviewKompaktPage.kompaktNetworkName
+ await expect(kompaktNetworkName).toBeDisplayed()
+ await expect(kompaktNetworkName).toHaveText("Play")
+
+ const kompaktBatteryLevelValue =
+ await OverviewKompaktPage.kompaktBatteryLevelValue
+ await expect(kompaktBatteryLevelValue).toBeDisplayed()
+ await expect(kompaktBatteryLevelValue).toHaveText("40%")
+ })
+
+ it("Verify Select Connected Devices, click on it and select 1st Kompakt", async () => {
+ const selectConnectedDevices = await overviewPage.selectConnectedDevices
+ await selectConnectedDevices.waitForClickable()
+ await expect(selectConnectedDevices).toHaveText("2")
+ await selectConnectedDevices.click()
+
+ const firstDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ firstSerialNumber
+ )
+ await expect(firstDeviceOnDrawer).toBeDisplayed()
+ await firstDeviceOnDrawer.waitForClickable()
+ await firstDeviceOnDrawer.click()
+ })
+
+ it("Disconnect the devices and check if Welcome Page is present", async () => {
+ E2EMockClient.removeDevice("path-1")
+ E2EMockClient.removeDevice("path-2")
+
+ const homeHeader = await HomePage.homeHeader
+ await homeHeader.waitForDisplayed()
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/settings/mc-version-check-for-updates-offline.e2e.ts b/apps/mudita-center-e2e/src/specs/settings/mc-version-check-for-updates-offline.e2e.ts
index 08384d3792..8d48cfc2d7 100644
--- a/apps/mudita-center-e2e/src/specs/settings/mc-version-check-for-updates-offline.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/settings/mc-version-check-for-updates-offline.e2e.ts
@@ -5,19 +5,45 @@
import SettingsPage from "../../page-objects/settings.page"
import NavigationTabs from "../../page-objects/tabs.page"
-import ModalPage from "../../page-objects/mc-update-modal.page"
+import ModalPage from "../../page-objects/modal.page"
+import McUpdateModalPage from "../../page-objects/mc-update-modal.page"
import HomePage from "../../page-objects/home.page"
-import TestHelper from "../../helpers/tests.helper"
+import testsHelper from "../../helpers/tests.helper"
import dns from "node:dns"
+import screenshotHelper from "../../helpers/screenshot.helper"
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
describe("Checking for Mudita Center updates", () => {
before(async function () {
- if (TestHelper.isLinux()) {
+ if (testsHelper.isLinux()) {
this.skip()
}
- dns.setDefaultResultOrder("ipv4first")
- await browser.throttle("offline")
+ E2EMockClient.connect()
+ //wait for a connection to be established
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+
+ // Clear browser cache
+ await browser.deleteAllCookies()
+ await browser.execute("window.localStorage.clear();")
+ await browser.execute("window.sessionStorage.clear();")
+
+ // Switch to offline mode before starting the tests
+ await browser.setNetworkConditions({
+ offline: true,
+ latency: 0,
+ download_throughput: 0,
+ upload_throughput: 0,
+ })
+
+ // Add a small delay to ensure network conditions are applied
+ await browser.pause(1000)
+
+ // Verify network conditions
+ const isOnline = await testsHelper.isOnline()
+ await expect(isOnline).toBeFalsy()
const notNowButton = await HomePage.notNowButton
await notNowButton.waitForDisplayed()
@@ -32,17 +58,6 @@ describe("Checking for Mudita Center updates", () => {
const aboutTab = await SettingsPage.aboutTab
await aboutTab.waitForDisplayed()
await aboutTab.click()
-
- const aboutCheckForUpdateFailedLabel =
- await SettingsPage.aboutCheckForUpdateFailedLabel
- await browser.executeAsync((done) => {
- setTimeout(done, 10000)
- })
-
- await expect(aboutCheckForUpdateFailedLabel).toBeDisplayed()
- await expect(aboutCheckForUpdateFailedLabel).toHaveText(
- "Checking for updates failed"
- )
})
it("Check 'Check for updates' button", async () => {
@@ -61,14 +76,48 @@ describe("Checking for Mudita Center updates", () => {
it("Check for updates", async () => {
const checkingFailedUpdateSubtitle =
- await ModalPage.checkingFailedUpdateSubtitle
+ await McUpdateModalPage.checkingFailedUpdateSubtitle
await expect(checkingFailedUpdateSubtitle).toBeDisplayed()
await expect(checkingFailedUpdateSubtitle).toHaveText("Checking failed")
- const checkingFailedUpdateBody = await ModalPage.checkingFailedUpdateBody
+ const checkingFailedUpdateBody =
+ await McUpdateModalPage.checkingFailedUpdateBody
await expect(checkingFailedUpdateBody).toBeDisplayed()
await expect(checkingFailedUpdateBody).toHaveText(
- "Opps, something went wrong. \nPlease check your internet connection"
+ "Oops, something went wrong. \nPlease check your internet connection"
)
+
+ await ModalPage.closeModalButtonClick()
+ })
+ it("Check Settings -> About checking failed label", async () => {
+ screenshotHelper.makeViewScreenshot()
+ const aboutCheckForUpdateFailedLabel =
+ await SettingsPage.aboutCheckForUpdateFailedLabel
+
+ await expect(aboutCheckForUpdateFailedLabel).toBeDisplayed()
+
+ await expect(aboutCheckForUpdateFailedLabel).toHaveText(
+ "Checking for updates failed"
+ )
+ })
+
+ after(async () => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+
+ // Switch back to online mode after finishing the tests
+ await browser.setNetworkConditions({
+ offline: false,
+ latency: 0,
+ download_throughput: -1,
+ upload_throughput: -1,
+ })
+
+ // Add a small delay to ensure network conditions are applied
+ await browser.pause(1000)
+
+ // Verify network conditions
+ const isOnline = await testsHelper.isOnline()
+ await expect(isOnline).toBeTruthy()
})
})
diff --git a/apps/mudita-center-e2e/src/specs/settings/privacy-policy.e2e.ts b/apps/mudita-center-e2e/src/specs/settings/privacy-policy.e2e.ts
index 1e0ffdebe1..791986c667 100644
--- a/apps/mudita-center-e2e/src/specs/settings/privacy-policy.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/settings/privacy-policy.e2e.ts
@@ -8,6 +8,8 @@ import NavigationTabs from "../../page-objects/tabs.page"
import HomePage from "../../page-objects/home.page"
import modalPrivacyPolicyPage from "../../page-objects/modal-privacy-policy.page"
import ModalPage from "../../page-objects/modal.page"
+import { sleep } from "../../helpers/sleep.helper"
+import testsHelper from "../../helpers/tests.helper"
describe("Checking Privacy Policy", () => {
before(async function () {
@@ -35,6 +37,10 @@ describe("Checking Privacy Policy", () => {
})
it("Check Privacy Policy 'LEARN MORE' button", async () => {
+ if(testsHelper.isLinux()){
+ sleep(5000)
+ }
+
const aboutPrivacyPolicyButton = await SettingsPage.aboutPrivacyPolicyButton
await expect(aboutPrivacyPolicyButton).toHaveText("LEARN MORE")
await aboutPrivacyPolicyButton.click()
diff --git a/apps/mudita-center-e2e/src/specs/settings/terms-of-service.e2e.ts b/apps/mudita-center-e2e/src/specs/settings/terms-of-service.e2e.ts
index b39ab8f779..ab8c6c3fa9 100644
--- a/apps/mudita-center-e2e/src/specs/settings/terms-of-service.e2e.ts
+++ b/apps/mudita-center-e2e/src/specs/settings/terms-of-service.e2e.ts
@@ -8,6 +8,8 @@ import NavigationTabs from "../../page-objects/tabs.page"
import HomePage from "../../page-objects/home.page"
import ModalTermsOfServicePage from "../../page-objects/modal-terms-of-service.page"
import ModalPage from "../../page-objects/modal.page"
+import { sleep } from "../../helpers/sleep.helper"
+import testsHelper from "../../helpers/tests.helper"
describe("Checking Terms of service", () => {
before(async function () {
@@ -35,8 +37,13 @@ describe("Checking Terms of service", () => {
})
it("Check Terms of service 'LEARN MORE' button", async () => {
+ if(testsHelper.isLinux()){
+ sleep(5000)
+ }
+
const aboutTermsOfServiceButton =
await SettingsPage.aboutTermsOfServiceButton
+
await expect(aboutTermsOfServiceButton).toHaveText("LEARN MORE")
await aboutTermsOfServiceButton.click()
diff --git a/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts b/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts
new file mode 100644
index 0000000000..8fdb23453c
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts
@@ -0,0 +1,232 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ overviewDataWithOneSimCard,
+ overviewDataWithOneSimCard2nd,
+ overviewDataWithOneSimCard3rd,
+ overviewDataWithOneSimCard4th,
+ overviewDataWithOneSimCard5th,
+ overviewDataWithOneSimCard6th,
+} from "../../../../../libs/e2e-mock/responses/src"
+import OverviewKompaktPage from "../../page-objects/overview-kompakt.page"
+import HomePage from "../../page-objects/home.page"
+import { kompaktImageRegex } from "../../consts/regex-const"
+import selectDevicePage from "../../page-objects/select-device.page"
+
+describe("Kompakt switching devices", () => {
+ const firstSerialNumber = "KOM1234567890"
+ const secondSerialNumber = "KOM1234567892"
+ const thirdSerialNumber = "KOM1234567893"
+ const fourthSerialNumber = "KOM1234567894"
+ const fifthSerialNumber = "KOM1234567895"
+ const sixthSerialNumber = "KOM1234567896"
+
+ before(async () => {
+ E2EMockClient.connect()
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect 1,2 Kompakt devices", async () => {
+ const devices = [
+ {
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ serialNumber: firstSerialNumber,
+ },
+ {
+ path: "path-2",
+ body: overviewDataWithOneSimCard2nd,
+ serialNumber: secondSerialNumber,
+ },
+ ]
+
+ const mockResponses = devices.map((device) => {
+ E2EMockClient.mockResponse({
+ path: device.path,
+ body: device.body,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ return E2EMockClient.addDevice({
+ path: device.path,
+ serialNumber: device.serialNumber,
+ })
+ })
+ await Promise.all(mockResponses)
+ await browser.pause(6000)
+ })
+
+ it("Check Select Device Modal and verify Devices 1 and 2", async () => {
+ const selectADeviceToContinueTitle =
+ await selectDevicePage.selectADeviceToContinueTitle
+ await expect(selectADeviceToContinueTitle).toHaveText(
+ "Select a device to continue"
+ )
+
+ const availableDevices = selectDevicePage.availableDevices
+ await expect(availableDevices).toBeDisplayed()
+
+ const firstDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(1)
+ const secondDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(2)
+
+ await expect(firstDeviceOnSelectModal).toBeDisplayed()
+ await expect(secondDeviceOnSelectModal).toBeDisplayed()
+
+ const selectDeviceModalSerialNumbers =
+ selectDevicePage.selectDeviceSerialNumber
+ const selectDeviceModalNames = selectDevicePage.selectDeviceName
+
+ const firstDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[0].getText()
+ await expect(firstDeviceSerialNumber).toEqual(firstSerialNumber)
+ const firstDeviceName = await selectDeviceModalNames[0]
+ await expect(firstDeviceName).toHaveText("Kompakt")
+
+ const secondDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[1].getText()
+ await expect(secondDeviceSerialNumber).toEqual(secondSerialNumber)
+ const secondDeviceName = await selectDeviceModalNames[1]
+ await expect(secondDeviceName).toHaveText("Kompakt")
+ })
+
+ it("Connect 3,4,5,6 Kompakt devices", async () => {
+ const devices = [
+ {
+ path: "path-3",
+ body: overviewDataWithOneSimCard3rd,
+ serialNumber: thirdSerialNumber,
+ },
+ {
+ path: "path-4",
+ body: overviewDataWithOneSimCard4th,
+ serialNumber: fourthSerialNumber,
+ },
+ {
+ path: "path-5",
+ body: overviewDataWithOneSimCard5th,
+ serialNumber: fifthSerialNumber,
+ },
+ {
+ path: "path-6",
+ body: overviewDataWithOneSimCard6th,
+ serialNumber: sixthSerialNumber,
+ },
+ ]
+
+ for (const device of devices) {
+ E2EMockClient.mockResponse({
+ path: device.path,
+ body: device.body,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: device.path,
+ serialNumber: device.serialNumber,
+ })
+
+ await browser.pause(6000)
+ }
+ })
+
+ it("Verify Devices 3, 4, 5, 6", async () => {
+ const thirdDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(1)
+ const fourthDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(2)
+
+ await expect(thirdDeviceOnSelectModal).toBeDisplayed()
+ await expect(fourthDeviceOnSelectModal).toBeDisplayed()
+
+ const selectDeviceModalSerialNumbers =
+ selectDevicePage.selectDeviceSerialNumber
+ const selectDeviceModalNames = selectDevicePage.selectDeviceName
+
+ const thirdDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[2].getText()
+ await expect(thirdDeviceSerialNumber).toEqual(thirdSerialNumber)
+ const thirdDeviceName = await selectDeviceModalNames[2]
+ await expect(thirdDeviceName).toHaveText("Kompakt")
+
+ const fourthDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[3].getText()
+ await expect(fourthDeviceSerialNumber).toEqual(fourthSerialNumber)
+ const fourthDeviceName = await selectDeviceModalNames[3]
+ await expect(fourthDeviceName).toHaveText("Kompakt")
+
+ const fifthDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(1)
+ const sixthDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(2)
+
+ await expect(fifthDeviceOnSelectModal).toBeDisplayed()
+ await expect(sixthDeviceOnSelectModal).toBeDisplayed()
+
+ const fifthDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[4].getText()
+ await expect(fifthDeviceSerialNumber).toEqual(fifthSerialNumber)
+ const fifthDeviceName = await selectDeviceModalNames[4]
+ await expect(fifthDeviceName).toHaveText("Kompakt")
+
+ const sixthDeviceSerialNumber =
+ await selectDeviceModalSerialNumbers[5].getText()
+ await expect(sixthDeviceSerialNumber).toEqual(sixthSerialNumber)
+ const sixthDeviceName = await selectDeviceModalNames[5]
+ await expect(sixthDeviceName).toHaveText("Kompakt")
+ })
+
+ it("Switch to 6th device", async () => {
+ const sixthDeviceOnSelectModal =
+ await selectDevicePage.getDeviceOnSelectModal(6)
+
+ await expect(sixthDeviceOnSelectModal).toBeDisplayed()
+ await sixthDeviceOnSelectModal.waitForClickable()
+ await sixthDeviceOnSelectModal.click()
+ })
+
+ it("Verify Overview Page for 6th device", async () => {
+ const kompaktImage = await OverviewKompaktPage.kompaktImage
+ await expect(kompaktImage).toBeDisplayed()
+ await expect(kompaktImage).toHaveAttribute("src", kompaktImageRegex)
+
+ const kompaktOsVersion = await OverviewKompaktPage.kompaktOsVersion
+ await expect(kompaktOsVersion).toBeDisplayed()
+ await expect(kompaktOsVersion).toHaveText("Mudita OS")
+
+ const kompaktSimCard1Subtext =
+ await OverviewKompaktPage.kompaktSimCard1Subtext
+ await expect(kompaktSimCard1Subtext).toHaveText("SIM 1")
+
+ const kompaktNetworkName = await OverviewKompaktPage.kompaktNetworkName
+ await expect(kompaktNetworkName).toBeDisplayed()
+ await expect(kompaktNetworkName).toHaveText("Telia")
+
+ const kompaktBatteryLevelValue =
+ await OverviewKompaktPage.kompaktBatteryLevelValue
+ await expect(kompaktBatteryLevelValue).toBeDisplayed()
+ await expect(kompaktBatteryLevelValue).toHaveText("20%")
+ })
+
+ it("Disconnect the devices and check if News page is present", async () => {
+ E2EMockClient.removeDevice("path-1")
+ E2EMockClient.removeDevice("path-2")
+ E2EMockClient.removeDevice("path-3")
+ E2EMockClient.removeDevice("path-4")
+ E2EMockClient.removeDevice("path-5")
+ E2EMockClient.removeDevice("path-6")
+
+ const homeHeader = await HomePage.homeHeader
+ await homeHeader.waitForDisplayed()
+ await expect(homeHeader).toHaveText("Welcome to Mudita Center")
+ })
+})
diff --git a/apps/mudita-center-e2e/src/specs/stress-tests/device-drawer-stress-test.ts b/apps/mudita-center-e2e/src/specs/stress-tests/device-drawer-stress-test.ts
new file mode 100644
index 0000000000..0c6c5a17cb
--- /dev/null
+++ b/apps/mudita-center-e2e/src/specs/stress-tests/device-drawer-stress-test.ts
@@ -0,0 +1,248 @@
+import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
+import {
+ overviewDataWithOneSimCard,
+ overviewDataWithOneSimCard2nd,
+ overviewDataWithOneSimCard3rd,
+ overviewDataWithOneSimCard4th,
+ overviewDataWithOneSimCard5th,
+ overviewDataWithOneSimCard6th,
+} from "../../../../../libs/e2e-mock/responses/src"
+import OverviewKompaktPage from "../../page-objects/overview-kompakt.page"
+import HomePage from "../../page-objects/home.page"
+import overviewPage from "../../page-objects/overview.page"
+import drawerPage from "../../page-objects/drawer.page"
+
+describe("Kompakt switching devices", () => {
+ const firstSerialNumber = "KOM1234567890"
+ const secondSerialNumber = "KOM1234567892"
+ const thirdSerialNumber = "KOM1234567893"
+ const fourthSerialNumber = "KOM1234567894"
+ const fifthSerialNumber = "KOM1234567895"
+ const sixthSerialNumber = "KOM1234567896"
+
+ before(async () => {
+ E2EMockClient.connect()
+ await browser.waitUntil(() => {
+ return E2EMockClient.checkConnection()
+ })
+ })
+
+ after(() => {
+ E2EMockClient.stopServer()
+ E2EMockClient.disconnect()
+ })
+
+ it("Connect 1,2 Kompakt devices", async () => {
+ const devices = [
+ {
+ path: "path-1",
+ body: overviewDataWithOneSimCard,
+ serialNumber: firstSerialNumber,
+ },
+ {
+ path: "path-2",
+ body: overviewDataWithOneSimCard2nd,
+ serialNumber: secondSerialNumber,
+ },
+ ]
+
+ for (const device of devices) {
+ E2EMockClient.mockResponse({
+ path: device.path,
+ body: device.body,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: device.path,
+ serialNumber: device.serialNumber,
+ })
+
+ await browser.pause(6000)
+ }
+ })
+
+ it("Verify Devices 1 and 2 on Drawer and check their Serial Numbers", async () => {
+ const deviceSelectDrawer = await drawerPage.deviceSelectDrawer
+ await expect(deviceSelectDrawer).toBeDisplayed()
+
+ const deviceImageOnDrawer = await drawerPage.deviceImageOnDrawer
+ await expect(deviceImageOnDrawer).toBeDisplayed()
+
+ const firstDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ firstSerialNumber
+ )
+ const secondDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ secondSerialNumber
+ )
+ await expect(firstDeviceOnDrawer).toBeDisplayed()
+ await expect(secondDeviceOnDrawer).toBeDisplayed()
+
+ const drawerSerialNumbers = await drawerPage.drawerDeviceSerialNumber
+
+ const devices = [
+ { serialNumber: firstSerialNumber, index: 0 },
+ { serialNumber: secondSerialNumber, index: 1 },
+ ]
+
+ for (const device of devices) {
+ const deviceSerialNumber = await drawerSerialNumbers[
+ device.index
+ ].getText()
+ await expect(deviceSerialNumber).toEqual(device.serialNumber)
+ }
+ })
+
+ it("Connect 3rd Kompakt device", async () => {
+ E2EMockClient.mockResponse({
+ path: "path-3",
+ body: overviewDataWithOneSimCard3rd,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: "path-3",
+ serialNumber: thirdSerialNumber,
+ })
+
+ await browser.pause(6000)
+ const menuItem = await $(`//a[@href="#/generic/mc-overview"]`)
+
+ await menuItem.waitForDisplayed({ timeout: 10000 })
+ await expect(menuItem).toBeDisplayed()
+ })
+
+ it("Verify Device 3 on the Drawer and check the Serial Number", async () => {
+ const deviceSelectDrawer = await drawerPage.deviceSelectDrawer
+ await expect(deviceSelectDrawer).toBeDisplayed()
+
+ const deviceImageOnDrawer = await drawerPage.deviceImageOnDrawer
+ await expect(deviceImageOnDrawer).toBeDisplayed()
+
+ const thirdDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ thirdSerialNumber
+ )
+
+ await expect(thirdDeviceOnDrawer).toBeDisplayed()
+
+ const drawerSerialNumbers = drawerPage.drawerDeviceSerialNumber
+
+ const thirdDrawerDeviceSerialNumber = await drawerSerialNumbers[2].getText()
+ await expect(thirdDrawerDeviceSerialNumber).toEqual(thirdSerialNumber)
+ })
+
+ it("Connect 4,5,6 Kompakt devices", async () => {
+ const devices = [
+ {
+ path: "path-4",
+ body: overviewDataWithOneSimCard4th,
+ serialNumber: fourthSerialNumber,
+ },
+ {
+ path: "path-5",
+ body: overviewDataWithOneSimCard5th,
+ serialNumber: fifthSerialNumber,
+ },
+ {
+ path: "path-6",
+ body: overviewDataWithOneSimCard6th,
+ serialNumber: sixthSerialNumber,
+ },
+ ]
+
+ for (const device of devices) {
+ E2EMockClient.mockResponse({
+ path: device.path,
+ body: device.body,
+ endpoint: "FEATURE_DATA",
+ method: "GET",
+ status: 200,
+ })
+ E2EMockClient.addDevice({
+ path: device.path,
+ serialNumber: device.serialNumber,
+ })
+
+ await browser.pause(6000)
+ }
+ })
+
+ it("Verify Devices 4,5 and 6 on Drawer and check their Serial Numbers, scroll down and select 6th Kompakt", async () => {
+ const deviceSelectDrawer = await drawerPage.deviceSelectDrawer
+ await expect(deviceSelectDrawer).toBeDisplayed()
+
+ const deviceImageOnDrawer = await drawerPage.deviceImageOnDrawer
+ await expect(deviceImageOnDrawer).toBeDisplayed()
+
+ const fourthDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ fourthSerialNumber
+ )
+ const fifthDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ fifthSerialNumber
+ )
+ const sixthDeviceOnDrawer = await drawerPage.getDeviceOnDrawer(
+ sixthSerialNumber
+ )
+ await expect(fourthDeviceOnDrawer).toBeDisplayed()
+ await expect(fifthDeviceOnDrawer).toBeDisplayed()
+ await expect(sixthDeviceOnDrawer).toBeDisplayed()
+
+ const drawerSerialNumbers = await drawerPage.drawerDeviceSerialNumber
+ const drawerDeviceNames = await drawerPage.drawerDeviceName
+
+ const devices = [
+ { serialNumber: fourthSerialNumber, name: "Kompakt", index: 3 },
+ { serialNumber: fifthSerialNumber, name: "Kompakt", index: 4 },
+ { serialNumber: sixthSerialNumber, name: "Kompakt", index: 5 },
+ ]
+
+ for (const device of devices) {
+ const deviceSerialNumber = await drawerSerialNumbers[
+ device.index
+ ].getText()
+ await expect(deviceSerialNumber).toEqual(device.serialNumber)
+
+ const deviceName = await drawerDeviceNames[device.index]
+ await expect(deviceName).toHaveText(device.name)
+ }
+
+ await browser.execute(() => {
+ window.scrollBy(0, 500)
+ })
+
+ await browser.pause(1000)
+
+ await sixthDeviceOnDrawer.waitForClickable()
+ await sixthDeviceOnDrawer.click()
+ })
+
+ it("Verify 6th Kompakt with new Serial Number and click Show connected devices", async () => {
+ const serialNumberLabel = await OverviewKompaktPage.serialNumberLabel
+ const serialNumberValue = await OverviewKompaktPage.serialNumberValue
+ await expect(serialNumberLabel).toHaveText("Serial number")
+ await expect(serialNumberValue).toHaveText(
+ overviewDataWithOneSimCard6th.summary.about.serialNumber.text.toString()
+ )
+ const selectConnectedDevices = await overviewPage.selectConnectedDevices
+ await selectConnectedDevices.waitForClickable()
+ await expect(selectConnectedDevices).toHaveText("6")
+ await selectConnectedDevices.click()
+ })
+
+ it("Disconnect the devices and check if Welcome Page is present", async () => {
+ E2EMockClient.removeDevice("path-1")
+ E2EMockClient.removeDevice("path-2")
+ E2EMockClient.removeDevice("path-3")
+ E2EMockClient.removeDevice("path-4")
+ E2EMockClient.removeDevice("path-5")
+ E2EMockClient.removeDevice("path-6")
+
+ const homeHeader = await HomePage.homeHeader
+ await homeHeader.waitForDisplayed()
+ })
+})
+
+const devicePaths = ["path-1", "path-2", "path-3", "path-4", "path-5", "path-6"]
+devicePaths.forEach((path) => E2EMockClient.removeDevice(path))
diff --git a/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts b/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts
index 10e4e12dc3..0ab7dc591e 100644
--- a/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts
+++ b/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts
@@ -18,5 +18,14 @@ export enum TestFilesPaths {
privacyPolicyTest = "src/specs/settings/privacy-policy.e2e.ts",
licenseTest = "src/specs/settings/license.e2e.ts",
helpWindowCheckOfflineTest = "src/specs/help/help-window-check-offline.e2e.ts",
+ mcHomePageForceUpdateTest = "src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts",
+ mcHomePageForceUpdateErrorTest = "src/specs/overview/e2e-mock-mc-force-update-error.e2e.ts",
+ mcHomePageSoftUpdateTest = "src/specs/overview/e2e-mock-mc-soft-update-available.e2e.ts",
+ mcHomePageSoftUpdateErrorTest = "src/specs/overview/e2e-mock-mc-soft-update-error.e2e.ts",
+ kompaktOverview = "src/specs/overview/kompakt-overview.ts",
+ kompaktSwitchingDevices = "src/specs/overview/kompakt-switching-devices.ts",
+ kompaktAbout = "src/specs/overview/kompakt-about.ts",
+ kompaktConnectedDevicesModalStressTest = "src/specs/stress-tests/connected-devices-stress-test.ts",
+ kompaktDrawerStressTest = "src/specs/stress-tests/device-drawer-stress-test.ts",
}
export const toRelativePath = (path: string) => `./${path}`
diff --git a/apps/mudita-center-e2e/wdio.conf.ts b/apps/mudita-center-e2e/wdio.conf.ts
index e51198e7c5..2da0d93030 100644
--- a/apps/mudita-center-e2e/wdio.conf.ts
+++ b/apps/mudita-center-e2e/wdio.conf.ts
@@ -63,29 +63,44 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.termsOfServiceTest),
toRelativePath(TestFilesPaths.backupLocationTest),
toRelativePath(TestFilesPaths.mcCheckForUpdatesOfflineTest),
- toRelativePath(TestFilesPaths.e2eMockSample),
toRelativePath(TestFilesPaths.privacyPolicyTest),
toRelativePath(TestFilesPaths.licenseTest),
toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest),
+ toRelativePath(TestFilesPaths.kompaktOverview),
+ toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateErrorTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateErrorTest),
+ toRelativePath(TestFilesPaths.kompaktAbout),
+ toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
+ toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
],
suites: {
standalone: [
- toRelativePath(TestFilesPaths.helpWindowCheckTest),
- toRelativePath(TestFilesPaths.mcCheckForUpdatesTest),
- toRelativePath(TestFilesPaths.homePageTestDeviceNotConnectedTest),
+ //toRelativePath(TestFilesPaths.helpWindowCheckTest),
+ //toRelativePath(TestFilesPaths.homePageTestDeviceNotConnectedTest),
toRelativePath(TestFilesPaths.newsPageOnlineTest),
toRelativePath(TestFilesPaths.termsOfServiceTest),
toRelativePath(TestFilesPaths.backupLocationTest),
- toRelativePath(TestFilesPaths.mcCheckForUpdatesOfflineTest),
- toRelativePath(TestFilesPaths.homePageTestDeviceNotConnectedTest),
- toRelativePath(TestFilesPaths.newsPageOnlineTest),
- toRelativePath(TestFilesPaths.termsOfServiceTest),
- toRelativePath(TestFilesPaths.e2eMockSample),
toRelativePath(TestFilesPaths.privacyPolicyTest),
toRelativePath(TestFilesPaths.licenseTest),
- toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest),
],
- mock: [toRelativePath(TestFilesPaths.e2eMockSample)],
+ mock: [
+ toRelativePath(TestFilesPaths.mcCheckForUpdatesTest),
+ toRelativePath(TestFilesPaths.mcCheckForUpdatesOfflineTest),
+ toRelativePath(TestFilesPaths.newsPageOfflineTest),
+ //toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateErrorTest),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateErrorTest),
+ toRelativePath(TestFilesPaths.kompaktOverview),
+ toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
+ toRelativePath(TestFilesPaths.kompaktAbout),
+ toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
+ toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
+ ],
multidevicePureHarmony: [],
multideviceSingleHarmony: [],
multideviceSinglePure: [],
@@ -97,17 +112,26 @@ export const config: Options.Testrunner = {
pure: [toRelativePath(TestFilesPaths.messagesInAppNavigationTest)],
kompakt: [],
deviceUpdate: [],
- cicd: [
- toRelativePath(TestFilesPaths.helpWindowCheckTest),
+ cicdStandalone: [
+ //toRelativePath(TestFilesPaths.helpWindowCheckTest),
+ //toRelativePath(TestFilesPaths.homePageTestDeviceNotConnectedTest),
+ toRelativePath(TestFilesPaths.newsPageOnlineTest),
+ toRelativePath(TestFilesPaths.termsOfServiceTest),
+ ],
+ cicdMock: [
toRelativePath(TestFilesPaths.mcCheckForUpdatesTest),
toRelativePath(TestFilesPaths.mcCheckForUpdatesOfflineTest),
- toRelativePath(TestFilesPaths.homePageTestDeviceNotConnectedTest),
- toRelativePath(TestFilesPaths.newsPageOnlineTest),
toRelativePath(TestFilesPaths.newsPageOfflineTest),
- toRelativePath(TestFilesPaths.termsOfServiceTest),
- toRelativePath(TestFilesPaths.privacyPolicyTest),
- toRelativePath(TestFilesPaths.licenseTest),
- toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest),
+ //toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageForceUpdateErrorTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateTest),
+ toRelativePath(TestFilesPaths.mcHomePageSoftUpdateErrorTest),
+ toRelativePath(TestFilesPaths.kompaktOverview),
+ toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
+ toRelativePath(TestFilesPaths.kompaktAbout),
+ toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
+ toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
],
},
// Patterns to exclude.
diff --git a/apps/mudita-center/package-lock.json b/apps/mudita-center/package-lock.json
index dcbbc9011a..c6474fb501 100644
--- a/apps/mudita-center/package-lock.json
+++ b/apps/mudita-center/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@mudita/mudita-center-app",
- "version": "2.3.1",
+ "version": "2.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@mudita/mudita-center-app",
- "version": "2.3.1",
+ "version": "2.4.0",
"license": "GPL-3.0",
"dependencies": {
"serialport": "10.1.0"
diff --git a/apps/mudita-center/package.json b/apps/mudita-center/package.json
index 765341d9c3..c7a5e560e6 100644
--- a/apps/mudita-center/package.json
+++ b/apps/mudita-center/package.json
@@ -1,6 +1,6 @@
{
"name": "mudita-center",
- "version": "2.3.1",
+ "version": "2.4.0",
"description": "Mudita Center",
"main": "./dist/main.js",
"productName": "Mudita Center",
@@ -27,14 +27,14 @@
"fonts:download": "node ../../scripts/downloadFonts.js",
"copy-static-dependencies": "node ../../scripts/copy-static-sql-js-dependencies.js",
"news:download": "ts-node ../../scripts/downloadNews.ts",
- "help:download": "ts-node ../../scripts/downloadHelpItems.ts",
+ "help-v2:download": "ts-node ../../scripts/downloadHelpV2.ts",
"app-configuration:download": "ts-node ../../scripts/download-configuration.ts",
"UTILITY/AUTO COMMANDS": "=================================================",
"prestart": "npm run build",
"posttranslations:sync": "npm run translations:sort",
"posttranslations:sort": "prettier --write src/**/*.json",
"posttest:coverage": "prettier --write ./jest.coverage.json",
- "postsetup": "npm run fonts:download && npm run news:download && npm run app-configuration:download && npm run copy-static-dependencies"
+ "postsetup": "npm run fonts:download && npm run news:download && npm run app-configuration:download && npm run copy-static-dependencies && npm run help-v2:download"
},
"build": {
"productName": "Mudita Center",
diff --git a/apps/mudita-center/src/main.ts b/apps/mudita-center/src/main.ts
index 3ee2751737..e6b9ce6cbf 100644
--- a/apps/mudita-center/src/main.ts
+++ b/apps/mudita-center/src/main.ts
@@ -24,18 +24,6 @@ import registerWriteGzipListener from "Core/__deprecated__/main/functions/regist
import registerRmdirListener from "Core/__deprecated__/main/functions/register-rmdir-listener"
import registerArchiveFilesListener from "Core/__deprecated__/main/functions/register-archive-files-listener"
import createDownloadListenerRegistrar from "Core/__deprecated__/main/functions/create-download-listener-registrar"
-import {
- registerDownloadHelpHandler,
- removeDownloadHelpHandler,
-} from "Core/__deprecated__/main/functions/download-help-handler"
-import {
- registerSetHelpStoreHandler,
- removeSetHelpStoreHandler,
-} from "Core/__deprecated__/main/functions/set-help-store-handler"
-import {
- registerGetHelpStoreHandler,
- removeGetHelpStoreHandler,
-} from "Core/__deprecated__/main/functions/get-help-store-handler"
import { GoogleAuthActions } from "Core/__deprecated__/common/enums/google-auth-actions.enum"
import {
authServerPort,
@@ -44,30 +32,29 @@ import {
} from "Core/__deprecated__/main/auth-server"
import logger from "Core/__deprecated__/main/utils/logger"
import {
- Scope,
clientId,
redirectUrl,
+ Scope,
TokenRequester,
} from "generic-view/store"
import { OutlookAuthActions } from "Core/__deprecated__/common/enums/outlook-auth-actions.enum"
import {
+ DEFAULT_WINDOWS_SIZE,
GOOGLE_AUTH_WINDOW_SIZE,
WINDOW_SIZE,
- DEFAULT_WINDOWS_SIZE,
} from "Core/__deprecated__/main/config"
import {
URL_MAIN,
URL_OVERVIEW,
} from "Core/__deprecated__/renderer/constants/urls"
import { Mode } from "Core/__deprecated__/common/enums/mode.enum"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
import { AboutActions } from "Core/__deprecated__/common/enums/about-actions.enum"
import { PureSystemActions } from "Core/__deprecated__/common/enums/pure-system-actions.enum"
import { BrowserActions } from "Core/__deprecated__/common/enums/browser-actions.enum"
import {
createMetadataStore,
- MetadataStore,
MetadataInitializer,
+ MetadataStore,
registerMetadataAllGetValueListener,
registerMetadataGetValueListener,
registerMetadataSetValueListener,
@@ -77,10 +64,17 @@ import { createSettingsService } from "Core/settings/containers/settings.contain
import { ApplicationModule } from "Core/core/application.module"
import registerExternalUsageDevice from "Core/device/listeners/register-external-usage-device.listner"
import installExtension, {
- REDUX_DEVTOOLS,
REACT_DEVELOPER_TOOLS,
+ REDUX_DEVTOOLS,
} from "electron-devtools-installer"
-import { AppEvents, callRenderer, getMainAppWindow } from "shared/utils"
+import {
+ AppEvents,
+ callRenderer,
+ getMainAppWindow,
+ openDevToolsOnceDomReady,
+ preventDefaultShortcuts,
+ registerShortcuts,
+} from "shared/utils"
import { mockServiceEnabled, startServer, stopServer } from "e2e-mock-server"
// AUTO DISABLED - fix me if you like :)
@@ -99,7 +93,6 @@ if (mockServiceEnabled) {
logger.info("Starting the app!")
let win: BrowserWindow | null
-let helpWindow: BrowserWindow | null = null
let googleAuthWindow: BrowserWindow | null = null
let outlookAuthWindow: BrowserWindow | null = null
const licenseWindow: BrowserWindow | null = null
@@ -184,12 +177,6 @@ const createWindow = async () => {
require("@electron/remote/main").enable(win.webContents)
win.removeMenu()
- win.webContents.on("before-input-event", (event, input) => {
- if ((input.control || input.meta) && input.key.toLowerCase() === "r") {
- event.preventDefault()
- }
- })
-
win.on("closed", () => {
win = null
app.exit()
@@ -250,26 +237,9 @@ const createWindow = async () => {
}
})
- if (productionEnvironment) {
- win.webContents.once("dom-ready", () => {
- appModules.lateInitialization()
- })
- } else {
- // Open DevTools, see https://github.com/electron/electron/issues/12438 for why we wait for dom-ready
- win.webContents.once("dom-ready", () => {
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
- win!.webContents.openDevTools()
- appModules.lateInitialization()
- })
-
- win.webContents.once("dom-ready", () => {
- win!.webContents.once("devtools-opened", () => {
- win!.focus()
- })
- win!.webContents.openDevTools()
- })
- }
+ win.webContents.once("dom-ready", () => {
+ appModules.lateInitialization()
+ })
logger.updateMetadata()
}
@@ -281,6 +251,12 @@ if (!gotTheLock) {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
app.on("ready", createWindow)
+ app.on("browser-window-created", (_event, window) => {
+ preventDefaultShortcuts(window)
+ registerShortcuts(window)
+ openDevToolsOnceDomReady(window)
+ })
+
app.on("before-quit", () => {
stopServer()
})
@@ -296,66 +272,6 @@ if (!gotTheLock) {
})
}
-ipcMain.answerRenderer(HelpActions.OpenWindow, () => {
- const title = "Mudita Center - Help"
- if (helpWindow === null) {
- helpWindow = new BrowserWindow(
- getWindowOptions({
- width: DEFAULT_WINDOWS_SIZE.width,
- height: DEFAULT_WINDOWS_SIZE.height,
- title,
- })
- )
- // FIXME: electron v12 added changes to the remote module. This module has many subtle pitfalls.
- // There is almost always a better way to accomplish your task than using this module.
- // You can read more in https://github.com/electron/remote#migrating-from-remote
- require("@electron/remote/main").enable(helpWindow.webContents)
- helpWindow.removeMenu()
-
- helpWindow.on("closed", () => {
- removeDownloadHelpHandler()
- removeSetHelpStoreHandler()
- removeGetHelpStoreHandler()
- helpWindow = null
- void ipcMain.callRenderer(
- win as BrowserWindow,
- HelpActions.CustomerIsSendingToRenderer,
- false
- )
- })
-
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
- helpWindow.loadURL(
- !productionEnvironment
- ? `http://localhost:2003/?mode=${Mode.Help}#${URL_MAIN.help}`
- : url.format({
- pathname: path.join(__dirname, "index.html"),
- protocol: "file:",
- slashes: true,
- hash: URL_MAIN.help,
- search: `?mode=${Mode.Help}`,
- })
- )
- registerDownloadHelpHandler()
- registerSetHelpStoreHandler()
- registerGetHelpStoreHandler()
- } else {
- helpWindow.show()
- }
-})
-
-ipcMain.answerRenderer(
- HelpActions.CustomerIsSendingToMain,
- (sending: boolean) => {
- ipcMain.callRenderer(
- win as BrowserWindow,
- HelpActions.CustomerIsSendingToRenderer,
- sending
- )
- }
-)
-
const createOpenWindowListener = (
channel: string,
mode: string,
diff --git a/jest.preset.js b/jest.preset.js
index 5add69934a..983cc58c6e 100644
--- a/jest.preset.js
+++ b/jest.preset.js
@@ -11,5 +11,7 @@ module.exports = {
...nxPreset.moduleNameMapper,
"App/(.*)": `${__dirname}/apps/mudita-center/src/$1`,
"Core/(.*)": `${__dirname}/libs/core/$1`,
+ "p-queue$": `${__dirname}/__mocks__/p-queue.ts`,
},
+ setupFilesAfterEnv: [`${__dirname}/jest.setup.js`],
}
diff --git a/jest.setup.js b/jest.setup.js
new file mode 100644
index 0000000000..25b5da26e7
--- /dev/null
+++ b/jest.setup.js
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+require("reflect-metadata")
diff --git a/jest/jest.config.core.js b/jest/jest.config.core.js
index a7527932bc..79988e407d 100644
--- a/jest/jest.config.core.js
+++ b/jest/jest.config.core.js
@@ -19,6 +19,8 @@ module.exports = {
"Core/(.*)": "/libs/core/$1",
"Cypress/(.*)": "/apps/mudita-center/cypress/$1",
"Storybook/(.*)": "/apps/mudita-center/.storybook/$1",
+ "p-queue$": `${__dirname}/__mocks__/p-queue.ts`,
+ "react-markdown": "/jest/testing-support/mocks/react-markdown.tsx",
},
rootDir: "../",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
diff --git a/jest/jest.setup.js b/jest/jest.setup.js
index 19b606dd40..7f90b49c62 100644
--- a/jest/jest.setup.js
+++ b/jest/jest.setup.js
@@ -20,3 +20,5 @@ jest.mock("Core/device/strategies/pure.strategy", () => {
expect.extend({
toBeTranslationKey,
})
+
+jest.mock("@orama/orama")
diff --git a/jest/testing-support/mocks/react-markdown.tsx b/jest/testing-support/mocks/react-markdown.tsx
new file mode 100644
index 0000000000..e29ae9c0d0
--- /dev/null
+++ b/jest/testing-support/mocks/react-markdown.tsx
@@ -0,0 +1,7 @@
+import React, { FunctionComponent, PropsWithChildren } from "react"
+
+const ReactMarkdown: FunctionComponent = ({ children }) => {
+ return <>{children}>
+}
+
+export default ReactMarkdown
diff --git a/libs/active-device-registry/feature/.babelrc b/libs/active-device-registry/feature/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/active-device-registry/feature/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/external-tools/matomo-to-gsheet/.eslintrc.json b/libs/active-device-registry/feature/.eslintrc.json
similarity index 100%
rename from libs/external-tools/matomo-to-gsheet/.eslintrc.json
rename to libs/active-device-registry/feature/.eslintrc.json
diff --git a/libs/active-device-registry/feature/README.md b/libs/active-device-registry/feature/README.md
new file mode 100644
index 0000000000..fa965afb1c
--- /dev/null
+++ b/libs/active-device-registry/feature/README.md
@@ -0,0 +1,7 @@
+# active-device-registry-feature
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test active-device-registry-feature` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/external-tools/matomo-to-gsheet/jest.config.ts b/libs/active-device-registry/feature/jest.config.ts
similarity index 69%
rename from libs/external-tools/matomo-to-gsheet/jest.config.ts
rename to libs/active-device-registry/feature/jest.config.ts
index dcbf778f66..8f857c9e58 100644
--- a/libs/external-tools/matomo-to-gsheet/jest.config.ts
+++ b/libs/active-device-registry/feature/jest.config.ts
@@ -1,11 +1,11 @@
/* eslint-disable */
export default {
- displayName: "external-tools-matomo-to-gsheet",
+ displayName: "active-device-registry-feature",
preset: "../../../jest.preset.js",
transform: {
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
"^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
- coverageDirectory: "../../../coverage/libs/external-tools/matomo-to-gsheet",
+ coverageDirectory: "../../../coverage/libs/active-device-registry/feature",
}
diff --git a/libs/external-tools/matomo-to-gsheet/project.json b/libs/active-device-registry/feature/project.json
similarity index 67%
rename from libs/external-tools/matomo-to-gsheet/project.json
rename to libs/active-device-registry/feature/project.json
index 36bbcc6856..0141ee0b5d 100644
--- a/libs/external-tools/matomo-to-gsheet/project.json
+++ b/libs/active-device-registry/feature/project.json
@@ -1,7 +1,7 @@
{
- "name": "external-tools-matomo-to-gsheet",
+ "name": "active-device-registry-feature",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
- "sourceRoot": "libs/external-tools/matomo-to-gsheet/src",
+ "sourceRoot": "libs/active-device-registry/feature/src",
"projectType": "library",
"tags": [],
"targets": {
@@ -13,7 +13,7 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
- "jestConfig": "libs/external-tools/matomo-to-gsheet/jest.config.ts"
+ "jestConfig": "libs/active-device-registry/feature/jest.config.ts"
}
}
}
diff --git a/libs/core/device-manager/controllers/index.ts b/libs/active-device-registry/feature/src/actions/index.ts
similarity index 77%
rename from libs/core/device-manager/controllers/index.ts
rename to libs/active-device-registry/feature/src/actions/index.ts
index 086f1e6a9c..676125a458 100644
--- a/libs/core/device-manager/controllers/index.ts
+++ b/libs/active-device-registry/feature/src/actions/index.ts
@@ -3,4 +3,4 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-export * from "./device-manager.controller"
+export * from "./set-active-device.action";
diff --git a/libs/core/device-manager/actions/set-active-device.action.ts b/libs/active-device-registry/feature/src/actions/set-active-device.action.ts
similarity index 59%
rename from libs/core/device-manager/actions/set-active-device.action.ts
rename to libs/active-device-registry/feature/src/actions/set-active-device.action.ts
index cd79965753..c784df583e 100644
--- a/libs/core/device-manager/actions/set-active-device.action.ts
+++ b/libs/active-device-registry/feature/src/actions/set-active-device.action.ts
@@ -4,19 +4,16 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
+import { setActiveDeviceRequest } from "device-protocol/feature"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
-import { setActiveDeviceRequest } from "Core/device-manager/requests"
import { DeviceId } from "Core/device/constants/device-id"
-import { cleanBackupProcess, cleanRestoreProcess } from "generic-view/store"
+import { ActiveDeviceRegistryEvent } from "../constants"
export const setActiveDevice = createAsyncThunk<
DeviceId | undefined,
DeviceId | undefined,
{ state: ReduxRootState }
->(DeviceManagerEvent.SetActiveDevice, async (payload, { dispatch }) => {
+>(ActiveDeviceRegistryEvent.SetActiveDevice, async (payload, { dispatch }) => {
await setActiveDeviceRequest(payload)
- dispatch(cleanBackupProcess())
- dispatch(cleanRestoreProcess())
return payload
})
diff --git a/libs/active-device-registry/feature/src/constants/event.constant.ts b/libs/active-device-registry/feature/src/constants/event.constant.ts
new file mode 100644
index 0000000000..5054edbcc1
--- /dev/null
+++ b/libs/active-device-registry/feature/src/constants/event.constant.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export enum ActiveDeviceRegistryEvent {
+ SetActiveDevice = "active-device-registry/set-active-device",
+}
diff --git a/libs/active-device-registry/feature/src/constants/index.ts b/libs/active-device-registry/feature/src/constants/index.ts
new file mode 100644
index 0000000000..fd9c217d57
--- /dev/null
+++ b/libs/active-device-registry/feature/src/constants/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./event.constant"
diff --git a/libs/active-device-registry/feature/src/index.ts b/libs/active-device-registry/feature/src/index.ts
new file mode 100644
index 0000000000..ed357a32d6
--- /dev/null
+++ b/libs/active-device-registry/feature/src/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./actions"
+export * from "./reducers"
+export * from "./selectors"
diff --git a/libs/active-device-registry/feature/src/reducers/active-device-registry.reducer.ts b/libs/active-device-registry/feature/src/reducers/active-device-registry.reducer.ts
new file mode 100644
index 0000000000..83b4c0a07b
--- /dev/null
+++ b/libs/active-device-registry/feature/src/reducers/active-device-registry.reducer.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createReducer } from "@reduxjs/toolkit"
+import { ActiveDeviceRegistryState } from "active-device-registry/models"
+import { setActiveDevice } from "../actions"
+
+export const initialState: ActiveDeviceRegistryState = {
+ activeDeviceId: undefined,
+}
+
+export const activeDeviceRegistryReducer = createReducer(
+ initialState,
+ (builder) => {
+ builder.addCase(setActiveDevice.fulfilled, (state, action) => {
+ return {
+ ...state,
+ activeDeviceId: action.payload,
+ }
+ })
+ }
+)
diff --git a/libs/active-device-registry/feature/src/reducers/index.ts b/libs/active-device-registry/feature/src/reducers/index.ts
new file mode 100644
index 0000000000..73250716eb
--- /dev/null
+++ b/libs/active-device-registry/feature/src/reducers/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./active-device-registry.reducer"
diff --git a/libs/core/device-manager/selectors/active-device-id.selector.ts b/libs/active-device-registry/feature/src/selectors/active-device-id.selector.ts
similarity index 54%
rename from libs/core/device-manager/selectors/active-device-id.selector.ts
rename to libs/active-device-registry/feature/src/selectors/active-device-id.selector.ts
index 1234c5a626..99d81b4108 100644
--- a/libs/core/device-manager/selectors/active-device-id.selector.ts
+++ b/libs/active-device-registry/feature/src/selectors/active-device-id.selector.ts
@@ -4,11 +4,11 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
+import { activeDeviceRegistryState } from "./active-device-registry-state.selector"
export const activeDeviceIdSelector = createSelector(
- deviceManagerState,
- (deviceManager): string | undefined => {
- return deviceManager.activeDeviceId
+ activeDeviceRegistryState,
+ (activeDeviceRegistryState): string | undefined => {
+ return activeDeviceRegistryState.activeDeviceId
}
)
diff --git a/libs/active-device-registry/feature/src/selectors/active-device-registry-state.selector.ts b/libs/active-device-registry/feature/src/selectors/active-device-registry-state.selector.ts
new file mode 100644
index 0000000000..d4f89d7305
--- /dev/null
+++ b/libs/active-device-registry/feature/src/selectors/active-device-registry-state.selector.ts
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ActiveDeviceRegistryState } from "active-device-registry/models"
+import { ReduxRootState } from "Core/__deprecated__/renderer/store"
+
+export const activeDeviceRegistryState = (state: ReduxRootState): ActiveDeviceRegistryState =>
+ state.activeDeviceRegistry
diff --git a/libs/active-device-registry/feature/src/selectors/index.ts b/libs/active-device-registry/feature/src/selectors/index.ts
new file mode 100644
index 0000000000..927e191c43
--- /dev/null
+++ b/libs/active-device-registry/feature/src/selectors/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./active-device-id.selector";
+export * from "./active-device-registry-state.selector";
+export * from "./is-active-device-set.selector";
diff --git a/libs/core/device-manager/selectors/is-active-device-set.selector.ts b/libs/active-device-registry/feature/src/selectors/is-active-device-set.selector.ts
similarity index 55%
rename from libs/core/device-manager/selectors/is-active-device-set.selector.ts
rename to libs/active-device-registry/feature/src/selectors/is-active-device-set.selector.ts
index 2a4e92c5c3..325207ca8c 100644
--- a/libs/core/device-manager/selectors/is-active-device-set.selector.ts
+++ b/libs/active-device-registry/feature/src/selectors/is-active-device-set.selector.ts
@@ -4,11 +4,11 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
+import { activeDeviceIdSelector } from "./active-device-id.selector"
export const isActiveDeviceSet = createSelector(
- deviceManagerState,
- (deviceManager): boolean => {
- return deviceManager.activeDeviceId !== undefined
+ activeDeviceIdSelector,
+ (activeDeviceId): boolean => {
+ return activeDeviceId !== undefined
}
)
diff --git a/libs/external-tools/matomo-to-gsheet/tsconfig.json b/libs/active-device-registry/feature/tsconfig.json
similarity index 100%
rename from libs/external-tools/matomo-to-gsheet/tsconfig.json
rename to libs/active-device-registry/feature/tsconfig.json
diff --git a/libs/external-tools/matomo-to-gsheet/tsconfig.lib.json b/libs/active-device-registry/feature/tsconfig.lib.json
similarity index 100%
rename from libs/external-tools/matomo-to-gsheet/tsconfig.lib.json
rename to libs/active-device-registry/feature/tsconfig.lib.json
diff --git a/libs/external-tools/matomo-to-gsheet/tsconfig.spec.json b/libs/active-device-registry/feature/tsconfig.spec.json
similarity index 100%
rename from libs/external-tools/matomo-to-gsheet/tsconfig.spec.json
rename to libs/active-device-registry/feature/tsconfig.spec.json
diff --git a/libs/active-device-registry/models/.babelrc b/libs/active-device-registry/models/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/active-device-registry/models/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/active-device-registry/models/.eslintrc.json b/libs/active-device-registry/models/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/active-device-registry/models/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/active-device-registry/models/README.md b/libs/active-device-registry/models/README.md
new file mode 100644
index 0000000000..e491313413
--- /dev/null
+++ b/libs/active-device-registry/models/README.md
@@ -0,0 +1,7 @@
+# active-device-registry-models
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test active-device-registry-models` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/active-device-registry/models/jest.config.ts b/libs/active-device-registry/models/jest.config.ts
new file mode 100644
index 0000000000..bd4c266fcf
--- /dev/null
+++ b/libs/active-device-registry/models/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "active-device-registry-models",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/active-device-registry/models",
+}
diff --git a/libs/active-device-registry/models/project.json b/libs/active-device-registry/models/project.json
new file mode 100644
index 0000000000..c9ebedf2b2
--- /dev/null
+++ b/libs/active-device-registry/models/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "active-device-registry-models",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/active-device-registry/models/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/active-device-registry/models/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/active-device-registry/models/src/active-device-registry.interface.ts b/libs/active-device-registry/models/src/active-device-registry.interface.ts
new file mode 100644
index 0000000000..c282c2e45e
--- /dev/null
+++ b/libs/active-device-registry/models/src/active-device-registry.interface.ts
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { DeviceId } from "Core/device/constants/device-id"
+
+export interface ActiveDeviceRegistryState {
+ activeDeviceId: DeviceId | undefined
+}
diff --git a/libs/active-device-registry/models/src/index.ts b/libs/active-device-registry/models/src/index.ts
new file mode 100644
index 0000000000..b761a81f81
--- /dev/null
+++ b/libs/active-device-registry/models/src/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./active-device-registry.interface"
diff --git a/libs/active-device-registry/models/tsconfig.json b/libs/active-device-registry/models/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/active-device-registry/models/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/active-device-registry/models/tsconfig.lib.json b/libs/active-device-registry/models/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/active-device-registry/models/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/active-device-registry/models/tsconfig.spec.json b/libs/active-device-registry/models/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/active-device-registry/models/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/external-tools/matomo-to-gsheet/.babelrc b/libs/core-device/feature/.babelrc
similarity index 100%
rename from libs/external-tools/matomo-to-gsheet/.babelrc
rename to libs/core-device/feature/.babelrc
diff --git a/libs/core-device/feature/.eslintrc.json b/libs/core-device/feature/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/core-device/feature/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/core-device/feature/README.md b/libs/core-device/feature/README.md
new file mode 100644
index 0000000000..f33c7eb8b8
--- /dev/null
+++ b/libs/core-device/feature/README.md
@@ -0,0 +1,7 @@
+# core-device-feature
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test core-device-feature` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/core-device/feature/jest.config.ts b/libs/core-device/feature/jest.config.ts
new file mode 100644
index 0000000000..9b89b49e49
--- /dev/null
+++ b/libs/core-device/feature/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "core-device-feature",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/core-device/feature",
+}
diff --git a/libs/core-device/feature/project.json b/libs/core-device/feature/project.json
new file mode 100644
index 0000000000..07471387aa
--- /dev/null
+++ b/libs/core-device/feature/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "core-device-feature",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/core-device/feature/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/core-device/feature/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/core-device/feature/src/actions/base.action.ts b/libs/core-device/feature/src/actions/base.action.ts
new file mode 100644
index 0000000000..219849917b
--- /dev/null
+++ b/libs/core-device/feature/src/actions/base.action.ts
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createAction } from "@reduxjs/toolkit"
+import { DeviceBaseProperties } from "device-protocol/models"
+import { DeviceState } from "device-manager/models"
+import { CaseColour } from "core-device/models"
+import { CoreDeviceEvent } from "../constants"
+
+export const addDevice = createAction<
+ DeviceBaseProperties & Partial<{ state: DeviceState; caseColour: CaseColour }>
+>(CoreDeviceEvent.AddDevice)
+
+export const removeDevice = createAction(
+ CoreDeviceEvent.RemoveDevice
+)
+
+export const setDeviceState = createAction<{ id: string; state: DeviceState }>(
+ CoreDeviceEvent.SetDeviceState
+)
diff --git a/libs/core/device-manager/actions/configure-device.action.ts b/libs/core-device/feature/src/actions/configure-device.action.ts
similarity index 55%
rename from libs/core/device-manager/actions/configure-device.action.ts
rename to libs/core-device/feature/src/actions/configure-device.action.ts
index 48214e1c75..f1c541fa51 100644
--- a/libs/core/device-manager/actions/configure-device.action.ts
+++ b/libs/core-device/feature/src/actions/configure-device.action.ts
@@ -5,11 +5,10 @@
import { createAsyncThunk } from "@reduxjs/toolkit"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
import { DeviceId } from "Core/device/constants/device-id"
-import { getDeviceConfigurationRequest } from "Core/device-manager/requests/get-device-configuration.request"
-import { DeviceConfiguration } from "Core/device-manager/controllers"
-import { DeviceType } from "Core/device"
+import { getDeviceConfigurationRequest } from "../requests"
+import { DeviceConfiguration } from "../controllers"
+import { CoreDeviceEvent } from "../constants"
interface ConfigureDevicePayload extends Partial {
id: DeviceId
@@ -19,13 +18,7 @@ export const configureDevice = createAsyncThunk<
ConfigureDevicePayload,
DeviceId,
{ state: ReduxRootState }
->(DeviceManagerEvent.ConfigureDevice, async (id, {getState}) => {
- // TODO: tmp solution to handle APIDevice
- const device = getState().deviceManager.devices.find((device) => device.id === id)
- if(device?.deviceType === DeviceType.APIDevice){
- return { id }
- }
-
+>(CoreDeviceEvent.ConfigureDevice, async (id) => {
const result = await getDeviceConfigurationRequest(id)
if (result.ok) {
diff --git a/libs/core-device/feature/src/actions/index.ts b/libs/core-device/feature/src/actions/index.ts
new file mode 100644
index 0000000000..9c5a7b6378
--- /dev/null
+++ b/libs/core-device/feature/src/actions/index.ts
@@ -0,0 +1,7 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./base.action"
+export * from "./configure-device.action"
diff --git a/libs/core-device/feature/src/constants/controller.constant.ts b/libs/core-device/feature/src/constants/controller.constant.ts
new file mode 100644
index 0000000000..5b127b3fca
--- /dev/null
+++ b/libs/core-device/feature/src/constants/controller.constant.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export enum IpcCoreDeviceEvent {
+ GetCoreDeviceConfiguration = "core-device_get-core-device-configuration",
+}
diff --git a/libs/core-device/feature/src/constants/event.constant.ts b/libs/core-device/feature/src/constants/event.constant.ts
new file mode 100644
index 0000000000..1a4e71fb22
--- /dev/null
+++ b/libs/core-device/feature/src/constants/event.constant.ts
@@ -0,0 +1,11 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export enum CoreDeviceEvent {
+ AddDevice = "core-device_add-device",
+ RemoveDevice = "core-device_remove-device",
+ SetDeviceState = "core-device_set-device-state",
+ ConfigureDevice = "core-device_configure-device",
+}
diff --git a/libs/core/device-manager/constants/index.ts b/libs/core-device/feature/src/constants/index.ts
similarity index 87%
rename from libs/core/device-manager/constants/index.ts
rename to libs/core-device/feature/src/constants/index.ts
index 47cd8ebe91..5a48343da1 100644
--- a/libs/core/device-manager/constants/index.ts
+++ b/libs/core-device/feature/src/constants/index.ts
@@ -4,5 +4,4 @@
*/
export * from "./controller.constant"
-export * from "./error.constant"
export * from "./event.constant"
diff --git a/libs/core/device-manager/controllers/device-manager.controller.ts b/libs/core-device/feature/src/controllers/core-device.controller.ts
similarity index 64%
rename from libs/core/device-manager/controllers/device-manager.controller.ts
rename to libs/core-device/feature/src/controllers/core-device.controller.ts
index 494aa405a9..6debfbceb2 100644
--- a/libs/core/device-manager/controllers/device-manager.controller.ts
+++ b/libs/core-device/feature/src/controllers/core-device.controller.ts
@@ -4,36 +4,31 @@
*/
import { IpcEvent } from "Core/core/decorators"
-import { DeviceManager } from "Core/device-manager/services"
-import { IpcDeviceManagerEvent } from "Core/device-manager/constants"
+import { DeviceProtocol } from "device-protocol/feature"
import { Result, ResultObject } from "Core/core/builder"
import { DeviceId } from "Core/device/constants/device-id"
+import { DeviceInfo } from "Core/device/types/mudita-os"
import {
CaseColour,
DeviceCommunicationError,
Endpoint,
Method,
-} from "Core/device"
-import { DeviceInfo } from "Core/device/types/mudita-os"
-import { DeviceCacheConfigurationService } from "Core/device-manager/services/device-cache-configuration.service"
+} from "core-device/models"
+import { DeviceCacheConfigurationService } from "../services"
+import { IpcCoreDeviceEvent } from "../constants"
export interface DeviceConfiguration {
caseColour: CaseColour | undefined
serialNumber: string | undefined
}
-export class DeviceManagerController {
+export class CoreDeviceController {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private deviceCacheConfigurationService: DeviceCacheConfigurationService
) {}
- @IpcEvent(IpcDeviceManagerEvent.SetActiveDevice)
- public setActiveDevice(id: DeviceId | undefined): ResultObject {
- return this.deviceManager.setActiveDevice(id)
- }
-
- @IpcEvent(IpcDeviceManagerEvent.GetDeviceConfiguration)
+ @IpcEvent(IpcCoreDeviceEvent.GetCoreDeviceConfiguration)
public async request(
id: DeviceId
): Promise> {
@@ -43,7 +38,7 @@ export class DeviceManagerController {
return Result.success(deviceConfigurationCached)
}
- const result = await this.deviceManager.request(id, {
+ const result = await this.deviceProtocol.request(id, {
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
options: {
@@ -65,9 +60,4 @@ export class DeviceManagerController {
return result
}
}
-
- @IpcEvent(IpcDeviceManagerEvent.ConnectDevice)
- public connectDevice(id: DeviceId): Promise> {
- return this.deviceManager.connectDevice(id)
- }
}
diff --git a/libs/core-device/feature/src/controllers/index.ts b/libs/core-device/feature/src/controllers/index.ts
new file mode 100644
index 0000000000..529b494a9b
--- /dev/null
+++ b/libs/core-device/feature/src/controllers/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./core-device.controller"
diff --git a/libs/core-device/feature/src/core-device.module.ts b/libs/core-device/feature/src/core-device.module.ts
new file mode 100644
index 0000000000..69cad99ca6
--- /dev/null
+++ b/libs/core-device/feature/src/core-device.module.ts
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { DeviceProtocol } from "device-protocol/feature"
+import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
+import { DeviceCacheConfigurationService } from "./services"
+import { CoreDeviceController } from "./controllers"
+
+export class CoreDeviceModule {
+ public controllers
+
+ constructor(
+ public deviceProtocol: DeviceProtocol,
+ public fileSystem: FileSystemService
+ ) {
+ const deviceManagerController = new CoreDeviceController(
+ this.deviceProtocol,
+ new DeviceCacheConfigurationService(this.fileSystem)
+ )
+
+ this.controllers = [deviceManagerController]
+ }
+}
diff --git a/libs/core-device/feature/src/hooks/index.ts b/libs/core-device/feature/src/hooks/index.ts
new file mode 100644
index 0000000000..e975497e8b
--- /dev/null
+++ b/libs/core-device/feature/src/hooks/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./use-core-device-protocol-listeners"
diff --git a/libs/core-device/feature/src/hooks/use-core-device-protocol-listeners.ts b/libs/core-device/feature/src/hooks/use-core-device-protocol-listeners.ts
new file mode 100644
index 0000000000..116ab2920b
--- /dev/null
+++ b/libs/core-device/feature/src/hooks/use-core-device-protocol-listeners.ts
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { useCallback, useEffect } from "react"
+import { useDispatch } from "react-redux"
+import { answerMain, useDebouncedEventsHandler } from "shared/utils"
+import { DeviceState } from "device-manager/models"
+import { DeviceProtocolMainEvent, DeviceType, DeviceBaseProperties } from "device-protocol/models"
+import { Dispatch } from "Core/__deprecated__/renderer/store"
+import { addDevice, configureDevice, removeDevice } from "../actions"
+import { getDeviceConfigurationRequest } from "../requests"
+
+export const useCoreDeviceProtocolListeners = () => {
+ const dispatch = useDispatch()
+ const handleDevicesDetached = useHandleDevicesDetached()
+ const batchDeviceDetachedEvents =
+ useDebouncedEventsHandler(handleDevicesDetached)
+
+ useEffect(() => {
+ return answerMain(
+ DeviceProtocolMainEvent.DeviceConnected,
+ (properties) => {
+ const { deviceType } = properties
+ if (deviceType === DeviceType.APIDevice) {
+ return
+ }
+
+ dispatch(addDevice(properties))
+ dispatch(configureDevice(properties.id))
+ }
+ )
+ }, [dispatch])
+
+ useEffect(() => {
+ return answerMain(
+ DeviceProtocolMainEvent.DeviceConnectFailed,
+ async (properties) => {
+ const { deviceType } = properties
+ if (deviceType === DeviceType.APIDevice) {
+ return
+ }
+
+ const result = await getDeviceConfigurationRequest(properties.id)
+ const caseColour = result.ok ? result.data.caseColour : undefined
+
+ dispatch(
+ addDevice({ ...properties, caseColour, state: DeviceState.Failed })
+ )
+ }
+ )
+ }, [dispatch])
+
+ useEffect(() => {
+ return answerMain(
+ DeviceProtocolMainEvent.DeviceDetached,
+ batchDeviceDetachedEvents
+ )
+ }, [dispatch, batchDeviceDetachedEvents])
+}
+
+const useHandleDevicesDetached = () => {
+ const dispatch = useDispatch()
+
+ return useCallback(
+ async (deviceDetachedEvents: DeviceBaseProperties[]) => {
+ for (const event of deviceDetachedEvents) {
+ const { deviceType } = event
+ if (deviceType !== DeviceType.APIDevice) {
+ dispatch(removeDevice(event))
+ }
+ }
+ },
+ [dispatch]
+ )
+}
diff --git a/libs/core-device/feature/src/index.ts b/libs/core-device/feature/src/index.ts
new file mode 100644
index 0000000000..80b5e6ceb5
--- /dev/null
+++ b/libs/core-device/feature/src/index.ts
@@ -0,0 +1,11 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./actions"
+export * from "./hooks"
+export * from "./reducers"
+export * from "./requests"
+export * from "./selectors"
+export * from "./core-device.module"
diff --git a/libs/core-device/feature/src/reducers/core-device.reducer.ts b/libs/core-device/feature/src/reducers/core-device.reducer.ts
new file mode 100644
index 0000000000..9509429b81
--- /dev/null
+++ b/libs/core-device/feature/src/reducers/core-device.reducer.ts
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createReducer } from "@reduxjs/toolkit"
+import { DeviceState } from "device-manager/models"
+import { CoreDeviceState } from "core-device/models"
+import {
+ addDevice,
+ removeDevice,
+ configureDevice,
+ setDeviceState,
+} from "../actions"
+
+export const initialState: CoreDeviceState = {
+ devices: {},
+}
+
+export const coreDeviceReducer = createReducer(
+ initialState,
+ (builder) => {
+ builder
+ .addCase(addDevice, (state, action) => {
+ state.devices[action.payload.id] = {
+ caseColour: undefined,
+ state: DeviceState.Connected,
+ ...action.payload,
+ }
+ })
+ .addCase(removeDevice, (state, action) => {
+ delete state.devices[action.payload.id]
+ })
+ .addCase(configureDevice.fulfilled, (state, action) => {
+ const id = action.payload.id
+ const device = state.devices[id]
+ state.devices[id] = {
+ ...device,
+ caseColour: action.payload.caseColour ?? device.caseColour,
+ serialNumber: action.payload.serialNumber ?? device.serialNumber,
+ state: DeviceState.Configured,
+ }
+ })
+ .addCase(setDeviceState, (state, action) => {
+ if (action.payload) {
+ const id = action.payload.id
+ const device = state.devices[id]
+ const deviceState = action.payload.state
+ state.devices[id] = {
+ ...device,
+ state: deviceState,
+ }
+ }
+ })
+ }
+)
diff --git a/libs/core-device/feature/src/reducers/index.ts b/libs/core-device/feature/src/reducers/index.ts
new file mode 100644
index 0000000000..47fd2cfa48
--- /dev/null
+++ b/libs/core-device/feature/src/reducers/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./core-device.reducer"
diff --git a/libs/core/device-manager/requests/get-device-configuration.request.ts b/libs/core-device/feature/src/requests/get-device-configuration.request.ts
similarity index 66%
rename from libs/core/device-manager/requests/get-device-configuration.request.ts
rename to libs/core-device/feature/src/requests/get-device-configuration.request.ts
index 33ae4b1987..7e46733c8e 100644
--- a/libs/core/device-manager/requests/get-device-configuration.request.ts
+++ b/libs/core-device/feature/src/requests/get-device-configuration.request.ts
@@ -5,12 +5,12 @@
import { ipcRenderer } from "electron-better-ipc"
import { ResultObject } from "Core/core/builder"
-import { IpcDeviceManagerEvent } from "Core/device-manager/constants"
import { DeviceId } from "Core/device/constants/device-id"
-import { DeviceConfiguration } from "Core/device-manager/controllers"
+import { DeviceConfiguration } from "../controllers"
+import { IpcCoreDeviceEvent } from "../constants"
export const getDeviceConfigurationRequest = async (
id: DeviceId
): Promise> => {
- return ipcRenderer.callMain(IpcDeviceManagerEvent.GetDeviceConfiguration, id)
+ return ipcRenderer.callMain(IpcCoreDeviceEvent.GetCoreDeviceConfiguration, id)
}
diff --git a/libs/core-device/feature/src/requests/index.ts b/libs/core-device/feature/src/requests/index.ts
new file mode 100644
index 0000000000..b1eb40f23f
--- /dev/null
+++ b/libs/core-device/feature/src/requests/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./get-device-configuration.request"
diff --git a/libs/core-device/feature/src/selectors/core-device-state.selector.ts b/libs/core-device/feature/src/selectors/core-device-state.selector.ts
new file mode 100644
index 0000000000..1f467f5814
--- /dev/null
+++ b/libs/core-device/feature/src/selectors/core-device-state.selector.ts
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ReduxRootState } from "Core/__deprecated__/renderer/store"
+import { CoreDeviceState } from "core-device/models"
+
+export const coreDeviceState = (state: ReduxRootState): CoreDeviceState =>
+ state.coreDevice
diff --git a/libs/core-device/feature/src/selectors/get-configured-core-devices.selector.ts b/libs/core-device/feature/src/selectors/get-configured-core-devices.selector.ts
new file mode 100644
index 0000000000..d1fbffa9c7
--- /dev/null
+++ b/libs/core-device/feature/src/selectors/get-configured-core-devices.selector.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { Device } from "core-device/models"
+import { DeviceState } from "device-manager/models"
+import { getCoreDevicesSelector } from "./get-core-devices.selector"
+
+export const getConfiguredCoreDevicesSelector = createSelector(
+ getCoreDevicesSelector,
+ (devices): Device[] => {
+ return devices.filter(({ state }) => state === DeviceState.Configured)
+ }
+)
diff --git a/libs/core-device/feature/src/selectors/get-core-devices.selector.ts b/libs/core-device/feature/src/selectors/get-core-devices.selector.ts
new file mode 100644
index 0000000000..b3f26913ce
--- /dev/null
+++ b/libs/core-device/feature/src/selectors/get-core-devices.selector.ts
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { Device } from "core-device/models"
+import { coreDeviceState } from "./core-device-state.selector"
+
+export const getCoreDevicesSelector = createSelector(
+ coreDeviceState,
+ ({ devices }): Device[] => {
+ return Object.values(devices);
+ }
+)
diff --git a/libs/core-device/feature/src/selectors/get-failed-core-devices.selector.ts b/libs/core-device/feature/src/selectors/get-failed-core-devices.selector.ts
new file mode 100644
index 0000000000..8230b8d17c
--- /dev/null
+++ b/libs/core-device/feature/src/selectors/get-failed-core-devices.selector.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { Device } from "core-device/models"
+import { DeviceState } from "device-manager/models"
+import { getCoreDevicesSelector } from "./get-core-devices.selector"
+
+export const getFailedCoreDevicesSelector = createSelector(
+ getCoreDevicesSelector,
+ (devices): Device[] => {
+ return devices.filter(({ state }) => state === DeviceState.Failed)
+ }
+)
diff --git a/libs/core-device/feature/src/selectors/index.ts b/libs/core-device/feature/src/selectors/index.ts
new file mode 100644
index 0000000000..63a3ecd917
--- /dev/null
+++ b/libs/core-device/feature/src/selectors/index.ts
@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./core-device-state.selector"
+export * from "./get-configured-core-devices.selector"
+export * from "./get-core-devices.selector"
+export * from "./get-failed-core-devices.selector"
diff --git a/libs/core/device-manager/services/device-cache-configuration.service.ts b/libs/core-device/feature/src/services/device-cache-configuration.service.ts
similarity index 95%
rename from libs/core/device-manager/services/device-cache-configuration.service.ts
rename to libs/core-device/feature/src/services/device-cache-configuration.service.ts
index 3f874ba15c..3c826ee59d 100644
--- a/libs/core/device-manager/services/device-cache-configuration.service.ts
+++ b/libs/core-device/feature/src/services/device-cache-configuration.service.ts
@@ -6,8 +6,8 @@
import path from "path"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import getAppPath from "Core/__deprecated__/main/utils/get-app-path"
-import { DeviceConfiguration } from "Core/device-manager/controllers"
import { DeviceId } from "Core/device/constants/device-id"
+import { DeviceConfiguration } from "../controllers"
type CacheMap = Record
diff --git a/libs/core-device/feature/src/services/index.ts b/libs/core-device/feature/src/services/index.ts
new file mode 100644
index 0000000000..6d80584128
--- /dev/null
+++ b/libs/core-device/feature/src/services/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./device-cache-configuration.service"
diff --git a/libs/core-device/feature/tsconfig.json b/libs/core-device/feature/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/core-device/feature/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/core-device/feature/tsconfig.lib.json b/libs/core-device/feature/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/core-device/feature/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/core-device/feature/tsconfig.spec.json b/libs/core-device/feature/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/core-device/feature/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/core-device/models/.babelrc b/libs/core-device/models/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/core-device/models/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/core-device/models/.eslintrc.json b/libs/core-device/models/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/core-device/models/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/core-device/models/README.md b/libs/core-device/models/README.md
new file mode 100644
index 0000000000..7e82719bfe
--- /dev/null
+++ b/libs/core-device/models/README.md
@@ -0,0 +1,7 @@
+# core-device-models
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test core-device-models` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/core-device/models/jest.config.ts b/libs/core-device/models/jest.config.ts
new file mode 100644
index 0000000000..12d1051c4d
--- /dev/null
+++ b/libs/core-device/models/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "core-device-models",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/core-device/models",
+}
diff --git a/libs/core-device/models/project.json b/libs/core-device/models/project.json
new file mode 100644
index 0000000000..95e0a8f8b0
--- /dev/null
+++ b/libs/core-device/models/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "core-device-models",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/core-device/models/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/core-device/models/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/core/device/constants/case-colour.constant.ts b/libs/core-device/models/src/case-colour.constant.ts
similarity index 100%
rename from libs/core/device/constants/case-colour.constant.ts
rename to libs/core-device/models/src/case-colour.constant.ts
diff --git a/libs/core-device/models/src/core-device.interface.ts b/libs/core-device/models/src/core-device.interface.ts
new file mode 100644
index 0000000000..9155e9d903
--- /dev/null
+++ b/libs/core-device/models/src/core-device.interface.ts
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
+import { DeviceProperties } from "device-manager/models"
+import { DeviceId } from "Core/device/constants/device-id"
+
+export interface Device extends DeviceProperties {
+ id: DeviceId
+ serialNumber: string | undefined
+ deviceType: DeviceType
+ caseColour: CaseColour | undefined
+}
+
+export interface CoreDeviceState {
+ devices: Record
+}
diff --git a/libs/core/device/constants/device-communication-error.constant.ts b/libs/core-device/models/src/device-communication-error.constant.ts
similarity index 100%
rename from libs/core/device/constants/device-communication-error.constant.ts
rename to libs/core-device/models/src/device-communication-error.constant.ts
diff --git a/libs/core/device/constants/endpoint.constant.ts b/libs/core-device/models/src/endpoint.constant.ts
similarity index 100%
rename from libs/core/device/constants/endpoint.constant.ts
rename to libs/core-device/models/src/endpoint.constant.ts
diff --git a/libs/core-device/models/src/index.ts b/libs/core-device/models/src/index.ts
new file mode 100644
index 0000000000..a2bc29af27
--- /dev/null
+++ b/libs/core-device/models/src/index.ts
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./case-colour.constant"
+export * from "./core-device.interface"
+export * from "./device-communication-error.constant"
+export * from "./endpoint.constant"
+export * from "./request-method.constant"
diff --git a/libs/core/device/constants/request-method.constant.ts b/libs/core-device/models/src/request-method.constant.ts
similarity index 100%
rename from libs/core/device/constants/request-method.constant.ts
rename to libs/core-device/models/src/request-method.constant.ts
diff --git a/libs/core-device/models/tsconfig.json b/libs/core-device/models/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/core-device/models/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/core-device/models/tsconfig.lib.json b/libs/core-device/models/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/core-device/models/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/core-device/models/tsconfig.spec.json b/libs/core-device/models/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/core-device/models/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/core/__deprecated__/api/mudita-center-server/client.interface.ts b/libs/core/__deprecated__/api/mudita-center-server/client.interface.ts
index a43730d82a..50eb56cf3c 100644
--- a/libs/core/__deprecated__/api/mudita-center-server/client.interface.ts
+++ b/libs/core/__deprecated__/api/mudita-center-server/client.interface.ts
@@ -3,15 +3,9 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { EntryCollection, SyncCollection } from "contentful"
+import { EntryCollection } from "contentful"
import { NewsEntry } from "Core/news/dto"
export interface ClientInterface {
getNews(query: { limit: number }): Promise>
- getHelp(query: HelpQuery): Promise
-}
-
-export interface HelpQuery {
- nextSyncToken?: string
- locale?: string
}
diff --git a/libs/core/__deprecated__/api/mudita-center-server/client.test.ts b/libs/core/__deprecated__/api/mudita-center-server/client.test.ts
index 47c07dc743..159db05f9b 100644
--- a/libs/core/__deprecated__/api/mudita-center-server/client.test.ts
+++ b/libs/core/__deprecated__/api/mudita-center-server/client.test.ts
@@ -36,24 +36,3 @@ test("returns news response properly", async () => {
const result = await client.getNews({ limit: 3 })
expect(result).toStrictEqual({ data: { response: "ok" } })
})
-
-test("returns help response properly", async () => {
- const data = {
- response: "ok",
- }
- axiosMock.onGet(MuditaCenterServerRoutes.Help).replyOnce(200, {
- data,
- })
- const client = new Client()
- const result = await client.getHelp({
- nextSyncToken: "dsad921342",
- })
- expect(result).toStrictEqual({ data })
-})
-
-test("returns 404 when no query is provided", () => {
- const client = new Client()
- void expect(async () => {
- await client.getHelp({})
- }).rejects.toThrowError(`Error: Request failed with status code 404`)
-})
diff --git a/libs/core/__deprecated__/api/mudita-center-server/client.ts b/libs/core/__deprecated__/api/mudita-center-server/client.ts
index c373fbc2f9..df203d000d 100644
--- a/libs/core/__deprecated__/api/mudita-center-server/client.ts
+++ b/libs/core/__deprecated__/api/mudita-center-server/client.ts
@@ -6,14 +6,11 @@
import { NewsEntry } from "Core/news/dto"
import { OsEnvironment } from "Core/update/constants"
import { ReleaseManifest } from "Core/update/dto"
-import {
- ClientInterface,
- HelpQuery,
-} from "Core/__deprecated__/api/mudita-center-server/client.interface"
+import { ClientInterface } from "Core/__deprecated__/api/mudita-center-server/client.interface"
import { MuditaCenterServerRoutes } from "Core/__deprecated__/api/mudita-center-server/mudita-center-server-routes"
import { Product } from "Core/__deprecated__/main/constants"
import axios, { AxiosInstance, AxiosResponse } from "axios"
-import { EntryCollection, SyncCollection } from "contentful"
+import { EntryCollection } from "contentful"
import https from "https"
export interface getLatestProductionReleaseParams {
@@ -65,33 +62,6 @@ export class Client implements ClientInterface {
}
}
- async getHelp(query: HelpQuery): Promise {
- try {
- const params = new URLSearchParams({
- locale: query.locale as string,
- })
-
- if (query.nextSyncToken) {
- params.append("nextSyncToken", query.nextSyncToken)
- }
-
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- const { data }: AxiosResponse = await this.httpClient.get(
- MuditaCenterServerRoutes.Help,
- { params }
- )
-
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
- return data
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- } catch (error: any) {
- throw new Error(error)
- }
- }
-
async getExternalUsageDevice(serialNumber: string): Promise {
try {
const params: ExternalUsageDeviceQueryParams = {
diff --git a/libs/core/__deprecated__/api/mudita-center-server/mudita-center-server-routes.ts b/libs/core/__deprecated__/api/mudita-center-server/mudita-center-server-routes.ts
index d12707a390..7e7aa5189a 100644
--- a/libs/core/__deprecated__/api/mudita-center-server/mudita-center-server-routes.ts
+++ b/libs/core/__deprecated__/api/mudita-center-server/mudita-center-server-routes.ts
@@ -5,7 +5,6 @@
export enum MuditaCenterServerRoutes {
News = "news",
- Help = "help",
GetReleaseV2 = "v2-get-release",
AppConfigurationV2 = "v2-app-configuration",
ExternalUsageDevice = "external-usage-device",
diff --git a/libs/core/__deprecated__/common/enums/help-actions.enum.ts b/libs/core/__deprecated__/common/enums/help-actions.enum.ts
index 16c6ef5c75..306b956264 100644
--- a/libs/core/__deprecated__/common/enums/help-actions.enum.ts
+++ b/libs/core/__deprecated__/common/enums/help-actions.enum.ts
@@ -4,10 +4,6 @@
*/
export enum HelpActions {
- OpenWindow = "open-window",
- SetStoreValue = "set-store-value",
- GetStore = "get-store",
- DownloadContentfulData = "download-contentful-data",
CustomerIsSendingToMain = "customer-is-sending-to-main",
CustomerIsSendingToRenderer = "customer-is-sending-to-renderer",
}
diff --git a/libs/core/__deprecated__/common/interfaces/device-info.interface.ts b/libs/core/__deprecated__/common/interfaces/device-info.interface.ts
index 5c9d0a1b67..c751d83be0 100644
--- a/libs/core/__deprecated__/common/interfaces/device-info.interface.ts
+++ b/libs/core/__deprecated__/common/interfaces/device-info.interface.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { CaseColour } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
export default interface DeviceInfo {
readonly serialNumber: string
diff --git a/libs/core/__deprecated__/main/functions/download-help-handler.ts b/libs/core/__deprecated__/main/functions/download-help-handler.ts
deleted file mode 100644
index c2d7794b85..0000000000
--- a/libs/core/__deprecated__/main/functions/download-help-handler.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { ipcMain } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
-import { settingsStore } from "Core/settings/store"
-import { normalizeHelpData } from "Core/__deprecated__/renderer/utils/contentful/normalize-help-data"
-import { createClient } from "Core/__deprecated__/api/mudita-center-server"
-import logger from "Core/__deprecated__/main/utils/logger"
-import { HelpQuery } from "Core/__deprecated__/api/mudita-center-server/client.interface"
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const registerDownloadHelpHandler = () => {
- const locale = settingsStore.get("language")
-
- ipcMain.answerRenderer(HelpActions.DownloadContentfulData, async () => {
- const client = createClient()
- const helpQuery: HelpQuery = {
- locale,
- }
- try {
- return normalizeHelpData(await client.getHelp(helpQuery), locale)
- } catch (error) {
- logger.error(
- `Help: loads data from from mudita-center-server fails. Data: ${JSON.stringify(
- error
- )}`
- )
- return false
- }
- })
-}
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const removeDownloadHelpHandler = () =>
- ipcMain.removeHandler(HelpActions.DownloadContentfulData)
diff --git a/libs/core/__deprecated__/main/functions/get-help-store-handler.ts b/libs/core/__deprecated__/main/functions/get-help-store-handler.ts
deleted file mode 100644
index 7fc4e2ded4..0000000000
--- a/libs/core/__deprecated__/main/functions/get-help-store-handler.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { ipcMain } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
-import helpStore from "Core/__deprecated__/main/store/help"
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const registerGetHelpStoreHandler = () =>
- ipcMain.answerRenderer(HelpActions.GetStore, () => {
- return helpStore.get("data")
- })
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const removeGetHelpStoreHandler = () =>
- ipcMain.removeHandler(HelpActions.GetStore)
diff --git a/libs/core/__deprecated__/main/functions/set-help-store-handler.ts b/libs/core/__deprecated__/main/functions/set-help-store-handler.ts
deleted file mode 100644
index f30c5e4f9c..0000000000
--- a/libs/core/__deprecated__/main/functions/set-help-store-handler.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { ipcMain } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
-import helpStore from "Core/__deprecated__/main/store/help"
-
-export const registerSetHelpStoreHandler = (): (() => void) =>
- ipcMain.answerRenderer(HelpActions.SetStoreValue, (response) => {
- return helpStore.set("data", response)
- })
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const removeSetHelpStoreHandler = () =>
- ipcMain.removeHandler(HelpActions.SetStoreValue)
diff --git a/libs/core/__deprecated__/renderer/components/core/badge/badge-with-icon.component.tsx b/libs/core/__deprecated__/renderer/components/core/badge/badge-with-icon.component.tsx
new file mode 100644
index 0000000000..dd54a37498
--- /dev/null
+++ b/libs/core/__deprecated__/renderer/components/core/badge/badge-with-icon.component.tsx
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import styled from "styled-components"
+
+export const BadgeWithIcon = styled.div`
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 0.8rem;
+ position: absolute;
+ right: 0;
+ top: 0;
+ background-color: black;
+ border-radius: 0.4rem;
+ padding: 0 1rem 0 0.8rem;
+ line-height: 2rem;
+ font-weight: 700;
+`
diff --git a/libs/core/__deprecated__/renderer/components/core/button/button.component.tsx b/libs/core/__deprecated__/renderer/components/core/button/button.component.tsx
index de3992f065..25ac0ddb53 100755
--- a/libs/core/__deprecated__/renderer/components/core/button/button.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/button/button.component.tsx
@@ -27,6 +27,7 @@ import { IconBadgeType } from "Core/__deprecated__/renderer/components/core/icon
export interface ButtonComponentProps {
nav?: boolean
exact?: boolean
+ disableWhenActive?: boolean
disabled?: boolean
displayStyle?: DisplayStyle
href?: string
@@ -55,6 +56,7 @@ const ButtonComponent: FunctionComponent = ({
disabled = false,
displayStyle = DisplayStyle.Primary,
exact,
+ disableWhenActive = true,
href,
Icon,
iconSize = IconSize.Big,
@@ -86,6 +88,7 @@ const ButtonComponent: FunctionComponent = ({
Object.assign(filteredProps, {
to,
exact,
+ disableWhenActive,
activeClassName,
})
} else if (to) {
diff --git a/libs/core/__deprecated__/renderer/components/core/button/button.stories.tsx b/libs/core/__deprecated__/renderer/components/core/button/button.stories.tsx
index ec10319ab7..0931c37307 100755
--- a/libs/core/__deprecated__/renderer/components/core/button/button.stories.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/button/button.stories.tsx
@@ -181,7 +181,7 @@ storiesOf("Components|Core/Button", module)
displayStyle={DisplayStyle.MenuLink}
label="I open Google in new tab"
href="http://www.google.pl"
- iconSize={IconSize.Bigger}
+ iconSize={IconSize.Large}
/>
@@ -192,7 +192,7 @@ storiesOf("Components|Core/Button", module)
displayStyle={DisplayStyle.MenuLink}
label="I open Google in new tab"
href="http://www.google.pl"
- iconSize={IconSize.Bigger}
+ iconSize={IconSize.Large}
/>
diff --git a/libs/core/__deprecated__/renderer/components/core/button/button.styled.elements.tsx b/libs/core/__deprecated__/renderer/components/core/button/button.styled.elements.tsx
index fd2c62c998..a74511dee4 100644
--- a/libs/core/__deprecated__/renderer/components/core/button/button.styled.elements.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/button/button.styled.elements.tsx
@@ -368,12 +368,14 @@ const buttonStyles = css<{
export const StyledNavLink = styled(NavLink)<{
displayStyle: DisplayStyle
disabled: boolean
+ disableWhenActive: boolean
size: Size
}>`
${buttonStyles}
&.${activeClassName} {
- pointer-events: none;
+ pointer-events: ${({ disableWhenActive }) =>
+ disableWhenActive ? "none" : "all"};
}
`
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.component.tsx b/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.component.tsx
index 9993c90d72..42b26931aa 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.component.tsx
@@ -3,13 +3,13 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { FunctionComponent } from "Core/core/types/function-component.interface"
import * as React from "react"
+import { DeviceType } from "device-protocol/models"
+import { FunctionComponent } from "Core/core/types/function-component.interface"
import Icon, {
Props as IconProps,
} from "Core/__deprecated__/renderer/components/core/icon/icon.component"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-import { DeviceType } from "Core/device"
export interface BatteryIconProps {
level: number
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.test.tsx b/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.test.tsx
index 09a613f8fc..b5964f7cb9 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.test.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/icon/battery-icon.test.tsx
@@ -4,9 +4,9 @@
*/
import React from "react"
+import { DeviceType } from "device-protocol/models"
import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
import BatteryIcon from "Core/__deprecated__/renderer/components/core/icon/battery-icon.component"
-import { DeviceType } from "Core/device"
describe("battery icon returns correct component", () => {
const testScenario = [
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/icon-type.ts b/libs/core/__deprecated__/renderer/components/core/icon/icon-type.ts
index bb0805c0fc..0ff97b9c54 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/icon-type.ts
+++ b/libs/core/__deprecated__/renderer/components/core/icon/icon-type.ts
@@ -128,4 +128,6 @@ export enum IconType {
Conversation,
Exclamation,
DataMigration,
+ RecoveryModeWhite,
+ RecoveryModeBlack,
}
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/icon.component.tsx b/libs/core/__deprecated__/renderer/components/core/icon/icon.component.tsx
index 0faccd2634..526f421f29 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/icon.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/icon/icon.component.tsx
@@ -21,7 +21,8 @@ export enum IconSize {
Small = 1.6,
Medium = 2.4,
Big = 2.8,
- Bigger = 3.2,
+ Large = 3.2,
+ ExtraLarge = 3.6,
}
export interface Props {
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/icon.config.ts b/libs/core/__deprecated__/renderer/components/core/icon/icon.config.ts
index f6688c1e98..495c2f9a15 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/icon.config.ts
+++ b/libs/core/__deprecated__/renderer/components/core/icon/icon.config.ts
@@ -126,6 +126,8 @@ import MarkAsUnread from "Core/__deprecated__/renderer/svg/mark-as-unread.svg"
import Conversation from "Core/__deprecated__/renderer/svg/conversation.svg"
import Exclamation from "Core/__deprecated__/renderer/svg/exclamation.svg"
import DataMigration from "../../../../../../generic-view/ui/src/lib/icon/svg/data-migration.svg"
+import RecoveryModeWhite from "../../../../../../generic-view/ui/src/lib/icon/svg/recovery-mode-white.svg"
+import RecoveryModeBlack from "../../../../../../generic-view/ui/src/lib/icon/svg/recovery-mode-black.svg"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
@@ -494,6 +496,8 @@ const typeToIcon: Partial> = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
[IconType.Exclamation]: Exclamation,
[IconType.DataMigration]: DataMigration,
+ [IconType.RecoveryModeWhite]: RecoveryModeWhite,
+ [IconType.RecoveryModeBlack]: RecoveryModeBlack,
}
export const getIconType = (
diff --git a/libs/core/__deprecated__/renderer/components/core/icon/icon.stories.tsx b/libs/core/__deprecated__/renderer/components/core/icon/icon.stories.tsx
index 7f18e6f77f..19db96195b 100644
--- a/libs/core/__deprecated__/renderer/components/core/icon/icon.stories.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/icon/icon.stories.tsx
@@ -3,18 +3,18 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { storiesOf } from "@storybook/react"
import * as React from "react"
+import styled from "styled-components"
+import { storiesOf } from "@storybook/react"
+import { DeviceType } from "device-protocol/models"
import Icon, {
IconSize,
} from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import styled from "styled-components"
import StoryContainer from "Core/__deprecated__/renderer/components/storybook/story-container.component"
import Story from "Core/__deprecated__/renderer/components/storybook/story.component"
import BatteryIcon from "Core/__deprecated__/renderer/components/core/icon/battery-icon.component"
import RangeIcon from "Core/__deprecated__/renderer/components/core/icon/range-icon.component"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-import { DeviceType } from "Core/device"
const CustomIcon = styled(Icon)`
height: 3rem;
diff --git a/libs/core/__deprecated__/renderer/components/core/modal/modal.helpers.tsx b/libs/core/__deprecated__/renderer/components/core/modal/modal.helpers.tsx
index 7776391ee5..2b243da8f6 100644
--- a/libs/core/__deprecated__/renderer/components/core/modal/modal.helpers.tsx
+++ b/libs/core/__deprecated__/renderer/components/core/modal/modal.helpers.tsx
@@ -29,6 +29,11 @@ export const getModalSize = (size: ModalSize) => {
return css`
width: 59rem;
`
+ case ModalSize.MediumNew:
+ return css`
+ width: 56.6rem;
+ padding: 2.4rem;
+ `
case ModalSize.Large:
return css`
width: 101rem;
diff --git a/libs/core/__deprecated__/renderer/components/core/modal/modal.interface.ts b/libs/core/__deprecated__/renderer/components/core/modal/modal.interface.ts
index 08ce169e61..5d431d73c6 100644
--- a/libs/core/__deprecated__/renderer/components/core/modal/modal.interface.ts
+++ b/libs/core/__deprecated__/renderer/components/core/modal/modal.interface.ts
@@ -7,6 +7,7 @@ export enum ModalSize {
VerySmall,
Small,
Medium,
+ MediumNew,
Large,
}
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/__snapshots__/menu.test.tsx.snap b/libs/core/__deprecated__/renderer/components/rest/menu/__snapshots__/menu.test.tsx.snap
index a6e7e87713..2dd3575d7f 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/__snapshots__/menu.test.tsx.snap
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/__snapshots__/menu.test.tsx.snap
@@ -225,6 +225,10 @@ exports[`Device: Mudita harmony matches snapshot 1`] = `
color: #6a6a6a;
}
+.c12.active {
+ pointer-events: all;
+}
+
.c7 {
margin: 0 0.8rem 0 0;
}
@@ -372,11 +376,12 @@ exports[`Device: Mudita harmony matches snapshot 1`] = `
-
+
@@ -793,7 +798,7 @@ exports[`Device: Mudita pure matches snapshot 1`] = `
class="c8 c9"
color="primary"
>
- [value] module.help
+ [value] module.help.v2
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu-bottom.component.tsx b/libs/core/__deprecated__/renderer/components/rest/menu/menu-bottom.component.tsx
index 22b402acbc..bbc15738dd 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu-bottom.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu-bottom.component.tsx
@@ -4,6 +4,14 @@
*/
import React from "react"
+import { useSelector, useDispatch } from "react-redux"
+import { useHistory } from "react-router-dom"
+import styled from "styled-components"
+import {
+ getDevicesSelector,
+ setSelectDeviceDrawerOpen,
+} from "device-manager/feature"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { MenuGroupTestIds } from "Core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum"
import Loader from "Core/__deprecated__/renderer/components/core/loader/loader.component"
@@ -12,19 +20,13 @@ import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
-import styled from "styled-components"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
import ButtonComponent from "Core/__deprecated__/renderer/components/core/button/button.component"
-import { useSelector, useDispatch } from "react-redux"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
-import { useHistory } from "react-router-dom"
import { URL_DISCOVERY_DEVICE } from "Core/__deprecated__/renderer/constants/urls"
import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
import { Dispatch } from "Core/__deprecated__/renderer/store"
import { getDeviceInitializationStatus } from "Core/device-initialization/selectors/get-device-initialization-status.selector"
import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
-import { setSelectDeviceDrawerOpen } from "Core/device-select/actions/set-select-device-drawer-open.action"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
import { useCustomerSupportIsSending } from "Core/__deprecated__/renderer/components/rest/menu/hooks/use-customer-support-is-sending"
const SyncProgressWrapper = styled.div`
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum.ts b/libs/core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum.ts
index a176ce6c11..5a392d9027 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum.ts
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum.ts
@@ -18,4 +18,5 @@ export enum MenuGroupTestIds {
Sync = "sync-info",
DataMigration = "data-migration-link",
DeviceSelectionButton = "menu-group_device-selection-button",
+ RecoveryMode = "recovery-mode-link",
}
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu-group.component.tsx b/libs/core/__deprecated__/renderer/components/rest/menu/menu-group.component.tsx
index af08a347b4..ddb4685c34 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu-group.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu-group.component.tsx
@@ -4,7 +4,7 @@
*/
import * as React from "react"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import Button from "Core/__deprecated__/renderer/components/core/button/button.component"
import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
import Text, {
@@ -15,9 +15,7 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { IconSize } from "Core/__deprecated__/renderer/components/core/icon/icon.component"
import RangeIcon from "Core/__deprecated__/renderer/components/core/icon/range-icon.component"
import BatteryIcon from "Core/__deprecated__/renderer/components/core/icon/battery-icon.component"
-import { views } from "Core/__deprecated__/renderer/constants/views"
-import { ipcRenderer } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
+import { View } from "Core/__deprecated__/renderer/constants/views"
import {
HeaderIcon,
HeaderIconBg,
@@ -27,7 +25,6 @@ import {
LinkWrapper,
} from "Core/__deprecated__/renderer/components/rest/menu/menu-group.styled"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-import { View } from "Core/__deprecated__/renderer/constants/views"
import { NotificationBadge } from "Core/notification/components"
interface MenuGroupProps extends MenuElement {
@@ -84,47 +81,40 @@ const MenuGroup: FunctionComponent = ({
.filter(({ visibleOn }) =>
visibleOn && deviceType ? visibleOn.includes(deviceType) : true
)
- .map(({ button, icon, testId, viewKey }, index) => {
- const buttonMenuConfig = {
- nav: true,
- displayStyle: DisplayStyle.MenuLink,
- Icon: icon,
- iconSize: IconSize.Bigger,
- ...(typeof button.label === "string"
- ? { label: button.label }
- : { labelMessage: button.label }),
- }
- if (button === views.help) {
- const openHelpWindow = () =>
- ipcRenderer.callMain(HelpActions.OpenWindow)
+ .map(
+ (
+ { button, icon, testId, disableWhenActive = true, viewKey },
+ index
+ ) => {
+ const buttonMenuConfig = {
+ nav: true,
+ displayStyle: DisplayStyle.MenuLink,
+ Icon: icon,
+ iconSize: IconSize.Large,
+ ...(typeof button.label === "string"
+ ? { label: button.label }
+ : { labelMessage: button.label }),
+ disableWhenActive,
+ }
return (
-
+
+
+
)
}
- return (
-
-
-
-
-
- )
- })}
+ )}
>
)
}
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu-top.component.tsx b/libs/core/__deprecated__/renderer/components/rest/menu/menu-top.component.tsx
index e0a4ad9d11..b584b5b6c0 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu-top.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu-top.component.tsx
@@ -5,6 +5,7 @@
import React from "react"
import styled from "styled-components"
+import { DeviceType } from "device-protocol/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
import {
@@ -16,7 +17,6 @@ import {
import MenuGroup from "Core/__deprecated__/renderer/components/rest/menu/menu-group.component"
import { backgroundColor } from "Core/core/styles/theming/theme-getters"
import Icon from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import { DeviceType } from "Core/device"
import { View } from "Core/__deprecated__/renderer/constants/views"
const LogoWrapper = styled.div`
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu.component.tsx b/libs/core/__deprecated__/renderer/components/rest/menu/menu.component.tsx
index f538cb062b..96cdb99c3a 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu.component.tsx
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu.component.tsx
@@ -7,7 +7,9 @@ import React from "react"
import styled from "styled-components"
import { connect } from "react-redux"
import { createSelector } from "@reduxjs/toolkit"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { getActiveDeviceTypeSelector } from "device-manager/feature"
+import { selectActiveDeviceMenuElements } from "generic-view/store"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { View } from "Core/__deprecated__/renderer/constants/views"
@@ -15,10 +17,8 @@ import { getUnreadThreads } from "Core/messages/selectors"
import MenuTop from "Core/__deprecated__/renderer/components/rest/menu/menu-top.component"
import MenuBottom from "Core/__deprecated__/renderer/components/rest/menu/menu-bottom.component"
import { MenuElement } from "Core/__deprecated__/renderer/constants/menu-elements"
-import { getActiveDeviceTypeSelector } from "Core/device-manager/selectors/get-active-device-type.selector"
import { RootModel } from "Core/__deprecated__/renderer/models/models"
import { deviceStateSelector } from "Core/device/selectors"
-import { selectActiveDeviceMenuElements } from "generic-view/store"
const MenuContainer = styled.div`
flex: 1;
diff --git a/libs/core/__deprecated__/renderer/components/rest/menu/menu.test.tsx b/libs/core/__deprecated__/renderer/components/rest/menu/menu.test.tsx
index fc466d370f..174f285c27 100644
--- a/libs/core/__deprecated__/renderer/components/rest/menu/menu.test.tsx
+++ b/libs/core/__deprecated__/renderer/components/rest/menu/menu.test.tsx
@@ -7,7 +7,9 @@ import createMockStore from "redux-mock-store"
import thunk from "redux-thunk"
import React from "react"
import { Provider } from "react-redux"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { CoreDeviceState } from "core-device/models"
+import { DeviceManagerState } from "device-manager/models"
import Menu, {
MenuProps,
} from "Core/__deprecated__/renderer/components/rest/menu/menu.component"
@@ -24,7 +26,7 @@ import {
DeviceInitializationState,
DeviceInitializationStatus,
} from "Core/device-initialization/reducers/device-initialization.interface"
-import { DeviceManagerState } from "Core/device-manager/reducers/device-manager.interface"
+import { ActiveDeviceRegistryState } from "active-device-registry/models"
jest.mock("Core/settings/store/schemas/generate-application-id", () => ({
generateApplicationId: () => "123",
@@ -38,9 +40,13 @@ const defaultState = {
device: {
deviceType: DeviceType.MuditaPure,
} as unknown as DeviceState,
- deviceManager: {
+ deviceManager: {} as unknown as DeviceManagerState,
+ activeDeviceRegistry: {
+ activeDeviceId: undefined,
+ } as unknown as ActiveDeviceRegistryState,
+ coreDevice: {
devices: [],
- } as unknown as DeviceManagerState,
+ } as unknown as CoreDeviceState,
deviceInitialization: {
deviceInitializationStatus: DeviceInitializationStatus.Idle,
} as unknown as DeviceInitializationState,
@@ -49,6 +55,7 @@ const defaultState = {
},
genericViews: {
menu: [],
+ devices: [],
},
} as unknown as ReduxRootState
@@ -94,8 +101,7 @@ const render = (
}
describe("Device: Mudita pure", () => {
-
- test("matches snapshot", () => {
+ test.skip("matches snapshot", () => {
const { container } = render(defaultState)
expect(container).toMatchSnapshot()
})
@@ -128,7 +134,7 @@ describe("Device: Mudita pure", () => {
},
},
} as unknown as MessagesState,
- deviceManager: {
+ coreDevice: {
devices: [
{
id: "1",
@@ -137,8 +143,10 @@ describe("Device: Mudita pure", () => {
caseColour: undefined,
},
],
- activeDeviceId: "1",
- } as unknown as DeviceManagerState,
+ } as unknown as CoreDeviceState,
+ activeDeviceRegistry: {
+ activeDeviceId: undefined,
+ } as unknown as ActiveDeviceRegistryState,
},
{
deviceFeaturesVisible: true,
@@ -151,8 +159,7 @@ describe("Device: Mudita pure", () => {
})
describe("Device: Mudita harmony", () => {
-
- test("matches snapshot", () => {
+ test.skip("matches snapshot", () => {
const { container } = render({
...defaultState,
device: {
@@ -164,7 +171,6 @@ describe("Device: Mudita harmony", () => {
})
test("Menu should have overview item", () => {
-
const { queryByTestId } = render({
...defaultState,
device: {
diff --git a/libs/core/__deprecated__/renderer/constants/menu-elements.ts b/libs/core/__deprecated__/renderer/constants/menu-elements.ts
index b6aa5ddd06..d2527529e7 100644
--- a/libs/core/__deprecated__/renderer/constants/menu-elements.ts
+++ b/libs/core/__deprecated__/renderer/constants/menu-elements.ts
@@ -4,7 +4,7 @@
*/
import { defineMessages } from "react-intl"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { View, views } from "Core/__deprecated__/renderer/constants/views"
import { MenuGroupTestIds } from "Core/__deprecated__/renderer/components/rest/menu/menu-group-test-ids.enum"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
@@ -63,6 +63,13 @@ const YOUR_PURE_BUTTONS = [
},
]
: []),
+ {
+ button: views.recoveryMode,
+ icon: IconType.RecoveryModeBlack,
+ testId: MenuGroupTestIds.RecoveryMode,
+ visibleOn: [DeviceType.MuditaHarmonyMsc],
+ viewKey: View.RecoveryMode,
+ },
]
const DESKTOP_APP_BUTTONS: Item[] = [
@@ -72,6 +79,7 @@ const DESKTOP_APP_BUTTONS: Item[] = [
visibleOn: [
DeviceType.MuditaPure,
DeviceType.MuditaHarmony,
+ DeviceType.MuditaHarmonyMsc,
DeviceType.APIDevice,
],
},
@@ -79,9 +87,11 @@ const DESKTOP_APP_BUTTONS: Item[] = [
button: views.help,
icon: IconType.MenuHelp,
testId: MenuGroupTestIds.Help,
+ disableWhenActive: false,
visibleOn: [
DeviceType.MuditaPure,
DeviceType.MuditaHarmony,
+ DeviceType.MuditaHarmonyMsc,
DeviceType.APIDevice,
],
},
@@ -94,6 +104,7 @@ interface Item {
hidden?: boolean
visibleOn?: DeviceType[]
viewKey?: View
+ disableWhenActive?: boolean
}
export interface MenuElement {
@@ -120,6 +131,7 @@ export const baseMenuElements: MenuElement[] = [
visibleOn: [
DeviceType.MuditaPure,
DeviceType.MuditaHarmony,
+ DeviceType.MuditaHarmonyMsc,
DeviceType.APIDevice,
],
},
@@ -143,6 +155,13 @@ export const deviceMenuElements: MenuElement[] = [
connectedPhoneOnly: true,
visibleOn: [DeviceType.MuditaHarmony],
},
+ {
+ label: messages.yourHarmony,
+ items: YOUR_PURE_BUTTONS,
+ icons: [],
+ connectedPhoneOnly: true,
+ visibleOn: [DeviceType.MuditaHarmonyMsc],
+ },
]
export const centerMenuElements: MenuElement[] = [
diff --git a/libs/core/__deprecated__/renderer/constants/urls.ts b/libs/core/__deprecated__/renderer/constants/urls.ts
index da63e4e9f3..d183174f03 100644
--- a/libs/core/__deprecated__/renderer/constants/urls.ts
+++ b/libs/core/__deprecated__/renderer/constants/urls.ts
@@ -20,6 +20,7 @@ export const URL_MAIN = {
apiConnectionDemo: "/api-connection-demo",
dataMigration: "/data-migration",
dataMigrationKompakt: "/generic/mc-data-migration",
+ recoveryMode: "/harmony-recovery-mode",
} as const
export const URL_TABS = {
diff --git a/libs/core/__deprecated__/renderer/constants/views.ts b/libs/core/__deprecated__/renderer/constants/views.ts
index 80e83f6f79..e7316fdc28 100644
--- a/libs/core/__deprecated__/renderer/constants/views.ts
+++ b/libs/core/__deprecated__/renderer/constants/views.ts
@@ -19,10 +19,11 @@ const messages = defineMessages({
filesManager: { id: "module.filesManager" },
manageSounds: { id: "module.manageSounds" },
settings: { id: "module.settings" },
- help: { id: "module.help" },
+ help: { id: "module.help.v2" },
error: { id: "module.error" },
pureSystem: { id: "module.overview.pureSystem" },
dataMigration: { id: "module.dataMigration.title" },
+ harmonyRecoveryMode: { id: "module.recoveryMode.harmony.title" },
})
export enum View {
@@ -38,6 +39,7 @@ export enum View {
Error = "error",
PureSystem = "pure-system",
DataMigration = "dataMigration",
+ RecoveryMode = "recoveryMode",
}
export type Views = {
@@ -102,4 +104,8 @@ export const views: Views = {
label: messages.dataMigration,
url: URL_MAIN.dataMigration,
},
+ [View.RecoveryMode]: {
+ label: messages.harmonyRecoveryMode,
+ url: URL_MAIN.recoveryMode,
+ },
}
diff --git a/libs/core/__deprecated__/renderer/images/harmony-msc-render.png b/libs/core/__deprecated__/renderer/images/harmony-msc-render.png
new file mode 100644
index 0000000000..44d171edb4
Binary files /dev/null and b/libs/core/__deprecated__/renderer/images/harmony-msc-render.png differ
diff --git a/libs/core/__deprecated__/renderer/locales/default/en-US.json b/libs/core/__deprecated__/renderer/locales/default/en-US.json
index 6bd92663f2..a75cfdc989 100644
--- a/libs/core/__deprecated__/renderer/locales/default/en-US.json
+++ b/libs/core/__deprecated__/renderer/locales/default/en-US.json
@@ -44,6 +44,7 @@
"component.contactSupportModalFormMessagePlaceholder": "How can we help?",
"component.contactSupportModalFormOptional": "optional",
"component.contactSupportModalTitle": "Mudita Center Support",
+ "component.contactSupportModalSendingTitle": "Sending, please wait...",
"component.crashDump.crashDumpModalErrorSubtitle": "Something went wrong during sending crash dump",
"component.crashDump.crashDumpModalErrorTitle": "Error",
"component.crashDump.crashDumpModalSendingSubtitle": "Sending logs to the support",
@@ -157,6 +158,7 @@
"component.supportModalSuccessBody": "We will contact you as soon as the problem is resolved",
"component.supportModalSuccessBodyWithoutEmail": "We will check the issue as soon as possible.",
"component.supportModalSuccessTitle": "Message sent",
+ "component.supportModalSuccessButtonLabel": "Close",
"component.supportModalTitle": "Mudita Center Support",
"component.table.close": "Close",
"component.textToday": "Today",
@@ -199,9 +201,11 @@
"component.cantConnectWithoutUSBPortAccessBody": "To allow access please restart Mudita Center. You\ncan still access limited features if you choose to\ncontinue without connecting.",
"component.restartYourComputerToConnectTitle": "Restart your computer to connect",
"component.restartYourComputerToConnectBody": "Please restart your computer to connect your\ndevice. You can still access limited features if you\nchoose to continue without connecting.",
+ "component.warningBox.headerTitle": "Warning!",
"module.availableDeviceList.headerTitle": "Select a device to continue",
"module.availableDeviceList.subheaderTitle": "You can change active devices later",
"module.availableDeviceList.serialNumber": "Serial number",
+ "module.availableDeviceList.recoveryMode": "Recovery Mode",
"module.availableDeviceList.active": " (ACTIVE)",
"module.calendar": "Calendar",
"module.calendar.authorizationFailedBody": "You need to allow all requested access rights in order to synchronize your calendar",
@@ -436,11 +440,27 @@
"module.filesManager.detachedDuringUploadErrorModalTextInfo": "Make sure your device stays connected and try again.",
"module.filesManager.detachedDuringUploadErrorModalActionButton": "Close",
"module.generic.viewBackButton": "Back to {name}",
- "module.help": "Help",
+ "module.help.v2": "Mudita Help Center",
+ "module.help.deviceSelectorTitle": "Which device are you using with Mudita Center?",
"module.help.answerError": "Something went wrong",
"module.help.backLinkText": "Back",
"module.help.supportTooltipDescription": "Contact support",
- "module.help.title": "Mudita Center Help",
+ "module.help.article.warning": "Warning!",
+ "module.help.article.externalLinksTitle": "Relevant guides from our Support Website:",
+ "module.help.article.footer.title": "Need more help?\nVisit our Support Website",
+ "module.help.article.footer.buttonLabel": "Visit support website",
+ "module.help.article.feedback.title": "Was this article helpful?",
+ "module.help.article.feedback.yesButtonLabel": "Yes",
+ "module.help.article.feedback.noButtonLabel": "No",
+ "module.help.article.feedback.thanks": "Thank you for your opinion!",
+ "module.help.footer.title": "Help request",
+ "module.help.footer.description": "We do our best to reply within 24h",
+ "module.help.footer.buttonLabel": "Contact support",
+ "module.help.search.title": "Welcome! How can we help you?",
+ "module.help.search.description": "Browse our selection of how-to and troubleshooting guides",
+ "module.help.search.placeholder": "Search topics",
+ "module.help.search.dropdown.description": "Quick Links",
+ "module.help.search.dropdown.noResults": "We couldn't find any topics...",
"module.license": "License",
"module.manageSounds": "Manage Sounds",
"module.manageSounds.alarmsTab": "Alarms",
@@ -604,9 +624,11 @@
"module.overview.backupSuccessModalDescription": "Your Pure files were successfully backed up to",
"module.overview.backupSuccessModalMainButton": "Done",
"module.overview.backupSuccessModalTitle": "Backup complete!",
- "module.overview.checkForUpdateFailedDescription": "Opps, something went wrong. \nPlease check your internet connection and try again or contact with us.",
+ "module.overview.checkForUpdateFailedDescription": "Oops, something went wrong. \nPlease check your internet connection and try again or contact with us.",
"module.overview.checkForUpdateFailedSupportButton": "Contact support",
"module.overview.checkForUpdateFailedTitle": "Checking failed",
+ "module.overview.checkForForceUpdateFailedTitle": "Update Required - No Network Connection",
+ "module.overview.checkForForceUpdateFailedDescription": "Your MuditaOS version is outdated, and we couldn't check for updates due to a network issue. Please connect to the internet and try again.",
"module.overview.checkForUpdateFailedTryAgainButton": "Try again",
"module.overview.checkingForUpdatesCloseButton": "Cancel",
"module.overview.checkingForUpdatesMessage": "Checking for MuditaOS update...",
@@ -766,7 +788,7 @@
"module.settings.backupDescription": " ",
"module.settings.backupLabel": "Backup Location",
"module.settings.backupTetheringLabel": "Start tethering",
- "module.settings.checkForFailedAppUpdateBody": "Opps, something went wrong. \nPlease check your internet connection",
+ "module.settings.checkForFailedAppUpdateBody": "Oops, something went wrong. \nPlease check your internet connection",
"module.settings.checkForFailedAppUpdateSubtitle": "Checking failed",
"module.settings.checkForFailedAppUpdateTitle": "Mudita Center",
"module.settings.collectingData": "Send Mudita Center logs to Mudita",
@@ -842,6 +864,10 @@
"module.genericBackup.restoreButtonLabel": "Restore from backup",
"module.genericViews.update.tag": "Update is available ({version}).",
"module.genericViews.update.actionLabel": "You can update it on your device.",
+ "module.genericViews.backup.features.comingSoon.messages": "Messages (coming soon!)",
+ "module.genericViews.backup.features.comingSoon.notes": "Notes (coming soon!)",
+ "module.genericViews.backup.features.comingSoon.calendar": "Calendar events (coming soon!)",
+ "module.genericViews.backup.features.comingSoon.apps": "App settings: Phone, Messages (coming soon!)",
"module.genericViews.backup.features.title": "Create backup",
"module.genericViews.backup.features.description": "All backup data stays on your computer.",
"module.genericViews.backup.features.cancelButtonLabel": "Cancel",
@@ -894,9 +920,11 @@
"module.genericViews.restore.failure.defaultErrorMessage": "The restore process was interrupted.",
"module.genericViews.restore.failure.closeButtonLabel": "Close",
"module.genericViews.importContacts.providerModal.title": "Import contacts",
- "module.genericViews.importContacts.providerModal.description": "Log into Google or upload CSV or vCard file to import your contacts.",
+ "module.genericViews.importContacts.providerModal.description": "Select the location of your contacts.",
"module.genericViews.importContacts.providerModal.fileUploadButtonLabel": "Upload csv or vcard",
- "module.genericViews.importContacts.providerModal.googleButtonLabel": "Continue with Google",
+ "module.genericViews.importContacts.providerModal.googleButtonLabel": "Google",
+ "module.genericViews.importContacts.providerModal.outlookButtonLabel": "Outlook",
+ "module.genericViews.importContacts.providerModal.needHelpButtonLabel": "Need help?",
"module.genericViews.importContacts.loaderModal.title": "Loading",
"module.genericViews.importContacts.loaderModal.description": "This will only take a moment...",
"module.genericViews.importContacts.contactsListModal.title": "Select contacts",
@@ -907,6 +935,12 @@
"module.genericViews.importContacts.progress.title": "Importing",
"module.genericViews.importContacts.progress.description": "Please wait, this might take a few minutes.",
"module.genericViews.importContacts.progress.progressDetails": "Preparing contacts",
+ "module.genericViews.importContacts.progress.progressDetailsForFeature": "Importing {featureLabel}",
+ "module.genericViews.importContacts.progress.cancelButtonLabel": "Cancel",
+ "module.genericViews.importContacts.cancelConfirm.title": "Cancel import?",
+ "module.genericViews.importContacts.cancelConfirm.description": "We'll stop the import process and no changes will be made to your phone.",
+ "module.genericViews.importContacts.cancelConfirm.backButtonLabel": "Back",
+ "module.genericViews.importContacts.cancelConfirm.cancelButtonLabel": "Cancel import",
"module.genericViews.importContacts.success.title": "Import complete",
"module.genericViews.importContacts.success.description": "{count, plural, =-1 {All contacts} one {# contact} other {# contacts}} imported successfully.",
"module.genericViews.importContacts.success.closeButtonLabel": "Close",
@@ -914,6 +948,7 @@
"module.genericViews.importContacts.failure.defaultErrorMessage": "The process was interrupted.",
"module.genericViews.importContacts.failure.fileErrorMessage": "We didn’t recognise some of the data in the file. Check that it only contains contact data and try again.",
"module.genericViews.importContacts.failure.closeButtonLabel": "Close",
+ "module.genericViews.importContacts.failure.notEnoughSpace": "Your phone’s storage is full.",
"module.genericViews.importContacts.cancellation.title": "Import cancelled",
"module.genericViews.importContacts.cancellation.message": "No changes were made to your phone’s contacts.",
"module.genericViews.importContacts.fileUploadDialog.title": "Import contacts",
@@ -921,12 +956,11 @@
"module.dataMigration.title": "Data Migration",
"module.genericViews.dataMigration.header": "Transfer Data from Pure to Kompakt",
"module.genericViews.dataMigration.features.title": "Select the data you want to transfer",
- "module.genericViews.dataMigration.features.notes": "Notes",
- "module.genericViews.dataMigration.features.alarms": "Alarms",
- "module.genericViews.dataMigration.features.callLog": "Call log",
+ "module.genericViews.dataMigration.features.notes": "Notes (coming soon!)",
+ "module.genericViews.dataMigration.features.alarms": "Alarms (coming soon!)",
+ "module.genericViews.dataMigration.features.callLog": "Call log (coming soon!)",
"module.genericViews.dataMigration.features.contacts": "Contacts",
- "module.genericViews.dataMigration.features.messages": "Messages",
- "module.genericViews.dataMigration.features.multimedia": "Multimedia files",
+ "module.genericViews.dataMigration.features.messages": "Messages (coming soon!)",
"module.genericViews.dataMigration.features.selectAll": "Select All",
"module.genericViews.dataMigration.instruction.title": "Connect your devices",
"module.genericViews.dataMigration.instruction.description": "Data can only be transferred from Pure to Kompakt\nand not vice versa.",
@@ -945,6 +979,7 @@
"module.genericViews.dataMigration.transferSetup.unlockInfo": "You may need to unlock your Pure before data transfer can start.",
"module.genericViews.dataMigration.transferSetup.deviceSelector.sourceLabel": "Source Device",
"module.genericViews.dataMigration.transferSetup.deviceSelector.targetLabel": "Destination Device",
+ "module.genericViews.dataMigration.transferSetup.pureNotReady": "Preparing Pure for data transfer, please wait...",
"module.genericViews.dataMigration.pureError.title": "Can’t start transfer",
"module.genericViews.dataMigration.pureError.closeButtonLabel": "Close",
"module.genericViews.dataMigration.pureError.onboardingRequired": "Please accept the MuditaOS license agreement on your device and complete the ondoarding process to continue.",
@@ -952,13 +987,32 @@
"module.genericViews.dataMigration.pureError.criticalBattery": "Please charge your Pure to start the transfer.",
"module.genericViews.dataMigration.pureError.connection.title": "Data transfer failed",
"module.genericViews.dataMigration.transferError.title": "Data transfer failed",
- "module.genericViews.dataMigration.transferError.connectionFailed": "Data cannot be transfered.\nTry reconnecting pure to your computer.",
- "module.genericViews.dataMigration.transferError.closeButtonLabel": "Close",
+ "module.genericViews.dataMigration.transferError.partialChangesDescription": "We transferred some data before the process failed, but we didn't transfer these items:",
+ "module.genericViews.dataMigration.transferError.notEnoughSpace": "Your phone’s storage is full.",
"module.genericViews.dataMigration.progress.title": "Transferring data",
"module.genericViews.dataMigration.progress.description": "Please don't unplug your devices from your computer.",
"module.genericViews.dataMigration.progress.cancelButtonLabel": "Cancel",
"module.genericViews.dataMigration.progress.genericMessage": "This might take a few minutes",
"module.genericViews.dataMigration.success.title": "Data transfer complete",
"module.genericViews.dataMigration.success.description": "We transferred your data successfully.\nIt's safe to use your devices again.",
- "module.genericViews.dataMigration.success.buttonLabel": "Ok"
+ "module.genericViews.dataMigration.success.buttonLabel": "Ok",
+ "module.recoveryMode.harmony.title": "Recovery Mode",
+ "module.recoveryMode.harmony.header": "Harmony is Ready for Recovery",
+ "module.recoveryMode.harmony.description": "Please read the instructions carefully. Not following the instructions may void the\nwarrenty!",
+ "module.recoveryMode.harmony.warning1": "Make sure your device is running OS 1.9.0 or later.",
+ "module.recoveryMode.harmony.warning2": "Once you start the recovery, it must not be cancelled or interrupted.",
+ "module.recoveryMode.harmony.warning3": "Do not disconnect your Harmony during the recovery process.",
+ "module.recoveryMode.harmony.warning4": "Before starting the recovery, charge your device for 1 hour (or more) from a suitable power outlet.",
+ "module.recoveryMode.harmony.confirmation": "I understand that not following these instructions may void the warranty",
+ "module.recoveryMode.harmony.action": "Start Recovery",
+ "module.genericViews.dataMigration.cancelConfirm.title": "Cancel data transfer?",
+ "module.genericViews.dataMigration.cancelConfirm.description": "We’ll stop the transfer but some data may already be on your Kompakt.",
+ "module.genericViews.dataMigration.cancelConfirm.cancelButtonLabel": "Cancel transfer",
+ "module.genericViews.dataMigration.cancelConfirm.backButtonLabel": "Back",
+ "module.genericViews.dataMigration.cancelConfirm.progress.title": "Cancelling, please wait...",
+ "module.genericViews.dataMigration.cancelled.title": "Data transfer cancelled",
+ "module.genericViews.dataMigration.cancelled.partialChangesDescription": "We transferred some data before you cancelled but we didn't transfer these items:",
+ "module.genericViews.dataMigration.failure.genericDescription": "The transfer process was interrupted.",
+ "module.genericViews.dataMigration.failure.noChangesDescription": "We didn’t transfer any data.",
+ "module.genericViews.dataMigration.failure.closeButtonLabel": "Close"
}
diff --git a/libs/core/__deprecated__/renderer/models/basic-info/basic-info.typings.ts b/libs/core/__deprecated__/renderer/models/basic-info/basic-info.typings.ts
index f6a216fb3f..6fce3c03e5 100644
--- a/libs/core/__deprecated__/renderer/models/basic-info/basic-info.typings.ts
+++ b/libs/core/__deprecated__/renderer/models/basic-info/basic-info.typings.ts
@@ -4,7 +4,8 @@
*/
import { State } from "Core/core/constants"
-import { DeviceType, CaseColour } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
export interface SimCard {
readonly network?: string
diff --git a/libs/core/__deprecated__/renderer/store/index.ts b/libs/core/__deprecated__/renderer/store/index.ts
index 29f785156d..c8147e636b 100644
--- a/libs/core/__deprecated__/renderer/store/index.ts
+++ b/libs/core/__deprecated__/renderer/store/index.ts
@@ -5,19 +5,18 @@
import {
init,
- RematchDispatch,
- RematchRootState,
InitConfig,
Middleware,
+ RematchDispatch,
+ RematchRootState,
} from "@rematch/core"
import selectPlugin from "@rematch/select"
import logger from "redux-logger"
import thunk from "redux-thunk"
import { models, RootModel } from "Core/__deprecated__/renderer/models/models"
import { filesManagerSeed } from "Core/__deprecated__/seeds/filesManager"
-import { helpSeed } from "Core/__deprecated__/seeds/help"
-import { reducers, combinedReducers } from "./reducers"
+import { combinedReducers, reducers } from "./reducers"
const middlewares: Middleware[] = [thunk]
@@ -39,7 +38,6 @@ if (process.env.NODE_ENV !== "test") {
...config.redux,
initialState: {
filesManager: filesManagerSeed,
- help: helpSeed,
},
}
}
diff --git a/libs/core/__deprecated__/renderer/store/reducers.ts b/libs/core/__deprecated__/renderer/store/reducers.ts
index a70ac4bd76..eed1d29773 100644
--- a/libs/core/__deprecated__/renderer/store/reducers.ts
+++ b/libs/core/__deprecated__/renderer/store/reducers.ts
@@ -21,7 +21,8 @@ import { updateOsReducer } from "Core/update/reducers"
import { discoveryDeviceReducer } from "Core/discovery-device/reducers/discovery-device.reducer"
import { deviceInitializationReducer } from "Core/device-initialization/reducers/device-initialization.reducer"
import { appInitializationReducer } from "Core/app-initialization/reducers/app-initialization.reducer"
-import { deviceManagerReducer } from "Core/device-manager/reducers/device-manager.reducer"
+import { coreDeviceReducer } from "core-device/feature"
+import { deviceManagerReducer } from "device-manager/feature"
import {
dataMigrationReducer,
genericBackupsReducer,
@@ -30,9 +31,11 @@ import {
genericModalsReducer,
genericViewsReducer,
importsReducer,
- externalProvidersReducer
+ externalProvidersReducer,
} from "generic-view/store"
import { appStateReducer } from "shared/app-state"
+import { activeDeviceRegistryReducer } from "active-device-registry/feature"
+import { helpReducer } from "help/store"
export const reducers = {
device: deviceReducer,
@@ -52,7 +55,9 @@ export const reducers = {
discoveryDevice: discoveryDeviceReducer,
deviceInitialization: deviceInitializationReducer,
appInitialization: appInitializationReducer,
+ coreDevice: coreDeviceReducer,
deviceManager: deviceManagerReducer,
+ activeDeviceRegistry: activeDeviceRegistryReducer,
genericViews: genericViewsReducer,
genericModals: genericModalsReducer,
genericBackups: genericBackupsReducer,
@@ -62,6 +67,7 @@ export const reducers = {
appState: appStateReducer,
dataMigration: dataMigrationReducer,
genericDataTransfer: genericDataTransferReducer,
+ helpV2: helpReducer,
}
export const combinedReducers = combineReducers(reducers)
diff --git a/libs/core/__deprecated__/renderer/utils/contentful/normalize-help-data.ts b/libs/core/__deprecated__/renderer/utils/contentful/normalize-help-data.ts
deleted file mode 100644
index d46af062fc..0000000000
--- a/libs/core/__deprecated__/renderer/utils/contentful/normalize-help-data.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { Entry, SyncCollection } from "contentful"
-import { Document } from "@contentful/rich-text-types"
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-
-export interface HelpEntry {
- id: string
- question: Record
- answer: { [key: string]: Document }
-}
-
-export interface NormalizedHelpEntry {
- id: string
- question: string
- answer: Document
-}
-
-export interface QuestionAndAnswerWithToken extends QuestionAndAnswer {
- nextSyncToken?: string
-}
-
-export const normalizeHelpData = (
- data: SyncCollection,
- locale: string
-): QuestionAndAnswerWithToken => {
- const { entries, nextSyncToken } = data
- const items = entries.reduce((acc, currentValue) => {
- return {
- ...acc,
- [currentValue.sys.id]: {
- id: currentValue.sys.id,
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- question: currentValue.fields.question[locale],
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- answer: currentValue.fields.answer[locale],
- },
- }
- }, {})
- const collection = entries.map(({ sys }: Entry) => sys.id)
- return {
- collection,
- items,
- nextSyncToken,
- }
-}
diff --git a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/create-freshdesk-ticket.types.ts b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/create-freshdesk-ticket.types.ts
index 6cef600c79..b305fa1292 100644
--- a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/create-freshdesk-ticket.types.ts
+++ b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/create-freshdesk-ticket.types.ts
@@ -10,6 +10,7 @@ export enum FreshdeskTicketDataType {
export enum FreshdeskTicketProduct {
Pure = "Mudita Pure",
Harmony = "Mudita Harmony",
+ HarmonyMsc = "Mudta Harmony MSC Mode",
Unknown = "Unknown",
None = "None",
}
diff --git a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.test.ts b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.test.ts
index 943a22aaa5..0422c79931 100644
--- a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.test.ts
+++ b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.test.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { FreshdeskTicketProduct } from "./create-freshdesk-ticket.types"
import { mapDeviceTypeToProduct } from "./map-device-type-to-product.helper"
diff --git a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.ts b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.ts
index 738ccccbb1..0dd7077a8a 100644
--- a/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.ts
+++ b/libs/core/__deprecated__/renderer/utils/create-freshdesk-ticket/map-device-type-to-product.helper.ts
@@ -3,11 +3,12 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants/device-type.constant"
+import { DeviceType } from "device-protocol/models"
import { FreshdeskTicketProduct } from "./create-freshdesk-ticket.types"
const DEVICE_TYPE_TO_PRODUCT: Record = {
[DeviceType.MuditaHarmony]: FreshdeskTicketProduct.Harmony,
+ [DeviceType.MuditaHarmonyMsc]: FreshdeskTicketProduct.HarmonyMsc,
[DeviceType.MuditaPure]: FreshdeskTicketProduct.Pure,
[DeviceType.APIDevice]: FreshdeskTicketProduct.Unknown,
}
diff --git a/libs/core/__deprecated__/renderer/utils/hooks/use-dynamic-progress-value.hook.test.tsx b/libs/core/__deprecated__/renderer/utils/hooks/use-dynamic-progress-value.hook.test.tsx
deleted file mode 100644
index fa5a26c65b..0000000000
--- a/libs/core/__deprecated__/renderer/utils/hooks/use-dynamic-progress-value.hook.test.tsx
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { renderHook, waitFor } from "@testing-library/react"
-import useDynamicProgressValue from "Core/__deprecated__/renderer/utils/hooks/use-dynamic-progress-value.hook"
-
-test("return the incremented progress value in the next render", async () => {
- const { result } = renderHook((props = 0) =>
- useDynamicProgressValue(props)
- )
- await waitFor(() => {
- expect(result.current).toBe(1)
- })
-
- await waitFor(() => {
- expect(result.current).toBe(2)
- })
-})
-
-test("new props don't have an impact on the smooth incrementing value", async () => {
- const { result, rerender } = renderHook((props = 0) =>
- useDynamicProgressValue(props)
- )
- await waitFor(() => {
- expect(result.current).toBe(1)
- })
-
- rerender(15)
-
- expect(result.current).not.toBe(15)
- await waitFor(() => {
- expect(result.current).toBe(2)
- })
-})
-
-test("passing the 100 number value return immediately 100 as complete progress state", async () => {
- const { result, rerender } = renderHook((props = 0) =>
- useDynamicProgressValue(props)
- )
- await waitFor(() => {
- expect(result.current).toBe(1)
- })
-
- rerender(100)
-
- await waitFor(() => {
- expect(result.current).not.toBe(2)
- expect(result.current).toBe(100)
- })
-})
-
-test("incremental progress value does not back down", async () => {
- const { result, rerender } = renderHook((props = 0) =>
- useDynamicProgressValue(props)
- )
- await waitFor(() => {
- expect(result.current).toBe(1)
- })
-
- await waitFor(() => {
- expect(result.current).toBe(2)
- })
-
- rerender(1)
-
- await waitFor(() => {
- expect(result.current).toBe(3)
- })
-})
-
-test("incremental progress value does not increase beyond the limit", async () => {
- const { result } = renderHook(() =>
- useDynamicProgressValue(0, { limitValue: 3 })
- )
- await waitFor(() => {
- expect(result.current).toBe(1)
- })
-
- try {
- new Error("unexpected re rendering has occurred")
- } catch {
- await waitFor(() => {
- expect(result.current).not.toBe(4)
- expect(result.current).toBe(3)
- })
- }
-})
diff --git a/libs/core/__deprecated__/renderer/utils/hooks/use-help-search/use-help-search.ts b/libs/core/__deprecated__/renderer/utils/hooks/use-help-search/use-help-search.ts
deleted file mode 100644
index 3d152a1561..0000000000
--- a/libs/core/__deprecated__/renderer/utils/hooks/use-help-search/use-help-search.ts
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { useCallback, useEffect, useMemo, useState } from "react"
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-import { ipcRenderer } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
-import debounce from "lodash/debounce"
-import { useSelector } from "react-redux"
-import { selectOnlineStatusSelector } from "shared/app-state"
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const useHelpSearch = (
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- saveToStore?: (data: QuestionAndAnswer) => Promise,
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- getStoreData?: (key?: string) => Promise
-): { data: QuestionAndAnswer; searchQuestion: (value: string) => void } => {
- const onlineStatus = useSelector(selectOnlineStatusSelector)
- const [data, setData] = useState({
- collection: [],
- items: {},
- })
- const [searchValue, setSearchValue] = useState("")
-
- const setDefaultHelpItemsAndSaveToStore = async (): Promise => {
- if (getStoreData) {
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- const storeData = await getStoreData("data")
- if (storeData) {
- setData(storeData)
- } else {
- const defaultHelpItems =
- require("Core/help/default-help.json") as QuestionAndAnswer
- setData(defaultHelpItems)
- if (saveToStore) {
- await saveToStore(defaultHelpItems)
- }
- }
- }
- }
- const fetchDataAndSaveToStore = async (): Promise => {
- const response: QuestionAndAnswer = await ipcRenderer.callMain(
- HelpActions.DownloadContentfulData
- )
- if (saveToStore) {
- await saveToStore(response)
- }
- if (getStoreData) {
- setData(await getStoreData("data"))
- }
- }
-
- useEffect(() => {
- if (onlineStatus) {
- void fetchDataAndSaveToStore()
- } else {
- void setDefaultHelpItemsAndSaveToStore()
- }
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [onlineStatus])
-
- const searchQuestion = (value: string) => {
- if (value) {
- if (value.length >= 3) {
- delaySearch(value)
- }
- } else {
- delaySearch.cancel()
- setSearchValue("")
- }
- }
-
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line react-hooks/exhaustive-deps
- const delaySearch = useCallback(
- debounce((value: string) => setSearchValue(value), 1000),
- []
- )
-
- const filteredData = useMemo(
- () => ({
- ...data,
- collection: Object.keys(data.items ? data.items : [])
- .map((id) => data.items[id])
- .filter(({ question }) =>
- question.toLowerCase().includes(searchValue.toLowerCase())
- )
- .map(({ id }) => id),
- }),
- [data, searchValue]
- )
-
- return {
- data: filteredData,
- searchQuestion,
- }
-}
diff --git a/libs/core/__deprecated__/renderer/utils/render-with-theme-and-intl.tsx b/libs/core/__deprecated__/renderer/utils/render-with-theme-and-intl.tsx
index 413f10a56e..1b545df78c 100644
--- a/libs/core/__deprecated__/renderer/utils/render-with-theme-and-intl.tsx
+++ b/libs/core/__deprecated__/renderer/utils/render-with-theme-and-intl.tsx
@@ -33,9 +33,7 @@ export function constructWrapper(ui: React.ReactElement) {
locale={translationConfig.defaultLanguage}
messages={process.env.NODE_ENV === "test" ? testLocale : localeEn}
>
-
- {ui}
-
+ {ui}
)
diff --git a/libs/core/__deprecated__/renderer/wrappers/layout-blank-wrapper.tsx b/libs/core/__deprecated__/renderer/wrappers/layout-blank-wrapper.tsx
index 71933fd251..217358f38b 100644
--- a/libs/core/__deprecated__/renderer/wrappers/layout-blank-wrapper.tsx
+++ b/libs/core/__deprecated__/renderer/wrappers/layout-blank-wrapper.tsx
@@ -5,7 +5,6 @@
import * as React from "react"
import styled from "styled-components"
-import { connect } from "react-redux"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import {
textColor,
@@ -18,8 +17,6 @@ import Text, {
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { LayoutBlankWrapperTestIds } from "Core/__deprecated__/renderer/wrappers/wrappers-test-ids.enum"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-import { RootState, ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { State } from "Core/core/constants"
import { useHandleActiveDeviceAborted } from "Core/overview/components/overview-screens/pure-overview/use-handle-active-device-aborted.hook"
import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
import { Close } from "Core/__deprecated__/renderer/components/core/modal/modal.styled.elements"
@@ -64,41 +61,19 @@ const Header = styled.header`
}
`
-interface ComponentProps {
- recoveryMode?: boolean
- onClose?: () => void
-}
-interface StateProps {
- closeable: boolean
-}
-
-type Props = ComponentProps & StateProps
-
const MainTitle = styled(Text)`
padding-top: 0.3rem;
`
-const mapStateToProps = (
- state: RootState & ReduxRootState,
- ownProps: ComponentProps
-): Props => {
- return {
- closeable: !(
- state.update.needsForceUpdate ||
- state.update.forceUpdateState === State.Loading ||
- state.update.updateOsState === State.Loading ||
- state.genericViews.activeDevice
- ),
- recoveryMode: ownProps.recoveryMode,
- onClose: ownProps.onClose,
- }
+interface Props {
+ closeable?: boolean
+ onClose?: () => void
}
const LayoutBlankWrapper: FunctionComponent = ({
children,
- recoveryMode,
onClose,
- closeable,
+ closeable = true,
}) => {
const handleActiveDeviceAborted = useHandleActiveDeviceAborted()
@@ -115,7 +90,7 @@ const LayoutBlankWrapper: FunctionComponent = ({
displayStyle={TextDisplayStyle.Paragraph3}
message={{ id: "module.onboarding.mainTitle" }}
/>
- {!recoveryMode && closeable && (
+ {closeable && (
= ({
)
}
-export default connect(mapStateToProps)(LayoutBlankWrapper)
+export default LayoutBlankWrapper
diff --git a/libs/core/__deprecated__/seeds/help.ts b/libs/core/__deprecated__/seeds/help.ts
deleted file mode 100644
index e1b455d307..0000000000
--- a/libs/core/__deprecated__/seeds/help.ts
+++ /dev/null
@@ -1,270 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-import { BLOCKS, Document } from "@contentful/rich-text-types"
-import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
-
-export const mockedHeadingText = "lala 123"
-export const mockedParagraphText =
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus diam neque, varius ac fermentum sit amet, interdum in metus. Vivamus eleifend turpis nec accumsan mollis."
-export const mockedMinorHeadingText =
- "Maecenas ultricies ex mi, quis consequat est cursus ut."
-
-const answer: Document = {
- nodeType: BLOCKS.DOCUMENT,
- data: {},
- content: [
- {
- nodeType: BLOCKS.HEADING_1,
- content: [
- {
- nodeType: "text",
- value: mockedHeadingText,
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: BLOCKS.PARAGRAPH,
- content: [
- {
- nodeType: "text",
- value: mockedParagraphText,
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: BLOCKS.HEADING_3,
- content: [
- {
- nodeType: "text",
- value: mockedMinorHeadingText,
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- ],
-}
-
-export const data: QuestionAndAnswer = {
- collection: [
- "e66895c6-3d65-4f96-8c81-e58c43ec6aee",
- "73f44c12-5c00-433f-a9cf-e7e503fa2594",
- "a042a5a8-6478-4e2b-8040-36b97497740f",
- "832b39ed-140b-476c-b1d8-6de8e441e3c2",
- "6d959bb2-489e-4419-a107-60abaa745d5c1",
- "6d959bb2-489e-4419-a107-60abaa745d5c2",
- "3c0c7f13-5b84-4da8-a7ea-e66a654b7c7f",
- "4c0c7f13-5b84-4da8-a7ea-e66a654b7c7f",
- "116d959bb2-489e-4419-a107-60abaa745d5c2",
- ],
- items: {
- "e66895c6-3d65-4f96-8c81-e58c43ec6aee": {
- id: "e66895c6-3d65-4f96-8c81-e58c43ec6aee",
- question:
- "Fuga tenetur necessitatibus perferendis aliquid officia recusandae et.",
- answer,
- },
- "73f44c12-5c00-433f-a9cf-e7e503fa2594": {
- id: "73f44c12-5c00-433f-a9cf-e7e503fa2594",
- question: "Delectus ea distinctio dolore ea.",
- answer,
- },
- "a042a5a8-6478-4e2b-8040-36b97497740f": {
- id: "a042a5a8-6478-4e2b-8040-36b97497740f",
- question: "Odio id eligendi aliquid.",
- answer,
- },
- "832b39ed-140b-476c-b1d8-6de8e441e3c2": {
- id: "832b39ed-140b-476c-b1d8-6de8e441e3c2",
- question: "Odio id eligendi aliquid.",
- answer,
- },
- "6d959bb2-489e-4419-a107-60abaa745d5c1": {
- id: "6d959bb2-489e-4419-a107-60abaa745d5c1",
- question: "Autem porro consectetur voluptatem.",
- answer,
- },
- "6d959bb2-489e-4419-a107-60abaa745d5c2": {
- id: "6d959bb2-489e-4419-a107-60abaa745d5c2",
- question: "Autem porro consectetur voluptatem.",
- answer,
- },
- "3c0c7f13-5b84-4da8-a7ea-e66a654b7c7f": {
- id: "3c0c7f13-5b84-4da8-a7ea-e66a654b7c7f",
- question: "Laboriosam suscipit ut aperiam molestiae veritatis.",
- answer,
- },
- "4c0c7f13-5b84-4da8-a7ea-e66a654b7c7f": {
- id: "4c0c7f13-5b84-4da8-a7ea-e66a654b7c7f",
- question: "Laboriosam suscipit ut aperiam molestiae veritatis.",
- answer,
- },
- "116d959bb2-489e-4419-a107-60abaa745d5c2": {
- id: "116d959bb2-489e-4419-a107-60abaa745d5c2",
- question: "Saepe non quasi at ipsa autem molestias et consequuntur.",
- answer,
- },
- },
-}
-
-export const testQuestion =
- "Fuga tenetur necessitatibus perferendis aliquid officia recusandae et."
-
-export const testSeedCollectionIds = [
- "24YEjwJx8jAuedvWDz8rvU",
- "1NESOKKWZCTjV8rlSE4JbH",
-]
-
-export const testSeed = {
- data: {
- collection: testSeedCollectionIds,
- items: {
- "24YEjwJx8jAuedvWDz8rvU": {
- id: "24YEjwJx8jAuedvWDz8rvU",
- question: testQuestion,
- answer: {
- data: {},
- content: [
- {
- data: {},
- content: [
- {
- data: {},
- marks: [],
- value: "lala",
- nodeType: "text",
- },
- ],
- nodeType: "heading-1",
- },
- {
- data: {},
- content: [
- {
- data: {},
- marks: [],
- value: "",
- nodeType: "text",
- },
- ],
- nodeType: "paragraph",
- },
- ],
- nodeType: "document",
- },
- },
- "1NESOKKWZCTjV8rlSE4JbH": {
- id: "1NESOKKWZCTjV8rlSE4JbH",
- question: "Example question lala",
- answer: {
- nodeType: "document",
- data: {},
- content: [
- {
- nodeType: "heading-2",
- content: [
- {
- nodeType: "text",
- value:
- "Consectetur adipiscing elit. Fusce imperdiet nisi odio, et iaculis justo sagittis non.",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: "paragraph",
- content: [
- {
- nodeType: "text",
- value:
- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus diam neque, varius ac fermentum sit amet, interdum in metus. Vivamus eleifend turpis nec accumsan mollis.",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: "paragraph",
- content: [
- {
- nodeType: "text",
- value:
- "Sed nunc erat, tempor vel risus nec, consectetur lobortis lectus. Maecenas ultricies ex mi, quis consequat est cursus ut. Phasellus ut ante quis metus lacinia lacinia a non ante. Etiam ut libero sit amet sem rutrum mollis quis sed sapien. Donec vitae lacus vitae odio auctor rhoncus et sed ipsum. Pellentesque ac viverra turpis. Aliquam posuere lorem non orci placerat venenatis. Mauris posuere consectetur orci sed sodales.",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: "heading-3",
- content: [
- {
- nodeType: "text",
- value:
- "Maecenas ultricies ex mi, quis consequat est cursus ut.",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: "paragraph",
- content: [
- {
- nodeType: "text",
- value:
- "Sed nunc erat, tempor vel risus nec, consectetur lobortis lectus. Maecenas ultricies ex mi, quis consequat est cursus ut. Phasellus ut ante quis metus lacinia lacinia a non ante. Etiam ut libero sit amet sem rutrum mollis quis sed sapien. Donec vitae lacus vitae odio auctor rhoncus et sed ipsum.",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- {
- nodeType: "paragraph",
- content: [
- {
- nodeType: "text",
- value: "",
- marks: [],
- data: {},
- },
- ],
- data: {},
- },
- ],
- },
- },
- },
- nextSyncToken:
- "w7Ese3kdwpMbMhhgw7QAUsKiw6bCiw_ClnfDrRLCuFDDkMO5YcKMJQ_CvcKUecOnMHjCjsOGw5HDu1Fdwrs7E8KjYGgHf8OTw7ZWwrTCiTMDSmkkDHUuC8OvGsOOw4d4IUTCghbDu8KRwp4XZcKZZEklwqkHVjU6Z8OAccKqwoklwoPDlVTCv8OLW8O2RcKRSMOpFsKZbnUKw4_CnsKPwpA",
- },
-}
-
-export const mockedRouteAndPath = {
- route: `${URL_MAIN.help}/${data.collection[0]}`,
- path: `${URL_MAIN.help}/:questionId`,
-}
-
-export const testSerialNumber = "123"
-
-export const helpSeed = {
- list: data,
- serialNumber: testSerialNumber,
-}
diff --git a/libs/core/analytic-data-tracker/analytic-data-tracker.module.ts b/libs/core/analytic-data-tracker/analytic-data-tracker.module.ts
index 5a5da68fa9..006b6c2a76 100644
--- a/libs/core/analytic-data-tracker/analytic-data-tracker.module.ts
+++ b/libs/core/analytic-data-tracker/analytic-data-tracker.module.ts
@@ -5,6 +5,7 @@
import { EventEmitter } from "events"
import { MainProcessIpc } from "electron-better-ipc"
+import { DeviceProtocol } from "device-protocol/feature"
import { BaseModule } from "Core/core/module"
import { IndexStorage } from "Core/index-storage/types"
import { MetadataStore } from "Core/metadata"
@@ -12,7 +13,6 @@ import { AppLogger } from "Core/__deprecated__/main/utils/logger"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { AnalyticDataTrackerController } from "Core/analytic-data-tracker/controllers"
import { AnalyticDataTrackerFactory } from "Core/analytic-data-tracker/services"
-import { DeviceManager } from "Core/device-manager/services"
const apiUrl = String(process.env.ANALYTICS_API_URL)
const siteId = Number(process.env.ANALYTICS_API_SITE_ID)
@@ -20,7 +20,7 @@ const siteId = Number(process.env.ANALYTICS_API_SITE_ID)
export class AnalyticDataTrackerModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -29,7 +29,7 @@ export class AnalyticDataTrackerModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
diff --git a/libs/core/analytic-data-tracker/constants/track-event.constant.ts b/libs/core/analytic-data-tracker/constants/track-event.constant.ts
index 9ed7b514d3..fe89674917 100644
--- a/libs/core/analytic-data-tracker/constants/track-event.constant.ts
+++ b/libs/core/analytic-data-tracker/constants/track-event.constant.ts
@@ -18,4 +18,6 @@ export enum TrackEventCategory {
CenterUpdateFail = "Center Update - fail",
PureUpdateDownload = "Pure Update - download",
HarmonyUpdateDownload = "Harmony Update - download",
+ HelpFeedbackVisit = "Help feedback - visits",
+ HelpFeedbackVote = "Help feedback - votes",
}
diff --git a/libs/core/analytic-data-tracker/helpers/track-os-update.test.ts b/libs/core/analytic-data-tracker/helpers/track-os-update.test.ts
index 8e58f5310d..25e54c176a 100644
--- a/libs/core/analytic-data-tracker/helpers/track-os-update.test.ts
+++ b/libs/core/analytic-data-tracker/helpers/track-os-update.test.ts
@@ -8,7 +8,7 @@ import {
TrackOsUpdateState,
TrackOsUpdateOptions,
} from "Core/analytic-data-tracker/helpers/track-os-update"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { trackRequest } from "Core/analytic-data-tracker/requests"
import { TrackEventCategory } from "Core/analytic-data-tracker/constants"
diff --git a/libs/core/analytic-data-tracker/helpers/track-os-update.ts b/libs/core/analytic-data-tracker/helpers/track-os-update.ts
index 96067802f8..01170e9101 100644
--- a/libs/core/analytic-data-tracker/helpers/track-os-update.ts
+++ b/libs/core/analytic-data-tracker/helpers/track-os-update.ts
@@ -8,7 +8,7 @@ import {
trackWithoutDeviceCheckRequest,
} from "Core/analytic-data-tracker/requests"
import { HarmonyDeviceData, PureDeviceData } from "Core/device"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { TrackEvent } from "Core/analytic-data-tracker/types"
import { TrackEventCategory } from "Core/analytic-data-tracker/constants"
diff --git a/libs/core/analytic-data-tracker/helpers/track-os-version.test.ts b/libs/core/analytic-data-tracker/helpers/track-os-version.test.ts
index 94abd50690..b04165124d 100644
--- a/libs/core/analytic-data-tracker/helpers/track-os-version.test.ts
+++ b/libs/core/analytic-data-tracker/helpers/track-os-version.test.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import {
trackOsVersion,
TrackOsVersionOptions,
diff --git a/libs/core/analytic-data-tracker/helpers/track-os-version.ts b/libs/core/analytic-data-tracker/helpers/track-os-version.ts
index 8e7c87c9ab..cba63b2043 100644
--- a/libs/core/analytic-data-tracker/helpers/track-os-version.ts
+++ b/libs/core/analytic-data-tracker/helpers/track-os-version.ts
@@ -3,9 +3,9 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceType } from "device-protocol/models"
import { trackUniqueRequest } from "Core/analytic-data-tracker/requests"
import { HarmonyDeviceData, PureDeviceData } from "Core/device"
-import { DeviceType } from "Core/device/constants"
import { TrackEvent } from "Core/analytic-data-tracker/types"
import { TrackEventCategory } from "Core/analytic-data-tracker/constants"
diff --git a/libs/core/analytic-data-tracker/types/track-event.interface.ts b/libs/core/analytic-data-tracker/types/track-event.interface.ts
index 0e3e5a06d6..4eb8e9f913 100644
--- a/libs/core/analytic-data-tracker/types/track-event.interface.ts
+++ b/libs/core/analytic-data-tracker/types/track-event.interface.ts
@@ -61,7 +61,7 @@ export interface TrackEvent {
e_c?: string
e_a?: string
e_n?: string
- e_v?: string
+ e_v?: number
// Optional Content Tracking info
c_n?: string
diff --git a/libs/core/backup/actions/base.action.ts b/libs/core/backup/actions/base.action.ts
index 261b2467fa..12f7472c17 100644
--- a/libs/core/backup/actions/base.action.ts
+++ b/libs/core/backup/actions/base.action.ts
@@ -7,9 +7,6 @@ import { createAction } from "@reduxjs/toolkit"
import { BackupEvent } from "Core/backup/constants"
import { Backup } from "Core/backup/dto"
-export const setInitialBackupState = createAction(
- BackupEvent.SetInitialBackupState
-)
export const setBackupData = createAction(BackupEvent.SetBackupData)
export const readBackupDeviceDataState = createAction(
diff --git a/libs/core/backup/backup.module.ts b/libs/core/backup/backup.module.ts
index 2e28acd547..75a723a378 100644
--- a/libs/core/backup/backup.module.ts
+++ b/libs/core/backup/backup.module.ts
@@ -17,7 +17,7 @@ import {
LoadBackupService,
} from "Core/backup/services"
import { BackupController } from "Core/backup/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { FileManagerService } from "Core/files-manager/services"
import { FileDeleteCommand } from "Core/device-file-system/commands/file-delete.command"
import {
@@ -29,7 +29,7 @@ import { DeviceInfoService } from "Core/device-info/services"
export class BackupModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -38,7 +38,7 @@ export class BackupModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -46,30 +46,30 @@ export class BackupModule extends BaseModule {
fileSystem
)
- const deviceFileSystem = new DeviceFileSystemService(this.deviceManager)
+ const deviceFileSystem = new DeviceFileSystemService(this.deviceProtocol)
const fileManagerService = new FileManagerService(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new FileDeleteCommand(this.deviceManager),
+ new FileDeleteCommand(this.deviceProtocol),
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new RetrieveFilesCommand(this.deviceManager),
+ new RetrieveFilesCommand(this.deviceProtocol),
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new FileUploadCommand(this.deviceManager, this.fileSystem)
+ new FileUploadCommand(this.deviceProtocol, this.fileSystem)
)
- const deviceInfoService = new DeviceInfoService(this.deviceManager)
+ const deviceInfoService = new DeviceInfoService(this.deviceProtocol)
const backupCreateService = new BackupCreateService(
- this.deviceManager,
+ this.deviceProtocol,
deviceFileSystem,
fileManagerService,
deviceInfoService,
this.keyStorage
)
const backupRestoreService = new BackupRestoreService(
- this.deviceManager,
+ this.deviceProtocol,
deviceFileSystem,
deviceInfoService,
fileSystem
diff --git a/libs/core/backup/constants/event.enum.ts b/libs/core/backup/constants/event.enum.ts
index 5815786ece..f599f3a0ec 100644
--- a/libs/core/backup/constants/event.enum.ts
+++ b/libs/core/backup/constants/event.enum.ts
@@ -4,7 +4,6 @@
*/
export enum BackupEvent {
- SetInitialBackupState = "SET_INITIAL_BACKUP_STATE",
Load = "LOAD_BACKUP_DATA",
SetBackupData = "SET_BACKUP_DATA",
CreateBackup = "CREATE_BACKUP",
diff --git a/libs/core/backup/reducers/backup.reducer.ts b/libs/core/backup/reducers/backup.reducer.ts
index c6462c559f..3b62da9289 100644
--- a/libs/core/backup/reducers/backup.reducer.ts
+++ b/libs/core/backup/reducers/backup.reducer.ts
@@ -4,6 +4,7 @@
*/
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import { AppError } from "Core/core/errors"
import { State } from "Core/core/constants"
import { BackupState } from "Core/backup/reducers/backup.interface"
@@ -14,9 +15,9 @@ import {
startBackupDevice,
startRestoreDevice,
readRestoreDeviceDataState,
- setInitialBackupState,
} from "Core/backup/actions"
import { BackupError } from "Core/backup/constants"
+import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
export const initialState: BackupState = {
data: {
@@ -77,7 +78,7 @@ export const backupReducer = createReducer(
state.restoringState = State.Initial
state.error = null
})
- .addCase(setInitialBackupState, () => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return { ...initialState }
})
}
diff --git a/libs/core/backup/services/backup-create.service.test.ts b/libs/core/backup/services/backup-create.service.test.ts
index b46ae7dc01..680f45af28 100644
--- a/libs/core/backup/services/backup-create.service.test.ts
+++ b/libs/core/backup/services/backup-create.service.test.ts
@@ -3,20 +3,16 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceProtocol } from "device-protocol/feature"
+import { Endpoint, Method } from "core-device/models"
+import { BackupCategory, PhoneLockCategory } from "Core/device"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { BackupCreateService } from "Core/backup/services/backup-create.service"
import { MetadataStore, MetadataKey } from "Core/metadata"
import { BackupError, Operation } from "Core/backup/constants"
import { UpdaterStatus } from "Core/backup/dto"
-import { DeviceManager } from "Core/device-manager/services"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import {
- BackupCategory,
- Endpoint,
- Method,
- PhoneLockCategory,
-} from "Core/device"
import { FileManagerService } from "Core/files-manager/services"
import { DeviceInfoService } from "Core/device-info/services"
@@ -29,11 +25,11 @@ const updaterStatusSuccessMock: UpdaterStatus = {
successful: true,
}
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const deviceFileSystemAdapter = {
downloadDeviceFilesLocally: jest.fn(),
@@ -54,7 +50,7 @@ const deviceInfoService = {
} as unknown as DeviceInfoService
const subject = new BackupCreateService(
- deviceManager,
+ deviceProtocol,
deviceFileSystemAdapter,
fileManagerService,
deviceInfoService,
@@ -67,7 +63,7 @@ beforeEach(() => {
describe("Backup process happy path", () => {
test("Returns the `Result.success` object with backup data", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -118,14 +114,14 @@ describe("Backup process happy path", () => {
expect(result).toEqual(Result.success(["/user/backup/backup.tar"]))
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenNthCalledWith(1, {
+ expect(deviceProtocol.device.request).toHaveBeenNthCalledWith(1, {
endpoint: Endpoint.Backup,
method: Method.Post,
body: { category: BackupCategory.Backup },
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenNthCalledWith(2, {
+ expect(deviceProtocol.device.request).toHaveBeenNthCalledWith(2, {
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Status },
@@ -198,7 +194,7 @@ describe("Backup process failed path", () => {
})
test("Returns the `Result.failed` with `BackupError.CannotReachBackupLocation` if `DeviceInfo` endpoint return error status", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(Result.failed(new AppError("", "")))
deviceInfoService.getDeviceInfo = jest.fn().mockResolvedValue(
@@ -230,7 +226,7 @@ describe("Backup process failed path", () => {
})
test("Returns the `Result.failed` with `BackupError.CannotReachBackupLocation` if `Backup` endpoint return error status", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(Result.failed(new AppError("", "")))
deviceInfoService.getDeviceInfo = jest.fn().mockResolvedValue(
@@ -263,7 +259,7 @@ describe("Backup process failed path", () => {
})
test("Returns the `Result.failed` with `BackupError.BackupProcessFailed` if `deviceFileSystem.downloadFile` returns error status", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -316,7 +312,7 @@ describe("Backup process failed path", () => {
}, 10000)
test("Returns the `Result.failed` with `BackupError.BackupDownloadFailed` if `deviceFileSystem.downloadDeviceFilesLocally` returns error status", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
diff --git a/libs/core/backup/services/backup-create.service.ts b/libs/core/backup/services/backup-create.service.ts
index 785ed35cf0..27a5388f5a 100644
--- a/libs/core/backup/services/backup-create.service.ts
+++ b/libs/core/backup/services/backup-create.service.ts
@@ -3,14 +3,15 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { Endpoint, Method, BackupCategory } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
+import { BackupCategory } from "Core/device/constants"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { BackupError, Operation } from "Core/backup/constants"
import { MetadataStore, MetadataKey } from "Core/metadata"
import { CreateDeviceBackup } from "Core/backup/types"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { DeviceManager } from "Core/device-manager/services"
import { BaseBackupService } from "Core/backup/services/base-backup.service"
import { FileManagerService } from "Core/files-manager/services"
import { DeviceDirectory } from "Core/files-manager/constants"
@@ -18,13 +19,13 @@ import { DeviceInfoService } from "Core/device-info/services"
export class BackupCreateService extends BaseBackupService {
constructor(
- protected deviceManager: DeviceManager,
+ protected deviceProtocol: DeviceProtocol,
protected deviceFileSystem: DeviceFileSystemService,
protected fileManagerService: FileManagerService,
protected deviceInfoService: DeviceInfoService,
private keyStorage: MetadataStore
) {
- super(deviceManager, deviceFileSystem, deviceInfoService)
+ super(deviceProtocol, deviceFileSystem, deviceInfoService)
}
public async createBackup(
@@ -108,7 +109,7 @@ export class BackupCreateService extends BaseBackupService {
)
}
- const backupResponse = await this.deviceManager.device.request({
+ const backupResponse = await this.deviceProtocol.device.request({
endpoint: Endpoint.Backup,
method: Method.Post,
body: {
diff --git a/libs/core/backup/services/backup-restore.service.test.ts b/libs/core/backup/services/backup-restore.service.test.ts
index 25a8fb6bc9..aedd2b3297 100644
--- a/libs/core/backup/services/backup-restore.service.test.ts
+++ b/libs/core/backup/services/backup-restore.service.test.ts
@@ -5,6 +5,8 @@
import fs from "fs"
import path from "path"
+import { Endpoint, Method } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { BackupRestoreService } from "Core/backup/services/backup-restore.service"
@@ -12,9 +14,8 @@ import CryptoFileService from "Core/file-system/services/crypto-file-service/cry
import { BackupError, Operation } from "Core/backup/constants"
import { UpdaterStatus } from "Core/backup/dto"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
-import { DeviceManager } from "Core/device-manager/services"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { Endpoint, Method, PhoneLockCategory } from "Core/device"
+import { PhoneLockCategory } from "Core/device"
import { DeviceInfoService } from "Core/device-info/services"
const arrayBufferToBuffer = (unitArray: Uint8Array): Buffer => {
@@ -60,11 +61,11 @@ const updaterStatusSuccessForAnotherOperationMock: UpdaterStatus = {
successful: true,
}
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const deviceFileSystemAdapter = {
uploadFile: jest.fn(),
@@ -83,7 +84,7 @@ const deviceInfoService = {
} as unknown as DeviceInfoService
const subject = new BackupRestoreService(
- deviceManager,
+ deviceProtocol,
deviceFileSystemAdapter,
deviceInfoService,
fileSystemServiceMock
@@ -110,7 +111,7 @@ describe("Restore process happy path", () => {
.mockResolvedValueOnce(
Result.success(JSON.stringify(updaterStatusSuccessMock))
)
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -161,14 +162,14 @@ describe("Restore process happy path", () => {
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenNthCalledWith(1, {
+ expect(deviceProtocol.device.request).toHaveBeenNthCalledWith(1, {
endpoint: Endpoint.Restore,
method: Method.Post,
body: { restore: "fileBase.tar" },
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenNthCalledWith(2, {
+ expect(deviceProtocol.device.request).toHaveBeenNthCalledWith(2, {
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Status },
@@ -262,7 +263,7 @@ describe("Backup restoring failed path", () => {
deviceFileSystemAdapter.uploadFile = jest
.fn()
.mockResolvedValueOnce(Result.success(true))
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -274,7 +275,7 @@ describe("Backup restoring failed path", () => {
return Result.failed(new AppError("", ""))
})
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(Result.failed(new AppError("", "")))
deviceInfoService.getDeviceInfo = jest.fn().mockResolvedValue(
@@ -309,7 +310,7 @@ describe("Backup restoring failed path", () => {
deviceFileSystemAdapter.downloadFile = jest
.fn()
.mockResolvedValueOnce(Result.failed(new AppError("", "")))
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -370,7 +371,7 @@ describe("Backup restoring failed path", () => {
JSON.stringify(updaterStatusSuccessForAnotherOperationMock)
)
)
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
@@ -429,7 +430,7 @@ describe("Backup restoring failed path", () => {
.mockResolvedValueOnce(
Result.success(JSON.stringify(updaterStatusFailedMock))
)
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation((config: { endpoint: Endpoint; method: Method }) => {
if (
diff --git a/libs/core/backup/services/backup-restore.service.ts b/libs/core/backup/services/backup-restore.service.ts
index 439b91b421..5c3711d5f6 100644
--- a/libs/core/backup/services/backup-restore.service.ts
+++ b/libs/core/backup/services/backup-restore.service.ts
@@ -3,26 +3,26 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import CryptoFileService from "Core/file-system/services/crypto-file-service/crypto-file-service"
import { RestoreDeviceBackup } from "Core/backup/types"
import { BackupError, Operation } from "Core/backup/constants"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { BaseBackupService } from "Core/backup/services/base-backup.service"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { DeviceInfoService } from "Core/device-info/services"
export class BackupRestoreService extends BaseBackupService {
constructor(
- protected deviceManager: DeviceManager,
+ protected deviceProtocol: DeviceProtocol,
protected deviceFileSystem: DeviceFileSystemService,
protected deviceInfoService: DeviceInfoService,
private fileSystem: FileSystemService
) {
- super(deviceManager, deviceFileSystem, deviceInfoService)
+ super(deviceProtocol, deviceFileSystem, deviceInfoService)
}
public async restoreBackup({
@@ -74,7 +74,7 @@ export class BackupRestoreService extends BaseBackupService {
)
}
- const restoreResult = await this.deviceManager.device.request({
+ const restoreResult = await this.deviceProtocol.device.request({
endpoint: Endpoint.Restore,
method: Method.Post,
body: {
diff --git a/libs/core/backup/services/base-backup.service.ts b/libs/core/backup/services/base-backup.service.ts
index 06793648cb..c8f862728c 100644
--- a/libs/core/backup/services/base-backup.service.ts
+++ b/libs/core/backup/services/base-backup.service.ts
@@ -3,12 +3,13 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { Endpoint, Method, PhoneLockCategory } from "Core/device"
+import { Endpoint, Method } from "core-device/models"
+import { PhoneLockCategory } from "Core/device"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { Operation, BackupError } from "Core/backup/constants"
import { UpdaterStatus } from "Core/backup/dto"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceFileSystemService } from "Core/device-file-system/services"
import { DeviceInfoService } from "Core/device-info/services"
@@ -17,7 +18,7 @@ export class BaseBackupService {
private REQUEST_TIME_OUT = 5000
constructor(
- protected deviceManager: DeviceManager,
+ protected deviceProtocol: DeviceProtocol,
protected deviceFileSystem: DeviceFileSystemService,
protected deviceInfoService: DeviceInfoService
) {}
@@ -95,7 +96,6 @@ export class BaseBackupService {
}
private async waitUntilDeviceResponse(index = 0): Promise {
-
if (index === this.MAX_WAKE_UP_RETRIES) {
return false
}
@@ -127,7 +127,7 @@ export class BaseBackupService {
return false
}
- const response = await this.deviceManager.device.request({
+ const response = await this.deviceProtocol.device.request({
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Status },
diff --git a/libs/core/backup/services/sync-backup-create.service.ts b/libs/core/backup/services/sync-backup-create.service.ts
index e89fee569d..bf69389bbc 100644
--- a/libs/core/backup/services/sync-backup-create.service.ts
+++ b/libs/core/backup/services/sync-backup-create.service.ts
@@ -8,9 +8,10 @@ import { AppError } from "Core/core/errors"
import { BackupError } from "Core/backup/constants"
import { MetadataStore, MetadataKey } from "Core/metadata"
import { TokenOptions } from "Core/file-system/services/crypto-file-service/crypto-file-service"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { BackupCategory, BackupState, Endpoint, Method } from "Core/device"
+import { Endpoint, Method } from "core-device/models"
+import { BackupCategory, BackupState } from "Core/device"
import {
DeviceInfo,
GetBackupDeviceStatusRequestConfigBody,
@@ -26,14 +27,14 @@ export interface createSyncBackupOptions
export class SyncBackupCreateService {
constructor(
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public deviceFileSystem: DeviceFileSystemService,
private keyStorage: MetadataStore
) {}
public async createSyncBackup(
options: createSyncBackupOptions,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
if (this.keyStorage.getValue(MetadataKey.BackupInProgress)) {
return Result.failed(
@@ -80,9 +81,9 @@ export class SyncBackupCreateService {
}
private async runDeviceSyncBackup(
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
- const deviceResponse = await this.deviceManager.request(
+ const deviceResponse = await this.deviceProtocol.request(
deviceId,
{
endpoint: Endpoint.DeviceInfo,
@@ -100,7 +101,7 @@ export class SyncBackupCreateService {
}
// id field as backup response is a deprecated field after Pure_1.6.0 & Harmony_1.9.0 (UDM releases)
- const backupResponse = await this.deviceManager.request<{
+ const backupResponse = await this.deviceProtocol.request<{
id?: string
}>(deviceId, {
endpoint: Endpoint.Backup,
@@ -150,7 +151,7 @@ export class SyncBackupCreateService {
private async waitUntilBackupDeviceFinished(
id: string,
iteration = 0,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
try {
const result = await this.getBackupDeviceStatus(
@@ -180,9 +181,9 @@ export class SyncBackupCreateService {
public async getBackupDeviceStatus(
config: GetBackupDeviceStatusRequestConfigBody,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
- return await this.deviceManager.request(deviceId, {
+ return await this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.Backup,
method: Method.Get,
body: {
diff --git a/libs/core/connecting/components/connecting-content.component.tsx b/libs/core/connecting/components/connecting-content.component.tsx
index 12d785adca..47ab4af107 100644
--- a/libs/core/connecting/components/connecting-content.component.tsx
+++ b/libs/core/connecting/components/connecting-content.component.tsx
@@ -3,42 +3,44 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+/* eslint-disable @typescript-eslint/no-unsafe-return */
+
import React from "react"
+import styled from "styled-components"
+import { defineMessages } from "react-intl"
+import { SpinnerLoader } from "generic-view/ui"
+import { GenericThemeProvider } from "generic-view/theme"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import Text, {
- TextDisplayStyle,
-} from "Core/__deprecated__/renderer/components/core/text/text.component"
+import { intl } from "Core/__deprecated__/renderer/utils/intl"
-import Loader from "Core/__deprecated__/renderer/components/core/loader/loader.component"
-import { LoaderType } from "Core/__deprecated__/renderer/components/core/loader/loader.interface"
-import styled from "styled-components"
-import { backgroundColor } from "Core/core/styles/theming/theme-getters"
+const messages = defineMessages({
+ connectingMessage: {
+ id: "module.onboarding.connectingMessage",
+ },
+ connectingLongMessage: {
+ id: "module.onboarding.connectingLongMessage",
+ },
+})
export const Container = styled.section`
- display: grid;
- grid-template-areas: "Header" "Main" "Footer";
- grid-row-gap: 0;
- grid-template-rows: 6.5rem 1fr 14rem;
-
- main {
- grid-area: Main;
- text-align: center;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
-`
-
-const LoaderWrapper = styled.div`
- width: 20rem;
- height: 20rem;
display: flex;
- border-radius: 50%;
+ flex-direction: column;
align-items: center;
justify-content: center;
- background-color: ${backgroundColor("icon")};
- margin-bottom: 4rem;
+ background-color: rgba(0, 0, 0, 0.3);
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ overflow: auto;
+`
+
+const ConnectingText = styled.p`
+ font-size: ${({ theme }) => theme.fontSize.headline3};
+ line-height: ${({ theme }) => theme.lineHeight.headline3};
+ color: ${({ theme }) => theme.color.white};
+ font-weight: ${({ theme }) => theme.fontWeight.bold};
+ margin: 2.4rem 0 0;
`
interface Props {
@@ -46,23 +48,20 @@ interface Props {
longerConnection?: boolean
}
-const ConnectingContent: FunctionComponent = ({ longerConnection = false }) => {
+const ConnectingContent: FunctionComponent = ({
+ longerConnection = false,
+}) => {
return (
-
-
-
-
-
-
-
-
+
+
+
+
+ {longerConnection
+ ? intl.formatMessage(messages.connectingLongMessage)
+ : intl.formatMessage(messages.connectingMessage)}
+
+
+
)
}
diff --git a/libs/core/contact-support/actions/send-ticket.action.test.ts b/libs/core/contact-support/actions/send-ticket.action.test.ts
index a6e1279957..1170bc16f6 100644
--- a/libs/core/contact-support/actions/send-ticket.action.test.ts
+++ b/libs/core/contact-support/actions/send-ticket.action.test.ts
@@ -14,7 +14,8 @@ import sendTicketRequest, {
CreateBugTicketResponseStatus,
} from "Core/contact-support/requests/send-ticket.request"
import { AppError } from "Core/core/errors"
-import { DeviceState, DeviceType } from "Core/device"
+import { DeviceState } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { ReduxRootState, RootState } from "Core/__deprecated__/renderer/store"
import { testError } from "Core/__deprecated__/renderer/store/constants"
import { FreshdeskTicketProduct } from "Core/__deprecated__/renderer/utils/create-freshdesk-ticket/create-freshdesk-ticket.types"
diff --git a/libs/core/contact-support/components/contact-support-flow.component.test.tsx b/libs/core/contact-support/components/contact-support-flow.component.test.tsx
deleted file mode 100644
index 47867a4112..0000000000
--- a/libs/core/contact-support/components/contact-support-flow.component.test.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import React, { ComponentProps } from "react"
-import ContactSupportFlow from "Core/contact-support/components/contact-support-flow.component"
-import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
-import { ContactSupportFlowTestIds } from "Core/contact-support/components/contact-support-flow-test-ids.component"
-import { SendTicketState } from "Core/contact-support/reducers"
-
-type Props = ComponentProps
-
-const defaultProps: Props = {
- closeContactSupportFlow: jest.fn(),
- sendTicket: jest.fn(),
- state: null,
- files: [],
-}
-const render = (extraProps?: Partial) => {
- const props = {
- ...defaultProps,
- ...extraProps,
- }
- return renderWithThemeAndIntl()
-}
-
-describe("`ContactSupportFlow` component", () => {
- describe("when component is render with default props", () => {
- test("`ContactSupportModal` as default is render", () => {
- const { queryByTestId } = render()
-
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModal)
- ).toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalSuccess)
- ).not.toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalError)
- ).not.toBeInTheDocument()
- })
- })
-
- describe("when component is render with proper where `state` is set to `Sending`", () => {
- test("`ContactSupportModal` is render", () => {
- const { queryByTestId } = render({ state: SendTicketState.Sending })
-
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModal)
- ).toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalSuccess)
- ).not.toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalError)
- ).not.toBeInTheDocument()
- })
- })
-
- describe("when component is render with proper where `state` is set to `Success`", () => {
- test("`ContactSupportModal` is render", () => {
- const { queryByTestId } = render({ state: SendTicketState.Success })
-
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalSuccess)
- ).toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModal)
- ).not.toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalError)
- ).not.toBeInTheDocument()
- })
- })
-
- describe("when component is render with proper where `state` is set to `Error`", () => {
- test("`ContactSupportModal` is render", () => {
- const { queryByTestId } = render({ state: SendTicketState.Error })
-
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalError)
- ).toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModal)
- ).not.toBeInTheDocument()
- expect(
- queryByTestId(ContactSupportFlowTestIds.ContactSupportModalSuccess)
- ).not.toBeInTheDocument()
- })
- })
-})
diff --git a/libs/core/contact-support/components/contact-support-flow.component.tsx b/libs/core/contact-support/components/contact-support-flow.component.tsx
index 8946afa20d..e4e284260a 100644
--- a/libs/core/contact-support/components/contact-support-flow.component.tsx
+++ b/libs/core/contact-support/components/contact-support-flow.component.tsx
@@ -5,13 +5,15 @@
import React, { ComponentProps } from "react"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import ContactSupportModal from "Core/contact-support/components/contact-support-modal.component"
-import ContactSupportModalSuccess from "Core/contact-support/components/contact-support-modal-success.component"
-import ContactSupportModalError from "Core/contact-support/components/contact-support-modal-error.component"
+import ContactSupportModal from "./contact-support-modal.component"
+import { ContactSupportModalSuccess } from "./contact-support-modal-success.component"
+import { ContactSupportModalError } from "./contact-support-modal-error.component"
import { ContactSupportFlowTestIds } from "Core/contact-support/components/contact-support-flow-test-ids.component"
import { SendTicketState } from "Core/contact-support/reducers"
import { SendTicketPayload } from "Core/contact-support/actions/send-ticket.action"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
+import { GenericThemeProvider } from "generic-view/theme"
+import { Modal } from "generic-view/ui"
interface Props
extends Pick, "files"> {
@@ -39,17 +41,40 @@ const ContactSupportFlow: FunctionComponent = ({
sending={SendTicketState.Sending === state}
files={files}
/>
-
-
+
+
+
+
+
+
+
+
>
)
}
diff --git a/libs/core/contact-support/components/contact-support-modal-error.component.tsx b/libs/core/contact-support/components/contact-support-modal-error.component.tsx
index 78e538812c..a5a5327055 100644
--- a/libs/core/contact-support/components/contact-support-modal-error.component.tsx
+++ b/libs/core/contact-support/components/contact-support-modal-error.component.tsx
@@ -3,45 +3,41 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import React, { ComponentProps } from "react"
+import React from "react"
import { defineMessages } from "react-intl"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { ModalSize } from "Core/__deprecated__/renderer/components/core/modal/modal.interface"
-import Icon from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import {
- ModalDialog,
- ModalContent as SimpleModal,
- RoundIconWrapper,
-} from "Core/ui/components/modal-dialog"
-import Text, {
- TextDisplayStyle,
-} from "Core/__deprecated__/renderer/components/core/text/text.component"
-import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
+import { Modal } from "generic-view/ui"
+import { intl } from "Core/__deprecated__/renderer/utils/intl"
+import { ButtonSecondary } from "../../../generic-view/ui/src/lib/buttons/button-secondary"
+import { IconType } from "generic-view/utils"
const messages = defineMessages({
title: { id: "component.supportModalErrorTitle" },
body: { id: "component.supportModalErrorBody" },
+ closeButtonLabel: { id: "component.supportModalSuccessButtonLabel" },
})
-const ContactSupportModalError: FunctionComponent<
- ComponentProps
-> = (props) => (
-
-
-
-
-
-
- = ({
+ closeContactSupportFlow,
+}) => (
+ <>
+
+ {intl.formatMessage(messages.title)}
+ {intl.formatMessage(messages.body)}
+
+
-
-
+
+ >
)
-
-export default ContactSupportModalError
diff --git a/libs/core/contact-support/components/contact-support-modal-success.component.tsx b/libs/core/contact-support/components/contact-support-modal-success.component.tsx
index d639d21015..f51cd23ee1 100644
--- a/libs/core/contact-support/components/contact-support-modal-success.component.tsx
+++ b/libs/core/contact-support/components/contact-support-modal-success.component.tsx
@@ -3,45 +3,41 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import React, { ComponentProps } from "react"
+import React from "react"
import { defineMessages } from "react-intl"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { ModalSize } from "Core/__deprecated__/renderer/components/core/modal/modal.interface"
-import Icon from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import {
- ModalDialog,
- ModalContent as SimpleModal,
- RoundIconWrapper,
-} from "Core/ui/components/modal-dialog"
-import Text, {
- TextDisplayStyle,
-} from "Core/__deprecated__/renderer/components/core/text/text.component"
-import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
+import { Modal } from "generic-view/ui"
+import { intl } from "Core/__deprecated__/renderer/utils/intl"
+import { ButtonSecondary } from "../../../generic-view/ui/src/lib/buttons/button-secondary"
+import { IconType } from "generic-view/utils"
const messages = defineMessages({
title: { id: "component.supportModalSuccessTitle" },
body: { id: "component.supportModalSuccessBody" },
+ closeButtonLabel: { id: "component.supportModalSuccessButtonLabel" },
})
-const ContactSupportModalSuccess: FunctionComponent<
- ComponentProps
-> = ({ ...props }) => (
-
-
-
-
-
-
- = ({
+ closeContactSupportFlow,
+}) => (
+ <>
+
+ {intl.formatMessage(messages.title)}
+ {intl.formatMessage(messages.body)}
+
+
-
-
+
+ >
)
-
-export default ContactSupportModalSuccess
diff --git a/libs/core/contact-support/components/contact-support-modal.component.test.tsx b/libs/core/contact-support/components/contact-support-modal.component.test.tsx
index 7e7a327839..2312575fb4 100644
--- a/libs/core/contact-support/components/contact-support-modal.component.test.tsx
+++ b/libs/core/contact-support/components/contact-support-modal.component.test.tsx
@@ -90,6 +90,7 @@ test("form trigger onSubmit when form is valid", async () => {
fireEvent.change(emailInput, {
target: { value: "mudita@center.com" },
})
+ await waitFor(() => expect(submitButton).toBeEnabled())
fireEvent.click(submitButton)
await waitFor(() => {
diff --git a/libs/core/contact-support/components/contact-support-modal.component.tsx b/libs/core/contact-support/components/contact-support-modal.component.tsx
index 79b1bc9f85..96e25a9ee7 100644
--- a/libs/core/contact-support/components/contact-support-modal.component.tsx
+++ b/libs/core/contact-support/components/contact-support-modal.component.tsx
@@ -14,10 +14,7 @@ import { ModalSize } from "Core/__deprecated__/renderer/components/core/modal/mo
import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
-import {
- backgroundColor,
- borderRadius,
-} from "Core/core/styles/theming/theme-getters"
+import { borderRadius } from "Core/core/styles/theming/theme-getters"
import InputComponent from "Core/__deprecated__/renderer/components/core/input-text/input-text.component"
import { Message } from "Core/__deprecated__/renderer/interfaces/message.interface"
import Button from "Core/__deprecated__/renderer/components/core/button/button.component"
@@ -29,13 +26,16 @@ import { InputComponentProps } from "Core/__deprecated__/renderer/components/cor
import { emailValidator } from "Core/__deprecated__/renderer/utils/form-validators"
import { getModalButtonsSize } from "Core/__deprecated__/renderer/components/core/modal/modal.helpers"
import { ContactSupportModalTestIds } from "Core/contact-support/components/contact-support-modal-test-ids.enum"
-import { IconSize } from "Core/__deprecated__/renderer/components/core/icon/icon.component"
+import Icon from "Core/__deprecated__/renderer/components/core/icon/icon.component"
import { ModalDialog } from "Core/ui/components/modal-dialog"
import FileList from "Core/__deprecated__/renderer/components/core/file-list/file-list.component"
import { SendTicketPayload } from "Core/contact-support/actions/send-ticket.action"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
import { ipcRenderer } from "electron-better-ipc"
import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
+import { ModalTestIds } from "Core/__deprecated__/renderer/components/core/modal/modal-test-ids.enum"
+import { Close } from "Core/__deprecated__/renderer/components/core/modal/modal.styled.elements"
+import { SpinnerLoader } from "../../../generic-view/ui/src/lib/shared/spinner-loader"
const messages = defineMessages({
actionButton: {
@@ -61,6 +61,7 @@ const messages = defineMessages({
id: "component.contactSupportModalFormFilesLabelDescription",
},
optional: { id: "component.contactSupportModalFormOptional" },
+ sendingTitle: { id: "component.contactSupportModalSendingTitle" },
})
export const DescriptionInput = styled(InputComponent)`
@@ -78,17 +79,13 @@ export const DescriptionInput = styled(InputComponent)`
const Form = styled.form`
display: flex;
flex-direction: column;
- margin-bottom: 0.8rem;
`
const ButtonWrapper = styled.div`
- margin-top: 4rem;
-`
-
-const ButtonWithRotatingIcon = styled(Button)`
- svg {
- fill: ${backgroundColor("lightIcon")};
- }
+ margin-top: 2.4rem;
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
`
interface FormInputLabelProps {
@@ -115,7 +112,7 @@ export const FormInputLabelComponent: FunctionComponent<
)
export const FormInputLabel = styled(FormInputLabelComponent)`
- margin-bottom: 0.4rem;
+ margin-bottom: 0.8rem;
&:not(:first-of-type) {
margin-top: 2.4rem;
@@ -155,6 +152,7 @@ const ContactSupportModal: FunctionComponent = ({
reset,
handleSubmit,
formState: { errors, isValid, isDirty, isSubmitted },
+ watch,
} = useForm({
mode: "onChange",
defaultValues: {
@@ -162,6 +160,7 @@ const ContactSupportModal: FunctionComponent = ({
[FieldKeys.Description]: "",
},
})
+ const email = watch(FieldKeys.Email)
const sendEmail = handleSubmit((data) => {
onSubmit(data)
@@ -180,63 +179,186 @@ const ContactSupportModal: FunctionComponent = ({
return (
+ }
{...rest}
>
-
+ {sending ? (
+ <>
+
+
+
+
+
+
+
+
+ >
+ ) : (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )}
)
}
export default ContactSupportModal
+
+// Override styles to match new design
+const ModalHeader = styled.div`
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ margin-top: -4rem;
+ padding: 0 1rem;
+
+ & + * {
+ margin-top: 2.4rem;
+ }
+
+ p {
+ font-size: 1.6rem;
+ line-height: 2.4rem;
+ color: #3b3f42;
+ margin: 0;
+ text-align: center;
+ }
+
+ h1 {
+ font-size: 2rem;
+ line-height: 3.2rem;
+ margin: 1.4rem 0 0;
+
+ & + * {
+ margin-top: 2.4rem;
+ }
+ }
+`
+
+const LoaderIcon = styled((props) => )`
+ width: 4.1rem;
+ height: 4.1rem;
+`
+
+const ModalClose = styled(Close)<{ hidden?: boolean }>`
+ visibility: ${({ hidden }) => (hidden ? "hidden" : "visible")};
+ position: absolute;
+ width: 3.2rem;
+ height: 3.2rem;
+ right: 2.4rem;
+ top: 2.4rem;
+
+ svg {
+ width: 1.6rem;
+ height: 1.6rem;
+ }
+`
+
+const IconWrapper = styled.div`
+ width: 6.8rem;
+ height: 6.8rem;
+ border-radius: 50%;
+ background-color: #f4f5f6;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+
+ > span {
+ width: 2.7rem;
+ height: 2.7rem;
+ }
+`
+
+const FilesDescription = styled(Text)`
+ color: #3b3f42;
+ font-weight: 300;
+ letter-spacing: 0.05em;
+`
+
+const Files = styled(FileList)`
+ justify-content: flex-start;
+
+ li {
+ min-width: 34%;
+ width: auto;
+ }
+
+ span {
+ width: 2.2rem;
+ height: 2.2rem;
+ }
+ p {
+ font-size: 1.4rem;
+ font-weight: 400;
+ color: #000;
+ }
+`
diff --git a/libs/core/contacts/actions/base.action.ts b/libs/core/contacts/actions/base.action.ts
index 6224b7cfeb..96c3851b50 100644
--- a/libs/core/contacts/actions/base.action.ts
+++ b/libs/core/contacts/actions/base.action.ts
@@ -7,10 +7,6 @@ import { createAction } from "@reduxjs/toolkit"
import { ContactsEvent } from "Core/contacts/constants"
import { Contact, ContactID } from "Core/contacts/reducers"
-export const setInitialContactsState = createAction(
- ContactsEvent.SetInitialContactsState
-)
-
export const setContacts = createAction(ContactsEvent.SetContacts)
export const addNewContactsToState = createAction(
diff --git a/libs/core/contacts/actions/delete-contacts.action.test.ts b/libs/core/contacts/actions/delete-contacts.action.test.ts
index 44cc83121d..7d71bdb0b6 100644
--- a/libs/core/contacts/actions/delete-contacts.action.test.ts
+++ b/libs/core/contacts/actions/delete-contacts.action.test.ts
@@ -65,7 +65,7 @@ describe("async `deleteContacts` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -99,7 +99,7 @@ describe("async `deleteContacts` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -127,7 +127,7 @@ describe("async `deleteContacts` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
diff --git a/libs/core/contacts/actions/delete-contacts.action.ts b/libs/core/contacts/actions/delete-contacts.action.ts
index ef5261a54d..c8bcfc96e8 100644
--- a/libs/core/contacts/actions/delete-contacts.action.ts
+++ b/libs/core/contacts/actions/delete-contacts.action.ts
@@ -4,12 +4,12 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
+import { isActiveDeviceSet } from "active-device-registry/feature"
import { deleteContactsInState } from "Core/contacts/actions/base.action"
import { ContactsEvent } from "Core/contacts/constants"
import { ContactID } from "Core/contacts/reducers"
import { deleteContactsRequest } from "Core/contacts/requests"
import { AppError } from "Core/core/errors"
-import { isActiveDeviceSet } from "Core/device-manager/selectors/is-active-device-set.selector"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
export const deleteContacts = createAsyncThunk<
diff --git a/libs/core/contacts/actions/import-contact.action.test.ts b/libs/core/contacts/actions/import-contact.action.test.ts
index bb2bc830c7..4b12b3f36d 100644
--- a/libs/core/contacts/actions/import-contact.action.test.ts
+++ b/libs/core/contacts/actions/import-contact.action.test.ts
@@ -83,7 +83,7 @@ describe("async `importContact` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: importContactArg.activeDeviceId,
},
})
@@ -117,7 +117,7 @@ describe("async `importContact` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: importContactArg.activeDeviceId,
},
})
@@ -153,7 +153,7 @@ describe("async `importContact` ", () => {
)
const mockStore = createMockStore([thunk])({
contacts: initialState,
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: importContactArg.activeDeviceId,
},
})
diff --git a/libs/core/contacts/actions/import-contact.action.ts b/libs/core/contacts/actions/import-contact.action.ts
index 710a6b29d0..09756c04b7 100644
--- a/libs/core/contacts/actions/import-contact.action.ts
+++ b/libs/core/contacts/actions/import-contact.action.ts
@@ -12,7 +12,7 @@ import {
} from "Core/contacts/requests"
import { AppError } from "Core/core/errors"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
export interface ImportContactArg {
diff --git a/libs/core/contacts/components/contact-search-results/contact-search-results.component.tsx b/libs/core/contacts/components/contact-search-results/contact-search-results.component.tsx
index 3baa8dceb6..69db61f781 100644
--- a/libs/core/contacts/components/contact-search-results/contact-search-results.component.tsx
+++ b/libs/core/contacts/components/contact-search-results/contact-search-results.component.tsx
@@ -77,6 +77,16 @@ const SelectableContacts = styled(Table)<{ mouseLock?: boolean }>`
}
`
+const PhoneNumberCol = styled(Col)`
+ overflow: hidden;
+ height: calc(100% - 1rem);
+
+ > p {
+ height: 100%;
+ margin: 0;
+ }
+`
+
interface ContactSearchResultProps {
selectedContact: Contact | null
onSelect: (contact: Contact) => void
@@ -158,12 +168,16 @@ const ContactSearchResults: FunctionComponent = ({
id: "module.contacts.listUnnamedContact",
})}
- {phoneNumber}
-
- {contact.primaryPhoneNumber &&
- contact.secondaryPhoneNumber &&
- contact.secondaryPhoneNumber}
-
+
+ {phoneNumber}
+
+
+
+ {contact.primaryPhoneNumber &&
+ contact.secondaryPhoneNumber &&
+ contact.secondaryPhoneNumber}
+
+
diff --git a/libs/core/contacts/components/contacts/contacts.component.test.tsx b/libs/core/contacts/components/contacts/contacts.component.test.tsx
index bf7679260f..c24e15e9ab 100644
--- a/libs/core/contacts/components/contacts/contacts.component.test.tsx
+++ b/libs/core/contacts/components/contacts/contacts.component.test.tsx
@@ -176,7 +176,7 @@ const defaultProps: Props = {
selectAllItems: jest.fn(),
toggleItem: jest.fn(),
closeImportWindow: jest.fn(),
- getPaths: jest.fn(),
+ openFileRequest: jest.fn(),
}
const renderer = (extraProps?: Partial) => {
diff --git a/libs/core/contacts/components/contacts/contacts.component.tsx b/libs/core/contacts/components/contacts/contacts.component.tsx
index d0a5e4de42..2cf50007ea 100644
--- a/libs/core/contacts/components/contacts/contacts.component.tsx
+++ b/libs/core/contacts/components/contacts/contacts.component.tsx
@@ -23,10 +23,7 @@ import { ContactSection } from "Core/contacts/components/contacts/contacts.style
import { defineMessages } from "react-intl"
import useURLSearchParams from "Core/__deprecated__/renderer/utils/hooks/use-url-search-params"
import findContactByPhoneNumber from "Core/contacts/helpers/find-contact-by-phone-number/find-contact-by-phone-number"
-import {
- ExternalProvider,
- Provider,
-} from "generic-view/store"
+import { ExternalProvider, Provider } from "generic-view/store"
import delayResponse from "@appnroll/delay-response"
import {
ErrorDataModal,
@@ -57,7 +54,7 @@ import { filterContacts } from "Core/contacts/helpers/filter-contacts/filter-con
import { AppError } from "Core/core/errors"
import { RequestResponseStatus } from "Core/core/types"
import createFile from "Core/__deprecated__/renderer/utils/create-file/create-file"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
const allPossibleFormErrorCausedByAPI: FormError[] = [
{
@@ -99,7 +96,7 @@ const Contacts: FunctionComponent = ({
editContact,
deleteContacts,
authorize,
- getPaths,
+ openFileRequest,
exportContacts,
addNewContactsToState,
resetAllItems,
@@ -433,7 +430,7 @@ const Contacts: FunctionComponent = ({
// Synchronization, step 2a: file select
const importFromFile = async () => {
- const { payload: getPathsPayload } = await getPaths({
+ const openFileResult = await openFileRequest({
filters: [
{
name: "vcf",
@@ -442,7 +439,7 @@ const Contacts: FunctionComponent = ({
],
properties: ["openFile", "multiSelections"],
})
- const { ok, data: paths } = getPathsPayload
+ const { ok, data: paths } = openFileResult
const files =
ok && paths !== undefined ? paths.map((path) => createFile(path)) : []
diff --git a/libs/core/contacts/components/contacts/contacts.interface.ts b/libs/core/contacts/components/contacts/contacts.interface.ts
index 3561b3c187..1f9b86f3fb 100644
--- a/libs/core/contacts/components/contacts/contacts.interface.ts
+++ b/libs/core/contacts/components/contacts/contacts.interface.ts
@@ -68,9 +68,9 @@ export interface ContactsProps {
resultState: ResultState
contactList: ContactCategory[]
closeImportWindow: (provider: ExternalProvider) => Promise
- getPaths: (
+ openFileRequest: (
options: OpenDialogOptions
- ) => Promise>>
+ ) => Promise>
}
export interface NewContactResponse extends NewContact {
diff --git a/libs/core/contacts/components/contacts/contacts.stories.tsx b/libs/core/contacts/components/contacts/contacts.stories.tsx
index 0e547f2607..fd46fb35ae 100644
--- a/libs/core/contacts/components/contacts/contacts.stories.tsx
+++ b/libs/core/contacts/components/contacts/contacts.stories.tsx
@@ -90,7 +90,7 @@ const ContactsComponent = ({
selectAllItems={noop}
toggleItem={noop}
closeImportWindow={noop}
- getPaths={noop}
+ openFileRequest={noop}
/>
)
diff --git a/libs/core/contacts/constants/event.enum.ts b/libs/core/contacts/constants/event.enum.ts
index 0271898ebf..ac31c35332 100644
--- a/libs/core/contacts/constants/event.enum.ts
+++ b/libs/core/contacts/constants/event.enum.ts
@@ -4,7 +4,6 @@
*/
export enum ContactsEvent {
- SetInitialContactsState = "SET_INITIAL_CONTACTS_STATE",
DevClearAllContacts = "CONTACTS_DEV_CLEAR_ALL_CONTACTS",
SetContacts = "CONTACTS_SET_CONTACTS",
Authorize = "CONTACTS_AUTHORIZE",
diff --git a/libs/core/contacts/contact.module.ts b/libs/core/contacts/contact.module.ts
index af433b8f56..b40eaaf173 100644
--- a/libs/core/contacts/contact.module.ts
+++ b/libs/core/contacts/contact.module.ts
@@ -14,12 +14,12 @@ import { ContactModel } from "Core/contacts/models"
import { ContactController } from "Core/contacts/controllers"
import { ContactService } from "Core/contacts/services"
import { ContactRepository } from "Core/contacts/repositories"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class ContactModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -28,7 +28,7 @@ export class ContactModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -39,7 +39,7 @@ export class ContactModule extends BaseModule {
const contactRepository = new ContactRepository(contactModel)
const contactService = new ContactService(
contactRepository,
- this.deviceManager
+ this.deviceProtocol
)
const contactController = new ContactController(contactService)
diff --git a/libs/core/contacts/contacts.container.tsx b/libs/core/contacts/contacts.container.tsx
index a83ffece93..7cb8b09002 100644
--- a/libs/core/contacts/contacts.container.tsx
+++ b/libs/core/contacts/contacts.container.tsx
@@ -43,9 +43,13 @@ import {
selectAllItems,
toggleItem,
} from "Core/contacts/actions"
-import { getPaths } from "shared/app-state"
-import { googleGetContacts, outlookGetContacts, ExternalProvider,
- Provider, } from "generic-view/store"
+import { openFileRequest } from "system-utils/feature"
+import {
+ googleGetContacts,
+ outlookGetContacts,
+ ExternalProvider,
+ Provider,
+} from "generic-view/store"
const mapStateToProps = (state: RootModel & ReduxRootState) => {
const { contacts, auth } = state
@@ -82,7 +86,8 @@ const mapDispatchToProps = (dispatch: TmpDispatch) => {
contacts =
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/await-thenable
- (await dispatch(googleGetContacts())).payload as unknown as Contact[]
+ (await dispatch(googleGetContacts()))
+ .payload as unknown as Contact[]
return getContacts(contactDatabaseFactory(contacts))
case Provider.Apple:
return
@@ -90,7 +95,8 @@ const mapDispatchToProps = (dispatch: TmpDispatch) => {
contacts =
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/await-thenable
- (await dispatch(outlookGetContacts())).payload as unknown as Contact[]
+ (await dispatch(outlookGetContacts()))
+ .payload as unknown as Contact[]
return getContacts(contactDatabaseFactory(contacts))
}
},
@@ -151,10 +157,10 @@ const mapDispatchToProps = (dispatch: TmpDispatch) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
void dispatch(closeWindow(provider))
},
- getPaths: (options: OpenDialogOptions) =>
+ openFileRequest: (options: OpenDialogOptions) =>
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
- dispatch(getPaths(options)),
+ openFileRequest(options),
}
}
diff --git a/libs/core/contacts/reducers/contacts.reducer.ts b/libs/core/contacts/reducers/contacts.reducer.ts
index 1d6789f3c8..e0c909a331 100644
--- a/libs/core/contacts/reducers/contacts.reducer.ts
+++ b/libs/core/contacts/reducers/contacts.reducer.ts
@@ -6,8 +6,10 @@
// TODO: CP-1494, CP-1495
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import {
fulfilledAction,
+ pendingAction,
rejectedAction,
} from "Core/__deprecated__/renderer/store/helpers"
import {
@@ -35,7 +37,6 @@ import {
resetAllItems,
toggleItem,
deleteContacts,
- setInitialContactsState,
} from "Core/contacts/actions"
import { changeLocation } from "Core/core/actions"
@@ -55,7 +56,7 @@ export const contactsReducer = createReducer(
initialState,
(builder) => {
builder
- .addCase(setInitialContactsState, (state) => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return { ...initialState }
})
.addCase(
diff --git a/libs/core/contacts/services/contact.service.test.ts b/libs/core/contacts/services/contact.service.test.ts
index d4b3c971e1..280145de17 100644
--- a/libs/core/contacts/services/contact.service.test.ts
+++ b/libs/core/contacts/services/contact.service.test.ts
@@ -5,10 +5,10 @@
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { DeviceCommunicationError } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
import { ContactService } from "Core/contacts/services/contact.service"
import { ContactRepository } from "Core/contacts/repositories"
-import { DeviceManager } from "Core/device-manager/services/device-manager.service"
+import { DeviceProtocol } from "device-protocol/feature"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import { Contact as PureContact } from "Core/device/types/mudita-os"
import { Contact } from "Core/contacts/reducers"
@@ -19,13 +19,13 @@ const contactRepository = {
delete: jest.fn(),
} as unknown as ContactRepository
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
-const subject = new ContactService(contactRepository, deviceManager)
+const subject = new ContactService(contactRepository, deviceProtocol)
const pureContact: PureContact = {
id: 19,
@@ -63,59 +63,59 @@ beforeEach(() => {
describe("`ContactService`", () => {
describe("`getContact` method", () => {
test("map data and returns success when `device.request` returns success", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureContact))
const response = await subject.getContact("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
expect(response.data).toEqual(contact)
})
test("returns error when `device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getContact("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
describe("`getContacts` method", () => {
test("map data and returns success when `device.request` returns success", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success({ entries: [pureContact] }))
const response = await subject.getContacts()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
expect(response.data).toEqual([contact])
})
test("returns error when `device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getContacts()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
describe("`createContact` method", () => {
test("returns success and `repository.create` is called when `device.request` returns success", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success({ id: pureContact.id }))
const response = await subject.createContact(contact)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(contactRepository.create).toHaveBeenCalled()
@@ -124,11 +124,11 @@ describe("`ContactService`", () => {
})
test("returns error when `device.request` returns error`", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.createContact(contact)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(contactRepository.create).not.toHaveBeenCalled()
@@ -138,7 +138,7 @@ describe("`ContactService`", () => {
describe("`editContact` method", () => {
test("returns success and `repository.update` is called when `device.request` and `isContactValid` returns success", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureContact))
@@ -171,12 +171,12 @@ describe("`ContactService`", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.spyOn(subject as unknown as { isContactValid: any }, "isContactValid")
.mockImplementation(() => successResponse)
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.editContact(contact)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(contactRepository.update).not.toHaveBeenCalled()
@@ -186,12 +186,12 @@ describe("`ContactService`", () => {
describe("`deleteContacts` method", () => {
test("returns success and `repository.delete` is called when `device.request` returns success", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(successResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(successResponse)
const response = await subject.deleteContacts(["1"])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(contactRepository.delete).toHaveBeenCalled()
@@ -199,12 +199,12 @@ describe("`ContactService`", () => {
})
test("returns error with ids when `device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.deleteContacts(["1"])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(contactRepository.delete).not.toHaveBeenCalled()
diff --git a/libs/core/contacts/services/contact.service.ts b/libs/core/contacts/services/contact.service.ts
index b572bb191f..ed68ade0df 100644
--- a/libs/core/contacts/services/contact.service.ts
+++ b/libs/core/contacts/services/contact.service.ts
@@ -3,18 +3,14 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- DeviceCommunicationError,
- Endpoint,
- Method,
-} from "Core/device/constants"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
import {
GetContactResponseBody,
GetContactsResponseBody,
CreateContactResponseBody,
CreateContactErrorResponseBody,
} from "Core/device/types/mudita-os"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { Contact, ContactID } from "Core/contacts/reducers"
import { ContactRepository } from "Core/contacts/repositories"
import { ContactPresenter } from "Core/contacts/presenters"
@@ -27,12 +23,12 @@ import { ResultObject } from "Core/core/builder"
export class ContactService {
constructor(
private contactRepository: ContactRepository,
- private deviceManager: DeviceManager
+ private deviceProtocol: DeviceProtocol
) {}
public async getContact(id: string): Promise> {
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Contacts,
method: Method.Get,
body: {
@@ -55,7 +51,7 @@ export class ContactService {
public async getContacts(): Promise> {
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Contacts,
method: Method.Get,
})
@@ -94,7 +90,7 @@ export class ContactService {
//workaround
const result =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Contacts,
method: Method.Post,
body: ContactPresenter.mapToPureContact(newContact),
@@ -164,7 +160,7 @@ export class ContactService {
return isContactValidResponse
}
- const result = await this.deviceManager.device.request({
+ const result = await this.deviceProtocol.device.request({
endpoint: Endpoint.Contacts,
method: Method.Put,
body: ContactPresenter.mapToPureContact(contact),
@@ -224,7 +220,7 @@ export class ContactService {
const successIds = []
for (const id of contactIds) {
- const result = await this.deviceManager.device.request({
+ const result = await this.deviceProtocol.device.request({
endpoint: Endpoint.Contacts,
method: Method.Delete,
body: { id: Number(id) },
diff --git a/libs/core/core/application.module.ts b/libs/core/core/application.module.ts
index 337e674ca6..31eb7dc02a 100644
--- a/libs/core/core/application.module.ts
+++ b/libs/core/core/application.module.ts
@@ -10,17 +10,16 @@ import { EventEmitter } from "events"
import { MetadataStore } from "Core/metadata/services"
import logger from "Core/__deprecated__/main/utils/logger"
import { LoggerFactory } from "Core/core/factories"
-import { DeviceLogger } from "Core/core/types"
-import { flags, Feature } from "Core/feature-flags"
+import { DeviceLogger, Module } from "Core/core/types"
+import { Feature, flags } from "Core/feature-flags"
import PureLogger from "Core/__deprecated__/main/utils/pure-logger"
import { IndexFactory } from "Core/index-storage/factories"
import {
- DataIndexInitializer,
ControllerInitializer,
+ DataIndexInitializer,
InitializeInitializer,
ObserverInitializer,
} from "Core/core/initializers"
-import { Module } from "Core/core/types"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { IndexStorageModule } from "Core/index-storage/index-storage.module"
import { DataSyncModule } from "Core/data-sync/data-sync.module"
@@ -39,17 +38,25 @@ import { DeviceInfoModule } from "Core/device-info/device-info.module"
import { DeviceFileSystemModule } from "Core/device-file-system/device-file-system.module"
import { DeviceLogModule } from "Core/device-log/device-log.module"
import { DeviceModule } from "Core/device/device.module"
-import { DeviceManagerModule } from "Core/device-manager/device-manager.module"
import {
- DeviceManager,
+ DeviceProtocol,
+ DeviceProtocolModule,
DeviceResolverService,
-} from "Core/device-manager/services"
+ SerialPortService,
+} from "device-protocol/feature"
import { APIModule } from "device/feature"
import { DesktopModule } from "Core/desktop/desktop.module"
-import { FileSystemDialogModule, OnlineStatusModule } from "shared/app-state"
+import { OnlineStatusModule } from "shared/app-state"
import { SystemUtilsModule } from "system-utils/feature"
-import { MockDeviceResolverService, mockServiceEnabled } from "e2e-mock-server"
+import {
+ MockDeviceResolverService,
+ MockSerialPortService,
+ mockServiceEnabled,
+} from "e2e-mock-server"
import { ApplicationUpdaterModule } from "electron/application-updater"
+import { CoreDeviceModule } from "core-device/feature"
+import { createSettingsService } from "Core/settings/containers"
+import { HelpModule } from "help/feature"
export class ApplicationModule {
public modules: Module[] = [
@@ -71,10 +78,11 @@ export class ApplicationModule {
]
public lateModules: Module[] = [
- DeviceManagerModule,
+ DeviceProtocolModule,
DataSyncModule,
CrashDumpModule,
DesktopModule,
+ HelpModule,
]
private deviceLogger: DeviceLogger = LoggerFactory.getInstance()
@@ -91,12 +99,7 @@ export class ApplicationModule {
private apiModule: APIModule
- private deviceManager = new DeviceManager(
- mockServiceEnabled
- ? new MockDeviceResolverService()
- : new DeviceResolverService(),
- this.eventEmitter
- )
+ private deviceProtocol = this.resolveDeviceProtocol()
private systemUtilsModule = new SystemUtilsModule()
constructor(
@@ -114,16 +117,20 @@ export class ApplicationModule {
this.initializeInitializer = new InitializeInitializer()
this.modules.forEach(this.initModule)
- this.apiModule = new APIModule(this.deviceManager, this.systemUtilsModule)
- this.controllerInitializer.initialize(this.apiModule.getAPIServices())
- this.controllerInitializer.initialize(
- FileSystemDialogModule.getControllers()
+ this.apiModule = new APIModule(
+ this.deviceProtocol,
+ this.systemUtilsModule,
+ createSettingsService()
)
+ this.controllerInitializer.initialize(this.apiModule.getAPIServices())
this.controllerInitializer.initialize(this.systemUtilsModule.getServices())
this.controllerInitializer.initialize(
new ApplicationUpdaterModule().controllers
)
this.controllerInitializer.initialize(new OnlineStatusModule().controllers)
+ this.controllerInitializer.initialize(
+ new CoreDeviceModule(this.deviceProtocol, this.fileSystem).controllers
+ )
}
lateInitialization(): void {
@@ -133,7 +140,7 @@ export class ApplicationModule {
private initModule = (module: Module): void => {
const instance = new module(
this.index,
- this.deviceManager,
+ this.deviceProtocol,
this.keyStorage,
this.logger,
this.ipc,
@@ -147,4 +154,20 @@ export class ApplicationModule {
this.observerInitializer.initialize(instance.observers)
this.controllerInitializer.initialize(instance.controllers)
}
+
+ private resolveDeviceProtocol(): DeviceProtocol {
+ if (mockServiceEnabled) {
+ return new DeviceProtocol(
+ new MockSerialPortService(),
+ new MockDeviceResolverService(),
+ this.eventEmitter
+ )
+ } else {
+ return new DeviceProtocol(
+ new SerialPortService(),
+ new DeviceResolverService(),
+ this.eventEmitter
+ )
+ }
+ }
}
diff --git a/libs/core/core/components/apps-switch.tsx b/libs/core/core/components/apps-switch.tsx
index f580ac717d..feb88354e6 100644
--- a/libs/core/core/components/apps-switch.tsx
+++ b/libs/core/core/components/apps-switch.tsx
@@ -6,7 +6,6 @@
import React from "react"
import { Mode } from "Core/__deprecated__/common/enums/mode.enum"
import ErrorApp from "Core/core/components/apps/error-app.component"
-import HelpApp from "Core/core/components/apps/help-app.component"
import LicenseApp from "Core/core/components/apps/license-app.component"
import TermsOfServiceApp from "Core/core/components/apps/terms-of-service-app.component"
import PrivacyPolicyApp from "Core/core/components/apps/privacy-policy-app.component"
@@ -19,8 +18,6 @@ const AppsSwitch = () => {
switch (mode) {
case Mode.ServerError:
return
- case Mode.Help:
- return
case Mode.License:
return
case Mode.TermsOfService:
diff --git a/libs/core/core/components/apps/base-app/base-app-container.component.tsx b/libs/core/core/components/apps/base-app/base-app-container.component.tsx
index 80e739aeda..e03fb55894 100644
--- a/libs/core/core/components/apps/base-app/base-app-container.component.tsx
+++ b/libs/core/core/components/apps/base-app/base-app-container.component.tsx
@@ -11,10 +11,12 @@ import BaseRoutes from "Core/core/components/apps/base-app/base-app-routes"
import BaseApp from "Core/core/components/apps/base-app/base-app.component"
import { RoutesHistoryProvider } from "shared/utils"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
+import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
import { ApiDeviceModals } from "generic-view/feature"
const BaseAppContainer: FunctionComponent = () => {
useAltLinkDownloadPreventer()
+ useBackForwardButtonPreventer()
return (
diff --git a/libs/core/core/components/apps/base-app/base-app-routes.tsx b/libs/core/core/components/apps/base-app/base-app-routes.tsx
index 890c298948..6ffa8f0216 100644
--- a/libs/core/core/components/apps/base-app/base-app-routes.tsx
+++ b/libs/core/core/components/apps/base-app/base-app-routes.tsx
@@ -30,9 +30,14 @@ import ConfiguredDevicesDiscovery from "Core/discovery-device/components/configu
import DevicesInitialization from "Core/device-initialization/components/devices-initialization.component"
import AvailableDeviceListContainer from "Core/discovery-device/components/available-device-list.container"
import DeviceConnecting from "Core/discovery-device/components/device-connecting.component"
-import { GenericView } from "generic-view/feature"
-import { APIConnectionDemo, DataMigrationPage } from "generic-view/ui"
import ManageSounds from "Core/files-manager/components/manage-sounds.component"
+import { GenericView } from "generic-view/feature"
+import {
+ APIConnectionDemo,
+ DataMigrationPage,
+ RecoveryModePage,
+} from "generic-view/ui"
+import { ArticlePage, HelpPage } from "help/ui"
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -58,8 +63,14 @@ export default () => (
-
-
+
+
(
component={DeviceConnecting}
exact
/>
+
+
+
+
+
(
-
+
(
+ ,
+ ,
+
+
diff --git a/libs/core/core/components/apps/base-app/base-app.component.tsx b/libs/core/core/components/apps/base-app/base-app.component.tsx
index fab405da17..fefad0f7dc 100644
--- a/libs/core/core/components/apps/base-app/base-app.component.tsx
+++ b/libs/core/core/components/apps/base-app/base-app.component.tsx
@@ -20,10 +20,12 @@ import { useRouterListener } from "Core/core/hooks"
import {
OutboxWrapper,
useAPISerialPortListeners,
- useBackupList,
useAppEventsListeners,
+ useBackupList,
} from "generic-view/store"
-import { useOnlineListener } from "shared/app-state"
+import { useFileDialogEventListener, useOnlineListener } from "shared/app-state"
+import { useCoreDeviceProtocolListeners } from "core-device/feature"
+import { useHelp } from "help/store"
const BaseApp: FunctionComponent = () => {
useRouterListener()
@@ -36,10 +38,13 @@ const BaseApp: FunctionComponent = () => {
useWatchOutboxEntriesEffect()
useWatchUnlockStatus()
useDiscoveryRedirectEffect()
+ useCoreDeviceProtocolListeners()
// API
useAPISerialPortListeners()
useAppEventsListeners()
useBackupList()
+ useFileDialogEventListener()
+ useHelp()
return (
<>
diff --git a/libs/core/core/components/apps/help-app.component.tsx b/libs/core/core/components/apps/help-app.component.tsx
deleted file mode 100644
index a5b120c103..0000000000
--- a/libs/core/core/components/apps/help-app.component.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import React, { useEffect, useState } from "react"
-import { Route, Router, Switch } from "react-router"
-import { ipcRenderer } from "electron-better-ipc"
-import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
-import history from "Core/core/history"
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-import Help from "Core/help/help.container"
-import { renderAnswer } from "Core/help/helpers/render-answer"
-import { useHelpSearch } from "Core/__deprecated__/renderer/utils/hooks/use-help-search/use-help-search"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
-import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
-
-const saveToStore = async (normalizeData: QuestionAndAnswer) =>
- await ipcRenderer.callMain(HelpActions.SetStoreValue, normalizeData)
-const getStoreData = async (key?: string) =>
- await ipcRenderer.callMain(HelpActions.GetStore, key)
-
-const HelpApp: FunctionComponent = () => {
- useAltLinkDownloadPreventer()
-
- const { data, searchQuestion } = useHelpSearch(saveToStore, getStoreData)
- const [searchInputValue, setSearchInputValue] = useState("")
- useEffect(() => {
- searchQuestion(searchInputValue)
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [searchInputValue])
-
- return (
-
-
- renderAnswer(data, props)}
- />
-
-
-
-
-
- )
-}
-
-export default HelpApp
diff --git a/libs/core/core/components/apps/license-app.component.tsx b/libs/core/core/components/apps/license-app.component.tsx
index 4f1fbd463e..449619920f 100644
--- a/libs/core/core/components/apps/license-app.component.tsx
+++ b/libs/core/core/components/apps/license-app.component.tsx
@@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { LicenseUI } from "Core/settings/components/license/license-ui.component"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
+import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
const LicenseApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
+ useBackForwardButtonPreventer()
return (
diff --git a/libs/core/core/components/apps/privacy-policy-app.component.tsx b/libs/core/core/components/apps/privacy-policy-app.component.tsx
index 57a964e9bc..eaa95350ee 100644
--- a/libs/core/core/components/apps/privacy-policy-app.component.tsx
+++ b/libs/core/core/components/apps/privacy-policy-app.component.tsx
@@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { PrivacyPolicyUI } from "Core/settings/components"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
+import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
const PrivacyPolicyApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
+ useBackForwardButtonPreventer()
return (
diff --git a/libs/core/core/components/apps/sar-app.component.tsx b/libs/core/core/components/apps/sar-app.component.tsx
index 256ce72796..5522740987 100644
--- a/libs/core/core/components/apps/sar-app.component.tsx
+++ b/libs/core/core/components/apps/sar-app.component.tsx
@@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_OVERVIEW } from "Core/__deprecated__/renderer/constants/urls"
import SarComponent from "Core/overview/components/pure-system/sar.component"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
+import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
const SarApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
+ useBackForwardButtonPreventer()
return (
diff --git a/libs/core/core/components/apps/terms-of-service-app.component.tsx b/libs/core/core/components/apps/terms-of-service-app.component.tsx
index aa8847b221..66e4be127c 100644
--- a/libs/core/core/components/apps/terms-of-service-app.component.tsx
+++ b/libs/core/core/components/apps/terms-of-service-app.component.tsx
@@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { TermsOfServiceUI } from "Core/settings/components"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
+import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
const TermsOfServiceApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
+ useBackForwardButtonPreventer()
return (
diff --git a/libs/core/core/components/use-back-forward-button-preventer.hook.tsx b/libs/core/core/components/use-back-forward-button-preventer.hook.tsx
new file mode 100644
index 0000000000..546e0e9ee8
--- /dev/null
+++ b/libs/core/core/components/use-back-forward-button-preventer.hook.tsx
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { useCallback, useEffect } from "react"
+
+const useBackForwardButtonPreventer = () => {
+ const handleMouseUp = useCallback((event: MouseEvent) => {
+ if (event.button === 3 || event.button === 4) {
+ event.preventDefault()
+ }
+ }, [])
+
+ useEffect(() => {
+ document.addEventListener("mouseup", handleMouseUp)
+ return () => document.removeEventListener("mouseup", handleMouseUp)
+ }, [handleMouseUp])
+}
+
+export default useBackForwardButtonPreventer
diff --git a/libs/core/core/hooks/use-device-connect-failed-effect.ts b/libs/core/core/hooks/use-device-connect-failed-effect.ts
index 0ead8929d2..c2223b950b 100644
--- a/libs/core/core/hooks/use-device-connect-failed-effect.ts
+++ b/libs/core/core/hooks/use-device-connect-failed-effect.ts
@@ -5,23 +5,19 @@
import { useEffect, useCallback } from "react"
import { useHistory } from "react-router-dom"
-import { useDispatch, useSelector } from "react-redux"
-import { answerMain, DeviceManagerMainEvent } from "shared/utils"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { addDevice } from "Core/device-manager/actions/base.action"
-import { Dispatch } from "Core/__deprecated__/renderer/store"
+import { useSelector } from "react-redux"
+import { answerMain } from "shared/utils"
+import { DeviceProtocolMainEvent } from "device-protocol/models"
+import { DeviceBaseProperties } from "device-protocol/models"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
import { URL_DISCOVERY_DEVICE } from "Core/__deprecated__/renderer/constants/urls"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { isDiscoveryDeviceInProgress } from "Core/discovery-device/selectors/is-discovery-device-in-progress.selector"
import { isInitializationDeviceInProgress } from "Core/device-initialization/selectors/is-initialization-device-in-progress.selector"
import { isInitializationAppInProgress } from "Core/app-initialization/selectors/is-initialization-app-in-progress.selector"
-import { DeviceState } from "Core/device-manager/reducers/device-manager.interface"
-import { getDeviceConfigurationRequest } from "Core/device-manager/requests/get-device-configuration.request"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
export const useDeviceConnectFailedEffect = () => {
const history = useHistory()
- const dispatch = useDispatch()
const activeDeviceProcessing = useSelector(isActiveDeviceProcessingSelector)
const activeDeviceId = useSelector(activeDeviceIdSelector)
const discoveryDeviceInProgress = useSelector(isDiscoveryDeviceInProgress)
@@ -44,31 +40,21 @@ export const useDeviceConnectFailedEffect = () => {
activeDeviceProcessing,
])
- const handleDeviceConnectFailed = useCallback(
- async (properties: DeviceBaseProperties) => {
- const result = await getDeviceConfigurationRequest(properties.id)
- const caseColour = result.ok ? result.data.caseColour : undefined
+ const handleDeviceConnectFailed = useCallback(async () => {
+ if (activeDeviceId) {
+ return
+ }
- dispatch(
- addDevice({ ...properties, caseColour, state: DeviceState.Failed })
- )
+ if (shouldSkipProcessing()) {
+ return
+ }
- if (activeDeviceId) {
- return
- }
-
- if (shouldSkipProcessing()) {
- return
- }
-
- history.push(URL_DISCOVERY_DEVICE.root)
- },
- [dispatch, activeDeviceId, shouldSkipProcessing, history]
- )
+ history.push(URL_DISCOVERY_DEVICE.root)
+ }, [activeDeviceId, shouldSkipProcessing, history])
useEffect(() => {
return answerMain(
- DeviceManagerMainEvent.DeviceConnectFailed,
+ DeviceProtocolMainEvent.DeviceConnectFailed,
handleDeviceConnectFailed
)
}, [handleDeviceConnectFailed])
diff --git a/libs/core/core/hooks/use-device-connected-effect.ts b/libs/core/core/hooks/use-device-connected-effect.ts
index 72d19d4bde..abe348833f 100644
--- a/libs/core/core/hooks/use-device-connected-effect.ts
+++ b/libs/core/core/hooks/use-device-connected-effect.ts
@@ -6,13 +6,25 @@
import { useCallback, useEffect } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
-import { answerMain, DeviceManagerMainEvent } from "shared/utils"
-import { Dispatch } from "Core/__deprecated__/renderer/store"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
-import { addDevice } from "Core/device-manager/actions/base.action"
-import { setActiveDevice } from "Core/device-manager/actions/set-active-device.action"
+import { answerMain } from "shared/utils"
+import {
+ deactivateDevice,
+ getDevicesSelector,
+ isActiveApiDeviceLockedSelector,
+} from "device-manager/feature"
+import {
+ setActiveDevice,
+ activeDeviceIdSelector,
+} from "active-device-registry/feature"
+import { getDeviceConfigurationRequest } from "core-device/feature"
+import {
+ DeviceProtocolMainEvent,
+ DeviceType,
+ DeviceBaseProperties,
+} from "device-protocol/models"
+import { selectDialogOpenState } from "shared/app-state"
+import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface"
import {
@@ -22,29 +34,31 @@ import {
} from "Core/__deprecated__/renderer/constants/urls"
import { isInitializationDeviceInProgress } from "Core/device-initialization/selectors/is-initialization-device-in-progress.selector"
import { isInitializationAppInProgress } from "Core/app-initialization/selectors/is-initialization-app-in-progress.selector"
-import { configureDevice } from "Core/device-manager/actions/configure-device.action"
-import { DeviceType } from "Core/device"
import { getTmpMuditaHarmonyPortInfoSelector } from "Core/update/selectors/get-tmp-mudita-harmony-port-info-selector"
import { isUnknownSerialNumber } from "Core/device/constants/unknown-serial-number.constant"
-import { getDeviceConfigurationRequest } from "Core/device-manager/requests/get-device-configuration.request"
import { getDiscoveryStatus } from "Core/discovery-device/selectors/get-discovery-status.selector"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
import { checkIsAnyModalPresent } from "Core/utils/check-is-any-other-modal-present"
-import { selectDialogOpenState } from "shared/app-state"
export const useDeviceConnectedEffect = () => {
const history = useHistory()
const dispatch = useDispatch()
const activeDeviceId = useSelector(activeDeviceIdSelector)
+ const activeApiDeviceLocked = useSelector((state: ReduxRootState) =>
+ activeDeviceId
+ ? isActiveApiDeviceLockedSelector(state, activeDeviceId)
+ : false
+ )
const shouldDiscoverySkipOnConnect = useDiscoverySkipOnConnect()
const continueProcess = useContinueProcess()
useEffect(() => {
const handler = async (properties: DeviceBaseProperties) => {
- dispatch(addDevice(properties))
- dispatch(configureDevice(properties.id))
+ if (activeApiDeviceLocked) {
+ await dispatch(deactivateDevice())
+ dispatch(setDiscoveryStatus(DiscoveryStatus.Aborted))
+ }
if (activeDeviceId) {
await continueProcess(properties)
@@ -57,7 +71,7 @@ export const useDeviceConnectedEffect = () => {
}
return answerMain(
- DeviceManagerMainEvent.DeviceConnected,
+ DeviceProtocolMainEvent.DeviceConnected,
handler
)
}, [
@@ -66,6 +80,7 @@ export const useDeviceConnectedEffect = () => {
activeDeviceId,
continueProcess,
shouldDiscoverySkipOnConnect,
+ activeApiDeviceLocked,
])
}
diff --git a/libs/core/core/hooks/use-device-detached-effect.ts b/libs/core/core/hooks/use-device-detached-effect.ts
index 690c4b318c..f217180fc8 100644
--- a/libs/core/core/hooks/use-device-detached-effect.ts
+++ b/libs/core/core/hooks/use-device-detached-effect.ts
@@ -6,23 +6,22 @@
import { useCallback, useEffect } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
-import { answerMain, DeviceManagerMainEvent } from "shared/utils"
+import { answerMain, useDebouncedEventsHandler } from "shared/utils"
+import { DeviceBaseProperties } from "device-protocol/models"
+import { getDevicesSelector } from "device-manager/feature"
+import { selectDialogOpenState } from "shared/app-state"
+import { DeviceProtocolMainEvent } from "device-protocol/models"
import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
+import { deactivateDevice } from "device-manager/feature"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import modalService from "Core/__deprecated__/renderer/components/core/modal/modal.service"
-import { removeDevice } from "Core/device-manager/actions/base.action"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
-import { deactivateDevice } from "Core/device-manager/actions/deactivate-device.action"
import { cancelOsDownload } from "Core/update/requests"
import {
URL_DISCOVERY_DEVICE,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
import { useDeactivateDeviceAndRedirect } from "Core/overview/components/overview-screens/pure-overview/use-deactivate-device-and-redirect.hook"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
-import { useDebouncedEventsHandler } from "Core/core/hooks/use-debounced-events-handler"
-import { selectDialogOpenState } from "shared/app-state"
import { closeContactSupportFlow } from "Core/contact-support"
export const useDeviceDetachedEffect = () => {
@@ -33,7 +32,7 @@ export const useDeviceDetachedEffect = () => {
useEffect(() => {
return answerMain(
- DeviceManagerMainEvent.DeviceDetached,
+ DeviceProtocolMainEvent.DeviceDetached,
batchDeviceDetachedEvents
)
}, [batchDeviceDetachedEvents])
@@ -46,14 +45,10 @@ const useHandleDevicesDetached = () => {
return useCallback(
async (deviceDetachedEvents: DeviceBaseProperties[]) => {
- for (const event of deviceDetachedEvents) {
- dispatch(removeDevice(event))
- }
-
await processActiveDevicesDetachment(deviceDetachedEvents)
processSingleDeviceRemaining(deviceDetachedEvents)
},
- [dispatch, processActiveDevicesDetachment, processSingleDeviceRemaining]
+ [processActiveDevicesDetachment, processSingleDeviceRemaining]
)
}
diff --git a/libs/core/core/hooks/use-device-locked-effect.ts b/libs/core/core/hooks/use-device-locked-effect.ts
index 27032c949a..01758bc4c0 100644
--- a/libs/core/core/hooks/use-device-locked-effect.ts
+++ b/libs/core/core/hooks/use-device-locked-effect.ts
@@ -12,8 +12,8 @@ import { getDeviceInitializationStatus } from "Core/device-initialization/select
import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
import { deviceUnlockedStatusSelector } from "Core/device/selectors/device-unlocked-status.selector"
import { URL_DEVICE_INITIALIZATION } from "Core/__deprecated__/renderer/constants/urls"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { getActiveDevice } from "device-manager/feature"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { PureStrategyMainEvent } from "Core/device/strategies"
export const useDeviceLockedEffect = () => {
diff --git a/libs/core/core/hooks/use-discovery-redirect-effect.ts b/libs/core/core/hooks/use-discovery-redirect-effect.ts
index 5710c2a401..bf2616a437 100644
--- a/libs/core/core/hooks/use-discovery-redirect-effect.ts
+++ b/libs/core/core/hooks/use-discovery-redirect-effect.ts
@@ -6,8 +6,8 @@
import { useEffect, useRef } from "react"
import { useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
-import { isDeviceListEmpty } from "Core/device-manager/selectors/is-device-list-empty.selector"
-import { isActiveDeviceSet } from "Core/device-manager/selectors/is-active-device-set.selector"
+import { isDeviceListEmpty } from "device-manager/feature"
+import { isActiveDeviceSet } from "active-device-registry/feature"
import { isDiscoveryDeviceInProgress } from "Core/discovery-device/selectors/is-discovery-device-in-progress.selector"
import { isInitializationDeviceInProgress } from "Core/device-initialization/selectors/is-initialization-device-in-progress.selector"
import { URL_DISCOVERY_DEVICE } from "Core/__deprecated__/renderer/constants/urls"
diff --git a/libs/core/core/hooks/use-watch-outbox-entries-effect.ts b/libs/core/core/hooks/use-watch-outbox-entries-effect.ts
index 00ca5b10fc..05874cb895 100644
--- a/libs/core/core/hooks/use-watch-outbox-entries-effect.ts
+++ b/libs/core/core/hooks/use-watch-outbox-entries-effect.ts
@@ -17,8 +17,8 @@ import {
NotificationMethod,
NotificationType,
} from "Core/notification/constants"
-import { getActiveDeviceTypeSelector } from "Core/device-manager/selectors/get-active-device-type.selector"
-import { DeviceType } from "Core/device"
+import { getActiveDeviceTypeSelector } from "device-manager/feature"
+import { DeviceType } from "device-protocol/models"
const outboxIntervalTime = 10000
diff --git a/libs/core/core/hooks/use-watch-unlock-status-effect.ts b/libs/core/core/hooks/use-watch-unlock-status-effect.ts
index 259cbff0fc..5e6f761400 100644
--- a/libs/core/core/hooks/use-watch-unlock-status-effect.ts
+++ b/libs/core/core/hooks/use-watch-unlock-status-effect.ts
@@ -8,10 +8,10 @@ import { useDispatch, useSelector } from "react-redux"
import { getDeviceInitializationStatus } from "Core/device-initialization/selectors/get-device-initialization-status.selector"
import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
import { Dispatch } from "Core/__deprecated__/renderer/store"
-import { getActiveDeviceTypeSelector } from "Core/device-manager/selectors/get-active-device-type.selector"
+import { getActiveDeviceTypeSelector } from "device-manager/feature"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { getUnlockStatus } from "Core/device/actions/get-unlock-status.action"
-import { DeviceType } from "Core/device/constants"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { DeviceType } from "device-protocol/models"
const unlockStatusIntervalTime = 10000
diff --git a/libs/core/core/module/base.module.ts b/libs/core/core/module/base.module.ts
index 9ab416ee3f..66ff19c96b 100644
--- a/libs/core/core/module/base.module.ts
+++ b/libs/core/core/module/base.module.ts
@@ -9,14 +9,15 @@ import { MetadataStore } from "Core/metadata/services"
import { AppLogger } from "Core/__deprecated__/main/utils/logger"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { IndexStorage } from "Core/index-storage/types"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import {
Controller,
+ Initializer,
Model,
- Repository,
Observer,
- Initializer,
+ Repository,
} from "Core/core/types"
+import { BrowserWindow } from "electron"
export class BaseModule {
public controllers: Controller[] = []
@@ -27,11 +28,12 @@ export class BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
public eventEmitter: EventEmitter,
- public fileSystem: FileSystemService
+ public fileSystem: FileSystemService,
+ public mainApplicationWindow?: BrowserWindow
) {}
}
diff --git a/libs/core/core/types/module.type.ts b/libs/core/core/types/module.type.ts
index d5f77a9e4d..3b1f821aa8 100644
--- a/libs/core/core/types/module.type.ts
+++ b/libs/core/core/types/module.type.ts
@@ -15,13 +15,13 @@ import { Model } from "./model.type"
import { Repository } from "./repository.type"
import { Observer } from "./observer.type"
import { Initializer } from "./initializer.type"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export interface Module {
// eslint-disable-next-line @typescript-eslint/no-misused-new
new (
index: IndexStorage,
- deviceManager: DeviceManager,
+ deviceProtocol: DeviceProtocol,
keyStorage: MetadataStore,
logger: AppLogger,
ipc: MainProcessIpc,
diff --git a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.component.tsx b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.component.tsx
index 807b3aa06d..7efb4ae134 100644
--- a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.component.tsx
+++ b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.component.tsx
@@ -5,7 +5,7 @@
import React from "react"
import { defineMessages } from "react-intl"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { ModalDialog, ModalDialogProps } from "Core/ui/components/modal-dialog"
diff --git a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.stories.tsx b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.stories.tsx
index ef38368a02..c65f87a620 100644
--- a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.stories.tsx
+++ b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.stories.tsx
@@ -6,7 +6,7 @@
import React from "react"
import { storiesOf } from "@storybook/react"
import { action } from "@storybook/addon-actions"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { CrashDumpModal } from "Core/crash-dump/components/crash-dump-modal/crash-dump-modal.component"
storiesOf("Crash Dump/Modals", module).add("Information", () => (
diff --git a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.test.tsx b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.test.tsx
index 998ec8f4bb..9d72340fd4 100644
--- a/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.test.tsx
+++ b/libs/core/crash-dump/components/crash-dump-modal/crash-dump-modal.test.tsx
@@ -5,7 +5,7 @@
import React from "react"
import { waitFor } from "@testing-library/dom"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { screen, fireEvent } from "@testing-library/dom"
import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
import {
diff --git a/libs/core/crash-dump/components/crash-dump/crash-dump.component.test.tsx b/libs/core/crash-dump/components/crash-dump/crash-dump.component.test.tsx
index 5830bf751e..dc9bb60e79 100644
--- a/libs/core/crash-dump/components/crash-dump/crash-dump.component.test.tsx
+++ b/libs/core/crash-dump/components/crash-dump/crash-dump.component.test.tsx
@@ -9,7 +9,7 @@ import { Provider } from "react-redux"
import createMockStore from "redux-mock-store"
import thunk from "redux-thunk"
import { screen, fireEvent } from "@testing-library/dom"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { State } from "Core/core/constants"
import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
import { CrashDump } from "Core/crash-dump/components/crash-dump/crash-dump.component"
diff --git a/libs/core/crash-dump/components/crash-dump/crash-dump.interface.ts b/libs/core/crash-dump/components/crash-dump/crash-dump.interface.ts
index 68c6889f3c..c609ff43fd 100644
--- a/libs/core/crash-dump/components/crash-dump/crash-dump.interface.ts
+++ b/libs/core/crash-dump/components/crash-dump/crash-dump.interface.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { CrashDump } from "Core/crash-dump/dto"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
diff --git a/libs/core/crash-dump/crash-dump.module.ts b/libs/core/crash-dump/crash-dump.module.ts
index 315bba2c11..9326484a40 100644
--- a/libs/core/crash-dump/crash-dump.module.ts
+++ b/libs/core/crash-dump/crash-dump.module.ts
@@ -14,7 +14,7 @@ import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { CrashDumpController } from "Core/crash-dump/controllers"
import { CrashDumpService } from "Core/crash-dump/services"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class CrashDumpModule extends BaseModule {
private crashDumpController: CrashDumpController
@@ -22,7 +22,7 @@ export class CrashDumpModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -31,7 +31,7 @@ export class CrashDumpModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -46,8 +46,8 @@ export class CrashDumpModule extends BaseModule {
}
this.crashDumpService = new CrashDumpService(
- this.deviceManager,
- new DeviceFileSystemService(this.deviceManager)
+ this.deviceProtocol,
+ new DeviceFileSystemService(this.deviceProtocol)
)
this.crashDumpController = new CrashDumpController(
this.crashDumpService,
diff --git a/libs/core/crash-dump/services/crash-dump.service.test.ts b/libs/core/crash-dump/services/crash-dump.service.test.ts
index 92ae4625a7..78591f2a8a 100644
--- a/libs/core/crash-dump/services/crash-dump.service.test.ts
+++ b/libs/core/crash-dump/services/crash-dump.service.test.ts
@@ -5,23 +5,23 @@
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { DeviceCommunicationError } from "Core/device/constants"
-import { DeviceManager } from "Core/device-manager/services/device-manager.service"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
import { CrashDumpService } from "Core/crash-dump/services/crash-dump.service"
import { DeviceFileSystemService } from "Core/device-file-system/services"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const deviceFileSystemMock = {
downloadDeviceFilesLocally: jest.fn(),
} as unknown as DeviceFileSystemService
-const subject = new CrashDumpService(deviceManager, deviceFileSystemMock)
+const subject = new CrashDumpService(deviceProtocol, deviceFileSystemMock)
afterEach(() => {
jest.resetAllMocks()
@@ -29,7 +29,7 @@ afterEach(() => {
describe("Method: getDeviceCrashDumpFiles", () => {
test("returns list of files if `Endpoint.DeviceInfo` endpoint returns `success` and list of files", async () => {
- deviceManager.device.request = jest.fn().mockReturnValueOnce(
+ deviceProtocol.device.request = jest.fn().mockReturnValueOnce(
Result.success({
files: ["/sys/crash_dumps/crashdump.hex"],
})
@@ -37,35 +37,35 @@ describe("Method: getDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(await subject.getDeviceCrashDumpFiles()).toEqual({
data: ["/sys/crash_dumps/crashdump.hex"],
status: RequestResponseStatus.Ok,
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
})
test("returns empty list of files if if data key isn't exists", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValueOnce(Result.success(undefined))
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(await subject.getDeviceCrashDumpFiles()).toEqual({
data: [],
status: RequestResponseStatus.Ok,
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
})
test("returns an `Error` status if status isn't equal to `Ok`", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValueOnce(
Result.failed(
@@ -78,19 +78,19 @@ describe("Method: getDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(await subject.getDeviceCrashDumpFiles()).toEqual({
status: RequestResponseStatus.Error,
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
})
})
describe("Method: downloadDeviceCrashDumpFiles", () => {
test("returns local files urls if `downloadDeviceFilesLocally` returns `success` status and files list exists", async () => {
- deviceManager.device.request = jest.fn().mockReturnValueOnce(
+ deviceProtocol.device.request = jest.fn().mockReturnValueOnce(
Result.success({
files: ["/sys/crash_dumps/crashdump.hex"],
})
@@ -103,7 +103,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -117,7 +117,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -128,18 +128,16 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
})
test("returns an `success` status if `getDeviceFiles` returns empty data", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValueOnce(Result.success(undefined))
;(
deviceFileSystemMock.downloadDeviceFilesLocally as jest.Mock
- ).mockReturnValueOnce(
- Result.success([])
- )
+ ).mockReturnValueOnce(Result.success([]))
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -148,12 +146,12 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
expect(await subject.downloadDeviceCrashDumpFiles()).toEqual({
status: RequestResponseStatus.Ok,
- data: []
+ data: [],
})
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -162,13 +160,13 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
})
test("returns an `Error` status if `getDeviceFiles` returns `Error` status", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValueOnce(Result.failed({} as AppError))
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -181,7 +179,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -190,7 +188,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
})
test("returns an `Error` status if `downloadDeviceFilesLocally` returns empty data", async () => {
- deviceManager.device.request = jest.fn().mockReturnValueOnce(
+ deviceProtocol.device.request = jest.fn().mockReturnValueOnce(
Result.success({
files: ["/sys/crash_dumps/crashdump.hex"],
})
@@ -204,7 +202,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -217,7 +215,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -228,7 +226,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
})
test("returns an `Error` status if `downloadDeviceFilesLocally` returns `Error` status", async () => {
- deviceManager.device.request = jest.fn().mockReturnValueOnce(
+ deviceProtocol.device.request = jest.fn().mockReturnValueOnce(
Result.success({
files: ["/sys/crash_dumps/crashdump.hex"],
})
@@ -241,7 +239,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -254,7 +252,7 @@ describe("Method: downloadDeviceCrashDumpFiles", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
diff --git a/libs/core/crash-dump/services/crash-dump.service.ts b/libs/core/crash-dump/services/crash-dump.service.ts
index 3a486e4063..b1727d25bd 100644
--- a/libs/core/crash-dump/services/crash-dump.service.ts
+++ b/libs/core/crash-dump/services/crash-dump.service.ts
@@ -3,7 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DiagnosticsFileList, Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
+import { DiagnosticsFileList } from "Core/device/constants"
import { GetDeviceFilesResponseBody } from "Core/device/types/mudita-os"
import path from "path"
import { ResultObject } from "Core/core/builder"
@@ -13,11 +14,11 @@ import {
RequestResponse,
RequestResponseStatus,
} from "Core/core/types/request-response.interface"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class CrashDumpService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private deviceFileSystem: DeviceFileSystemService
) {}
@@ -86,7 +87,7 @@ export class CrashDumpService {
public async getDiagnosticFileList(
fileList: DiagnosticsFileList
): Promise> {
- return this.deviceManager.device.request({
+ return this.deviceProtocol.device.request({
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
body: { fileList },
diff --git a/libs/core/data-sync/actions/base-app.action.test.ts b/libs/core/data-sync/actions/base-app.action.test.ts
deleted file mode 100644
index adbc646d30..0000000000
--- a/libs/core/data-sync/actions/base-app.action.test.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import createMockStore from "redux-mock-store"
-import thunk from "redux-thunk"
-import { DataSyncEvent } from "Core/data-sync/constants"
-import { setDataSyncInitState } from "Core/data-sync/actions/base-app.action"
-
-const mockStore = createMockStore([thunk])()
-
-afterEach(() => {
- mockStore.clearActions()
-})
-
-describe("Action: SetDataSyncInitState", () => {
- test("fire action without payload and `SetDataSyncInitState` type", () => {
- mockStore.dispatch(setDataSyncInitState())
- expect(mockStore.getActions()).toEqual([
- {
- type: DataSyncEvent.SetDataSyncInitState,
- payload: undefined,
- },
- ])
- })
-})
diff --git a/libs/core/data-sync/actions/base-app.action.ts b/libs/core/data-sync/actions/base-app.action.ts
index 521e684846..70f01379b7 100644
--- a/libs/core/data-sync/actions/base-app.action.ts
+++ b/libs/core/data-sync/actions/base-app.action.ts
@@ -7,9 +7,6 @@ import { createAction } from "@reduxjs/toolkit"
import { DataSyncEvent } from "Core/data-sync/constants"
import { SynchronizationStatus } from "Core/data-sync/reducers"
-export const setDataSyncInitState = createAction(
- DataSyncEvent.SetDataSyncInitState
-)
export const setDataSyncSetStatus = createAction(
DataSyncEvent.SetDataSyncSetStatus
)
diff --git a/libs/core/data-sync/constants/event.enum.ts b/libs/core/data-sync/constants/event.enum.ts
index 240807a107..cc6ab8ac18 100644
--- a/libs/core/data-sync/constants/event.enum.ts
+++ b/libs/core/data-sync/constants/event.enum.ts
@@ -4,9 +4,7 @@
*/
export enum DataSyncEvent {
- SetDataSyncInitState = "DATA_SYNC_SET_INIT_STATE",
SetDataSyncSetStatus = "DATA_SYNC_SET_STATUS",
-
ReadAllIndexes = "DATA_SYNC_READ_ALL_INDEXES",
UpdateAllIndexes = "DATA_SYNC_UPDATE_ALL_INDEXES",
}
diff --git a/libs/core/data-sync/controllers/data-sync.controller.ts b/libs/core/data-sync/controllers/data-sync.controller.ts
index 249da67633..025393bb2d 100644
--- a/libs/core/data-sync/controllers/data-sync.controller.ts
+++ b/libs/core/data-sync/controllers/data-sync.controller.ts
@@ -7,7 +7,7 @@ import { SerialisedIndexData } from "elasticlunr"
import { IpcEvent } from "Core/core/decorators"
import { IndexStorage } from "Core/index-storage/types"
import { DataSyncService } from "Core/data-sync/services/data-sync.service"
-import { IpcDataSyncEvent, DataIndex } from "Core/data-sync/constants"
+import { DataIndex, IpcDataSyncEvent } from "Core/data-sync/constants"
import { InitializeOptions } from "Core/data-sync/types"
export class DataSyncController {
diff --git a/libs/core/data-sync/data-sync.module.ts b/libs/core/data-sync/data-sync.module.ts
index 1c3062ca64..71a81a6e0e 100644
--- a/libs/core/data-sync/data-sync.module.ts
+++ b/libs/core/data-sync/data-sync.module.ts
@@ -12,7 +12,7 @@ import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { DataSyncService } from "Core/data-sync/services/data-sync.service"
import { DataSyncController } from "Core/data-sync/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DataSyncModule extends BaseModule {
private dataSyncService: DataSyncService
@@ -20,7 +20,7 @@ export class DataSyncModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -29,7 +29,7 @@ export class DataSyncModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -39,7 +39,7 @@ export class DataSyncModule extends BaseModule {
this.dataSyncService = new DataSyncService(
this.index,
- this.deviceManager,
+ this.deviceProtocol,
this.keyStorage,
this.fileSystem
)
diff --git a/libs/core/data-sync/reducers/data-sync.reducer.ts b/libs/core/data-sync/reducers/data-sync.reducer.ts
index 886799ea3a..7939747cb1 100644
--- a/libs/core/data-sync/reducers/data-sync.reducer.ts
+++ b/libs/core/data-sync/reducers/data-sync.reducer.ts
@@ -3,17 +3,15 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import {
DataSyncState,
SynchronizationStatus,
} from "Core/data-sync/reducers/data-sync.interface"
-import { createReducer } from "@reduxjs/toolkit"
-import {
- setDataSyncInitState,
- setDataSyncSetStatus,
- updateAllIndexes,
-} from "Core/data-sync/actions"
+import { setDataSyncSetStatus, updateAllIndexes } from "Core/data-sync/actions"
import { AppError } from "Core/core/errors"
+import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
export const initialState: DataSyncState = {
status: SynchronizationStatus.Empty,
@@ -24,7 +22,7 @@ export const dataSyncReducer = createReducer(
initialState,
(builder) => {
builder
- .addCase(setDataSyncInitState, () => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return {
...initialState,
}
diff --git a/libs/core/data-sync/services/data-sync.service.ts b/libs/core/data-sync/services/data-sync.service.ts
index 27df3cbfdf..d3008cca10 100644
--- a/libs/core/data-sync/services/data-sync.service.ts
+++ b/libs/core/data-sync/services/data-sync.service.ts
@@ -8,7 +8,7 @@ import { DeviceFileSystemService } from "Core/device-file-system/services"
import getAppPath from "Core/__deprecated__/main/utils/get-app-path"
import { IndexStorage } from "Core/index-storage/types"
import { DataIndex } from "Core/index-storage/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { MetadataStore } from "Core/metadata/services"
import {
ContactIndexer,
@@ -35,13 +35,13 @@ export class DataSyncService {
constructor(
private index: IndexStorage,
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private keyStorage: MetadataStore,
private fileSystemStorage: FileSystemService
) {
this.syncBackupCreateService = new SyncBackupCreateService(
- this.deviceManager,
- new DeviceFileSystemService(this.deviceManager),
+ this.deviceProtocol,
+ new DeviceFileSystemService(this.deviceProtocol),
this.keyStorage
)
diff --git a/libs/core/desktop/desktop.module.ts b/libs/core/desktop/desktop.module.ts
index 7fd5ac6d2b..a03b0c98a9 100644
--- a/libs/core/desktop/desktop.module.ts
+++ b/libs/core/desktop/desktop.module.ts
@@ -10,14 +10,14 @@ import { FileSystemService } from "Core/file-system/services/file-system.service
import { AppLogger } from "Core/__deprecated__/main/utils/logger"
import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DesktopController } from "Core/desktop/desktop.controller"
import { DesktopService } from "Core/desktop/desktop.service"
export class DesktopModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -26,7 +26,7 @@ export class DesktopModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
diff --git a/libs/core/device-file-system/commands/base.command.ts b/libs/core/device-file-system/commands/base.command.ts
index bb86061bf2..f2b0fb0b15 100644
--- a/libs/core/device-file-system/commands/base.command.ts
+++ b/libs/core/device-file-system/commands/base.command.ts
@@ -4,10 +4,10 @@
*/
import * as CRC32 from "crc-32"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export abstract class BaseCommand {
- constructor(public deviceManager: DeviceManager) {}
+ constructor(public deviceProtocol: DeviceProtocol) {}
public countCRC32(buffer: Buffer | Uint8Array): string {
const crc = CRC32.buf(buffer)
diff --git a/libs/core/device-file-system/commands/file-delete.command.test.ts b/libs/core/device-file-system/commands/file-delete.command.test.ts
index 5af1fa58e6..4053a43bda 100644
--- a/libs/core/device-file-system/commands/file-delete.command.test.ts
+++ b/libs/core/device-file-system/commands/file-delete.command.test.ts
@@ -3,24 +3,20 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- Endpoint,
- Method,
- DeviceCommunicationError,
-} from "Core/device/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
import { AppError } from "Core/core/errors"
import { Result, ResultObject, SuccessResult } from "Core/core/builder"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import { FileDeleteCommand } from "Core/device-file-system/commands/file-delete.command"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
-const subject = new FileDeleteCommand(deviceManager)
+const subject = new FileDeleteCommand(deviceProtocol)
const successResponse: ResultObject = Result.success(undefined)
@@ -41,7 +37,7 @@ beforeEach(() => {
describe("`FileDeleteCommand`", () => {
describe("when `DeviceManager.device.request` returns success response", () => {
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(successResponse)
})
@@ -51,7 +47,7 @@ describe("`FileDeleteCommand`", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Delete,
body: {
@@ -64,7 +60,9 @@ describe("`FileDeleteCommand`", () => {
describe("when `DeviceManager.device.request` returns failed response", () => {
beforeEach(() => {
- deviceManager.device.request = jest.fn().mockResolvedValue(failedResponse)
+ deviceProtocol.device.request = jest
+ .fn()
+ .mockResolvedValue(failedResponse)
})
test("returns `ResultObject.failed`", async () => {
@@ -72,7 +70,7 @@ describe("`FileDeleteCommand`", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Delete,
body: {
diff --git a/libs/core/device-file-system/commands/file-delete.command.ts b/libs/core/device-file-system/commands/file-delete.command.ts
index cab6196abd..7f4af75284 100644
--- a/libs/core/device-file-system/commands/file-delete.command.ts
+++ b/libs/core/device-file-system/commands/file-delete.command.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import { AppError } from "Core/core/errors"
import { Result, ResultObject } from "Core/core/builder"
import { BaseCommand } from "Core/device-file-system/commands/base.command"
@@ -14,7 +14,7 @@ import { DeviceFileSystemError } from "Core/device-file-system/constants"
export class FileDeleteCommand extends BaseCommand {
public async exec(path: string): Promise> {
const { ok, error } =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Delete,
body: {
diff --git a/libs/core/device-file-system/commands/file-upload.command.test.ts b/libs/core/device-file-system/commands/file-upload.command.test.ts
index 061f735e1e..cb31963d20 100644
--- a/libs/core/device-file-system/commands/file-upload.command.test.ts
+++ b/libs/core/device-file-system/commands/file-upload.command.test.ts
@@ -6,31 +6,27 @@
import fs from "fs"
import path from "path"
import mock from "mock-fs"
-import {
- Endpoint,
- Method,
- DeviceCommunicationError,
-} from "Core/device/constants"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
import { FileUploadCommand } from "Core/device-file-system/commands/file-upload.command"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { AppError } from "Core/core/errors"
import { Result, ResultObject } from "Core/core/builder"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import { DeviceFileSystemError } from "Core/device-file-system/constants"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const fileSystemService = {
readFile: jest.fn(),
getFileSize: jest.fn(),
} as unknown as FileSystemService
-const subject = new FileUploadCommand(deviceManager, fileSystemService)
+const subject = new FileUploadCommand(deviceProtocol, fileSystemService)
const successResponse: ResultObject<{
txID: string
@@ -92,7 +88,7 @@ describe("When requested file is unreadable", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).not.toHaveBeenCalled()
+ expect(deviceProtocol.device.request).not.toHaveBeenCalled()
expect(result).toEqual(
Result.failed(
new AppError(
@@ -134,7 +130,7 @@ describe("When requested file is valid", () => {
mock.restore()
})
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(successResponse)
})
@@ -147,7 +143,7 @@ describe("When requested file is valid", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -173,7 +169,9 @@ describe("When requested file is valid", () => {
mock.restore()
})
beforeEach(() => {
- deviceManager.device.request = jest.fn().mockResolvedValue(failedResponse)
+ deviceProtocol.device.request = jest
+ .fn()
+ .mockResolvedValue(failedResponse)
})
test("returns `ResultObject.failed` with `DeviceFileSystemError.FileUploadRequest` type", async () => {
@@ -184,7 +182,7 @@ describe("When requested file is valid", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -217,7 +215,7 @@ describe("When requested file is valid", () => {
mock.restore()
})
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockImplementation(({ body }) => {
// AUTO DISABLED - fix me if you like :)
@@ -240,7 +238,7 @@ describe("When requested file is valid", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -273,7 +271,7 @@ describe("When requested file is valid", () => {
mock.restore()
})
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(failedResponseWithInsufficientStorage)
})
@@ -286,7 +284,7 @@ describe("When requested file is valid", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
diff --git a/libs/core/device-file-system/commands/file-upload.command.ts b/libs/core/device-file-system/commands/file-upload.command.ts
index 382442d259..a4cf81a7a1 100644
--- a/libs/core/device-file-system/commands/file-upload.command.ts
+++ b/libs/core/device-file-system/commands/file-upload.command.ts
@@ -4,9 +4,9 @@
*/
import path from "path"
-import { Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import { PutFileSystemResponseBody } from "Core/device/types/mudita-os"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { FileSystemService } from "Core/file-system/services/file-system.service.refactored"
import { AppError } from "Core/core/errors"
import { Result, ResultObject } from "Core/core/builder"
@@ -16,10 +16,10 @@ import { DeviceFileSystemError } from "Core/device-file-system/constants"
export class FileUploadCommand extends BaseCommand {
constructor(
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public fileSystemService: FileSystemService
) {
- super(deviceManager)
+ super(deviceProtocol)
}
public async exec(
@@ -53,7 +53,7 @@ export class FileUploadCommand extends BaseCommand {
const fileName = path.basename(filePath)
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -103,7 +103,7 @@ export class FileUploadCommand extends BaseCommand {
const chunkedBufferSize = Buffer.byteLength(chunkedBuffer)
const lastChunk = chunkedBufferSize < chunkSize
- const response = await this.deviceManager.device.request({
+ const response = await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
diff --git a/libs/core/device-file-system/commands/retrieve-files.command.test.ts b/libs/core/device-file-system/commands/retrieve-files.command.test.ts
index 8f1e58413c..74d1bf35d4 100644
--- a/libs/core/device-file-system/commands/retrieve-files.command.test.ts
+++ b/libs/core/device-file-system/commands/retrieve-files.command.test.ts
@@ -3,25 +3,21 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- Endpoint,
- Method,
- DeviceCommunicationError,
-} from "Core/device/constants"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
import { RetrieveFilesCommand } from "Core/device-file-system/commands/retrieve-files.command"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { AppError } from "Core/core/errors"
import { Result, ResultObject } from "Core/core/builder"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import { DeviceFileSystemError } from "Core/device-file-system/constants"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
-const subject = new RetrieveFilesCommand(deviceManager)
+const subject = new RetrieveFilesCommand(deviceProtocol)
const responseData: Record = {
["/test/directory"]: [
@@ -50,7 +46,7 @@ beforeEach(() => {
describe("When `DeviceManager.device.request` returns success response", () => {
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(successResponse)
})
@@ -60,7 +56,7 @@ describe("When `DeviceManager.device.request` returns success response", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Get,
body: {
@@ -73,7 +69,7 @@ describe("When `DeviceManager.device.request` returns success response", () => {
describe("When `DeviceManager.device.request` returns failed response", () => {
beforeEach(() => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(failedResponse)
})
@@ -83,7 +79,7 @@ describe("When `DeviceManager.device.request` returns failed response", () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.FileSystem,
method: Method.Get,
body: {
diff --git a/libs/core/device-file-system/commands/retrieve-files.command.ts b/libs/core/device-file-system/commands/retrieve-files.command.ts
index 4283c3f735..eb74f410e3 100644
--- a/libs/core/device-file-system/commands/retrieve-files.command.ts
+++ b/libs/core/device-file-system/commands/retrieve-files.command.ts
@@ -8,7 +8,7 @@ import { AppError } from "Core/core/errors"
import { BaseCommand } from "Core/device-file-system/commands/base.command"
import { DeviceFileSystemError } from "Core/device-file-system/constants"
import { DirectoryFile } from "Core/device-file-system/types"
-import { Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import { GetFileSystemDirectoryResponseBody } from "Core/device/types/mudita-os"
export class RetrieveFilesCommand extends BaseCommand {
@@ -16,7 +16,7 @@ export class RetrieveFilesCommand extends BaseCommand {
directory: string
): Promise | undefined>> {
const result =
- await this.deviceManager.device.request(
+ await this.deviceProtocol.device.request(
{
endpoint: Endpoint.FileSystem,
method: Method.Get,
diff --git a/libs/core/device-file-system/device-file-system.module.ts b/libs/core/device-file-system/device-file-system.module.ts
index 0ae2ec6abc..b828514abf 100644
--- a/libs/core/device-file-system/device-file-system.module.ts
+++ b/libs/core/device-file-system/device-file-system.module.ts
@@ -12,12 +12,12 @@ import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { DeviceFileSystemController } from "Core/device-file-system/controllers"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DeviceFileSystemModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -26,7 +26,7 @@ export class DeviceFileSystemModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -35,7 +35,7 @@ export class DeviceFileSystemModule extends BaseModule {
)
const deviceFileSystemService = new DeviceFileSystemService(
- this.deviceManager
+ this.deviceProtocol
)
const deviceFileSystemController = new DeviceFileSystemController(
deviceFileSystemService
diff --git a/libs/core/device-file-system/services/device-file-system.service.test.ts b/libs/core/device-file-system/services/device-file-system.service.test.ts
index 87a0cf83cf..79ccf0ba10 100644
--- a/libs/core/device-file-system/services/device-file-system.service.test.ts
+++ b/libs/core/device-file-system/services/device-file-system.service.test.ts
@@ -6,8 +6,8 @@
import path from "path"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { DeviceCommunicationError } from "Core/device/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
import {
DownloadFileSystemRequestConfig,
GetFileSystemRequestConfig,
@@ -22,21 +22,21 @@ import {
} from "Root/jest/testing-support/mocks/diagnostic-data.mock"
import { DeviceFileSystemService } from "Core/device-file-system/services/device-file-system.service"
-const deviceManager = {
+const deviceProtocol = {
request: jest.fn(),
device: {
id: "abc123",
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
-const deviceFileSystem = new DeviceFileSystemService(deviceManager)
+const deviceFileSystem = new DeviceFileSystemService(deviceProtocol)
beforeEach(() => {
jest.clearAllMocks()
})
test("downloading file handle properly chunks data", async () => {
- deviceManager.request = jest
+ deviceProtocol.request = jest
.fn()
.mockImplementation(
(
@@ -84,7 +84,7 @@ test("downloading file handle properly chunks data", async () => {
})
test("downloading file handle properly chunks data if fileSize is less than chunkSize", async () => {
- deviceManager.request = jest
+ deviceProtocol.request = jest
.fn()
.mockImplementation(
(
@@ -125,7 +125,7 @@ test("downloading file handle properly chunks data if fileSize is less than chun
})
test("downloading file return error when part of the chunks data is broken", async () => {
- deviceManager.request = jest
+ deviceProtocol.request = jest
.fn()
.mockImplementation(
(
@@ -169,7 +169,7 @@ test("downloading file return error when part of the chunks data is broken", asy
})
test("downloading file returns error properly", async () => {
- deviceManager.request = jest.fn().mockImplementation(() => {
+ deviceProtocol.request = jest.fn().mockImplementation(() => {
return Result.failed(
new AppError(
DeviceCommunicationError.RequestFailed,
@@ -185,7 +185,7 @@ test("downloading file returns error properly", async () => {
})
test("upload file file handle properly chunks data", async () => {
- deviceManager.request = jest
+ deviceProtocol.request = jest
.fn()
.mockImplementation(
(
diff --git a/libs/core/device-file-system/services/device-file-system.service.ts b/libs/core/device-file-system/services/device-file-system.service.ts
index 8397db836b..f72fedf7ef 100644
--- a/libs/core/device-file-system/services/device-file-system.service.ts
+++ b/libs/core/device-file-system/services/device-file-system.service.ts
@@ -8,8 +8,8 @@ import stream from "stream"
import path from "path"
import { AppError } from "Core/core/errors"
import { ResultObject, Result } from "Core/core/builder"
-import { Endpoint, Method } from "Core/device/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { Endpoint, Method } from "core-device/models"
+import { DeviceProtocol } from "device-protocol/feature"
import logger from "Core/__deprecated__/main/utils/logger"
import countCRC32 from "Core/device-file-system/helpers/count-crc32"
import { FileSystemService } from "Core/file-system/services/file-system.service"
@@ -27,12 +27,12 @@ import {
} from "Core/device-file-system/dto"
export class DeviceFileSystemService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
public async downloadDeviceFilesLocally(
filePaths: string[],
options: DownloadDeviceFileLocallyOptions,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
const data: string[] = []
@@ -61,7 +61,7 @@ export class DeviceFileSystemService {
public async downloadDeviceFiles(
filePaths: string[],
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
const data: DeviceFile[] = []
for (let i = 0; i < filePaths.length; i++) {
@@ -81,11 +81,11 @@ export class DeviceFileSystemService {
public async downloadFile(
filePath: string,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
try {
const { ok, data } =
- await this.deviceManager.request(deviceId, {
+ await this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.FileSystem,
method: Method.Get,
body: {
@@ -157,7 +157,7 @@ export class DeviceFileSystemService {
const fileSize = Buffer.byteLength(data)
const fileCrc32 = countCRC32(data)
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -190,7 +190,7 @@ export class DeviceFileSystemService {
const fileCrc32 = countCRC32(fileBuffer)
const { ok, data } =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -229,7 +229,7 @@ export class DeviceFileSystemService {
return Result.failed(new AppError("", ""))
}
- const { ok } = await this.deviceManager.device.request({
+ const { ok } = await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Delete,
body: {
@@ -247,7 +247,7 @@ export class DeviceFileSystemService {
private async downloadDeviceFileLocally(
filePath: string,
options: DownloadDeviceFileLocallyOptions,
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
const { data: result, ok } = await this.downloadFile(filePath, deviceId)
@@ -317,7 +317,7 @@ export class DeviceFileSystemService {
const chunkedBufferSize = Buffer.byteLength(chunkedBuffer)
const lastChunk = chunkedBufferSize < chunkSize
- const response = await this.deviceManager.device.request({
+ const response = await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -368,7 +368,7 @@ export class DeviceFileSystemService {
const lastChunk = nread < chunkSize
const dataBuffer = lastChunk ? buffer.slice(0, nread) : buffer
- const response = await this.deviceManager.device.request({
+ const response = await this.deviceProtocol.device.request({
endpoint: Endpoint.FileSystem,
method: Method.Put,
body: {
@@ -404,10 +404,10 @@ export class DeviceFileSystemService {
chunkLength: number,
chunkNo = 1,
chunkedString = "",
- deviceId = this.deviceManager.device.id
+ deviceId = this.deviceProtocol.device.id
): Promise> {
const { ok, data } =
- await this.deviceManager.request(
+ await this.deviceProtocol.request(
deviceId,
{
endpoint: Endpoint.FileSystem,
diff --git a/libs/core/device-info/device-info.module.ts b/libs/core/device-info/device-info.module.ts
index 31bc6fca26..abef8179a5 100644
--- a/libs/core/device-info/device-info.module.ts
+++ b/libs/core/device-info/device-info.module.ts
@@ -12,12 +12,12 @@ import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { DeviceInfoService } from "Core/device-info/services"
import { DeviceInfoController } from "Core/device-info/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DeviceInfoModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -26,7 +26,7 @@ export class DeviceInfoModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -34,7 +34,7 @@ export class DeviceInfoModule extends BaseModule {
fileSystem
)
- const deviceInfoService = new DeviceInfoService(this.deviceManager)
+ const deviceInfoService = new DeviceInfoService(this.deviceProtocol)
const deviceInfoController = new DeviceInfoController(deviceInfoService)
this.controllers = [deviceInfoController]
diff --git a/libs/core/device-info/dto/device-info.object.ts b/libs/core/device-info/dto/device-info.object.ts
index 7073921f31..ce327e985a 100644
--- a/libs/core/device-info/dto/device-info.object.ts
+++ b/libs/core/device-info/dto/device-info.object.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { CaseColour } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
// DEPRECATED
import { SimCard } from "Core/__deprecated__/renderer/models/basic-info/basic-info.typings"
diff --git a/libs/core/device-info/presenters/device-info.presenter.ts b/libs/core/device-info/presenters/device-info.presenter.ts
index 1fc5abc23b..91e47a9ddc 100644
--- a/libs/core/device-info/presenters/device-info.presenter.ts
+++ b/libs/core/device-info/presenters/device-info.presenter.ts
@@ -4,7 +4,8 @@
*/
import { DeviceInfo as DeviceInfoRaw } from "Core/device/types/mudita-os"
-import { CaseColour, DeviceType } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { DeviceInfo } from "Core/device-info/dto"
import { SimCardPresenter } from "Core/device-info/presenters/sim-card.presenter"
import { OnboardingState } from "Core/device/constants/onboarding-state.constant"
diff --git a/libs/core/device-info/services/device-info.service.ts b/libs/core/device-info/services/device-info.service.ts
index 81251e3b87..a4e687aac7 100644
--- a/libs/core/device-info/services/device-info.service.ts
+++ b/libs/core/device-info/services/device-info.service.ts
@@ -7,12 +7,8 @@ import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { DeviceInfo } from "Core/device-info/dto"
import { DeviceInfoPresenter } from "Core/device-info/presenters"
-import { DeviceManager } from "Core/device-manager/services"
-import {
- DeviceCommunicationError,
- Endpoint,
- Method,
-} from "Core/device/constants"
+import { DeviceProtocol } from "device-protocol/feature"
+import { Endpoint, Method, DeviceCommunicationError } from "core-device/models"
import {
DeviceInfo as DeviceInfoRaw,
NotSupportedDeviceInfo,
@@ -20,12 +16,12 @@ import {
import { DeviceId } from "Core/device/constants/device-id"
export class DeviceInfoService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
private async getDeviceInfoRequest(
- deviceId: DeviceId = this.deviceManager.device.id
+ deviceId: DeviceId = this.deviceProtocol.device.id
): Promise> {
- return this.deviceManager.request(deviceId, {
+ return this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
})
@@ -41,8 +37,8 @@ export class DeviceInfoService {
return response
}
const device = deviceId
- ? this.deviceManager.getCoreDeviceById(deviceId)
- : this.deviceManager.device
+ ? this.deviceProtocol.getCoreDeviceById(deviceId)
+ : this.deviceProtocol.device
if (!device) {
return Result.failed(new AppError("", ""))
diff --git a/libs/core/device-initialization/actions/initialize-mudita-harmony.action.ts b/libs/core/device-initialization/actions/initialize-mudita-harmony.action.ts
index 3a627bf98d..bb088cd197 100644
--- a/libs/core/device-initialization/actions/initialize-mudita-harmony.action.ts
+++ b/libs/core/device-initialization/actions/initialize-mudita-harmony.action.ts
@@ -12,12 +12,11 @@ import { DeviceInitializationStatus } from "Core/device-initialization/reducers/
import { AppError } from "Core/core/errors"
import { DeviceInitializationError } from "Core/device-initialization/constants/errors.enum"
import { loadSettings } from "Core/settings/actions"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { isActiveDeviceAttachedSelector } from "device-manager/feature"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { getCrashDump } from "Core/crash-dump"
import { checkForForceUpdateNeed } from "Core/update/actions"
-import { isActiveDeviceAttachedSelector } from "Core/device-manager/selectors/is-active-device-attached.selector"
-
export const initializeMuditaHarmony = createAsyncThunk<
DeviceInitializationStatus,
void,
diff --git a/libs/core/device-initialization/actions/initialize-mudita-pure.action.ts b/libs/core/device-initialization/actions/initialize-mudita-pure.action.ts
index 8a4e5539b5..d03f54047d 100644
--- a/libs/core/device-initialization/actions/initialize-mudita-pure.action.ts
+++ b/libs/core/device-initialization/actions/initialize-mudita-pure.action.ts
@@ -12,9 +12,10 @@ import { DeviceInitializationStatus } from "Core/device-initialization/reducers/
import { AppError } from "Core/core/errors"
import { DeviceInitializationError } from "Core/device-initialization/constants/errors.enum"
import { loadSettings } from "Core/settings/actions"
-import { configureDevice } from "Core/device-manager/actions/configure-device.action"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { configureDevice } from "core-device/feature"
+import { isActiveDeviceAttachedSelector } from "device-manager/feature"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { getCrashDump } from "Core/crash-dump"
import { checkForForceUpdateNeed } from "Core/update/actions"
import { deviceDataSelector } from "Core/device/selectors/device-data.selector"
@@ -27,7 +28,6 @@ import {
} from "Core/data-sync/actions"
import { SynchronizationStatus } from "Core/data-sync/reducers"
import { loadBackupData } from "Core/backup"
-import { isActiveDeviceAttachedSelector } from "Core/device-manager/selectors/is-active-device-attached.selector"
export const initializeMuditaPure = createAsyncThunk<
DeviceInitializationStatus,
diff --git a/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx b/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx
index 1946557bcb..b684c93e80 100644
--- a/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx
+++ b/libs/core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow.tsx
@@ -8,39 +8,37 @@
import React, { useCallback, useEffect, useMemo, useRef } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
-import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store"
+import { defineMessages } from "react-intl"
+import styled from "styled-components"
+import { useFilteredRoutesHistory } from "shared/utils"
+import { useDataMigrationDeviceSelector } from "shared/feature"
+import { ApiError } from "device/models"
+import { getDevicesSelector } from "device-manager/feature"
import {
selectActiveDeviceMenuElements,
selectApiError,
selectDataMigrationSourceDevice,
selectDataMigrationTargetDevice,
- setSourceDevice,
+ setDataMigrationSourceDevice,
} from "generic-view/store"
-import { ApiError } from "device/models"
-import { intl } from "Core/__deprecated__/renderer/utils/intl"
-import { defineMessages } from "react-intl"
-import { Modal, SpinnerLoader } from "generic-view/ui"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
+import { Modal } from "generic-view/ui"
import { GenericThemeProvider } from "generic-view/theme"
import { ButtonAction, IconType } from "generic-view/utils"
-import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
-import ReactModal from "react-modal"
-import styled from "styled-components"
+import { FunctionComponent } from "Core/core/types/function-component.interface"
+import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store"
+import { intl } from "Core/__deprecated__/renderer/utils/intl"
import {
URL_DEVICE_INITIALIZATION,
URL_DISCOVERY_DEVICE,
URL_MAIN,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
-import { useFilteredRoutesHistory } from "shared/utils"
import { setDeviceInitializationStatus } from "Core/device-initialization/actions/base.action"
import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
-import { useDataMigrationDeviceSelector } from "shared/feature"
+import { useDeactivateDeviceAndRedirect } from "Core/overview/components/overview-screens/pure-overview/use-deactivate-device-and-redirect.hook"
const messages = defineMessages({
- connectingModalParagraph: {
- id: "module.onboarding.connectingMessage",
- },
lockedModalHeadline: {
id: "component.deviceLockedModalHeadline",
},
@@ -52,20 +50,28 @@ const messages = defineMessages({
export const APIDeviceInitializationModalFlow: FunctionComponent = () => {
const history = useHistory()
const dispatch = useDispatch()
+ const devices = useSelector(getDevicesSelector)
+ const deactivateDeviceAndRedirect = useDeactivateDeviceAndRedirect()
const selectDevice = useDataMigrationDeviceSelector()
const firstRenderTime = useRef(Date.now())
- const deviceLocked = useSelector((state: ReduxRootState) => {
- return selectApiError(state, ApiError.DeviceLocked)
- })
const menuElements = useSelector(selectActiveDeviceMenuElements)
- const [pathToGoBack] = useFilteredRoutesHistory([
- URL_MAIN.root,
- ...Object.values(URL_ONBOARDING),
- ...Object.values(URL_DISCOVERY_DEVICE),
- ...Object.values(URL_DEVICE_INITIALIZATION),
- ])
+ const [pathToGoBack] = useFilteredRoutesHistory(
+ [
+ URL_MAIN.root,
+ ...Object.values(URL_ONBOARDING),
+ ...Object.values(URL_DISCOVERY_DEVICE),
+ ...Object.values(URL_DEVICE_INITIALIZATION),
+ ],
+ URL_DISCOVERY_DEVICE.availableDeviceListModal
+ )
const dataMigrationSourceDevice = useSelector(selectDataMigrationSourceDevice)
const dataMigrationTargetDevice = useSelector(selectDataMigrationTargetDevice)
+ const activeDeviceId = useSelector(activeDeviceIdSelector)
+ const deviceLocked = useSelector((state: ReduxRootState) =>
+ activeDeviceId
+ ? selectApiError(state, activeDeviceId, ApiError.DeviceLocked)
+ : false
+ )
const targetPath = useMemo(() => {
const firstMenuItemUrl = menuElements?.[0]?.items?.[0]?.button.url
@@ -100,11 +106,21 @@ export const APIDeviceInitializationModalFlow: FunctionComponent = () => {
dataMigrationSourceDevice.serialNumber,
URL_MAIN.dataMigration
)
- dispatch(setSourceDevice(undefined))
+ dispatch(setDataMigrationSourceDevice(undefined))
+ } else if (devices.length > 1) {
+ await deactivateDeviceAndRedirect()
} else {
history.push(pathToGoBack || URL_MAIN.news)
}
- }, [dataMigrationSourceDevice, dispatch, history, pathToGoBack, selectDevice])
+ }, [
+ dataMigrationSourceDevice,
+ dispatch,
+ history,
+ pathToGoBack,
+ selectDevice,
+ devices.length,
+ deactivateDeviceAndRedirect,
+ ])
const modalCloseAction: ButtonAction = {
type: "custom",
@@ -132,28 +148,6 @@ export const APIDeviceInitializationModalFlow: FunctionComponent = () => {
return (
-
-
-
- {intl.formatMessage(messages.connectingModalParagraph)}
-
-
theme.color.grey6};
`
-
-const ConnectingText = styled.p`
- font-size: ${({ theme }) => theme.fontSize.headline3};
- line-height: ${({ theme }) => theme.lineHeight.headline3};
- color: ${({ theme }) => theme.color.white};
- font-weight: ${({ theme }) => theme.fontWeight.bold};
- margin: 2.4rem 0 0;
-`
diff --git a/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-harmony-msc-initialization-modal-flow.tsx b/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-harmony-msc-initialization-modal-flow.tsx
new file mode 100644
index 0000000000..6651acd7af
--- /dev/null
+++ b/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-harmony-msc-initialization-modal-flow.tsx
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+/* eslint-disable @typescript-eslint/no-unsafe-return */
+
+import React, { useEffect } from "react"
+import { useDispatch } from "react-redux"
+import { FunctionComponent } from "Core/core/types/function-component.interface"
+import { Dispatch } from "Core/__deprecated__/renderer/store"
+import { setDeviceInitializationStatus } from "Core/device-initialization/actions/base.action"
+import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
+import { useHistory } from "react-router-dom"
+import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
+
+export const HarmonyMscInitializationModalFlow: FunctionComponent = () => {
+ const history = useHistory()
+ const dispatch = useDispatch()
+
+ useEffect(() => {
+ dispatch(
+ setDeviceInitializationStatus(DeviceInitializationStatus.Initialized)
+ )
+
+ history.push(URL_MAIN.recoveryMode)
+ // AUTO DISABLED - fix me if you like :)
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [])
+
+ return <>>
+}
diff --git a/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-pure-initialization-modal-flow.tsx b/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-pure-initialization-modal-flow.tsx
index 0ba0ab2963..fbdc9330cb 100644
--- a/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-pure-initialization-modal-flow.tsx
+++ b/libs/core/device-initialization/components/devices-initialization-modal-flows/mudita-pure-initialization-modal-flow.tsx
@@ -6,7 +6,6 @@
import React, { useEffect, useRef } from "react"
import { useSelector } from "react-redux"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-
import { deviceStatusSelector } from "Core/device/selectors/device-status.selector"
import { useDeviceInitializer } from "Core/device-initialization/components/devices-initialization-modal-flows/handle-initialize-device.helper"
import { initializeMuditaPure } from "Core/device-initialization/actions/initialize-mudita-pure.action"
diff --git a/libs/core/device-initialization/components/devices-initialization.component.tsx b/libs/core/device-initialization/components/devices-initialization.component.tsx
index 5f4ef6420c..9a770acfde 100644
--- a/libs/core/device-initialization/components/devices-initialization.component.tsx
+++ b/libs/core/device-initialization/components/devices-initialization.component.tsx
@@ -3,19 +3,24 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import React from "react"
+import React, { useEffect } from "react"
import { useSelector } from "react-redux"
+import { useHistory } from "react-router-dom"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import ConnectingContent from "Core/connecting/components/connecting-content.component"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
-import { DeviceType } from "Core/device"
+import { URL_ONBOARDING } from "Core/__deprecated__/renderer/constants/urls"
+import {
+ getActiveDevice,
+ isActiveDeviceFailedSelector,
+} from "device-manager/feature"
+import { DeviceBaseProperties, DeviceType } from "device-protocol/models"
import { MuditaPureInitializationModalFlow } from "Core/device-initialization/components/devices-initialization-modal-flows/mudita-pure-initialization-modal-flow"
import { MuditaHarmonyInitializationModalFlow } from "Core/device-initialization/components/devices-initialization-modal-flows/mudita-harmony-initialization-modal-flow"
import { APIDeviceInitializationModalFlow } from "Core/device-initialization/components/devices-initialization-modal-flows/api-device-initialization-modal-flow"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
+import { HarmonyMscInitializationModalFlow } from "Core/device-initialization/components//devices-initialization-modal-flows/mudita-harmony-msc-initialization-modal-flow"
const DevicesInitializationModalFlow: FunctionComponent<{
- activeDevice?: Device
+ activeDevice?: DeviceBaseProperties
}> = ({ activeDevice }) => {
if (activeDevice?.deviceType === DeviceType.MuditaPure) {
return
@@ -23,19 +28,28 @@ const DevicesInitializationModalFlow: FunctionComponent<{
return
} else if (activeDevice?.deviceType === DeviceType.APIDevice) {
return
+ } else if (activeDevice?.deviceType === DeviceType.MuditaHarmonyMsc) {
+ return
} else {
return <>>
}
}
const DevicesInitialization: FunctionComponent = () => {
+ const history = useHistory()
const activeDevice = useSelector(getActiveDevice)
+ const activeDeviceFailedSelector = useSelector(isActiveDeviceFailedSelector)
+
+ useEffect(() => {
+ if (activeDeviceFailedSelector) {
+ history.push(URL_ONBOARDING.troubleshooting)
+ }
+ }, [activeDeviceFailedSelector, history])
+
return (
<>
- {activeDevice?.deviceType !== DeviceType.APIDevice && (
-
- )}
+
>
)
}
diff --git a/libs/core/device-initialization/components/passcode-modal/passcode-modal-ui.component.tsx b/libs/core/device-initialization/components/passcode-modal/passcode-modal-ui.component.tsx
index 50bad38cc6..d195729784 100644
--- a/libs/core/device-initialization/components/passcode-modal/passcode-modal-ui.component.tsx
+++ b/libs/core/device-initialization/components/passcode-modal/passcode-modal-ui.component.tsx
@@ -61,6 +61,7 @@ export interface PasscodeModalProps
errorMessage: string
leftTime?: number | undefined
canBeClosed: boolean
+ noOverlayBg?: boolean
}
const PasscodeModalUI: FunctionComponent = ({
@@ -73,6 +74,7 @@ const PasscodeModalUI: FunctionComponent = ({
errorMessage,
leftTime,
canBeClosed,
+ noOverlayBg = true,
...props
}) => {
const muditaLogo = (
@@ -80,7 +82,7 @@ const PasscodeModalUI: FunctionComponent = ({
)
@@ -94,6 +96,7 @@ const PasscodeModalUI: FunctionComponent = ({
closeButton={false}
closeModal={canBeClosed ? close : undefined}
title={muditaLogo}
+ noOverlayBg={noOverlayBg}
>
diff --git a/libs/core/device-initialization/components/passcode-modal/passcode-modal.component.tsx b/libs/core/device-initialization/components/passcode-modal/passcode-modal.component.tsx
index 6cb2ecc1c7..b6a64af321 100644
--- a/libs/core/device-initialization/components/passcode-modal/passcode-modal.component.tsx
+++ b/libs/core/device-initialization/components/passcode-modal/passcode-modal.component.tsx
@@ -5,13 +5,12 @@
import React, { useEffect, useState } from "react"
import { PayloadAction } from "@reduxjs/toolkit"
-import { ipcRenderer } from "electron-better-ipc"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import PasscodeModalUI from "Core/device-initialization/components/passcode-modal/passcode-modal-ui.component"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
import { AppError } from "Core/core/errors"
import { ModalDialogProps } from "Core/ui"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
+import { useHelpShortcut } from "help/store"
export type UnlockDeviceReturnType = Promise<
PayloadAction
@@ -51,9 +50,13 @@ const PasscodeModal: FunctionComponent = ({
unlockDevice,
...rest
}) => {
+ const openHelpShortcut = useHelpShortcut()
const [errorState, setErrorState] = useState(ErrorState.NoError)
const [values, setValues] = useState(initValue)
- const openHelpWindow = () => ipcRenderer.callMain(HelpActions.OpenWindow)
+
+ const openHelpWindow = () => {
+ openHelpShortcut("pure-password-forgotten")
+ }
const updateValues = (values: string[]): void => {
setValues(values)
diff --git a/libs/core/device-initialization/components/passcode-modal/passcode-modal.test.tsx b/libs/core/device-initialization/components/passcode-modal/passcode-modal.test.tsx
index ce67b55332..edfceac469 100644
--- a/libs/core/device-initialization/components/passcode-modal/passcode-modal.test.tsx
+++ b/libs/core/device-initialization/components/passcode-modal/passcode-modal.test.tsx
@@ -81,6 +81,10 @@ afterEach(() => {
cleanup()
})
+jest.mock("help/store", () => ({
+ useHelpShortcut: () => jest.fn(),
+}))
+
test("Passcode modal has 4 inputs", () => {
const { inputsContainer } = renderer()
expect(inputsContainer()?.childNodes).toHaveLength(4)
diff --git a/libs/core/device-initialization/selectors/is-passcode-modal-can-be-closed.selector.ts b/libs/core/device-initialization/selectors/is-passcode-modal-can-be-closed.selector.ts
index b425801631..eecc7ae3bb 100644
--- a/libs/core/device-initialization/selectors/is-passcode-modal-can-be-closed.selector.ts
+++ b/libs/core/device-initialization/selectors/is-passcode-modal-can-be-closed.selector.ts
@@ -5,7 +5,7 @@
import { createSelector } from "@reduxjs/toolkit"
import { updateStateSelector } from "Core/update/selectors/update-state-selector"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
export const isPasscodeModalCanBeClosedSelector = createSelector(
updateStateSelector,
diff --git a/libs/core/device-log/device-log.module.ts b/libs/core/device-log/device-log.module.ts
index 0ed685e287..2ecda83053 100644
--- a/libs/core/device-log/device-log.module.ts
+++ b/libs/core/device-log/device-log.module.ts
@@ -13,12 +13,12 @@ import { BaseModule } from "Core/core/module"
import { DeviceFileSystemService } from "Core/device-file-system/services"
import { DeviceLogService } from "Core/device-log/services"
import { DeviceLogController } from "Core/device-log/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DeviceLogModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -27,7 +27,7 @@ export class DeviceLogModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -36,8 +36,8 @@ export class DeviceLogModule extends BaseModule {
)
const deviceLogService = new DeviceLogService(
- this.deviceManager,
- new DeviceFileSystemService(this.deviceManager)
+ this.deviceProtocol,
+ new DeviceFileSystemService(this.deviceProtocol)
)
const deviceLogController = new DeviceLogController(deviceLogService)
diff --git a/libs/core/device-log/services/device-log.service.test.ts b/libs/core/device-log/services/device-log.service.test.ts
index cd3a584cca..fab2b090e1 100644
--- a/libs/core/device-log/services/device-log.service.test.ts
+++ b/libs/core/device-log/services/device-log.service.test.ts
@@ -5,16 +5,12 @@
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import {
- Endpoint,
- Method,
- DiagnosticsFileList,
- DeviceCommunicationError,
-} from "Core/device/constants"
+import { DiagnosticsFileList } from "Core/device/constants"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
import { GetDeviceFilesResponseBody } from "Core/device/types/mudita-os"
import { DeviceLogService } from "Core/device-log/services/device-log.service"
import { DeviceEnumError } from "Core/device-log/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceFileSystemService } from "Core/device-file-system/services"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import {
@@ -22,17 +18,17 @@ import {
secondsPartDecodeLog,
} from "Root/jest/testing-support/mocks/diagnostic-data.mock"
-const deviceManagerMock = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const deviceFileSystemMock = {
downloadDeviceFiles: jest.fn(),
} as unknown as DeviceFileSystemService
-const subject = new DeviceLogService(deviceManagerMock, deviceFileSystemMock)
+const subject = new DeviceLogService(deviceProtocol, deviceFileSystemMock)
const deviceInfoErrorResponse: ResultObject = Result.failed(
new AppError(DeviceCommunicationError.RequestFailed, "Something went wrong", {
@@ -45,7 +41,7 @@ const deviceInfoSuccessResponse: ResultObject =
describe("Method: `downloadDeviceLogs`", () => {
test("returns Result.failed if DeviceInfo endpoint response with error", async () => {
- deviceManagerMock.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(deviceInfoErrorResponse)
@@ -61,7 +57,7 @@ describe("Method: `downloadDeviceLogs`", () => {
)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManagerMock.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
body: {
@@ -74,7 +70,7 @@ describe("Method: `downloadDeviceLogs`", () => {
})
test("returns Result.failed if `downloadDeviceFiles` returns empty data", async () => {
- deviceManagerMock.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(deviceInfoSuccessResponse)
deviceFileSystemMock.downloadDeviceFiles = jest
@@ -93,7 +89,7 @@ describe("Method: `downloadDeviceLogs`", () => {
)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManagerMock.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
body: {
@@ -108,7 +104,7 @@ describe("Method: `downloadDeviceLogs`", () => {
})
test("returns Result.success if `downloadDeviceFiles` returns file data", async () => {
- deviceManagerMock.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(deviceInfoSuccessResponse)
deviceFileSystemMock.downloadDeviceFiles = jest.fn().mockResolvedValueOnce(
diff --git a/libs/core/device-log/services/device-log.service.ts b/libs/core/device-log/services/device-log.service.ts
index 9874aab847..884c13bdae 100644
--- a/libs/core/device-log/services/device-log.service.ts
+++ b/libs/core/device-log/services/device-log.service.ts
@@ -3,20 +3,21 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Endpoint, Method } from "core-device/models"
import { ResultObject, Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import { Endpoint, Method, DiagnosticsFileList } from "Core/device/constants"
+import { DiagnosticsFileList } from "Core/device/constants"
import { GetDeviceFilesResponseBody } from "Core/device/types/mudita-os"
import { transformDeviceFilesByOption } from "Core/device-log/helpers"
import { DeviceFile } from "Core/device-file-system/dto"
import { DeviceEnumError } from "Core/device-log/constants"
import { DeviceFilesOption } from "Core/device-file-system/types"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DeviceLogService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private deviceFileSystem: DeviceFileSystemService
) {}
@@ -25,7 +26,7 @@ export class DeviceLogService {
): Promise> {
try {
const files =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.DeviceInfo,
method: Method.Get,
body: {
diff --git a/libs/core/device-manager/actions/base.action.ts b/libs/core/device-manager/actions/base.action.ts
deleted file mode 100644
index efe2596a56..0000000000
--- a/libs/core/device-manager/actions/base.action.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createAction } from "@reduxjs/toolkit"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { DeviceState } from "Core/device-manager/reducers/device-manager.interface"
-import { CaseColour } from "Core/device"
-
-export const addDevice = createAction>(
- DeviceManagerEvent.AddDevice
-)
-
-export const removeDevice = createAction(
- DeviceManagerEvent.RemoveDevice
-)
diff --git a/libs/core/device-manager/actions/connect-device.action.ts b/libs/core/device-manager/actions/connect-device.action.ts
deleted file mode 100644
index bbcc2b6245..0000000000
--- a/libs/core/device-manager/actions/connect-device.action.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createAsyncThunk } from "@reduxjs/toolkit"
-import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
-import { DeviceId } from "Core/device/constants/device-id"
-import { connectDeviceRequest } from "Core/device-manager/requests/connect-device.request"
-
-export const connectDevice = createAsyncThunk<
- boolean,
- DeviceId,
- { state: ReduxRootState }
->(
- DeviceManagerEvent.ConnectDevice,
- async (id) => {
- const result = await connectDeviceRequest(id)
- return result.ok
- }
-)
diff --git a/libs/core/device-manager/constants/controller.constant.ts b/libs/core/device-manager/constants/controller.constant.ts
deleted file mode 100644
index 487dd36339..0000000000
--- a/libs/core/device-manager/constants/controller.constant.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-export const ControllerPrefix = "device-manager"
-
-export enum IpcDeviceManagerEvent {
- SetActiveDevice = "device-manager_set-active-device",
- GetDeviceConfiguration = "device-manager_get-device-configuration",
- ConnectDevice = "device-manager_connect-device",
-}
diff --git a/libs/core/device-manager/reducers/device-manager.interface.ts b/libs/core/device-manager/reducers/device-manager.interface.ts
deleted file mode 100644
index 5554975d65..0000000000
--- a/libs/core/device-manager/reducers/device-manager.interface.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { CaseColour, DeviceType } from "Core/device"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { DeviceId } from "Core/device/constants/device-id"
-
-export enum DeviceState {
- Connected = "CONNECTED",
- Configured = "CONFIGURED",
- Initialized = "INITIALIZED",
- Failed = "FAILED",
-}
-
-export interface Device extends DeviceBaseProperties {
- id: DeviceId
- serialNumber: string | undefined
- deviceType: DeviceType
- caseColour: CaseColour | undefined
- state: DeviceState
-}
-
-export interface DeviceManagerState {
- devices: Device[]
- activeDeviceId: DeviceId | undefined
- selectDeviceDrawerOpen: boolean
-}
diff --git a/libs/core/device-manager/reducers/device-manager.reducer.ts b/libs/core/device-manager/reducers/device-manager.reducer.ts
deleted file mode 100644
index 9fa2f186ee..0000000000
--- a/libs/core/device-manager/reducers/device-manager.reducer.ts
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createReducer } from "@reduxjs/toolkit"
-import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
-import {
- Device,
- DeviceManagerState,
- DeviceState,
-} from "Core/device-manager/reducers/device-manager.interface"
-import {
- addDevice,
- removeDevice,
-} from "Core/device-manager/actions/base.action"
-import { setActiveDevice } from "Core/device-manager/actions/set-active-device.action"
-import { configureDevice } from "Core/device-manager/actions/configure-device.action"
-import { deactivateDevice } from "Core/device-manager/actions/deactivate-device.action"
-import { setSelectDeviceDrawerOpen } from "Core/device-select/actions/set-select-device-drawer-open.action"
-import { connectDevice } from "Core/device-manager/actions/connect-device.action"
-
-export const initialState: DeviceManagerState = {
- devices: [],
- activeDeviceId: undefined,
- selectDeviceDrawerOpen: false,
-}
-
-export const deviceManagerReducer = createReducer(
- initialState,
- (builder) => {
- builder
- .addCase(setDiscoveryStatus, (state, action) => {
- return {
- ...state,
- discoveryStatus: action.payload,
- }
- })
- .addCase(addDevice, (state, action) => {
- const devices = [...state.devices]
- devices.push({
- caseColour: undefined,
- state: DeviceState.Connected,
- ...action.payload,
- })
-
- return {
- ...state,
- devices,
- }
- })
- .addCase(removeDevice, (state, action) => {
- const devices = state.devices.filter(
- ({ id }) => id !== action.payload.id
- )
-
- return {
- ...state,
- devices,
- }
- })
- .addCase(setActiveDevice.fulfilled, (state, action) => {
- return {
- ...state,
- activeDeviceId: action.payload,
- }
- })
- .addCase(configureDevice.fulfilled, (state, action) => {
- const devices = state.devices.reduce((prev, device) => {
- const payload = action.payload
- if (device.id === payload.id) {
- return [
- ...prev,
- {
- ...device,
- caseColour: payload.caseColour ?? device.caseColour,
- serialNumber: payload.serialNumber ?? device.serialNumber,
- state: DeviceState.Configured,
- },
- ]
- } else {
- return [...prev, device]
- }
- }, [] as Device[])
-
- return {
- ...state,
- devices,
- }
- })
- .addCase(connectDevice.fulfilled, (state, action) => {
- if(!action.payload){
- return { ...state }
- }
-
- const devices = state.devices.reduce((prev, device) => {
- const id = action.meta.arg
- if (device.id === id) {
- return [
- ...prev,
- {
- ...device,
- state: DeviceState.Connected,
- },
- ]
- } else {
- return [...prev, device]
- }
- }, [] as Device[])
-
- return {
- ...state,
- devices,
- }
- })
- .addCase(deactivateDevice.fulfilled, (state) => {
-
- return {
- ...state,
- activeDeviceId: undefined,
- }
- })
- .addCase(setSelectDeviceDrawerOpen, (state, action) => {
- return {
- ...state,
- selectDeviceDrawerOpen: action.payload,
- }
- })
- }
-)
diff --git a/libs/core/device-manager/selectors/get-active-device-base-data.selector.ts b/libs/core/device-manager/selectors/get-active-device-base-data.selector.ts
deleted file mode 100644
index 1c63312729..0000000000
--- a/libs/core/device-manager/selectors/get-active-device-base-data.selector.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
-import { DeviceState, HarmonyDeviceData, KompaktDeviceData, PureDeviceData } from "Core/device"
-import { deviceStateSelector } from "Core/device/selectors"
-
-export interface DeviceBaseData
- extends DeviceBaseProperties,
- Pick {
- data: Partial
-}
-
-export const getActiveDeviceBaseDataSelector = createSelector(
- deviceManagerState,
- deviceStateSelector,
- (deviceManager, deviceState): DeviceBaseData | undefined => {
- const { devices, activeDeviceId } = deviceManager
- const activeDevice = devices.find(({ id }) => id === activeDeviceId)
-
- if(activeDevice === undefined){
- return
- }
-
- const {data, externalUsageDevice} = deviceState
-
- if(data === null){
- return
- }
-
- return {
- ...activeDevice,
- data,
- externalUsageDevice
- }
- }
-)
diff --git a/libs/core/device-manager/selectors/get-configured-devices.selector.ts b/libs/core/device-manager/selectors/get-configured-devices.selector.ts
deleted file mode 100644
index 9985883e21..0000000000
--- a/libs/core/device-manager/selectors/get-configured-devices.selector.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import {
- Device,
- DeviceState,
-} from "Core/device-manager/reducers/device-manager.interface"
-import { selectConfiguredDeviceIDs } from "generic-view/store"
-import { DeviceType } from "Core/device/constants"
-
-export const getConfiguredDevicesSelector = createSelector(
- deviceManagerState,
- selectConfiguredDeviceIDs,
- (deviceManager, apiIds): Device[] => {
- return deviceManager.devices.filter(({ state, deviceType, id }) => {
- if (deviceType === DeviceType.APIDevice && apiIds.includes(id)) {
- return true
- }
- return state === DeviceState.Configured
- })
- }
-)
diff --git a/libs/core/device-manager/selectors/get-device.selector.ts b/libs/core/device-manager/selectors/get-device.selector.ts
deleted file mode 100644
index 70b39b246f..0000000000
--- a/libs/core/device-manager/selectors/get-device.selector.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
-
-export const getDeviceSelector = (id: string) => {
- return createSelector(
- deviceManagerState,
- ({ devices }): Device | undefined => {
- return devices.find((device) => device.id === id)
- }
- )
-}
diff --git a/libs/core/device-manager/selectors/get-devices.selector.ts b/libs/core/device-manager/selectors/get-devices.selector.ts
deleted file mode 100644
index 0a634f4191..0000000000
--- a/libs/core/device-manager/selectors/get-devices.selector.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
-
-export const getDevicesSelector = createSelector(
- deviceManagerState,
- (deviceManager): Device[] => {
- return deviceManager.devices
- }
-)
diff --git a/libs/core/device-manager/selectors/get-failed-devices.selector.ts b/libs/core/device-manager/selectors/get-failed-devices.selector.ts
deleted file mode 100644
index 9caff9d657..0000000000
--- a/libs/core/device-manager/selectors/get-failed-devices.selector.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import {
- Device,
- DeviceState,
-} from "Core/device-manager/reducers/device-manager.interface"
-
-export const getFailedDevicesSelector = createSelector(
- deviceManagerState,
- (deviceManager): Device[] => {
- return deviceManager.devices.filter(
- ({ state }) => state === DeviceState.Failed
- )
- }
-)
diff --git a/libs/core/device-manager/services/serial-port-list.helper.ts b/libs/core/device-manager/services/serial-port-list.helper.ts
deleted file mode 100644
index a8b3b3706f..0000000000
--- a/libs/core/device-manager/services/serial-port-list.helper.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { getMockedDevices, mockServiceEnabled } from "e2e-mock-server"
-import SerialPort, { PortInfo } from "serialport"
-
-export const getSerialPortList = () => {
- if (mockServiceEnabled) {
- return new Promise((resolve) => {
- resolve(getMockedDevices())
- })
- }
- return SerialPort.list()
-}
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.test.ts b/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.test.ts
new file mode 100644
index 0000000000..68b0d9ea4e
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.test.ts
@@ -0,0 +1,77 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import {
+ getHarmonyMSCDevice,
+ parseUsbDeviceDetails,
+} from "./usb-devices-linux.helper"
+import { PortInfo } from "serialport"
+
+describe("getHarmonyMSCDevice", () => {
+ it("should return the correct USB device", () => {
+ const output = `
+Bus 002 Device 008: ID 3310:0102 MUDITA Sp. z o.o. Mudita Pure
+Bus 002 Device 007: ID 3310:0103 MUDITA Sp. z o.o. Mudita Harmony (MSC mode)
+ `
+ const device = getHarmonyMSCDevice(output)
+ expect(device).toEqual({
+ bus: "2",
+ device: "7",
+ id: "3310:0103",
+ description: "MUDITA Sp. z o.o. Mudita Harmony (MSC mode)",
+ })
+ })
+
+ it("should return undefined if no matching device is found", () => {
+ const output = `
+ Bus 002 Device 008: ID 3310:0102 MUDITA Sp. z o.o. Mudita Pure
+ `
+ const device = getHarmonyMSCDevice(output)
+ expect(device).toBeUndefined()
+ })
+})
+
+describe("parseUsbDeviceDetails", () => {
+ it("should parse USB device details correctly", () => {
+ const output = `
+Bus 002 Device 007: ID 3310:0103 MUDITA Sp. z o.o. Mudita Harmony (MSC mode)
+Couldn't open device, some information will be missing
+Device Descriptor:
+ iManufacturer 1 Mudita
+ iProduct 2 Mudita Harmony (MSC mode)
+ iSerial 3 0123456789ABCDEF
+ bNumConfigurations 1
+ Interface Descriptor:
+ bLength 9
+ bDescriptorType 4
+ bInterfaceNumber 0
+ iInterface 0
+ Endpoint Descriptor:
+ bLength 7
+ bmAttributes 2
+ Transfer Type Bulk
+ Synch Type None
+ Usage Type Data
+ wMaxPacketSize 0x0200 1x 512 bytes
+ bInterval 0
+ Endpoint Descriptor:
+ bEndpointAddress 0x02 EP 2 OUT
+ bmAttributes 2
+ Transfer Type Bulk
+ Synch Type None
+ Usage Type Data
+ wMaxPacketSize 0x0200 1x 512 bytes
+ bInterval 0
+ `
+ const portInfo: PortInfo = parseUsbDeviceDetails(output)
+ expect(portInfo).toEqual({
+ path: "3310/0103/0123456789ABCDEF",
+ manufacturer: "Mudita",
+ serialNumber: "0123456789ABCDEF",
+ productId: "0103",
+ vendorId: "3310",
+ })
+ })
+})
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.ts b/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.ts
new file mode 100644
index 0000000000..58c6f7bf16
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-linux.helper.ts
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ProductID, VendorID } from "Core/device/constants"
+import { execPromise } from "shared/utils"
+import { PortInfo } from "serialport"
+
+interface UsbDevice {
+ bus: string
+ device: string
+ id: string
+ description: string
+}
+
+export const getHarmonyMSCDevice = (output: string): UsbDevice | undefined => {
+ const devices: UsbDevice[] = output
+ .trim()
+ .split("\n")
+ .map((line) => {
+ const parts = line.split(" ")
+ return {
+ bus: parts[1].replace(/^0+/, ""),
+ device: parts[3].slice(0, -1).replace(/^0+/, ""),
+ id: parts[5],
+ description: parts.slice(6).join(" "),
+ }
+ })
+ return devices.find(
+ (device) =>
+ device.id === `${VendorID.MuditaHarmony}:${ProductID.MuditaHarmonyMsc}`
+ )
+}
+
+const getUsbDeviceDetails = async (
+ bus: string,
+ device: string
+): Promise => {
+ const stdout = await execPromise(`lsusb -v -s ${bus}:${device}`)
+ if (stdout) {
+ return parseUsbDeviceDetails(stdout)
+ }
+
+ return
+}
+
+export function parseUsbDeviceDetails(output: string): PortInfo {
+ const lines = output.split("\n").map((line) => line.trim())
+ const portInfo: Partial = {}
+
+ lines.forEach((line) => {
+ if (line.startsWith("Bus")) {
+ const parts = line.split(" ")
+ portInfo.vendorId = parts[5].split(":")[0]
+ portInfo.productId = parts[5].split(":")[1]
+ } else if (line.startsWith("iManufacturer")) {
+ portInfo.manufacturer = line.split(/\s+/).slice(2).join(" ")
+ } else if (line.startsWith("iSerial")) {
+ portInfo.serialNumber = line.split(/\s+/).slice(2).join(" ")
+ }
+ })
+ portInfo.path = `${portInfo.vendorId}/${portInfo.productId}/${portInfo.serialNumber}`
+ return portInfo as PortInfo
+}
+
+export const getUsbDevicesLinux = async (): Promise => {
+ try {
+ const stdout = await execPromise("lsusb")
+ if (stdout) {
+ const harmonyDevice = getHarmonyMSCDevice(stdout)
+ if (harmonyDevice) {
+ const details = await getUsbDeviceDetails(
+ harmonyDevice.bus,
+ harmonyDevice.device
+ )
+ return details
+ }
+ }
+ } catch (error) {
+ console.error(error)
+ }
+}
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.test.ts b/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.test.ts
new file mode 100644
index 0000000000..ebdbcb5926
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.test.ts
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { getHarmonyMSCDevice, parseToPortInfo } from "./usb-devices-mac.helper"
+import { PortInfo } from "serialport"
+
+describe("getHarmonyMSCDevice", () => {
+ it("should return the correct device details", () => {
+ const output = `
+ Mudita Harmony (MSC mode):
+ Product ID: 0x0103
+ Vendor ID: 0x3310
+ Version: 1.01
+ Serial Number: 0123456789ABCDEF
+ Speed: Up to 480 Mb/s
+ Manufacturer: Mudita
+ Location ID: 0x00140000 / 4
+ Current Available (mA): 500
+ Current Required (mA): 100
+ Extra Operating Current (mA): 0
+ Mudita Pure:
+ Product ID: 0x0102
+ Vendor ID: 0x3310
+ Version: 1.12
+ Serial Number: 25878580214921
+ Speed: Up to 480 Mb/s
+ Manufacturer: Mudita
+ Location ID: 0x00120000 / 5
+ Current Available (mA): 500
+ Current Required (mA): 500
+ Extra Operating Current (mA): 0
+ `
+
+ const device = getHarmonyMSCDevice(output)
+
+ expect(device).toEqual({
+ name: "Mudita Harmony (MSC mode)",
+ VendorID: "0x3310",
+ ProductID: "0x0103",
+ SerialNumber: "0123456789ABCDEF",
+ Manufacturer: "Mudita",
+ LocationID: "0x00140000 / 4",
+ Version: "1.01",
+ Speed: "Up to 480 Mb/s",
+ "CurrentAvailable(mA)": "500",
+ "CurrentRequired(mA)": "100",
+ "ExtraOperatingCurrent(mA)": "0",
+ })
+ })
+
+ it("should return null if no matching device is found", () => {
+ const output = `
+ Mudita Pure:
+ Product ID: 0x0102
+ Vendor ID: 0x3310
+ Version: 1.12
+ Serial Number: 25878580214921
+ Speed: Up to 480 Mb/s
+ Manufacturer: Mudita
+ Location ID: 0x00120000 / 5
+ Current Available (mA): 500
+ Current Required (mA): 500
+ Extra Operating Current (mA): 0
+ `
+ const device = getHarmonyMSCDevice(output)
+ expect(device).toBeNull()
+ })
+})
+
+describe("parseToPortInfo", () => {
+ it("should parse DeviceDetails to PortInfo correctly", () => {
+ const deviceDetails = {
+ name: "Mudita Harmony (MSC mode)",
+ VendorID: "0x3310",
+ ProductID: "0x0103",
+ SerialNumber: "0123456789ABCDEF",
+ Manufacturer: "Mudita",
+ LocationID: "0x00140000 / 3",
+ }
+
+ const portInfo: PortInfo = parseToPortInfo(deviceDetails)
+
+ expect(portInfo).toEqual({
+ path: "3310/0103/0123456789ABCDEF",
+ manufacturer: "Mudita",
+ serialNumber: "0123456789ABCDEF",
+ productId: "0103",
+ vendorId: "3310",
+ locationId: "0x00140000",
+ })
+ })
+})
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.ts b/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.ts
new file mode 100644
index 0000000000..17014949fa
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-mac.helper.ts
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ProductID, VendorID } from "Core/device/constants"
+import { execPromise } from "shared/utils"
+import { PortInfo } from "serialport"
+
+interface DeviceDetails {
+ [key: string]: string | undefined
+ name?: string
+ ProductID?: string
+ VendorID?: string
+ Version?: string
+ SerialNumber?: string
+ Speed?: string
+ Manufacturer?: string
+ LocationID?: string
+ "CurrentAvailable(mA)"?: string
+ "CurrentRequired(mA)"?: string
+ "ExtraOperatingCurrent(mA)"?: string
+}
+
+export const getHarmonyMSCDevice = (output: string): DeviceDetails | null => {
+ const devices: Array = []
+ const lines = output.trim().split("\n")
+ let currentDevice: DeviceDetails = {}
+ let currentKey = ""
+
+ lines.forEach((line) => {
+ if (line.trim() && !line.trim().endsWith(":")) {
+ const [keyParts, ...valueParts] = line.trim().split(":")
+ const key = keyParts.replaceAll(" ", "")
+ const value = valueParts.join(":").trim()
+ currentDevice[key] = value
+ } else if (line.trim().endsWith(":")) {
+ if (Object.keys(currentDevice).length) {
+ devices.push({ name: currentKey, ...currentDevice })
+ currentDevice = {}
+ }
+ currentKey = line.trim().slice(0, -1)
+ }
+ })
+
+ if (Object.keys(currentDevice).length) {
+ devices.push({ name: currentKey, ...currentDevice })
+ }
+
+ return (
+ devices.find((device) => {
+ if (device.VendorID && device.ProductID) {
+ return (
+ device.VendorID.includes(VendorID.MuditaHarmony) &&
+ device.ProductID.includes(ProductID.MuditaHarmonyMsc)
+ )
+ }
+ return null
+ }) || null
+ )
+}
+
+export const parseToPortInfo = (device: DeviceDetails): PortInfo => {
+ const vendorId = device.VendorID!.replace("0x", "")
+ const productId = device.ProductID!.replace("0x", "")
+ const serialNumber = device.SerialNumber
+
+ return {
+ path: `${vendorId}/${productId}/${serialNumber}`,
+ manufacturer: device.Manufacturer,
+ serialNumber: device.SerialNumber,
+ productId,
+ vendorId,
+ locationId: device.LocationID?.split(" ")[0],
+ }
+}
+
+export const getUsbDevicesMacOS = async (): Promise => {
+ try {
+ const stdout = await execPromise("system_profiler SPUSBDataType")
+ if (stdout) {
+ const harmonyDevice = getHarmonyMSCDevice(stdout)
+ if (harmonyDevice) {
+ return parseToPortInfo(harmonyDevice)
+ }
+ }
+ } catch (error) {
+ console.error(error)
+ }
+}
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.test.ts b/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.test.ts
new file mode 100644
index 0000000000..ccb4207f7b
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.test.ts
@@ -0,0 +1,76 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import {
+ getHarmonyMSCDevice,
+ parseToPortInfo,
+} from "./usb-devices-windows.helper"
+import { PortInfo } from "serialport"
+
+describe("getHarmonyMSCDevice", () => {
+ it("should return the correct device details", () => {
+ const output = `
+Name : MUDITA HARMONY MSC USB Device
+DeviceID : USBSTOR\\DISK&VEN_MUDITA&PROD_HARMONY_MSC&REV_0001\\0123456789ABCDEF&0
+Manufacturer : (standard disk station)
+Description : Disk station
+Service : disk
+
+Name : USB mass storage device
+DeviceID : USB\\VID_3310&PID_0103\\0123456789ABCDEF
+Manufacturer : Compatible USB storage device
+Description : USB mass storage device
+Service : USBSTOR
+
+Name : USB composite device
+DeviceID : USB\\VID_046D&PID_085C\\F48B64BF
+Manufacturer : (Standard USB host controller)
+Description : USB composite device
+Service : usbccgp
+ `
+ const device = getHarmonyMSCDevice(output)
+ expect(device).toEqual({
+ name: "USB mass storage device",
+ deviceId: "USB\\VID_3310&PID_0103\\0123456789ABCDEF",
+ manufacturer: "Compatible USB storage device",
+ description: "USB mass storage device",
+ service: "USBSTOR",
+ })
+ })
+
+ it("should return undefined if no matching device is found", () => {
+ const output = `
+Name : Other Device
+DeviceID : USB\\VID_1234&PID_5678\\87654321
+Manufacturer : Other Manufacturer
+Description : Other Device Description
+Service : OtherService
+ `
+ const device = getHarmonyMSCDevice(output)
+ expect(device).toBeUndefined()
+ })
+})
+
+describe("parseToPortInfo", () => {
+ it("should parse DeviceInfo to PortInfo correctly", () => {
+ const deviceInfo = {
+ name: "Mudita Harmony (MSC mode)",
+ deviceId: "USB\\VID_3310&PID_0103\\0123456789ABCDEF",
+ manufacturer: "Mudita",
+ description: "Mudita Harmony (MSC mode)",
+ service: "USBSTOR",
+ }
+
+ const portInfo: PortInfo = parseToPortInfo(deviceInfo)
+
+ expect(portInfo).toEqual({
+ path: "3310/0103/0123456789ABCDEF",
+ manufacturer: "MUDITA",
+ serialNumber: "0123456789ABCDEF",
+ productId: "0103",
+ vendorId: "3310",
+ })
+ })
+})
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.ts b/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.ts
new file mode 100644
index 0000000000..290cabd37c
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices-windows.helper.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ProductID, VendorID } from "Core/device/constants"
+import { execPromise } from "shared/utils"
+import { PortInfo } from "serialport"
+
+interface DeviceInfo {
+ name: string
+ deviceId: string
+ manufacturer: string
+ description: string
+ service: string
+}
+
+export const getHarmonyMSCDevice = (output: string): DeviceInfo | undefined => {
+ const devices: DeviceInfo[] = []
+ const deviceSections = output.trim().split(/(?=Name\s*:)/)
+
+ deviceSections.forEach((section) => {
+ const lines = section.split(/\n/)
+ const device: Partial = {}
+
+ lines.forEach((line) => {
+ if (line.includes("DeviceID")) {
+ device.deviceId = line.split(":")[1].trim()
+ } else if (line.includes("Manufacturer")) {
+ device.manufacturer = line.split(":")[1].trim()
+ } else if (line.includes("Description")) {
+ device.description = line.split(":")[1].trim()
+ } else if (line.includes("Service")) {
+ device.service = line.split(":")[1].trim()
+ } else if (line.includes("Name")) {
+ device.name = line.split(":")[1].trim()
+ }
+ })
+
+ if (
+ device.name &&
+ device.deviceId &&
+ device.manufacturer &&
+ device.description &&
+ device.service
+ ) {
+ devices.push(device as DeviceInfo)
+ }
+ })
+
+ return devices.find(
+ (device) =>
+ device.deviceId.includes(VendorID.MuditaHarmony) &&
+ device.deviceId.includes(ProductID.MuditaHarmonyMsc)
+ )
+}
+
+export const parseToPortInfo = (device: DeviceInfo): PortInfo => {
+ const vendorId = /VID_(\w+)/.exec(device.deviceId)?.[1]
+ const productId = /PID_(\w+)/.exec(device.deviceId)?.[1]
+ const serialNumber = device.deviceId.split("\\").pop()
+
+ return {
+ path: `${vendorId}/${productId}/${serialNumber}`,
+ manufacturer: "MUDITA",
+ serialNumber: serialNumber,
+ productId,
+ vendorId,
+ }
+}
+
+export const getUsbDevicesWindows = async (): Promise => {
+ try {
+ const stdout = await execPromise(
+ `powershell -Command "Get-CimInstance Win32_PnPEntity | Where-Object { $_.DeviceID -like 'USB*' } | Select-Object Name, DeviceID, Manufacturer, Description, Service"`
+ )
+ if (stdout) {
+ const harmonyDevice = getHarmonyMSCDevice(stdout as string)
+ if (harmonyDevice) {
+ return parseToPortInfo(harmonyDevice)
+ }
+ }
+ } catch (error) {
+ console.error(error)
+ }
+}
diff --git a/libs/core/device-manager/services/usb-devices/usb-devices.helper.ts b/libs/core/device-manager/services/usb-devices/usb-devices.helper.ts
new file mode 100644
index 0000000000..e3b5ab1e8f
--- /dev/null
+++ b/libs/core/device-manager/services/usb-devices/usb-devices.helper.ts
@@ -0,0 +1,23 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { getUsbDevicesLinux } from "./usb-devices-linux.helper"
+import { getUsbDevicesMacOS } from "./usb-devices-mac.helper"
+import { getUsbDevicesWindows } from "./usb-devices-windows.helper"
+import { PortInfo } from "serialport"
+
+export async function getUsbDevices(): Promise {
+ try {
+ if (process.platform === "darwin") {
+ return await getUsbDevicesMacOS()
+ } else if (process.platform === "linux") {
+ return await getUsbDevicesLinux()
+ } else if (process.platform === "win32") {
+ return await getUsbDevicesWindows()
+ }
+ } catch (error) {
+ console.error("During USB device detection, an error occured: ", error)
+ }
+}
diff --git a/libs/core/device-select/components/device-select-drawer.component.tsx b/libs/core/device-select/components/device-select-drawer.component.tsx
index 93dc51812d..88bede757b 100644
--- a/libs/core/device-select/components/device-select-drawer.component.tsx
+++ b/libs/core/device-select/components/device-select-drawer.component.tsx
@@ -3,14 +3,19 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import "react-modern-drawer/dist/index.css"
+import Drawer from "react-modern-drawer"
import * as React from "react"
import { useSelector, useDispatch } from "react-redux"
+import { useHistory } from "react-router-dom"
+import { defineMessages } from "react-intl"
+import {
+ getFailedDevicesSelector,
+ setSelectDeviceDrawerOpen,
+} from "device-manager/feature"
import { Dispatch } from "Core/__deprecated__/renderer/store"
-import Drawer from "react-modern-drawer"
-import "react-modern-drawer/dist/index.css"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { isSelectDeviceDrawerOpenSelector } from "Core/device-select/selectors/is-select-device-drawer-open.selector"
-import { setSelectDeviceDrawerOpen } from "Core/device-select/actions/set-select-device-drawer-open.action"
import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
@@ -18,22 +23,25 @@ import styled from "styled-components"
import { Close } from "Core/__deprecated__/renderer/components/core/modal/modal.styled.elements"
import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-import { getAvailableDevicesSelector } from "Core/device-manager/selectors/get-available-devices.selector"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
-import { useHistory } from "react-router-dom"
-import { handleDeviceActivated } from "Core/device-manager/actions/handle-device-activated.action"
-import { deactivateDevice } from "Core/device-manager/actions/deactivate-device.action"
-import { DeviceState } from "Core/device-manager/reducers/device-manager.interface"
+import {
+ getAvailableDevicesSelector,
+ deactivateDevice,
+ handleDeviceActivated,
+} from "device-manager/feature"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
import {
URL_DEVICE_INITIALIZATION,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
import { DrawerDevice } from "Core/device-select/components/drawer-device.component"
-import { defineMessages } from "react-intl"
import { DeviceId } from "Core/device/constants/device-id"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
import { useEffect } from "react"
+const dataTestIds = {
+ drawerContent: "device-select-drawer-content",
+}
+
const messages = defineMessages({
changeDevice: { id: "component.drawer.headerTitle" },
})
@@ -76,14 +84,15 @@ const DevicesContainer = styled("div")`
const DeviceSelectDrawer: FunctionComponent = () => {
const isOpen = useSelector(isSelectDeviceDrawerOpenSelector)
const devices = useSelector(getAvailableDevicesSelector)
+ const failedDevices = useSelector(getFailedDevicesSelector)
const activeDeviceId = useSelector(activeDeviceIdSelector)
const dispatch = useDispatch()
const history = useHistory()
const handleDrawerDeviceClick = async (id: DeviceId) => {
dispatch(setSelectDeviceDrawerOpen(false))
- const device = devices.find((device) => device.id === id)
- if (device?.state === DeviceState.Failed) {
+ const failedDevice = failedDevices.find((device) => device.id === id)
+ if (failedDevice !== undefined) {
await dispatch(handleDeviceActivated(id))
history.push(URL_ONBOARDING.troubleshooting)
} else {
@@ -110,7 +119,7 @@ const DeviceSelectDrawer: FunctionComponent = () => {
size="36.9rem"
zIndex={ModalLayers.Drawer}
>
-
+
`
padding: 1.8rem 2.4rem 1.8rem 1rem;
@@ -29,6 +39,8 @@ const Device = styled("div")<{ active: boolean }>`
min-width: 27.2rem;
max-width: 27.2rem;
+ position: relative;
+
&:hover {
background: ${backgroundColor("main")};
cursor: pointer;
@@ -66,6 +78,7 @@ export const DeviceImageStyled = styled(DeviceImage)`
max-width: 4.2rem;
`
case DeviceType.MuditaHarmony:
+ case DeviceType.MuditaHarmonyMsc:
return css`
max-height: 7.5rem;
max-width: 7rem;
@@ -122,14 +135,32 @@ export const DrawerDevice: FunctionComponent = ({
active={deviceId == activeDeviceId}
key={deviceId}
onClick={deviceId === activeDeviceId ? () => {} : onClick}
+ data-testid={`${dataTestIds.drawerDeviceWrapper}-${serialNumberValue}`}
>
+ {deviceType === DeviceType.MuditaHarmonyMsc && (
+
+
+
+ {intl.formatMessage({
+ id: "module.availableDeviceList.recoveryMode",
+ })}
+
+
+ )}
-
+
-
+
{getDeviceTypeName(deviceType, caseColour)}
{deviceId === activeDeviceId &&
intl.formatMessage({
@@ -137,7 +168,7 @@ export const DrawerDevice: FunctionComponent = ({
})}
- {serialNumberValue && (
+ {serialNumberValue && deviceType !== DeviceType.MuditaHarmonyMsc && (
<>
= ({
id: "module.availableDeviceList.serialNumber",
})}
-
+
{serialNumberValue}
>
diff --git a/libs/core/device-select/selectors/is-select-device-drawer-open.selector.ts b/libs/core/device-select/selectors/is-select-device-drawer-open.selector.ts
index 03983429ca..2d39476d54 100644
--- a/libs/core/device-select/selectors/is-select-device-drawer-open.selector.ts
+++ b/libs/core/device-select/selectors/is-select-device-drawer-open.selector.ts
@@ -4,7 +4,7 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
+import { deviceManagerState } from "device-manager/feature"
export const isSelectDeviceDrawerOpenSelector = createSelector(
deviceManagerState,
diff --git a/libs/core/device/actions/base.action.ts b/libs/core/device/actions/base.action.ts
index 6cfd194928..e4f4f8c474 100644
--- a/libs/core/device/actions/base.action.ts
+++ b/libs/core/device/actions/base.action.ts
@@ -11,7 +11,6 @@ export const setLockTime = createAction<
GetPhoneLockTimeResponseBody | undefined
>(DeviceEvent.SetLockTime)
-export const setInitState = createAction(DeviceEvent.SetInitState)
export const setOnboardingStatus = createAction(
DeviceEvent.SetOnboardingStatus
)
@@ -27,4 +26,6 @@ export const setExternalUsageDevice = createAction(
DeviceEvent.SetExternalUsageDevice
)
-export const setRestartingStatus = createAction(DeviceEvent.SetRestartingStatus)
+export const setRestartingStatus = createAction(
+ DeviceEvent.SetRestartingStatus
+)
diff --git a/libs/core/device/actions/get-onboarding-status.action.ts b/libs/core/device/actions/get-onboarding-status.action.ts
index 62351e2d70..b16f835410 100644
--- a/libs/core/device/actions/get-onboarding-status.action.ts
+++ b/libs/core/device/actions/get-onboarding-status.action.ts
@@ -4,10 +4,11 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
-import { DeviceCommunicationError, DeviceEvent } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceEvent } from "Core/device/constants"
import { unlockDeviceStatusRequest } from "Core/device/requests"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
+import { getActiveDevice } from "device-manager/feature"
export const getOnboardingStatus = createAsyncThunk<
boolean,
diff --git a/libs/core/device/actions/get-unlock-status.action.ts b/libs/core/device/actions/get-unlock-status.action.ts
index 1e5d686725..d9038f8db7 100644
--- a/libs/core/device/actions/get-unlock-status.action.ts
+++ b/libs/core/device/actions/get-unlock-status.action.ts
@@ -4,7 +4,8 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
-import { DeviceCommunicationError, DeviceEvent } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceEvent } from "Core/device/constants"
import { unlockDeviceStatusRequest } from "Core/device/requests"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { setLockTime, setUnlockedStatus } from "Core/device/actions/base.action"
diff --git a/libs/core/device/actions/handle-communication-error.action.ts b/libs/core/device/actions/handle-communication-error.action.ts
index 42569134bc..4323e03b09 100644
--- a/libs/core/device/actions/handle-communication-error.action.ts
+++ b/libs/core/device/actions/handle-communication-error.action.ts
@@ -4,7 +4,8 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
-import { DeviceCommunicationError, DeviceEvent } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceEvent } from "Core/device/constants"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import {
setCriticalBatteryLevelStatus,
diff --git a/libs/core/device/actions/load-device-data.action.ts b/libs/core/device/actions/load-device-data.action.ts
index 6715c14174..7a54449638 100644
--- a/libs/core/device/actions/load-device-data.action.ts
+++ b/libs/core/device/actions/load-device-data.action.ts
@@ -8,7 +8,7 @@ import { DeviceEvent } from "Core/device/constants"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { getDeviceInfoRequest } from "Core/device-info/requests"
import { DeviceInfo } from "Core/device-info/dto"
-import { getActiveDeviceTypeSelector } from "Core/device-manager/selectors/get-active-device-type.selector"
+import { getActiveDeviceTypeSelector } from "device-manager/feature"
import { DeviceState } from "Core/device/reducers"
import { processDeviceDataOnLoad } from "Core/device/actions/process-device-data-on-load.action"
import { handleCommunicationError } from "Core/device/actions/handle-communication-error.action"
diff --git a/libs/core/device/actions/process-device-data-on-load.action.ts b/libs/core/device/actions/process-device-data-on-load.action.ts
index 7cd5f044ca..3c91e412ff 100644
--- a/libs/core/device/actions/process-device-data-on-load.action.ts
+++ b/libs/core/device/actions/process-device-data-on-load.action.ts
@@ -10,7 +10,7 @@ import { setExternalUsageDevice } from "Core/device/actions/base.action"
import { externalUsageDevice } from "Core/device/requests/external-usage-device.request"
import { setExternalUsageDeviceRequest } from "Core/analytic-data-tracker/requests/set-external-usage-device.request"
import { settingsStateSelector } from "Core/settings/selectors"
-import { getActiveDeviceBaseDataSelector } from "Core/device-manager/selectors/get-active-device-base-data.selector"
+import { getActiveDeviceBaseDataSelector } from "device-manager/feature"
import { trackOsVersion } from "Core/analytic-data-tracker/helpers"
import { MetadataKey, setValue } from "Core/metadata"
diff --git a/libs/core/device/actions/unlock-device.action.ts b/libs/core/device/actions/unlock-device.action.ts
index d5cae8fd7d..60ba2d40d6 100644
--- a/libs/core/device/actions/unlock-device.action.ts
+++ b/libs/core/device/actions/unlock-device.action.ts
@@ -5,11 +5,8 @@
import { createAsyncThunk, PayloadAction } from "@reduxjs/toolkit"
import { delay } from "shared/utils"
-import {
- DeviceCommunicationError,
- DeviceError,
- DeviceEvent,
-} from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceError, DeviceEvent } from "Core/device/constants"
import {
unlockDeviceRequest,
unlockDeviceStatusRequest,
diff --git a/libs/core/device/constants/event.enum.ts b/libs/core/device/constants/event.enum.ts
index 5efff9a964..e22b23bfa8 100644
--- a/libs/core/device/constants/event.enum.ts
+++ b/libs/core/device/constants/event.enum.ts
@@ -4,8 +4,6 @@
*/
export enum DeviceEvent {
- SetInitState = "DEVICE_SET_INIT_STATE",
-
Unlock = "DEVICE_UNLOCK",
UnlockById = "DEVICE_UNLOCK_BY_ID",
Locked = "DEVICE_LOCKED",
diff --git a/libs/core/device/constants/index.ts b/libs/core/device/constants/index.ts
index 1df4ed5902..fc5d1830af 100644
--- a/libs/core/device/constants/index.ts
+++ b/libs/core/device/constants/index.ts
@@ -7,16 +7,12 @@ export * from "./access-technology.constant"
export * from "./backup-category.constant"
export * from "./backup-state.constant"
export * from "./battery-state.constant"
-export * from "./case-colour.constant"
export * from "./connection-timeout.constant"
export * from "./controller.constant"
-export * from "./device-communication-error.constant"
-export * from "./device-type.constant"
export * from "./device-communication-event.constant"
export * from "./device-update-error.constant"
export * from "./diagnostic-file.constant"
export * from "./diagnostics-file-path.constant"
-export * from "./endpoint.constant"
export * from "./errors.enum"
export * from "./event.enum"
export * from "./manufactures.constant"
@@ -29,7 +25,6 @@ export * from "./outbox-entry-change.constant"
export * from "./outbox-entry-type.constant"
export * from "./phone-lock-category.type"
export * from "./product-identifier.constant"
-export * from "./request-method.constant"
export * from "./response-status.constant"
export * from "./restore-state.constant"
export * from "./signal-strength.constant"
diff --git a/libs/core/device/constants/product-identifier.constant.ts b/libs/core/device/constants/product-identifier.constant.ts
index b82eb27aea..3f5a673472 100644
--- a/libs/core/device/constants/product-identifier.constant.ts
+++ b/libs/core/device/constants/product-identifier.constant.ts
@@ -7,6 +7,7 @@ export enum ProductID {
MuditaPure = "0102",
MuditaPureDeprecated = "0100",
MuditaHarmony = "0300",
+ MuditaHarmonyMsc = "0103",
MuditaKompaktChargeHex = "2006", //0x2006
MuditaKompaktTransferHex = "200a", //0x200a
MuditaKompaktNoDebugHex = "2012", //0x2012
diff --git a/libs/core/device/descriptors/device-descriptor.ts b/libs/core/device/descriptors/device-descriptor.ts
index 60f42f5707..2b952df2ac 100644
--- a/libs/core/device/descriptors/device-descriptor.ts
+++ b/libs/core/device/descriptors/device-descriptor.ts
@@ -3,12 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- Manufacture,
- VendorID,
- ProductID,
- DeviceType,
-} from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { Manufacture, VendorID, ProductID } from "Core/device/constants"
import { PureStrategy, HarmonyStrategy } from "Core/device/strategies"
import { SerialPortDeviceAdapter } from "Core/device/modules/mudita-os/adapters/serial-port-device.adapters"
diff --git a/libs/core/device/descriptors/index.ts b/libs/core/device/descriptors/index.ts
index 0739a5d30c..780d308a79 100644
--- a/libs/core/device/descriptors/index.ts
+++ b/libs/core/device/descriptors/index.ts
@@ -5,5 +5,6 @@
export * from "./mudita-pure.descriptor"
export * from "./mudita-harmony.descriptor"
+export * from "./mudita-harmony-msc.descriptor"
export * from "./mudita-kompakt.descriptor"
export * from "./device-descriptor"
diff --git a/libs/core/device/descriptors/mudita-harmony-msc.descriptor.ts b/libs/core/device/descriptors/mudita-harmony-msc.descriptor.ts
new file mode 100644
index 0000000000..b7a6d06a41
--- /dev/null
+++ b/libs/core/device/descriptors/mudita-harmony-msc.descriptor.ts
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { Manufacture, VendorID, ProductID } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { HarmonyStrategy } from "Core/device/strategies"
+import { SerialPortDeviceAdapter } from "Core/device/modules/mudita-os/adapters"
+
+export class MuditaHarmonyMscDescriptor {
+ static manufacturer = Manufacture.Mudita
+ static deviceType = DeviceType.MuditaHarmonyMsc
+ static productIds = [ProductID.MuditaHarmonyMsc]
+ static vendorIds = [VendorID.MuditaHarmony]
+ static adapter = SerialPortDeviceAdapter
+ static strategy = HarmonyStrategy
+}
diff --git a/libs/core/device/descriptors/mudita-harmony.descriptor.ts b/libs/core/device/descriptors/mudita-harmony.descriptor.ts
index a10452a9df..54b43a1258 100644
--- a/libs/core/device/descriptors/mudita-harmony.descriptor.ts
+++ b/libs/core/device/descriptors/mudita-harmony.descriptor.ts
@@ -3,12 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- Manufacture,
- VendorID,
- ProductID,
- DeviceType,
-} from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { Manufacture, VendorID, ProductID } from "Core/device/constants"
import { HarmonyStrategy } from "Core/device/strategies"
import { SerialPortDeviceAdapter } from "Core/device/modules/mudita-os/adapters"
diff --git a/libs/core/device/descriptors/mudita-pure.descriptor.ts b/libs/core/device/descriptors/mudita-pure.descriptor.ts
index d9c44f28f8..49f23424bc 100644
--- a/libs/core/device/descriptors/mudita-pure.descriptor.ts
+++ b/libs/core/device/descriptors/mudita-pure.descriptor.ts
@@ -3,12 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import {
- Manufacture,
- VendorID,
- ProductID,
- DeviceType,
-} from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
+import { Manufacture, VendorID, ProductID } from "Core/device/constants"
import { PureStrategy } from "Core/device/strategies"
import { SerialPortDeviceAdapter } from "Core/device/modules/mudita-os/adapters"
diff --git a/libs/core/device/device.module.ts b/libs/core/device/device.module.ts
index 686faef37d..d96b51412b 100644
--- a/libs/core/device/device.module.ts
+++ b/libs/core/device/device.module.ts
@@ -12,12 +12,12 @@ import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { DeviceService } from "Core/device/services"
import { DeviceController } from "Core/device/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class DeviceModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -26,7 +26,7 @@ export class DeviceModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -34,7 +34,7 @@ export class DeviceModule extends BaseModule {
fileSystem
)
- const deviceService = new DeviceService(this.deviceManager)
+ const deviceService = new DeviceService(this.deviceProtocol)
const deviceController = new DeviceController(deviceService)
this.controllers = [deviceController]
diff --git a/libs/core/device/factories/device.factory.ts b/libs/core/device/factories/device.factory.ts
index 6e5a5bd425..905f5f8718 100644
--- a/libs/core/device/factories/device.factory.ts
+++ b/libs/core/device/factories/device.factory.ts
@@ -5,7 +5,7 @@
import { PortInfo } from "serialport"
import { CoreDevice } from "Core/device/modules/core-device"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { DeviceDescriptor } from "Core/device/descriptors"
export class DeviceFactory {
diff --git a/libs/core/device/modules/base-device.ts b/libs/core/device/modules/base-device.ts
index f095d15632..f96532fd3c 100644
--- a/libs/core/device/modules/base-device.ts
+++ b/libs/core/device/modules/base-device.ts
@@ -5,9 +5,8 @@
import { PortInfo } from "serialport"
import { ResultObject } from "Core/core/builder"
-import { DeviceBaseProperties } from "Core/device/constants/device-base-properties"
+import { DeviceBaseProperties, DeviceType } from "device-protocol/models"
import { DeviceId } from "Core/device/constants/device-id"
-import { DeviceType } from "Core/device"
import { unknownSerialNumber } from "Core/device/constants/unknown-serial-number.constant"
const uniqueId = (length = 16): DeviceId => {
diff --git a/libs/core/device/modules/base.adapter.ts b/libs/core/device/modules/base.adapter.ts
index 4f9f66bdad..88c54471ee 100644
--- a/libs/core/device/modules/base.adapter.ts
+++ b/libs/core/device/modules/base.adapter.ts
@@ -32,7 +32,7 @@ export abstract class BaseAdapter<
public connect(): Promise> {
return new Promise((resolve) => {
- this.serialPort = new SerialPort(this.path, (error) => {
+ const serialPort = new SerialPort(this.path, (error) => {
if (error) {
resolve(
Result.failed(
@@ -40,6 +40,7 @@ export abstract class BaseAdapter<
)
)
} else {
+ this.serialPort = serialPort
resolve(Result.success(undefined))
}
})
diff --git a/libs/core/device/modules/core-device.ts b/libs/core/device/modules/core-device.ts
index a3838e695d..ff7c4766c3 100644
--- a/libs/core/device/modules/core-device.ts
+++ b/libs/core/device/modules/core-device.ts
@@ -5,7 +5,8 @@
import { PortInfo } from "serialport"
import { ResultObject } from "Core/core/builder"
-import { DeviceCommunicationError, DeviceType } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { RequestConfig } from "Core/device/types/mudita-os"
import { DeviceStrategy } from "Core/device/strategies/device-strategy.class"
import { BaseDevice } from "Core/device/modules/base-device"
diff --git a/libs/core/device/modules/device.class.ts b/libs/core/device/modules/device.class.ts
index 5982f9873a..242db6ff01 100644
--- a/libs/core/device/modules/device.class.ts
+++ b/libs/core/device/modules/device.class.ts
@@ -3,9 +3,10 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceType } from "device-protocol/models"
import { ResultObject } from "Core/core/builder"
import { RequestConfig, Response } from "Core/device/types/mudita-os"
-import { DeviceCommunicationEvent, DeviceType } from "Core/device/constants"
+import { DeviceCommunicationEvent } from "Core/device/constants"
export interface DeviceFactoryClass {
path: string
diff --git a/libs/core/device/modules/mock-core-device.ts b/libs/core/device/modules/mock-core-device.ts
index c3e9b1e8ec..a854941648 100644
--- a/libs/core/device/modules/mock-core-device.ts
+++ b/libs/core/device/modules/mock-core-device.ts
@@ -5,7 +5,8 @@
import { PortInfo } from "serialport"
import { Result, ResultObject } from "Core/core/builder"
-import { DeviceCommunicationError, DeviceType } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { RequestConfig } from "Core/device/types/mudita-os"
import { BaseDevice } from "Core/device/modules/base-device"
import { AppError } from "Core/core/errors"
diff --git a/libs/core/device/modules/mudita-os/adapters/serial-port-device.adapters.ts b/libs/core/device/modules/mudita-os/adapters/serial-port-device.adapters.ts
index 7669216775..1faaace478 100644
--- a/libs/core/device/modules/mudita-os/adapters/serial-port-device.adapters.ts
+++ b/libs/core/device/modules/mudita-os/adapters/serial-port-device.adapters.ts
@@ -8,7 +8,8 @@ import { ipcMain } from "electron-better-ipc"
import { log, LogConfig } from "Core/core/decorators/log.decorator"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { CONNECTION_TIME_OUT_MS, Endpoint } from "Core/device/constants"
+import { Endpoint } from "core-device/models"
+import { CONNECTION_TIME_OUT_MS } from "Core/device/constants"
import { DeviceCommunicationEvent, ResponseStatus } from "Core/device/constants"
import { DeviceError } from "Core/device/modules/mudita-os/constants"
import { SerialPortParser } from "Core/device/modules/mudita-os/parsers"
diff --git a/libs/core/device/reducers/device.interface.ts b/libs/core/device/reducers/device.interface.ts
index d6d8cb5246..d93cc9309f 100644
--- a/libs/core/device/reducers/device.interface.ts
+++ b/libs/core/device/reducers/device.interface.ts
@@ -3,7 +3,9 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { CaseColour, DeviceType, OnboardingState } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
+import { OnboardingState } from "Core/device/constants"
import { SimCard } from "Core/__deprecated__/renderer/models/basic-info/basic-info.typings"
export interface KompaktDeviceData {
diff --git a/libs/core/device/reducers/device.reducer.ts b/libs/core/device/reducers/device.reducer.ts
index 83bc95072a..ef8cf7297f 100644
--- a/libs/core/device/reducers/device.reducer.ts
+++ b/libs/core/device/reducers/device.reducer.ts
@@ -4,11 +4,11 @@
*/
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import {
loadDeviceData,
loadStorageInfoAction,
setCriticalBatteryLevelStatus,
- setInitState,
setLockTime,
setOnboardingStatus,
setRestartingStatus,
@@ -17,6 +17,7 @@ import {
import { DeviceState } from "Core/device/reducers/device.interface"
import { AppError } from "Core/core/errors"
import { getOnboardingStatus } from "Core/device/actions/get-onboarding-status.action"
+import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
export const initialState: DeviceState = {
deviceType: null,
@@ -36,7 +37,7 @@ export const deviceReducer = createReducer(
initialState,
(builder) => {
builder
- .addCase(setInitState, () => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return {
...initialState,
}
diff --git a/libs/core/device/requests/unlock-device-status.request.ts b/libs/core/device/requests/unlock-device-status.request.ts
index 5f9cab17e3..08ea5c7834 100644
--- a/libs/core/device/requests/unlock-device-status.request.ts
+++ b/libs/core/device/requests/unlock-device-status.request.ts
@@ -4,8 +4,9 @@
*/
import { ipcRenderer } from "electron-better-ipc"
+import { DeviceCommunicationError } from "core-device/models"
import { ResultObject } from "Core/core/builder"
-import { DeviceCommunicationError, IpcDeviceEvent } from "Core/device/constants"
+import { IpcDeviceEvent } from "Core/device/constants"
import { DeviceId } from "Core/device/constants/device-id"
export const unlockDeviceStatusRequest = async (
diff --git a/libs/core/device/selectors/device-type.selector.ts b/libs/core/device/selectors/device-type.selector.ts
index 6f853c6531..f2ede3ab7a 100644
--- a/libs/core/device/selectors/device-type.selector.ts
+++ b/libs/core/device/selectors/device-type.selector.ts
@@ -4,7 +4,7 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { deviceStateSelector } from "Core/device/selectors/device-state.selector"
export const deviceTypeSelector = createSelector(
diff --git a/libs/core/device-manager/selectors/is-active-device-processing.selector.ts b/libs/core/device/selectors/is-active-device-processing.selector.ts
similarity index 89%
rename from libs/core/device-manager/selectors/is-active-device-processing.selector.ts
rename to libs/core/device/selectors/is-active-device-processing.selector.ts
index 24f51c2e93..e979522506 100644
--- a/libs/core/device-manager/selectors/is-active-device-processing.selector.ts
+++ b/libs/core/device/selectors/is-active-device-processing.selector.ts
@@ -4,8 +4,8 @@
*/
import { createSelector } from "@reduxjs/toolkit"
+import { isActiveDeviceSet } from "active-device-registry/feature"
import { backupStateSelector } from "Core/backup"
-import { isActiveDeviceSet } from "Core/device-manager/selectors/is-active-device-set.selector"
import { updateStateSelector } from "Core/update/selectors/update-state-selector"
import { State } from "Core/core/constants"
diff --git a/libs/core/device/services/device.service.ts b/libs/core/device/services/device.service.ts
index 30eb1bf4e4..e312474b9d 100644
--- a/libs/core/device/services/device.service.ts
+++ b/libs/core/device/services/device.service.ts
@@ -4,25 +4,21 @@
*/
import { Result, ResultObject } from "Core/core/builder"
-import {
- DeviceCommunicationError,
- Endpoint,
- Method,
- PhoneLockCategory,
-} from "Core/device/constants"
+import { PhoneLockCategory } from "Core/device/constants"
+import { DeviceCommunicationError, Endpoint, Method } from "core-device/models"
import { PhoneLockTime } from "Core/device/dto"
import { GetPhoneLockTimeResponseBody } from "Core/device/types/mudita-os"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
export class DeviceService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
public async unlock(
code: string,
- deviceId: DeviceId = this.deviceManager.device.id
+ deviceId: DeviceId = this.deviceProtocol.device.id
): Promise> {
- const response = await this.deviceManager.request(deviceId, {
+ const response = await this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.Security,
method: Method.Put,
body: {
@@ -34,9 +30,9 @@ export class DeviceService {
}
public async unlockStatus(
- deviceId: DeviceId = this.deviceManager.device.id
+ deviceId: DeviceId = this.deviceProtocol.device.id
): Promise> {
- return this.deviceManager.request(deviceId, {
+ return this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Status },
@@ -44,9 +40,9 @@ export class DeviceService {
}
public async unlockTime(
- deviceId: DeviceId = this.deviceManager.device.id
+ deviceId: DeviceId = this.deviceProtocol.device.id
): Promise> {
- return this.deviceManager.request(deviceId, {
+ return this.deviceProtocol.request(deviceId, {
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Time },
diff --git a/libs/core/device/strategies/device-strategy.class.ts b/libs/core/device/strategies/device-strategy.class.ts
index 8d50e9af67..5f42edcfa2 100644
--- a/libs/core/device/strategies/device-strategy.class.ts
+++ b/libs/core/device/strategies/device-strategy.class.ts
@@ -5,7 +5,7 @@
import { RequestConfig } from "Core/device/types/mudita-os"
import { ResultObject } from "Core/core/builder"
-import { DeviceCommunicationError } from "Core/device"
+import { DeviceCommunicationError } from "core-device/models"
export interface DeviceStrategy {
connect(): Promise>
diff --git a/libs/core/device/strategies/harmony.strategy.ts b/libs/core/device/strategies/harmony.strategy.ts
index 048d917586..fb32efacab 100644
--- a/libs/core/device/strategies/harmony.strategy.ts
+++ b/libs/core/device/strategies/harmony.strategy.ts
@@ -14,7 +14,7 @@ import {
import { Result, ResultObject } from "Core/core/builder"
import { BaseAdapter } from "Core/device/modules/base.adapter"
import { AppError } from "Core/core/errors"
-import { DeviceCommunicationError } from "Core/device"
+import { DeviceCommunicationError } from "core-device/models"
export class HarmonyStrategy implements DeviceStrategy {
constructor(private adapter: BaseAdapter) {
diff --git a/libs/core/device/strategies/pure.strategy.ts b/libs/core/device/strategies/pure.strategy.ts
index 4965f7f869..4564a885af 100644
--- a/libs/core/device/strategies/pure.strategy.ts
+++ b/libs/core/device/strategies/pure.strategy.ts
@@ -4,7 +4,7 @@
*/
import { callRenderer } from "shared/utils"
-import { DeviceCommunicationError } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
import { RequestConfig } from "Core/device/types/mudita-os"
import {
RequestResponse,
diff --git a/libs/core/device/types/mudita-os/request-config.type.ts b/libs/core/device/types/mudita-os/request-config.type.ts
index 29fa4bf9b4..d13467ba08 100644
--- a/libs/core/device/types/mudita-os/request-config.type.ts
+++ b/libs/core/device/types/mudita-os/request-config.type.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { Endpoint, Method } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
export interface RequestConfigOptions {
connectionTimeOut?: number
diff --git a/libs/core/device/types/mudita-os/response.type.ts b/libs/core/device/types/mudita-os/response.type.ts
index a111d596b1..a53741f744 100644
--- a/libs/core/device/types/mudita-os/response.type.ts
+++ b/libs/core/device/types/mudita-os/response.type.ts
@@ -3,7 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { ResponseStatus, Endpoint } from "Core/device/constants"
+import { Endpoint } from "core-device/models"
+import { ResponseStatus } from "Core/device/constants"
import { ResponseError } from "Core/device/types/mudita-os/response-error.type"
export interface Response {
diff --git a/libs/core/device/types/mudita-os/serialport-request.type.ts b/libs/core/device/types/mudita-os/serialport-request.type.ts
index ae406173d5..8cf57d0561 100644
--- a/libs/core/device/types/mudita-os/serialport-request.type.ts
+++ b/libs/core/device/types/mudita-os/serialport-request.type.ts
@@ -3,10 +3,10 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { CaseColour } from "core-device/models"
+import { Endpoint, Method } from "core-device/models"
import {
BackupCategory,
- Method,
- Endpoint,
BackupState,
BatteryState,
SIM,
@@ -14,7 +14,6 @@ import {
Tray,
AccessTechnology,
NetworkStatus,
- CaseColour,
DiagnosticsFileList,
PhoneLockCategory,
MessageType,
diff --git a/libs/core/device/types/serial-port-device.type.ts b/libs/core/device/types/serial-port-device.type.ts
index d907fe1662..b3472a07c9 100644
--- a/libs/core/device/types/serial-port-device.type.ts
+++ b/libs/core/device/types/serial-port-device.type.ts
@@ -3,8 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceType } from "device-protocol/models"
import { DeviceEvent } from "Core/device/constants"
-import { DeviceType } from "Core/device/constants"
import { RequestConfig, Response } from "Core/device/types/mudita-os"
export interface SerialPortDevice {
diff --git a/libs/core/discovery-device/components/available-device-list.component.tsx b/libs/core/discovery-device/components/available-device-list.component.tsx
index 7af0e3a280..2bdd183b07 100644
--- a/libs/core/discovery-device/components/available-device-list.component.tsx
+++ b/libs/core/discovery-device/components/available-device-list.component.tsx
@@ -9,19 +9,21 @@ import styled from "styled-components"
import { useHistory } from "react-router-dom"
import { useDispatch, useSelector } from "react-redux"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { DeviceState } from "Core/device-manager/reducers/device-manager.interface"
import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { fontWeight } from "Core/core/styles/theming/theme-getters"
import DeviceList from "Core/discovery-device/components/device-list.component"
import { Dispatch } from "Core/__deprecated__/renderer/store"
-import { getAvailableDevicesSelector } from "Core/device-manager/selectors/get-available-devices.selector"
+import {
+ getAvailableDevicesSelector,
+ getFailedDevicesSelector,
+ handleDeviceActivated,
+} from "device-manager/feature"
import {
URL_DEVICE_INITIALIZATION,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
-import { handleDeviceActivated } from "Core/device-manager/actions/handle-device-activated.action"
const messages = defineMessages({
headerTitle: { id: "module.availableDeviceList.headerTitle" },
@@ -52,10 +54,11 @@ const AvailableDeviceList: FunctionComponent = () => {
const history = useHistory()
const dispatch = useDispatch()
const devices = useSelector(getAvailableDevicesSelector)
+ const failedDevices = useSelector(getFailedDevicesSelector)
const handleDeviceClick = async (id: string) => {
- const device = devices.find((device) => device.id === id)
- if (device?.state === DeviceState.Failed) {
+ const failedDevice = failedDevices.find((device) => device.id === id)
+ if (failedDevice !== undefined) {
await dispatch(handleDeviceActivated(id))
history.push(URL_ONBOARDING.troubleshooting)
} else {
diff --git a/libs/core/discovery-device/components/available-device-list.container.tsx b/libs/core/discovery-device/components/available-device-list.container.tsx
index dc51c25840..e3d5764622 100644
--- a/libs/core/discovery-device/components/available-device-list.container.tsx
+++ b/libs/core/discovery-device/components/available-device-list.container.tsx
@@ -8,7 +8,7 @@ import { useDispatch, useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import AvailableDeviceList from "Core/discovery-device/components/available-device-list.component"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
+import { getDevicesSelector } from "device-manager/feature"
import { Dispatch } from "Core/__deprecated__/renderer/store"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
diff --git a/libs/core/discovery-device/components/configured-devices-discovery.component.tsx b/libs/core/discovery-device/components/configured-devices-discovery.component.tsx
index 028ceba43a..28882879a1 100644
--- a/libs/core/discovery-device/components/configured-devices-discovery.component.tsx
+++ b/libs/core/discovery-device/components/configured-devices-discovery.component.tsx
@@ -10,22 +10,26 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface"
import ConnectingContent from "Core/connecting/components/connecting-content.component"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
-import { handleDeviceActivated } from "Core/device-manager/actions/handle-device-activated.action"
-import { Dispatch } from "Core/__deprecated__/renderer/store"
+import {
+ getAvailableDevicesSelector,
+ getDevicesSelector,
+ getFailedDevicesSelector,
+ handleDeviceActivated,
+} from "device-manager/feature"
+import { DeviceType } from "device-protocol/models"
+import { getAPIConfig } from "generic-view/store"
+import { TmpDispatch } from "Core/__deprecated__/renderer/store"
import {
URL_DEVICE_INITIALIZATION,
URL_DISCOVERY_DEVICE,
URL_MAIN,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
-import { getAvailableDevicesSelector } from "Core/device-manager/selectors/get-available-devices.selector"
-import { getFailedDevicesSelector } from "Core/device-manager/selectors/get-failed-devices.selector"
import { useNoNewDevicesDetectedHook } from "Core/discovery-device/hooks/use-no-new-devices-detected.hook"
const ConfiguredDevicesDiscovery: FunctionComponent = () => {
const history = useHistory()
- const dispatch = useDispatch()
+ const dispatch = useDispatch()
const devices = useSelector(getDevicesSelector)
const failedDevices = useSelector(getFailedDevicesSelector)
const availableDevices = useSelector(getAvailableDevicesSelector)
@@ -43,9 +47,23 @@ const ConfiguredDevicesDiscovery: FunctionComponent = () => {
failedDevices.length === 1 &&
noNewDevicesDetectedState
) {
- await dispatch(handleDeviceActivated(devices[0].id))
- history.push(URL_ONBOARDING.troubleshooting)
- return
+ if (devices[0].deviceType === DeviceType.APIDevice) {
+ const getAPIConfigResult = await dispatch(
+ getAPIConfig({ deviceId: devices[0].id })
+ )
+ await dispatch(handleDeviceActivated(devices[0].id))
+ if (getAPIConfigResult.error !== undefined) {
+ history.push(URL_ONBOARDING.troubleshooting)
+ } else {
+ history.push(URL_DEVICE_INITIALIZATION.root)
+ }
+
+ return
+ } else {
+ await dispatch(handleDeviceActivated(devices[0].id))
+ history.push(URL_ONBOARDING.troubleshooting)
+ return
+ }
}
if (
@@ -70,18 +88,24 @@ const ConfiguredDevicesDiscovery: FunctionComponent = () => {
noNewDevicesDetectedState,
])
- const isAnyDeviceAttachedOnInitialRender = useRef(undefined)
+ const isAnyDeviceAttachedOnInitialRender = useRef(
+ undefined
+ )
useEffect(() => {
- if(isAnyDeviceAttachedOnInitialRender.current !== undefined){
+ if (isAnyDeviceAttachedOnInitialRender.current !== undefined) {
return
}
- isAnyDeviceAttachedOnInitialRender.current = devices.length > 0;
+ isAnyDeviceAttachedOnInitialRender.current = devices.length > 0
}, [devices])
useEffect(() => {
- if(!isAnyDeviceAttachedOnInitialRender.current && noNewDevicesDetectedState){
- history.push(URL_ONBOARDING.troubleshooting)
+ if (
+ !isAnyDeviceAttachedOnInitialRender.current &&
+ noNewDevicesDetectedState
+ ) {
+ dispatch(setDiscoveryStatus(DiscoveryStatus.Idle))
+ history.push(URL_ONBOARDING.root)
return
}
diff --git a/libs/core/discovery-device/components/device-connecting.component.tsx b/libs/core/discovery-device/components/device-connecting.component.tsx
index a26906ab88..dfce88c678 100644
--- a/libs/core/discovery-device/components/device-connecting.component.tsx
+++ b/libs/core/discovery-device/components/device-connecting.component.tsx
@@ -3,46 +3,71 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import React, { useEffect } from "react"
+import React, { useEffect, useRef } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
import { delay } from "shared/utils"
+import { connectDevice, getActiveDevice } from "device-manager/feature"
+import { configureDevice } from "core-device/feature"
+import { DeviceType } from "device-protocol/models"
+import { getAPIConfig } from "generic-view/store"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import ConnectingContent from "Core/connecting/components/connecting-content.component"
import { TmpDispatch } from "Core/__deprecated__/renderer/store"
-import { activeDeviceIdSelector } from "Core/device-manager/selectors/active-device-id.selector"
import {
URL_DEVICE_INITIALIZATION,
URL_DISCOVERY_DEVICE,
URL_ONBOARDING,
} from "Core/__deprecated__/renderer/constants/urls"
-import { connectDevice } from "Core/device-manager/actions/connect-device.action"
-import { configureDevice } from "Core/device-manager/actions/configure-device.action"
const DeviceConnecting: FunctionComponent = () => {
const history = useHistory()
const dispatch = useDispatch()
- const activeDeviceId = useSelector(activeDeviceIdSelector)
+ const activeDevice = useSelector(getActiveDevice)
+ const firstRun = useRef(true)
useEffect(() => {
+ if (!firstRun.current) {
+ return
+ }
+
+ firstRun.current = false
+
const handleConnectDevice = async () => {
- if (activeDeviceId !== undefined) {
- const { payload: ok } = await dispatch(connectDevice(activeDeviceId))
-
- if (ok) {
- await dispatch(configureDevice(activeDeviceId))
- history.push(URL_DEVICE_INITIALIZATION.root)
- } else {
- await delay(500)
+ if (activeDevice?.id === undefined) {
+ history.push(URL_DISCOVERY_DEVICE.root)
+ return
+ }
+
+ await delay(500)
+
+ if (activeDevice.deviceType !== DeviceType.APIDevice) {
+ const { payload: ok } = await dispatch(connectDevice(activeDevice.id))
+
+ if (!ok) {
history.push(URL_ONBOARDING.troubleshooting)
+ return
}
+
+ await dispatch(configureDevice(activeDevice.id))
+
+ history.push(URL_DEVICE_INITIALIZATION.root)
} else {
- history.push(URL_DISCOVERY_DEVICE.root)
+ const getAPIConfigResult = await dispatch(
+ getAPIConfig({ deviceId: activeDevice.id })
+ )
+
+ if (getAPIConfigResult.error !== undefined) {
+ history.push(URL_ONBOARDING.troubleshooting)
+ return
+ }
+
+ history.push(URL_DEVICE_INITIALIZATION.root)
}
}
void handleConnectDevice()
- }, [history, dispatch, activeDeviceId])
+ }, [history, dispatch, activeDevice])
return
}
diff --git a/libs/core/discovery-device/components/device-list-item.component.tsx b/libs/core/discovery-device/components/device-list-item.component.tsx
index a2fd02f890..7657ad8a6a 100644
--- a/libs/core/discovery-device/components/device-list-item.component.tsx
+++ b/libs/core/discovery-device/components/device-list-item.component.tsx
@@ -6,8 +6,8 @@
import React from "react"
import { defineMessages } from "react-intl"
import styled, { css } from "styled-components"
+import { DeviceProperties } from "device-manager/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
import {
backgroundColor,
borderColor,
@@ -20,14 +20,24 @@ import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { getSerialNumberValue } from "Core/utils/get-serial-number-value"
import { getDeviceTypeName } from "Core/discovery-device/utils/get-device-type-name"
+import Icon from "Core/__deprecated__/renderer/components/core/icon/icon.component"
+import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
+import { BadgeWithIcon } from "Core/__deprecated__/renderer/components/core/badge/badge-with-icon.component"
+
+const dataTestIds = {
+ availableDevice: "available-device",
+ availableDeviceName: "available-device-name",
+ availableDeviceSerialNumber: "available-device-serial-number",
+}
const messages = defineMessages({
headerTitle: { id: "module.availableDeviceList.headerTitle" },
subheaderTitle: { id: "module.availableDeviceList.subheaderTitle" },
serialNumber: { id: "module.availableDeviceList.serialNumber" },
+ recoveryMode: { id: "module.availableDeviceList.recoveryMode" },
})
const DeviceImageWrapper = styled.div`
@@ -54,6 +64,8 @@ const Container = styled.div`
border: 0.1rem solid ${borderColor("deviceListSeparator")};
border-radius: ${borderRadius("medium")};
+ position: relative;
+
&:hover {
cursor: pointer;
background-color: ${backgroundColor("main")};
@@ -93,7 +105,7 @@ export const DeviceInfoDeviceTypeName = styled(Text)`
margin-bottom: 0.5rem;
`
-export interface DeviceListItemProps extends Device {
+export interface DeviceListItemProps extends DeviceProperties {
onDeviceClick: (id: string) => void
}
@@ -111,20 +123,42 @@ const DeviceListItem: FunctionComponent = ({
serialNumberValue !== "" ? intl.formatMessage(messages.serialNumber) : ""
return (
- onDeviceClick(id)}>
+ onDeviceClick(id)}
+ data-testid={dataTestIds.availableDevice}
+ >
+ {deviceType === DeviceType.MuditaHarmonyMsc && (
+
+
+
+ {intl.formatMessage(messages.recoveryMode)}
+
+
+ )}
-
+
{getDeviceTypeName(deviceType, caseColour)}
-
- {serialNumberHeader}
-
-
- {serialNumberValue}
-
+ {deviceType !== DeviceType.MuditaHarmonyMsc && (
+ <>
+
+ {serialNumberHeader}
+
+
+ {serialNumberValue}
+
+ >
+ )}
)
diff --git a/libs/core/discovery-device/components/device-list.component.tsx b/libs/core/discovery-device/components/device-list.component.tsx
index 9964a060ae..5339eff403 100644
--- a/libs/core/discovery-device/components/device-list.component.tsx
+++ b/libs/core/discovery-device/components/device-list.component.tsx
@@ -6,11 +6,15 @@
import React from "react"
import styled from "styled-components"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
+import { DeviceProperties } from "device-manager/models"
import DeviceListItem from "Core/discovery-device/components/device-list-item.component"
+const dataTestIds = {
+ devicesList: "devices-list",
+}
+
interface Props {
- devices: Device[]
+ devices: DeviceProperties[]
onDeviceClick: (id: string) => void
}
@@ -19,14 +23,15 @@ const Wrapper = styled.div`
overflow: auto;
`
const gridColumnsMap: Record = {
- 1: 'repeat(1, minmax(0, 34rem))',
- 2: 'repeat(2, minmax(0, 34rem))',
- default: 'repeat(3, minmax(0, 34rem))',
-};
+ 1: "repeat(1, minmax(0, 34rem))",
+ 2: "repeat(2, minmax(0, 34rem))",
+ default: "repeat(3, minmax(0, 34rem))",
+}
const Container = styled.div<{ devicesLength: number }>`
display: grid;
- grid-template-columns: ${({ devicesLength }) => gridColumnsMap[devicesLength] || gridColumnsMap.default};
+ grid-template-columns: ${({ devicesLength }) =>
+ gridColumnsMap[devicesLength] || gridColumnsMap.default};
gap: 2.6rem;
justify-content: center;
max-width: 107.2rem;
@@ -36,7 +41,10 @@ const Container = styled.div<{ devicesLength: number }>`
const DeviceList: FunctionComponent = ({ devices, onDeviceClick }) => {
return (
-
+
{devices.map((device) => {
return (
{
const [noNewDevicesDetectedState, setNoNewDevicesDetectedState] =
@@ -18,11 +19,11 @@ export const useNoNewDevicesDetectedHook = () => {
timeoutId = setTimeout(() => {
setNoNewDevicesDetectedState(true)
- }, 3000)
+ }, 4500)
}
handler()
const unregisterDeviceConnectedListener = answerMain(
- DeviceManagerMainEvent.DeviceConnected,
+ DeviceProtocolMainEvent.DeviceConnected,
handler
)
return () => {
diff --git a/libs/core/discovery-device/utils/get-device-type-name.ts b/libs/core/discovery-device/utils/get-device-type-name.ts
index 95286f7f14..c7ee71f70b 100644
--- a/libs/core/discovery-device/utils/get-device-type-name.ts
+++ b/libs/core/discovery-device/utils/get-device-type-name.ts
@@ -3,10 +3,12 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { CaseColour, DeviceType } from "Core/device"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
export const DeviceNames = {
Pure: "Pure",
+ Harmony: "Harmony",
Harmony1: "Harmony 1",
Harmony2: "Harmony 2",
Kompakt: "Kompakt",
@@ -21,6 +23,10 @@ export const getDeviceTypeName = (
return DeviceNames.Pure
}
+ if (deviceType === DeviceType.MuditaHarmonyMsc) {
+ return DeviceNames.Harmony
+ }
+
if (
deviceType === DeviceType.MuditaHarmony &&
caseColour === CaseColour.Gray
diff --git a/libs/core/files-manager/actions/base.action.ts b/libs/core/files-manager/actions/base.action.ts
index 458fd9d0e6..d3d293494f 100644
--- a/libs/core/files-manager/actions/base.action.ts
+++ b/libs/core/files-manager/actions/base.action.ts
@@ -8,10 +8,6 @@ import { State } from "Core/core/constants"
import { FilesManagerEvent } from "Core/files-manager/constants"
import { SoundApp } from "Core/files-manager/reducers"
-export const setInitialFilesManagerState = createAction(
- FilesManagerEvent.SetInitialFilesManagerState
-)
-
export const setUploadingState = createAction(
FilesManagerEvent.SetUploadingState
)
diff --git a/libs/core/files-manager/actions/get-files.action.ts b/libs/core/files-manager/actions/get-files.action.ts
index ce66d8307c..daeb9faca6 100644
--- a/libs/core/files-manager/actions/get-files.action.ts
+++ b/libs/core/files-manager/actions/get-files.action.ts
@@ -12,9 +12,10 @@ import {
} from "Core/files-manager/constants"
import { getFilesRequest } from "Core/files-manager/requests/get-files.request"
import { File } from "Core/files-manager/dto"
-import { DeviceType, loadDeviceData } from "Core/device"
+import { loadDeviceData } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { getActiveDeviceTypeSelector } from "Core/device-manager/selectors/get-active-device-type.selector"
+import { getActiveDeviceTypeSelector } from "device-manager/feature"
import { FilesManagerState, SoundApp } from "Core/files-manager/reducers"
export const getFiles = createAsyncThunk<
diff --git a/libs/core/files-manager/actions/get-paths-wrapper.ts b/libs/core/files-manager/actions/get-paths-wrapper.ts
deleted file mode 100644
index af90892d5b..0000000000
--- a/libs/core/files-manager/actions/get-paths-wrapper.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { OpenDialogOptions } from "electron"
-import { PayloadAction } from "@reduxjs/toolkit"
-import { getPaths } from "shared/app-state"
-import { ResultObject } from "Core/core/builder"
-import { TmpDispatch } from "Core/__deprecated__/renderer/store"
-
-/**
- * `getPathsWrapper` simplifies testing the `getPaths` thunk by isolating dispatch calls,
- * addressing challenges with mocking `shared/app-state`. It streamlines unit testing,
- * minimizing the need for direct involvement of the store and external APIs.
- */
-export const getPathsWrapper = async (
- dispatch: TmpDispatch,
- options: OpenDialogOptions
-): Promise>> =>
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
- dispatch(getPaths(options))
diff --git a/libs/core/files-manager/actions/upload-file.action.ts b/libs/core/files-manager/actions/upload-file.action.ts
index 32396b19c6..5aa1bbd40a 100644
--- a/libs/core/files-manager/actions/upload-file.action.ts
+++ b/libs/core/files-manager/actions/upload-file.action.ts
@@ -11,7 +11,7 @@ import {
FilesManagerError,
FilesManagerEvent,
} from "Core/files-manager/constants"
-import { getPathsWrapper } from "Core/files-manager/actions/get-paths-wrapper"
+import { openFileRequest } from "system-utils/feature"
import { uploadFilesRequest } from "Core/files-manager/requests"
import { getFiles } from "Core/files-manager/actions/get-files.action"
import {
@@ -36,7 +36,7 @@ export const uploadFile = createAsyncThunk<
FilesManagerEvent.UploadFiles,
async (_, { getState, dispatch, rejectWithValue }) => {
dispatch(setUploadBlocked(true))
- const { payload: getPathsPayload } = await getPathsWrapper(dispatch, {
+ const openFileResult = await openFileRequest({
filters: [
{
name: "Audio",
@@ -56,12 +56,12 @@ export const uploadFile = createAsyncThunk<
return rejectWithValue("files are not yet loaded")
}
- if (!getPathsPayload.ok || !getPathsPayload.data) {
+ if (!openFileResult.ok || !openFileResult.data) {
dispatch(setUploadBlocked(false))
return rejectWithValue("no files to upload")
}
- const filePaths = getPathsPayload.data
+ const filePaths = openFileResult.data
if (filePaths.length === 0) {
dispatch(setUploadBlocked(false))
diff --git a/libs/core/files-manager/components/invalid-files-modal/invalid-files-modal.component.tsx b/libs/core/files-manager/components/invalid-files-modal/invalid-files-modal.component.tsx
index 1ccbb08ec4..41b5d630fc 100644
--- a/libs/core/files-manager/components/invalid-files-modal/invalid-files-modal.component.tsx
+++ b/libs/core/files-manager/components/invalid-files-modal/invalid-files-modal.component.tsx
@@ -22,9 +22,9 @@ import Text, {
TextDisplayStyle,
} from "Core/__deprecated__/renderer/components/core/text/text.component"
import { resetUploadingState } from "Core/files-manager/actions"
-import { ipcRenderer } from "electron-better-ipc"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
import { Size } from "Core/__deprecated__/renderer/components/core/button/button.config"
+import { useHistory } from "react-router-dom"
+import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
const messages = defineMessages({
title: {
@@ -46,7 +46,10 @@ const messages = defineMessages({
export const InvalidFilesModal: FunctionComponent = ({ ...props }) => {
const invalidFiles = useSelector(getInvalidFiles)
- const openHelpWindow = () => ipcRenderer.callMain(HelpActions.OpenWindow)
+ const history = useHistory()
+ const openHelp = () => {
+ history.push(URL_MAIN.help)
+ }
const dispatch = useDispatch()
return (
@@ -82,7 +85,7 @@ export const InvalidFilesModal: FunctionComponent = ({ ...props }) => {
message={{
...messages.helpInfo,
values: {
- link: help pages,
+ link: help pages,
},
}}
/>
diff --git a/libs/core/files-manager/constants/event.enum.ts b/libs/core/files-manager/constants/event.enum.ts
index a7eb5ffb67..a6bc314951 100644
--- a/libs/core/files-manager/constants/event.enum.ts
+++ b/libs/core/files-manager/constants/event.enum.ts
@@ -4,7 +4,6 @@
*/
export enum FilesManagerEvent {
- SetInitialFilesManagerState = "SET_INITIAL_FILES_MANAGER_STATE",
GetFiles = "FILES_MANAGER_GET_FILES",
SetFiles = "FILES_MANAGER_SET_FILES",
SelectAllItems = "FILES_MANAGER_SELECT_ALL",
diff --git a/libs/core/files-manager/files-manager.module.ts b/libs/core/files-manager/files-manager.module.ts
index eb548b737d..4a7e26ea98 100644
--- a/libs/core/files-manager/files-manager.module.ts
+++ b/libs/core/files-manager/files-manager.module.ts
@@ -17,14 +17,14 @@ import {
FileUploadCommand,
} from "Core/device-file-system/commands"
import { FileDeleteCommand } from "Core/device-file-system/commands/file-delete.command"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class FilesManagerModule extends BaseModule {
private readonly filesManagerController: FilesManagerController
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -33,7 +33,7 @@ export class FilesManagerModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -44,13 +44,13 @@ export class FilesManagerModule extends BaseModule {
const fileManagerService = new FileManagerService(
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new FileDeleteCommand(this.deviceManager),
+ new FileDeleteCommand(this.deviceProtocol),
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new RetrieveFilesCommand(this.deviceManager),
+ new RetrieveFilesCommand(this.deviceProtocol),
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
- new FileUploadCommand(this.deviceManager, this.fileSystem)
+ new FileUploadCommand(this.deviceProtocol, this.fileSystem)
)
this.filesManagerController = new FilesManagerController(fileManagerService)
diff --git a/libs/core/files-manager/reducers/files-manager.reducer.ts b/libs/core/files-manager/reducers/files-manager.reducer.ts
index 80dedd5697..8890d3a639 100644
--- a/libs/core/files-manager/reducers/files-manager.reducer.ts
+++ b/libs/core/files-manager/reducers/files-manager.reducer.ts
@@ -4,6 +4,7 @@
*/
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
import {
@@ -22,12 +23,12 @@ import {
resetUploadingStateAfterSuccess,
resetFiles,
setInvalidFiles,
- setInitialFilesManagerState,
setActiveSoundApp,
} from "Core/files-manager/actions"
import { changeLocation } from "Core/core/actions"
import { FilesManagerState } from "Core/files-manager/reducers/files-manager.interface"
import { deleteFiles } from "Core/files-manager/actions/delete-files.action"
+import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
export const initialState: FilesManagerState = {
filesMap: {
@@ -52,7 +53,7 @@ export const filesManagerReducer = createReducer(
initialState,
(builder) => {
builder
- .addCase(setInitialFilesManagerState, () => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return { ...initialState }
})
.addCase(getFiles.pending, (state) => {
diff --git a/libs/core/files-manager/selectors/is-dettached-during-upload-error.selector.ts b/libs/core/files-manager/selectors/is-dettached-during-upload-error.selector.ts
index 3da8b62202..69056f594c 100644
--- a/libs/core/files-manager/selectors/is-dettached-during-upload-error.selector.ts
+++ b/libs/core/files-manager/selectors/is-dettached-during-upload-error.selector.ts
@@ -6,7 +6,7 @@
import { createSelector } from "@reduxjs/toolkit"
import { getFilesManager } from "Core/files-manager/selectors/get-files-manager.selector"
import { State } from "Core/core/constants"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
+import { getActiveDevice } from "device-manager/feature"
export const isDettachedDuringUploadErrorSelector = createSelector(
getFilesManager,
diff --git a/libs/core/help/components/answer/answer.component.tsx b/libs/core/help/components/answer/answer.component.tsx
deleted file mode 100644
index 53e11d2750..0000000000
--- a/libs/core/help/components/answer/answer.component.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import React from "react"
-import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { RouteComponentProps } from "react-router"
-import Button from "Core/__deprecated__/renderer/components/core/button/button.component"
-import { DisplayStyle } from "Core/__deprecated__/renderer/components/core/button/button.config"
-import { intl } from "Core/__deprecated__/renderer/utils/intl"
-import styled from "styled-components"
-import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-import { documentToReactComponents } from "@contentful/rich-text-react-renderer"
-import { richTextReactComponentOptions } from "Core/__deprecated__/renderer/utils/rich-text/rich-text-renderer"
-import { backgroundColor } from "Core/core/styles/theming/theme-getters"
-import { AnswerUiTestIds } from "Core/help/components/answer/answer-test-ids.enum"
-import Text, {
- TextDisplayStyle,
-} from "Core/__deprecated__/renderer/components/core/text/text.component"
-import { IconSize } from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-
-const AnswerContainer = styled.div`
- padding: 0 10.5rem;
- background-color: ${backgroundColor("row")};
- height: 100vh;
-`
-
-const AnswerHeader = styled.div`
- padding: 4.5rem 0 5.3rem 0;
- background-color: ${backgroundColor("row")};
-`
-
-const BackLink = styled(Button)`
- width: max-content;
-`
-
-const AnswerContent = styled.div`
- max-width: 48rem;
-`
-
-interface Props extends RouteComponentProps<{ questionId: string }> {
- list: QuestionAndAnswer
-}
-
-const Answer: FunctionComponent = ({ match, list }) => {
- const { items } = list
- return (
-
-
-
-
-
- {items[match.params.questionId]?.answer ? (
- documentToReactComponents(
- items[match.params.questionId].answer,
- richTextReactComponentOptions
- )
- ) : (
-
- )}
-
-
- )
-}
-
-export default Answer
diff --git a/libs/core/help/components/answer/answer.stories.tsx b/libs/core/help/components/answer/answer.stories.tsx
deleted file mode 100644
index b2fc66807c..0000000000
--- a/libs/core/help/components/answer/answer.stories.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { storiesOf } from "@storybook/react"
-import React from "react"
-import { MemoryRouter, Route, RouteComponentProps } from "react-router"
-import { data, mockedRouteAndPath } from "Core/__deprecated__/seeds/help"
-import { renderAnswer } from "Core/help/helpers/render-answer"
-
-storiesOf("Views/Help", module)
- .addDecorator((story) => (
-
- {story()}
-
- ))
- .add("Details UI - Answer", () => {
- const AnswerComponent = (
- props: RouteComponentProps<{ questionId: string }>
- ) => renderAnswer(data, props)
- return
- })
diff --git a/libs/core/help/components/answer/answer.test.tsx b/libs/core/help/components/answer/answer.test.tsx
deleted file mode 100644
index aa5f1bdac0..0000000000
--- a/libs/core/help/components/answer/answer.test.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import {
- data,
- mockedHeadingText,
- mockedParagraphText,
- mockedMinorHeadingText,
- mockedRouteAndPath,
-} from "Core/__deprecated__/seeds/help"
-import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
-import { Route, RouteComponentProps, Router } from "react-router"
-import React from "react"
-import { createMemoryHistory, MemoryHistory } from "history"
-import { AnswerUiTestIds } from "Core/help/components/answer/answer-test-ids.enum"
-import { renderAnswer } from "Core/help/helpers/render-answer"
-import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
-
-const renderWithRouterMatch = ({
- path = "/",
- route = "/",
- history = createMemoryHistory({ initialEntries: [route] }),
-}: {
- path: string
- route: string
- history?: MemoryHistory
-}) => {
- const AnswerComponent = (
- props: RouteComponentProps<{ questionId: string }>
- ) => renderAnswer(data, props)
- return {
- ...renderWithThemeAndIntl(
-
-
-
- ),
- }
-}
-
-test("content is rendered", () => {
- const { getByTestId } = renderWithRouterMatch(mockedRouteAndPath)
- expect(getByTestId(AnswerUiTestIds.Content)).toHaveTextContent(
- `${mockedHeadingText}${mockedParagraphText}${mockedMinorHeadingText}`
- )
-})
-
-test("error text is rendered", () => {
- const { getByText } = renderWithRouterMatch({
- route: `${URL_MAIN.help}/error-route`,
- path: `${URL_MAIN.help}/:questionId`,
- })
- expect(getByText("[value] module.help.answerError")).toBeInTheDocument()
-})
-
-test("back link has correct text ", () => {
- const { getByTestId } = renderWithRouterMatch(mockedRouteAndPath)
- const backLinkText = "module.help.backLinkText"
- expect(getByTestId(AnswerUiTestIds.BackLink)).toHaveTextContent(backLinkText)
-})
diff --git a/libs/core/help/components/help.component.tsx b/libs/core/help/components/help.component.tsx
deleted file mode 100644
index cfaf620091..0000000000
--- a/libs/core/help/components/help.component.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import React, { ChangeEvent } from "react"
-import { Link } from "react-router-dom"
-import { HelpComponentTestIds } from "Core/help/components/help.enum"
-import { FunctionComponent } from "Core/core/types/function-component.interface"
-import Text, {
- TextDisplayStyle,
-} from "Core/__deprecated__/renderer/components/core/text/text.component"
-import styled from "styled-components"
-import { intl, textFormatters } from "Core/__deprecated__/renderer/utils/intl"
-import InputText from "Core/__deprecated__/renderer/components/core/input-text/input-text.component"
-import { searchIcon } from "Core/__deprecated__/renderer/components/core/input-text/input-text.elements"
-import {
- backgroundColor,
- transitionTime,
- transitionTimingFunction,
- zIndex,
-} from "Core/core/styles/theming/theme-getters"
-import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
-import Icon, {
- IconSize,
-} from "Core/__deprecated__/renderer/components/core/icon/icon.component"
-import { NormalizedHelpEntry } from "Core/__deprecated__/renderer/utils/contentful/normalize-help-data"
-import ModalsManager from "Core/modals-manager/components/modals-manager.component"
-import { IconButtonWithSecondaryTooltip } from "Core/__deprecated__/renderer/components/core/icon-button-with-tooltip/icon-button-with-secondary-tooltip.component"
-import { defineMessages } from "react-intl"
-import { IconType } from "Core/__deprecated__/renderer/components/core/icon/icon-type"
-
-const messages = defineMessages({
- supportTooltipDescription: { id: "module.help.supportTooltipDescription" },
-})
-
-export interface QuestionAndAnswer {
- collection: string[]
- items: Record
-}
-
-interface Props {
- list: QuestionAndAnswer
- searchQuestion: (value: string) => void
- searchValue?: string
- openContactSupportFlow: () => void
-}
-
-const HelpPanel = styled.div`
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 3.6rem 10.5rem 2rem 10.5rem;
- background-color: ${backgroundColor("row")};
- position: sticky;
- top: 0;
- z-index: ${zIndex("content")};
-`
-
-const SearchContainer = styled.div`
- display: flex;
- justify-content: space-between;
- align-items: center;
-`
-
-const SearchInput = styled(InputText)`
- width: 27.5rem;
- margin-left: 1.6rem;
-`
-
-const QuestionsContainer = styled.div`
- padding: 0 8.9rem;
- margin-top: 4.1rem;
- background-color: ${backgroundColor("main")};
-`
-
-const Question = styled(Link)`
- padding: 1.6rem;
- display: flex;
- justify-content: space-between;
- align-items: center;
- transition: background-color, ${transitionTime("veryQuick")},
- ${transitionTimingFunction("smooth")};
- &:hover {
- background-color: ${backgroundColor("minor")};
- }
-`
-
-const ArrowIcon = styled(Icon)`
- transform: rotate(270deg);
-`
-
-const Help: FunctionComponent = ({
- list: { collection = [], items },
- searchQuestion,
- searchValue,
- openContactSupportFlow,
-}) => {
- const search = (event: ChangeEvent) => {
- searchQuestion(event.target.value)
- }
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
- {collection
- .sort((aId, bId) => {
- const questionA = items[aId].question.toUpperCase()
- const questionB = items[bId].question.toUpperCase()
- if (questionA < questionB) {
- return -1
- }
- if (questionA > questionB) {
- return 1
- }
-
- return 0
- })
- .map((id: string) => {
- return (
-
-
- {items[id].question}
-
-
-
- )
- })}
-
-
- >
- )
-}
-
-export default Help
diff --git a/libs/core/help/components/help.enum.ts b/libs/core/help/components/help.enum.ts
deleted file mode 100644
index 4a0c68cb19..0000000000
--- a/libs/core/help/components/help.enum.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-export enum HelpComponentTestIds {
- Wrapper = "help-component-wrapper",
- ToggleButton = "help-component-toggle-button",
- Title = "help-component-title",
- Question = "help-component-question",
- SupportButton = "help-support-button",
-}
diff --git a/libs/core/help/components/help.stories.tsx b/libs/core/help/components/help.stories.tsx
deleted file mode 100644
index f03c3463fa..0000000000
--- a/libs/core/help/components/help.stories.tsx
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { storiesOf } from "@storybook/react"
-import React from "react"
-import { helpSeed } from "Core/__deprecated__/seeds/help"
-import Help from "Core/help/components/help.component"
-import { BrowserRouter as Router } from "react-router-dom"
-import { noop } from "Core/__deprecated__/renderer/utils/noop"
-
-storiesOf("Views/Help", module).add("Help", () => (
-
-
-
-
-
-))
diff --git a/libs/core/help/components/help.test.tsx b/libs/core/help/components/help.test.tsx
deleted file mode 100644
index 49ff37bfde..0000000000
--- a/libs/core/help/components/help.test.tsx
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import React, { ComponentProps } from "react"
-import { Provider } from "react-redux"
-import { fireEvent } from "@testing-library/dom"
-import store from "Core/__deprecated__/renderer/store"
-import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
-import { HelpComponentTestIds } from "Core/help/components/help.enum"
-import Help from "Core/help/components/help.component"
-import { data } from "Core/__deprecated__/seeds/help"
-
-jest.mock("Core/settings/store/schemas/generate-application-id", () => ({
- generateApplicationId: () => "123",
-}))
-
-jest.mock("@electron/remote", () => ({
- dialog: {
- showOpenDialog: jest.fn(),
- },
-}))
-
-type Props = ComponentProps
-
-const defaultProps: Props = {
- list: data,
- searchQuestion: jest.fn(),
- openContactSupportFlow: jest.fn(),
-}
-
-const render = (extraProps?: Partial) => {
- const props = {
- ...defaultProps,
- ...extraProps,
- }
-
- return renderWithThemeAndIntl(
-
-
-
- )
-}
-
-test("Help component renders", () => {
- const { getByTestId } = render()
- expect(getByTestId(HelpComponentTestIds.Wrapper)).toBeInTheDocument()
-})
-
-test("render title correctly", () => {
- const titleText = "module.help.title"
- const { getByTestId } = render()
- expect(getByTestId(HelpComponentTestIds.Title)).toHaveTextContent(titleText)
-})
-
-test("renders correct amount of links", () => {
- const { getAllByRole } = render()
- expect(getAllByRole("link")).toHaveLength(defaultProps.list.collection.length)
-})
-
-test("search input works", () => {
- const { getByRole } = render()
- const searchInput = getByRole("searchbox")
- fireEvent.change(searchInput, {
- target: { value: "adsad" },
- })
- expect(defaultProps.searchQuestion).toBeCalled()
-})
-
-test("click `SupportButton` emit `openContactSupportFlow` event", () => {
- const openContactSupportFlow = jest.fn()
- const { getByTestId } = render({ openContactSupportFlow })
- fireEvent.click(getByTestId(HelpComponentTestIds.SupportButton))
- expect(openContactSupportFlow).toHaveBeenCalled()
-})
diff --git a/libs/core/help/default-help.json b/libs/core/help/default-help.json
deleted file mode 100644
index aabf27b92e..0000000000
--- a/libs/core/help/default-help.json
+++ /dev/null
@@ -1 +0,0 @@
-{"collection":["6rTLyyR6Khdu6d4GGpcbon","5D42R98KntZbQUTcrhizxs","4igDlwh9GW7L6PsgjVHyxw","3uLZU88v7L2oUZHsaYAQTs","41R11zxpX0tYVubr52CIxM","3gHVtYGoa4SOixNHTxnSlJ","5JSK4d3iUXoWNOGjj1lTTF","24oHmzMGKaqoWKKFjX3mJT","DwCnLFElFKxV8yz7HjqKT","60AtHCFNpdJ7jA26bC55ju","m9GNSfDdpvSeQbqgXVHQ6","7laaEbQCtg7hfQjZIqO7Lv","3El0ssG9bX6jxvDDckWQiP","5z0tuCdYhnnQrRyAsNoAHT","kZ3ZB95I8tCX0lZYQTRZr","1Cr7VOps6vyYUgw2VwDJSU","RxG8PskOtkWQ00aCL4JJ7","68ZLLjHM25XQKu9pRLUtPR","GSBqsntyLST2hANzSdMh1","1OzihaTKRPEfPk3NPyRhku","4kQ3BfvtPxoM1ErBSoXlMW","2W0Yh5enrN1SqWGkvGkvf2","3UzcSgFRo8CjfMUTycu3KB","4Kj1OMtlPJSTs27TkS9ELG","1oCmuEnSQyYHsSvew1g0vm"],"items":{"6rTLyyR6Khdu6d4GGpcbon":{"id":"6rTLyyR6Khdu6d4GGpcbon","question":" How to import my iCloud contacts into Mudita Pure by using .vcf file?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Note: Please note there is no direct option to sync Pure contacts with iCloud, there is an import from a file. ","marks":[{"type":"bold"}],"data":{}}]},{"nodeType":"ordered-list","data":{},"content":[{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Go to the “Contacts” section inside the “YOUR PURE” section.","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click on the “Import” button.","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “Import from VCF file”, it will direct you to the system modal which allows you to choose a file from your computer. Make sure that you have exported your iCloud contact into a VCF file.","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Once the file is chosen to import, you will be able to see the list of the contacts (you can choose contacts to import).","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click the confirmation button to start the import process.","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"After the process is finished successfully you will be able to view the contacts in Mudita Center and on Mudita Pure","marks":[],"data":{}}]}]}]},{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"","marks":[],"data":{}}]}]}},"5D42R98KntZbQUTcrhizxs":{"id":"5D42R98KntZbQUTcrhizxs","question":"How to import my contacts from the .vcf file to Mudita Pure?","answer":{"data":{},"content":[{"data":{},"content":[{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Go to the “Contacts” section inside the “YOUR PURE” section.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Click on the “Import” button.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Click “Import from VCF file”, it will direct you to the system modal which allows you to choose a file from your computer. ","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Once the file is chosen to import, you will be able to see the list of the contacts (you can choose contacts to import).","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Click the confirmation button to start the import process.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"After the process is finished successfully you will be able to view the contacts in Mudita Center and on Mudita Pure.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"}],"nodeType":"ordered-list"},{"data":{},"content":[{"data":{},"marks":[],"value":"","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"document"}},"4igDlwh9GW7L6PsgjVHyxw":{"id":"4igDlwh9GW7L6PsgjVHyxw","question":"How to import my Outlook contacts to Mudita Pure?","answer":{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"1. Go to the “Contacts” section inside the “YOUR PURE” section.\n2. Click on “Import”.\n3. You will see several options to import contacts.\n4. Select the “Continue with Outlook” method, it will bring you to the next modal with authorization (it means you need to log in to your Outlook account). \n5. Now you can choose which contacts you want to import and follow the instructions.\n6. After the process is finished successfully you will be able to view the contacts in Mudita Center and on Mudita Pure.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"document"}},"3uLZU88v7L2oUZHsaYAQTs":{"id":"3uLZU88v7L2oUZHsaYAQTs","question":"How to upload music files to my Harmony or Pure?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","data":{},"content":[{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Connect your Mudita Harmony or Pure to your computer with a USB C cable","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Open Mudita Center and ","marks":[],"data":{}},{"nodeType":"hyperlink","data":{"uri":"https://support.mudita.com/en/support/solutions/articles/77000512487-connecting-a-mudita-pure-or-harmony-to-mudita-center"},"content":[{"nodeType":"text","value":"make sure your device is connected","marks":[],"data":{}}]},{"nodeType":"text","value":"","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “","marks":[],"data":{}},{"nodeType":"text","value":"File Manager","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"”","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “","marks":[],"data":{}},{"nodeType":"text","value":"Upload","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"”","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"In the window that opens, you can browse and select your audio files (mp3, wav and FLAC) to upload*","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Confirm the selection","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"When the files finish uploading, you will see them listed in Mudita Center, ","marks":[],"data":{}},{"nodeType":"text","value":"Mudita Pure in the Music app and ","marks":[],"data":{}},{"nodeType":"text","value":"Mudita Harmony in the Relaxation app.","marks":[],"data":{}}]}]}]},{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":" *Harmony supports up to a maximum of 100 audio files","marks":[],"data":{}}]}]}},"41R11zxpX0tYVubr52CIxM":{"id":"41R11zxpX0tYVubr52CIxM","question":"How to delete music files from my Mudita Harmony or Pure?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","data":{},"content":[{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Connect your Mudita Harmony or Pure to your computer with a USB C cable","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Open Mudita Center and make ","marks":[],"data":{}},{"nodeType":"hyperlink","data":{"uri":"https://support.mudita.com/en/support/solutions/articles/77000512487-connecting-a-mudita-pure-or-harmony-to-mudita-center"},"content":[{"nodeType":"text","value":"sure your device is connected","marks":[],"data":{}}]},{"nodeType":"text","value":"","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “","marks":[],"data":{}},{"nodeType":"text","value":"File Manager","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"”","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “","marks":[],"data":{}},{"nodeType":"text","value":"…","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"” on the file you want to delete*","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"To confirm the process click button „delete”","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Click “","marks":[],"data":{}},{"nodeType":"text","value":"Delete","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"” again to confirm\n\n*You can delete multiple files at once by selecting them with the checkbox and clicking “","marks":[],"data":{}},{"nodeType":"text","value":"Delete","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"”","marks":[],"data":{}}]},{"nodeType":"unordered-list","data":{},"content":[{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"On the top bar above, click the checkbox (near the word 1 file selected) using the search bar.","marks":[],"data":{}}]}]},{"nodeType":"list-item","data":{},"content":[{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"Once all files are selected, click \"Delete\" in the search bar and confirm the action.","marks":[],"data":{}}]}]}]}]}]},{"nodeType":"paragraph","data":{},"content":[{"nodeType":"text","value":"","marks":[],"data":{}}]}]}},"3gHVtYGoa4SOixNHTxnSlJ":{"id":"3gHVtYGoa4SOixNHTxnSlJ","question":"OS update failed","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Make sure you didn’t any of the following during the update:","marks":[],"data":{}}],"data":{}},{"nodeType":"unordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"use your Mudita Pure,","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"unplug your Mudita Pure from the computer,","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"turn off your Mudita Pure,","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"close the Mudita Center app.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Still not working? Contact our Support ","marks":[],"data":{}},{"nodeType":"hyperlink","content":[{"nodeType":"text","value":"support@mudita.com","marks":[{"type":"underline"}],"data":{}}],"data":{"uri":"mailto:support@mudita.com"}},{"nodeType":"text","value":" ","marks":[],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"5JSK4d3iUXoWNOGjj1lTTF":{"id":"5JSK4d3iUXoWNOGjj1lTTF","question":"How to delete all contacts?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Contacts” section inside the “YOUR PURE” section.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Select a contact you want to delete.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"On the top bar above click on the check box (near inscription 1 Contact selected) by using the search bar.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Once all contacts are selected, click “Delete” in the search bar and confirm the action.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"All selected contacts will be deleted.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"24oHmzMGKaqoWKKFjX3mJT":{"id":"24oHmzMGKaqoWKKFjX3mJT","question":"How to export my Contacts to the file? ","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Contacts” section inside the “YOUR PURE” section.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Select the contacts you want to export.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click the “Export” icon at the top bar.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Choose the file you want your contacts exported to. ","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You will be able to see the confirmation that contacts have been exported to the file.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"DwCnLFElFKxV8yz7HjqKT":{"id":"DwCnLFElFKxV8yz7HjqKT","question":"How to update Mudita Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Run Mudita Center on your computer and make sure you have an Internet connection.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"If an update is available, Mudita Center will show you the relevant information with an option to update the software.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click the “update now” button and follow the instructions.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"To check for an update manually, head into Settings > About > Check for Updates.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"After a successful update, Mudita Center will restart.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set, after the app reopens & you’re able to use the latest version.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"60AtHCFNpdJ7jA26bC55ju":{"id":"60AtHCFNpdJ7jA26bC55ju","question":"Forgot passcode?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Resetting your passcode is only available through a factory reset of your Mudita Pure.","marks":[],"data":{}}],"data":{}}]}},"m9GNSfDdpvSeQbqgXVHQ6":{"id":"m9GNSfDdpvSeQbqgXVHQ6","question":"How to update Harmony OS?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Harmony to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Overview” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"In the sub-section showing your MuditaOS version, you will you will see a notification about whether there is a new software update available for your Mudita Harmony.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click the “Download Now” button and follow the instructions.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"After a successful update, your Harmony will automatically restart. After that, you will be able to see your MuditaOS version in the “Overview” section.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Note: Remember to not unplug your device from the computer during the update process","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":". ","marks":[],"data":{}}],"data":{}}]}},"7laaEbQCtg7hfQjZIqO7Lv":{"id":"7laaEbQCtg7hfQjZIqO7Lv","question":"How to check my phone's serial number?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Overview” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Under the photo of your Pure, just below the ","marks":[],"data":{}},{"nodeType":"text","value":"Disconnect ","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":"button you will see a clickable ‘About your Pure’ text.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Once inside, in the About your Pure section you will see your Serial number as well as additional information about SAR","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"3El0ssG9bX6jxvDDckWQiP":{"id":"3El0ssG9bX6jxvDDckWQiP","question":"How to send a message using Mudita Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Messages” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"On the right side of the search bar you will see a button.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Search for your desired contact or jump into an existing conversation.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set!","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"5z0tuCdYhnnQrRyAsNoAHT":{"id":"5z0tuCdYhnnQrRyAsNoAHT","question":"Where can I find the backup file to restore Pure?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Settings” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":" In the sub-section titled “Backup” navigate to ","marks":[],"data":{}},{"nodeType":"text","value":"Backup Location","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":", you will see the exact file path.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Follow the path on your PC in order to find the correct folder.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set!","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"kZ3ZB95I8tCX0lZYQTRZr":{"id":"kZ3ZB95I8tCX0lZYQTRZr","question":"How to change the backup’s hard drive location?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Settings” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"In the sub-section named \"Backup\" there will be an option visible to change the hard drive location.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click Change Location and select the desired folder.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set!","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"1Cr7VOps6vyYUgw2VwDJSU":{"id":"1Cr7VOps6vyYUgw2VwDJSU","question":"How to backup your Mudita Pure?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Overview” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"In the sub-section titled “Backup” you will see an option to either create your first backup file or retrieve a previously created backup file.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click twice and create a password in order to start creating the backup. This password is unique for each restoring process and cannot be restored.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set!","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"RxG8PskOtkWQ00aCL4JJ7":{"id":"RxG8PskOtkWQ00aCL4JJ7","question":"How to restore my Pure’s backup through Mudita Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your computer and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Overview” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"In the sub-section titled “Backup” there will be an option visible to retrieve or create your first backup file.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click and select the file you want to restore.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click Restore, enter the password you created when creating the backup file, and wait for the process to complete.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"68ZLLjHM25XQKu9pRLUtPR":{"id":"68ZLLjHM25XQKu9pRLUtPR","question":"How to update MuditaOS in Mudita Pure?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your computer with a dedicated USB cable and make sure that Mudita Center runs on your machine and recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Go to the “Overview” section inside Mudita Center.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"In the sub-section showing your MuditaOS version, you will be notified whether your phone needs updating with an “Update is available” prompt.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Click the “Download Now” button and follow the instructions.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"After a successful update, your Pure will automatically restart. After that, you will be able to see your MuditaOS version in the “Overview” section.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Note: Remember to not use nor unplug your Pure from the computer during the update process","marks":[{"type":"bold"}],"data":{}},{"nodeType":"text","value":". ","marks":[],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"GSBqsntyLST2hANzSdMh1":{"id":"GSBqsntyLST2hANzSdMh1","question":"How to connect my Mudita Harmony to Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Open the Mudita Center app.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Harmony to your desktop computer with a dedicated USB cable and make sure that Mudita Center recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"1OzihaTKRPEfPk3NPyRhku":{"id":"1OzihaTKRPEfPk3NPyRhku","question":"How to delete a message inside Mudita Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You currently cannot directly delete messages in the Mudita Center.\nPlease locate the desired message on your Mudita Pure and remove it from there.\nNaturally, once connected, Mudita Center will reflect the changes.","marks":[],"data":{}}],"data":{}}]}},"4kQ3BfvtPxoM1ErBSoXlMW":{"id":"4kQ3BfvtPxoM1ErBSoXlMW","question":"How to import my Google contacts to Mudita Pure?","answer":{"data":{},"content":[{"data":{},"content":[{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Go to the “Contacts” section inside the “YOUR PURE” section.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Click on “Import”.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"You will see several options to import contacts.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Select the “Continue with Google” method, it will bring you to the next modal with authorization (it means you need to log in to your Google account). ","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"Now you can choose which contacts you want to import and follow the instructions.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"},{"data":{},"content":[{"data":{},"content":[{"data":{},"marks":[],"value":"After the process is finished successfully you will be able to view the contacts in Mudita Center and on Mudita Pure.","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"list-item"}],"nodeType":"ordered-list"},{"data":{},"content":[{"data":{},"marks":[],"value":"","nodeType":"text"}],"nodeType":"paragraph"}],"nodeType":"document"}},"2W0Yh5enrN1SqWGkvGkvf2":{"id":"2W0Yh5enrN1SqWGkvGkvf2","question":"I can’t see the section YOUR PURE, how can I open it?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Make sure that Mudita Center is running and it recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Check the categories on the left bar; below “Mudita News” you will be able to see a few categories under the “YOUR PURE” section.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"3UzcSgFRo8CjfMUTycu3KB":{"id":"3UzcSgFRo8CjfMUTycu3KB","question":"How to connect my Pure to Mudita Center?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Open the Mudita Center app.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Connect your Mudita Pure to your desktop computer with a dedicated USB cable and make sure that Mudita Center recognizes your device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"You’re all set.","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"4Kj1OMtlPJSTs27TkS9ELG":{"id":"4Kj1OMtlPJSTs27TkS9ELG","question":"What to do when Mudita Center does not recognise my device?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"ordered-list","content":[{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Remove the USB cable from your Mudita device and your computer.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Inspect the USB port and cable for damages or dirt.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Restart your Mudita device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Make sure you’re using the cable that came with your Mudita device.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Make sure the cable plug goes all the way into the port.","marks":[],"data":{}}],"data":{}}],"data":{}},{"nodeType":"list-item","content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Unlock your Mudita device's screen (if applicable).","marks":[],"data":{}}],"data":{}}],"data":{}}],"data":{}},{"nodeType":"paragraph","content":[{"nodeType":"text","value":"","marks":[],"data":{}}],"data":{}}]}},"1oCmuEnSQyYHsSvew1g0vm":{"id":"1oCmuEnSQyYHsSvew1g0vm","question":"How to contact support?","answer":{"nodeType":"document","data":{},"content":[{"nodeType":"paragraph","content":[{"nodeType":"text","value":"Please reach out to ","marks":[],"data":{}},{"nodeType":"hyperlink","content":[{"nodeType":"text","value":"support@mudita.com","marks":[{"type":"underline"}],"data":{}}],"data":{"uri":"mailto:support@mudita.com"}},{"nodeType":"text","value":" for assistance.","marks":[],"data":{}}],"data":{}}]}}},"nextSyncToken":"w7Ese3kdwpMbMhhgw7QAUsKiw6bCiw_ClnfDrRLCuFDDkMO5YcKMJQ_CvcKUecOnMHjCjsOGw5HDu1Fdwrs7E8KjYGgHJcK7wqwmwp0pSsKWw5fCmsK1wrPCsMKsHsKSYSAkw43ClnBRwoUvwppOUjw6w7TDucK-AcOWwrtew73CgMOoRlfCqX4NRCrDn2B_w5JQcMODDwRbwr7DkjPDmcKqKHM"}
diff --git a/libs/core/help/help.container.tsx b/libs/core/help/help.container.tsx
deleted file mode 100644
index 3acb1797a4..0000000000
--- a/libs/core/help/help.container.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { connect } from "react-redux"
-import { TmpDispatch } from "Core/__deprecated__/renderer/store"
-import Help from "Core/help/components/help.component"
-import { ModalStateKey, showModal } from "Core/modals-manager"
-
-const mapDispatchToProps = (dispatch: TmpDispatch) => ({
- openContactSupportFlow: () =>
- // AUTO DISABLED - fix me if you like :)
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
- dispatch(showModal(ModalStateKey.ContactSupportFlow)),
-})
-
-export default connect(undefined, mapDispatchToProps)(Help)
diff --git a/libs/core/help/helpers/render-answer.tsx b/libs/core/help/helpers/render-answer.tsx
deleted file mode 100644
index 56132075ea..0000000000
--- a/libs/core/help/helpers/render-answer.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { QuestionAndAnswer } from "Core/help/components/help.component"
-import { RouteComponentProps } from "react-router"
-import Answer from "Core/help/components/answer/answer.component"
-import React from "react"
-
-// AUTO DISABLED - fix me if you like :)
-// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
-export const renderAnswer = (
- data: QuestionAndAnswer,
- props: RouteComponentProps<{ questionId: string }>
-) =>
diff --git a/libs/core/index-storage/index-storage.module.ts b/libs/core/index-storage/index-storage.module.ts
index 15eee2bf99..d38927c9d5 100644
--- a/libs/core/index-storage/index-storage.module.ts
+++ b/libs/core/index-storage/index-storage.module.ts
@@ -11,7 +11,7 @@ import { FileSystemService } from "Core/file-system/services/file-system.service
import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { IndexStorageService } from "Core/index-storage/services"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { IndexStorageController } from "Core/index-storage/controllers"
export class IndexStorageModule extends BaseModule {
@@ -20,7 +20,7 @@ export class IndexStorageModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -29,7 +29,7 @@ export class IndexStorageModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
diff --git a/libs/core/messages/actions/base.action.ts b/libs/core/messages/actions/base.action.ts
index af31f7f0b2..ab3316ad8d 100644
--- a/libs/core/messages/actions/base.action.ts
+++ b/libs/core/messages/actions/base.action.ts
@@ -7,10 +7,6 @@ import { createAction } from "@reduxjs/toolkit"
import { MessagesEvent } from "Core/messages/constants"
import { MessagesState } from "Core/messages/reducers"
-export const setInitialMessagesState = createAction(
- MessagesEvent.SetInitialMessagesState
-)
-
export const changeVisibilityFilter = createAction<
MessagesState["data"]["visibilityFilter"]
>(MessagesEvent.ChangeVisibilityFilter)
diff --git a/libs/core/messages/actions/update-message.action.test.ts b/libs/core/messages/actions/update-message.action.test.ts
index fa7859d721..47c5cddea9 100644
--- a/libs/core/messages/actions/update-message.action.test.ts
+++ b/libs/core/messages/actions/update-message.action.test.ts
@@ -7,7 +7,7 @@ import createMockStore from "redux-mock-store"
import thunk from "redux-thunk"
import { AnyAction } from "@reduxjs/toolkit"
import { Result, ResultObject } from "Core/core/builder"
-import { DeviceCommunicationError } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
import { updateMessage } from "Core/messages/actions/update-message.action"
import { updateMessageRequest } from "Core/messages/requests"
import { testError } from "Core/__deprecated__/renderer/store/constants"
diff --git a/libs/core/messages/components/receiver-input-search/receiver-input-search.component.tsx b/libs/core/messages/components/receiver-input-search/receiver-input-search.component.tsx
index 62ba9d5850..8ddd683de0 100644
--- a/libs/core/messages/components/receiver-input-search/receiver-input-search.component.tsx
+++ b/libs/core/messages/components/receiver-input-search/receiver-input-search.component.tsx
@@ -31,7 +31,7 @@ const ReceiverInputSelect = styled(InputSearch)`
type InputSearchProps = Omit<
ComponentProps,
- "results" | "items" | "type"
+ "results" | "items" | "type" | "ref"
>
interface Props extends InputSearchProps {
diff --git a/libs/core/messages/constants/event.enum.ts b/libs/core/messages/constants/event.enum.ts
index e19898ffaf..2b822c1b70 100644
--- a/libs/core/messages/constants/event.enum.ts
+++ b/libs/core/messages/constants/event.enum.ts
@@ -4,8 +4,6 @@
*/
export enum MessagesEvent {
- SetInitialMessagesState = "SET_INITIAL_MESSAGES_STATE",
-
ToggleThreadsReadStatus = "TOGGLE_THREADS_READ_STATUS",
MarkThreadsReadStatus = "MARK_THREADS_READ_STATUS",
diff --git a/libs/core/messages/message.module.ts b/libs/core/messages/message.module.ts
index cba023a126..51f8dd2561 100644
--- a/libs/core/messages/message.module.ts
+++ b/libs/core/messages/message.module.ts
@@ -14,12 +14,12 @@ import { MessageModel, ThreadModel } from "Core/messages/models"
import { MessageService, ThreadService } from "Core/messages/services"
import { MessageController, ThreadController } from "Core/messages/controllers"
import { MessageRepository, ThreadRepository } from "Core/messages/repositories"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class MessageModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceModule: DeviceManager,
+ public deviceModule: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
diff --git a/libs/core/messages/reducers/messages.reducer.ts b/libs/core/messages/reducers/messages.reducer.ts
index 40c0561840..2a29a2540d 100644
--- a/libs/core/messages/reducers/messages.reducer.ts
+++ b/libs/core/messages/reducers/messages.reducer.ts
@@ -6,6 +6,7 @@
// TODO: CP-1494, CP-1495
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import {
fulfilledAction,
pendingAction,
@@ -43,7 +44,6 @@ import assert from "assert"
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
import { search, searchPreview } from "Core/search/actions/search.action"
-import { setInitialMessagesState } from "Core/messages/actions/base.action"
export const initialState: MessagesState = {
data: {
@@ -67,7 +67,7 @@ export const messagesReducer = createReducer(
initialState,
(builder) => {
builder
- .addCase(setInitialMessagesState, (state) => {
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), () => {
return { ...initialState }
})
.addCase(
diff --git a/libs/core/messages/services/message.service.test.ts b/libs/core/messages/services/message.service.test.ts
index 8dd00e7071..4dc5d7c777 100644
--- a/libs/core/messages/services/message.service.test.ts
+++ b/libs/core/messages/services/message.service.test.ts
@@ -6,12 +6,11 @@
import { Result } from "Core/core/builder"
import { Message as PureMessage } from "Core/device/types/mudita-os"
import {
- Endpoint,
- Method,
MessagesCategory as PureMessagesCategory,
MessageType,
MessageType as PureMessageType,
} from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import {
ErrorRequestResponse,
RequestResponseStatus,
@@ -25,15 +24,15 @@ import {
import { MessageRepository } from "Core/messages/repositories"
import { MessageService } from "Core/messages/services/message.service"
import { ThreadService } from "Core/messages/services/thread.service"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import assert from "assert"
import { MessageType as MessageTypeFromDTO } from "Core/messages/constants"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const threadService = {
getThreads: jest.fn(),
@@ -46,7 +45,7 @@ const messageRepository = {
} as unknown as MessageRepository
const subject = new MessageService(
- deviceManager,
+ deviceProtocol,
threadService,
messageRepository
)
@@ -118,66 +117,66 @@ beforeEach(() => {
describe("`MessageService`", () => {
describe("`getMessage` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureMessage))
const response = await subject.getMessage("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getMessage("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
describe("`getMessages` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success({ entries: [pureMessage] }))
const response = await subject.getMessages({ limit: 1, offset: 0 })
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getMessages({ limit: 1, offset: 0 })
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
describe("`createMessage` method", () => {
describe("when message is lower than 469 bytes", () => {
- test("the `deviceManager.device.request` is called once", async () => {
- deviceManager.device.request = jest
+ test("the `deviceProtocol.device.request` is called once", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureMessage))
const response = await subject.createMessage(newMessageWithThreadId)
expect(response.status).toEqual(RequestResponseStatus.Ok)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledTimes(1)
+ expect(deviceProtocol.device.request).toHaveBeenCalledTimes(1)
})
})
describe("when message is bigger than 469 bytes", () => {
- test("the `deviceManager.device.request` is called more than once", async () => {
- deviceManager.device.request = jest
+ test("the `deviceProtocol.device.request` is called more than once", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureMessage))
const newLongMessageWithThreadId: NewMessage = {
@@ -188,14 +187,14 @@ describe("`MessageService`", () => {
expect(response.status).toEqual(RequestResponseStatus.Ok)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledTimes(2)
+ expect(deviceProtocol.device.request).toHaveBeenCalledTimes(2)
})
})
describe("when every part of the message is sent successfully", () => {
- describe("when `deviceManager.device.request` returns success with acceptable pure message type", () => {
+ describe("when `deviceProtocol.device.request` returns success with acceptable pure message type", () => {
test("return in response just message when threadId is known", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureMessage))
const response = await subject.createMessage(
@@ -203,7 +202,7 @@ describe("`MessageService`", () => {
)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
assert(response.data?.messageParts)
@@ -214,7 +213,7 @@ describe("`MessageService`", () => {
})
test("return in response message and thread when threadId isn't known", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(pureMessage))
threadService.getThreads = jest.fn().mockReturnValue({
@@ -226,7 +225,7 @@ describe("`MessageService`", () => {
)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
assert(response.data?.messageParts)
@@ -238,9 +237,9 @@ describe("`MessageService`", () => {
})
})
- describe("when `deviceManager.device.request` returns success with no acceptable pure message type", () => {
+ describe("when `deviceProtocol.device.request` returns success with no acceptable pure message type", () => {
test("method returns error", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(
Result.success({ ...pureMessage, messageType: MessageType.UNKNOWN })
@@ -248,25 +247,25 @@ describe("`MessageService`", () => {
const response = await subject.createMessage(newMessageWithThreadId)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
- describe("when `deviceManager.device.request` returns error", () => {
+ describe("when `deviceProtocol.device.request` returns error", () => {
test("method returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.createMessage(newMessageWithThreadId)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
})
- describe("when `deviceManager.device.request` returns error for the second message", () => {
+ describe("when `deviceProtocol.device.request` returns error for the second message", () => {
test("method returns error", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValueOnce({
...successResponse,
@@ -276,7 +275,7 @@ describe("`MessageService`", () => {
const response = await subject.createMessage(newLongMessageWithThreadId)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Error)
})
@@ -289,7 +288,7 @@ describe("`MessageService`", () => {
describe("when everything is fine", () => {
let result: unknown
beforeEach(async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success(undefined))
messageRepository.findById = jest.fn().mockReturnValue(message)
@@ -305,10 +304,10 @@ describe("`MessageService`", () => {
test("construct proper delete request to device service and calls proper repository method", async () => {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledTimes(1)
+ expect(deviceProtocol.device.request).toHaveBeenCalledTimes(1)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
body: {
category: PureMessagesCategory.message,
messageID: 123,
@@ -346,7 +345,7 @@ describe("`MessageService`", () => {
describe("when an error appears", () => {
test("returns error when message was not found in the repository", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(successResponse)
messageRepository.findById = jest.fn().mockReturnValue(undefined)
@@ -361,7 +360,7 @@ describe("`MessageService`", () => {
})
test("returns error when delete request failed", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
messageRepository.findById = jest.fn().mockReturnValue(message)
const result = await subject.deleteMessage(messageId)
expect(result).toEqual({
@@ -373,7 +372,7 @@ describe("`MessageService`", () => {
})
test("returns error when refreshing repository failed", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(successResponse)
messageRepository.findById = jest.fn().mockReturnValue(message)
@@ -399,7 +398,7 @@ describe("`MessageService`", () => {
const result = await subject.resendMessage(messageId)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledTimes(0)
+ expect(deviceProtocol.device.request).toHaveBeenCalledTimes(0)
expect(result).toEqual({
status: RequestResponseStatus.Error,
error: {
@@ -422,14 +421,14 @@ describe("`MessageService`", () => {
phoneNumber: "+48500600700",
messageType: MessageType.INBOX,
})
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValue(Result.success(pureMessage))
const result = await subject.resendMessage(messageId)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
body: {
number: "+48500600700",
messageBody:
@@ -464,9 +463,9 @@ describe("`MessageService`", () => {
})
describe("`updateMessage` method", () => {
- describe("`deviceManager.device` returns success status", () => {
+ describe("`deviceProtocol.device` returns success status", () => {
test("returns success result", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(successResponse)
const result = await subject.updateMessage(message)
@@ -474,7 +473,7 @@ describe("`MessageService`", () => {
expect(result).toEqual(successResponse)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
body: MessagePresenter.mapToUpdatePureMessagesBody(message),
endpoint: Endpoint.Messages,
method: Method.Put,
@@ -482,15 +481,15 @@ describe("`MessageService`", () => {
})
})
- describe("`deviceManager.device` returns failed satus", () => {
+ describe("`deviceProtocol.device` returns failed satus", () => {
test("returns failed result", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const result = await subject.updateMessage(message)
expect(result).toEqual(errorResponse)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
body: MessagePresenter.mapToUpdatePureMessagesBody(message),
endpoint: Endpoint.Messages,
method: Method.Put,
diff --git a/libs/core/messages/services/message.service.ts b/libs/core/messages/services/message.service.ts
index 127f4fdc78..a8043f584c 100644
--- a/libs/core/messages/services/message.service.ts
+++ b/libs/core/messages/services/message.service.ts
@@ -5,11 +5,10 @@
import { ResultObject } from "Core/core/builder"
import {
- Endpoint,
- Method,
MessagesCategory as PureMessagesCategory,
MessageType as PureMessageType,
} from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import {
GetMessagesRequestConfig as PureGetMessagesBody,
Message as PureMessage,
@@ -31,7 +30,7 @@ import {
} from "Core/messages/presenters"
import { MessageRepository } from "Core/messages/repositories"
import { ThreadService } from "Core/messages/services/thread.service"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { mapToRawNumber, splitMessageByBytesSize } from "Core/messages/helpers"
export interface GetMessagesByThreadIdResponse {
@@ -50,7 +49,7 @@ export interface CreateMessageDataResponse {
export class MessageService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private threadService: ThreadService,
private messageRepository: MessageRepository
) {}
@@ -59,7 +58,7 @@ export class MessageService {
public async getMessage(id: string): Promise> {
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Get,
body: {
@@ -94,7 +93,7 @@ export class MessageService {
}
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
body,
endpoint: Endpoint.Messages,
method: Method.Get,
@@ -173,7 +172,7 @@ export class MessageService {
newMessage: NewMessage
): Promise> {
const result =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
body: MessagePresenter.mapToCreatePureMessageBody(newMessage),
endpoint: Endpoint.Messages,
method: Method.Post,
@@ -241,7 +240,7 @@ export class MessageService {
}
}
- const result = await this.deviceManager.device.request({
+ const result = await this.deviceProtocol.device.request({
body: {
category: PureMessagesCategory.message,
messageID: Number(messageId),
@@ -303,7 +302,7 @@ export class MessageService {
}
public async updateMessage(message: Message): Promise> {
- return this.deviceManager.device.request({
+ return this.deviceProtocol.device.request({
body: MessagePresenter.mapToUpdatePureMessagesBody(message),
endpoint: Endpoint.Messages,
method: Method.Put,
diff --git a/libs/core/messages/services/thread.service.test.ts b/libs/core/messages/services/thread.service.test.ts
index f3d61b6e98..268904abfd 100644
--- a/libs/core/messages/services/thread.service.test.ts
+++ b/libs/core/messages/services/thread.service.test.ts
@@ -5,24 +5,24 @@
import { ResultObject, Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { DeviceCommunicationError } from "Core/device/constants"
+import { DeviceCommunicationError } from "core-device/models"
import { Thread as PureThread } from "Core/device/types/mudita-os"
import {
RequestResponseStatus,
SuccessRequestResponse,
} from "Core/core/types/request-response.interface"
import { ThreadService } from "Core/messages/services/thread.service"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { ThreadPresenter } from "Core/messages/presenters"
import { ThreadRepository } from "Core/messages/repositories"
import { Thread } from "Core/messages/dto"
import { MessageType } from "Core/messages/constants"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const threadRepository = {
create: jest.fn(),
@@ -30,7 +30,7 @@ const threadRepository = {
delete: jest.fn(),
} as unknown as ThreadRepository
-const subject = new ThreadService(deviceManager, threadRepository)
+const subject = new ThreadService(deviceProtocol, threadRepository)
const pureThread: PureThread = {
contactID: 1,
@@ -78,21 +78,21 @@ beforeEach(() => {
describe("`ThreadService`", () => {
describe("`getThread` method", () => {
// test skipped until os part will be implemented CP-1232
- test.skip("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(successResponse)
+ test.skip("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(successResponse)
const response = await subject.getThread("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getThread("1")
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toEqual({
status: RequestResponseStatus.Error,
error: {
@@ -103,14 +103,14 @@ describe("`ThreadService`", () => {
})
describe("`getThreads` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(getThreadsSuccessResponse)
const response = await subject.getThreads({ limit: 1, offset: 0 })
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response.status).toEqual(RequestResponseStatus.Ok)
expect(response.data).toMatchInlineSnapshot(`
Object {
@@ -132,12 +132,12 @@ describe("`ThreadService`", () => {
`)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.getThreads({ limit: 1, offset: 0 })
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toEqual({
status: RequestResponseStatus.Error,
error: {
@@ -148,25 +148,25 @@ describe("`ThreadService`", () => {
})
describe("`deleteThreads` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success({ id: "1" }))
const response = await subject.deleteThreads(["1"])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toEqual({
status: RequestResponseStatus.Ok,
})
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.deleteThreads(["1"])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toMatchInlineSnapshot(`
Object {
"error": Object {
@@ -182,25 +182,25 @@ describe("`ThreadService`", () => {
})
describe("`toggleThreadsReadStatus` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(Result.success([thread]))
const response = await subject.toggleThreadsReadStatus([thread])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toEqual({
status: RequestResponseStatus.Ok,
})
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.toggleThreadsReadStatus([thread])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalled()
+ expect(deviceProtocol.device.request).toHaveBeenCalled()
expect(response).toMatchInlineSnapshot(`
Object {
"error": Object {
@@ -226,7 +226,7 @@ describe("`ThreadService`", () => {
describe("`refreshThread` method", () => {
test("returns error when fetching thread failed", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.refreshThread("1")
expect(response).toEqual({
status: RequestResponseStatus.Error,
@@ -238,7 +238,7 @@ describe("`ThreadService`", () => {
describe("when the thread was not found in the device", () => {
test("removes thread from the repository and returns success response", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(getThreadsSuccessResponse)
const response = await subject.refreshThread("6666")
@@ -257,7 +257,7 @@ describe("`ThreadService`", () => {
describe("when the thread was found in the device", () => {
test("updates the thread and returns success response", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(getThreadsSuccessResponse)
const response = await subject.refreshThread("1")
diff --git a/libs/core/messages/services/thread.service.ts b/libs/core/messages/services/thread.service.ts
index fa884ef108..a75316b29d 100644
--- a/libs/core/messages/services/thread.service.ts
+++ b/libs/core/messages/services/thread.service.ts
@@ -4,18 +4,15 @@
*/
import { Thread } from "Core/messages/dto"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import {
GetThreadsRequestConfig,
PaginationBody,
GetThreadResponseBody,
GetThreadsResponseBody,
} from "Core/device/types/mudita-os"
-import {
- Endpoint,
- Method,
- MessagesCategory as PureMessagesCategory,
-} from "Core/device/constants"
+import { MessagesCategory as PureMessagesCategory } from "Core/device/constants"
+import { Endpoint, Method } from "core-device/models"
import {
RequestResponse,
RequestResponseStatus,
@@ -32,7 +29,7 @@ export interface GetThreadsResponse {
export class ThreadService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private threadRepository: ThreadRepository
) {}
@@ -58,7 +55,7 @@ export class ThreadService {
}
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
body,
endpoint: Endpoint.Messages,
method: Method.Get,
@@ -159,7 +156,7 @@ export class ThreadService {
// the method is commented until os part will be implemented as CP-1232
private async getThreadRequest(id: string): Promise> {
const response =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Get,
body: {
@@ -185,7 +182,7 @@ export class ThreadService {
threads: Thread[]
): Promise> {
const results = threads.map(async (thread) => {
- const { ok } = await this.deviceManager.device.request({
+ const { ok } = await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Put,
body: {
@@ -232,7 +229,7 @@ export class ThreadService {
threadIds: string[]
): Promise> {
const results = threadIds.map(async (id) => {
- const { ok } = await this.deviceManager.device.request({
+ const { ok } = await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Delete,
body: { category: PureMessagesCategory.thread, threadID: Number(id) },
diff --git a/libs/core/modals-manager/components/connecting-loader-modal.component.tsx b/libs/core/modals-manager/components/connecting-loader-modal.component.tsx
index acec89e9ab..5138108796 100644
--- a/libs/core/modals-manager/components/connecting-loader-modal.component.tsx
+++ b/libs/core/modals-manager/components/connecting-loader-modal.component.tsx
@@ -7,7 +7,12 @@ import React, { useEffect, useState } from "react"
import { useDispatch, useSelector } from "react-redux"
import { defineMessages } from "react-intl"
import { useHistory } from "react-router-dom"
-import { answerMain, DeviceManagerMainEvent } from "shared/utils"
+import { answerMain } from "shared/utils"
+import {
+ getDevicesSelector,
+ setSelectDeviceDrawerOpen,
+} from "device-manager/feature"
+import { DeviceProtocolMainEvent } from "device-protocol/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
import LoaderModal from "Core/ui/components/loader-modal/loader-modal.component"
@@ -16,7 +21,6 @@ import {
URL_DISCOVERY_DEVICE,
URL_MAIN,
} from "Core/__deprecated__/renderer/constants/urls"
-import { setSelectDeviceDrawerOpen } from "Core/device-select/actions/set-select-device-drawer-open.action"
import { getDiscoveryStatus } from "Core/discovery-device/selectors/get-discovery-status.selector"
import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
@@ -24,6 +28,7 @@ import {
CONNECTING_LOADER_MODAL_ID,
useLoaderSkipOnConnect,
} from "Core/modals-manager/components/use-loader-skip-on-connect.hook"
+import { DeviceState } from "device-manager/models"
const messages = defineMessages({
subtitle: {
@@ -33,28 +38,29 @@ const messages = defineMessages({
const ConnectingLoaderModal: FunctionComponent = () => {
const dispatch = useDispatch()
- const [openModal, setOpenModal] = useState(false)
-
+ const [loaderModalOpened, setLoaderModalOpened] = useState(false)
+ const devices = useSelector(getDevicesSelector)
const history = useHistory()
-
const discoveryStatus = useSelector(getDiscoveryStatus)
const shouldLoaderSkipOnConnect = useLoaderSkipOnConnect()
+ const devicesInProgress = devices.filter((device) => {
+ return [DeviceState.Connected, DeviceState.Initialized].includes(
+ device.state
+ )
+ })
+
useEffect(() => {
- const handler = async () => {
- if (shouldLoaderSkipOnConnect()) {
- setOpenModal(false)
- } else {
- setOpenModal(true)
- }
+ const handler = () => {
+ setLoaderModalOpened(!shouldLoaderSkipOnConnect())
}
const unregisterDeviceConnectedListener = answerMain(
- DeviceManagerMainEvent.DeviceConnected,
+ DeviceProtocolMainEvent.DeviceConnected,
handler
)
const unregisterDeviceConnectFailedListener = answerMain(
- DeviceManagerMainEvent.DeviceConnectFailed,
+ DeviceProtocolMainEvent.DeviceConnectFailed,
handler
)
@@ -67,9 +73,12 @@ const ConnectingLoaderModal: FunctionComponent = () => {
useEffect(() => {
let timeoutId: ReturnType
- if (openModal) {
+ if (loaderModalOpened) {
timeoutId = setTimeout(() => {
- setOpenModal(false)
+ if (devicesInProgress.length > 0) {
+ return
+ }
+ setLoaderModalOpened(false)
const pathname = history.location.pathname
if (
![
@@ -87,7 +96,7 @@ const ConnectingLoaderModal: FunctionComponent = () => {
const unregister = history.listen((location) => {
if (location.pathname.includes(URL_DISCOVERY_DEVICE.root)) {
clearTimeout(timeoutId)
- setOpenModal(false)
+ setLoaderModalOpened(false)
}
})
@@ -95,13 +104,19 @@ const ConnectingLoaderModal: FunctionComponent = () => {
clearTimeout(timeoutId)
unregister()
}
- }, [openModal, dispatch, discoveryStatus, history])
+ }, [
+ devicesInProgress.length,
+ discoveryStatus,
+ dispatch,
+ history,
+ loaderModalOpened,
+ ])
return (
)
diff --git a/libs/core/modals-manager/components/use-loader-skip-on-connect.hook.ts b/libs/core/modals-manager/components/use-loader-skip-on-connect.hook.ts
index f8dd34b93a..4bf07d12ee 100644
--- a/libs/core/modals-manager/components/use-loader-skip-on-connect.hook.ts
+++ b/libs/core/modals-manager/components/use-loader-skip-on-connect.hook.ts
@@ -8,7 +8,7 @@ import { useSelector } from "react-redux"
import { useHistory } from "react-router-dom"
import { URL_DISCOVERY_DEVICE } from "Core/__deprecated__/renderer/constants/urls"
import { checkIsAnyOtherModalPresent } from "Core/utils/check-is-any-other-modal-present"
-import { isActiveDeviceProcessingSelector } from "Core/device-manager/selectors/is-active-device-processing.selector"
+import { isActiveDeviceProcessingSelector } from "Core/device/selectors/is-active-device-processing.selector"
import { isInitializationDeviceInProgress } from "Core/device-initialization/selectors/is-initialization-device-in-progress.selector"
import { isInitializationAppInProgress } from "Core/app-initialization/selectors/is-initialization-app-in-progress.selector"
import { useNoNewDevicesDetectedHook } from "Core/discovery-device/hooks/use-no-new-devices-detected.hook"
diff --git a/libs/core/modals-manager/constants/modal-layers.enum.ts b/libs/core/modals-manager/constants/modal-layers.enum.ts
index 0b69139f0e..dcad329ddb 100644
--- a/libs/core/modals-manager/constants/modal-layers.enum.ts
+++ b/libs/core/modals-manager/constants/modal-layers.enum.ts
@@ -14,5 +14,6 @@ export enum ModalLayers {
UpdateApp,
PrivacyPolicy,
Drawer,
- ConnectingLoader
+ ConnectingLoader,
+ DisconnectedDeviceError
}
diff --git a/libs/core/onboarding/components/onboarding-troubleshooting/onboarding-troubleshooting.component.tsx b/libs/core/onboarding/components/onboarding-troubleshooting/onboarding-troubleshooting.component.tsx
index df9a872a94..c703e7487f 100644
--- a/libs/core/onboarding/components/onboarding-troubleshooting/onboarding-troubleshooting.component.tsx
+++ b/libs/core/onboarding/components/onboarding-troubleshooting/onboarding-troubleshooting.component.tsx
@@ -11,7 +11,7 @@ import OnboardingTroubleshootingUI from "Core/onboarding/components/onboarding-t
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { TmpDispatch } from "Core/__deprecated__/renderer/store"
import { ModalStateKey, showModal } from "Core/modals-manager"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
+import { getDevicesSelector } from "device-manager/feature"
const OnboardingTroubleshooting: FunctionComponent = () => {
const history = useHistory()
diff --git a/libs/core/outbox/factories/outbox.factory.ts b/libs/core/outbox/factories/outbox.factory.ts
index be868c8443..eb603dd0b6 100644
--- a/libs/core/outbox/factories/outbox.factory.ts
+++ b/libs/core/outbox/factories/outbox.factory.ts
@@ -5,7 +5,7 @@
import { EventEmitter } from "events"
import { OutboxEntryType } from "Core/device/constants"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { IndexStorage } from "Core/index-storage/types"
import {
EntryHandlersMapType,
@@ -25,11 +25,11 @@ export class OutboxFactory {
static create(
index: IndexStorage,
eventEmitter: EventEmitter,
- deviceManager: DeviceManager
+ deviceProtocol: DeviceProtocol
): OutboxService {
const contactModel = new ContactModel(index, eventEmitter)
const contactRepository = new ContactRepository(contactModel)
- const contactService = new ContactService(contactRepository, deviceManager)
+ const contactService = new ContactService(contactRepository, deviceProtocol)
const contactEntryHandlerService = new ContactEntryHandlerService(
contactService,
contactRepository
@@ -40,9 +40,9 @@ export class OutboxFactory {
const messageModel = new MessageModel(index, eventEmitter)
const messageRepository = new MessageRepository(messageModel)
- const threadService = new ThreadService(deviceManager, threadRepository)
+ const threadService = new ThreadService(deviceProtocol, threadRepository)
const messageService = new MessageService(
- deviceManager,
+ deviceProtocol,
threadService,
messageRepository
)
@@ -65,6 +65,6 @@ export class OutboxFactory {
[OutboxEntryType.Thread]: threadEntryHandlerService,
}
- return new OutboxService(deviceManager, entryHandlersMap)
+ return new OutboxService(deviceProtocol, entryHandlersMap)
}
}
diff --git a/libs/core/outbox/outbox.module.ts b/libs/core/outbox/outbox.module.ts
index ad1cd82e2d..0ccf2531b9 100644
--- a/libs/core/outbox/outbox.module.ts
+++ b/libs/core/outbox/outbox.module.ts
@@ -11,13 +11,13 @@ import { AppLogger } from "Core/__deprecated__/main/utils/logger"
import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
import { OutboxFactory } from "Core/outbox/factories"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { IndexStorageController } from "Core/outbox/controllers"
export class OutboxModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceModule: DeviceManager,
+ public deviceModule: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
diff --git a/libs/core/outbox/services/outbox.service.test.ts b/libs/core/outbox/services/outbox.service.test.ts
index cfc0c70a70..377d9d5d4b 100644
--- a/libs/core/outbox/services/outbox.service.test.ts
+++ b/libs/core/outbox/services/outbox.service.test.ts
@@ -3,31 +3,27 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Endpoint, Method } from "core-device/models"
import { Result } from "Core/core/builder"
import {
EntryHandlersMapType,
OutboxService,
} from "Core/outbox/services/outbox.service"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { OutboxEntry } from "Core/device/types/mudita-os"
-import {
- OutboxEntryChange,
- OutboxEntryType,
- Endpoint,
- Method,
-} from "Core/device/constants"
+import { OutboxEntryChange, OutboxEntryType } from "Core/device/constants"
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn().mockResolvedValue(Result.success({ entries: [] })),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
const entryHandlersMap = {
[OutboxEntryType.Contact]: {
handleEntry: jest.fn(),
},
} as unknown as EntryHandlersMapType
-const subject = new OutboxService(deviceManager, entryHandlersMap)
+const subject = new OutboxService(deviceProtocol, entryHandlersMap)
const entriesMock: OutboxEntry[] = [
{
@@ -45,14 +41,14 @@ beforeEach(() => {
describe("`OutboxService`", () => {
describe("when Get Outbox Entries returns Contact Entry", () => {
test("outbox `delete` request was called", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(Result.success({ entries: entriesMock }))
await subject.readOutboxEntries()
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenCalledWith({
endpoint: Endpoint.Outbox,
method: Method.Delete,
body: {
@@ -62,7 +58,7 @@ describe("`OutboxService`", () => {
})
test("contact handler was called", async () => {
- deviceManager.device.request = jest
+ deviceProtocol.device.request = jest
.fn()
.mockResolvedValueOnce(Result.success({ entries: entriesMock }))
diff --git a/libs/core/outbox/services/outbox.service.ts b/libs/core/outbox/services/outbox.service.ts
index 6b7d56f866..efd603be91 100644
--- a/libs/core/outbox/services/outbox.service.ts
+++ b/libs/core/outbox/services/outbox.service.ts
@@ -3,19 +3,15 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Endpoint, Method } from "core-device/models"
import { ResultObject } from "Core/core/builder"
import {
GetEntriesResponseBody,
OutboxEntry,
} from "Core/device/types/mudita-os"
-import {
- OutboxEntryType,
- OutboxCategory,
- Method,
- Endpoint,
-} from "Core/device/constants"
+import { OutboxEntryType, OutboxCategory } from "Core/device/constants"
import { asyncNoop } from "Core/__deprecated__/renderer/utils/noop"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { EntryHandler } from "Core/outbox/services/entry-handler.type"
export type EntryHandlersMapType = Record
@@ -24,7 +20,7 @@ export type EntryChangesEvent = { entry: OutboxEntry; payload: unknown }
export class OutboxService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private entryHandlersMap: EntryHandlersMapType
) {}
@@ -56,7 +52,7 @@ export class OutboxService {
private async getOutboxEntriesRequest(): Promise<
ResultObject
> {
- return this.deviceManager.device.request({
+ return this.deviceProtocol.device.request({
endpoint: Endpoint.Outbox,
method: Method.Get,
body: {
@@ -68,7 +64,7 @@ export class OutboxService {
private async deleteOutboxEntriesRequest(
uids: number[]
): Promise> {
- return this.deviceManager.device.request({
+ return this.deviceProtocol.device.request({
endpoint: Endpoint.Outbox,
method: Method.Delete,
body: {
diff --git a/libs/core/overview/components/device-preview/device-image.component.tsx b/libs/core/overview/components/device-preview/device-image.component.tsx
index 7a2e88486a..480cdc933c 100644
--- a/libs/core/overview/components/device-preview/device-image.component.tsx
+++ b/libs/core/overview/components/device-preview/device-image.component.tsx
@@ -4,7 +4,8 @@
*/
import React from "react"
-import { DeviceType, CaseColour } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import Image from "Core/__deprecated__/renderer/components/core/image/image.component"
import { DeviceTestIds } from "Core/overview/components/device-preview/device-preview-test-ids.enum"
@@ -13,6 +14,7 @@ import PureBlackImage from "Core/__deprecated__/renderer/images/pure-black-rende
import KompaktBlackImage from "Core/__deprecated__/renderer/images/kompakt-black-render.png"
import HarmonyGrayImage from "Core/__deprecated__/renderer/images/harmony-gray-render.png"
import HarmonyBlackImage from "Core/__deprecated__/renderer/images/harmony-black-render.png"
+import HarmonyMscImage from "Core/__deprecated__/renderer/images/harmony-msc-render.png"
interface DeviceImageProps {
deviceType: DeviceType
@@ -25,22 +27,42 @@ export const DeviceImage: FunctionComponent = ({
...props
}) => {
if (deviceType === DeviceType.MuditaPure && caseColour === CaseColour.Black) {
- return
+ return (
+
+ )
}
if (deviceType === DeviceType.MuditaPure) {
- return
+ return (
+
+ )
}
- if (deviceType === DeviceType.MuditaHarmony && caseColour === CaseColour.Black) {
- return
+ if (
+ deviceType === DeviceType.MuditaHarmony &&
+ caseColour === CaseColour.Black
+ ) {
+ return
}
if (deviceType === DeviceType.MuditaHarmony) {
- return
+ return
}
+
+ if (deviceType === DeviceType.MuditaHarmonyMsc) {
+ return
+ }
+
if (deviceType === DeviceType.APIDevice) {
- return
+ return
}
return <>>
diff --git a/libs/core/overview/components/device-preview/device-preview.component.tsx b/libs/core/overview/components/device-preview/device-preview.component.tsx
index 1885201590..ea9bc9c195 100644
--- a/libs/core/overview/components/device-preview/device-preview.component.tsx
+++ b/libs/core/overview/components/device-preview/device-preview.component.tsx
@@ -7,7 +7,7 @@ import React from "react"
import styled from "styled-components"
import { defineMessages } from "react-intl"
import { useHistory } from "react-router-dom"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import { DevicePreviewProps } from "Core/overview/components/device-preview/device-preview.interface"
import { intl } from "Core/__deprecated__/renderer/utils/intl"
@@ -91,7 +91,7 @@ export const DevicePreview: FunctionComponent = ({
data-testid={DeviceTestIds.PureSystemButton}
displayStyle={DisplayStyle.LinkWithParagraph}
Icon={IconType.MenuPhone}
- iconSize={IconSize.Bigger}
+ iconSize={IconSize.Large}
/>
)}
diff --git a/libs/core/overview/components/device-preview/device-preview.interface.tsx b/libs/core/overview/components/device-preview/device-preview.interface.tsx
index d19ab0cac6..01e1d0b988 100644
--- a/libs/core/overview/components/device-preview/device-preview.interface.tsx
+++ b/libs/core/overview/components/device-preview/device-preview.interface.tsx
@@ -3,7 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType, CaseColour } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
export interface DevicePreviewProps {
onClick?: () => void
diff --git a/libs/core/overview/components/device-preview/device-preview.stories.tsx b/libs/core/overview/components/device-preview/device-preview.stories.tsx
index 029ca09b56..3d90a059eb 100644
--- a/libs/core/overview/components/device-preview/device-preview.stories.tsx
+++ b/libs/core/overview/components/device-preview/device-preview.stories.tsx
@@ -6,7 +6,7 @@
import React from "react"
import styled from "styled-components"
import { storiesOf } from "@storybook/react"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { DevicePreview } from "Core/overview/components/device-preview/device-preview.component"
const Part = styled.div`
diff --git a/libs/core/overview/components/device-preview/device-preview.test.tsx b/libs/core/overview/components/device-preview/device-preview.test.tsx
index 7ba553ce0a..1011b330d1 100644
--- a/libs/core/overview/components/device-preview/device-preview.test.tsx
+++ b/libs/core/overview/components/device-preview/device-preview.test.tsx
@@ -7,7 +7,8 @@ import React, { ComponentProps } from "react"
import { Provider } from "react-redux"
import thunk from "redux-thunk"
import createMockStore from "redux-mock-store"
-import { CaseColour, DeviceType } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
import { DevicePreview } from "Core/overview/components/device-preview/device-preview.component"
import { DeviceTestIds } from "Core/overview/components/device-preview/device-preview-test-ids.enum"
diff --git a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface.ts b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface.ts
index 47e60992e2..e638f67d2e 100644
--- a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface.ts
+++ b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface.ts
@@ -5,7 +5,8 @@
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
-import { CaseColour, DeviceType } from "Core/device/constants"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import {
CheckForUpdateMode,
DownloadState,
diff --git a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.test.tsx b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.test.tsx
index a89a147b69..ec2bc26ded 100644
--- a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.test.tsx
+++ b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.test.tsx
@@ -14,7 +14,7 @@ import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/rende
import React, { ComponentProps } from "react"
import { Provider } from "react-redux"
import { CheckForUpdateState } from "Core/update/constants/check-for-update-state.constant"
-import { CaseColour } from "Core/device"
+import { CaseColour } from "core-device/models"
jest.mock("Core/settings/store/schemas/generate-application-id", () => ({
generateApplicationId: () => "123",
diff --git a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.tsx b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.tsx
index dfc01fda2f..7ddb5c240d 100644
--- a/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.tsx
+++ b/libs/core/overview/components/overview-screens/harmony-overview/harmony-overview.component.tsx
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { Feature, flags } from "Core/feature-flags"
import { HarmonyOverviewProps } from "Core/overview/components/overview-screens/harmony-overview/harmony-overview.component.interface"
import OverviewContent from "Core/overview/components/overview-screens/harmony-overview/overview-content.component"
@@ -11,12 +11,13 @@ import { UpdateOsFlow } from "Core/overview/components/update-os-flow"
import UpdatingForceModalFlow from "Core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component"
import { CheckForUpdateMode } from "Core/update/constants"
import { OsRelease } from "Core/update/dto"
-import { HelpActions } from "Core/__deprecated__/common/enums/help-actions.enum"
import { FunctionComponent } from "Core/core/types/function-component.interface"
-import { ipcRenderer } from "electron-better-ipc"
import React from "react"
import { CheckForUpdateState } from "Core/update/constants/check-for-update-state.constant"
import { useWatchDeviceDataEffect } from "Core/overview/components/overview-screens/helpers/use-watch-device-data-effect"
+import { useSelector } from "react-redux"
+import { selectDeviceErrorModalOpened } from "generic-view/store"
+import { useHelpShortcut } from "help/store"
export const HarmonyOverview: FunctionComponent = ({
batteryLevel = 0,
@@ -44,9 +45,13 @@ export const HarmonyOverview: FunctionComponent = ({
closeForceUpdateFlow,
caseColour,
}) => {
+ const openHelpShortcut = useHelpShortcut()
+ const genericDeviceErrorModalOpened = useSelector(
+ selectDeviceErrorModalOpened
+ )
useWatchDeviceDataEffect()
const goToHelp = (): void => {
- void ipcRenderer.callMain(HelpActions.OpenWindow)
+ openHelpShortcut("harmony-os-update-fail")
}
const updateReleases = (devReleases?: OsRelease[]) => {
@@ -87,44 +92,50 @@ export const HarmonyOverview: FunctionComponent = ({
return (
<>
- {!forceUpdateNeeded && (
-
- )}
+ {!genericDeviceErrorModalOpened && (
+ <>
+ {!forceUpdateNeeded && (
+
+ )}
- {flags.get(Feature.ForceUpdate) && (
-
+ {flags.get(Feature.ForceUpdate) && (
+
+ )}
+ >
)}
-
= ({
batteryLevel = 0,
@@ -80,6 +80,10 @@ export const PureOverview: FunctionComponent = ({
useWatchDeviceDataEffect()
const activeDeviceAttached = useSelector(isActiveDeviceAttachedSelector)
const deactivateDeviceAndRedirect = useDeactivateDeviceAndRedirect()
+ const genericDeviceErrorModalOpened = useSelector(
+ selectDeviceErrorModalOpened
+ )
+ const openHelpShortcut = useHelpShortcut()
const [openModal, setOpenModal] = useState({
backupStartModal: false,
@@ -115,8 +119,8 @@ export const PureOverview: FunctionComponent = ({
}
}, [openModal, progress])
- const goToHelp = (): void => {
- void ipcRenderer.callMain(HelpActions.OpenWindow)
+ const goToHelp = () => {
+ openHelpShortcut("pure-os-update-fail")
}
const [backupDeviceFlowState, setBackupDeviceFlowState] =
@@ -229,65 +233,72 @@ export const PureOverview: FunctionComponent = ({
return (
<>
- {!forceUpdateNeeded && (
-
- )}
+ {!genericDeviceErrorModalOpened && (
+ <>
+ {!forceUpdateNeeded && (
+
+ )}
- {flags.get(Feature.ForceUpdate) && (
-
- )}
- {backupDeviceFlowState && (
-
- )}
- {restoreDeviceFlowState && (
-
- )}
- {shouldErrorSyncModalVisible() && (
-
+ {flags.get(Feature.ForceUpdate) && (
+
+ )}
+ {backupDeviceFlowState && (
+
+ )}
+ {restoreDeviceFlowState && (
+
+ )}
+ {shouldErrorSyncModalVisible() && (
+
+ )}
+ >
)}
* {
diff --git a/libs/core/overview/components/system/system.test.tsx b/libs/core/overview/components/system/system.test.tsx
index c7f855e0ff..528581fe23 100644
--- a/libs/core/overview/components/system/system.test.tsx
+++ b/libs/core/overview/components/system/system.test.tsx
@@ -10,7 +10,9 @@ import { renderWithThemeAndIntl } from "Core/__deprecated__/renderer/utils/rende
import { intl } from "Core/__deprecated__/renderer/utils/intl"
import System from "Core/overview/components/system/system.component"
import { SystemTestIds } from "Core/overview/components/system/system-test-ids.enum"
-import { CaseColour, DeviceType, PureDeviceData } from "Core/device"
+import { PureDeviceData } from "Core/device"
+import { CaseColour } from "core-device/models"
+import { DeviceType } from "device-protocol/models"
import { Provider } from "react-redux"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import createMockStore from "redux-mock-store"
diff --git a/libs/core/overview/components/update-os-flow/update-os-flow.component.interface.ts b/libs/core/overview/components/update-os-flow/update-os-flow.component.interface.ts
index 141833ac02..c28ad2b5a3 100644
--- a/libs/core/overview/components/update-os-flow/update-os-flow.component.interface.ts
+++ b/libs/core/overview/components/update-os-flow/update-os-flow.component.interface.ts
@@ -5,7 +5,7 @@
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
import {
DownloadState,
diff --git a/libs/core/overview/components/update-os-flow/update-os-flow.component.test.tsx b/libs/core/overview/components/update-os-flow/update-os-flow.component.test.tsx
index e47cb13f54..ce5c50b355 100644
--- a/libs/core/overview/components/update-os-flow/update-os-flow.component.test.tsx
+++ b/libs/core/overview/components/update-os-flow/update-os-flow.component.test.tsx
@@ -5,7 +5,7 @@
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { UpdateOsFlow } from "Core/overview/components/update-os-flow"
import { UpdateOsFlowTestIds } from "Core/overview/components/update-os-flow/update-os-flow-test-ids.enum"
import { UpdateOsFlowProps } from "Core/overview/components/update-os-flow/update-os-flow.component.interface"
diff --git a/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.component.tsx b/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.component.tsx
new file mode 100644
index 0000000000..dfd4b27157
--- /dev/null
+++ b/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.component.tsx
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import React, { FunctionComponent } from "react"
+import { defineMessages } from "react-intl"
+import ErrorModal from "Core/ui/components/error-modal/error-modal.component"
+import { Size } from "Core/__deprecated__/renderer/components/core/button/button.config"
+import { intl } from "Core/__deprecated__/renderer/utils/intl"
+import {
+ CheckForForceUpdateFailedModalProps
+} from "Core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.interface"
+
+const messages = defineMessages({
+ muditaOsUpdateTitle: {
+ id: "module.overview.muditaOsUpdateTitle",
+ },
+ checkForUpdateFailedTitle: {
+ id: "module.overview.checkForForceUpdateFailedTitle",
+ },
+ checkForUpdateFailedDescription: {
+ id: "module.overview.checkForForceUpdateFailedDescription",
+ },
+ checkForUpdateFailedSupportButton: {
+ id: "module.overview.checkForUpdateFailedSupportButton",
+ },
+ checkForUpdateFailedTryAgainButton: {
+ id: "module.overview.checkForUpdateFailedTryAgainButton",
+ },
+})
+
+export const CheckForForceUpdateFailedModal: FunctionComponent<
+ CheckForForceUpdateFailedModalProps
+> = ({
+ onContactSupport,
+ onTryAgain,
+ open,
+ testId,
+ ...rest
+}: CheckForForceUpdateFailedModalProps) => {
+ return (
+
+ )
+}
diff --git a/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.interface.ts b/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.interface.ts
new file mode 100644
index 0000000000..3a812c4caa
--- /dev/null
+++ b/libs/core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.interface.ts
@@ -0,0 +1,14 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ModalDialogProps } from "Core/ui"
+
+export interface CheckForForceUpdateFailedModalProps
+ extends Omit {
+ open: boolean
+ testId?: string
+ onContactSupport: () => void
+ onTryAgain: () => void
+}
diff --git a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.component.tsx b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.component.tsx
index 7317934a36..e7072e5cbd 100644
--- a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.component.tsx
+++ b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.component.tsx
@@ -4,7 +4,7 @@
*/
import { ModalText } from "Core/contacts/components/sync-contacts-modal/sync-contacts.styled"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { OSUpdateModal } from "Core/overview/components/update-os-modals/os-update-modal"
import { TooLowBatteryModalProps } from "Core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.interface"
import { RoundIconWrapper } from "Core/ui/components/modal-dialog"
diff --git a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.interface.ts b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.interface.ts
index 1a0187c6cf..79d8ce4f67 100644
--- a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.interface.ts
+++ b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.interface.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { ModalDialogProps } from "Core/ui"
export interface TooLowBatteryModalProps extends ModalDialogProps {
diff --git a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.stories.tsx b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.stories.tsx
index db1fc5fd4b..631bcc7f0b 100644
--- a/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.stories.tsx
+++ b/libs/core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.stories.tsx
@@ -8,7 +8,7 @@ import { Meta } from "@storybook/react"
import Story from "Core/__deprecated__/renderer/components/storybook/story.component"
import { action } from "@storybook/addon-actions"
import { TooLowBatteryModal } from "Core/overview/components/update-os-modals/too-low-battery-modal/too-low-battery-modal.component"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
export const TooLowBatteryModalStory: FunctionComponent = () => {
return (
diff --git a/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.test.tsx b/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.test.tsx
index abd5781bcc..89d18d0652 100644
--- a/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.test.tsx
+++ b/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.test.tsx
@@ -3,9 +3,12 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Provider } from "react-redux"
+import thunk from "redux-thunk"
+import createMockStore from "redux-mock-store"
import { State } from "Core/core/constants"
import { AppError } from "Core/core/errors"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { UpdatingForceModalFlowTestIds } from "Core/overview/components/updating-force-modal-flow/updating-force-modal-flow-test-ids.enum"
import UpdatingForceModalFlow from "Core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component"
import { UpdatingForceModalFlowProps } from "Core/overview/components/updating-force-modal-flow/updating-force-modal-flow.interface"
@@ -16,11 +19,14 @@ import {
renderWithThemeAndIntl,
} from "Core/__deprecated__/renderer/utils/render-with-theme-and-intl"
import React from "react"
+import { CheckForUpdateState } from "Core/update/constants/check-for-update-state.constant"
+import { ReduxRootState } from "Core/__deprecated__/renderer/store"
const defaultProps: UpdatingForceModalFlowProps = {
deviceType: DeviceType.MuditaPure,
availableReleasesForUpdate: [],
enabled: true,
+ checkForUpdateState: CheckForUpdateState.Initial,
forceUpdateState: State.Initial,
error: null,
updatingReleasesProcessStates: [],
@@ -30,12 +36,26 @@ const defaultProps: UpdatingForceModalFlowProps = {
startForceUpdate: jest.fn(),
}
-const render = (extraProps?: Partial) => {
+const defaultState = {
+ appState: {
+ dialogOpen: false,
+ },
+} as ReduxRootState
+
+const render = (
+ extraProps?: Partial,
+ state = defaultState
+) => {
+ const store = createMockStore([thunk])(state)
const props = {
...defaultProps,
...extraProps,
}
- const outcome = renderWithThemeAndIntl()
+ const outcome = renderWithThemeAndIntl(
+
+
+
+ )
return {
...outcome,
rerender: (newExtraProps: Partial) => {
@@ -44,7 +64,11 @@ const render = (extraProps?: Partial) => {
...newExtraProps,
}
outcome.rerender(
- constructWrapper()
+ constructWrapper(
+
+
+
+ )
)
},
}
diff --git a/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.tsx b/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.tsx
index ddd0177178..53629cc3f6 100644
--- a/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.tsx
+++ b/libs/core/overview/components/updating-force-modal-flow/updating-force-modal-flow.component.tsx
@@ -18,6 +18,13 @@ import { NotEnoughSpaceModal } from "Core/overview/components/update-os-modals/n
import { UpdateOsFlowTestIds } from "Core/overview/components/update-os-flow/update-os-flow-test-ids.enum"
import { OnboardingNotCompleteModal } from "Core/overview/components/onboarding-not-complete-modal"
import { ModalLayers } from "Core/modals-manager/constants/modal-layers.enum"
+import { CheckForUpdateState } from "Core/update/constants/check-for-update-state.constant"
+import {
+ useDeactivateDeviceAndRedirect
+} from "Core/overview/components/overview-screens/pure-overview/use-deactivate-device-and-redirect.hook"
+import {
+ CheckForForceUpdateFailedModal
+} from "Core/overview/components/update-os-modals/check-for-force-update-failed-modal/check-for-force-update-failed-modal.component"
const UpdatingForceModalFlow: FunctionComponent<
UpdatingForceModalFlowProps
@@ -32,16 +39,26 @@ const UpdatingForceModalFlow: FunctionComponent<
forceUpdateState,
closeForceUpdateFlow,
deviceType,
+ checkForUpdateState,
layer = ModalLayers.UpdateOS,
}) => {
+ const deactivateDeviceAndRedirect = useDeactivateDeviceAndRedirect()
const [forceUpdateShowModal, setForceUpdateShowModal] =
useState(false)
const [showErrorModal, setShowErrorModal] = useState(false)
const [showSuccessModal, setShowSuccessModal] = useState(false)
const [showLoadingModal, setShowLoadingModal] = useState(false)
+ const [showCheckForUpdateFailedModal, setShowCheckForUpdateFailedModal] =
+ useState(false)
useEffect(() => {
- if (forceUpdateState === State.Initial && enabled) {
+ if (
+ checkForUpdateState === CheckForUpdateState.Failed &&
+ availableReleasesForUpdate === null
+ ) {
+ setShowCheckForUpdateFailedModal(true)
+ setForceUpdateShowModal(false)
+ } else if (forceUpdateState === State.Initial && enabled) {
setForceUpdateShowModal(true)
} else if (forceUpdateState === State.Loading) {
setShowErrorModal(false)
@@ -56,7 +73,12 @@ const UpdatingForceModalFlow: FunctionComponent<
setForceUpdateShowModal(false)
setShowLoadingModal(false)
}
- }, [forceUpdateState, enabled])
+ }, [
+ forceUpdateState,
+ enabled,
+ checkForUpdateState,
+ availableReleasesForUpdate,
+ ])
const currentlyInstalledReleaseIndex = useMemo(() => {
return (updatingReleasesProcessStates ?? []).findIndex(
@@ -79,6 +101,10 @@ const UpdatingForceModalFlow: FunctionComponent<
closeForceUpdateFlow()
}
+ const tryAgainCheckForUpdate = () => {
+ void deactivateDeviceAndRedirect()
+ }
+
return (
<>
+
+
{availableReleasesForUpdate && availableReleasesForUpdate.length > 0 && (
| null
availableReleasesForUpdate: OsRelease[] | null
updatingReleasesProcessStates: ProcessedRelease[] | null
+ checkForUpdateState: CheckForUpdateState
forceUpdateState: State
deviceType: DeviceType
startForceUpdate: () => void
diff --git a/libs/core/overview/overview.container.tsx b/libs/core/overview/overview.container.tsx
index f9d0070406..9d8eec781b 100644
--- a/libs/core/overview/overview.container.tsx
+++ b/libs/core/overview/overview.container.tsx
@@ -4,6 +4,7 @@
*/
import { connect } from "react-redux"
+import { DeviceType } from "device-protocol/models"
import Overview from "Core/overview/components/overview/overview.component"
import {
ReduxRootState,
@@ -11,7 +12,7 @@ import {
TmpDispatch,
} from "Core/__deprecated__/renderer/store"
import { RootModel } from "Core/__deprecated__/renderer/models/models"
-import { PureDeviceData, DeviceType } from "Core/device"
+import { PureDeviceData } from "Core/device"
import { lastBackupDateSelector } from "Core/backup/selectors"
import {
startBackupDevice,
@@ -38,7 +39,7 @@ import { CheckForUpdateMode } from "Core/update/constants"
import { forceUpdate } from "Core/update/actions/force-update/force-update.action"
import { CheckForUpdateState } from "Core/update/constants/check-for-update-state.constant"
import { isDataSyncInProgressSelector } from "Core/data-sync/selectors/is-data-sync-in-progress.selector"
-import { deactivateDevice } from "Core/device-manager/actions/deactivate-device.action"
+import { deactivateDevice } from "device-manager/feature"
const mapStateToProps = (state: RootModel & ReduxRootState) => {
return {
diff --git a/libs/core/search/search.module.ts b/libs/core/search/search.module.ts
index 3487ffcd04..065840850e 100644
--- a/libs/core/search/search.module.ts
+++ b/libs/core/search/search.module.ts
@@ -19,12 +19,12 @@ import {
import { SearcherMediator } from "Core/search/mediators"
import { SearchService } from "Core/search/services/search.service"
import { SearchController } from "Core/search/controllers/search.controller"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class SearchModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -33,7 +33,7 @@ export class SearchModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
diff --git a/libs/core/settings/actions/load-settings.action.test.ts b/libs/core/settings/actions/load-settings.action.test.ts
index a925acb86f..9c0a9044c4 100644
--- a/libs/core/settings/actions/load-settings.action.test.ts
+++ b/libs/core/settings/actions/load-settings.action.test.ts
@@ -6,7 +6,7 @@
import { AnyAction } from "@reduxjs/toolkit"
import thunk from "redux-thunk"
import createMockStore from "redux-mock-store"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { getConfiguration } from "Core/settings/requests"
import { getSettings } from "Core/settings/requests"
import { SettingsEvent } from "Core/settings/constants"
@@ -23,6 +23,7 @@ jest.mock("Core/settings/requests", () => ({
centerVersion: "1.0.0",
productVersions: {
[DeviceType.MuditaHarmony]: "1.0.0",
+ [DeviceType.MuditaHarmonyMsc]: "1.0.0",
[DeviceType.MuditaPure]: "1.0.0",
},
}),
@@ -68,6 +69,7 @@ test("`loadSettings` action dispatch SettingsEvent.LoadSettings event and calls
lowestSupportedCenterVersion: "1.0.0",
lowestSupportedProductVersion: {
MuditaHarmony: "1.0.0",
+ MuditaHarmonyMsc: "1.0.0",
MuditaPure: "1.0.0",
},
},
diff --git a/libs/core/settings/components/backup/backup.component.tsx b/libs/core/settings/components/backup/backup.component.tsx
index 02b362ddcb..677e417a57 100644
--- a/libs/core/settings/components/backup/backup.component.tsx
+++ b/libs/core/settings/components/backup/backup.component.tsx
@@ -4,13 +4,9 @@
*/
import React from "react"
-import { useDispatch } from "react-redux"
-import { PayloadAction } from "@reduxjs/toolkit"
+import { openFileRequest } from "system-utils/feature"
import { FunctionComponent } from "Core/core/types/function-component.interface"
import BackupUI from "Core/settings/components/backup/backup-ui.component"
-import { TmpDispatch } from "Core/__deprecated__/renderer/store"
-import { getPaths } from "shared/app-state"
-import { ResultObject } from "Core/core/builder"
export interface BackupProps {
setOsBackupLocation: (value: string) => void
@@ -21,16 +17,13 @@ export const Backup: FunctionComponent = ({
setOsBackupLocation,
osBackupLocation,
}) => {
- const dispatch = useDispatch()
-
const openDialog = async () => {
- const { payload: getPathsPayload } = (await dispatch(
- getPaths({
- properties: ["openDirectory"],
- defaultPath: osBackupLocation,
- })
- )) as PayloadAction>
- const location = getPathsPayload.ok && (getPathsPayload.data as string[])[0]
+ const openFileResult = await openFileRequest({
+ properties: ["openDirectory"],
+ defaultPath: osBackupLocation,
+ })
+
+ const location = openFileResult.ok && openFileResult.data[0]
if (location) {
setOsBackupLocation(location)
diff --git a/libs/core/settings/dto/configuration.object.ts b/libs/core/settings/dto/configuration.object.ts
index 05e618fd3d..f21735889a 100644
--- a/libs/core/settings/dto/configuration.object.ts
+++ b/libs/core/settings/dto/configuration.object.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
export interface Configuration {
centerVersion: string
diff --git a/libs/core/settings/reducers/settings.interface.ts b/libs/core/settings/reducers/settings.interface.ts
index 035c2ccdfe..3062f50526 100644
--- a/libs/core/settings/reducers/settings.interface.ts
+++ b/libs/core/settings/reducers/settings.interface.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { Settings } from "Core/settings/dto"
export interface DeviceVersion {
diff --git a/libs/core/settings/reducers/settings.reducer.test.ts b/libs/core/settings/reducers/settings.reducer.test.ts
index c2c1a7bd7c..88b0d630a5 100644
--- a/libs/core/settings/reducers/settings.reducer.test.ts
+++ b/libs/core/settings/reducers/settings.reducer.test.ts
@@ -28,6 +28,7 @@ const settings: SettingsState = {
lowestSupportedCenterVersion: "1.0.0",
lowestSupportedProductVersion: {
MuditaHarmony: "1.5.0",
+ MuditaHarmonyMsc: "1.5.0",
MuditaPure: "1.0.0",
APIDevice: "2.0.0",
},
diff --git a/libs/core/settings/selectors/get-device-lowest-version.selector.test.ts b/libs/core/settings/selectors/get-device-lowest-version.selector.test.ts
index 680c133cca..19c1eb265f 100644
--- a/libs/core/settings/selectors/get-device-lowest-version.selector.test.ts
+++ b/libs/core/settings/selectors/get-device-lowest-version.selector.test.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { initialState } from "Core/settings/reducers"
import { getDeviceLatestVersion } from "Core/settings/selectors/get-device-lowest-version.selector"
@@ -70,6 +70,7 @@ describe("When `deviceType` and `lowestSupportedVersions` has been provided", ()
lowestSupportedCenterVersion: "1.0.0",
lowestSupportedProductVersion: {
MuditaHarmony: "1.0.0",
+ MuditaHarmonyMsc: "1.0.0",
MuditaPure: "2.0.0",
APIDevice: "3.0.0",
},
@@ -90,6 +91,7 @@ describe("When `deviceType` and `lowestSupportedVersions` has been provided", ()
lowestSupportedCenterVersion: "1.0.0",
lowestSupportedProductVersion: {
MuditaHarmony: "1.0.0",
+ MuditaHarmonyMsc: "1.0.0",
MuditaPure: "2.0.0",
APIDevice: "3.0.0",
},
diff --git a/libs/core/settings/selectors/get-device-lowest-version.selector.ts b/libs/core/settings/selectors/get-device-lowest-version.selector.ts
index a7c9151f48..7416304315 100644
--- a/libs/core/settings/selectors/get-device-lowest-version.selector.ts
+++ b/libs/core/settings/selectors/get-device-lowest-version.selector.ts
@@ -5,7 +5,7 @@
import { createSelector } from "reselect"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { deviceTypeSelector } from "Core/device/selectors/device-type.selector"
import { SettingsState } from "Core/settings/reducers/settings.interface"
import { settingsStateSelector } from "Core/settings/selectors/get-settings-state.selector"
diff --git a/libs/core/settings/services/configuration.service.test.ts b/libs/core/settings/services/configuration.service.test.ts
index e357b3eba8..7f8ae4b702 100644
--- a/libs/core/settings/services/configuration.service.test.ts
+++ b/libs/core/settings/services/configuration.service.test.ts
@@ -20,6 +20,7 @@ const configuration: Configuration = {
centerVersion: "1.0.0",
productVersions: {
MuditaHarmony: "1.1.1",
+ MuditaHarmonyMsc: "1.1.1",
MuditaPure: "2.2.2",
APIDevice: "3.3.3",
},
@@ -28,6 +29,7 @@ const defaultConfig = {
centerVersion: "1.0.0-default",
productVersions: {
MuditaHarmony: "1.1.1-default",
+ MuditaHarmonyMsc: "1.1.1-default",
MuditaPure: "2.2.2-default",
},
}
diff --git a/libs/core/settings/services/settings.service.ts b/libs/core/settings/services/settings.service.ts
index a3fb1e0cca..fbf9917ebd 100644
--- a/libs/core/settings/services/settings.service.ts
+++ b/libs/core/settings/services/settings.service.ts
@@ -4,13 +4,14 @@
*/
import Store from "electron-store"
+import { ISettingsService } from "shared/utils"
import { Settings, SettingsUpdateOption } from "Core/settings/dto"
import { settingsSchema } from "Core/settings/store/schemas"
import { SettingsValue } from "Core/settings/types"
// TODO: Les't merge this functionality with `metadata-store.service.ts`
-export class SettingsService {
+export class SettingsService implements ISettingsService {
constructor(private readonly store: Store) {}
init(): void {
diff --git a/libs/core/settings/settings.module.ts b/libs/core/settings/settings.module.ts
index fc52ec424a..4596589950 100644
--- a/libs/core/settings/settings.module.ts
+++ b/libs/core/settings/settings.module.ts
@@ -16,12 +16,12 @@ import {
} from "Core/settings/controllers"
import { ConfigurationService } from "Core/settings/services"
import { getSettingsService } from "Core/settings/containers/settings.container"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class SettingsModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -30,7 +30,7 @@ export class SettingsModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
diff --git a/libs/core/settings/static/app-configuration.json b/libs/core/settings/static/app-configuration.json
index d8e41b89b0..93d2062e87 100644
--- a/libs/core/settings/static/app-configuration.json
+++ b/libs/core/settings/static/app-configuration.json
@@ -1 +1 @@
-{"centerVersion":"2.2.5","productVersions":{"MuditaPure":"1.8.0","MuditaHarmony":"2.0.0"}}
+{"centerVersion": "2.3.1", "productVersions": {"MuditaPure": "1.12.0", "MuditaHarmony": "2.8.0"}}
diff --git a/libs/core/settings/static/default-app-configuration.json b/libs/core/settings/static/default-app-configuration.json
index e7ad996857..e3c2bc92a2 100644
--- a/libs/core/settings/static/default-app-configuration.json
+++ b/libs/core/settings/static/default-app-configuration.json
@@ -1,7 +1,7 @@
{
- "centerVersion": "2.2.5",
+ "centerVersion": "2.3.1",
"productVersions": {
"MuditaPure": "1.12.0",
- "MuditaHarmony": "2.0.0"
+ "MuditaHarmony": "2.8.0"
}
}
diff --git a/libs/core/templates/services/template.service.test.ts b/libs/core/templates/services/template.service.test.ts
index 93e6ff8989..66b0db8d4b 100644
--- a/libs/core/templates/services/template.service.test.ts
+++ b/libs/core/templates/services/template.service.test.ts
@@ -3,11 +3,12 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Endpoint, Method } from "core-device/models"
import { Result, ResultObject } from "Core/core/builder"
-import { MessagesCategory, Method, Endpoint } from "Core/device/constants"
+import { MessagesCategory } from "Core/device/constants"
import { TemplateService } from "Core/templates/services/template.service"
import { TemplateRepository } from "Core/templates/repositories"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import {
ErrorRequestResponse,
RequestResponseStatus,
@@ -20,13 +21,13 @@ const templateRepository = {
delete: jest.fn(),
} as unknown as TemplateRepository
-const deviceManager = {
+const deviceProtocol = {
device: {
request: jest.fn(),
},
-} as unknown as DeviceManager
+} as unknown as DeviceProtocol
-const subject = new TemplateService(deviceManager, templateRepository)
+const subject = new TemplateService(deviceProtocol, templateRepository)
const errorResponse: ErrorRequestResponse = {
status: RequestResponseStatus.Error,
@@ -64,14 +65,14 @@ beforeEach(() => {
describe("`TemplateService`", () => {
describe("`createTemplate` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest
.fn()
.mockReturnValue(successResponseWithTemplate)
const response = await subject.createTemplate(newTemplate)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenNthCalledWith(1, {
+ expect(deviceProtocol.device.request).toHaveBeenNthCalledWith(1, {
endpoint: Endpoint.Messages,
method: Method.Post,
body: {
@@ -83,12 +84,12 @@ describe("`TemplateService`", () => {
expect(response.status).toEqual(RequestResponseStatus.Ok)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.createTemplate(newTemplate)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.Messages,
method: Method.Post,
body: {
@@ -102,12 +103,12 @@ describe("`TemplateService`", () => {
})
describe("`updateTemplate` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(successResponse)
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(successResponse)
const response = await subject.updateTemplate(template)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.Messages,
method: Method.Put,
body: {
@@ -119,12 +120,12 @@ describe("`TemplateService`", () => {
expect(response.status).toEqual(RequestResponseStatus.Ok)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.updateTemplate(template)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.Messages,
method: Method.Put,
body: {
@@ -137,15 +138,15 @@ describe("`TemplateService`", () => {
})
})
describe("`updateTemplateOrder` method", () => {
- test("map data and returns success when `deviceManager.device.request` returns success", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(successResponse)
+ test("map data and returns success when `deviceProtocol.device.request` returns success", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(successResponse)
const response = await subject.updateTemplatesOrder([
template,
secondTemplate,
])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.Messages,
method: Method.Put,
body: {
@@ -157,18 +158,18 @@ describe("`TemplateService`", () => {
expect(response.status).toEqual(RequestResponseStatus.Ok)
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenCalledTimes(2)
+ expect(deviceProtocol.device.request).toHaveBeenCalledTimes(2)
})
- test("returns error when `deviceManager.device.request` returns error", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(errorResponse)
+ test("returns error when `deviceProtocol.device.request` returns error", async () => {
+ deviceProtocol.device.request = jest.fn().mockReturnValue(errorResponse)
const response = await subject.updateTemplatesOrder([
template,
secondTemplate,
])
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/unbound-method
- expect(deviceManager.device.request).toHaveBeenLastCalledWith({
+ expect(deviceProtocol.device.request).toHaveBeenLastCalledWith({
endpoint: Endpoint.Messages,
method: Method.Put,
body: {
@@ -182,7 +183,7 @@ describe("`TemplateService`", () => {
})
test("calls templateRepository update method for each updated template", async () => {
- deviceManager.device.request = jest.fn().mockReturnValue(successResponse)
+ deviceProtocol.device.request = jest.fn().mockReturnValue(successResponse)
await subject.updateTemplatesOrder([template, secondTemplate])
// AUTO DISABLED - fix me if you like :)
diff --git a/libs/core/templates/services/template.service.ts b/libs/core/templates/services/template.service.ts
index 9144ee66ae..ae119f19f1 100644
--- a/libs/core/templates/services/template.service.ts
+++ b/libs/core/templates/services/template.service.ts
@@ -3,9 +3,10 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { Endpoint, Method } from "core-device/models"
import { NewTemplate, Template } from "Core/templates/dto"
-import { DeviceManager } from "Core/device-manager/services"
-import { Endpoint, Method, MessagesCategory } from "Core/device/constants"
+import { DeviceProtocol } from "device-protocol/feature"
+import { MessagesCategory } from "Core/device/constants"
import {
CreateTemplateResponseBody,
PureTemplate,
@@ -23,7 +24,7 @@ import {
export class TemplateService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private templateRepository: TemplateRepository
) {}
@@ -31,23 +32,22 @@ export class TemplateService {
template: NewTemplate
): Promise> {
const createResponse =
- await this.deviceManager.device.request({
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Post,
body: TemplatePresenter.mapToPureNewTemplateBody(template),
})
if (createResponse.ok && createResponse.data) {
- const getResponse = await this.deviceManager.device.request(
- {
+ const getResponse =
+ await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Get,
body: {
templateID: createResponse.data.templateID,
category: MessagesCategory.template,
},
- }
- )
+ })
if (getResponse.ok && getResponse.data) {
const templateData = TemplatePresenter.mapToTemplate(getResponse.data)
@@ -71,7 +71,7 @@ export class TemplateService {
templateIds: string[]
): Promise {
const results = templateIds.map(async (id) => {
- const { ok } = await this.deviceManager.device.request({
+ const { ok } = await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Delete,
body: {
@@ -114,7 +114,7 @@ export class TemplateService {
public async updateTemplate(
template: Template
): Promise> {
- const response = await this.deviceManager.device.request({
+ const response = await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Put,
body: TemplatePresenter.mapToPureTemplateBody(template),
@@ -139,7 +139,7 @@ export class TemplateService {
templates: Template[]
): Promise {
const results = templates.map(async (template) => {
- const { ok } = await this.deviceManager.device.request({
+ const { ok } = await this.deviceProtocol.device.request({
endpoint: Endpoint.Messages,
method: Method.Put,
body: TemplatePresenter.mapToPureTemplateOrder(template),
diff --git a/libs/core/templates/template.module.ts b/libs/core/templates/template.module.ts
index 03b7c04ac3..89e5eb0d1f 100644
--- a/libs/core/templates/template.module.ts
+++ b/libs/core/templates/template.module.ts
@@ -14,12 +14,12 @@ import { TemplateModel } from "Core/templates/models"
import { TemplateRepository } from "Core/templates/repositories"
import { TemplateService } from "Core/templates/services"
import { TemplateController } from "Core/templates/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
export class TemplateModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -28,7 +28,7 @@ export class TemplateModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -38,7 +38,7 @@ export class TemplateModule extends BaseModule {
const templateModel = new TemplateModel(this.index, this.eventEmitter)
const templateRepository = new TemplateRepository(templateModel)
const templateService = new TemplateService(
- this.deviceManager,
+ this.deviceProtocol,
templateRepository
)
const templateController = new TemplateController(templateService)
diff --git a/libs/core/ui/components/modal-dialog/get-modal-dialog-style.helper.ts b/libs/core/ui/components/modal-dialog/get-modal-dialog-style.helper.ts
index f641beab8f..b20be87285 100644
--- a/libs/core/ui/components/modal-dialog/get-modal-dialog-style.helper.ts
+++ b/libs/core/ui/components/modal-dialog/get-modal-dialog-style.helper.ts
@@ -3,9 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import muditaTheme, {
- Theme,
-} from "Core/core/styles/theming/theme"
+import muditaTheme, { Theme } from "Core/core/styles/theming/theme"
import {
backgroundColor,
zIndex as getZIndex,
@@ -16,6 +14,7 @@ import { Styles } from "react-modal"
export interface GetModalDialogStyleProps {
size: ModalProps["size"]
+ noOverlayBg?: boolean
zIndex?: number
theme?: Theme
}
@@ -36,6 +35,11 @@ const getModalSize = (size: ModalProps["size"]) => {
return {
width: "59rem",
}
+ case ModalSize.MediumNew:
+ return {
+ width: "56.6rem",
+ padding: "2.4rem",
+ }
case ModalSize.Large:
return {
width: "101rem",
@@ -49,12 +53,15 @@ export const getModalDialogStyle = ({
zIndex,
size,
theme = muditaTheme,
+ noOverlayBg = false,
}: GetModalDialogStyleProps): Styles => {
return {
overlay: {
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- backgroundColor: backgroundColor("modalBackdrop")({ theme }),
+ backgroundColor: noOverlayBg
+ ? "transparent"
+ : backgroundColor("modalBackdrop")({ theme }),
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
zIndex: zIndex ? zIndex : getZIndex("modalBackdrop")({ theme }),
diff --git a/libs/core/ui/components/modal-dialog/modal-dialog.component.tsx b/libs/core/ui/components/modal-dialog/modal-dialog.component.tsx
index ef8641f8e1..cc88ae784a 100644
--- a/libs/core/ui/components/modal-dialog/modal-dialog.component.tsx
+++ b/libs/core/ui/components/modal-dialog/modal-dialog.component.tsx
@@ -65,6 +65,7 @@ export const ModalDialog: FunctionComponent = withTheme(
actionButtonSize,
actionButtonDisabled,
theme,
+ noOverlayBg,
...props
}) => {
const closeModalByButtonClick = () => {
@@ -87,39 +88,43 @@ export const ModalDialog: FunctionComponent = withTheme(
isOpen={open}
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- style={getModalDialogStyle({ zIndex: layer, size, theme })}
+ style={getModalDialogStyle({ zIndex: layer, size, theme, noOverlayBg })}
shouldCloseOnOverlayClick={false}
// AUTO DISABLED - fix me if you like :)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
onAfterClose={onClose}
{...props}
>
- {(title || subtitle || closeModal) &&
- {title &&
- {title}
- }
- {Boolean(closeModal) && close}
-
- {subtitle}
-
- }
+ {title && (
+
+ {title}
+
+ )}
+ {Boolean(closeModal) && close}
+
+ {subtitle}
+
+
+ )}
{children}
{actionButtonLabel || closeButton ? (
// AUTO DISABLED - fix me if you like :)
diff --git a/libs/core/ui/components/modal-dialog/modal-dialog.interface.ts b/libs/core/ui/components/modal-dialog/modal-dialog.interface.ts
index 7fab4979b0..9109e4af14 100644
--- a/libs/core/ui/components/modal-dialog/modal-dialog.interface.ts
+++ b/libs/core/ui/components/modal-dialog/modal-dialog.interface.ts
@@ -14,6 +14,7 @@ export interface ModalDialogProps extends Omit, ModalProps {
close?: ComponentProps
closeModal?: () => void
open: boolean
+ noOverlayBg?: boolean
theme?: GetModalDialogStyleProps["theme"]
layer?: ModalLayers
}
diff --git a/libs/core/ui/components/password-field/password-filed.component.tsx b/libs/core/ui/components/password-field/password-filed.component.tsx
index 361b36a7fb..5077f6bf29 100644
--- a/libs/core/ui/components/password-field/password-filed.component.tsx
+++ b/libs/core/ui/components/password-field/password-filed.component.tsx
@@ -51,7 +51,7 @@ export const PasswordField = React.forwardRef<
onClick={handleToggleInputType}
>
(
UpdateOsEvent.SetCheckForUpdateState
)
export const closeUpdateFlow = createAction(UpdateOsEvent.CloseUpdateFlow)
-export const clearStateAndData = createAction(UpdateOsEvent.ClearStateAndData)
export const cancelDownload = createAction(UpdateOsEvent.CancelDownload)
export const setStateForDownloadedRelease = createAction<{
version: string
@@ -25,4 +24,6 @@ export const setStateForInstalledRelease = createAction<{
version: string
state: ReleaseProcessState
}>(UpdateOsEvent.SetStateForInstalledRelease)
-export const setTmpMuditaHarmonyPortInfo = createAction(UpdateOsEvent.SetTmpMuditaHarmonyPortInfo)
+export const setTmpMuditaHarmonyPortInfo = createAction(
+ UpdateOsEvent.SetTmpMuditaHarmonyPortInfo
+)
diff --git a/libs/core/update/actions/check-for-force-update-need/check-for-force-update-need.action.test.ts b/libs/core/update/actions/check-for-force-update-need/check-for-force-update-need.action.test.ts
index e64ee8d7c4..e15edda4cd 100644
--- a/libs/core/update/actions/check-for-force-update-need/check-for-force-update-need.action.test.ts
+++ b/libs/core/update/actions/check-for-force-update-need/check-for-force-update-need.action.test.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { checkForForceUpdateNeed } from "Core/update/actions/check-for-force-update-need/check-for-force-update-need.action"
import { CheckForUpdateMode, UpdateOsEvent } from "Core/update/constants"
import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
diff --git a/libs/core/update/actions/check-for-update/check-for-update.action.test.ts b/libs/core/update/actions/check-for-update/check-for-update.action.test.ts
index 7929523c12..537ed85f95 100644
--- a/libs/core/update/actions/check-for-update/check-for-update.action.test.ts
+++ b/libs/core/update/actions/check-for-update/check-for-update.action.test.ts
@@ -6,7 +6,7 @@
import { AnyAction } from "@reduxjs/toolkit"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import { checkForUpdate } from "Core/update/actions"
import {
Product,
@@ -84,7 +84,7 @@ describe("when fetching all releases fails", () => {
osVersion: "1.2.0",
},
},
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -120,7 +120,7 @@ describe("when latest release os version is not greater than current os version"
osVersion: "1.1.0",
},
},
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -166,7 +166,7 @@ describe("when latest release os version is greater than current os version", ()
osVersion: "1.2.0",
},
},
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -237,7 +237,7 @@ describe("when latest release contains information about mandatory releases", ()
osVersion: "1.2.0",
},
},
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
@@ -288,7 +288,7 @@ describe("when fetching mandatory releases fails", () => {
osVersion: "1.2.0",
},
},
- deviceManager: {
+ activeDeviceRegistry: {
activeDeviceId: "",
},
})
diff --git a/libs/core/update/actions/check-for-update/check-for-update.action.ts b/libs/core/update/actions/check-for-update/check-for-update.action.ts
index 086949aab0..e58364c1a5 100644
--- a/libs/core/update/actions/check-for-update/check-for-update.action.ts
+++ b/libs/core/update/actions/check-for-update/check-for-update.action.ts
@@ -5,7 +5,7 @@
import { createAsyncThunk } from "@reduxjs/toolkit"
import { AppError } from "Core/core/errors"
-import { DeviceType } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import isVersionGreaterOrEqual from "Core/utils/is-version-greater-or-equal"
import {
CheckForUpdateMode,
@@ -21,7 +21,7 @@ import {
osUpdateAlreadyDownloadedCheck,
} from "Core/update/requests"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { isActiveDeviceSet } from "Core/device-manager/selectors/is-active-device-set.selector"
+import { isActiveDeviceSet } from "active-device-registry/feature"
interface Params {
deviceType: DeviceType
diff --git a/libs/core/update/actions/download-updates/download-updates.action.test.ts b/libs/core/update/actions/download-updates/download-updates.action.test.ts
index 911fa94da6..9c0a6da9b6 100644
--- a/libs/core/update/actions/download-updates/download-updates.action.test.ts
+++ b/libs/core/update/actions/download-updates/download-updates.action.test.ts
@@ -4,6 +4,10 @@
*/
import { AnyAction } from "@reduxjs/toolkit"
+import createMockStore from "redux-mock-store"
+import thunk from "redux-thunk"
+import { CoreDeviceState } from "core-device/models"
+import { ActiveDeviceRegistryState } from "active-device-registry/models"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { downloadUpdates } from "Core/update/actions/download-updates/download-updates.action"
@@ -22,10 +26,7 @@ import {
import { testError } from "Core/__deprecated__/renderer/store/constants"
import * as downloadOsUpdateRequestModule from "Core/update/requests/download-os-update.request"
import * as osUpdateAlreadyDownloadedCheckModule from "Core/update/requests/os-update-already-downloaded.request"
-import createMockStore from "redux-mock-store"
-import thunk from "redux-thunk"
import { trackOsDownload } from "Core/analytic-data-tracker/helpers/track-os-download"
-import { DeviceManagerState } from "Core/device-manager/reducers/device-manager.interface"
jest.mock("Core/analytic-data-tracker/helpers/track-os-download")
@@ -63,10 +64,13 @@ const mockedRelease2: OsRelease = {
mandatoryVersions: [],
}
-const mockedDeviceManagerState = {
+const mockedCoreDeviceState = {
devices: [{ id: "1" }],
+} as unknown as CoreDeviceState
+
+const mockedActiveDeviceRegistryState = {
activeDeviceId: "1",
-} as unknown as DeviceManagerState
+} as unknown as ActiveDeviceRegistryState
const params = { releases: [mockedRelease, mockedRelease2] }
@@ -128,7 +132,11 @@ describe("when some of the updates have been downloaded before", () => {
batteryLevel: 0.55,
},
},
- deviceManager: mockedDeviceManagerState,
+ coreDevice: mockedCoreDeviceState,
+ activeDeviceRegistry: mockedActiveDeviceRegistryState,
+ genericViews: {
+ devices: [],
+ }
})
const {
@@ -187,7 +195,11 @@ describe("when update downloads successfully", () => {
batteryLevel: 0.55,
},
},
- deviceManager: mockedDeviceManagerState,
+ coreDevice: mockedCoreDeviceState,
+ activeDeviceRegistry: mockedActiveDeviceRegistryState,
+ genericViews: {
+ devices: [],
+ }
})
const {
@@ -242,7 +254,11 @@ describe("when download is cancelled by user", () => {
batteryLevel: 0.55,
},
},
- deviceManager: mockedDeviceManagerState,
+ coreDevice: mockedCoreDeviceState,
+ activeDeviceRegistry: mockedActiveDeviceRegistryState,
+ genericViews: {
+ devices: [],
+ }
})
const {
@@ -290,7 +306,11 @@ describe("when download failed", () => {
batteryLevel: 0.55,
},
},
- deviceManager: mockedDeviceManagerState,
+ coreDevice: mockedCoreDeviceState,
+ activeDeviceRegistry: mockedActiveDeviceRegistryState,
+ genericViews: {
+ devices: [],
+ }
})
const {
diff --git a/libs/core/update/actions/download-updates/download-updates.action.ts b/libs/core/update/actions/download-updates/download-updates.action.ts
index 9133afa7b0..edbce88cad 100644
--- a/libs/core/update/actions/download-updates/download-updates.action.ts
+++ b/libs/core/update/actions/download-updates/download-updates.action.ts
@@ -23,7 +23,7 @@ import {
} from "Core/update/requests"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
import { RELEASE_SPACE } from "Core/update/constants/release-space.constant"
-import { isActiveDeviceAttachedSelector } from "Core/device-manager/selectors/is-active-device-attached.selector"
+import { isActiveDeviceAttachedSelector } from "device-manager/feature"
interface Params {
releases: OsRelease[]
diff --git a/libs/core/update/actions/start-update-os/start-update-os.action.test.ts b/libs/core/update/actions/start-update-os/start-update-os.action.test.ts
index ee3ea607e7..7fe7f81ab5 100644
--- a/libs/core/update/actions/start-update-os/start-update-os.action.test.ts
+++ b/libs/core/update/actions/start-update-os/start-update-os.action.test.ts
@@ -6,6 +6,9 @@
import { AnyAction } from "@reduxjs/toolkit"
import createMockStore from "redux-mock-store"
import thunk from "redux-thunk"
+import { DeviceType } from "device-protocol/models"
+import { ActiveDeviceRegistryState } from "active-device-registry/models"
+import { GenericState } from "generic-view/store"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import {
@@ -26,8 +29,8 @@ import {
trackOsUpdate,
TrackOsUpdateState,
} from "Core/analytic-data-tracker/helpers"
-import { DeviceType, setRestartingStatus } from "Core/device"
-import { DeviceManagerState } from "Core/device-manager/reducers/device-manager.interface"
+import { setRestartingStatus } from "Core/device"
+import { CoreDeviceState } from "core-device/models"
import { startUpdateOs } from "Core/update/actions"
jest.mock("Core/update/requests/remove-downloaded-os-updates.request")
@@ -169,15 +172,20 @@ describe("when all updating os requests return success status", () => {
osVersion: "1.0.0",
},
},
- deviceManager: {
+ coreDevice: {
devices: [
{
id: "1",
deviceType: DeviceType.MuditaPure,
},
],
- activeDeviceId: "1"
- } as unknown as DeviceManagerState,
+ } as unknown as CoreDeviceState,
+ genericViews: {
+ devices: []
+ } as unknown as GenericState,
+ activeDeviceRegistry: {
+ activeDeviceId: "1",
+ } as unknown as ActiveDeviceRegistryState,
})
beforeEach(() => {
@@ -281,15 +289,20 @@ describe("when updating os request return failure status", () => {
osVersion: "1.0.0",
},
},
- deviceManager: {
+ coreDevice: {
devices: [
{
id: "1",
deviceType: DeviceType.MuditaPure,
},
],
- activeDeviceId: "1"
- } as unknown as DeviceManagerState,
+ } as unknown as CoreDeviceState,
+ genericViews: {
+ devices: []
+ } as unknown as GenericState,
+ activeDeviceRegistry: {
+ activeDeviceId: "1",
+ } as unknown as ActiveDeviceRegistryState,
})
test("action is rejected", async () => {
diff --git a/libs/core/update/actions/start-update-os/start-update-os.action.ts b/libs/core/update/actions/start-update-os/start-update-os.action.ts
index cb6a3141fc..b16cd3b3b7 100644
--- a/libs/core/update/actions/start-update-os/start-update-os.action.ts
+++ b/libs/core/update/actions/start-update-os/start-update-os.action.ts
@@ -6,7 +6,8 @@
import { createAsyncThunk } from "@reduxjs/toolkit"
import { AppError } from "Core/core/errors"
import { removeFile } from "Core/device-file-system"
-import { DeviceType, DiagnosticsFilePath } from "Core/device/constants"
+import { DiagnosticsFilePath } from "Core/device/constants"
+import { DeviceType } from "device-protocol/models"
import {
setStateForInstalledRelease,
setTmpMuditaHarmonyPortInfo,
@@ -28,7 +29,7 @@ import {
} from "Core/analytic-data-tracker/helpers"
import { checkUpdate } from "Core/update/requests/checkUpdate.request"
import { setRestartingStatus } from "Core/device"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
+import { getActiveDevice } from "device-manager/feature"
interface Params {
releases: OsRelease[]
diff --git a/libs/core/update/components/update-os-interrupted-flow/update-os-interrupted-flow.container.tsx b/libs/core/update/components/update-os-interrupted-flow/update-os-interrupted-flow.container.tsx
index 63256e82aa..10bc419804 100644
--- a/libs/core/update/components/update-os-interrupted-flow/update-os-interrupted-flow.container.tsx
+++ b/libs/core/update/components/update-os-interrupted-flow/update-os-interrupted-flow.container.tsx
@@ -16,8 +16,10 @@ import {
RootState,
TmpDispatch,
} from "Core/__deprecated__/renderer/store"
-import { isActiveDeviceAttachedSelector } from "Core/device-manager/selectors/is-active-device-attached.selector"
-import { deactivateDevice } from "Core/device-manager/actions/deactivate-device.action"
+import {
+ deactivateDevice,
+ isActiveDeviceAttachedSelector,
+} from "device-manager/feature"
const mapStateToProps = (state: RootState & ReduxRootState) => {
return {
diff --git a/libs/core/update/constants/event.constant.ts b/libs/core/update/constants/event.constant.ts
index 6b16ae90b3..f696df94e5 100644
--- a/libs/core/update/constants/event.constant.ts
+++ b/libs/core/update/constants/event.constant.ts
@@ -10,7 +10,6 @@ export enum UpdateOsEvent {
SetCheckForUpdateState = "SET_CHECK_FOR_UPDATE_STATE",
CancelDownload = "CANCEL_DOWNLOAD",
CloseUpdateFlow = "CLOSE_UPDATE_FLOW",
- ClearStateAndData = "CLEAR_STATE_AND_DATA",
SetStateForDownloadedRelease = "SET_STATE_FOR_DOWNLOADED_RELEASE",
SetStateForInstalledRelease = "SET_STATE_FOR_INSTALLED_RELEASE",
HandleDeviceAttached = "HANDLE_DEVICE_ATTACHED",
diff --git a/libs/core/update/reducers/update-os.reducer.test.ts b/libs/core/update/reducers/update-os.reducer.test.ts
index 2540e39153..a957e9eb44 100644
--- a/libs/core/update/reducers/update-os.reducer.test.ts
+++ b/libs/core/update/reducers/update-os.reducer.test.ts
@@ -598,37 +598,6 @@ describe("closeUpdateFlow", () => {
})
})
-describe("clearStateAndData", () => {
- test("clear states and data", () => {
- const data = {
- ...initialState.data,
- downloadedProcessedReleases: [
- { release: mockedRelease, state: ReleaseProcessState.Done },
- ],
- availableReleasesForUpdate: [mockedRelease],
- updateProcessedReleases: [
- { release: mockedRelease, state: ReleaseProcessState.Initial },
- ],
- }
-
- expect(
- updateOsReducer(
- {
- ...initialState,
- error: exampleError,
- updateOsState: State.Failed,
- data,
- },
- {
- type: UpdateOsEvent.ClearStateAndData,
- }
- )
- ).toEqual({
- ...initialState,
- })
- })
-})
-
describe("checkForForceUpdateNeed", () => {
test("sets needsForceUpdate according to the action result and checkedForForceUpdateNeed as true", () => {
expect(
diff --git a/libs/core/update/reducers/update-os.reducer.ts b/libs/core/update/reducers/update-os.reducer.ts
index 1d2e286a51..90c3903e89 100644
--- a/libs/core/update/reducers/update-os.reducer.ts
+++ b/libs/core/update/reducers/update-os.reducer.ts
@@ -4,13 +4,13 @@
*/
import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerEvent } from "device-manager/models"
import { State } from "Core/core/constants"
import { CheckForUpdateState } from "../constants/check-for-update-state.constant"
import { AppError } from "Core/core/errors"
import {
cancelDownload,
checkForUpdate,
- clearStateAndData,
closeUpdateFlow,
downloadUpdates,
setCheckForUpdateState,
@@ -22,7 +22,6 @@ import {
checkForForceUpdateNeed,
setTmpMuditaHarmonyPortInfo,
} from "Core/update/actions"
-
import {
CheckForUpdateMode,
DownloadState,
@@ -31,6 +30,7 @@ import {
UpdateError,
} from "Core/update/constants"
import { UpdateOsState } from "Core/update/reducers/update-os.interface"
+import { pendingAction } from "Core/__deprecated__/renderer/store/helpers"
export const initialState: UpdateOsState = {
silentCheckForUpdate: SilentCheckForUpdateState.Initial,
@@ -52,265 +52,266 @@ export const initialState: UpdateOsState = {
export const updateOsReducer = createReducer(
initialState,
(builder) => {
- builder.addCase(closeForceUpdateFlow, (state) => {
- return {
- ...state,
- forceUpdateState: State.Initial,
- }
- })
- builder.addCase(setCheckForUpdateState, (state, action) => {
- return {
- ...state,
- checkForUpdateState: action.payload,
- }
- })
- builder.addCase(closeUpdateFlow, (state) => {
- const { PerformedWithFailure, Performed, Initial, Failed } =
- CheckForUpdateState
- let silentCheckForUpdate: SilentCheckForUpdateState =
- state.silentCheckForUpdate
- let checkForUpdateState: CheckForUpdateState = Initial
- if (silentCheckForUpdate === SilentCheckForUpdateState.Failed) {
- silentCheckForUpdate = SilentCheckForUpdateState.Skipped
- }
- if (
- state.checkForUpdateState !== Initial &&
- state.checkForUpdateState === Failed
- ) {
- checkForUpdateState = PerformedWithFailure
- } else if (state.checkForUpdateState !== Initial) {
- checkForUpdateState = Performed
- }
- return {
- ...state,
- error: null,
- silentCheckForUpdate,
- checkForUpdateState,
- updateOsState: State.Initial,
- downloadState: DownloadState.Initial,
- }
- })
- builder.addCase(clearStateAndData, (state) => {
- return {
- ...initialState,
- tmpMuditaHarmonyPortInfo: state.tmpMuditaHarmonyPortInfo,
- }
- })
- builder.addCase(setStateForDownloadedRelease, (state, action) => {
- const { state: newReleaseState, version } = action.payload
- const newDownloadedProcessedReleases = (
- state.data.downloadedProcessedReleases ?? []
- ).map((item) =>
- item.release.version === version
- ? {
- ...item,
- state: newReleaseState,
- }
- : item
- )
-
- return {
- ...state,
- data: {
- ...state.data,
- downloadedProcessedReleases: newDownloadedProcessedReleases,
- },
- }
- })
- builder.addCase(setStateForInstalledRelease, (state, action) => {
- const { state: newReleaseState, version } = action.payload
- const newUpdateProcessedReleases = (
- state.data.updateProcessedReleases ?? []
- ).map((item) =>
- item.release.version === version
- ? {
- ...item,
- state: newReleaseState,
- }
- : item
- )
-
- const newAvailableReleasesForUpdate = (
- state.data.availableReleasesForUpdate ?? []
- ).filter(
- (release) =>
- !(
- release.version === version &&
- newReleaseState === ReleaseProcessState.Done
- )
- )
-
- return {
- ...state,
- data: {
- ...state.data,
- updateProcessedReleases: newUpdateProcessedReleases,
- availableReleasesForUpdate: newAvailableReleasesForUpdate,
- },
- }
- })
-
- builder.addCase(checkForUpdate.pending, (state, payload) => {
- state.error = null
- state.data = {
- availableReleasesForUpdate: null,
- downloadedProcessedReleases: null,
- updateProcessedReleases: null,
- }
-
- const {
- meta: {
- arg: { mode },
- },
- } = payload
-
- if (mode === CheckForUpdateMode.SilentCheck) {
- state.silentCheckForUpdate = SilentCheckForUpdateState.Loading
- state.checkForUpdateState = CheckForUpdateState.Initial
- } else if (mode === CheckForUpdateMode.TryAgain) {
- state.silentCheckForUpdate = SilentCheckForUpdateState.Skipped
- state.checkForUpdateState = CheckForUpdateState.Loading
- } else {
- state.checkForUpdateState = CheckForUpdateState.Loading
- }
- })
- builder.addCase(checkForUpdate.fulfilled, (state, action) => {
- state.data.availableReleasesForUpdate =
- action.payload.availableReleasesForUpdate
- if (action.meta.arg.mode === CheckForUpdateMode.SilentCheck) {
- state.silentCheckForUpdate = SilentCheckForUpdateState.Loaded
- } else {
- state.checkForUpdateState = CheckForUpdateState.Loaded
- }
- if (action.payload.areAllReleasesAlreadyDownloaded) {
- state.data.downloadedProcessedReleases =
- action.payload.availableReleasesForUpdate.map((release) => ({
- release,
- state: ReleaseProcessState.Done,
- }))
- }
- })
- builder.addCase(checkForUpdate.rejected, (state, action) => {
- const error = action.payload as AppError
-
- if (error?.type === UpdateError.NoActiveDevice) {
- return { ...initialState }
- }
-
- if (
- action.meta.aborted &&
- action.meta.arg.mode === CheckForUpdateMode.SilentCheck
- ) {
+ builder
+ .addCase(closeForceUpdateFlow, (state) => {
+ return {
+ ...state,
+ forceUpdateState: State.Initial,
+ }
+ })
+ .addCase(setCheckForUpdateState, (state, action) => {
+ return {
+ ...state,
+ checkForUpdateState: action.payload,
+ }
+ })
+ .addCase(closeUpdateFlow, (state) => {
+ const { PerformedWithFailure, Performed, Initial, Failed } =
+ CheckForUpdateState
+ let silentCheckForUpdate: SilentCheckForUpdateState =
+ state.silentCheckForUpdate
+ let checkForUpdateState: CheckForUpdateState = Initial
+ if (silentCheckForUpdate === SilentCheckForUpdateState.Failed) {
+ silentCheckForUpdate = SilentCheckForUpdateState.Skipped
+ }
+ if (
+ state.checkForUpdateState !== Initial &&
+ state.checkForUpdateState === Failed
+ ) {
+ checkForUpdateState = PerformedWithFailure
+ } else if (state.checkForUpdateState !== Initial) {
+ checkForUpdateState = Performed
+ }
return {
...state,
error: null,
- silentCheckForUpdate: SilentCheckForUpdateState.Initial,
+ silentCheckForUpdate,
+ checkForUpdateState,
+ updateOsState: State.Initial,
+ downloadState: DownloadState.Initial,
+ }
+ })
+ .addCase(pendingAction(DeviceManagerEvent.DeactivateDevice), (state) => {
+ return {
+ ...initialState,
+ tmpMuditaHarmonyPortInfo: state.tmpMuditaHarmonyPortInfo,
}
- } else if (action.meta.arg.mode === CheckForUpdateMode.SilentCheck) {
+ })
+ .addCase(setStateForDownloadedRelease, (state, action) => {
+ const { state: newReleaseState, version } = action.payload
+ const newDownloadedProcessedReleases = (
+ state.data.downloadedProcessedReleases ?? []
+ ).map((item) =>
+ item.release.version === version
+ ? {
+ ...item,
+ state: newReleaseState,
+ }
+ : item
+ )
+
return {
...state,
- error: error ?? null,
- silentCheckForUpdate: SilentCheckForUpdateState.Failed,
+ data: {
+ ...state.data,
+ downloadedProcessedReleases: newDownloadedProcessedReleases,
+ },
}
- } else {
+ })
+ .addCase(setStateForInstalledRelease, (state, action) => {
+ const { state: newReleaseState, version } = action.payload
+ const newUpdateProcessedReleases = (
+ state.data.updateProcessedReleases ?? []
+ ).map((item) =>
+ item.release.version === version
+ ? {
+ ...item,
+ state: newReleaseState,
+ }
+ : item
+ )
+
+ const newAvailableReleasesForUpdate = (
+ state.data.availableReleasesForUpdate ?? []
+ ).filter(
+ (release) =>
+ !(
+ release.version === version &&
+ newReleaseState === ReleaseProcessState.Done
+ )
+ )
+
return {
...state,
- error: error ?? null,
- checkForUpdateState: CheckForUpdateState.Failed,
+ data: {
+ ...state.data,
+ updateProcessedReleases: newUpdateProcessedReleases,
+ availableReleasesForUpdate: newAvailableReleasesForUpdate,
+ },
+ }
+ })
+
+ .addCase(checkForUpdate.pending, (state, payload) => {
+ state.error = null
+ state.data = {
+ availableReleasesForUpdate: null,
+ downloadedProcessedReleases: null,
+ updateProcessedReleases: null,
+ }
+
+ const {
+ meta: {
+ arg: { mode },
+ },
+ } = payload
+
+ if (mode === CheckForUpdateMode.SilentCheck) {
+ state.silentCheckForUpdate = SilentCheckForUpdateState.Loading
+ state.checkForUpdateState = CheckForUpdateState.Initial
+ } else if (mode === CheckForUpdateMode.TryAgain) {
+ state.silentCheckForUpdate = SilentCheckForUpdateState.Skipped
+ state.checkForUpdateState = CheckForUpdateState.Loading
+ } else {
+ state.checkForUpdateState = CheckForUpdateState.Loading
+ }
+ })
+ .addCase(checkForUpdate.fulfilled, (state, action) => {
+ state.data.availableReleasesForUpdate =
+ action.payload.availableReleasesForUpdate
+ if (action.meta.arg.mode === CheckForUpdateMode.SilentCheck) {
+ state.silentCheckForUpdate = SilentCheckForUpdateState.Loaded
+ } else {
+ state.checkForUpdateState = CheckForUpdateState.Loaded
+ }
+ if (action.payload.areAllReleasesAlreadyDownloaded) {
+ state.data.downloadedProcessedReleases =
+ action.payload.availableReleasesForUpdate.map((release) => ({
+ release,
+ state: ReleaseProcessState.Done,
+ }))
+ }
+ })
+ .addCase(checkForUpdate.rejected, (state, action) => {
+ const error = action.payload as AppError
+
+ if (error?.type === UpdateError.NoActiveDevice) {
+ return { ...initialState }
}
- }
- })
- builder.addCase(downloadUpdates.pending, (state, action) => {
- state.data.downloadedProcessedReleases = action.meta.arg.releases.map(
- (release) => ({
- release,
- state: ReleaseProcessState.Initial,
- })
- )
- state.error = null
- state.checkForUpdateState = CheckForUpdateState.Initial
- state.downloadState = DownloadState.Loading
- })
- builder.addCase(downloadUpdates.fulfilled, (state) => {
- state.checkForUpdateState = CheckForUpdateState.Initial
- state.silentCheckForUpdate = SilentCheckForUpdateState.Loaded
- state.downloadState = DownloadState.Loaded
- })
- builder.addCase(downloadUpdates.rejected, (state, action) => {
- const error = action.payload as AppError
- if (error?.type === UpdateError.DownloadCancelledByUser) {
+ if (
+ action.meta.aborted &&
+ action.meta.arg.mode === CheckForUpdateMode.SilentCheck
+ ) {
+ return {
+ ...state,
+ error: null,
+ silentCheckForUpdate: SilentCheckForUpdateState.Initial,
+ }
+ } else if (action.meta.arg.mode === CheckForUpdateMode.SilentCheck) {
+ return {
+ ...state,
+ error: error ?? null,
+ silentCheckForUpdate: SilentCheckForUpdateState.Failed,
+ }
+ } else {
+ return {
+ ...state,
+ error: error ?? null,
+ checkForUpdateState: CheckForUpdateState.Failed,
+ }
+ }
+ })
+
+ .addCase(downloadUpdates.pending, (state, action) => {
+ state.data.downloadedProcessedReleases = action.meta.arg.releases.map(
+ (release) => ({
+ release,
+ state: ReleaseProcessState.Initial,
+ })
+ )
+ state.error = null
+ state.checkForUpdateState = CheckForUpdateState.Initial
+ state.downloadState = DownloadState.Loading
+ })
+ .addCase(downloadUpdates.fulfilled, (state) => {
+ state.checkForUpdateState = CheckForUpdateState.Initial
+ state.silentCheckForUpdate = SilentCheckForUpdateState.Loaded
+ state.downloadState = DownloadState.Loaded
+ })
+ .addCase(downloadUpdates.rejected, (state, action) => {
+ const error = action.payload as AppError
+ if (error?.type === UpdateError.DownloadCancelledByUser) {
+ state.downloadState = DownloadState.Cancelled
+ } else {
+ state.downloadState = DownloadState.Failed
+ state.error = error
+ }
+ })
+ .addCase(cancelDownload, (state) => {
state.downloadState = DownloadState.Cancelled
- } else {
- state.downloadState = DownloadState.Failed
- state.error = error
- }
- })
- builder.addCase(cancelDownload, (state) => {
- state.downloadState = DownloadState.Cancelled
- })
+ })
- builder.addCase(startUpdateOs.pending, (state, action) => {
- state.data.updateProcessedReleases = action.meta.arg.releases.map(
- (release) => ({
- release,
- state: ReleaseProcessState.Initial,
- })
- )
- state.error = null
- state.downloadState = DownloadState.Initial
- state.updateOsState = State.Loading
- state.tmpMuditaHarmonyPortInfo = undefined
- })
- builder.addCase(startUpdateOs.fulfilled, (state) => {
- state.updateOsState = State.Loaded
- state.data = {
- ...state.data,
- availableReleasesForUpdate: [],
- downloadedProcessedReleases: [],
- updateProcessedReleases: [],
- }
- state.error = null
- state.tmpMuditaHarmonyPortInfo = undefined
- })
- builder.addCase(startUpdateOs.rejected, (state, action) => {
- state.updateOsState = State.Failed
- state.error = action.payload as AppError
- state.tmpMuditaHarmonyPortInfo = undefined
- })
- builder.addCase(checkForForceUpdateNeed.fulfilled, (state, action) => {
- state.needsForceUpdate = action.payload
- state.checkedForForceUpdateNeed = true
- })
+ .addCase(startUpdateOs.pending, (state, action) => {
+ state.data.updateProcessedReleases = action.meta.arg.releases.map(
+ (release) => ({
+ release,
+ state: ReleaseProcessState.Initial,
+ })
+ )
+ state.error = null
+ state.downloadState = DownloadState.Initial
+ state.updateOsState = State.Loading
+ state.tmpMuditaHarmonyPortInfo = undefined
+ })
+ .addCase(startUpdateOs.fulfilled, (state) => {
+ state.updateOsState = State.Loaded
+ state.data = {
+ ...state.data,
+ availableReleasesForUpdate: [],
+ downloadedProcessedReleases: [],
+ updateProcessedReleases: [],
+ }
+ state.error = null
+ state.tmpMuditaHarmonyPortInfo = undefined
+ })
+ .addCase(startUpdateOs.rejected, (state, action) => {
+ state.updateOsState = State.Failed
+ state.error = action.payload as AppError
+ state.tmpMuditaHarmonyPortInfo = undefined
+ })
+ .addCase(checkForForceUpdateNeed.fulfilled, (state, action) => {
+ state.needsForceUpdate = action.payload
+ state.checkedForForceUpdateNeed = true
+ })
- builder.addCase(forceUpdate.pending, (state, action) => {
- state.data.updateProcessedReleases = action.meta.arg.releases.map(
- (release) => ({
- release,
- state: ReleaseProcessState.Initial,
- })
- )
- state.data.downloadedProcessedReleases = action.meta.arg.releases.map(
- (release) => ({
- release,
- state: ReleaseProcessState.Initial,
- })
- )
- state.error = null
- state.forceUpdateState = State.Loading
- })
- builder.addCase(forceUpdate.fulfilled, (state) => {
- state.forceUpdateState = State.Loaded
- state.downloadState = DownloadState.Initial
- state.updateOsState = State.Initial
- state.needsForceUpdate = false
- })
- builder.addCase(forceUpdate.rejected, (state, action) => {
- state.forceUpdateState = State.Failed
- state.error = action.payload as AppError
- })
- builder.addCase(setTmpMuditaHarmonyPortInfo, (state, action) => {
- state.tmpMuditaHarmonyPortInfo = action.payload
- })
+ .addCase(forceUpdate.pending, (state, action) => {
+ state.data.updateProcessedReleases = action.meta.arg.releases.map(
+ (release) => ({
+ release,
+ state: ReleaseProcessState.Initial,
+ })
+ )
+ state.data.downloadedProcessedReleases = action.meta.arg.releases.map(
+ (release) => ({
+ release,
+ state: ReleaseProcessState.Initial,
+ })
+ )
+ state.error = null
+ state.forceUpdateState = State.Loading
+ })
+ .addCase(forceUpdate.fulfilled, (state) => {
+ state.forceUpdateState = State.Loaded
+ state.downloadState = DownloadState.Initial
+ state.updateOsState = State.Initial
+ state.needsForceUpdate = false
+ })
+ .addCase(forceUpdate.rejected, (state, action) => {
+ state.forceUpdateState = State.Failed
+ state.error = action.payload as AppError
+ })
+ .addCase(setTmpMuditaHarmonyPortInfo, (state, action) => {
+ state.tmpMuditaHarmonyPortInfo = action.payload
+ })
}
)
diff --git a/libs/core/update/services/device-update.service.ts b/libs/core/update/services/device-update.service.ts
index 917a748235..dd2d194eee 100644
--- a/libs/core/update/services/device-update.service.ts
+++ b/libs/core/update/services/device-update.service.ts
@@ -3,29 +3,25 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceType } from "device-protocol/models"
+import { Endpoint, Method } from "core-device/models"
import { Result, ResultObject } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { RequestResponseStatus } from "Core/core/types/request-response.interface"
import { DeviceFileSystemService } from "Core/device-file-system/services"
-import {
- DeviceType,
- Endpoint,
- Method,
- OnboardingState,
- PhoneLockCategory,
-} from "Core/device/constants"
+import { OnboardingState, PhoneLockCategory } from "Core/device/constants"
import { SettingsService } from "Core/settings/services"
import { UpdateErrorServiceErrors } from "Core/update/constants"
import { UpdateOS } from "Core/update/dto"
import { join } from "path"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import * as fs from "fs"
import { DeviceInfoService } from "Core/device-info/services"
export class DeviceUpdateService {
constructor(
private settingsService: SettingsService,
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private deviceFileSystem: DeviceFileSystemService,
private deviceInfoService: DeviceInfoService
) {}
@@ -93,7 +89,7 @@ export class DeviceUpdateService {
)
}
- const pureUpdateResponse = await this.deviceManager.device.request({
+ const pureUpdateResponse = await this.deviceProtocol.device.request({
endpoint: Endpoint.Update,
method: Method.Post,
body: {
@@ -133,7 +129,7 @@ export class DeviceUpdateService {
)
}
- if (this.deviceManager.device.deviceType === DeviceType.MuditaPure) {
+ if (this.deviceProtocol.device.deviceType === DeviceType.MuditaPure) {
const deviceUnlockedResponse = await this.waitUntilDeviceUnlocked()
if (!deviceUnlockedResponse.ok) {
@@ -170,7 +166,7 @@ export class DeviceUpdateService {
private async getUnlockDeviceStatus(): Promise<
ResultObject
> {
- const { ok, error } = await this.deviceManager.device.request({
+ const { ok, error } = await this.deviceProtocol.device.request({
endpoint: Endpoint.Security,
method: Method.Get,
body: { category: PhoneLockCategory.Status },
@@ -183,7 +179,7 @@ export class DeviceUpdateService {
private async waitUntilDeviceRestart(
index = 0,
- deviceType = this.deviceManager.device.deviceType,
+ deviceType = this.deviceProtocol.device.deviceType,
timeout = 10000,
callsMax = 60
): Promise> {
diff --git a/libs/core/update/update.module.ts b/libs/core/update/update.module.ts
index c9b9021447..6afbaf3497 100644
--- a/libs/core/update/update.module.ts
+++ b/libs/core/update/update.module.ts
@@ -22,14 +22,14 @@ import {
ReleasesController,
DeviceUpdateController,
} from "Core/update/controllers"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceInfoService } from "Core/device-info/services"
import { RELEASE_TIMEOUT } from "Core/update/constants/get-release-timeout.constant"
export class UpdateModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -38,7 +38,7 @@ export class UpdateModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -54,9 +54,9 @@ export class UpdateModule extends BaseModule {
const deviceUpdateService = new DeviceUpdateService(
settingsService,
- this.deviceManager,
- new DeviceFileSystemService(this.deviceManager),
- new DeviceInfoService(this.deviceManager)
+ this.deviceProtocol,
+ new DeviceFileSystemService(this.deviceProtocol),
+ new DeviceInfoService(this.deviceProtocol)
)
const deviceUpdateFilesService = new DeviceUpdateFilesService()
const releaseService = new ReleaseService(createClient(RELEASE_TIMEOUT))
diff --git a/libs/device-manager/feature/.babelrc b/libs/device-manager/feature/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/device-manager/feature/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/device-manager/feature/.eslintrc.json b/libs/device-manager/feature/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/device-manager/feature/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/device-manager/feature/README.md b/libs/device-manager/feature/README.md
new file mode 100644
index 0000000000..97b21345a6
--- /dev/null
+++ b/libs/device-manager/feature/README.md
@@ -0,0 +1,7 @@
+# device-manager-feature
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test device-manager-feature` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/device-manager/feature/jest.config.ts b/libs/device-manager/feature/jest.config.ts
new file mode 100644
index 0000000000..c14617760b
--- /dev/null
+++ b/libs/device-manager/feature/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "device-manager-feature",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/device-manager/feature",
+}
diff --git a/libs/device-manager/feature/project.json b/libs/device-manager/feature/project.json
new file mode 100644
index 0000000000..a9da5395ce
--- /dev/null
+++ b/libs/device-manager/feature/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "device-manager-feature",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/device-manager/feature/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/device-manager/feature/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/device-manager/feature/src/actions/connect-device.action.ts b/libs/device-manager/feature/src/actions/connect-device.action.ts
new file mode 100644
index 0000000000..a8720cae9f
--- /dev/null
+++ b/libs/device-manager/feature/src/actions/connect-device.action.ts
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createAsyncThunk } from "@reduxjs/toolkit"
+import { DeviceType } from "device-protocol/models"
+import { connectDeviceRequest } from "device-protocol/feature"
+import { DeviceManagerEvent, DeviceState } from "device-manager/models"
+import { setDeviceState as setCoreDeviceState } from "core-device/feature"
+import { setDeviceState as setApiDeviceState } from "generic-view/store"
+import { ReduxRootState } from "Core/__deprecated__/renderer/store"
+import { DeviceId } from "Core/device/constants/device-id"
+import { getActiveDevice } from "../selectors/get-active-device.selector"
+
+export const connectDevice = createAsyncThunk<
+ boolean,
+ DeviceId,
+ { state: ReduxRootState }
+>(DeviceManagerEvent.ConnectDevice, async (id, { dispatch, getState }) => {
+ const result = await connectDeviceRequest(id)
+ const activeDevice = getActiveDevice(getState())
+ const setDeviceState =
+ activeDevice?.deviceType !== DeviceType.APIDevice
+ ? setCoreDeviceState
+ : setApiDeviceState
+
+ if (result.ok) {
+ dispatch(setDeviceState({ id, state: DeviceState.Connected }))
+ } else {
+ dispatch(setDeviceState({ id, state: DeviceState.Failed }))
+ }
+
+ return result.ok
+})
diff --git a/libs/core/device-manager/actions/deactivate-device.action.ts b/libs/device-manager/feature/src/actions/deactivate-device.action.ts
similarity index 51%
rename from libs/core/device-manager/actions/deactivate-device.action.ts
rename to libs/device-manager/feature/src/actions/deactivate-device.action.ts
index dadcb558a9..a9140d5452 100644
--- a/libs/core/device-manager/actions/deactivate-device.action.ts
+++ b/libs/device-manager/feature/src/actions/deactivate-device.action.ts
@@ -4,42 +4,28 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
+import { DeviceBaseProperties } from "device-protocol/models"
+import { DeviceManagerEvent } from "device-manager/models"
+import { setActiveDevice } from "active-device-registry/feature"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
-import { setActiveDeviceRequest } from "Core/device-manager/requests"
import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface"
import { setDeviceInitializationStatus } from "Core/device-initialization/actions/base.action"
import { DeviceInitializationStatus } from "Core/device-initialization/reducers/device-initialization.interface"
-import { setDataSyncInitState } from "Core/data-sync/actions"
-import { setInitState } from "Core/device"
-import { clearStateAndData } from "Core/update/actions"
import { MetadataKey, setValue } from "Core/metadata"
-import { setInitialBackupState } from "Core/backup"
-import { setInitialContactsState } from "Core/contacts/actions"
-import { setInitialFilesManagerState } from "Core/files-manager/actions"
-import { setInitialMessagesState } from "Core/messages/actions/base.action"
-import { getDevicesSelector } from "Core/device-manager/selectors/get-devices.selector"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
-import { setSelectDeviceDrawerOpen } from "Core/device-select/actions/set-select-device-drawer-open.action"
+import { getDevicesSelector } from "../selectors"
+import { setSelectDeviceDrawerOpen } from "./set-select-device-drawer-open.action"
export const deactivateDevice = createAsyncThunk<
- Device[],
+ DeviceBaseProperties[],
void,
{ state: ReduxRootState }
>(DeviceManagerEvent.DeactivateDevice, async (_, { dispatch, getState }) => {
- await setActiveDeviceRequest(undefined)
+ await dispatch(setActiveDevice(undefined))
dispatch(setSelectDeviceDrawerOpen(false))
dispatch(setDiscoveryStatus(DiscoveryStatus.Idle))
dispatch(setDeviceInitializationStatus(DeviceInitializationStatus.Idle))
- dispatch(setDataSyncInitState())
- dispatch(setInitialBackupState())
- dispatch(setInitialContactsState())
- dispatch(setInitialFilesManagerState())
- dispatch(setInitialMessagesState())
- dispatch(setInitState())
- dispatch(clearStateAndData())
void setValue({ key: MetadataKey.DeviceOsVersion, value: null })
void setValue({ key: MetadataKey.DeviceType, value: null })
diff --git a/libs/core/device-manager/actions/handle-device-activated.action.ts b/libs/device-manager/feature/src/actions/handle-device-activated.action.ts
similarity index 74%
rename from libs/core/device-manager/actions/handle-device-activated.action.ts
rename to libs/device-manager/feature/src/actions/handle-device-activated.action.ts
index 6695532603..4a47e60e71 100644
--- a/libs/core/device-manager/actions/handle-device-activated.action.ts
+++ b/libs/device-manager/feature/src/actions/handle-device-activated.action.ts
@@ -4,13 +4,13 @@
*/
import { createAsyncThunk } from "@reduxjs/toolkit"
+import { cleanBackupProcess, cleanRestoreProcess } from "generic-view/store"
+import { DeviceManagerEvent } from "device-manager/models"
+import { setActiveDevice } from "active-device-registry/feature"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerEvent } from "Core/device-manager/constants"
-import { setActiveDevice } from "Core/device-manager/actions/set-active-device.action"
import { DeviceId } from "Core/device/constants/device-id"
import { setDiscoveryStatus } from "Core/discovery-device/actions/base.action"
import { DiscoveryStatus } from "Core/discovery-device/reducers/discovery-device.interface"
-import { activateDevice } from "generic-view/store"
export const handleDeviceActivated = createAsyncThunk<
void,
@@ -18,6 +18,7 @@ export const handleDeviceActivated = createAsyncThunk<
{ state: ReduxRootState }
>(DeviceManagerEvent.HandleDeviceActivated, async (deviceId, { dispatch }) => {
await dispatch(setActiveDevice(deviceId))
+ dispatch(cleanBackupProcess())
+ dispatch(cleanRestoreProcess())
setDiscoveryStatus(DiscoveryStatus.Discovered)
- dispatch(activateDevice({ deviceId }))
})
diff --git a/libs/device-manager/feature/src/actions/index.ts b/libs/device-manager/feature/src/actions/index.ts
new file mode 100644
index 0000000000..a8ccfe3242
--- /dev/null
+++ b/libs/device-manager/feature/src/actions/index.ts
@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./connect-device.action"
+export * from "./deactivate-device.action"
+export * from "./handle-device-activated.action"
+export * from "./set-select-device-drawer-open.action"
diff --git a/libs/core/device-select/actions/set-select-device-drawer-open.action.ts b/libs/device-manager/feature/src/actions/set-select-device-drawer-open.action.ts
similarity index 67%
rename from libs/core/device-select/actions/set-select-device-drawer-open.action.ts
rename to libs/device-manager/feature/src/actions/set-select-device-drawer-open.action.ts
index e7b1ec442b..245049d7f7 100644
--- a/libs/core/device-select/actions/set-select-device-drawer-open.action.ts
+++ b/libs/device-manager/feature/src/actions/set-select-device-drawer-open.action.ts
@@ -4,8 +4,8 @@
*/
import { createAction } from "@reduxjs/toolkit"
-import { DeviceSelectEvent } from "Core/device-select/constants/event.constant"
+import { DeviceManagerEvent } from "device-manager/models"
export const setSelectDeviceDrawerOpen = createAction(
- DeviceSelectEvent.SetSelectDeviceDrawerOpen
+ DeviceManagerEvent.SetSelectDeviceDrawerOpen
)
diff --git a/libs/shared/app-state/src/lib/dialog-file-system/controller.constant.ts b/libs/device-manager/feature/src/constants/controller.constant.ts
similarity index 63%
rename from libs/shared/app-state/src/lib/dialog-file-system/controller.constant.ts
rename to libs/device-manager/feature/src/constants/controller.constant.ts
index c8f296d035..afa8860120 100644
--- a/libs/shared/app-state/src/lib/dialog-file-system/controller.constant.ts
+++ b/libs/device-manager/feature/src/constants/controller.constant.ts
@@ -3,6 +3,6 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-export enum IpcFileSystemDialogEvent {
- GetPaths = "file-system-dialog_get-paths",
+export enum IpcDeviceManagerEvent {
+ ConnectDevice = "device-manager_connect-device",
}
diff --git a/libs/device-manager/feature/src/constants/index.ts b/libs/device-manager/feature/src/constants/index.ts
new file mode 100644
index 0000000000..eb01fd9553
--- /dev/null
+++ b/libs/device-manager/feature/src/constants/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./controller.constant"
diff --git a/libs/device-manager/feature/src/index.ts b/libs/device-manager/feature/src/index.ts
new file mode 100644
index 0000000000..74112c6701
--- /dev/null
+++ b/libs/device-manager/feature/src/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./actions"
+export * from "./selectors"
+export * from "./reducers"
diff --git a/libs/device-manager/feature/src/reducers/device-manager.reducer.ts b/libs/device-manager/feature/src/reducers/device-manager.reducer.ts
new file mode 100644
index 0000000000..4156f7d649
--- /dev/null
+++ b/libs/device-manager/feature/src/reducers/device-manager.reducer.ts
@@ -0,0 +1,27 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createReducer } from "@reduxjs/toolkit"
+import { DeviceManagerState } from "device-manager/models"
+import {
+ setSelectDeviceDrawerOpen,
+} from "../actions"
+
+export const initialState: DeviceManagerState = {
+ selectDeviceDrawerOpen: false,
+}
+
+export const deviceManagerReducer = createReducer(
+ initialState,
+ (builder) => {
+ builder
+ .addCase(setSelectDeviceDrawerOpen, (state, action) => {
+ return {
+ ...state,
+ selectDeviceDrawerOpen: action.payload,
+ }
+ })
+ }
+)
diff --git a/libs/device-manager/feature/src/reducers/index.ts b/libs/device-manager/feature/src/reducers/index.ts
new file mode 100644
index 0000000000..fcfa2ac8a7
--- /dev/null
+++ b/libs/device-manager/feature/src/reducers/index.ts
@@ -0,0 +1,7 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "../../../models/src/device-manager.interface"
+export * from "./device-manager.reducer"
diff --git a/libs/core/device-manager/selectors/device-manager-state.selector.ts b/libs/device-manager/feature/src/selectors/device-manager-state.selector.ts
similarity index 77%
rename from libs/core/device-manager/selectors/device-manager-state.selector.ts
rename to libs/device-manager/feature/src/selectors/device-manager-state.selector.ts
index ae53bea7ed..1d71ae4f62 100644
--- a/libs/core/device-manager/selectors/device-manager-state.selector.ts
+++ b/libs/device-manager/feature/src/selectors/device-manager-state.selector.ts
@@ -3,8 +3,8 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+import { DeviceManagerState } from "device-manager/models"
import { ReduxRootState } from "Core/__deprecated__/renderer/store"
-import { DeviceManagerState } from "Core/device-manager/reducers/device-manager.interface"
export const deviceManagerState = (state: ReduxRootState): DeviceManagerState =>
state.deviceManager
diff --git a/libs/device-manager/feature/src/selectors/get-active-device-base-data.selector.ts b/libs/device-manager/feature/src/selectors/get-active-device-base-data.selector.ts
new file mode 100644
index 0000000000..6e0e649911
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/get-active-device-base-data.selector.ts
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { getCoreDevicesSelector } from "core-device/feature"
+import { DeviceBaseProperties } from "device-protocol/models"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
+import {
+ DeviceState,
+ HarmonyDeviceData,
+ KompaktDeviceData,
+ PureDeviceData,
+} from "Core/device"
+import { deviceStateSelector } from "Core/device/selectors"
+
+export interface DeviceBaseData
+ extends DeviceBaseProperties,
+ Pick {
+ data: Partial
+}
+
+export const getActiveDeviceBaseDataSelector = createSelector(
+ getCoreDevicesSelector,
+ activeDeviceIdSelector,
+ deviceStateSelector,
+ (coreDevices, activeDeviceId, deviceState): DeviceBaseData | undefined => {
+ const activeDevice = coreDevices.find(({ id }) => id === activeDeviceId)
+
+ if (activeDevice === undefined) {
+ return
+ }
+
+ const { data, externalUsageDevice } = deviceState
+
+ if (data === null) {
+ return
+ }
+
+ return {
+ ...activeDevice,
+ data,
+ externalUsageDevice,
+ }
+ }
+)
diff --git a/libs/core/device-manager/selectors/get-active-device-type.selector.ts b/libs/device-manager/feature/src/selectors/get-active-device-type.selector.ts
similarity index 72%
rename from libs/core/device-manager/selectors/get-active-device-type.selector.ts
rename to libs/device-manager/feature/src/selectors/get-active-device-type.selector.ts
index 14ae517fb0..c4453b00c4 100644
--- a/libs/core/device-manager/selectors/get-active-device-type.selector.ts
+++ b/libs/device-manager/feature/src/selectors/get-active-device-type.selector.ts
@@ -4,8 +4,8 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
-import { DeviceType } from "Core/device"
+import { getActiveDevice } from "./get-active-device.selector"
+import { DeviceType } from "device-protocol/models"
export const getActiveDeviceTypeSelector = createSelector(
getActiveDevice,
diff --git a/libs/core/device-manager/selectors/get-active-device.selector.ts b/libs/device-manager/feature/src/selectors/get-active-device.selector.ts
similarity index 51%
rename from libs/core/device-manager/selectors/get-active-device.selector.ts
rename to libs/device-manager/feature/src/selectors/get-active-device.selector.ts
index 3ff2257a89..9ff588aac7 100644
--- a/libs/core/device-manager/selectors/get-active-device.selector.ts
+++ b/libs/device-manager/feature/src/selectors/get-active-device.selector.ts
@@ -4,13 +4,14 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
+import { DeviceProperties } from "device-manager/models"
+import { activeDeviceIdSelector } from "active-device-registry/feature"
+import { getDevicesSelector } from "./get-devices.selector"
export const getActiveDevice = createSelector(
- deviceManagerState,
- (deviceManager): Device | undefined => {
- const { devices, activeDeviceId } = deviceManager
+ getDevicesSelector,
+ activeDeviceIdSelector,
+ (devices, activeDeviceId): DeviceProperties | undefined => {
return devices.find(({ id }) => id === activeDeviceId)
}
)
diff --git a/libs/core/device-manager/selectors/get-available-devices.selector.ts b/libs/device-manager/feature/src/selectors/get-available-devices.selector.ts
similarity index 52%
rename from libs/core/device-manager/selectors/get-available-devices.selector.ts
rename to libs/device-manager/feature/src/selectors/get-available-devices.selector.ts
index f23d4a674a..63f6c52c6e 100644
--- a/libs/core/device-manager/selectors/get-available-devices.selector.ts
+++ b/libs/device-manager/feature/src/selectors/get-available-devices.selector.ts
@@ -4,14 +4,14 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { Device } from "Core/device-manager/reducers/device-manager.interface"
-import { getFailedDevicesSelector } from "Core/device-manager/selectors/get-failed-devices.selector"
-import { getConfiguredDevicesSelector } from "Core/device-manager/selectors/get-configured-devices.selector"
+import { DeviceProperties } from "device-manager/models"
+import { getFailedDevicesSelector } from "./get-failed-devices.selector"
+import { getConfiguredDevicesSelector } from "./get-configured-devices.selector"
export const getAvailableDevicesSelector = createSelector(
getConfiguredDevicesSelector,
getFailedDevicesSelector,
- (configuredDevices, failedDevices): Device[] => {
+ (configuredDevices, failedDevices): DeviceProperties[] => {
return [...configuredDevices, ...failedDevices]
}
)
diff --git a/libs/device-manager/feature/src/selectors/get-configured-devices.selector.ts b/libs/device-manager/feature/src/selectors/get-configured-devices.selector.ts
new file mode 100644
index 0000000000..4b665912c0
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/get-configured-devices.selector.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { DeviceProperties } from "device-manager/models"
+import { selectConfiguredDevices } from "generic-view/store"
+import { getConfiguredCoreDevicesSelector } from "core-device/feature"
+
+export const getConfiguredDevicesSelector = createSelector(
+ getConfiguredCoreDevicesSelector,
+ selectConfiguredDevices,
+ (coreDevices, apiDevices): DeviceProperties[] => {
+ return [...coreDevices, ...Object.values(apiDevices)]
+ }
+)
diff --git a/libs/device-manager/feature/src/selectors/get-devices.selector.ts b/libs/device-manager/feature/src/selectors/get-devices.selector.ts
new file mode 100644
index 0000000000..55e461e6ea
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/get-devices.selector.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { DeviceProperties } from "device-manager/models"
+import { getCoreDevicesSelector } from "core-device/feature"
+import { selectDevices } from "generic-view/store"
+
+export const getDevicesSelector = createSelector(
+ getCoreDevicesSelector,
+ selectDevices,
+ (coreDevices, apiDevices): DeviceProperties[] => {
+ return [...coreDevices, ...Object.values(apiDevices)]
+ }
+)
diff --git a/libs/device-manager/feature/src/selectors/get-failed-devices.selector.ts b/libs/device-manager/feature/src/selectors/get-failed-devices.selector.ts
new file mode 100644
index 0000000000..412b7490d9
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/get-failed-devices.selector.ts
@@ -0,0 +1,17 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { DeviceProperties } from "device-manager/models"
+import { getFailedCoreDevicesSelector } from "core-device/feature"
+import { selectFailedDevices } from "generic-view/store"
+
+export const getFailedDevicesSelector = createSelector(
+ getFailedCoreDevicesSelector,
+ selectFailedDevices,
+ (failedCoreDevices, failedApiDevices): DeviceProperties[] => {
+ return [...failedCoreDevices, ...Object.values(failedApiDevices)]
+ }
+)
diff --git a/libs/device-manager/feature/src/selectors/index.ts b/libs/device-manager/feature/src/selectors/index.ts
new file mode 100644
index 0000000000..3ce76ac830
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/index.ts
@@ -0,0 +1,18 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./device-manager-state.selector"
+export * from "./get-active-device-type.selector"
+export * from "./get-active-device.selector"
+export * from "./get-active-device-base-data.selector"
+export * from "./get-available-devices.selector"
+export * from "./get-available-devices.selector"
+export * from "./get-configured-devices.selector"
+export * from "./get-devices.selector"
+export * from "./get-failed-devices.selector"
+export * from "./is-active-api-device-locked.selector"
+export * from "./is-active-device-attached.selector"
+export * from "./is-active-device-failed.selector"
+export * from "./is-device-list-empty.selector"
diff --git a/libs/device-manager/feature/src/selectors/is-active-api-device-locked.selector.ts b/libs/device-manager/feature/src/selectors/is-active-api-device-locked.selector.ts
new file mode 100644
index 0000000000..abb3029d0d
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/is-active-api-device-locked.selector.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { DeviceType } from "device-protocol/models"
+import { isDeviceLockedErrorSelector } from "generic-view/store"
+import { getActiveDevice } from "./get-active-device.selector"
+
+export const isActiveApiDeviceLockedSelector = createSelector(
+ getActiveDevice,
+ isDeviceLockedErrorSelector,
+ (activeDevice, deviceLockedError): boolean => {
+ return (
+ activeDevice?.deviceType === DeviceType.APIDevice && deviceLockedError
+ )
+ }
+)
diff --git a/libs/core/device-manager/selectors/is-active-device-attached.selector.ts b/libs/device-manager/feature/src/selectors/is-active-device-attached.selector.ts
similarity index 79%
rename from libs/core/device-manager/selectors/is-active-device-attached.selector.ts
rename to libs/device-manager/feature/src/selectors/is-active-device-attached.selector.ts
index 34e30af511..db593673c8 100644
--- a/libs/core/device-manager/selectors/is-active-device-attached.selector.ts
+++ b/libs/device-manager/feature/src/selectors/is-active-device-attached.selector.ts
@@ -4,7 +4,7 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { getActiveDevice } from "Core/device-manager/selectors/get-active-device.selector"
+import { getActiveDevice } from "./get-active-device.selector"
export const isActiveDeviceAttachedSelector = createSelector(
getActiveDevice,
diff --git a/libs/device-manager/feature/src/selectors/is-active-device-failed.selector.ts b/libs/device-manager/feature/src/selectors/is-active-device-failed.selector.ts
new file mode 100644
index 0000000000..d060490fea
--- /dev/null
+++ b/libs/device-manager/feature/src/selectors/is-active-device-failed.selector.ts
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { createSelector } from "@reduxjs/toolkit"
+import { DeviceState } from "device-manager/models"
+import { getActiveDevice } from "./get-active-device.selector"
+
+export const isActiveDeviceFailedSelector = createSelector(
+ getActiveDevice,
+ (activeDevice): boolean => {
+ return activeDevice?.state === DeviceState.Failed
+ }
+)
diff --git a/libs/core/device-manager/selectors/is-device-list-empty.selector.ts b/libs/device-manager/feature/src/selectors/is-device-list-empty.selector.ts
similarity index 56%
rename from libs/core/device-manager/selectors/is-device-list-empty.selector.ts
rename to libs/device-manager/feature/src/selectors/is-device-list-empty.selector.ts
index 12f0e67830..566c1da18b 100644
--- a/libs/core/device-manager/selectors/is-device-list-empty.selector.ts
+++ b/libs/device-manager/feature/src/selectors/is-device-list-empty.selector.ts
@@ -4,11 +4,11 @@
*/
import { createSelector } from "@reduxjs/toolkit"
-import { deviceManagerState } from "Core/device-manager/selectors/device-manager-state.selector"
+import { getDevicesSelector } from "./get-devices.selector"
export const isDeviceListEmpty = createSelector(
- deviceManagerState,
- (deviceManager): boolean => {
- return deviceManager.devices.length === 0
+ getDevicesSelector,
+ (devices): boolean => {
+ return devices.length === 0
}
)
diff --git a/libs/device-manager/feature/tsconfig.json b/libs/device-manager/feature/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/device-manager/feature/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/device-manager/feature/tsconfig.lib.json b/libs/device-manager/feature/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/device-manager/feature/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/device-manager/feature/tsconfig.spec.json b/libs/device-manager/feature/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/device-manager/feature/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/device-manager/models/.babelrc b/libs/device-manager/models/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/device-manager/models/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/device-manager/models/.eslintrc.json b/libs/device-manager/models/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/device-manager/models/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/device-manager/models/README.md b/libs/device-manager/models/README.md
new file mode 100644
index 0000000000..47f1400a2b
--- /dev/null
+++ b/libs/device-manager/models/README.md
@@ -0,0 +1,7 @@
+# device-manager-models
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test device-manager-models` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/device-manager/models/jest.config.ts b/libs/device-manager/models/jest.config.ts
new file mode 100644
index 0000000000..3efd3505e2
--- /dev/null
+++ b/libs/device-manager/models/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "device-manager-models",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../coverage/libs/device-manager/models",
+}
diff --git a/libs/device-manager/models/project.json b/libs/device-manager/models/project.json
new file mode 100644
index 0000000000..5b03e6d428
--- /dev/null
+++ b/libs/device-manager/models/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "device-manager-models",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/device-manager/models/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/device-manager/models/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/core/help/components/answer/answer-test-ids.enum.ts b/libs/device-manager/models/src/device-manager.interface.ts
similarity index 65%
rename from libs/core/help/components/answer/answer-test-ids.enum.ts
rename to libs/device-manager/models/src/device-manager.interface.ts
index 45be223252..6dcdb00a26 100644
--- a/libs/core/help/components/answer/answer-test-ids.enum.ts
+++ b/libs/device-manager/models/src/device-manager.interface.ts
@@ -3,7 +3,6 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-export enum AnswerUiTestIds {
- BackLink = "back-link",
- Content = "content",
+export interface DeviceManagerState {
+ selectDeviceDrawerOpen: boolean
}
diff --git a/libs/device-manager/models/src/device-properties.interface.ts b/libs/device-manager/models/src/device-properties.interface.ts
new file mode 100644
index 0000000000..5db02d84ed
--- /dev/null
+++ b/libs/device-manager/models/src/device-properties.interface.ts
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { DeviceBaseProperties } from "device-protocol/models"
+import { CaseColour } from "core-device/models"
+
+export enum DeviceState {
+ Connected = "CONNECTED",
+ Configured = "CONFIGURED",
+ Initialized = "INITIALIZED",
+ Failed = "FAILED",
+}
+
+export interface DeviceProperties extends DeviceBaseProperties {
+ caseColour?: CaseColour
+ state: DeviceState
+}
diff --git a/libs/core/device-manager/constants/event.constant.ts b/libs/device-manager/models/src/event.constant.ts
similarity index 64%
rename from libs/core/device-manager/constants/event.constant.ts
rename to libs/device-manager/models/src/event.constant.ts
index 40a379c9ad..c54730b64e 100644
--- a/libs/core/device-manager/constants/event.constant.ts
+++ b/libs/device-manager/models/src/event.constant.ts
@@ -4,11 +4,8 @@
*/
export enum DeviceManagerEvent {
- HandleDeviceActivated = "device-manager_handle-device-activated",
- AddDevice = "device-manager_add-device",
- RemoveDevice = "device-manager_remove-device",
- SetActiveDevice = "device-manager_set-active-device",
- DeactivateDevice = "device-manager_deactivate-device",
- ConfigureDevice = "device-manager_configure-device",
ConnectDevice = "device-manager_connect-device",
+ DeactivateDevice = "device-manager_deactivate-device",
+ HandleDeviceActivated = "device-manager_handle-device-activated",
+ SetSelectDeviceDrawerOpen = "device-manager_set-select-device-drawer-open",
}
diff --git a/libs/device-manager/models/src/index.ts b/libs/device-manager/models/src/index.ts
new file mode 100644
index 0000000000..c23cf9ca59
--- /dev/null
+++ b/libs/device-manager/models/src/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./device-properties.interface"
+export * from "./device-manager.interface"
+export * from "./event.constant"
diff --git a/libs/device-manager/models/tsconfig.json b/libs/device-manager/models/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/device-manager/models/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/device-manager/models/tsconfig.lib.json b/libs/device-manager/models/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/device-manager/models/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/device-manager/models/tsconfig.spec.json b/libs/device-manager/models/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/device-manager/models/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/device-protocol/feature/.babelrc b/libs/device-protocol/feature/.babelrc
new file mode 100644
index 0000000000..1ea870ead4
--- /dev/null
+++ b/libs/device-protocol/feature/.babelrc
@@ -0,0 +1,12 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": []
+}
diff --git a/libs/device-protocol/feature/.eslintrc.json b/libs/device-protocol/feature/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/device-protocol/feature/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/device-protocol/feature/README.md b/libs/device-protocol/feature/README.md
new file mode 100644
index 0000000000..cc20b42843
--- /dev/null
+++ b/libs/device-protocol/feature/README.md
@@ -0,0 +1,7 @@
+# device-protocol-feature
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test device-protocol-feature` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/device-protocol/feature/jest.config.ts b/libs/device-protocol/feature/jest.config.ts
new file mode 100644
index 0000000000..432bda00ad
--- /dev/null
+++ b/libs/device-protocol/feature/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "device-protocol-feature",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/device-protocol/feature",
+}
diff --git a/libs/device-protocol/feature/project.json b/libs/device-protocol/feature/project.json
new file mode 100644
index 0000000000..e092a13994
--- /dev/null
+++ b/libs/device-protocol/feature/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "device-protocol-feature",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/device-protocol-feature/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/device-protocol/feature/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/device-protocol/feature/src/constants/controller.constant.ts b/libs/device-protocol/feature/src/constants/controller.constant.ts
new file mode 100644
index 0000000000..189ddc233f
--- /dev/null
+++ b/libs/device-protocol/feature/src/constants/controller.constant.ts
@@ -0,0 +1,9 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export enum IpcDeviceProtocolEvent {
+ SetActiveDevice = "device-protocol/set-active-device",
+ ConnectDevice = "device-protocol/connect-device",
+}
diff --git a/libs/core/device-manager/constants/error.constant.ts b/libs/device-protocol/feature/src/constants/error.constant.ts
similarity index 66%
rename from libs/core/device-manager/constants/error.constant.ts
rename to libs/device-protocol/feature/src/constants/error.constant.ts
index d46dc2e407..36f578aafd 100644
--- a/libs/core/device-manager/constants/error.constant.ts
+++ b/libs/device-protocol/feature/src/constants/error.constant.ts
@@ -4,7 +4,5 @@
*/
export enum DeviceManagerError {
- NoActiveDevice = "NO_ACTIVE_DEVICE_ERROR",
CannotFindDevice = "CANNOT_FIND_DEVICE_ERROR",
- CannotInitializeDeviceObject = "CANNOT_INITIALIZE_DEVICE_OBJECT_ERROR",
}
diff --git a/libs/device-protocol/feature/src/constants/index.ts b/libs/device-protocol/feature/src/constants/index.ts
new file mode 100644
index 0000000000..2a7dd1c8c8
--- /dev/null
+++ b/libs/device-protocol/feature/src/constants/index.ts
@@ -0,0 +1,6 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./error.constant"
diff --git a/libs/core/device-manager/device-manager.module.ts b/libs/device-protocol/feature/src/device-protocol.module.ts
similarity index 61%
rename from libs/core/device-manager/device-manager.module.ts
rename to libs/device-protocol/feature/src/device-protocol.module.ts
index d5f1001f72..dcf4644d2b 100644
--- a/libs/core/device-manager/device-manager.module.ts
+++ b/libs/device-protocol/feature/src/device-protocol.module.ts
@@ -10,15 +10,14 @@ import { FileSystemService } from "Core/file-system/services/file-system.service
import { AppLogger } from "Core/__deprecated__/main/utils/logger"
import { IndexStorage } from "Core/index-storage/types"
import { BaseModule } from "Core/core/module"
-import { DeviceManager } from "Core/device-manager/services"
-import { UsbDeviceDetectionObserver } from "Core/device-manager/observers"
-import { DeviceManagerController } from "Core/device-manager/controllers"
-import { DeviceCacheConfigurationService } from "Core/device-manager/services/device-cache-configuration.service"
+import { DeviceProtocol } from "./services"
+import { UsbDeviceDetectionObserver } from "./observers"
+import { DeviceProtocolService } from "./services/device-protocol.service"
-export class DeviceManagerModule extends BaseModule {
+export class DeviceProtocolModule extends BaseModule {
constructor(
public index: IndexStorage,
- public deviceManager: DeviceManager,
+ public deviceProtocol: DeviceProtocol,
public keyStorage: MetadataStore,
public logger: AppLogger,
public ipc: MainProcessIpc,
@@ -27,7 +26,7 @@ export class DeviceManagerModule extends BaseModule {
) {
super(
index,
- deviceManager,
+ deviceProtocol,
keyStorage,
logger,
ipc,
@@ -36,16 +35,11 @@ export class DeviceManagerModule extends BaseModule {
)
const usbDeviceDetectionObserver = new UsbDeviceDetectionObserver(
- this.deviceManager
- )
-
- const deviceManagerController = new DeviceManagerController(
- this.deviceManager,
- new DeviceCacheConfigurationService(this.fileSystem)
+ this.deviceProtocol
)
this.initializers = []
this.observers = [usbDeviceDetectionObserver]
- this.controllers = [deviceManagerController]
+ this.controllers = [new DeviceProtocolService(this.deviceProtocol)]
}
}
diff --git a/libs/device-protocol/feature/src/index.ts b/libs/device-protocol/feature/src/index.ts
new file mode 100644
index 0000000000..5d2fca06cf
--- /dev/null
+++ b/libs/device-protocol/feature/src/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./device-protocol.module"
+export * from "./requests"
+export * from "./services"
diff --git a/libs/core/device-manager/observers/index.ts b/libs/device-protocol/feature/src/observers/index.ts
similarity index 100%
rename from libs/core/device-manager/observers/index.ts
rename to libs/device-protocol/feature/src/observers/index.ts
diff --git a/libs/core/device-manager/observers/usb-device-detection.observer.ts b/libs/device-protocol/feature/src/observers/usb-device-detection.observer.ts
similarity index 81%
rename from libs/core/device-manager/observers/usb-device-detection.observer.ts
rename to libs/device-protocol/feature/src/observers/usb-device-detection.observer.ts
index 080d100d3c..3d8cf2411d 100644
--- a/libs/core/device-manager/observers/usb-device-detection.observer.ts
+++ b/libs/device-protocol/feature/src/observers/usb-device-detection.observer.ts
@@ -4,16 +4,16 @@
*/
import { Observer } from "Core/core/types"
-import { DeviceManager } from "Core/device-manager/services"
import { ipcMain } from "electron-better-ipc"
import { ApiSerialPortToRendererEvents } from "device/models"
import { SerialPortDeviceAdapterEvent } from "Core/device/modules/mudita-os/adapters"
+import { DeviceProtocol } from "../services"
const intervalTime = 3000
export class UsbDeviceDetectionObserver implements Observer {
private previousAttachedDevicePaths = new Set()
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
public observe(): void {
void this.watchAttachedDevices()
@@ -35,14 +35,14 @@ export class UsbDeviceDetectionObserver implements Observer {
private mountListeners() {
ipcMain.on(ApiSerialPortToRendererEvents.Closed, () => {
void this.detectDeviceStateChange()
- });
+ })
ipcMain.on(SerialPortDeviceAdapterEvent.Closed, () => {
void this.detectDeviceStateChange()
- });
+ })
}
- private async detectDeviceStateChange(): Promise {
- const attachedDevices = await this.deviceManager.getAttachedDevices()
+ private async detectDeviceStateChange(): Promise {
+ const attachedDevices = await this.deviceProtocol.getAttachedDevices()
const detachedDevicePaths = Array.from(
this.previousAttachedDevicePaths
).filter(
@@ -53,12 +53,12 @@ export class UsbDeviceDetectionObserver implements Observer {
)
detachedDevicePaths.forEach((detachedDevicePath) => {
- void this.deviceManager.removeDevice(detachedDevicePath)
+ void this.deviceProtocol.removeDevice(detachedDevicePath)
})
attachedDevices.forEach((attachedDevice) => {
if (!this.previousAttachedDevicePaths.has(attachedDevice.path)) {
- void this.deviceManager.addDevice(attachedDevice)
+ void this.deviceProtocol.addDevice(attachedDevice)
}
})
diff --git a/libs/core/device-manager/requests/connect-device.request.ts b/libs/device-protocol/feature/src/requests/connect-device.request.ts
similarity index 55%
rename from libs/core/device-manager/requests/connect-device.request.ts
rename to libs/device-protocol/feature/src/requests/connect-device.request.ts
index 5c85920df3..1343cfef69 100644
--- a/libs/core/device-manager/requests/connect-device.request.ts
+++ b/libs/device-protocol/feature/src/requests/connect-device.request.ts
@@ -5,9 +5,11 @@
import { ipcRenderer } from "electron-better-ipc"
import { ResultObject } from "Core/core/builder"
-import { IpcDeviceManagerEvent } from "Core/device-manager/constants"
import { DeviceId } from "Core/device/constants/device-id"
+import { IpcDeviceProtocolEvent } from "../constants/controller.constant"
-export const connectDeviceRequest = async (id: DeviceId): Promise> => {
- return ipcRenderer.callMain(IpcDeviceManagerEvent.ConnectDevice, id)
+export const connectDeviceRequest = async (
+ id: DeviceId
+): Promise> => {
+ return ipcRenderer.callMain(IpcDeviceProtocolEvent.ConnectDevice, id)
}
diff --git a/libs/core/device-manager/requests/index.ts b/libs/device-protocol/feature/src/requests/index.ts
similarity index 82%
rename from libs/core/device-manager/requests/index.ts
rename to libs/device-protocol/feature/src/requests/index.ts
index 7de1bf4d87..07f35b725e 100644
--- a/libs/core/device-manager/requests/index.ts
+++ b/libs/device-protocol/feature/src/requests/index.ts
@@ -3,4 +3,5 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
+export * from "./connect-device.request"
export * from "./set-active-device.request"
diff --git a/libs/core/device-manager/requests/set-active-device.request.ts b/libs/device-protocol/feature/src/requests/set-active-device.request.ts
similarity index 54%
rename from libs/core/device-manager/requests/set-active-device.request.ts
rename to libs/device-protocol/feature/src/requests/set-active-device.request.ts
index 44f3fc9173..7df53bb597 100644
--- a/libs/core/device-manager/requests/set-active-device.request.ts
+++ b/libs/device-protocol/feature/src/requests/set-active-device.request.ts
@@ -5,9 +5,11 @@
import { ipcRenderer } from "electron-better-ipc"
import { ResultObject } from "Core/core/builder"
-import { IpcDeviceManagerEvent } from "Core/device-manager/constants"
import { DeviceId } from "Core/device/constants/device-id"
+import { IpcDeviceProtocolEvent } from "../constants/controller.constant"
-export const setActiveDeviceRequest = async (id: DeviceId | undefined): Promise> => {
- return ipcRenderer.callMain(IpcDeviceManagerEvent.SetActiveDevice, id)
+export const setActiveDeviceRequest = async (
+ id: DeviceId | undefined
+): Promise> => {
+ return ipcRenderer.callMain(IpcDeviceProtocolEvent.SetActiveDevice, id)
}
diff --git a/libs/device-protocol/feature/src/services/device-protocol.service.ts b/libs/device-protocol/feature/src/services/device-protocol.service.ts
new file mode 100644
index 0000000000..17a188a3cf
--- /dev/null
+++ b/libs/device-protocol/feature/src/services/device-protocol.service.ts
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ResultObject } from "Core/core/builder"
+import { DeviceId } from "Core/device/constants/device-id"
+import { IpcEvent } from "Core/core/decorators"
+import { IpcDeviceProtocolEvent } from "../constants/controller.constant"
+import { DeviceProtocol } from "./device-protocol"
+
+export class DeviceProtocolService {
+ constructor(private deviceProtocol: DeviceProtocol) {}
+
+ @IpcEvent(IpcDeviceProtocolEvent.SetActiveDevice)
+ public setActiveDevice(id: DeviceId | undefined): ResultObject {
+ return this.deviceProtocol.setActiveDevice(id)
+ }
+
+ @IpcEvent(IpcDeviceProtocolEvent.ConnectDevice)
+ public connectDevice(id: DeviceId): Promise> {
+ return this.deviceProtocol.connectDevice(id)
+ }
+}
diff --git a/libs/core/device-manager/services/device-manager.service.ts b/libs/device-protocol/feature/src/services/device-protocol.ts
similarity index 85%
rename from libs/core/device-manager/services/device-manager.service.ts
rename to libs/device-protocol/feature/src/services/device-protocol.ts
index bdce4009cd..7629043380 100644
--- a/libs/core/device-manager/services/device-manager.service.ts
+++ b/libs/device-protocol/feature/src/services/device-protocol.ts
@@ -6,13 +6,11 @@
import { PortInfo as SerialPortInfo } from "serialport"
import { Mutex } from "async-mutex"
import { EventEmitter } from "events"
-import { IDeviceResolverService } from "Core/device-manager/services/device-resolver.service"
+import { callRenderer } from "shared/utils"
+import { DeviceCommunicationError } from "core-device/models"
+import { DeviceProtocolMainEvent, DeviceType } from "device-protocol/models"
import { AppError } from "Core/core/errors"
import { Result, ResultObject } from "Core/core/builder"
-import { PortInfo } from "Core/device-manager/types"
-import { PortInfoValidator } from "Core/device-manager/validators"
-import { DeviceManagerError } from "Core/device-manager/constants"
-import { DeviceManagerMainEvent } from "shared/utils"
import logger from "Core/__deprecated__/main/utils/logger"
import { DeviceId } from "Core/device/constants/device-id"
import { log } from "Core/core/decorators/log.decorator"
@@ -20,18 +18,22 @@ import { APIDevice } from "device/feature"
import { BaseDevice } from "Core/device/modules/base-device"
import { CoreDevice } from "Core/device/modules/core-device"
import { RequestConfig } from "Core/device/types/mudita-os"
-import { DeviceCommunicationError, DeviceType } from "Core/device"
import { MockCoreDevice } from "Core/device/modules/mock-core-device"
-import { callRenderer } from "shared/utils"
-import { getSerialPortList } from "./serial-port-list.helper"
-
-export class DeviceManager {
+import { PortInfo } from "../types"
+import { ISerialPortService } from "./serial-port.service"
+import { DeviceManagerError } from "../constants"
+import { PortInfoValidator } from "../validators"
+import { IDeviceResolverService } from "./device-resolver.service"
+import { getUsbDevices } from "Core/device-manager/services/usb-devices/usb-devices.helper"
+
+export class DeviceProtocol {
public activeDevice: BaseDevice | undefined
public devicesMap = new Map()
private mutex = new Mutex()
constructor(
+ private serialPortService: ISerialPortService,
private deviceResolver: IDeviceResolverService,
protected eventEmitter: EventEmitter
) {}
@@ -124,12 +126,18 @@ export class DeviceManager {
}
const data = device.toSerializableObject()
- callRenderer(DeviceManagerMainEvent.DeviceDetached, data)
+ callRenderer(DeviceProtocolMainEvent.DeviceDetached, data)
logger.info(`Detached device with path: ${path}`)
}
public async getAttachedDevices(): Promise {
const portList = await this.getSerialPortList()
+ const harmonyMSCMode = await getUsbDevices()
+
+ if (harmonyMSCMode) {
+ portList.push(harmonyMSCMode)
+ }
+
return (
portList
// AUTO DISABLED - fix me if you like :)
@@ -161,9 +169,9 @@ export class DeviceManager {
const result = await device.connect()
const data = device.toSerializableObject()
if (result.ok) {
- callRenderer(DeviceManagerMainEvent.DeviceConnected, data)
+ callRenderer(DeviceProtocolMainEvent.DeviceConnected, data)
} else {
- callRenderer(DeviceManagerMainEvent.DeviceConnectFailed, data)
+ callRenderer(DeviceProtocolMainEvent.DeviceConnectFailed, data)
}
}
@@ -202,7 +210,7 @@ export class DeviceManager {
@log("==== device manager: list ====", { space: 0 })
private getSerialPortList(): Promise {
- return getSerialPortList()
+ return this.serialPortService.list()
}
private getDeviceByPath(path: string): BaseDevice | undefined {
diff --git a/libs/core/device-manager/services/device-resolver.service.test.ts b/libs/device-protocol/feature/src/services/device-resolver.service.test.ts
similarity index 87%
rename from libs/core/device-manager/services/device-resolver.service.test.ts
rename to libs/device-protocol/feature/src/services/device-resolver.service.test.ts
index 3712a66436..94420a02e7 100644
--- a/libs/core/device-manager/services/device-resolver.service.test.ts
+++ b/libs/device-protocol/feature/src/services/device-resolver.service.test.ts
@@ -3,8 +3,9 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { ProductID, DeviceType } from "Core/device/constants"
-import { DeviceResolverService } from "Core/device-manager/services/device-resolver.service"
+import { DeviceType } from "device-protocol/models"
+import { ProductID } from "Core/device/constants"
+import { DeviceResolverService } from "../services"
const subject = new DeviceResolverService()
diff --git a/libs/core/device-manager/services/device-resolver.service.ts b/libs/device-protocol/feature/src/services/device-resolver.service.ts
similarity index 69%
rename from libs/core/device-manager/services/device-resolver.service.ts
rename to libs/device-protocol/feature/src/services/device-resolver.service.ts
index d74f952d54..4393040adf 100644
--- a/libs/core/device-manager/services/device-resolver.service.ts
+++ b/libs/device-protocol/feature/src/services/device-resolver.service.ts
@@ -4,13 +4,14 @@
*/
import { PortInfo } from "serialport"
+import { APIDevice, MSCDevice } from "device/feature"
+import { DeviceType } from "device-protocol/models"
import {
MuditaPureDescriptor,
MuditaHarmonyDescriptor,
+ MuditaHarmonyMscDescriptor,
} from "Core/device/descriptors"
import { DeviceFactory } from "Core/device/factories"
-import { APIDevice } from "device/feature"
-import { DeviceType } from "Core/device"
import { BaseDevice } from "Core/device/modules/base-device"
export interface IDeviceResolverService {
@@ -20,6 +21,8 @@ export interface IDeviceResolverService {
export class DeviceResolverService implements IDeviceResolverService {
private eligibleDevices = [MuditaPureDescriptor, MuditaHarmonyDescriptor]
+ private mscDevices = [MuditaHarmonyMscDescriptor]
+
public resolve(portInfo: PortInfo): BaseDevice | undefined {
const id = portInfo.productId?.toLowerCase() ?? ""
const descriptor = this.eligibleDevices.find((device) =>
@@ -37,11 +40,16 @@ export class DeviceResolverService implements IDeviceResolverService {
)
}
- if (!descriptor) {
- //TODO: temporary, remove in future
- return new APIDevice(portInfo, DeviceType.APIDevice)
+ const mscDescriptor = this.mscDevices.find((device) =>
+ device.productIds
+ .map((item) => item.toString().toLowerCase())
+ .includes(id)
+ )
+
+ if (mscDescriptor) {
+ return new MSCDevice(portInfo, DeviceType.MuditaHarmonyMsc)
}
- return
+ return new APIDevice(portInfo, DeviceType.APIDevice)
}
}
diff --git a/libs/core/device-manager/services/index.ts b/libs/device-protocol/feature/src/services/index.ts
similarity index 72%
rename from libs/core/device-manager/services/index.ts
rename to libs/device-protocol/feature/src/services/index.ts
index 479f0d19e3..fb5629fe01 100644
--- a/libs/core/device-manager/services/index.ts
+++ b/libs/device-protocol/feature/src/services/index.ts
@@ -3,5 +3,6 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-export * from "./device-manager.service"
+export * from "./device-protocol"
export * from "./device-resolver.service"
+export * from "./serial-port.service"
diff --git a/libs/device-protocol/feature/src/services/serial-port.service.ts b/libs/device-protocol/feature/src/services/serial-port.service.ts
new file mode 100644
index 0000000000..5c6a60a6ff
--- /dev/null
+++ b/libs/device-protocol/feature/src/services/serial-port.service.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import SerialPort from "serialport"
+
+export interface ISerialPortService {
+ list(): Promise
+}
+
+export class SerialPortService implements ISerialPortService {
+ list(): Promise {
+ return SerialPort.list()
+ }
+}
diff --git a/libs/core/device-manager/types/index.ts b/libs/device-protocol/feature/src/types/index.ts
similarity index 100%
rename from libs/core/device-manager/types/index.ts
rename to libs/device-protocol/feature/src/types/index.ts
diff --git a/libs/core/device-manager/types/port.type.ts b/libs/device-protocol/feature/src/types/port.type.ts
similarity index 100%
rename from libs/core/device-manager/types/port.type.ts
rename to libs/device-protocol/feature/src/types/port.type.ts
diff --git a/libs/core/device-manager/validators/index.ts b/libs/device-protocol/feature/src/validators/index.ts
similarity index 100%
rename from libs/core/device-manager/validators/index.ts
rename to libs/device-protocol/feature/src/validators/index.ts
diff --git a/libs/core/device-manager/validators/port-info.validator.test.ts b/libs/device-protocol/feature/src/validators/port-info.validator.test.ts
similarity index 100%
rename from libs/core/device-manager/validators/port-info.validator.test.ts
rename to libs/device-protocol/feature/src/validators/port-info.validator.test.ts
diff --git a/libs/core/device-manager/validators/port-info.validator.ts b/libs/device-protocol/feature/src/validators/port-info.validator.ts
similarity index 94%
rename from libs/core/device-manager/validators/port-info.validator.ts
rename to libs/device-protocol/feature/src/validators/port-info.validator.ts
index b3058650a3..0f68f671df 100644
--- a/libs/core/device-manager/validators/port-info.validator.ts
+++ b/libs/device-protocol/feature/src/validators/port-info.validator.ts
@@ -6,14 +6,16 @@
import { PortInfo } from "serialport"
import {
MuditaHarmonyDescriptor,
+ MuditaHarmonyMscDescriptor,
MuditaKompaktDescriptor,
MuditaPureDescriptor,
-} from "../../device/descriptors"
+} from "Core/device/descriptors"
export class PortInfoValidator {
static eligibleDevices = [
MuditaPureDescriptor,
MuditaHarmonyDescriptor,
+ MuditaHarmonyMscDescriptor,
MuditaKompaktDescriptor,
]
diff --git a/libs/device-protocol/feature/tsconfig.json b/libs/device-protocol/feature/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/device-protocol/feature/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/device-protocol/feature/tsconfig.lib.json b/libs/device-protocol/feature/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/device-protocol/feature/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/device-protocol/feature/tsconfig.spec.json b/libs/device-protocol/feature/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/device-protocol/feature/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/device-protocol/models/.babelrc b/libs/device-protocol/models/.babelrc
new file mode 100644
index 0000000000..ef4889c1ab
--- /dev/null
+++ b/libs/device-protocol/models/.babelrc
@@ -0,0 +1,20 @@
+{
+ "presets": [
+ [
+ "@nx/react/babel",
+ {
+ "runtime": "automatic",
+ "useBuiltIns": "usage"
+ }
+ ]
+ ],
+ "plugins": [
+ [
+ "styled-components",
+ {
+ "pure": true,
+ "ssr": true
+ }
+ ]
+ ]
+}
diff --git a/libs/device-protocol/models/.eslintrc.json b/libs/device-protocol/models/.eslintrc.json
new file mode 100644
index 0000000000..cacbe26215
--- /dev/null
+++ b/libs/device-protocol/models/.eslintrc.json
@@ -0,0 +1,18 @@
+{
+ "extends": ["../../../.eslintrc.js"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ }
+ ]
+}
diff --git a/libs/device-protocol/models/README.md b/libs/device-protocol/models/README.md
new file mode 100644
index 0000000000..b9142dccf6
--- /dev/null
+++ b/libs/device-protocol/models/README.md
@@ -0,0 +1,7 @@
+# device-protocol-models
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test device-protocol-models` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/device-protocol/models/jest.config.ts b/libs/device-protocol/models/jest.config.ts
new file mode 100644
index 0000000000..9e92770f18
--- /dev/null
+++ b/libs/device-protocol/models/jest.config.ts
@@ -0,0 +1,11 @@
+/* eslint-disable */
+export default {
+ displayName: "device-protocol-models",
+ preset: "../../../jest.preset.js",
+ transform: {
+ "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest",
+ "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/react/babel"] }],
+ },
+ moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
+ coverageDirectory: "../../../coverage/libs/device-protocol/models",
+}
diff --git a/libs/device-protocol/models/project.json b/libs/device-protocol/models/project.json
new file mode 100644
index 0000000000..e131348c4b
--- /dev/null
+++ b/libs/device-protocol/models/project.json
@@ -0,0 +1,20 @@
+{
+ "name": "device-protocol-models",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/device-protocol/models/src",
+ "projectType": "library",
+ "tags": [],
+ "targets": {
+ "lint": {
+ "executor": "@nx/eslint:lint",
+ "outputs": ["{options.outputFile}"]
+ },
+ "test": {
+ "executor": "@nx/jest:jest",
+ "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
+ "options": {
+ "jestConfig": "libs/device-protocol/models/jest.config.ts"
+ }
+ }
+ }
+}
diff --git a/libs/core/device/constants/device-base-properties.ts b/libs/device-protocol/models/src/device-base-properties.ts
similarity index 86%
rename from libs/core/device/constants/device-base-properties.ts
rename to libs/device-protocol/models/src/device-base-properties.ts
index 351decf534..52ed8a2d17 100644
--- a/libs/core/device/constants/device-base-properties.ts
+++ b/libs/device-protocol/models/src/device-base-properties.ts
@@ -4,7 +4,7 @@
*/
import { PortInfo } from "serialport"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "./device-type.constant"
export interface DeviceBaseProperties extends PortInfo {
id: string
diff --git a/libs/device-protocol/models/src/device-protocol-main-event.ts b/libs/device-protocol/models/src/device-protocol-main-event.ts
new file mode 100644
index 0000000000..430e6e86fb
--- /dev/null
+++ b/libs/device-protocol/models/src/device-protocol-main-event.ts
@@ -0,0 +1,10 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export enum DeviceProtocolMainEvent {
+ DeviceDetached = "device-protocol/device-detached",
+ DeviceConnected = "device-protocol/device-connected",
+ DeviceConnectFailed = "device-protocol/device-connect-failed",
+}
diff --git a/libs/core/device/constants/device-type.constant.ts b/libs/device-protocol/models/src/device-type.constant.ts
similarity index 86%
rename from libs/core/device/constants/device-type.constant.ts
rename to libs/device-protocol/models/src/device-type.constant.ts
index d5a22a9de0..8aa8d9efbf 100644
--- a/libs/core/device/constants/device-type.constant.ts
+++ b/libs/device-protocol/models/src/device-type.constant.ts
@@ -6,5 +6,6 @@
export enum DeviceType {
MuditaPure = "MuditaPure",
MuditaHarmony = "MuditaHarmony",
+ MuditaHarmonyMsc = "MuditaHarmonyMsc",
APIDevice = "APIDevice",
}
diff --git a/libs/device-protocol/models/src/index.ts b/libs/device-protocol/models/src/index.ts
new file mode 100644
index 0000000000..9594b3b9d2
--- /dev/null
+++ b/libs/device-protocol/models/src/index.ts
@@ -0,0 +1,8 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export * from "./device-base-properties"
+export * from "./device-protocol-main-event"
+export * from "./device-type.constant"
diff --git a/libs/device-protocol/models/tsconfig.json b/libs/device-protocol/models/tsconfig.json
new file mode 100644
index 0000000000..4daaf45cd3
--- /dev/null
+++ b/libs/device-protocol/models/tsconfig.json
@@ -0,0 +1,20 @@
+{
+ "compilerOptions": {
+ "jsx": "react-jsx",
+ "allowJs": false,
+ "esModuleInterop": false,
+ "allowSyntheticDefaultImports": true,
+ "strict": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ],
+ "extends": "../../../tsconfig.base.json"
+}
diff --git a/libs/device-protocol/models/tsconfig.lib.json b/libs/device-protocol/models/tsconfig.lib.json
new file mode 100644
index 0000000000..21799b3e6b
--- /dev/null
+++ b/libs/device-protocol/models/tsconfig.lib.json
@@ -0,0 +1,24 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "types": [
+ "node",
+
+ "@nx/react/typings/cssmodule.d.ts",
+ "@nx/react/typings/image.d.ts"
+ ]
+ },
+ "exclude": [
+ "jest.config.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.js",
+ "src/**/*.test.js",
+ "src/**/*.spec.jsx",
+ "src/**/*.test.jsx"
+ ],
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
+}
diff --git a/libs/device-protocol/models/tsconfig.spec.json b/libs/device-protocol/models/tsconfig.spec.json
new file mode 100644
index 0000000000..25b7af8f6d
--- /dev/null
+++ b/libs/device-protocol/models/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "include": [
+ "jest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/libs/device/adapters/src/lib/serial-port-api-device.ts b/libs/device/adapters/src/lib/serial-port-api-device.ts
index ff925168ef..1af4e052b1 100644
--- a/libs/device/adapters/src/lib/serial-port-api-device.ts
+++ b/libs/device/adapters/src/lib/serial-port-api-device.ts
@@ -42,7 +42,7 @@ export class SerialPortDeviceAPIAdapter {
public connect(): Promise> {
return new Promise((resolve) => {
- this.serialPort = new SerialPort(this.path, (error) => {
+ const serialPort = new SerialPort(this.path, (error) => {
if (error) {
resolve(
Result.failed(
@@ -50,6 +50,7 @@ export class SerialPortDeviceAPIAdapter {
)
)
} else {
+ this.serialPort = serialPort
this.mountListeners()
resolve(Result.success(undefined))
}
diff --git a/libs/device/feature/src/index.ts b/libs/device/feature/src/index.ts
index 582b2264b9..d91fba1db0 100644
--- a/libs/device/feature/src/index.ts
+++ b/libs/device/feature/src/index.ts
@@ -15,3 +15,4 @@ export * from "./lib/file-manager"
export * from "./lib/backup"
export * from "./lib/restore"
export * from "./lib/data-transfer"
+export * from "./lib/msc-device"
diff --git a/libs/device/feature/src/lib/api-config/api-config.service.ts b/libs/device/feature/src/lib/api-config/api-config.service.ts
index 7c390050fa..dd8fe85c93 100644
--- a/libs/device/feature/src/lib/api-config/api-config.service.ts
+++ b/libs/device/feature/src/lib/api-config/api-config.service.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import {
@@ -17,24 +17,26 @@ import { AppError } from "Core/core/errors"
import { APIConfigError } from "./api-config-error"
export class APIConfigService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIConfigServiceEvents.APIConfig)
public async getAPIConfig(
deviceId?: DeviceId
): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
}
-
const response = await device.request({
endpoint: "API_CONFIGURATION",
method: "GET",
body: {},
+ options: {
+ connectionTimeOut: 2000,
+ },
})
if (response.ok) {
@@ -51,7 +53,7 @@ export class APIConfigService {
//to remove
@IpcEvent(APIConfigServiceEvents.APIAny)
public async getAPIAny(payload: unknown): Promise> {
- const device = this.deviceManager.apiDevice
+ const device = this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
}
diff --git a/libs/device/feature/src/lib/api-device.ts b/libs/device/feature/src/lib/api-device.ts
index d98494edfe..3d95738c88 100644
--- a/libs/device/feature/src/lib/api-device.ts
+++ b/libs/device/feature/src/lib/api-device.ts
@@ -12,7 +12,7 @@ import {
APIRequestWithPayload,
} from "device/models"
import { BaseDevice } from "Core/device/modules/base-device"
-import { DeviceType } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { ResultObject } from "Core/core/builder"
import logger from "Core/__deprecated__/main/utils/logger"
diff --git a/libs/device/feature/src/lib/api-features/api-features.service.ts b/libs/device/feature/src/lib/api-features/api-features.service.ts
index 03361856cc..c88d37a882 100644
--- a/libs/device/feature/src/lib/api-features/api-features.service.ts
+++ b/libs/device/feature/src/lib/api-features/api-features.service.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import {
@@ -21,7 +21,7 @@ import { DeviceId } from "Core/device/constants/device-id"
import { View } from "generic-view/utils"
export class APIFeaturesService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIFeaturesServiceEvents.FeatureConfiguration)
public async getFeatureConfiguration({
@@ -32,8 +32,8 @@ export class APIFeaturesService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -47,6 +47,7 @@ export class APIFeaturesService {
lang: "en-US",
},
})
+
if (response.ok) {
const config = featureConfigValidator.safeParse(response.data.body)
if (process.env.NODE_ENV === "development" && !config.success) {
@@ -65,8 +66,8 @@ export class APIFeaturesService {
deviceId?: DeviceId
): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -94,7 +95,7 @@ export class APIFeaturesService {
@IpcEvent(APIFeaturesServiceEvents.FeatureData)
public async getFeatureData(feature: string): Promise> {
- const device = this.deviceManager.apiDevice
+ const device = this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
}
@@ -107,6 +108,7 @@ export class APIFeaturesService {
lang: "en-US",
},
})
+
if (response.ok) {
return Result.success(response.data.body)
}
@@ -125,8 +127,8 @@ export class APIFeaturesService {
about: View
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/feature/src/lib/api-module.ts b/libs/device/feature/src/lib/api-module.ts
index 9f24eb31ce..4341dfe354 100644
--- a/libs/device/feature/src/lib/api-module.ts
+++ b/libs/device/feature/src/lib/api-module.ts
@@ -3,7 +3,7 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { APIConfigService } from "./api-config/api-config.service"
import { APIFeaturesService } from "./api-features/api-features.service"
import { APIBackupService } from "./backup"
@@ -14,10 +14,10 @@ import { ServerService } from "./server/server.service"
import { APIFileTransferService } from "./file-transfer"
import { ServiceBridge } from "./service-bridge"
import { SystemUtilsModule } from "system-utils/feature"
-import { createSettingsService } from "Core/settings/containers/settings.container"
import { APIRestoreService } from "./restore"
import { DeviceSystemActionsService } from "./device-system-actions/device-system-actions.service"
import { APIDataTransferService } from "./data-transfer"
+import { ISettingsService } from "shared/utils"
export class APIModule {
private apiConfigService: APIConfigService
@@ -34,32 +34,34 @@ export class APIModule {
private apiDataTransferService: APIDataTransferService
constructor(
- deviceManager: DeviceManager,
- systemUtilsModule: SystemUtilsModule
+ deviceProtocol: DeviceProtocol,
+ systemUtilsModule: SystemUtilsModule,
+ settingsService: ISettingsService
) {
this.serviceBridge = new ServiceBridge()
- this.apiConfigService = new APIConfigService(deviceManager)
- this.apiFeaturesService = new APIFeaturesService(deviceManager)
- this.apiOutboxService = new APIOutboxService(deviceManager)
- this.apiMenuService = new APIMenuService(deviceManager)
+ this.apiConfigService = new APIConfigService(deviceProtocol)
+ this.apiFeaturesService = new APIFeaturesService(deviceProtocol)
+ this.apiOutboxService = new APIOutboxService(deviceProtocol)
+ this.apiMenuService = new APIMenuService(deviceProtocol)
this.serverService = new ServerService()
- this.backupService = new APIBackupService(deviceManager)
- this.apiDataTransferService = new APIDataTransferService(deviceManager)
+ this.backupService = new APIBackupService(deviceProtocol)
+ this.apiDataTransferService = new APIDataTransferService(deviceProtocol)
this.restoreService = new APIRestoreService(
- deviceManager,
+ deviceProtocol,
this.serviceBridge
)
this.fileTransferService = new APIFileTransferService(
- deviceManager,
+ deviceProtocol,
this.serviceBridge
)
- this.fileManager = new FileManager(deviceManager, this.serviceBridge)
+ this.fileManager = new FileManager(deviceProtocol, this.serviceBridge)
this.deviceSystemActionsService = new DeviceSystemActionsService(
- deviceManager
+ deviceProtocol
)
this.serviceBridge.systemUtilsModule = systemUtilsModule
this.serviceBridge.fileTransfer = this.fileTransferService
- this.serviceBridge.settingsService = createSettingsService()
+ // @ts-ignore
+ this.serviceBridge.settingsService = settingsService
this.serviceBridge.fileManager = this.fileManager
this.serviceBridge.deviceSystemActions = this.deviceSystemActionsService
}
diff --git a/libs/device/feature/src/lib/backup/backup.service.ts b/libs/device/feature/src/lib/backup/backup.service.ts
index 010190cf6f..4ad07f0e3b 100644
--- a/libs/device/feature/src/lib/backup/backup.service.ts
+++ b/libs/device/feature/src/lib/backup/backup.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import { ApiResponse } from "Core/device/types/mudita-os"
import {
@@ -19,7 +19,7 @@ import {
import random from "lodash/random"
export class APIBackupService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIBackupServiceEvents.StartPreBackup)
public async startPreBackup({
@@ -30,8 +30,8 @@ export class APIBackupService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -62,8 +62,8 @@ export class APIBackupService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -89,8 +89,8 @@ export class APIBackupService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/feature/src/lib/data-transfer/data-transfer.service.ts b/libs/device/feature/src/lib/data-transfer/data-transfer.service.ts
index 91506e8bec..638660e0fb 100644
--- a/libs/device/feature/src/lib/data-transfer/data-transfer.service.ts
+++ b/libs/device/feature/src/lib/data-transfer/data-transfer.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import { ApiResponse } from "Core/device/types/mudita-os"
import {
@@ -22,7 +22,7 @@ import {
import random from "lodash/random"
export class APIDataTransferService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIDataTransferServiceEvents.StartPreDataTransfer)
public async startPreDataTransfer({
@@ -33,8 +33,8 @@ export class APIDataTransferService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -73,8 +73,8 @@ export class APIDataTransferService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -100,8 +100,8 @@ export class APIDataTransferService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -127,8 +127,8 @@ export class APIDataTransferService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/feature/src/lib/device-system-actions/device-system-actions.service.ts b/libs/device/feature/src/lib/device-system-actions/device-system-actions.service.ts
index 34c11cc798..2cfb5d75c2 100644
--- a/libs/device/feature/src/lib/device-system-actions/device-system-actions.service.ts
+++ b/libs/device/feature/src/lib/device-system-actions/device-system-actions.service.ts
@@ -3,22 +3,22 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { Result } from "Core/core/builder"
import { AppError } from "Core/core/errors"
import { GeneralError, DeviceSystemActionsServiceEvents } from "device/models"
import { IpcEvent } from "Core/core/decorators"
export class DeviceSystemActionsService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
private async sendSystemRequest(
action: string,
{ deviceId }: { deviceId?: string } = {}
) {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/feature/src/lib/file-manager/file-manager.service.ts b/libs/device/feature/src/lib/file-manager/file-manager.service.ts
index caf103ea23..65e2dd0361 100644
--- a/libs/device/feature/src/lib/file-manager/file-manager.service.ts
+++ b/libs/device/feature/src/lib/file-manager/file-manager.service.ts
@@ -8,7 +8,7 @@ import { IpcEvent } from "Core/core/decorators"
import { ServiceBridge } from "../service-bridge"
import { FileManagerServiceEvents, GeneralError } from "device/models"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import packageInfo from "../../../../../../apps/mudita-center/package.json"
import {
@@ -28,7 +28,7 @@ export class FileManager {
private files: Record = {}
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private serviceBridge: ServiceBridge
) {}
@@ -43,7 +43,7 @@ export class FileManager {
try {
const file =
this.serviceBridge.fileTransfer.getFileByTransferId(transferId)
- writeFileSync(filePath, file.chunks.join(), "base64")
+ writeFileSync(filePath, file.chunks.join(""), "base64")
return Result.success(undefined)
} catch (e) {
@@ -55,8 +55,8 @@ export class FileManager {
@IpcEvent(FileManagerServiceEvents.GetBackupPath)
public getBackupPath({ deviceId }: { deviceId?: DeviceId } = {}) {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -101,8 +101,8 @@ export class FileManager {
password?: string
}) {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -130,8 +130,8 @@ export class FileManager {
this.serviceBridge.fileTransfer.getFileByTransferId(transferId)
const featureData = password
- ? AES.encrypt(transfer.chunks.join(), password).toString()
- : transfer.chunks.join()
+ ? AES.encrypt(transfer.chunks.join(""), password).toString()
+ : transfer.chunks.join("")
return { ...acc, [feature]: featureData }
},
diff --git a/libs/device/feature/src/lib/file-manager/index.ts b/libs/device/feature/src/lib/file-manager/index.ts
index 88c24f9955..3ee3964211 100644
--- a/libs/device/feature/src/lib/file-manager/index.ts
+++ b/libs/device/feature/src/lib/file-manager/index.ts
@@ -14,4 +14,3 @@ export * from "./clear-file.request"
export * from "./get-backup-path.request"
export * from "./secure-backup-password.request"
export * from "./read-and-get-file.request"
-export * from "./select-single-file.request"
diff --git a/libs/device/feature/src/lib/file-manager/select-single-file.request.ts b/libs/device/feature/src/lib/file-manager/select-single-file.request.ts
deleted file mode 100644
index ac098d96ea..0000000000
--- a/libs/device/feature/src/lib/file-manager/select-single-file.request.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { ResultObject } from "Core/core/builder"
-import { ipcRenderer } from "electron-better-ipc"
-import { OpenDialogOptions } from "electron"
-import { FileDialogServiceEvents } from "system-utils/models"
-
-export const selectSingleFileRequest = (
- options: Omit
-): Promise> => {
- return ipcRenderer.callMain(FileDialogServiceEvents.SelectSingleFile, {
- options,
- })
-}
diff --git a/libs/device/feature/src/lib/file-transfer/file-transfer.service.ts b/libs/device/feature/src/lib/file-transfer/file-transfer.service.ts
index 958f9ece22..d9a7c29103 100644
--- a/libs/device/feature/src/lib/file-transfer/file-transfer.service.ts
+++ b/libs/device/feature/src/lib/file-transfer/file-transfer.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError, AppErrorType } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import {
ApiFileTransferError,
@@ -38,7 +38,7 @@ const DEFAULT_MAX_REPEATS = 2
export class APIFileTransferService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private serviceBridge: ServiceBridge,
private transfers: Record = {}
) {}
@@ -122,8 +122,8 @@ export class APIFileTransferService {
}>
> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -157,8 +157,8 @@ export class APIFileTransferService {
}>
> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -191,8 +191,8 @@ export class APIFileTransferService {
maxRepeats: number
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -256,8 +256,8 @@ export class APIFileTransferService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -310,8 +310,8 @@ export class APIFileTransferService {
maxRepeats: number
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -399,8 +399,8 @@ export class APIFileTransferService {
}>
> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/feature/src/lib/menu/menu.service.ts b/libs/device/feature/src/lib/menu/menu.service.ts
index 5eb220c402..898abc7907 100644
--- a/libs/device/feature/src/lib/menu/menu.service.ts
+++ b/libs/device/feature/src/lib/menu/menu.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import {
APIMenuServiceEvents,
GeneralError,
@@ -16,15 +16,15 @@ import {
import { DeviceId } from "Core/device/constants/device-id"
export class APIMenuService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIMenuServiceEvents.GetMenuConfig)
public async getMenuConfig(
deviceId?: DeviceId
): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -36,6 +36,9 @@ export class APIMenuService {
body: {
lang: "en-US",
},
+ options: {
+ connectionTimeOut: 1000
+ }
})
if (response.ok) {
const menuConfig = MenuConfigValidator.safeParse(response.data.body)
diff --git a/libs/device/feature/src/lib/msc-device.ts b/libs/device/feature/src/lib/msc-device.ts
new file mode 100644
index 0000000000..22d5a30183
--- /dev/null
+++ b/libs/device/feature/src/lib/msc-device.ts
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { PortInfo } from "serialport"
+import { APIEndpointType, APIRequestWithPayload } from "device/models"
+import { BaseDevice } from "Core/device/modules/base-device"
+import { DeviceType } from "device-protocol/models"
+import { Result, ResultObject } from "Core/core/builder"
+import logger from "Core/__deprecated__/main/utils/logger"
+import { AppError } from "Core/core/errors"
+
+export class MSCDevice extends BaseDevice {
+ constructor(portInfo: PortInfo, deviceType: DeviceType) {
+ super(portInfo, deviceType)
+ }
+ connect(): Promise> {
+ logger.info(`MSC_DEVICE adapter - connect: ${this.portInfo.path}`)
+ return Promise.resolve(Result.success(undefined))
+ }
+
+ public request(
+ config: APIRequestWithPayload
+ ) {
+ return Promise.resolve(
+ Result.failed(
+ new AppError("request method is not required for msc devices")
+ )
+ )
+ }
+}
diff --git a/libs/device/feature/src/lib/outbox/outbox.service.ts b/libs/device/feature/src/lib/outbox/outbox.service.ts
index f104fde898..71b4d0df4d 100644
--- a/libs/device/feature/src/lib/outbox/outbox.service.ts
+++ b/libs/device/feature/src/lib/outbox/outbox.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import {
APIOutboxServiceEvents,
@@ -16,13 +16,13 @@ import {
} from "device/models"
export class APIOutboxService {
- constructor(private deviceManager: DeviceManager) {}
+ constructor(private deviceProtocol: DeviceProtocol) {}
@IpcEvent(APIOutboxServiceEvents.GetOutboxData)
public async getOutboxData(
deviceId: DeviceId
): Promise> {
- const device = this.deviceManager.getAPIDeviceById(deviceId)
+ const device = this.deviceProtocol.getAPIDeviceById(deviceId)
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
}
diff --git a/libs/device/feature/src/lib/restore/restore.service.ts b/libs/device/feature/src/lib/restore/restore.service.ts
index f1f859efca..c25fbdf353 100644
--- a/libs/device/feature/src/lib/restore/restore.service.ts
+++ b/libs/device/feature/src/lib/restore/restore.service.ts
@@ -6,7 +6,7 @@
import { Result, ResultObject } from "Core/core/builder"
import { IpcEvent } from "Core/core/decorators"
import { AppError } from "Core/core/errors"
-import { DeviceManager } from "Core/device-manager/services"
+import { DeviceProtocol } from "device-protocol/feature"
import { DeviceId } from "Core/device/constants/device-id"
import { ApiResponse } from "Core/device/types/mudita-os"
import {
@@ -24,7 +24,7 @@ import { ServiceBridge } from "../service-bridge"
export class APIRestoreService {
constructor(
- private deviceManager: DeviceManager,
+ private deviceProtocol: DeviceProtocol,
private serviceBridge: ServiceBridge
) {}
@@ -40,8 +40,8 @@ export class APIRestoreService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -80,8 +80,8 @@ export class APIRestoreService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -107,8 +107,8 @@ export class APIRestoreService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
@@ -136,8 +136,8 @@ export class APIRestoreService {
deviceId?: DeviceId
}): Promise> {
const device = deviceId
- ? this.deviceManager.getAPIDeviceById(deviceId)
- : this.deviceManager.apiDevice
+ ? this.deviceProtocol.getAPIDeviceById(deviceId)
+ : this.deviceProtocol.apiDevice
if (!device) {
return Result.failed(new AppError(GeneralError.NoDevice, ""))
diff --git a/libs/device/models/src/lib/api-request.model.ts b/libs/device/models/src/lib/api-request.model.ts
index eb4ce4f9a0..9bca8acd77 100644
--- a/libs/device/models/src/lib/api-request.model.ts
+++ b/libs/device/models/src/lib/api-request.model.ts
@@ -58,6 +58,7 @@ export interface APIRequestWithPayload<
Body = Record
> extends APIRequestConfig {
body?: Body
+ options?: { connectionTimeOut?: number }
}
export interface APIRequestData {
diff --git a/libs/device/models/src/lib/import-contacts/unified-contact.ts b/libs/device/models/src/lib/import-contacts/unified-contact.ts
index 1bd0f2230a..3afe16c0ca 100644
--- a/libs/device/models/src/lib/import-contacts/unified-contact.ts
+++ b/libs/device/models/src/lib/import-contacts/unified-contact.ts
@@ -12,6 +12,7 @@ export type UnifiedContact = {
honorificSuffix?: string
nickname?: string
displayName: string
+ starred?: boolean
phoneNumbers: {
type?: string
value: string
diff --git a/libs/e2e-mock/client/src/lib/e2e-mock-client.ts b/libs/e2e-mock/client/src/lib/e2e-mock-client.ts
index b3af272e5b..1931effb0e 100644
--- a/libs/e2e-mock/client/src/lib/e2e-mock-client.ts
+++ b/libs/e2e-mock/client/src/lib/e2e-mock-client.ts
@@ -3,7 +3,13 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { AddKompakt, AddKompaktResponse, MockHttpResponse, UpdateState } from "e2e-mock-server"
+import {
+ AddKompakt,
+ AddKompaktResponse,
+ MockHttpResponse,
+ RestoreDefaultResponses,
+ UpdateState,
+} from "e2e-mock-server"
import { connect, disconnect, getClientEmiter } from "./ipc-client/ipc-client"
export const E2EMockClient = {
@@ -22,6 +28,9 @@ export const E2EMockClient = {
removeDevice: (path: string) => {
getClientEmiter()?.("mock.remove.device", path)
},
+ mockReset: (param: RestoreDefaultResponses) => {
+ getClientEmiter()?.("mock.response.reset", param)
+ },
mockResponse: (param: AddKompaktResponse) => {
getClientEmiter()?.("mock.response.every", param)
},
diff --git a/libs/e2e-mock/responses/src/index.ts b/libs/e2e-mock/responses/src/index.ts
index 32332f592f..1e7a629aa7 100644
--- a/libs/e2e-mock/responses/src/index.ts
+++ b/libs/e2e-mock/responses/src/index.ts
@@ -6,3 +6,6 @@
export * from "./lib/default-responses"
export * from "./lib/outbox-responses"
export * from "./lib/overview-responses"
+export * from "./lib/menu-responses"
+export * from "./lib/api-config-responses"
+export * from "./lib/contacts-responses"
diff --git a/libs/e2e-mock/responses/src/lib/api-config-responses.ts b/libs/e2e-mock/responses/src/lib/api-config-responses.ts
new file mode 100644
index 0000000000..db4e4c5f75
--- /dev/null
+++ b/libs/e2e-mock/responses/src/lib/api-config-responses.ts
@@ -0,0 +1,16 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import { ApiConfig } from "device/models"
+
+export const apiConfigWithContacts: ApiConfig = {
+ apiVersion: "1.0.0",
+ lang: "en-US",
+ variant: "black",
+ features: ["mc-overview", "contacts"],
+ productId: "2006",
+ vendorId: "0e8d",
+ serialNumber: "0123456789ABCDEF",
+}
diff --git a/libs/e2e-mock/responses/src/lib/contacts-responses.ts b/libs/e2e-mock/responses/src/lib/contacts-responses.ts
new file mode 100644
index 0000000000..b2b7e3e044
--- /dev/null
+++ b/libs/e2e-mock/responses/src/lib/contacts-responses.ts
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export const contactsData = {}
+
+export const contactsConfig = {
+ main: {
+ screenTitle: "Contacts",
+ component: "block-plain",
+ childrenKeys: ["fullScreenWrapper"],
+ layout: {
+ flexLayout: {
+ direction: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ },
+ },
+ fullScreenWrapper: {
+ component: "block-plain",
+ childrenKeys: ["title", "detailText", "importContactsButton"],
+ layout: {
+ flexLayout: {
+ direction: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ rowGap: "8px",
+ columnGap: "8px",
+ },
+ },
+ },
+ title: {
+ component: "h3-component",
+ config: { text: "Import your contacts" },
+ },
+ detailText: {
+ component: "p1-component",
+ config: { text: "Import all your contacts from a singles ource." },
+ },
+ importContactsButton: {
+ component: "mc-import-contacts-button",
+ config: { text: "import contacts" },
+ layout: { margin: "16px" },
+ },
+}
diff --git a/libs/e2e-mock/responses/src/lib/default-responses.ts b/libs/e2e-mock/responses/src/lib/default-responses.ts
index 550c69b4f4..692283a7f2 100644
--- a/libs/e2e-mock/responses/src/lib/default-responses.ts
+++ b/libs/e2e-mock/responses/src/lib/default-responses.ts
@@ -4,6 +4,7 @@
*/
import { ApiResponse } from "Core/device/types/mudita-os"
+import { MatchConfig } from "Libs/e2e-mock/server/src"
import { APIEndpointType, APIMethodsType } from "device/models"
//import from "Core/device" breaks usage in e2e
@@ -29,9 +30,15 @@ enum ResponseStatus {
Timeout = 505,
}
+export type ApiResponseWithConfig = ApiResponse & {
+ match?: MatchConfig
+}
+
+export type ApiResponsesWithConfigArray = ApiResponseWithConfig[]
+
type MethodObject = Partial>>
-type MethodArray = Partial[]>>
+type MethodArray = Partial>
export type MockResponsesMap = Partial>
export type MocksArrayResponsesMap = Partial<
diff --git a/libs/e2e-mock/responses/src/lib/menu-responses.ts b/libs/e2e-mock/responses/src/lib/menu-responses.ts
new file mode 100644
index 0000000000..b62c25e84c
--- /dev/null
+++ b/libs/e2e-mock/responses/src/lib/menu-responses.ts
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+export const menuWithContacts = {
+ title: "Kompakt",
+ menuItems: [
+ {
+ feature: "mc-overview",
+ displayName: "Overview",
+ icon: "overview",
+ },
+ {
+ feature: "contacts",
+ displayName: "Contacts",
+ icon: "contacts-book",
+ },
+ ],
+}
diff --git a/libs/e2e-mock/responses/src/lib/overview-responses.ts b/libs/e2e-mock/responses/src/lib/overview-responses.ts
index 1afb5b64cc..f9fb72dd07 100644
--- a/libs/e2e-mock/responses/src/lib/overview-responses.ts
+++ b/libs/e2e-mock/responses/src/lib/overview-responses.ts
@@ -20,3 +20,155 @@ export const overviewDataWithoutBadge = {
"airplane-mode": { icon: "airplane-mode", text: "Airplane mode" },
},
}
+
+export const overviewDataWithOneSimCard = {
+ summary: {
+ about: {
+ serialNumber: { text: "0123456789ABCDEF" },
+ imei1: { text: "864055030138811" },
+ imei2: { text: "864055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: { icon: "battery-charging-5", text: "100%", subText: "" },
+ update: { text: "Mudita OS", version: "0.3.0" },
+ "airplane-mode": {
+ icon: "network-signal-2",
+ text: "T-Mobile",
+ subText: "SIM 1",
+ },
+ },
+}
+
+export const overviewDataWithOneSimCard2nd = {
+ summary: {
+ about: {
+ serialNumber: { text: "1123456789ABCDEG" },
+ imei1: { text: "064055030138811" },
+ imei2: { text: "064055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: {
+ icon: "battery-charging-2",
+ text: "40%",
+ subText: "",
+ },
+ update: { text: "Mudita OS", version: "0.3.1" },
+ "airplane-mode": {
+ icon: "network-signal-4",
+ text: "Play",
+ subText: "SIM 1",
+ },
+ },
+}
+
+export const overviewDataWithOneSimCard3rd = {
+ summary: {
+ about: {
+ serialNumber: { text: "1123456789ABCDEH" },
+ imei1: { text: "064055030138811" },
+ imei2: { text: "064055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: {
+ icon: "battery-charging-3",
+ text: "60%",
+ subText: "",
+ },
+ update: { text: "Mudita OS", version: "0.3.1" },
+ "airplane-mode": {
+ icon: "network-signal-3",
+ text: "Orange",
+ subText: "SIM 1",
+ },
+ },
+}
+
+export const overviewDataWithOneSimCard4th = {
+ summary: {
+ about: {
+ serialNumber: { text: "1123456789ABCDEI" },
+ imei1: { text: "064055030138811" },
+ imei2: { text: "064055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: {
+ icon: "battery-charging-2",
+ text: "80%",
+ subText: "",
+ },
+ update: { text: "Mudita OS", version: "0.3.1" },
+ "airplane-mode": {
+ icon: "network-signal-4",
+ text: "O2",
+ subText: "SIM 1",
+ },
+ },
+}
+
+export const overviewDataWithOneSimCard5th = {
+ summary: {
+ about: {
+ serialNumber: { text: "1123456789ABCDEJ" },
+ imei1: { text: "064055030138811" },
+ imei2: { text: "064055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: {
+ icon: "battery-charging-2",
+ text: "100%",
+ subText: "",
+ },
+ update: { text: "Mudita OS", version: "0.3.1" },
+ "airplane-mode": {
+ icon: "network-signal-4",
+ text: "Vodafone",
+ subText: "SIM 1",
+ },
+ },
+}
+
+export const overviewDataWithOneSimCard6th = {
+ summary: {
+ about: {
+ serialNumber: { text: "1123456789ABCDEK" },
+ imei1: { text: "064055030138811" },
+ imei2: { text: "064055030138829" },
+ sar: {
+ text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.",
+ },
+ },
+ },
+ sections: {
+ battery: {
+ icon: "battery-charging-2",
+ text: "20%",
+ subText: "",
+ },
+ update: { text: "Mudita OS", version: "0.3.1" },
+ "airplane-mode": {
+ icon: "network-signal-4",
+ text: "Telia",
+ subText: "SIM 1",
+ },
+ },
+}
diff --git a/libs/e2e-mock/server/README.md b/libs/e2e-mock/server/README.md
index 35be3b3273..b0e6fa1f9e 100644
--- a/libs/e2e-mock/server/README.md
+++ b/libs/e2e-mock/server/README.md
@@ -47,7 +47,7 @@ E2EMockClient.mockHttpResponse({
The `setMockUpdateState` function is a method provided by the `E2EMockClient` to simulate different update states of the application, use the following command:
```javascript
-E2EMockClient.setMockUpdateState({ available: boolean, version?: string })
+E2EMockClient.setMockUpdateState({ available: boolean, downloaded?: boolean, version?: string })
```
### Parameters
@@ -55,6 +55,8 @@ E2EMockClient.setMockUpdateState({ available: boolean, version?: string })
- `version` (string, optional): This parameter specifies the version of the update that is available. It is only required if `available` is set to `true`.
+- `downloaded` (boolean, optional): This parameter indicates whether the download process was successful (`true`) or not (`false`). When downloaded is `true`, the modal shows in-progress indefinitely, and in the production environment, the application closes to complete the installation process. When downloaded is `false`, the application displays an error message.
+
## Usage Examples
### No Update Available
@@ -71,13 +73,27 @@ To set the response indicating that an update is available with a specified vers
E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0" })
```
+### Update Available with Download Failure
+
+To set the response indicating that an update is available with a specified version, but the download process fails, use the following command:
+```javascript
+E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0", downloaded: false })
+```
+
+### Update Available with Successful Download
+
+To set the response indicating that an update is available with a specified version and the download process is successful, use the following command:
+```javascript
+E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0", downloaded: true })
+```
+
### Required Mudita Center Update
To set the response indicating that an update is available and a Mudita Center update is required for versions lower than 3.0.0, use the following commands:
```javascript
E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0" })
E2EMockClient.mockHttpResponse({
- url: '/v2-app-configuration',
+ url: 'v2-app-configuration',
method: 'GET',
status: 200,
data: {
@@ -97,7 +113,7 @@ To set the response indicating that an update is available and the application i
```javascript
E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0" })
E2EMockClient.mockHttpResponse({
- url: '/v2-app-configuration',
+ url: 'v2-app-configuration',
method: 'GET',
status: 200,
data: {
diff --git a/libs/e2e-mock/server/src/index.ts b/libs/e2e-mock/server/src/index.ts
index c7066d6942..ef223decf3 100644
--- a/libs/e2e-mock/server/src/index.ts
+++ b/libs/e2e-mock/server/src/index.ts
@@ -8,4 +8,5 @@ export * from "./lib/server"
export { getMockedDevices } from "./lib/mock-descriptor/mock-descriptor"
export * from "./lib/mock-data-resolver-service"
export * from "./lib/mock-http-state.service"
+export * from "./lib/mock-serial-port.service"
export * from "./lib/mock-descriptor/mock-descriptor-validators"
diff --git a/libs/e2e-mock/server/src/lib/mock-data-resolver-service.ts b/libs/e2e-mock/server/src/lib/mock-data-resolver-service.ts
index d4aa66eeed..4f12b00c92 100644
--- a/libs/e2e-mock/server/src/lib/mock-data-resolver-service.ts
+++ b/libs/e2e-mock/server/src/lib/mock-data-resolver-service.ts
@@ -3,11 +3,11 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { IDeviceResolverService } from "Core/device-manager/services"
+import { DeviceType } from "device-protocol/models"
+import { IDeviceResolverService } from "device-protocol/feature"
import { BaseDevice } from "Core/device/modules/base-device"
import { PortInfo } from "serialport"
import { MockDevice } from "./mock-device/mock-device"
-import { DeviceType } from "Core/device"
export class MockDeviceResolverService implements IDeviceResolverService {
public resolve(portInfo: PortInfo): BaseDevice | undefined {
diff --git a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor-validators.ts b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor-validators.ts
index c7fb697e94..bf905fd3b5 100644
--- a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor-validators.ts
+++ b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor-validators.ts
@@ -12,6 +12,17 @@ export const addKompaktValidator = z.object({
serialNumber: z.string().min(1),
})
+const MatchConfigValidator = z.object({
+ expected: z.object({}).passthrough(),
+ options: z
+ .object({
+ id: z.string().optional(),
+ })
+ .optional(),
+})
+
+export type MatchConfig = z.infer
+
export type AddKompakt = z.infer
export const addKompaktResponseValidator = z.object({
@@ -20,6 +31,23 @@ export const addKompaktResponseValidator = z.object({
method: z.enum(APIMethods),
status: z.nativeEnum(ResponseStatus),
body: z.object({}).passthrough(),
+ match: MatchConfigValidator.optional(),
})
export type AddKompaktResponse = z.infer
+
+export const restoreDefaultResponsesValidator = z.object({
+ path: z.string().min(1),
+ requests: z
+ .array(
+ z.object({
+ endpoint: z.enum(APIEndpoints),
+ method: z.enum(APIMethods),
+ })
+ )
+ .optional(),
+})
+
+export type RestoreDefaultResponses = z.infer<
+ typeof restoreDefaultResponsesValidator
+>
diff --git a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts
index 2de6354477..8282d6af04 100644
--- a/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts
+++ b/libs/e2e-mock/server/src/lib/mock-descriptor/mock-descriptor.ts
@@ -3,12 +3,17 @@
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/
-import { find } from "lodash"
+import { findIndex, pullAt, find } from "lodash"
import { PortInfo } from "serialport"
-import { AddKompakt, AddKompaktResponse } from "./mock-descriptor-validators"
import {
+ AddKompakt,
+ AddKompaktResponse,
+ RestoreDefaultResponses,
+} from "./mock-descriptor-validators"
+import {
+ ApiResponseWithConfig,
+ ApiResponsesWithConfigArray,
DEFAULT_RESPONSES,
- MockResponsesMap,
MocksArrayResponsesMap,
} from "e2e-mock-responses"
import { APIEndpointType, APIMethodsType } from "device/models"
@@ -23,7 +28,7 @@ const KOMPAKT_PORT_INFO: Omit = {
}
class MockDescriptor {
- private _mockResponsesPerDevice: Record = {}
+ private _mockResponsesPerDevice: Record = {}
private _mockResponsesPerDeviceOnce: Record =
{}
@@ -55,35 +60,82 @@ class MockDescriptor {
method,
path,
status,
+ match,
}: AddKompaktResponse) {
+ const currentResponses =
+ this._mockResponsesPerDevice[path]?.[endpoint]?.[method] ?? []
+
+ const filteredResponses = currentResponses.filter((item) => {
+ if (match?.options?.id === item.match?.options?.id) {
+ return false
+ }
+ return true
+ })
+
this._mockResponsesPerDevice[path] = {
...this._mockResponsesPerDevice[path],
[endpoint]: {
...this._mockResponsesPerDevice[path]?.[endpoint],
- [method]: {
- status,
- body,
- },
+ [method]: [
+ ...filteredResponses,
+ {
+ status,
+ body,
+ match,
+ },
+ ],
},
}
}
+ public removeResponses({ path, requests }: RestoreDefaultResponses) {
+ requests?.forEach((request) => {
+ if (
+ this._mockResponsesPerDevice[path]?.[request.endpoint]?.[request.method]
+ ) {
+ this._mockResponsesPerDevice[path][request.endpoint]![request.method] =
+ undefined
+ }
+ if (
+ this._mockResponsesPerDeviceOnce[path]?.[request.endpoint]?.[
+ request.method
+ ]
+ ) {
+ this._mockResponsesPerDeviceOnce[path][request.endpoint]![
+ request.method
+ ] = undefined
+ }
+ })
+ }
+
public addResponseOnce({
body,
endpoint,
method,
path,
status,
+ match,
}: AddKompaktResponse) {
+ const currentResponses =
+ this._mockResponsesPerDevice[path]?.[endpoint]?.[method] ?? []
+
+ const filteredResponses = currentResponses.filter((item) => {
+ if (match?.options?.id === item.match?.options?.id) {
+ return false
+ }
+ return true
+ })
+
this.setResponseOnce({
path,
endpoint,
method,
responses: [
- ...(this._mockResponsesPerDeviceOnce[path]?.[endpoint]?.[method] ?? []),
+ ...filteredResponses,
{
status,
body,
+ match,
},
],
})
@@ -95,7 +147,7 @@ class MockDescriptor {
method,
responses,
}: Pick & {
- responses: ApiResponse[]
+ responses: ApiResponseWithConfig[]
}) {
this._mockResponsesPerDeviceOnce[path] = {
...this._mockResponsesPerDeviceOnce[path],
@@ -106,32 +158,98 @@ class MockDescriptor {
}
}
- public getResponse(
+ private findResponse(
+ responses: ApiResponsesWithConfigArray,
+ body: Record | undefined
+ ) {
+ const matchArray = responses.map((item) => item.match?.expected)
+ const matchIndex = findIndex(matchArray, body)
+ if (matchIndex > -1) {
+ const response = responses[matchIndex]
+
+ return {
+ response,
+ index: matchIndex,
+ }
+ }
+
+ const index = findIndex(responses, (item) => !item.match)
+
+ if (index > -1) {
+ const response = responses[index]
+
+ return {
+ response,
+ index: index,
+ }
+ }
+
+ return
+ }
+
+ private getPerDeviceOnceResponse(
path: string,
endpoint: APIEndpointType,
- method: APIMethodsType
+ method: APIMethodsType,
+ body: Record | undefined
): ApiResponse | undefined {
- const perDeviceOnceResponse =
+ const perDeviceOnceResponses =
this._mockResponsesPerDeviceOnce[path]?.[endpoint]?.[method]
- if (
- perDeviceOnceResponse !== undefined &&
- perDeviceOnceResponse.length > 0
- ) {
- const response: ApiResponse | undefined =
- perDeviceOnceResponse.pop()
- this.setResponseOnce({
- path,
- endpoint,
- method,
- responses: perDeviceOnceResponse,
- })
- return response
+ if (perDeviceOnceResponses !== undefined) {
+ const foundResponse = this.findResponse(perDeviceOnceResponses, body)
+ if (foundResponse) {
+ pullAt(perDeviceOnceResponses, [foundResponse.index])
+ this.setResponseOnce({
+ path,
+ endpoint,
+ method,
+ responses: perDeviceOnceResponses,
+ })
+ return foundResponse.response
+ }
}
- const perDeviceResponse: ApiResponse | undefined =
+ return undefined
+ }
+
+ private getPerDeviceResponse(
+ path: string,
+ endpoint: APIEndpointType,
+ method: APIMethodsType,
+ body: Record | undefined
+ ): ApiResponse | undefined {
+ const perDeviceResponses =
this._mockResponsesPerDevice[path]?.[endpoint]?.[method]
- if (perDeviceResponse !== undefined) {
- return perDeviceResponse
+ if (perDeviceResponses !== undefined) {
+ const foundResponse = this.findResponse(perDeviceResponses, body)
+
+ if (foundResponse) {
+ return foundResponse.response
+ }
+ }
+ return undefined
+ }
+
+ public getResponse(
+ path: string,
+ endpoint: APIEndpointType,
+ method: APIMethodsType,
+ body: Record | undefined
+ ): ApiResponse | undefined {
+ const onceResponse = this.getPerDeviceOnceResponse(
+ path,
+ endpoint,
+ method,
+ body
+ )
+ if (onceResponse) {
+ return onceResponse
}
+
+ const response = this.getPerDeviceResponse(path, endpoint, method, body)
+ if (response) {
+ return response
+ }
+
const defaultResponse: ApiResponse | undefined =
DEFAULT_RESPONSES[endpoint]?.[method]
diff --git a/libs/e2e-mock/server/src/lib/mock-device/mock-device.ts b/libs/e2e-mock/server/src/lib/mock-device/mock-device.ts
index 29c34458aa..816a0f16d8 100644
--- a/libs/e2e-mock/server/src/lib/mock-device/mock-device.ts
+++ b/libs/e2e-mock/server/src/lib/mock-device/mock-device.ts
@@ -4,7 +4,8 @@
*/
import { Result, ResultObject } from "Core/core/builder"
-import { DeviceType, ResponseStatus } from "Core/device"
+import { ResponseStatus } from "Core/device"
+import { DeviceType } from "device-protocol/models"
import { DeviceError } from "Core/device/modules/mudita-os/constants"
import { BaseDevice } from "Core/device/modules/base-device"
import { ApiResponse } from "Core/device/types/mudita-os"
@@ -33,7 +34,8 @@ export class MockDevice extends BaseDevice {
const response = mockDescriptor.getResponse(
this.portInfo.path,
config.endpoint,
- config.method as APIMethodsType
+ config.method as APIMethodsType,
+ config.body
)
let result: ResultObject> | undefined = undefined
diff --git a/libs/e2e-mock/server/src/lib/mock-serial-port.service.ts b/libs/e2e-mock/server/src/lib/mock-serial-port.service.ts
new file mode 100644
index 0000000000..6c83124540
--- /dev/null
+++ b/libs/e2e-mock/server/src/lib/mock-serial-port.service.ts
@@ -0,0 +1,14 @@
+/**
+ * Copyright (c) Mudita sp. z o.o. All rights reserved.
+ * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
+ */
+
+import SerialPort from "serialport"
+import { ISerialPortService } from "Libs/device-protocol/feature/src/services/serial-port.service"
+import { getMockedDevices } from "./mock-descriptor/mock-descriptor"
+
+export class MockSerialPortService implements ISerialPortService {
+ async list(): Promise {
+ return getMockedDevices()
+ }
+}
diff --git a/libs/e2e-mock/server/src/lib/mock-updater-state.service.ts b/libs/e2e-mock/server/src/lib/mock-updater-state.service.ts
index 95abbb67da..79a0c9d489 100644
--- a/libs/e2e-mock/server/src/lib/mock-updater-state.service.ts
+++ b/libs/e2e-mock/server/src/lib/mock-updater-state.service.ts
@@ -5,20 +5,24 @@
export interface UpdateState {
available: boolean
+ downloaded?: boolean
version?: string
}
+const defaultUpdateState: UpdateState = {
+ available: false,
+ downloaded: true,
+}
+
export class MockUpdaterStateService {
- private _updateState: UpdateState = {
- available: false,
- }
+ private _updateState = { ...defaultUpdateState }
get updateState(): UpdateState {
return this._updateState
}
set updateState(value: UpdateState) {
- this._updateState = value
+ this._updateState = { ...defaultUpdateState, ...value }
}
}
diff --git a/libs/e2e-mock/server/src/lib/server.tsx b/libs/e2e-mock/server/src/lib/server.tsx
index c4e02035ba..2715cf491b 100644
--- a/libs/e2e-mock/server/src/lib/server.tsx
+++ b/libs/e2e-mock/server/src/lib/server.tsx
@@ -8,6 +8,7 @@ import logger from "Core/__deprecated__/main/utils/logger"
import {
addKompaktResponseValidator,
addKompaktValidator,
+ restoreDefaultResponsesValidator,
} from "./mock-descriptor/mock-descriptor-validators"
import { mockDescriptor } from "./mock-descriptor/mock-descriptor"
import {
@@ -49,6 +50,12 @@ ipc.serve(function () {
mockDescriptor.addResponseOnce(params.data)
}
})
+ ipc.server.on("mock.response.reset", function (data, socket) {
+ const params = restoreDefaultResponsesValidator.safeParse(data)
+ if (params.success) {
+ mockDescriptor.removeResponses(params.data)
+ }
+ })
ipc.server.on("server.stop", function (data, socket) {
stopServer()
})
diff --git a/libs/electron/application-updater/src/lib/application-updater.controller.ts b/libs/electron/application-updater/src/lib/application-updater.controller.ts
deleted file mode 100644
index cd045899c6..0000000000
--- a/libs/electron/application-updater/src/lib/application-updater.controller.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { IpcEvent } from "Core/core/decorators"
-import { IpcApplicationUpdaterEvent } from "./ipc-application-updater.event"
-import { BaseApplicationUpdaterService } from "./base-application-updater.service"
-
-export class ApplicationUpdaterController {
- constructor(
- private applicationUpdaterService: BaseApplicationUpdaterService
- ) {}
-
- @IpcEvent(IpcApplicationUpdaterEvent.Check)
- public async check(): Promise {
- return this.applicationUpdaterService.checkForUpdatesAndNotify()
- }
- @IpcEvent(IpcApplicationUpdaterEvent.Install)
- public async install(): Promise {
- return this.applicationUpdaterService.quitAndInstall()
- }
- @IpcEvent(IpcApplicationUpdaterEvent.Download)
- public async download(): Promise {
- return this.applicationUpdaterService.downloadUpdate()
- }
-}
diff --git a/libs/electron/application-updater/src/lib/application-updater.module.ts b/libs/electron/application-updater/src/lib/application-updater.module.ts
index c455708a5f..5d67ce966b 100644
--- a/libs/electron/application-updater/src/lib/application-updater.module.ts
+++ b/libs/electron/application-updater/src/lib/application-updater.module.ts
@@ -5,7 +5,6 @@
import { mockServiceEnabled, mockUpdaterStateService } from "e2e-mock-server"
import { onlineStatusService } from "shared/app-state"
-import { ApplicationUpdaterController } from "./application-updater.controller"
import { ApplicationUpdaterService } from "./application-updater.service"
import { BaseApplicationUpdaterService } from "./base-application-updater.service"
import { MockApplicationUpdaterService } from "./mock-application-updater.service"
@@ -17,7 +16,7 @@ export class ApplicationUpdaterModule {
const applicationUpdaterService = this.resolveApplicationUpdaterService()
this.controllers = [
- new ApplicationUpdaterController(applicationUpdaterService),
+ applicationUpdaterService,
]
}
diff --git a/libs/electron/application-updater/src/lib/application-updater.service.ts b/libs/electron/application-updater/src/lib/application-updater.service.ts
index f52418bf71..3d90fa0b04 100644
--- a/libs/electron/application-updater/src/lib/application-updater.service.ts
+++ b/libs/electron/application-updater/src/lib/application-updater.service.ts
@@ -5,7 +5,9 @@
import { autoUpdater } from "electron-updater"
import logger from "Core/__deprecated__/main/utils/logger"
+import { IpcEvent } from "Core/core/decorators"
import { BaseApplicationUpdaterService } from "./base-application-updater.service"
+import { IpcApplicationUpdaterEvent } from "./ipc-application-updater.event"
const token = process.env.GITHUB_ACCESS_TOKEN
const repo = process.env.RELEASES_REPOSITORY_NAME
@@ -18,13 +20,17 @@ export class ApplicationUpdaterService extends BaseApplicationUpdaterService {
this.mountListeners()
}
+ @IpcEvent(IpcApplicationUpdaterEvent.Install)
public quitAndInstall(): void {
autoUpdater.quitAndInstall(true, true)
}
+ @IpcEvent(IpcApplicationUpdaterEvent.Download)
public async downloadUpdate(): Promise {
await autoUpdater.downloadUpdate()
}
+
+ @IpcEvent(IpcApplicationUpdaterEvent.Check)
public async checkForUpdatesAndNotify(): Promise {
await autoUpdater.checkForUpdatesAndNotify()
}
diff --git a/libs/electron/application-updater/src/lib/mock-application-updater.service.ts b/libs/electron/application-updater/src/lib/mock-application-updater.service.ts
index 13cd2d221c..db469ef009 100644
--- a/libs/electron/application-updater/src/lib/mock-application-updater.service.ts
+++ b/libs/electron/application-updater/src/lib/mock-application-updater.service.ts
@@ -4,24 +4,30 @@
*/
import { MockUpdaterStateService } from "e2e-mock-server"
-import { OnlineStatusService } from "shared/app-state"
+import { IOnlineStatusService } from "shared/app-state"
+import { IpcEvent } from "Core/core/decorators"
import { BaseApplicationUpdaterService } from "./base-application-updater.service"
+import { IpcApplicationUpdaterEvent } from "./ipc-application-updater.event"
export class MockApplicationUpdaterService extends BaseApplicationUpdaterService {
constructor(
- private onlineStatusService: OnlineStatusService,
+ private onlineStatusService: IOnlineStatusService,
private mockUpdaterStateService: MockUpdaterStateService
) {
super()
}
- public quitAndInstall(): void {
- this.onError()
- }
+ public quitAndInstall(): void {}
+ @IpcEvent(IpcApplicationUpdaterEvent.Download)
public async downloadUpdate(): Promise {
- this.onError()
+ if (this.isUpdateDownloaded()) {
+ this.onUpdateDownloaded()
+ } else {
+ this.onError()
+ }
}
+ @IpcEvent(IpcApplicationUpdaterEvent.Check)
public async checkForUpdatesAndNotify(): Promise {
if (!this.onlineStatusService.online) {
return this.onError()
@@ -33,6 +39,11 @@ export class MockApplicationUpdaterService extends BaseApplicationUpdaterService
this.onUpdateNotAvailable()
}
}
+
+ private isUpdateDownloaded(): boolean {
+ return this.mockUpdaterStateService.updateState.downloaded ?? true
+ }
+
private isUpdateAvailable(): boolean {
return this.mockUpdaterStateService.updateState.available
}
diff --git a/libs/external-tools/matomo-to-gsheet/README.md b/libs/external-tools/matomo-to-gsheet/README.md
deleted file mode 100644
index 812047fb8f..0000000000
--- a/libs/external-tools/matomo-to-gsheet/README.md
+++ /dev/null
@@ -1,58 +0,0 @@
-# Matomo Data to Google Sheets Script
-
-This script is designed to fetch data from the Matomo API and update it in a Google Sheets spreadsheet.
-
-## Requirements
-
-1. Node.js
-2. Matomo API key and access to a Google Sheets account.
-
-## Configuration
-
-1. Copy the `.env.example` file and rename it to `.env`.
-2. Fill in the required environment variables in the `.env` file:
- - `MATOMO_TO_GSHEET_KEYFILEPATH`: Path to the Google service key.
- - `MATOMO_TO_GSHEET_SPREADSHEET_ID`: Google Sheets spreadsheet ID where the data will be saved.
- - `MATOMO_TO_GSHEET_API_URL`: Matomo API URL.
- - `MATOMO_TO_GSHEET_SITE_ID`: Matomo website ID.
- - `MATOMO_TO_GSHEET_TOKEN`: Matomo authentication token.
-
-### Note on Authentication
-
-For the `MATOMO_TO_GSHEET_KEYFILEPATH` variable, it represents the path to the Google service account key file, which is required for authentication with the Google Sheets API. You can obtain this key file by following these steps:
-
-1. Navigate to the Google Cloud Console.
-2. Select the project associated with your Google Sheets account.
-3. In the left sidebar, click on "IAM & admin" and then "Service accounts".
-4. Find the service account you want to use or create a new one.
-5. Click on the service account and then navigate to the "Keys" tab.
-6. Click on "Add key" and select "JSON" format.
-7. Save the downloaded JSON file securely to your local machine.
-8. Set the `MATOMO_TO_GSHEET_KEYFILEPATH` variable in the `.env` file to the path of the downloaded JSON file.
-
-Ensure that the service account has the necessary permissions to access the Google Sheets API and edit the specified spreadsheet.
-
-## Installation
-
-3. Run `npm install` to install all required dependencies.
-
-## Running the Script
-
-1. Run `npm run matomo-to-gsheet:run` to execute the script from the project's root directory.
-2. The script will fetch data from the Matomo API and update the Google Sheets spreadsheet.
-
-## Architecture
-
-The project consists of several main components:
-
-1. **Matomo Service**: Responsible for communicating with the Matomo API and fetching data according to specified parameters. Handles various types of queries, such as fetching action events, category events, etc.
-
-2. **Google Sheet Service**: Manages the update of the Google Sheets spreadsheet. Retrieves data from the Matomo Service and updates the appropriate cells in the Google Sheets spreadsheet.
-
-3. **Utils**: Set of utility functions, such as generating date ranges, validating date formats, etc.
-
-4. **Environment Configuration**: The `.env` file where environment variables necessary for configuring the script are stored, such as API keys and Google Sheets identifiers.
-
-### Enhancing Automation
-
-For enhanced automation, consider transferring the script to GitHub Actions as a scheduled cron job. This will allow for periodic execution of the script without the need for manual intervention.
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/google-sheet.factory.ts b/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/google-sheet.factory.ts
deleted file mode 100644
index 0fb677c967..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/google-sheet.factory.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { google, sheets_v4 } from "googleapis"
-
-const KEYFILEPATH = process.env.MATOMO_TO_GSHEET_KEYFILEPATH!
-
-class GoogleSheetFactory {
- static makeGoogleSheet(): sheets_v4.Sheets{
- // @ts-ignore
- return google.sheets({
- version: "v4",
- auth: new google.auth.GoogleAuth({
- keyFile: KEYFILEPATH,
- scopes: ["https://www.googleapis.com/auth/spreadsheets"],
- }),
- })
- }
-}
-
-export default GoogleSheetFactory
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/stats-sheet.service.ts b/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/stats-sheet.service.ts
deleted file mode 100644
index 20ea31f968..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/google-sheet/stats-sheet.service.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import { sheets_v4 } from "googleapis"
-import isValidDateFormat from "../utils/is-valid-date-format"
-
-type MatomoData = { [date: string]: { label: string; nb_events: number }[] }
-
-const SPREADSHEET_ID = process.env.MATOMO_TO_GSHEET_SPREADSHEET_ID!
-const defaultStartDate = "2023-07-30"
-
-export default class StatsSheetService {
- constructor(private sheets: sheets_v4.Sheets) {}
-
- public async getLastDate(sheetName: string): Promise {
- const response = await this.sheets.spreadsheets.values.get({
- spreadsheetId: SPREADSHEET_ID,
- range: `${sheetName}!A:A`,
- })
- const rows: string[][] = response.data.values ?? []
-
- if (rows.length === 0) {
- return defaultStartDate
- }
-
- const date = rows[rows.length - 1][0]
-
- if (!isValidDateFormat(date)) {
- throw new Error(
- "dateString is in another format than YYYY-MM-DD while retrieving data from the sheet"
- )
- }
-
- return date
- }
-
- public async updateStats(data: MatomoData, sheetName: string): Promise {
- const response = await this.sheets.spreadsheets.values.get({
- spreadsheetId: SPREADSHEET_ID,
- range: `${sheetName}!A2:ZZ`,
- })
-
- const existingData = response.data.values || []
-
- const existingHeaders = existingData.length > 0 ? existingData[0] : []
- const allVersions = new Set(existingHeaders.slice(1)) // Removing "Dzień" from the headers
-
- // Adding new versions from current data
- Object.values(data).forEach((events) =>
- events.forEach((event) =>
- allVersions.add(event.label.replace("latest - ", ""))
- )
- )
-
- const updatedHeaders = ["Dzień", ...Array.from(allVersions)]
- const headersToUpdate =
- existingHeaders.length < updatedHeaders.length ||
- !updatedHeaders.every(
- (header, index) => existingHeaders[index] === header
- )
-
- // Updating headers if necessary
- if (headersToUpdate) {
- await this.sheets.spreadsheets.values.update({
- spreadsheetId: SPREADSHEET_ID,
- range: `${sheetName}!A2`,
- valueInputOption: "USER_ENTERED",
- requestBody: { values: [updatedHeaders] },
- })
- }
-
- // Preparing new data rows according to current headers
- const rows = Object.entries(data).map(([date, events]) => {
- const row = new Array(updatedHeaders.length).fill(0)
- row[0] = date // Date set
-
- events.forEach((event) => {
- const versionIndex = updatedHeaders.indexOf(
- event.label.replace("latest - ", "")
- )
- if (versionIndex !== -1) {
- row[versionIndex] = event.nb_events // Setting the number of events for the respective version
- }
- })
-
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
- return row
- })
-
- // Finding the first empty row after existing data
- const startRow = existingData.length + 2 // +2 because headers are in the second row
-
- // Adding new data
- await this.sheets.spreadsheets.values.append({
- spreadsheetId: SPREADSHEET_ID,
- range: `${sheetName}!A${startRow}`,
- valueInputOption: "USER_ENTERED",
- requestBody: { values: rows },
- })
- }
-}
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo-data.interface.ts b/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo-data.interface.ts
deleted file mode 100644
index 98474a9b6c..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo-data.interface.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-export interface MatomoEvent {
- label: string;
- nb_uniq_visitors: number;
- nb_visits: number;
- nb_events: number;
- nb_events_with_value: number;
- sum_event_value: number;
- min_event_value: boolean | number;
- max_event_value: number;
- avg_event_value: number;
- segment: string;
- idsubdatatable?: string;
-}
-
- export type MatomoData = { [date: string]: MatomoEvent[] };
-
-export interface FetchDataOptions {
- label: string
- startDate: string
- endDate: string
-}
-
-export interface GetActionEventsOptions {
- date: string
- label: string
-}
-
-export interface GetCategoryEventByLabelOptions {
- date: string
- label: string
-}
-
-export interface GetActionEventsByCategoryIdOptions {
- date: string
- id: string
-}
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo.service.ts b/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo.service.ts
deleted file mode 100644
index fe018624e5..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/matomo/matomo.service.ts
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import axios from "axios"
-import {
- FetchDataOptions,
- GetActionEventsByCategoryIdOptions,
- GetActionEventsOptions,
- GetCategoryEventByLabelOptions,
- MatomoData,
- MatomoEvent,
-} from "../matomo/matomo-data.interface"
-import generateDateRange from "../utils/generate-date-range"
-
-const MATOMO_API_URL: string = process.env.MATOMO_TO_GSHEET_API_URL!
-const MATOMO_SITE_ID: string = process.env.MATOMO_TO_GSHEET_SITE_ID!
-const MATOMO_TOKEN: string = process.env.MATOMO_TO_GSHEET_TOKEN!
-
-class MatomoService {
- public async fetchMatomoData({
- startDate,
- endDate,
- label,
- }: FetchDataOptions): Promise {
- const data: MatomoData = {}
- const dateRange = generateDateRange(startDate, endDate)
-
- for (const date of dateRange) {
- data[date] = await this.getActionEvents({ date, label })
- }
-
- return data
- }
-
- private async getActionEvents({
- date,
- label,
- }: GetActionEventsOptions): Promise {
- const categoryEvent = await this.getCategoryEventByLabel({ date, label })
-
- const id = categoryEvent?.idsubdatatable
- if (id === undefined) {
- return []
- }
-
- const actionEvents = await this.getActionEventsByCategoryId({
- date,
- id,
- })
- return actionEvents.filter((event) => event.label.includes("latest"))
- }
-
- private async getCategoryEventByLabel({
- date,
- label,
- }: GetCategoryEventByLabelOptions): Promise {
- try {
- const url = this.buildUrl({
- method: "Events.getCategory",
- period: "day",
- date: date,
- })
- const response = await axios.get(url)
-
- // @ts-ignore
- if (response.data.result === "error") {
- console.error(
- "Error while retrieving getCategoryEventByLabel:",
- response.data
- )
- return undefined
- }
-
- return response.data.find((event) => event.label === label)
- } catch (error) {
- console.error("Error while retrieving getCategoryEventByLabel:", error)
-
- return undefined
- }
- }
-
- private async getActionEventsByCategoryId({
- date,
- id,
- }: GetActionEventsByCategoryIdOptions): Promise {
- try {
- const url = this.buildUrl({
- method: "Events.getActionFromCategoryId",
- period: "day",
- date: date,
- idSubtable: id,
- })
- const response = await axios.get(url)
-
- // @ts-ignore
- if (response.data.result === "error") {
- console.error(
- "Error while retrieving getActionEventsByCategoryId:",
- response.data
- )
- return []
- }
-
- return response.data as MatomoEvent[]
- } catch (error) {
- console.error(
- "Error while retrieving getActionEventsByCategoryId:",
- error
- )
- return []
- }
- }
-
- private buildUrl(params: Record): string {
- const url = new URL(MATOMO_API_URL)
- url.search = new URLSearchParams({
- module: "API",
- format: "JSON",
- idSite: MATOMO_SITE_ID,
- token_auth: MATOMO_TOKEN,
- ...params,
- }).toString()
- return url.toString()
- }
-}
-
-export default MatomoService
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/script.ts b/libs/external-tools/matomo-to-gsheet/src/lib/script.ts
deleted file mode 100644
index 36116549b2..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/script.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-import 'dotenv/config';
-import MatomoService from "./matomo/matomo.service"
-import GoogleSheetFactory from "./google-sheet/google-sheet.factory"
-import StatsSheetService from "./google-sheet/stats-sheet.service"
-import getYesterdayDateString from "./utils/get-yesterday-date"
-
-const matomoService = new MatomoService()
-const statsSheetService = new StatsSheetService(
- GoogleSheetFactory.makeGoogleSheet()
-)
-
-const endDate = getYesterdayDateString()
-
-async function script() {
- try {
- const muditaHarmonySheetLastDate = await statsSheetService.getLastDate(
- "Mudita Harmony - MD"
- )
-
- const muditaHarmonyMatomoData = await matomoService.fetchMatomoData({
- label: "Harmony Update - download",
- startDate: muditaHarmonySheetLastDate,
- endDate,
- })
-
- await statsSheetService.updateStats(
- muditaHarmonyMatomoData,
- "Mudita Harmony - MD"
- )
-
- const muditaPureSheetLastDate = await statsSheetService.getLastDate(
- "Mudita Pure - MD"
- )
-
- const muditaPureMatomoData = await matomoService.fetchMatomoData({
- label: "Pure Update - download",
- startDate: muditaPureSheetLastDate,
- endDate,
- })
-
- await statsSheetService.updateStats(
- muditaPureMatomoData,
- "Mudita Pure - MD"
- )
-
- } catch (error) {
- console.error(error)
- return
- }
-}
-
-void script()
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/utils/generate-date-range.ts b/libs/external-tools/matomo-to-gsheet/src/lib/utils/generate-date-range.ts
deleted file mode 100644
index d75f275c77..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/utils/generate-date-range.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-/**
- * Generates an array of date strings between two specified dates.
- *
- * @param startDate The start date in `YYYY-MM-DD` format.
- * @param endDate The end date in `YYYY-MM-DD` format.
- * @returns An array of dates (inclusive) between `startDate` and `endDate`, formatted as `YYYY-MM-DD`.
- */
-function generateDateRange(startDate: string, endDate: string): string[] {
- const start = new Date(startDate)
- start.setDate(start.getDate() + 1)
- const end = new Date(endDate)
- const currentDate = new Date(start)
- const dateRange: string[] = []
-
- while (currentDate <= end) {
- dateRange.push(currentDate.toISOString().split("T")[0])
- currentDate.setDate(currentDate.getDate() + 1)
- }
-
- return dateRange
-}
-
-export default generateDateRange
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/utils/get-yesterday-date.ts b/libs/external-tools/matomo-to-gsheet/src/lib/utils/get-yesterday-date.ts
deleted file mode 100644
index 08d9b2cea8..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/utils/get-yesterday-date.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-/**
- * Returns yesterday's date as a string in 'YYYY-MM-DD' format.
- *
- * Utilizes the Date object to subtract one day from the current date,
- * then formats it to ISO string, extracting only the date part.
- *
- * @returns {string} Yesterday's date in 'YYYY-MM-DD'.
- */
-function getYesterdayDateString(): string {
- const date: Date = new Date()
- date.setDate(date.getDate() - 1)
-
- return date.toISOString().split("T")[0]
-}
-
-export default getYesterdayDateString
diff --git a/libs/external-tools/matomo-to-gsheet/src/lib/utils/is-valid-date-format.ts b/libs/external-tools/matomo-to-gsheet/src/lib/utils/is-valid-date-format.ts
deleted file mode 100644
index a8c3678283..0000000000
--- a/libs/external-tools/matomo-to-gsheet/src/lib/utils/is-valid-date-format.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright (c) Mudita sp. z o.o. All rights reserved.
- * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
- */
-
-/**
- * Validates if a given date string is in the format YYYY-MM-DD.
- * @param dateString The date string to validate.
- * @returns true if the dateString is in the format YYYY-MM-DD, otherwise false.
- */
-function isValidDateFormat(dateString: string): boolean {
- // Regular expression to match the YYYY-MM-DD format
- const regex = /^\d{4}-\d{2}-\d{2}$/;
-
- // Check if the dateString matches the regular expression
- if (!regex.test(dateString)) {
- return false;
- }
-
- // Further validation to ensure the date is valid (e.g., not 2022-02-30)
- const date = new Date(dateString);
- const dateNum = date.getTime();
-
- // Check if date is Invalid Date or the dateString does not match the date's toISOString() substring
- if (!dateNum && dateNum !== 0 || dateString !== date.toISOString().substring(0, 10)) {
- return false;
- }
-
- return true;
-}
-
-export default isValidDateFormat
diff --git a/libs/generic-view/feature/src/lib/api-device-modals.tsx b/libs/generic-view/feature/src/lib/api-device-modals.tsx
index 2ca1b162a0..fdb54f2111 100644
--- a/libs/generic-view/feature/src/lib/api-device-modals.tsx
+++ b/libs/generic-view/feature/src/lib/api-device-modals.tsx
@@ -8,6 +8,7 @@ import { GenericThemeProvider } from "generic-view/theme"
import BackupErrorModal from "./modals/backup-error-modal"
import RestoreErrorModal from "./modals/restore-error-modal"
import ImportContactsErrorModal from "./modals/import-contacts-error-modal"
+import { DataMigrationErrorModal } from "./modals/data-migration-error-modal"
export const ApiDeviceModals: FunctionComponent = () => {
return (
@@ -15,6 +16,7 @@ export const ApiDeviceModals: FunctionComponent = () => {