Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/launch/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import js from '@eslint/js'
import globals from 'globals'
import reactPlugin from 'eslint-plugin-react'
import importPlugin from 'eslint-plugin-import'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import reactPlugin from 'eslint-plugin-react'

export default [
js.configs.recommended,
{
files: ['**/*.{js,jsx}'],
plugins: {
react: reactPlugin,
import: importPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
},
languageOptions: {
ecmaVersion: 'latest',
Expand All @@ -30,9 +32,11 @@ export default [
...reactPlugin.configs.recommended.rules,
// React 17+ automatic JSX transform does not require React in scope
'react/react-in-jsx-scope': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
// Project does not use PropTypes
'react/prop-types': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
'no-case-declarations': 'warn',
'import/order': [
'error',
Expand Down
105 changes: 87 additions & 18 deletions app/launch/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions app/launch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "app",
"version": "0.1.1",
"private": true,
"type": "module",
"homepage": ".",
"dependencies": {
"@emotion/react": "^11.14.0",
Expand All @@ -22,8 +23,10 @@
"@testing-library/react": "^16.3.2",
"@vitejs/plugin-react": "^6.0.1",
"baseline-browser-mapping": "^2.10.0",
"cross-env": "^10.1.0",
"eslint": "^9.39.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react": "^7.37.5",
"globals": "^17.6.0",
"jsdom": "^29.1.1",
Expand All @@ -34,12 +37,12 @@
},
"scripts": {
"start": "vite",
"start:local": "VITE_VERSION_FEED='http://localhost:8088' vite",
"start:local": "cross-env VITE_VERSION_FEED=http://localhost:8088/grails-version-feed.json vite",
"build": "vite build",
"preview": "vite preview",
"format": "prettier --write \"**/*.+(js|jsx|json|css|md)\"",
"lint": "eslint './src/**/*.{js,jsx}'",
"lint:fix": "eslint './src/**/*.{js,jsx}' --fix",
"lint": "eslint \"./src/**/*.{js,jsx}\"",
"lint:fix": "eslint \"./src/**/*.{js,jsx}\" --fix",
"test": "vitest run"
},
"browserslist": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import { render } from '@testing-library/react'
import { useAppStore } from '../../../state/store'
import ApplicationState from '../../../state/ApplicationState'
import { useAppStore } from '../../../state/store'

import { App } from '../App'

Expand All @@ -15,5 +15,7 @@ it(`Application Launches`, () => {
<App />
</ApplicationState>
)
expect(container).toBeDefined()

expect(container.querySelector('.mn-starter-form-main')).not.toBeNull()
expect(container.querySelector('.button-row')).not.toBeNull()
})
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const MockSdk = {
}
return types
},
defaultIncludedFeatures: async ({ type }) => {
const types = MockTypes[type]
if (!types) {
throw new Error('Invalid Type')
}
return { features: [] }
},
}

beforeEach(() => {
Expand Down Expand Up @@ -80,11 +87,16 @@ TEST_DATA.forEach(({ initialData, hasError }) => {
await new Promise((r) => setTimeout(r, 50))
})

expect(container).toBeDefined()
if (hasError) {
expect(error).not.toBeNull()
expect(container.querySelector('.reloading').textContent).toEqual('[]')
} else {
expect(error).toBeNull()
expect(JSON.parse(container.querySelector('.reloading').textContent)).toEqual([
'a',
'b',
'c',
])
}
})
})
3 changes: 1 addition & 2 deletions app/launch/src/components/ErrorView/ErrorView.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// ErrorView.js
import React, { useState } from 'react'
import { Avatar, Snackbar, Alert } from '@mui/material'

import AssignmentIcon from '@mui/icons-material/Assignment'
import AssignmentTurnedInIcon from '@mui/icons-material/AssignmentTurnedIn'
import { Alert, Avatar, Snackbar } from '@mui/material'

import logo from '../../images/grails-white-icon.png'
import { copyToClipboard } from '../../utility'
Expand Down
6 changes: 3 additions & 3 deletions app/launch/src/components/FeatureSelector/FeatureSelector.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// FeatureSelector.js
import React, { useCallback, useMemo, useRef, useState } from 'react'
import React, { useMemo, useRef, useState } from 'react'

import {
Button,
Expand Down Expand Up @@ -118,8 +118,8 @@ export const FeatureSelectorModal = ({ theme = 'light' }) => {
}, 300)
}

const handleKeyDown = useCallback(
keyboardHandler.createKeyDownHandler(() => contentRef.current),
const handleKeyDown = useMemo(
() => keyboardHandler.createKeyDownHandler(() => contentRef.current),
[]
)

Expand Down
13 changes: 8 additions & 5 deletions app/launch/src/components/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ const Select = ({
onChange,
tabIndex = '0',
}) => {
const controlId = id ?? name

return (
<div className="MuiFormControlOverrides select-wrapper input-field col">
<FormControl>
<InputLabel id={id}>{label}</InputLabel>
<FormControl variant="standard">
<InputLabel id={`${controlId}-select-label`}>{label}</InputLabel>
<SelectProxy
name={name}
labelId={`${id}-select-label`}
id={`${id}-select`}
value={value}
labelId={`${controlId}-select-label`}
id={`${controlId}-select`}
value={value ?? ''}
onChange={onChange}
tabIndex={tabIndex}
variant="standard"
>
{options.map((opt, idx) => (
<MenuItem key={`select-${opt.value}-${idx}`} value={opt.value}>
Expand Down
2 changes: 2 additions & 0 deletions app/launch/src/components/StarterForm/starter-form.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

.mn-starter-form-main .mn-radio-row {
margin-top: 20px;
padding-bottom: 4px;
padding-top: 4px;
}

.mn-starter-form-main .mn-radio .radio-row {
Expand Down
21 changes: 14 additions & 7 deletions app/launch/src/state/ApplicationState.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { useEffect } from 'react'
import { useAppStore } from './store'
import { useLayoutEffect, useRef, useState } from 'react'
import { initializeStateFactory } from './factories/initializeState'
import { useAppStore } from './store'

export default function ApplicationState({
initialData,
initialData = {},
stateInitializer,
children,
}) {
useEffect(() => {
const initialized = useRef(false)
const [ready, setReady] = useState(false)

useLayoutEffect(() => {
if (initialized.current) return

initialized.current = true
const initializer = typeof stateInitializer === 'function'
Comment thread
jamesfredley marked this conversation as resolved.
? stateInitializer
: initializeStateFactory(initialData)

// Apply initial state to the store
if (typeof initializer === 'function') {
initializer(useAppStore)
}
}, []) // eslint-disable-line react-hooks/exhaustive-deps

return <>{children}</>
setReady(true)
}, [initialData, stateInitializer])

return ready ? <>{children}</> : null
}
Loading
Loading