Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Liuliu/electron app #1

Merged
merged 31 commits into from
Sep 16, 2024
Merged

Liuliu/electron app #1

merged 31 commits into from
Sep 16, 2024

Conversation

liuliu-dev
Copy link
Collaborator

@liuliu-dev liuliu-dev commented Sep 13, 2024

To run in dev mode: run yarn dev in the root directory.

Changes:

  1. add package.json in root directory, put web and graphql-server in workspaces.

  2. In main:

  • background.ts starts the main process, creates the app window and loads the built files.
  • createGraphqlSeverProcess executes a child process to spawn the GraphQL server.
  • preload.ts establishes the IPC handler for communication between the renderer and the main process.
  1. In web:
  • Most changes happen in pages, commented getServerSideProps because server side rendering is not allowed.
  • In serverConfig.tsx, use ipc to get the api/config, since api route is not allowed in nextron build.
  1. In graphql-server:
    After the app is built, writing schema.gql file in the app is not allowed since the app is readonly. We will write the file to the user's application data folder specified by process.env.SCHEMA_PATH. This path is set in background.ts as follows: const schemaPath = path.join(userDataPath, "schema.gql");

Existing issues:
Distributing the built macOS application have an issue due to the "com.apple.Quarantine" attribute applied when the app is not downloaded from an Apple-sanctioned source. A temporary workaround involves disabling Gatekeeper for the app with the command:
xattr -c <path/to/application.app>

A more permanent solution requires getting an Apple Developer account, a Team ID for our developer team, and add this ID into the build configuration:

"notarize": {
        "teamId": "id"
      },

Copy link

@tbantle22 tbantle22 left a comment

Choose a reason for hiding this comment

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

Overall looks good. A few questions/clarifications

package.json Outdated
Comment on lines 17 to 18
"clean": "tsc -b --clean && yarn yalc:clean",
"compile": "tsc -b"

Choose a reason for hiding this comment

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

Should these use the clean and compile scripts from the workspaces instead? Like we do in ld/web

schema.gql Outdated
@@ -0,0 +1,376 @@
# ------------------------------------------------------

Choose a reason for hiding this comment

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

Doesn't seem like this file belongs here? Isn't this already in graphql-server?

Comment on lines 30 to 33
function useServerConfigIPC(): {
data: ServerConfigContextValue | undefined;
error: any;
} {

Choose a reason for hiding this comment

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

Can you move this return type to a declared type? Can also use the type for InnerProps since they share data and error

Comment on lines +75 to +79
return process.env.NEXT_PUBLIC_FOR_ELECTRON === "true" ? (
<IPCConfigProvider>{children}</IPCConfigProvider>
) : (
<APIConfigProvider>{children}</APIConfigProvider>
);

Choose a reason for hiding this comment

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

Could use a comment here for what this does/why

Comment on lines 13 to 23
const fetchHeaders = async () => {
const response = await fetch("/api/headers"); // This endpoint should return headers
const headersData = await response.json();
const user = headersData["x-forwarded-user"];
const email = headersData["x-forwarded-email"];
if (user || email) {
setHeaders({ user, email });
}
};

await fetchHeaders();

Choose a reason for hiding this comment

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

Was there a reason you changed this?

loader: 'webpack-preprocessor-loader',
options: {
params: {
isWeb: process.env.NEXT_PUBLIC_FOR_ELECTRON!=="true",

Choose a reason for hiding this comment

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

isWeb isn't the clearest name. Maybe isElectron and do #!if !isElectron in the pages?

Suggested change
isWeb: process.env.NEXT_PUBLIC_FOR_ELECTRON!=="true",
isElectron: process.env.NEXT_PUBLIC_FOR_ELECTRON === "true",

test: /\.tsx$/,
use: [
{
loader: 'webpack-preprocessor-loader',

Choose a reason for hiding this comment

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

This could also use a comment for its purpose

@@ -5,14 +5,14 @@ import { GetServerSideProps, NextPage } from "next";

type Params = RefParams & {
diffRange: string;
tableName?: string;

Choose a reason for hiding this comment

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

I wouldn't expect there to be any params/props changes in this PR? Where are all of these coming from?

module.exports = {
plugins: {
"tailwindcss/nesting": {},
tailwindcss: {},
tailwindcss: { ...tailwindConfig },

Choose a reason for hiding this comment

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

What does this do?

@@ -0,0 +1,24 @@
const { mergeConfig } = require("@dolthub/react-components");

Choose a reason for hiding this comment

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

Does this need to be .js?

}}
compare
/>
<DatabasePage.ForCommits params={params} compare />

Choose a reason for hiding this comment

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

tableName needs to be passed explicitly here

@@ -6,8 +6,8 @@ import { GetServerSideProps, NextPage } from "next";
type Props = {
params: TableParams & {
active?: string;
edit?: boolean;

Choose a reason for hiding this comment

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

edit needs to be explicitly passed to DatabasePage.ForTable now that it isn't a prop

@liuliu-dev liuliu-dev merged commit f88fd2f into main Sep 16, 2024
2 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/electron-app branch September 16, 2024 23:09
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