Skip to content

Commit

Permalink
Merge e3febcc into 8c8cac0
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Apr 22, 2024
2 parents 8c8cac0 + e3febcc commit a318c8a
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isOwner } from 'modules/item/utils'
import { getSelectedItemId } from 'modules/location/selectors'
import { getCollection, hasViewAndEditRights } from 'modules/collection/selectors'
import { isWalletCommitteeMember } from 'modules/committee/selectors'
import { getIsCampaignEnabled, getIsExoticRarityEnabled, getIsVrmOptOutEnabled } from 'modules/features/selectors'
import { getIsCampaignEnabled, getIsVrmOptOutEnabled } from 'modules/features/selectors'
import { MapStateProps, MapDispatchProps, MapDispatch } from './RightPanel.types'
import RightPanel from './RightPanel'

Expand All @@ -35,7 +35,6 @@ const mapState = (state: RootState): MapStateProps => {
isDownloading: isDownloading(state),
isCommitteeMember: isWalletCommitteeMember(state),
isCampaignEnabled: getIsCampaignEnabled(state),
isExoticRarityEnabled: getIsExoticRarityEnabled(state),
isVrmOptOutEnabled: getIsVrmOptOutEnabled(state)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ItemEditorPage/RightPanel/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ export default class RightPanel extends React.PureComponent<Props, State> {
}

render() {
const { selectedItemId, address, isConnected, error, isCampaignEnabled, isExoticRarityEnabled, isVrmOptOutEnabled } = this.props
const { selectedItemId, address, isConnected, error, isCampaignEnabled, isVrmOptOutEnabled } = this.props
const { name, description, rarity, data, isDirty, hasItem } = this.state
const rarities = Rarity.getRarities().filter(rarity => isExoticRarityEnabled || rarity !== Rarity.EXOTIC)
const rarities = Rarity.getRarities()
const playModes = getEmotePlayModes()

return (
Expand Down
2 changes: 0 additions & 2 deletions src/components/ItemEditorPage/RightPanel/RightPanel.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export type Props = {
isDownloading: boolean
isCommitteeMember: boolean
isCampaignEnabled: boolean
isExoticRarityEnabled: boolean
isVrmOptOutEnabled: boolean
onSaveItem: typeof saveItemRequest
onDeleteItem: typeof deleteItemRequest
Expand Down Expand Up @@ -60,7 +59,6 @@ export type MapStateProps = Pick<
| 'isCommitteeMember'
| 'canEditSelectedItem'
| 'isCampaignEnabled'
| 'isExoticRarityEnabled'
| 'isVrmOptOutEnabled'
>
export type MapDispatchProps = Pick<Props, 'onSaveItem' | 'onDeleteItem' | 'onOpenModal' | 'onSetCollection' | 'onDownload'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getCollection } from 'modules/collection/selectors'
import { Collection } from 'modules/collection/types'
import { saveItemRequest, SAVE_ITEM_REQUEST } from 'modules/item/actions'
import { getLoading, getError, getStatusByItemId } from 'modules/item/selectors'
import { getIsExoticRarityEnabled } from 'modules/features/selectors'
import { MapStateProps, MapDispatchProps, MapDispatch, OwnProps } from './CreateSingleItemModal.types'
import CreateSingleItemModal from './CreateSingleItemModal'

Expand All @@ -20,8 +19,7 @@ const mapState = (state: RootState, ownProps: OwnProps): MapStateProps => {
address: getAddress(state),
error: getError(state),
itemStatus,
isLoading: isLoadingType(getLoading(state), SAVE_ITEM_REQUEST),
isExoticRarityEnabled: getIsExoticRarityEnabled(state)
isLoading: isLoadingType(getLoading(state), SAVE_ITEM_REQUEST)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,11 +827,11 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

renderFields() {
const { collection, isExoticRarityEnabled } = this.props
const { collection } = this.props
const { name, category, rarity, contents, item, type, isLoading } = this.state

const belongsToAThirdPartyCollection = collection?.urn && isThirdParty(collection.urn)
const rarities = Rarity.getRarities().filter(rarity => isExoticRarityEnabled || rarity !== Rarity.EXOTIC)
const rarities = Rarity.getRarities()
const categories: string[] = type === ItemType.WEARABLE ? getWearableCategories(contents) : getEmoteCategories()

const raritiesLink =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type Props = ModalProps & {
isLoading: boolean
collection: Collection | null
itemStatus: SyncStatus | null
isExoticRarityEnabled: boolean
onSave: typeof saveItemRequest
}

Expand Down Expand Up @@ -103,6 +102,6 @@ export type AcceptedFileProps = Pick<
| 'blockVrmExport'
>
export type OwnProps = Pick<Props, 'metadata' | 'name' | 'onClose'>
export type MapStateProps = Pick<Props, 'address' | 'error' | 'isLoading' | 'collection' | 'itemStatus' | 'isExoticRarityEnabled'>
export type MapStateProps = Pick<Props, 'address' | 'error' | 'isLoading' | 'collection' | 'itemStatus'>
export type MapDispatchProps = Pick<Props, 'onSave'>
export type MapDispatch = Dispatch<SaveItemRequestAction>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getUnsyncedCollectionError,
getError as getCollectionError
} from 'modules/collection/selectors'
import { getLoading as getItemLoading, getCollectionItems, getError as getItemError, getFilteredRarities } from 'modules/item/selectors'
import { getLoading as getItemLoading, getCollectionItems, getError as getItemError, getRarities } from 'modules/item/selectors'
import { publishCollectionRequest, PUBLISH_COLLECTION_REQUEST } from 'modules/collection/actions'
import { CREATE_COLLECTION_FORUM_POST_REQUEST } from 'modules/forum/actions'
import { fetchRaritiesRequest, FETCH_RARITIES_REQUEST, FETCH_ITEMS_REQUEST } from 'modules/item/actions'
Expand All @@ -29,7 +29,7 @@ const mapState = (state: RootState, ownProps: OwnProps): MapStateProps => {
wallet: getWallet(state)!,
collection,
items: getCollectionItems(state, collectionId),
rarities: getFilteredRarities(state),
rarities: getRarities(state),
unsyncedCollectionError: getUnsyncedCollectionError(state),
itemError: getItemError(state),
collectionError: getCollectionError(state),
Expand Down
8 changes: 0 additions & 8 deletions src/modules/features/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ export const getIsPublishCollectionsWertEnabled = (state: RootState) => {
}
}

export const getIsExoticRarityEnabled = (state: RootState) => {
try {
return getIsFeatureEnabled(state, ApplicationName.DAPPS, FeatureName.EXOTIC_RARITY)
} catch (e) {
return false
}
}

export const getIsVrmOptOutEnabled = (state: RootState) => {
try {
return getIsFeatureEnabled(state, ApplicationName.BUILDER, FeatureName.VRM_OPTOUT)
Expand Down
1 change: 0 additions & 1 deletion src/modules/features/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ export enum FeatureName {
CREATE_SCENE_ONLY_SDK7 = 'create-scene-only-sdk7',
ENS_ADDRESS = 'ens-address',
PUBLISH_COLLECTIONS_WERT = 'publish-collections-wert',
EXOTIC_RARITY = 'exotic-rarity',
VRM_OPTOUT = 'vrm-optout'
}
55 changes: 0 additions & 55 deletions src/modules/item/selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { mockedItem } from 'specs/item'
import { ItemState } from './reducer'
import {
getAuthorizedItems,
getFilteredRarities,
getItem,
getItems,
getPaginatedCollectionItems,
Expand Down Expand Up @@ -184,60 +183,6 @@ describe('Item selectors', () => {
})
})

describe('when getting the filtered rarities', () => {
describe('and the feature flag is enabled', () => {
beforeEach(() => {
state = {
...state,
features: {
data: {
dapps: {
name: 'dapps',
flags: {
'dapps-exotic-rarity': true
},
variants: {}
}
},
error: null,
loading: [],
hasLoadedInitialFlags: true
}
} as RootState
})

it('should return the rarities with the exotic rarity', () => {
expect(getFilteredRarities(state)).toEqual(state.item.rarities)
})
})

describe('and the feature flag is not enabled', () => {
beforeEach(() => {
state = {
...state,
features: {
data: {
dapps: {
name: 'dapps',
flags: {
'dapps-exotic-rarity': false
},
variants: {}
}
},
error: null,
loading: [],
hasLoadedInitialFlags: true
}
} as RootState
})

it('should return the rarities without the exotic rarity', () => {
expect(getFilteredRarities(state)).toEqual(state.item.rarities.filter(rarity => rarity.name !== Rarity.EXOTIC))
})
})
})

describe('when getting the rarities', () => {
it('should return the rarities', () => {
expect(getRarities(state)).toEqual(state.item.rarities)
Expand Down
10 changes: 1 addition & 9 deletions src/modules/item/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Entity, Rarity } from '@dcl/schemas'
import { Entity } from '@dcl/schemas'
import { createSelector } from 'reselect'
import { isLoadingType } from 'decentraland-dapps/dist/modules/loading/selectors'
import { getAddress } from 'decentraland-dapps/dist/modules/wallet/selectors'
Expand All @@ -13,7 +13,6 @@ import { ItemCuration } from 'modules/curations/itemCuration/types'
import { getItemCurationsByItemId } from 'modules/curations/itemCuration/selectors'
import { CurationStatus } from 'modules/curations/types'
import { getItemThirdParty } from 'modules/thirdParty/selectors'
import { getIsExoticRarityEnabled } from 'modules/features/selectors'
import { isUserManagerOfThirdParty } from 'modules/thirdParty/utils'
import { isEqual } from 'lib/address'
import { buildCatalystItemURN, isThirdParty } from '../../lib/urn'
Expand Down Expand Up @@ -85,13 +84,6 @@ export const getRarities = (state: RootState): BlockchainRarity[] => {
return getState(state).rarities
}

// Temporal rarity selector to filter out the exotic rarity in accordance to the feature flag
export const getFilteredRarities = createSelector<RootState, boolean, BlockchainRarity[], BlockchainRarity[]>(
getIsExoticRarityEnabled,
getRarities,
(isExoticRarityEnabled, rarities) => rarities.filter(rarity => isExoticRarityEnabled || rarity.name !== Rarity.EXOTIC)
)

export const getWearables = createSelector<RootState, Item[], Item[]>(getItems, items =>
items.filter(item => item.type === ItemType.WEARABLE)
)
Expand Down

0 comments on commit a318c8a

Please sign in to comment.