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 IR-3297-client-input-system-restructure-into-…
Browse files Browse the repository at this point in the history
…multiple-files
  • Loading branch information
SamMazerIR authored Aug 16, 2024
2 parents 57b0451 + 1bf2882 commit 65f1323
Show file tree
Hide file tree
Showing 30 changed files with 288 additions and 121 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
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ export const FileThumbnailJobState = defineState({
if (seenResources.has(resource.key)) continue
seenResources.add(resource.key)

if (resource.type === 'thumbnail') {
//set thumbnail's thumbnail as itself
Engine.instance.api.service(staticResourcePath).patch(resource.id, { thumbnailKey: resource.key })
continue
}

if (resource.thumbnailKey != null || !extensionCanHaveThumbnail(resource.key.split('.').pop() ?? '')) continue

getMutableState(FileThumbnailJobState).merge([
Expand Down
18 changes: 9 additions & 9 deletions packages/client-core/src/hooks/useZendesk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { AuthState } from '../user/services/AuthService'

declare global {
interface Window {
zE: (...args: any) => void
zE?: (...args: any) => void
}
}

Expand All @@ -49,7 +49,7 @@ export const useZendesk = () => {
const authenticateUser = () => {
if (authenticated.value || config.client.zendesk.authenticationEnabled !== 'true') return

window.zE('messenger', 'loginUser', function (callback: any) {
window.zE?.('messenger', 'loginUser', function (callback: any) {
zendeskMutation.create().then(async (token) => {
authenticated.set(true)
await callback(token)
Expand All @@ -71,10 +71,10 @@ export const useZendesk = () => {
hideWidget()
authenticateUser()
}
window.zE('messenger:on', 'close', () => {
window.zE?.('messenger:on', 'close', () => {
hideWidget()
})
window.zE('messenger:on', 'open', function () {
window.zE?.('messenger:on', 'open', function () {
showWidget()
})
})
Expand All @@ -89,28 +89,28 @@ export const useZendesk = () => {
authenticateUser()
} else if (user.isGuest.value && initialized.value) {
closeChat()
window.zE('messenger', 'logoutUser')
window.zE?.('messenger', 'logoutUser')
}
}, [user.value])

const hideWidget = () => {
if (!initialized.value) return
window.zE('messenger', 'hide')
window.zE?.('messenger', 'hide')
isWidgetVisible.set(false)
}
const showWidget = () => {
if (!initialized.value) return
window.zE('messenger', 'show')
window.zE?.('messenger', 'show')
isWidgetVisible.set(true)
}
const openChat = () => {
if (!initialized.value) return
window.zE('messenger', 'open')
window.zE?.('messenger', 'open')
}

const closeChat = () => {
if (!initialized.value) return
window.zE('messenger', 'close')
window.zE?.('messenger', 'close')
}

return {
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: 1 addition & 1 deletion packages/engine/src/scene/components/LinkComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const LinkComponent = defineComponent({

onInit: (entity) => {
return {
url: 'https://www.etherealengine.org',
url: '',
sceneNav: false,
location: ''
}
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
39 changes: 31 additions & 8 deletions packages/server-core/src/media/file-browser/file-browser.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,37 @@ export class FileBrowserService
const results = [] as StaticResourceType[]
for (const resource of staticResources) {
const newKey = resource.key.replace(path.join(oldDirectory, oldName), path.join(newDirectory, fileName))
const result = await this.app.service(staticResourcePath).patch(
resource.id,
{
key: newKey
},
{ isInternal: true }
)
results.push(result)

if (data.isCopy) {
const result = await this.app.service(staticResourcePath).create(
{
key: newKey,
hash: resource.hash,
mimeType: resource.mimeType,
project: data.newProject,
stats: resource.stats,
type: resource.type,
tags: resource.tags,
dependencies: resource.dependencies,
licensing: resource.licensing,
description: resource.description,
attribution: resource.attribution,
thumbnailKey: resource.thumbnailKey,
thumbnailMode: resource.thumbnailMode
},
{ isInternal: true }
)
results.push(result)
} else {
const result = await this.app.service(staticResourcePath).patch(
resource.id,
{
key: newKey
},
{ isInternal: true }
)
results.push(result)
}
}

if (config.fsProjectSyncEnabled) {
Expand Down
Loading

0 comments on commit 65f1323

Please sign in to comment.