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

Next js prototype #3896

Merged
merged 147 commits into from
Dec 22, 2023
Merged

Next js prototype #3896

merged 147 commits into from
Dec 22, 2023

Conversation

VakarisZ
Copy link
Contributor

@VakarisZ VakarisZ commented Nov 28, 2023

What does this PR do?

Fixes #3793
Fixes #3794
Fixes #2898

PR adds next.js server and UI prototype using a feature flag.

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Do all unit tests pass?
  • Do all end-to-end tests pass?
  • Any other testing performed?

    Tested by running with/without feature flag set

  • If applicable, add screenshots or log transcripts of the feature working

Copy link

codecov bot commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7aee5a4) 78.01% compared to head (db2e4d2) 77.57%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3896      +/-   ##
===========================================
- Coverage    78.01%   77.57%   -0.44%     
===========================================
  Files          464      467       +3     
  Lines        14672    14759      +87     
===========================================
+ Hits         11447    11450       +3     
- Misses        3225     3309      +84     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

build_scripts/common.sh Outdated Show resolved Hide resolved
key={name}
data-emotion={`${registry.cache.key}-global ${name}`}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: style }}
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 temporary? We shouldn't use dangerouslySetInnerHTML because well, the name says it.

Copy link
Contributor Author

@VakarisZ VakarisZ Dec 15, 2023

Choose a reason for hiding this comment

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

@ordabach do you know where the styles are coming from?

@VakarisZ VakarisZ marked this pull request as draft December 6, 2023 11:54
@VakarisZ VakarisZ mentioned this pull request Dec 18, 2023
2 tasks
@VakarisZ VakarisZ marked this pull request as ready for review December 18, 2023 13:44
@VakarisZ VakarisZ force-pushed the next-js-prototype branch 2 times, most recently from 4fb8aa7 to f2a021b Compare December 19, 2023 15:30
Comment on lines 17 to 21
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we allow this?

Comment on lines +128 to +134
return null; // clear the session if the refresh token gets an error

// The error property will be used client-side to handle the refresh token error
// return {
// ...token,
// error: 'RefreshAccessTokenError' as const
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to do this later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole authentication needs a lot of work

);

const logoutResponseBody = await logoutResponse.json();
console.log('logoutResponseBody', logoutResponseBody);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can keep it, I'll have to review the authentication anyway and log statements are ignored in production builds

);

const registerResponseBody = await registerResponse.json();
console.log('registerResponseBody', registerResponseBody);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Comment on lines +2 to +3
// TODO remove with the NEXT_JS_UI_FEATURE in monkey_island/cc/feature_flags.py:1
return process.env.NEXT_PUBLIC_JAVASCRIPT_RUNTIME_PORT || 5000;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet, we'll do it once the old UI is removed

Copy link
Contributor

@cakekoa cakekoa left a comment

Choose a reason for hiding this comment

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

A few comments. I didn't review everything since I needed to learn about Redux and NextAuth

### Added
- Configurable Island port through node proxy server. #3827
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll need to devise a way to expose this port through docker. Either that or provide documentation on how to expose the configured port when running the container

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK --network=host already exposes the port.

Copy link
Contributor

@cakekoa cakekoa Dec 21, 2023

Choose a reason for hiding this comment

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

That may be correct. I tried to test out this feature in docker and couldn't access the UI. I realized that modifying the server port is only applicable to the old UI but I still couldn't get it to work. In fact, if I modify it, the UI is not available at the original port (5000) or the new one

@@ -235,7 +239,7 @@ pushd "$ISLAND_PATH/cc/ui" || handle_error
npm ci

log_message "Generating front end"
npm run dev
npm run build
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the current UI support a build target? We used to run dev or dist

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'm not sure what value the dev build had, but on the new UI we can build production or run a dev server with hot reloads. This builds production in case the dev is not intending to work on UI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me rephrase. This is generating the frontend for the old UI ("$ISLAND_PATH/cc/ui"). Does build work for it?

docs/content/_index.md Outdated Show resolved Hide resolved
...
}
```
1. Run the Monkey Island again, it will be accessible on `https://localhost:8080`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need to tell docker to expose the new port?

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 don't think so, but I haven't tested it IIRC

{{% notice info %}}
You need to have **root permissions** to run the Infection Monkey AppImage package.
By default, the Infection Monkey server is configured to listen on **port 443**,
which requires setting the `CAP_NET_BIND_SERVICE` capability on the AppImage package.
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 TMI? Should we just say that serving on port 443 requires root permission?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I was trying to say is that the process will not run as root, but root permissions are required. Feel free to rephrase or shorten

monkey/monkey_island/cc/next_ui/README.md Outdated Show resolved Hide resolved
VakarisZ and others added 25 commits December 22, 2023 16:05
The script is not necessary, because production is started by island anyway
Moving prettier config to a separate file makes more readable and allows other tools to find it
@VakarisZ VakarisZ merged commit 4fe4bed into develop Dec 22, 2023
2 of 3 checks passed
@VakarisZ VakarisZ deleted the next-js-prototype branch January 2, 2024 12:55
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.

Barebones UI prototype Deploy nextjs server ESlint support for typescript
5 participants