Skip to content

Conversation

KIvanow
Copy link
Contributor

@KIvanow KIvanow commented Oct 26, 2024

Steps to start (from the root folder each in a different browser tab):
yarn dev:electron:ui
yarn dev:electron:api
yarn dev:electron

This will start the fe and be with the required environments for electron as well as the electron app.

Live reload works both for the ui and api.

There is a new added script - dev:api for the sake of consistency. Right now we had to run (based on the wiki)yarn dev:uiand yarn --cwd redisinsight/api/ start:dev which seems difficult to remember and inconsistent.

Running just yarn dev:ui and yarn dev:api in separate terminals (or terminal tabs) will still allow the project to be ran in a browser (no loss of functionality).

All of the changes are aimed for development environment, production builds should be unaffected (tested on local linux builds)

Major changes

  1. Added vite configs for the desktop folder to keep it consistent

  2. Decoupled the desktop from loading parts of the api to handle window authentication and cloud authentication. On dev now those are done through TCP servers. This is what allows for everything to be ran separately and still have live/hot reload. This is also going to be used only during development

    2.1 All windows have the window id header in the requests and are checked in the api through the TCP communication approach

    2.2 The renderer is able to handle click on a social login button, then the main process is able to ping the api, the api is able to generate a URL, pass it back, open it in the default browser, complete the flow and then have the protocol of redisinsight:// be opened as a result. Everything going through the TCP communication instead of the desktop directly invoking methods of the api.

  3. Added 4 different packages that I've had yarn complain are not installed but required on 2 different OSs

I've tried to keep the changes as minimal as possible.

Any and all feedback is welcomed (especially if I've missed another place the desktop relied on the api in such a way).

Copy link
Contributor

@egor-zalenski egor-zalenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clear this pull request. There are unused files, console.logs, if(.... true)

  1. There are changes for BE code, please rename branch to 'be/feature/...' to auto run BE tests
  2. check your eslint. For desktop folder should apply root .eslintrc.js. This code has a lot of eslint errors: import orders, semicolon etc
    Backend has own eslint with semicolon.

@@ -0,0 +1,61 @@
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
Copy link
Contributor

@egor-zalenski egor-zalenski Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file forge.config.js used? I can't find a link to it anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I've missed to clean it up after when I started removing all different experiments. Removed.

"build:renderer": "vite build --config vite.renderer.config.ts"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not have duplicates of dependendcies
Please remove all dependencies from this file. They should be taken from root package.json.
Or move dependencies from root to here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleared the entire dependencies for the desktop. Tested to make sure it will still work.

package.json Outdated
"yarn-deduplicate": "^3.1.0"
},
"dependencies": {
"@antv/hierarchy": "^0.6.14",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need add dependencies.
Vite optimise warning appears if dependencies from the packages folder (redisinsight/ui/src/packages) have not been installed.
or you can exclude them in the ui vite.config.mjs

optimizeDeps: {
    exclude: [
      'react-json-tree',
      'redisinsight-plugin-sdk',
      'plotly.js-dist-min',
      '@antv/x6',
      '@antv/x6-react-shape',
      '@antv/hierarchy'
    ],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused, why shouldn't we add them as dependencies, if the warning is caused by them not being installed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They aren't used in the RedisInsight application.
They are a part of plugins (redisinsight/ui/src/packages). Each plugin is built separately from RedisInsight. Plugins dependencies are not used in the Redis Insight. Vite optimization doesn't see the difference and shows useless warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! THank you for the explanation. Cleared those as well.

@@ -0,0 +1,53 @@
import { defineConfig } from 'vite';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the corresponding package.json

entryFileNames: '[name].js',
}
},
target: 'node14',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node14?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most likely an artifact from testing. Removed

@KIvanow
Copy link
Contributor Author

KIvanow commented Oct 28, 2024

@zalenskiSofteq your feedback has been addressed, please take another look.

About the lining, there are multiple lint errors for API and UI from before this PR. When are those typically enforced? Should we set up the husky hooks for that?

@KIvanow KIvanow closed this Oct 28, 2024
@KIvanow KIvanow deleted the RI-5876-Fix-start-electron-dev-mode branch October 28, 2024 14:15
@egor-zalenski
Copy link
Contributor

@zalenskiSofteq your feedback has been addressed, please take another look.

About the lining, there are multiple lint errors for API and UI from before this PR. When are those typically enforced? Should we set up the husky hooks for that?

To set up husky we need to fix all the errors, it's gonna take time.
I have auto format after save a file, it fixes almost all the errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants