Skip to content

Commit 50f49dd

Browse files
Initial React frontend styling implementation
1 parent 466804d commit 50f49dd

74 files changed

Lines changed: 40283 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

react-frontend/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SKIP_PREFLIGHT_CHECK=true
2+
DISABLE_ESLINT_PLUGIN=true

react-frontend/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build stage
2+
FROM node:16-alpine as build
3+
4+
WORKDIR /app
5+
6+
# Copy package.json and package-lock.json
7+
COPY package*.json ./
8+
9+
# Install dependencies
10+
RUN npm ci
11+
12+
# Copy the rest of the code
13+
COPY . .
14+
15+
# Build the app
16+
RUN npm run build
17+
18+
# Production stage
19+
FROM nginx:alpine
20+
21+
# Copy the build output to replace the default nginx contents
22+
COPY --from=build /app/build /usr/share/nginx/html
23+
24+
# Copy custom nginx config if needed
25+
# COPY nginx.conf /etc/nginx/conf.d/default.conf
26+
27+
# Expose port 80
28+
EXPOSE 80
29+
30+
# Start nginx
31+
CMD ["nginx", "-g", "daemon off;"]

react-frontend/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Sysdig Inspect React Frontend
2+
3+
This is a React.js port of the original Ember.js frontend for Sysdig Inspect. It maintains the same visual appearance and functionality while using modern React.js and Redux for state management.
4+
5+
## Project Structure
6+
7+
- `src/components`: Reusable UI components
8+
- `src/pages`: Page components that correspond to routes
9+
- `src/store`: Redux store configuration and slices
10+
- `src/services`: API and utility services
11+
- `src/styles`: LESS stylesheets
12+
- `public`: Static assets
13+
14+
## Getting Started
15+
16+
### Prerequisites
17+
18+
- Node.js 16 or higher
19+
- npm 7 or higher
20+
21+
### Installation
22+
23+
```bash
24+
cd react-frontend
25+
npm install
26+
```
27+
28+
If you encounter TypeScript version conflicts during installation, the project has been configured to use TypeScript 4.9.5 which is compatible with Create React App. The configuration includes:
29+
30+
- Using react-app-rewired and customize-cra for LESS support
31+
- Setting up proper TypeScript configuration
32+
- Adding type declarations for LESS files
33+
34+
If you still encounter issues, try removing the node_modules directory and package-lock.json file before reinstalling:
35+
36+
```bash
37+
rm -rf node_modules package-lock.json
38+
npm install
39+
```
40+
41+
### Development
42+
43+
To start the development server:
44+
45+
```bash
46+
npm start
47+
```
48+
49+
This will start the React development server on port 3001, which proxies API requests to the backend server running on port 3000.
50+
51+
### Building for Production
52+
53+
To build the application for production:
54+
55+
```bash
56+
npm run build
57+
```
58+
59+
This creates a `build` directory with the compiled application.
60+
61+
## Docker
62+
63+
To build and run the React frontend in a Docker container:
64+
65+
```bash
66+
# Build the Docker image
67+
docker build -t sysdig-inspect-react .
68+
69+
# Run the container
70+
docker run -p 80:80 sysdig-inspect-react
71+
```
72+
73+
## Integration with Electron
74+
75+
The React frontend is designed to work with the existing Electron application. The Electron main process and backend server remain unchanged, while the frontend is replaced with this React implementation.
76+
77+
## License
78+
79+
This project is licensed under the GNU General Public License - see the LICENSE file for details.

react-frontend/config-overrides.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { addLessLoader } = require('customize-cra');
2+
3+
// Custom function to fix PostCSS loader issues
4+
const fixPostcssLoaderConfig = (config) => {
5+
const oneOfRules = config.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf;
6+
7+
// Find all rules that use postcss-loader
8+
oneOfRules.forEach(rule => {
9+
if (rule.use && Array.isArray(rule.use)) {
10+
rule.use.forEach(loader => {
11+
if (loader.loader && loader.loader.includes('postcss-loader') && loader.options) {
12+
// Fix the options to match the new API
13+
const options = { ...loader.options };
14+
delete options.ident;
15+
delete options.plugins;
16+
17+
// Set the new options
18+
loader.options = {
19+
postcssOptions: {
20+
plugins: [
21+
require.resolve('postcss-flexbugs-fixes'),
22+
[
23+
require.resolve('postcss-preset-env'),
24+
{
25+
autoprefixer: {
26+
flexbox: 'no-2009',
27+
},
28+
stage: 3,
29+
},
30+
],
31+
require.resolve('postcss-normalize'),
32+
],
33+
},
34+
sourceMap: options.sourceMap,
35+
};
36+
}
37+
});
38+
}
39+
});
40+
41+
return config;
42+
};
43+
44+
module.exports = function override(config, env) {
45+
// Add LESS loader
46+
config = addLessLoader({
47+
lessOptions: {
48+
javascriptEnabled: true,
49+
modifyVars: {
50+
// You can add any LESS variables here if needed
51+
}
52+
}
53+
})(config, env);
54+
55+
// Fix PostCSS loader config
56+
config = fixPostcssLoaderConfig(config);
57+
58+
return config;
59+
};

react-frontend/craco.config.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const lessRegex = /\.less$/;
2+
const lessModuleRegex = /\.module\.less$/;
3+
4+
module.exports = {
5+
webpack: {
6+
configure: (webpackConfig) => {
7+
// Find the style rules
8+
const oneOfRules = webpackConfig.module.rules.find(rule => Array.isArray(rule.oneOf)).oneOf;
9+
10+
// Add LESS support
11+
const lessRule = {
12+
test: lessRegex,
13+
exclude: lessModuleRegex,
14+
use: [
15+
// The first two loaders are the same as for CSS
16+
...oneOfRules.find(rule => rule.test && rule.test.toString().includes('css') && !rule.test.toString().includes('module')).use,
17+
{
18+
loader: require.resolve('less-loader'),
19+
options: {
20+
lessOptions: {
21+
javascriptEnabled: true,
22+
},
23+
},
24+
},
25+
],
26+
sideEffects: true,
27+
};
28+
29+
// Add LESS modules support
30+
const lessModuleRule = {
31+
test: lessModuleRegex,
32+
use: [
33+
// The first loaders are the same as for CSS modules
34+
...oneOfRules.find(rule => rule.test && rule.test.toString().includes('module')).use,
35+
{
36+
loader: require.resolve('less-loader'),
37+
options: {
38+
lessOptions: {
39+
javascriptEnabled: true,
40+
},
41+
},
42+
},
43+
],
44+
};
45+
46+
// Insert the LESS rules before the file-loader rule
47+
const fileLoaderIndex = oneOfRules.findIndex(rule => rule.type === 'asset/resource');
48+
oneOfRules.splice(fileLoaderIndex, 0, lessRule, lessModuleRule);
49+
50+
// Fix PostCSS loader issues
51+
oneOfRules.forEach(rule => {
52+
if (rule.use && Array.isArray(rule.use)) {
53+
rule.use.forEach(loader => {
54+
if (loader.loader && loader.loader.includes('postcss-loader') && loader.options) {
55+
// Fix the options to match the new API
56+
if (loader.options.ident) {
57+
delete loader.options.ident;
58+
}
59+
60+
if (loader.options.plugins) {
61+
loader.options.postcssOptions = {
62+
plugins: loader.options.plugins
63+
};
64+
delete loader.options.plugins;
65+
}
66+
}
67+
});
68+
}
69+
});
70+
71+
return webpackConfig;
72+
}
73+
}
74+
};

0 commit comments

Comments
 (0)