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

Commit

Permalink
Merge branch 'dev' into project-orgnames
Browse files Browse the repository at this point in the history
  • Loading branch information
HexaField authored Aug 16, 2024
2 parents 5ff3b69 + 64f7afd commit f80c26e
Show file tree
Hide file tree
Showing 29 changed files with 1,192 additions and 825 deletions.
1 change: 1 addition & 0 deletions packages/client-core/i18n/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
"subtitle": "Edit Metabase Settings",
"siteUrl": "Site Url",
"secretKey": "Secret Key",
"environment": "Environment",
"expiration": "Expiration",
"crashDashboardId": "Crash Dashboard Id"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/client-core/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"unknownStatus": "Unknown Status",
"CORS": "Possibly a CORS error",
"urlFetchError": "Failed to fetch \"{{url}}\"",
"invalidSceneName": "Scene name must be 4-64 characters long, using only alphanumeric characters, hyphens, and underscores."
"invalidSceneName": "Scene name must be 4-64 characters long, using only alphanumeric characters and hyphens, and begin and end with an alphanumeric."
},
"viewport": {
"title": "Viewport",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
const id = useHookstate<string | undefined>(undefined)
const siteUrl = useHookstate('')
const secretKey = useHookstate('')
const environment = useHookstate('')
const expiration = useHookstate(10)
const crashDashboardId = useHookstate('')
const metabaseSettingMutation = useMutation(metabaseSettingPath)
Expand All @@ -55,6 +56,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
id.set(data[0].id)
siteUrl.set(data[0].siteUrl)
secretKey.set(data[0].secretKey)
environment.set(data[0].environment)
expiration.set(data[0].expiration)
crashDashboardId.set(data[0].crashDashboardId || '')
}
Expand All @@ -63,13 +65,14 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
const handleSubmit = (event) => {
event.preventDefault()

if (!siteUrl.value || !secretKey.value) return
if (!siteUrl.value || !secretKey.value || !environment.value) return

state.loading.set(true)

const setting = {
siteUrl: siteUrl.value,
secretKey: secretKey.value,
environment: environment.value,
crashDashboardId: crashDashboardId.value
}

Expand All @@ -90,6 +93,7 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
id.set(data[0].id)
siteUrl.set(data[0].siteUrl)
secretKey.set(data[0].secretKey)
environment.set(data[0].environment)
expiration.set(data[0].expiration)
crashDashboardId.set(data[0].crashDashboardId || '')
}
Expand All @@ -112,6 +116,13 @@ const MetabaseTab = forwardRef(({ open }: { open: boolean }, ref: React.MutableR
onChange={(e) => siteUrl.set(e.target.value)}
/>

<Input
className="col-span-1"
label={t('admin:components.setting.metabase.environment')}
value={environment?.value || ''}
onChange={(e) => environment.set(e.target.value)}
/>

<PasswordInput
className="col-span-1"
label={t('admin:components.setting.metabase.secretKey')}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/regex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Ethereal Engine. All Rights Reserved.
export const VALID_FILENAME_REGEX = /^(?!.*[\s_<>:"/\\|?*\u0000-\u001F].*)[^\s_<>:"/\\|?*\u0000-\u001F]{1,64}$/
// eslint-disable-next-line no-control-regex
export const WINDOWS_RESERVED_NAME_REGEX = /^(con|prn|aux|nul|com\d|lpt\d)$/i
export const VALID_SCENE_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-]{2,62}[a-zA-Z0-9_\-]$/
export const VALID_SCENE_NAME_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9-]{2,62}[a-zA-Z0-9]$/
export const VALID_HEIRARCHY_SEARCH_REGEX = /[.*+?^${}()|[\]\\]/g

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const metabaseSettingSchema = Type.Object(
}),
siteUrl: Type.String(),
secretKey: Type.String(),
environment: Type.String(),
crashDashboardId: Type.Optional(Type.String()),
expiration: Type.Number(),
createdAt: Type.String({ format: 'date-time' }),
Expand Down Expand Up @@ -70,6 +71,7 @@ export const metabaseSettingQueryProperties = Type.Pick(metabaseSettingSchema, [
'id',
'siteUrl',
'secretKey',
'environment',
'crashDashboardId'
])

Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/schemas/media/file-browser.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export const fileBrowserPatchSchema = Type.Intersect(
project: Type.String(),
body: Type.Any(), // Buffer | string
contentType: Type.Optional(Type.String()),
storageProviderName: Type.Optional(Type.String())
storageProviderName: Type.Optional(Type.String()),
fileName: Type.Optional(Type.String())
})
],
{
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/schemas/media/invalidation.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const invalidationSchema = Type.Object(
export interface InvalidationType extends Static<typeof invalidationSchema> {}

// Schema for creating new entries
export const invalidationDataSchema = Type.Partial(invalidationSchema, { $id: 'InvalidationData' })
export const invalidationDataSchema = Type.Pick(invalidationSchema, ['path'], { $id: 'InvalidationData' })
export interface InvalidationData extends Static<typeof invalidationDataSchema> {}

// Schema for allowed query properties
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/schemas/recording/recording.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface RecordingDatabaseType extends Omit<RecordingType, 'schema'> {
}

// Schema for creating new entries
export const recordingDataSchema = Type.Partial(recordingSchema, {
export const recordingDataSchema = Type.Pick(recordingSchema, ['schema'], {
$id: 'RecordingData'
})
export interface RecordingData extends Static<typeof recordingDataSchema> {}
Expand All @@ -81,7 +81,7 @@ export const recordingPatchSchema = Type.Partial(recordingSchema, {
export interface RecordingPatch extends Static<typeof recordingPatchSchema> {}

// Schema for allowed query properties
export const recordingQueryProperties = Type.Pick(recordingSchema, ['id', 'userId'])
export const recordingQueryProperties = Type.Pick(recordingSchema, ['id', 'userId', 'createdAt'])
export const recordingQuerySchema = Type.Intersect(
[
querySyntax(recordingQueryProperties),
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/components/toolbar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { GLTFModifiedState } from '@etherealengine/engine/src/gltf/GLTFDocumentS
import { getMutableState, getState, useHookstate, useMutableState } from '@etherealengine/hyperflux'
import { useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
import { ContextMenu } from '@etherealengine/ui/src/components/tailwind/ContextMenu'
import { SidebarButton } from '@etherealengine/ui/src/components/tailwind/SidebarButton'
import Button from '@etherealengine/ui/src/primitives/tailwind/Button'
import { t } from 'i18next'
import React from 'react'
Expand Down Expand Up @@ -201,10 +202,9 @@ export default function Toolbar() {
<div className="flex w-fit min-w-44 flex-col gap-1 truncate rounded-lg bg-neutral-900 shadow-lg">
{toolbarMenu.map(({ name, action, hotkey }, index) => (
<div key={index}>
<Button
<SidebarButton
className="px-4 py-2.5 text-left font-light text-theme-input"
textContainerClassName="text-xs"
variant="sidebar"
size="small"
fullWidth
onClick={() => {
Expand All @@ -214,7 +214,7 @@ export default function Toolbar() {
endIcon={hotkey}
>
{name}
</Button>
</SidebarButton>
</div>
))}
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/scene/components/MediaComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ export const MediaComponent = defineComponent({
if (typeof json.seekTime === 'number') component.seekTime.set(json.seekTime)

if (typeof json.autoplay === 'boolean') component.autoplay.set(json.autoplay)

if (typeof json.synchronize === 'boolean') component.synchronize.set(json.synchronize)
})
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function seed(knex: Knex): Promise<void> {
{
siteUrl: process.env.METABASE_SITE_URL!,
secretKey: process.env.METABASE_SECRET_KEY!,
environment: process.env.METABASE_ENVIRONMENT!,
crashDashboardId: process.env.METABASE_CRASH_DASHBOARD_ID!,
expiration: isNaN(parseInt(process.env.METABASE_EXPIRATION!)) ? 10 : parseInt(process.env.METABASE_EXPIRATION!)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
CPAL-1.0 License
The contents of this file are subject to the Common Public Attribution License
Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
specific language governing rights and limitations under the License.
The Original Code is Ethereal Engine.
The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Ethereal Engine team.
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023
Ethereal Engine. All Rights Reserved.
*/

import { metabaseSettingPath } from '@etherealengine/common/src/schemas/integrations/metabase/metabase-setting.schema'
import type { Knex } from 'knex'

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export async function up(knex: Knex): Promise<void> {
await knex.raw('SET FOREIGN_KEY_CHECKS=0')

const tableExists = await knex.schema.hasTable(metabaseSettingPath)
if (tableExists) {
const environmentExists = await knex.schema.hasColumn(metabaseSettingPath, 'environment')
if (environmentExists === false) {
await knex.schema.alterTable(metabaseSettingPath, async (table) => {
table.string('environment').nullable()
})

const metabaseSettings = await knex.table(metabaseSettingPath).first()

if (metabaseSettings) {
await knex.table(metabaseSettingPath).update({
environment: process.env.METABASE_ENVIRONMENT
})
}
}
}
await knex.raw('SET FOREIGN_KEY_CHECKS=1')
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export async function down(knex: Knex): Promise<void> {
await knex.raw('SET FOREIGN_KEY_CHECKS=0')

const tableExists = await knex.schema.hasTable(metabaseSettingPath)
if (tableExists) {
const environmentExists = await knex.schema.hasColumn(metabaseSettingPath, 'environment')
if (environmentExists) {
await knex.schema.alterTable(metabaseSettingPath, async (table) => {
table.dropColumn('environment')
})
}
}

await knex.raw('SET FOREIGN_KEY_CHECKS=1')
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const metabaseCrashDashboard = async (context: HookContext<MetabaseUrlSer

const METABASE_SITE_URL = metabaseSetting.data[0].siteUrl
const METABASE_SECRET_KEY = metabaseSetting.data[0].secretKey
const ENVIRONMENT = metabaseSetting.data[0].environment
const EXPIRATION = metabaseSetting.data[0].expiration
const METABASE_CRASH_DASHBOARD_ID = metabaseSetting.data[0].crashDashboardId

Expand All @@ -56,7 +57,9 @@ export const metabaseCrashDashboard = async (context: HookContext<MetabaseUrlSer

const payload = {
resource: { dashboard: parseInt(METABASE_CRASH_DASHBOARD_ID) },
params: {},
params: {
environment: [ENVIRONMENT]
},
exp: Math.round(Date.now() / 1000) + EXPIRATION * 60
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export default {
return context
}
],
update: [() => schemaHooks.validateData(fileBrowserUpdateValidator)],
update: [schemaHooks.validateData(fileBrowserUpdateValidator)],
patch: [
(context) => {
context[SYNC] = false
return context
},
() => schemaHooks.validateData(fileBrowserPatchValidator)
schemaHooks.validateData(fileBrowserPatchValidator)
],
remove: []
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ export default {
before: {
all: [
disallow('external'),
() => schemaHooks.validateQuery(invalidationQueryValidator),
schemaHooks.validateQuery(invalidationQueryValidator),
schemaHooks.resolveQuery(invalidationQueryResolver)
],
find: [],
get: [],
create: [
() => schemaHooks.validateData(invalidationDataValidator),
schemaHooks.resolveData(invalidationDataResolver)
],
create: [schemaHooks.validateData(invalidationDataValidator), schemaHooks.resolveData(invalidationDataResolver)],
update: [disallow()],
patch: [disallow()],
remove: []
Expand Down
4 changes: 2 additions & 2 deletions packages/server-core/src/projects/project/github-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import { createExecutorJob } from '../../k8s-job-helper'
import { getFileKeysRecursive } from '../../media/storageprovider/storageProviderUtils'
import { getStorageProvider } from '../../media/storageprovider/storageprovider'
import { useGit } from '../../util/gitHelperFunctions'
import { getProjectPushJobBody } from './project-helper'
import { cleanProjectName, getProjectPushJobBody } from './project-helper'
import { ProjectParams } from './project.class'

// 30 MB. GitHub's documentation says that the blob upload cutoff is 50MB, but in testing, some files that were around
Expand Down Expand Up @@ -353,7 +353,7 @@ export const pushProjectToGithub = async (
returnData: '',
status: 'pending'
})
const projectJobName = project.name.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(project.name)
const jobBody = await getProjectPushJobBody(app, project, user, reset, newJob.id, commitSHA)
await app.service(apiJobPath).patch(newJob.id, {
name: jobBody.metadata!.name
Expand Down
17 changes: 12 additions & 5 deletions packages/server-core/src/projects/project/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ export async function getProjectUpdateJobBody(
command.push(data.reset.toString())
}

const projectJobName = data.name.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(data.name)

const labels = {
'etherealengine/projectUpdater': 'true',
Expand Down Expand Up @@ -1090,7 +1090,7 @@ export async function getProjectPushJobBody(
command.push(storageProviderName)
}

const projectJobName = project.name.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(project.name)

const labels = {
'etherealengine/projectPusher': 'true',
Expand All @@ -1104,7 +1104,7 @@ export async function getProjectPushJobBody(
}

export const getCronJobBody = (project: ProjectType, image: string): object => {
const projectJobName = project.name.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(project.name)
return {
metadata: {
name: `${process.env.RELEASE_NAME}-${projectJobName}-auto-update`,
Expand Down Expand Up @@ -1180,7 +1180,7 @@ export async function getDirectoryArchiveJobBody(
jobId
]

const projectJobName = projectName.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(projectName)

const labels = {
'etherealengine/directoryArchiver': 'true',
Expand Down Expand Up @@ -1540,7 +1540,7 @@ export const updateProject = async (
returned.needsRebuild = typeof data.needsRebuild === 'boolean' ? data.needsRebuild : true

if (returned.name !== projectName)
await app.service(projectPath).patch(existingProject!.id, {
await app.service(projectPath).patch(returned.id, {
name: projectName
})

Expand Down Expand Up @@ -1861,3 +1861,10 @@ export const uploadLocalProjectToProvider = async (
const assetsOnly = !fs.existsSync(path.join(projectRootPath, 'xrengine.config.ts'))
return { files: results.filter((success) => !!success) as string[], assetsOnly }
}

export const cleanProjectName = (name: string) => {
const returned = name.toLowerCase().replace(/[^a-zA-Z0-9-.]/g, '-')
if (!/[a-zA-Z0-9]/.test(returned[0])) return cleanProjectName(name.slice(1))
if (!/[a-zA-Z0-9]/.test(returned[returned.length - 1])) return cleanProjectName(name.slice(0, returned.length - 1))
return returned
}
3 changes: 2 additions & 1 deletion packages/server-core/src/projects/project/project.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import logger from '../../ServerLogger'
import { useGit } from '../../util/gitHelperFunctions'
import { checkAppOrgStatus, checkUserOrgWriteStatus, checkUserRepoWriteStatus } from './github-helper'
import {
cleanProjectName,
deleteProjectFilesInStorageProvider,
engineVersion,
getProjectConfig,
Expand Down Expand Up @@ -556,7 +557,7 @@ const updateProjectJob = async (context: HookContext) => {
returnData: '',
status: 'pending'
})
const projectJobName = data.name.toLowerCase().replace(/[^a-z0-9-.]/g, '-')
const projectJobName = cleanProjectName(data.name)
const jobBody = await getProjectUpdateJobBody(
data,
context.app,
Expand Down
Loading

0 comments on commit f80c26e

Please sign in to comment.