Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

7532 project info split #7596

Merged
merged 1 commit into from
Feb 16, 2023
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
5 changes: 4 additions & 1 deletion packages/client-core/i18n/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@
"day": "day",
"commitSHACopied": "Commit SHA copied",
"buildStatus": "Build Status",
"defaultProjectUpdateTooltip": "default-project is updated when engine is updated"
"defaultProjectUpdateTooltip": "default-project is updated when engine is updated",
"refreshGithubRepoAccess": "Refresh GitHub Repo Access",
"refreshingGithubRepoAccess": "Refreshing"
},
"instance": {
"confirmInstanceDelete": "Do you want to delete instance",
Expand Down Expand Up @@ -321,6 +323,7 @@
"googleAnalyticsTrackingId": "Google Analytics Tracking ID",
"certPath": "CertPath",
"keyPath": "KeyPath",
"githubWebhookSecret": "Github Webhook Secret",
"githubPrivateKey": "Github Private Key",
"instanceserverUnreachableTimeoutSeconds": "Seconds for instanceserver to be considered unreachable",
"project": "Project",
Expand Down
62 changes: 40 additions & 22 deletions packages/client-core/src/admin/components/Project/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'

import { Engine } from '@xrengine/engine/src/ecs/classes/Engine'
import { initSystems } from '@xrengine/engine/src/ecs/functions/SystemFunctions'
import { useHookstate } from '@xrengine/hyperflux'

import { Box, CircularProgress } from '@mui/material'
import Button from '@mui/material/Button'
Expand All @@ -23,21 +24,15 @@ const Projects = () => {
const adminProjectState = useProjectState()
const builderTags = adminProjectState.builderTags.value
const { t } = useTranslation()
const [projectDrawerOpen, setProjectDrawerOpen] = useState(false)
const [updateDrawerOpen, setUpdateDrawerOpen] = useState(false)
const [buildStatusDrawerOpen, setBuildStatusDrawerOpen] = useState(false)
const [isFirstRun, setIsFirstRun] = useState(true)
const githubProvider = user.identityProviders.value?.find((ip) => ip.type === 'github')

const handleOpenProjectDrawer = () => {
setProjectDrawerOpen(true)
}

const handleOpenUpdateDrawer = () => {
setUpdateDrawerOpen(true)
}
const projectDrawerOpen = useHookstate(false)
const updateDrawerOpen = useHookstate(false)
const buildStatusDrawerOpen = useHookstate(false)
const isFirstRun = useHookstate(true)

const handleOpenBuildStatusDrawer = () => {
setBuildStatusDrawerOpen(true)
const refreshGithubRepoAccess = () => {
ProjectService.refreshGithubRepoAccess()
}

const ProjectUpdateSystemInjection = {
Expand All @@ -61,7 +56,7 @@ const Projects = () => {
useEffect(() => {
let interval

setIsFirstRun(false)
isFirstRun.set(false)

if (adminProjectState.rebuilding.value) {
interval = setInterval(ProjectService.checkReloadStatus, 10000)
Expand All @@ -82,7 +77,7 @@ const Projects = () => {
type="button"
variant="contained"
color="primary"
onClick={handleOpenProjectDrawer}
onClick={() => projectDrawerOpen.set(true)}
>
{t('admin:components.project.addProject')}
</Button>
Expand All @@ -93,12 +88,12 @@ const Projects = () => {
type="button"
variant="contained"
color="primary"
onClick={() => handleOpenUpdateDrawer()}
onClick={() => updateDrawerOpen.set(true)}
>
{adminProjectState.rebuilding.value ? (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<CircularProgress color="inherit" size={24} sx={{ marginRight: 1 }} />
{isFirstRun ? t('admin:components.project.checking') : t('admin:components.project.rebuilding')}
{isFirstRun.value ? t('admin:components.project.checking') : t('admin:components.project.rebuilding')}
</Box>
) : (
t('admin:components.project.updateAndRebuild')
Expand All @@ -111,7 +106,7 @@ const Projects = () => {
type="button"
variant="contained"
color="primary"
onClick={() => handleOpenBuildStatusDrawer()}
onClick={() => buildStatusDrawerOpen.set(true)}
>
{t('admin:components.project.buildStatus')}
</Button>
Expand All @@ -121,15 +116,38 @@ const Projects = () => {
<div className={styles.engineInfo}>
<Chip label={`Current Engine Version: ${adminProjectState.builderInfo.engineVersion.value}`} />
<Chip label={`Current Engine Commit: ${adminProjectState.builderInfo.engineCommit.value}`} />
{githubProvider != null && (
<Button
className={styles.refreshGHBtn}
type="button"
variant="contained"
color="primary"
disabled={adminProjectState.refreshingGithubRepoAccess.value}
onClick={() => refreshGithubRepoAccess()}
>
{adminProjectState.refreshingGithubRepoAccess.value ? (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<CircularProgress color="inherit" size={24} sx={{ marginRight: 1 }} />
{t('admin:components.project.refreshingGithubRepoAccess')}
</Box>
) : (
t('admin:components.project.refreshGithubRepoAccess')
)}
</Button>
)}
</div>

<ProjectTable className={styles.rootTableWithSearch} />

<UpdateDrawer open={updateDrawerOpen} builderTags={builderTags} onClose={() => setUpdateDrawerOpen(false)} />
<UpdateDrawer
open={updateDrawerOpen.value}
builderTags={builderTags}
onClose={() => updateDrawerOpen.set(false)}
/>

<ProjectDrawer open={projectDrawerOpen} onClose={() => setProjectDrawerOpen(false)} />
<ProjectDrawer open={projectDrawerOpen.value} onClose={() => projectDrawerOpen.set(false)} />

<BuildStatusDrawer open={buildStatusDrawerOpen} onClose={() => setBuildStatusDrawerOpen(false)} />
<BuildStatusDrawer open={buildStatusDrawerOpen.value} onClose={() => buildStatusDrawerOpen.set(false)} />
</div>
)
}
Expand Down
41 changes: 20 additions & 21 deletions packages/client-core/src/admin/components/Setting/Server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'

import InputSwitch from '@xrengine/client-core/src/common/components/InputSwitch'
import InputText from '@xrengine/client-core/src/common/components/InputText'
import { useHookstate } from '@xrengine/hyperflux'

import { Box, Button, Grid, Typography } from '@mui/material'

Expand All @@ -20,36 +21,34 @@ const Server = () => {
const [serverSetting] = serverSettingState?.server?.value || []
const id = serverSetting?.id

const [gaTrackingId, setGaTrackingId] = useState(serverSetting?.gaTrackingId)
const [gitPem, setGitPem] = useState(serverSetting?.gitPem)
const [instanceserverUnreachableTimeoutSeconds, setInstanceserverUnreachableTimeoutSeconds] = useState(
serverSetting?.instanceserverUnreachableTimeoutSeconds
)
const gaTrackingId = useHookstate(serverSetting?.gaTrackingId)
const githubWebhookSecret = useHookstate(serverSetting?.githubWebhookSecret)
const instanceserverUnreachableTimeoutSeconds = useHookstate(serverSetting?.instanceserverUnreachableTimeoutSeconds)
const [dryRun, setDryRun] = useState(true)
const [local, setLocal] = useState(true)

useEffect(() => {
if (serverSetting) {
setGaTrackingId(serverSetting?.gaTrackingId)
setGitPem(serverSetting?.gitPem)
setInstanceserverUnreachableTimeoutSeconds(serverSetting?.instanceserverUnreachableTimeoutSeconds)
gaTrackingId.set(serverSetting?.gaTrackingId)
githubWebhookSecret.set(serverSetting?.githubWebhookSecret)
instanceserverUnreachableTimeoutSeconds.set(serverSetting?.instanceserverUnreachableTimeoutSeconds)
}
}, [serverSettingState?.updateNeeded?.value])

const handleSubmit = (event) => {
ServerSettingService.patchServerSetting(
{
gaTrackingId: gaTrackingId,
gitPem: gitPem,
instanceserverUnreachableTimeoutSeconds: instanceserverUnreachableTimeoutSeconds
gaTrackingId: gaTrackingId.value,
githubWebhookSecret: githubWebhookSecret.value,
instanceserverUnreachableTimeoutSeconds: instanceserverUnreachableTimeoutSeconds.value
},
id
)
}

const handleCancel = () => {
setGaTrackingId(serverSetting?.gaTrackingId)
setGitPem(serverSetting?.gitPem)
gaTrackingId.set(serverSetting?.gaTrackingId)
githubWebhookSecret.set(serverSetting?.githubWebhookSecret)
}

useEffect(() => {
Expand Down Expand Up @@ -140,9 +139,9 @@ const Server = () => {
<InputText
name="gaTrackingId"
label={t('admin:components.setting.googleAnalyticsTrackingId')}
value={gaTrackingId || ''}
value={gaTrackingId.value || ''}
startAdornment={<Icon style={{ marginRight: 8 }} fontSize={18} icon="emojione:key" />}
onChange={(e) => setGaTrackingId(e.target.value)}
onChange={(e) => gaTrackingId.set(e.target.value)}
/>

<InputText
Expand Down Expand Up @@ -178,10 +177,10 @@ const Server = () => {
/>

<InputText
name="githubPrivateKey"
label={t('admin:components.setting.githubPrivateKey')}
value={gitPem || ''}
onChange={(e) => setGitPem(e.target.value)}
name="githubWebhookSecret"
label={t('admin:components.setting.githubWebhookSecret')}
value={githubWebhookSecret.value || ''}
onChange={(e) => githubWebhookSecret.set(e.target.value)}
/>

<InputText
Expand All @@ -194,8 +193,8 @@ const Server = () => {
<InputText
name="releaseName"
label={t('admin:components.setting.instanceserverUnreachableTimeoutSeconds')}
value={instanceserverUnreachableTimeoutSeconds}
onChange={(e) => setInstanceserverUnreachableTimeoutSeconds(e.target.value)}
value={instanceserverUnreachableTimeoutSeconds.value}
onChange={(e) => instanceserverUnreachableTimeoutSeconds.set(e.target.value)}
/>

<InputSwitch
Expand Down
8 changes: 8 additions & 0 deletions packages/client-core/src/admin/styles/admin.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
}
}

.refreshGHBtn {
margin-top: 0;
margin-bottom: 0;
font-size: 12px;
background-color: var(--popupBackground) !important;
color: var(--textColor) !important;
}

.dateTimePickerDialog {
background: var(--popupBackground);
color: var(--textColor) !important;
Expand Down
23 changes: 22 additions & 1 deletion packages/client-core/src/common/services/ProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const ProjectState = defineState({
builderInfo: {
engineVersion: '',
engineCommit: ''
}
},
refreshingGithubRepoAccess: false
})
})

Expand All @@ -51,6 +52,9 @@ export const ProjectServiceReceptor = (action) => {
.when(ProjectAction.builderInfoFetched.matches, (action) => {
return s.merge({ builderInfo: action.builderInfo })
})
.when(ProjectAction.setGithubRepoAccessRefreshing.matches, (action) => {
return s.merge({ refreshingGithubRepoAccess: action.refreshing })
})
}

export const accessProjectState = () => getState(ProjectState)
Expand Down Expand Up @@ -299,6 +303,18 @@ export const ProjectService = {
logger.error('Error with getting engine info', err)
throw err
}
},

refreshGithubRepoAccess: async () => {
try {
dispatchAction(ProjectAction.setGithubRepoAccessRefreshing({ refreshing: true }))
await API.instance.client.service('github-repo-access-refresh').find()
dispatchAction(ProjectAction.setGithubRepoAccessRefreshing({ refreshing: false }))
await ProjectService.fetchProjects()
} catch (err) {
logger.error('Error with refreshing Github repo access', err)
throw err
}
}
}

Expand Down Expand Up @@ -337,6 +353,11 @@ export class ProjectAction {
builderInfo: matches.object as Validator<unknown, BuilderInfo>
})

static setGithubRepoAccessRefreshing = defineAction({
type: 'xre.client.project.SET_ACCESS_REFRESHING' as const,
refreshing: matches.boolean
})

// TODO #7254
// buildProgress: (message: string) => {
// return {
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/dbmodels/GithubRepoAccess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface GithubRepoAccessInterface {
id: string
repo: string
identityProviderId: string
}
1 change: 1 addition & 0 deletions packages/common/src/dbmodels/ServerSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export interface ServerSettingInterface {
local: boolean
releaseName: string
instanceserverUnreachableTimeoutSeconds: number
githubWebhookSecret: string
}
11 changes: 11 additions & 0 deletions packages/common/src/interfaces/GithubRepoAccess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface GithubRepoAccess {
id: string
repo: string
identityProviderId: string
}

export const GithubRepoAccess: GithubRepoAccess = {
id: '',
repo: '',
identityProviderId: ''
}
3 changes: 2 additions & 1 deletion packages/common/src/interfaces/ServerSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface ServerSetting {
local?: boolean
releaseName?: string
instanceserverUnreachableTimeoutSeconds?: number
githubWebhookSecret?: string
}

export interface HubInfo {
Expand All @@ -28,6 +29,6 @@ export interface HubInfo {

export interface PatchServerSetting {
gaTrackingId?: string
gitPem?: string
githubWebhookSecret?: string
instanceserverUnreachableTimeoutSeconds?: number
}
Loading