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

Commit

Permalink
IR-2824-Reinstate-original-publish-workflow-in-studio (#10462)
Browse files Browse the repository at this point in the history
Co-authored-by: Aditya Mitra <[email protected]>
  • Loading branch information
HexaField and aditya-mitra authored Jun 27, 2024
1 parent 67fc9f9 commit 4ea6942
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ const locationTypeOptions = [
{ label: 'Showroom', value: 'showroom' }
]

export default function AddEditLocationModal({ location }: { location?: LocationType }) {
export default function AddEditLocationModal({
location,
sceneID
}: {
location?: LocationType
sceneID?: string | null
}) {
const { t } = useTranslation()

const locationMutation = useMutation(locationPath)
Expand All @@ -59,7 +65,8 @@ export default function AddEditLocationModal({ location }: { location?: Location

const name = useHookstate(location?.name || '')
const maxUsers = useHookstate(location?.maxUsersPerInstance || 20)
const scene = useHookstate(location?.sceneId || '')

const scene = useHookstate((location ? location.sceneId : sceneID) ?? '')
const videoEnabled = useHookstate<boolean>(location?.locationSetting.videoEnabled || true)
const audioEnabled = useHookstate<boolean>(location?.locationSetting.audioEnabled || true)
const screenSharingEnabled = useHookstate<boolean>(location?.locationSetting.screenSharingEnabled || true)
Expand Down
23 changes: 19 additions & 4 deletions packages/editor/src/components/toolbar/Toolbar2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import AddEditLocationModal from '@etherealengine/client-core/src/admin/components/locations/AddEditLocationModal'
import { NotificationService } from '@etherealengine/client-core/src/common/services/NotificationService'
import { PopoverState } from '@etherealengine/client-core/src/common/services/PopoverState'
import { RouterState } from '@etherealengine/client-core/src/common/services/RouterService'
import { useProjectPermissions } from '@etherealengine/client-core/src/user/useUserProjectPermission'
import { useUserHasAccessHook } from '@etherealengine/client-core/src/user/userHasAccess'
import { locationPath } from '@etherealengine/common/src/schema.type.module'
import { GLTFModifiedState } from '@etherealengine/engine/src/gltf/GLTFDocumentState'
import { getMutableState, getState, useHookstate, useMutableState } from '@etherealengine/hyperflux'
import { useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks'
import ContextMenu from '@etherealengine/ui/src/components/editor/layout/ContextMenu'
import Button from '@etherealengine/ui/src/primitives/tailwind/Button'
import { t } from 'i18next'
Expand Down Expand Up @@ -113,11 +116,13 @@ export default function Toolbar() {
const anchorEvent = useHookstate<null | React.MouseEvent<HTMLElement>>(null)
const anchorPosition = useHookstate({ left: 0, top: 0 })

const { projectName, sceneName } = useMutableState(EditorState)
const { projectName, sceneName, sceneAssetID } = useMutableState(EditorState)

const hasLocationWriteScope = useUserHasAccessHook('location:write')
const permission = useProjectPermissions(projectName.value!)
const hasPublishAccess = hasLocationWriteScope || permission?.type === 'owner' || permission?.type === 'editor'
const locationQuery = useFind(locationPath, { query: { sceneId: sceneAssetID.value } })
const currentLocation = locationQuery.data.length === 1 ? locationQuery.data[0] : undefined

return (
<>
Expand Down Expand Up @@ -148,9 +153,19 @@ export default function Toolbar() {
<span>/</span>
<span>{sceneName.value}</span>
</div>
<Button rounded="none" disabled={!hasPublishAccess}>
{t('editor:toolbar.lbl-publish')}
</Button>
{sceneAssetID.value && (
<Button
rounded="none"
disabled={!hasPublishAccess}
onClick={() =>
PopoverState.showPopupover(
<AddEditLocationModal sceneID={sceneAssetID.value} location={currentLocation} />
)
}
>
{t('editor:toolbar.lbl-publish')}
</Button>
)}
</div>
<ContextMenu
anchorEvent={anchorEvent.value as React.MouseEvent<HTMLElement>}
Expand Down

0 comments on commit 4ea6942

Please sign in to comment.