Skip to content

Commit

Permalink
feat: remove FF for templates, smart wearables, hands and deploy to w…
Browse files Browse the repository at this point in the history
…orlds (#2922)
  • Loading branch information
Melisa Anabella Rossi authored Sep 28, 2023
1 parent 1a01a82 commit 2f176ac
Show file tree
Hide file tree
Showing 40 changed files with 84 additions and 479 deletions.
3 changes: 1 addition & 2 deletions src/components/CollectionsPage/CollectionsPage.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { setCollectionPageView } from 'modules/ui/collection/actions'
import { getCollectionPageView } from 'modules/ui/collection/selectors'
import { isThirdPartyManager } from 'modules/thirdParty/selectors'
import { fetchItemsRequest, fetchOrphanItemRequest, FETCH_ITEMS_REQUEST, FETCH_ORPHAN_ITEM_REQUEST } from 'modules/item/actions'
import { getEmotesV2Enabled, getIsCampaignEnabled, getIsPublishSmartWearablesEnabled } from 'modules/features/selectors'
import { getEmotesV2Enabled, getIsCampaignEnabled } from 'modules/features/selectors'
import { fetchCollectionsRequest, FETCH_COLLECTIONS_REQUEST } from 'modules/collection/actions'
import { MapStateProps, MapDispatchProps, MapDispatch } from './CollectionsPage.types'
import CollectionsPage from './CollectionsPage'
Expand All @@ -40,7 +40,6 @@ const mapState = (state: RootState): MapStateProps => {
isLoadingOrphanItem: isLoadingType(getLoadingItems(state), FETCH_ORPHAN_ITEM_REQUEST),
isCampaignEnabled: getIsCampaignEnabled(state),
isEmotesV2Enabled: getEmotesV2Enabled(state),
isPublishSmartWearablesEnabled: getIsPublishSmartWearablesEnabled(state),
hasUserOrphanItems: hasUserOrphanItems(state)
}
}
Expand Down
15 changes: 1 addition & 14 deletions src/components/CollectionsPage/CollectionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { Props, TABS } from './CollectionsPage.types'
import './CollectionsPage.css'

const PAGE_SIZE = 20
export const LOCALSTORAGE_SMART_WEARABLES_ANNOUCEMENT = 'builder-smart-wearables-announcement'
export const LOCALSTORAGE_EMOTES_V2_ANNOUCEMENT = 'builder-emotes-2.0-announcement'
export default class CollectionsPage extends React.PureComponent<Props> {
state = {
Expand All @@ -42,15 +41,7 @@ export default class CollectionsPage extends React.PureComponent<Props> {
}

componentDidMount() {
const {
address,
hasUserOrphanItems,
isPublishSmartWearablesEnabled,
isEmotesV2Enabled,
onFetchCollections,
onFetchOrphanItem,
onOpenModal
} = this.props
const { address, hasUserOrphanItems, isEmotesV2Enabled, onFetchCollections, onFetchOrphanItem, onOpenModal } = this.props
// fetch if already connected
if (address) {
onFetchCollections(address, { page: 1, limit: PAGE_SIZE, sort: CurationSortOptions.CREATED_AT_DESC })
Expand All @@ -59,10 +50,6 @@ export default class CollectionsPage extends React.PureComponent<Props> {
onFetchOrphanItem(address)
}

if (isPublishSmartWearablesEnabled && !localStorage.getItem(LOCALSTORAGE_SMART_WEARABLES_ANNOUCEMENT)) {
onOpenModal('SmartWearablesAnnouncementModal')
}

if (isEmotesV2Enabled && !localStorage.getItem(LOCALSTORAGE_EMOTES_V2_ANNOUCEMENT)) {
onOpenModal('EmotesV2AnnouncementModal')
}
Expand Down
2 changes: 0 additions & 2 deletions src/components/CollectionsPage/CollectionsPage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export type Props = {
isLoadingItems: boolean
isLoadingOrphanItem: boolean
isCampaignEnabled: boolean
isPublishSmartWearablesEnabled: boolean
isEmotesV2Enabled: boolean
hasUserOrphanItems: boolean | undefined
onNavigate: (path: string) => void
Expand All @@ -53,7 +52,6 @@ export type MapStateProps = Pick<
| 'isCampaignEnabled'
| 'isEmotesV2Enabled'
| 'hasUserOrphanItems'
| 'isPublishSmartWearablesEnabled'
>
export type MapDispatchProps = Pick<
Props,
Expand Down
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, getIsHandsCategoryEnabled } from 'modules/features/selectors'
import { getIsCampaignEnabled } from 'modules/features/selectors'
import { MapStateProps, MapDispatchProps, MapDispatch } from './RightPanel.types'
import RightPanel from './RightPanel'

Expand All @@ -34,8 +34,7 @@ const mapState = (state: RootState): MapStateProps => {
isConnected: isConnected(state),
isDownloading: isDownloading(state),
isCommitteeMember: isWalletCommitteeMember(state),
isCampaignEnabled: getIsCampaignEnabled(state),
isHandsCategoryEnabled: getIsHandsCategoryEnabled(state)
isCampaignEnabled: getIsCampaignEnabled(state)
}
}

Expand Down
103 changes: 24 additions & 79 deletions src/components/ItemEditorPage/RightPanel/RightPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ export default class RightPanel extends React.PureComponent<Props, State> {
}

setItem(item: Item) {
const { isHandsCategoryEnabled } = this.props
const data = item.data

if (isHandsCategoryEnabled && item.type === ItemType.WEARABLE) {
if (item.type === ItemType.WEARABLE && data.replaces?.length) {
// Move all items that are in replaces array to hides array
data.hides = data.hides.concat(data.replaces)
data.replaces = []
Expand Down Expand Up @@ -212,12 +211,9 @@ export default class RightPanel extends React.PureComponent<Props, State> {

handleChangeHides = (value: HideableWearableCategory[], category?: 'wearable' | 'bodypart') => {
const currentHides = (this.state.data as WearableData).hides
const { isHandsCategoryEnabled } = this.props

let hides: HideableWearableCategory[] = []
if (!isHandsCategoryEnabled) {
hides = value
} else if (category === 'wearable') {
if (category === 'wearable') {
hides = [...currentHides.filter(cat => !WearableCategory.schema.enum.includes(cat)), ...value]
} else {
hides = [...currentHides.filter(cat => !BodyPartCategory.schema.enum.includes(cat)), ...value]
Expand All @@ -237,13 +233,13 @@ export default class RightPanel extends React.PureComponent<Props, State> {
}

handleOnSaveItem = async () => {
const { selectedItem, itemStatus, isHandsCategoryEnabled, onSaveItem } = this.props
const { selectedItem, itemStatus, onSaveItem } = this.props
const { name, description, rarity, contents, data, isDirty } = this.state

if (isDirty && selectedItem) {
let itemData = data
//override hands default hiding for all new wearables
if (itemData && !isEmoteData(itemData) && isHandsCategoryEnabled) {
if (itemData && !isEmoteData(itemData)) {
itemData = {
...itemData,
removesDefaultHiding:
Expand Down Expand Up @@ -374,17 +370,15 @@ export default class RightPanel extends React.PureComponent<Props, State> {
}

renderOverrides(item: Item) {
const { isHandsCategoryEnabled } = this.props
const canEditItemMetadata = this.canEditItemMetadata(item)
const data = this.state.data as WearableData

if (!item || isEmoteData(data)) {
return null
}

const hideableWearableCategories = getHideableWearableCategories(item.contents, data.category, isHandsCategoryEnabled)
const hideableBodyPartCategories = getHideableBodyPartCategories(item.contents, isHandsCategoryEnabled)
const actionableCategories = [...hideableWearableCategories, ...hideableBodyPartCategories]
const hideableWearableCategories = getHideableWearableCategories(item.contents, data.category)
const hideableBodyPartCategories = getHideableBodyPartCategories(item.contents)

const hidesWearable = data.hides.filter(category =>
hideableWearableCategories.includes(category as WearableCategory)
Expand All @@ -393,76 +387,33 @@ export default class RightPanel extends React.PureComponent<Props, State> {
hideableBodyPartCategories.includes(category as BodyPartCategory)
) as BodyPartCategory[]

if (isHandsCategoryEnabled) {
return (
<>
<MultiSelect<BodyPartCategory>
itemId={item.id}
label={t('item_editor.right_panel.base_body')}
info={t('item_editor.right_panel.base_body_info')}
value={hidesBodyPart}
options={this.asCategorySelect(item.type, hideableBodyPartCategories)}
disabled={!canEditItemMetadata}
onChange={value => this.handleChangeHides(value, 'bodypart')}
/>
<MultiSelect<WearableCategory>
itemId={item.id}
label={t('item_editor.right_panel.wearables')}
info={t('item_editor.right_panel.wearables_info')}
value={hidesWearable}
options={this.asCategorySelect(
item.type,
// Workaround for https://github.com/decentraland/builder/issues/2068
// This will only show the body shape option if the item is currenlty hiding it.
// Once removed, the option cannot be selected again
hidesWearable.some(c => c === WearableCategory.BODY_SHAPE)
? hideableWearableCategories
: hideableWearableCategories.filter(c => c !== WearableCategory.BODY_SHAPE)
)}
disabled={!canEditItemMetadata}
onChange={value => this.handleChangeHides(value, 'wearable')}
/>
</>
)
}

const replacesWearable = data.replaces.filter(category =>
hideableWearableCategories.includes(category as WearableCategory)
) as WearableCategory[]
const replacesBodyPart = data.replaces.filter(category =>
hideableBodyPartCategories.includes(category as BodyPartCategory)
) as BodyPartCategory[]
const hides = [...hidesBodyPart, ...hidesWearable]
const replaces = [...replacesBodyPart, ...replacesWearable]
const availableToHide = actionableCategories.filter(category => !replaces.includes(category))
const availableToOverride = actionableCategories.filter(category => !hides.includes(category))
return (
<>
<MultiSelect<WearableCategory | BodyPartCategory>
<MultiSelect<BodyPartCategory>
itemId={item.id}
label={t('item_editor.right_panel.replaces')}
info={t('item_editor.right_panel.replaces_info')}
value={replaces}
options={this.asCategorySelect(item.type, availableToOverride)}
disabled={!canEditItemMetadata || this.isSkin()}
onChange={this.handleChangeReplaces}
label={t('item_editor.right_panel.base_body')}
info={t('item_editor.right_panel.base_body_info')}
value={hidesBodyPart}
options={this.asCategorySelect(item.type, hideableBodyPartCategories)}
disabled={!canEditItemMetadata}
onChange={value => this.handleChangeHides(value, 'bodypart')}
/>
<MultiSelect<WearableCategory | BodyPartCategory>
<MultiSelect<WearableCategory>
itemId={item.id}
label={t('item_editor.right_panel.hides')}
info={t('item_editor.right_panel.hides_info')}
value={hides}
label={t('item_editor.right_panel.wearables')}
info={t('item_editor.right_panel.wearables_info')}
value={hidesWearable}
options={this.asCategorySelect(
item.type,
// Workaround for https://github.com/decentraland/builder/issues/2068
// This will only show the body shape option if the item is currenlty hiding it.
// Once removed, the option cannot be selected again
item.data.hides.some(c => c === WearableCategory.BODY_SHAPE)
? availableToHide
: availableToHide.filter(c => c !== WearableCategory.BODY_SHAPE)
hidesWearable.some(c => c === WearableCategory.BODY_SHAPE)
? hideableWearableCategories
: hideableWearableCategories.filter(c => c !== WearableCategory.BODY_SHAPE)
)}
disabled={!canEditItemMetadata}
onChange={this.handleChangeHides}
onChange={value => this.handleChangeHides(value, 'wearable')}
/>
</>
)
Expand Down Expand Up @@ -540,7 +491,7 @@ export default class RightPanel extends React.PureComponent<Props, State> {
}

render() {
const { selectedItemId, address, isConnected, error, isCampaignEnabled, isHandsCategoryEnabled } = this.props
const { selectedItemId, address, isConnected, error, isCampaignEnabled } = this.props
const { name, description, rarity, data, isDirty, hasItem } = this.state
const rarities = getRarities()
const playModes = getEmotePlayModes()
Expand All @@ -553,11 +504,7 @@ export default class RightPanel extends React.PureComponent<Props, State> {
const isItemLocked = collection && isLocked(collection)
const canEditItemMetadata = this.canEditItemMetadata(item)

const categories = item
? item.type === ItemType.WEARABLE
? getWearableCategories(item.contents, isHandsCategoryEnabled)
: getEmoteCategories()
: []
const categories = item ? (item.type === ItemType.WEARABLE ? getWearableCategories(item.contents) : getEmoteCategories()) : []

return isLoading ? (
<Loader size="massive" active />
Expand Down Expand Up @@ -641,9 +588,7 @@ export default class RightPanel extends React.PureComponent<Props, State> {
label={
<>
<span className="overrides-label-panel">{t('item_editor.right_panel.overrides')}</span>
{isHandsCategoryEnabled ? (
<Info content={t('item_editor.right_panel.overrides_info')} className="info" />
) : null}
<Info content={t('item_editor.right_panel.overrides_info')} className="info" />
</>
}
>
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
isHandsCategoryEnabled: boolean
onSaveItem: typeof saveItemRequest
onDeleteItem: typeof deleteItemRequest
onOpenModal: typeof openModal
Expand Down Expand Up @@ -59,7 +58,6 @@ export type MapStateProps = Pick<
| 'isCommitteeMember'
| 'canEditSelectedItem'
| 'isCampaignEnabled'
| 'isHandsCategoryEnabled'
>
export type MapDispatchProps = Pick<Props, 'onSaveItem' | 'onDeleteItem' | 'onOpenModal' | 'onSetCollection' | 'onDownload'>
export type MapDispatch = Dispatch<
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 { getIsHandsCategoryEnabled, getIsPublishSmartWearablesEnabled } from 'modules/features/selectors'
import { MapStateProps, MapDispatchProps, MapDispatch, OwnProps } from './CreateSingleItemModal.types'
import CreateSingleItemModal from './CreateSingleItemModal'

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

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

createItem = async (sortedContents: SortedContent, representations: WearableRepresentation[]) => {
const { address, collection, isHandsCategoryEnabled } = this.props
const { address, collection } = this.props
const {
id,
name,
Expand Down Expand Up @@ -230,7 +230,7 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
let data: WearableData | EmoteDataADR74

if (type === ItemType.WEARABLE) {
const removesDefaultHiding = isHandsCategoryEnabled && category === WearableCategory.UPPER_BODY ? [BodyPartCategory.HANDS] : []
const removesDefaultHiding = category === WearableCategory.UPPER_BODY ? [BodyPartCategory.HANDS] : []
data = {
category: category as WearableCategory,
replaces: [],
Expand Down Expand Up @@ -285,12 +285,11 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

addItemRepresentation = async (sortedContents: SortedContent, representations: WearableRepresentation[]) => {
const { isHandsCategoryEnabled, onSave } = this.props
const { onSave } = this.props
const { bodyShape, item: editedItem, requiredPermissions } = this.state as StateData
const hashedContents = await computeHashes(bodyShape === BodyShapeType.MALE ? sortedContents.male : sortedContents.female)
const removesDefaultHiding =
isHandsCategoryEnabled &&
(editedItem.data.category === WearableCategory.UPPER_BODY || editedItem.data.hides.includes(WearableCategory.UPPER_BODY))
editedItem.data.category === WearableCategory.UPPER_BODY || editedItem.data.hides.includes(WearableCategory.UPPER_BODY)
? [BodyPartCategory.HANDS]
: []
const item = {
Expand Down Expand Up @@ -321,13 +320,13 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

modifyItem = async (pristineItem: Item, sortedContents: SortedContent, representations: WearableRepresentation[]) => {
const { itemStatus, isHandsCategoryEnabled, onSave } = this.props
const { itemStatus, onSave } = this.props
const { name, bodyShape, type, metrics, category, playMode, requiredPermissions } = this.state as StateData

let data: WearableData | EmoteDataADR74

if (type === ItemType.WEARABLE) {
const removesDefaultHiding = isHandsCategoryEnabled && category === WearableCategory.UPPER_BODY ? [BodyPartCategory.HANDS] : []
const removesDefaultHiding = category === WearableCategory.UPPER_BODY ? [BodyPartCategory.HANDS] : []
data = {
...pristineItem.data,
replaces: [],
Expand Down Expand Up @@ -749,7 +748,7 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

renderImportView() {
const { collection, metadata, isPublishSmartWearablesEnabled, onClose } = this.props
const { collection, metadata, onClose } = this.props
const { category, isLoading, isRepresentation } = this.state
const title = this.renderModalTitle()

Expand All @@ -764,7 +763,6 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
isRepresentation={!!isRepresentation}
onDropAccepted={this.handleDropAccepted}
onClose={onClose}
isPublishSmartWearablesEnabled={isPublishSmartWearablesEnabled}
/>
)
}
Expand All @@ -788,12 +786,12 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

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

const belongsToAThirdPartyCollection = collection?.urn && isThirdParty(collection.urn)
const rarities = getRarities()
const categories: string[] = type === ItemType.WEARABLE ? getWearableCategories(contents, isHandsCategoryEnabled) : getEmoteCategories()
const categories: string[] = type === ItemType.WEARABLE ? getWearableCategories(contents) : getEmoteCategories()

const raritiesLink =
'https://docs.decentraland.org/creator/wearables-and-emotes/manage-collections' +
Expand Down
Loading

1 comment on commit 2f176ac

@vercel
Copy link

@vercel vercel bot commented on 2f176ac Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder – ./

builder-git-master-decentraland1.vercel.app
builder-decentraland1.vercel.app

Please sign in to comment.