Skip to content

Commit

Permalink
feat: adding index stuff
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Sonis <[email protected]>
  • Loading branch information
tonysnowboardunderthebridge committed Dec 3, 2023
1 parent 3e01dee commit 75fe573
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/main/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import icon from '../../resources/icon.png?asset'
import setupMenu from './menu.mjs'
import { getTemplates, getPlugins } from './client.mjs'
import { prepareFolder, createApp } from './generate.mjs'
const generate = require('boring-name-generator')

// eslint-disable-next-line no-unused-vars
const isMac = process.platform === 'darwin'
Expand Down Expand Up @@ -116,6 +117,11 @@ app.whenReady().then(() => {
ipcMain.handle('quit-app', () => {
app.quit()
})

ipcMain.handle('generate-name', async () => {
const val = await generate({ words: 1 }).dashed
return val
})
})

// Quit when all windows are closed, except on macOS. There, it's common
Expand Down
3 changes: 2 additions & 1 deletion src/preload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ if (process.contextIsolated) {
prepareFolder: (folder, templates, appName) => (ipcRenderer.invoke('prepare-folder', folder, templates, appName)),
onLog: callback => ipcRenderer.on('log', callback),
createApp: (folder, project) => (ipcRenderer.invoke('create-app', folder, project)),
quitApp: () => (ipcRenderer.invoke('quit-app'))
quitApp: () => (ipcRenderer.invoke('quit-app')),
getServiceName: () => (ipcRenderer.invoke('generate-name'))
})
} catch (error) {
console.error(error)
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/src/components/steps/CreateApplication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CreateApplication = React.forwardRef(({ onNext }, ref) => {
}
}, [formData])

function handleSubmit (event) {
async function handleSubmit (event) {
event.preventDefault()
addFormData({
createApplication: {
Expand All @@ -37,7 +37,8 @@ const CreateApplication = React.forwardRef(({ onNext }, ref) => {
}
})
if (callAddService) {
addService()
const serviceName = await window.api.getServiceName()
addService(serviceName)
}
onNext()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ const ComposeApplication = React.forwardRef(({ onNext, onBack }, ref) => {
setShowModalViewAll(false)
}

async function onClickAddService () {
const serviceName = await window.api.getServiceName()
addService(serviceName)
}

function handleEditApplicationName (newName) {
addFormData({
createApplication: {
Expand Down Expand Up @@ -181,7 +186,7 @@ const ComposeApplication = React.forwardRef(({ onNext, onBack }, ref) => {
<h5 className={`${typographyStyles.desktopHeadline5} ${typographyStyles.textWhite}`}>&nbsp;</h5>
</div>
<AddService
onClick={() => addService()}
onClick={() => onClickAddService()}
enabled={services.find(service => Object.keys(service.template).length === 0) === undefined || currentView === GRID_VIEW}
/>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/src/useStackablesStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { create } from 'zustand'
import { generateName } from '../../main/client.mjs'

const useStackablesStore = create((set, get) => ({
formData: {},
Expand All @@ -10,12 +9,12 @@ const useStackablesStore = create((set, get) => ({
formData: { ...get().formData, ...newValue }
}
}),
addService: () => set((state) => {
addService: (serviceName) => set((state) => {
const currentServices = get().services
return {
...state,
services: [...currentServices, {
name: generateName({ words: 1 }),
name: serviceName,
template: {},
plugins: []
}]
Expand Down

0 comments on commit 75fe573

Please sign in to comment.