Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
* origin/main:
  Removes UI start from end of workflow (grails#17)
  New Option to Select Embedded Servlet
  • Loading branch information
virtualdogbert committed May 29, 2023
2 parents 0991db0 + d64bfa6 commit 22ea943
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 43 deletions.
1 change: 0 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ jobs:
run: |
cd ./app/launch/
npm test -- --watchAll=false
npm run start:local
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ npm run start:local

## Running a Grails Forge API locally to dev against

If you want to run against a version of the starter api (Micronaut Starter Api)[https://github.com/grails/grails-forge]
If you want to run against a version of the starter api (Grails Starter Api)[https://github.com/grails/grails-forge]

Outside of this project pull down that repo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const TestView = () => {
<>
<div className="type">{`${form.type}`}</div>
<div className="test">{`${form.test}`}</div>
<div className="build">{`${form.build}`}</div>
<div className="lang">{`${form.lang}`}</div>
<div className="servlet">{`${form.servlet}`}</div>
<div className="gorm">{`${form.gorm}`}</div>
<div className="javaVersion">{`${form.javaVersion}`}</div>
<div className="name">{`${form.name}`}</div>
<div className="package">{`${form.package}`}</div>
Expand Down Expand Up @@ -49,12 +49,12 @@ TEST_DATA.forEach(({ initialData }) => {
`${initialData.test || ''}`,
])

expect(testInstance.findByProps({ className: 'build' }).children).toEqual([
`${initialData.build || ''}`,
expect(testInstance.findByProps({ className: 'servlet' }).children).toEqual([
`${initialData.servlet || ''}`,
])

expect(testInstance.findByProps({ className: 'lang' }).children).toEqual([
`${initialData.lang || ''}`,
expect(testInstance.findByProps({ className: 'gorm' }).children).toEqual([
`${initialData.gorm || ''}`,
])

expect(
Expand Down
7 changes: 3 additions & 4 deletions app/launch/src/components/CodePreview/CodePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import CopyToClipboard from '../CopyToClipboard'
import TooltipButton, { TooltipWrapper } from '../TooltipButton'

const CodePreview = ({ theme = 'light', disabled, onLoad, onClose }, ref) => {
const { lang, build } = useStarterForm()
const { gorm, servlet } = useStarterForm()
const sharable = useSharableLink()

const [showing, setShowing] = useState(null)
Expand Down Expand Up @@ -194,10 +194,9 @@ const CodePreview = ({ theme = 'light', disabled, onLoad, onClose }, ref) => {
<Modal
open={open}
header={
'Previewing a ' +
capitalize(lang) +
'Previewing a Grails application using ' +
' application using ' +
capitalize(build)
capitalize(servlet) + ', ' + capitalize(gorm)
}
className={'preview ' + theme}
fixedFooter
Expand Down
8 changes: 3 additions & 5 deletions app/launch/src/components/Diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { capitalize } from '../utility'
import TooltipButton from './TooltipButton'

const Diff = ({ theme = 'light', disabled, onLoad, onClose }, ref) => {
const { lang, build } = useStarterForm()
const { gorm, servlet } = useStarterForm()

const [diff, setDiff] = useState(null)
useKeyboardShortcuts(DIFF_SHORTCUT.keys, onLoad, disabled)
Expand Down Expand Up @@ -67,10 +67,8 @@ const Diff = ({ theme = 'light', disabled, onLoad, onClose }, ref) => {

<Modal
header={
'Showing Diff for a ' +
capitalize(lang) +
' application using ' +
capitalize(build)
'Showing Diff for a Grails application using ' +
capitalize(gorm) + ', ' + capitalize(servlet)
}
className={'diff ' + theme}
fixedFooter
Expand Down
6 changes: 3 additions & 3 deletions app/launch/src/components/InfoButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ const InfoButton = ({ className = '', theme, style }) => {
>
<div className="info-contents">
<p>
Micronaut Launch is a web application that allows you to create
Micronaut projects through an interface instead of using the console
Grails Forge is a web application that allows you to create
Grails projects through an interface instead of using the console
CLI. You can set the application type, the project name, the
language (Java, Kotlin, Groovy), the build tool (Maven, Gradle), the
GORM implementation (Hibernate5, MongoDB, Neo4J), the embedded servlet (Tomcat, Jetty, Undertow, or None), the
Java version and the features you need to develop your software.
</p>
<div className="shortcut-legend">
Expand Down
4 changes: 2 additions & 2 deletions app/launch/src/components/Links/GitHubLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export const GitHubLink = ({ className, theme }) => {

return (
<a
href="https://github.com/micronaut-projects/micronaut-starter"
href="https://github.com/grails/grails-forge"
aria-label="Grails Application Forge Github Repo"
title="Micronaut Application Forge Github Repo"
title="Grails Application Forge Github Repo"
target="_blank"
rel="noopener noreferrer"
className={className}
Expand Down
2 changes: 1 addition & 1 deletion app/launch/src/components/OtherCommands/OtherCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function OtherCommands({ theme, trigger }) {
const actions = useMemo(() => {
if (!createCommand) return []
return [
{ link: createCommand.toCli(), title: 'Using the Micronaut CLI' },
{ link: createCommand.toCli(), title: 'Using the Grails CLI' },
{ link: createCommand.toCurl(), title: 'Using cURL' },
]
}, [createCommand])
Expand Down
4 changes: 2 additions & 2 deletions app/launch/src/components/StarterForm/StarterForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Col from 'react-materialize/lib/Col'
import Row from 'react-materialize/lib/Row'

import StarterFormApplicationType from './StarterFormApplicationType'
import StarterFormBuild from './StarterFormBuild'
import StarterFormGorm from "./StarterFormGorm";
import StarterFormJavaVersion from './StarterFormJavaVersion'
import StarterFormMicronautVersion from './StarterFormMicronautVersion'
import StarterFormName from './StarterFormName'
import StarterFormPackage from './StarterFormPackage'
import StarterFormServlet from './StarterFormServlet'
import StarterFormTestFramework from './StarterFormTestFramework'

const StarterForm = ({ onError }) => {
Expand All @@ -34,7 +34,7 @@ const StarterForm = ({ onError }) => {
<StarterFormGorm />
</Col>
<Col m={3} s={12} className="mn-radio">
<StarterFormBuild />
<StarterFormServlet />
</Col>
<Col m={3} s={12} className="mn-radio">
<StarterFormTestFramework />
Expand Down
32 changes: 32 additions & 0 deletions app/launch/src/components/StarterForm/StarterFormServlet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { NEXT_BUILD_SHORTCUT } from '../../constants/shortcuts'
import useKeyboardShortcuts from '../../hooks/useKeyboardShortcuts'
import { useServlet } from '../../state/store'
import RadioGroup from '../RadioGroup'
import { useOptHandler } from './useStarterFormKeyboardEvents'

export default function StarterFormServlet() {
const [value, setter, select] = useServlet()
const handleChange = (event) => setter(event.target.value)

const next = useOptHandler(
'servlet',
value,
select?.options ?? [],
handleChange
)
useKeyboardShortcuts(NEXT_BUILD_SHORTCUT.keys, next)

return (
<RadioGroup
tabIndex={1}
label="Embedded Servlet"
id="servlet"
name="servlet"
value={value}
onChange={handleChange}
options={select?.options ?? []}
loading={!select}
expected={3}
/>
)
}
9 changes: 8 additions & 1 deletion app/launch/src/constants/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
KEY_CODE_J,
KEY_CODE_L,
KEY_CODE_P,
KEY_CODE_S,
KEY_CODE_QUESTION,
KEY_CODE_SHIFT,
KEY_CODE_T,
Expand Down Expand Up @@ -40,7 +41,7 @@ export const GENERATE_SHORTCUT = {
}

export const NEXT_VERSION_SHORTCUT = {
label: 'Toggle to the Next Micronaut Version',
label: 'Toggle to the Next Grails Version',
textValue: SHIFT_TEXT + ' + V',
keys: [KEY_CODE_SHIFT, KEY_CODE_V],
}
Expand Down Expand Up @@ -75,6 +76,12 @@ export const NEXT_BUILD_SHORTCUT = {
keys: [KEY_CODE_SHIFT, KEY_CODE_B],
}

export const NEXT_SERVLET_SHORTCUT = {
label: 'Toggle to the Servlet Build',
textValue: SHIFT_TEXT + ' + S',
keys: [KEY_CODE_SHIFT, KEY_CODE_S],
}

export const NEXT_TEST_SHORTCUT = {
label: 'Toggle to the Next Test Framework',
textValue: SHIFT_TEXT + ' + T',
Expand Down
4 changes: 2 additions & 2 deletions app/launch/src/micronaut/CreateCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import ToUrl from './creators/ToUrl'

export class CreateCommand {
constructor(
{ type, javaVersion, build, gorm, test, name, package: _package, features },
{ type, javaVersion, servlet, gorm, test, name, package: _package, features },
baseUrl = ''
) {
this.type = type
this.javaVersion = javaVersion
this.name = name
this.gorm = gorm
this.build = build
this.servlet = servlet
this.test = test
this.package = _package
this.features = features
Expand Down
4 changes: 2 additions & 2 deletions app/launch/src/micronaut/FeatureCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import ToUrl from './creators/ToUrl'

export class FeatureCommand {
constructor(
{ javaVersion, build, gorm, test },
{ javaVersion, servlet, gorm, test },
featuresUrl = ''
) {
this.javaVersion = javaVersion
this.build = build
this.servlet = servlet
this.gorm = gorm
this.test = test
this.baseUrl = featuresUrl
Expand Down
6 changes: 3 additions & 3 deletions app/launch/src/micronaut/creators/ToCli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ function buildFeaturesArgs(features) {

export default class ToCli {
static make(createCommand) {
const { lang, build, test, javaVersion } = createCommand
const { gorm, servlet, test, javaVersion } = createCommand
const jdk = javaVersion ? javaVersion.replace('JDK_', '') : null
const command = deriveCommand(createCommand.type)
const applicationName = createCommand.applicationName()

const features = buildFeaturesArgs(createCommand.features)
const opts = { build, jdk, lang, test, features }
const opts = { servlet, jdk, gorm, test, features }
const args = Object.keys(opts).reduce((acc, key) => {
const value = opts[key]
if (value) {
Expand All @@ -31,6 +31,6 @@ export default class ToCli {
return acc
}, [])

return ['mn', command, ...args, applicationName].join(' ').toLowerCase()
return ['grails', command, ...args, applicationName].join(' ').toLowerCase()
}
}
8 changes: 4 additions & 4 deletions app/launch/src/micronaut/creators/ToUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export default class ToUrl {
static makeFeaturesUrl(featureCommand, baseUrl) {
const {
javaVersion,
build,
servlet,
gorm,
test,
} = featureCommand

const query = [
gorm && `gorm=${featureCommand.gorm}`,
build && `build=${featureCommand.build}`,
servlet && `servlet=${featureCommand.servlet}`,
test && `test=${featureCommand.test}`,
javaVersion && `javaVersion=${featureCommand.javaVersion}`,
].filter((i) => i)
Expand All @@ -36,7 +36,7 @@ export default class ToUrl {
const {
type,
gorm,
build,
servlet,
test,
javaVersion,
features,
Expand All @@ -48,7 +48,7 @@ export default class ToUrl {

const query = [
gorm && `gorm=${gorm}`,
build && `build=${build}`,
servlet && `servlet=${servlet}`,
test && `test=${test}`,
javaVersion && `javaVersion=${javaVersion}`,
].filter((i) => i)
Expand Down
6 changes: 3 additions & 3 deletions app/launch/src/state/factories/initializeState.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { StarterSDK } from './StarterSDK'
export const INITIAL_FORM_DATA_STORAGE_KEY = 'INITIAL_FORM_DATA'

const initialForm = (initialData) => {
const { javaVersion, lang, build, test, features } = initialData
const { javaVersion, gorm, servlet, test, features } = initialData
const parsed = {
javaVersion: typeof javaVersion === 'string' ? javaVersion : '', // This is specifically "" to work with the SelectOption component
lang: typeof lang === 'string' ? lang : '',
build: typeof build === 'string' ? build : '',
servlet: typeof servlet === 'string' ? servlet : '',
gorm: typeof gorm === 'string' ? gorm : '',
test: typeof test === 'string' ? test : '',
features: StarterSDK.reconstructFeatures(features),
[ACTIVITY_KEY]: initialData[ACTIVITY_KEY],
Expand Down
18 changes: 15 additions & 3 deletions app/launch/src/state/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export const buildState = atom({
default: defaultValueSelectorFactory('build'),
})

export const servletState = atom({
key: 'SERVLET_STATE',
default: defaultValueSelectorFactory('servlet'),
})

export const gormState = atom({
key: 'GORM_STATE',
default: defaultValueSelectorFactory('gorm'),
Expand Down Expand Up @@ -172,7 +177,7 @@ export const starterFormState = selector({
const type = get(appTypeState)
const name = get(nameState)
const pkg = get(packageState)
const build = get(buildState)
const servlet = get(servletState)
const gorm = get(gormState)
const test = get(testState)
const javaVersion = get(javaVersionState)
Expand All @@ -187,7 +192,7 @@ export const starterFormState = selector({
package: pkg,
javaVersion,
gorm,
build,
servlet,
test,
features,
})
Expand Down Expand Up @@ -392,6 +397,13 @@ export const useBuild = () => {
return [value, setter, select]
}

export const useServlet = () => {
const [value, setter] = useRecoilState(servletState)
const select = useSelectOptionsForType('servlet')
useDerivedDefultsEffect(select, setter)
return [value, setter, select]
}

export const useGorm = () => {
const [value, setter] = useRecoilState(gormState)
const select = useSelectOptionsForType('gorm')
Expand Down Expand Up @@ -431,7 +443,7 @@ export const useResetStarterForm = () => {
set(packageState, resets.package)

set(appTypeState, options.type.defaultOption.value)
set(buildState, options.build.defaultOption.value)
set(servletState, options.servlet.defaultOption.value)
set(gormState, options.gorm.defaultOption.value)
set(testState, options.test.defaultOption.value)
set(javaVersionState, options.jdkVersion.defaultOption.value)
Expand Down

0 comments on commit 22ea943

Please # to comment.