Skip to content

Commit

Permalink
feat: split feature flags between create scene and start from template
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Dec 19, 2023
1 parent da7f52f commit de00211
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import { isLoadingType } from 'decentraland-dapps/dist/modules/loading/selectors
import { getLoadingProjectIds } from 'modules/sync/selectors'
import { SDKVersion } from 'modules/scene/types'
import { Project } from 'modules/project/types'
import { getIsSDK7TemplatesEnabled } from 'modules/features/selectors'
import { getIsCreateSceneOnlySDK7Enabled, getIsSDK7TemplatesEnabled } from 'modules/features/selectors'

const mapState = (state: RootState): MapStateProps => {
return {
isLoading: isLoadingType(getProjectLoading(state), LOAD_MANIFEST_REQUEST) || getLoadingProjectIds(state).length > 0,
error: getProjectError(state),
isSDK7TemplatesEnabled: getIsSDK7TemplatesEnabled(state)
isSDK7TemplatesEnabled: getIsSDK7TemplatesEnabled(state),
isCreateSceneOnlySDK7Enabled: getIsCreateSceneOnlySDK7Enabled(state)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Modals/CustomLayoutModal/CustomLayoutModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class CustomLayoutModal extends React.PureComponent<Props, State>
}

renderModalActions = () => {
const { isSDK7TemplatesEnabled } = this.props
const { isCreateSceneOnlySDK7Enabled } = this.props
const { hasError, name, step } = this.state

switch (step) {
Expand All @@ -128,7 +128,7 @@ export default class CustomLayoutModal extends React.PureComponent<Props, State>
<Button
primary
disabled={hasError || !name}
onClick={isSDK7TemplatesEnabled ? this.handleSubmit.bind(this, SDKVersion.SDK7) : this.handleNext}
onClick={isCreateSceneOnlySDK7Enabled ? this.handleSubmit.bind(this, SDKVersion.SDK7) : this.handleNext}
>
{t('global.next')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type Props = ModalProps & {
isLoading: boolean
onCreateProject: (name: string, description: string, template: Template, sdk: SDKVersion) => void
isSDK7TemplatesEnabled: boolean
isCreateSceneOnlySDK7Enabled: boolean
}

export enum SceneCreationStep {
Expand All @@ -29,6 +30,6 @@ export type State = {
description: string
}

export type MapStateProps = Pick<Props, 'error' | 'isLoading' | 'isSDK7TemplatesEnabled'>
export type MapStateProps = Pick<Props, 'error' | 'isLoading' | 'isSDK7TemplatesEnabled' | 'isCreateSceneOnlySDK7Enabled'>
export type MapDispatchProps = Pick<Props, 'onCreateProject'>
export type MapDispatch = Dispatch<CreateProjectFromTemplateAction | CallHistoryMethodAction>
3 changes: 2 additions & 1 deletion src/modules/common/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({
},
onError: (err, store) => {
const isQuotaModalOpen = !!getOpenModals(store.getState())['QuotaExceededModal']
if (err instanceof DOMException && err.name === 'QuotaExceededError' && !isQuotaModalOpen) {
const isCloneTemplateModalOpen = !!getOpenModals(store.getState())['CloneTemplateModal']
if (err instanceof DOMException && err.name === 'QuotaExceededError' && !isQuotaModalOpen && !isCloneTemplateModalOpen) {
store.dispatch(openModal('QuotaExceededModal'))
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/modules/features/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ export const getIsSDK7TemplatesEnabled = (state: RootState) => {
return false
}
}

export const getIsCreateSceneOnlySDK7Enabled = (state: RootState) => {
try {
return getIsFeatureEnabled(state, ApplicationName.BUILDER, FeatureName.CREATE_SCENE_ONLY_SDK7)
} catch (e) {
return false
}
}
3 changes: 2 additions & 1 deletion src/modules/features/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export enum FeatureName {
EMOTES_V2 = 'emotes-2.0',
SMART_ITEMS = 'smart-items',
WORLDS_FOR_ENS_OWNERS = 'worlds-for-ens-owners',
SDK7_TEMPLATES = 'sdk7-templates'
SDK7_TEMPLATES = 'sdk7-templates',
CREATE_SCENE_ONLY_SDK7 = 'create-scene-only-sdk7'
}

0 comments on commit de00211

Please sign in to comment.