-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
738 additions
and
197 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import { connect } from 'react-redux' | ||
import { push } from 'connected-react-router' | ||
import { getIsWorldContributorEnabled } from 'modules/features/selectors' | ||
import { RootState } from 'modules/common/types' | ||
import NameTabs from './NameTabs' | ||
import { MapDispatch, MapDispatchProps } from './NameTabs.types' | ||
|
||
const mapState = (state: RootState) => { | ||
return { | ||
isWorldContributorEnabled: getIsWorldContributorEnabled(state) | ||
} | ||
} | ||
|
||
const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => { | ||
return { | ||
onNavigate: to => dispatch(push(to)) | ||
} | ||
} | ||
|
||
export default connect(null, mapDispatch)(NameTabs) | ||
export default connect(mapState, mapDispatch)(NameTabs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/components/WorldListPage/WorldContributorTab/WorldContributorTab.container.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { connect } from 'react-redux' | ||
import { push } from 'connected-react-router' | ||
import { isLoadingType } from 'decentraland-dapps/dist/modules/loading' | ||
import { getContributableNamesList, getLoading as getLoadingENS, getContributableNamesError } from 'modules/ens/selectors' | ||
import { RootState } from 'modules/common/types' | ||
import { getDeploymentsByWorlds, getLoading as getDeploymentLoading } from 'modules/deployment/selectors' | ||
import { getProjects } from 'modules/ui/dashboard/selectors' | ||
import { FETCH_WORLD_DEPLOYMENTS_REQUEST, clearDeploymentRequest } from 'modules/deployment/actions' | ||
import { FETCH_CONTRIBUTABLE_NAMES_REQUEST } from 'modules/ens/actions' | ||
import WorldContributorTab from './WorldContributorTab' | ||
import { MapStateProp, MapDispatch, MapDispatchProps } from './WorldContributorTab.types' | ||
|
||
const mapState = (state: RootState): MapStateProp => ({ | ||
items: getContributableNamesList(state), | ||
deploymentsByWorlds: getDeploymentsByWorlds(state), | ||
projects: getProjects(state), | ||
error: getContributableNamesError(state), | ||
loading: | ||
isLoadingType(getLoadingENS(state), FETCH_CONTRIBUTABLE_NAMES_REQUEST) || | ||
isLoadingType(getDeploymentLoading(state), FETCH_WORLD_DEPLOYMENTS_REQUEST) | ||
}) | ||
|
||
const mapDispatch = (dispatch: MapDispatch): MapDispatchProps => ({ | ||
onNavigate: path => dispatch(push(path)), | ||
onUnpublishWorld: deploymentId => dispatch(clearDeploymentRequest(deploymentId)) | ||
}) | ||
|
||
export default connect(mapState, mapDispatch)(WorldContributorTab) |
99 changes: 99 additions & 0 deletions
99
src/components/WorldListPage/WorldContributorTab/WorldContributorTab.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { t } from 'decentraland-dapps/dist/modules/translation' | ||
import { Loader, Message, Table, Empty, Button } from 'decentraland-ui' | ||
import { formatNumber } from 'decentraland-dapps/dist/lib' | ||
import { useCallback } from 'react' | ||
import { config } from 'config' | ||
import { locations } from 'routing/locations' | ||
import Profile from 'components/Profile' | ||
import { ENS } from 'modules/ens/types' | ||
import { fromBytesToMegabytes, renderPublishSceneButton, renderWorldUrl } from '../utils' | ||
import { Props } from './WorldContributorTab.types' | ||
|
||
export default function WorldContributorTab({ items, deploymentsByWorlds, projects, loading, error, onNavigate, onUnpublishWorld }: Props) { | ||
const handlePublishScene = useCallback(() => { | ||
onNavigate(locations.scenes()) | ||
}, [onNavigate]) | ||
|
||
const handleEditScene = useCallback( | ||
(ens: ENS) => { | ||
const { projectId } = deploymentsByWorlds[ens.subdomain] | ||
onNavigate(locations.sceneDetail(projectId as string)) | ||
}, | ||
[deploymentsByWorlds, locations, onNavigate] | ||
) | ||
|
||
const handleUnpublishScene = useCallback( | ||
(ens: ENS) => { | ||
const deploymentId = deploymentsByWorlds[ens.subdomain]?.id | ||
if (deploymentId) { | ||
onUnpublishWorld(deploymentId) | ||
} | ||
}, | ||
[deploymentsByWorlds, onUnpublishWorld] | ||
) | ||
|
||
if (error) { | ||
return <Message error size="tiny" visible content={error.message} header={t('worlds_list_page.error_title')} /> | ||
} | ||
|
||
if (loading) { | ||
return <Loader active size="big" /> | ||
} | ||
|
||
if (!items.length) { | ||
return ( | ||
<Empty className="empty-names-container" height={500}> | ||
<div className="empty-icon dcl-icon" /> | ||
<div className="empty-title">{t('worlds_list_page.empty_contributor_list.title')}</div> | ||
<div className="empty-description"> | ||
{t('worlds_list_page.empty_contributor_list.description', { b: (text: string) => <b>{text}</b> })} | ||
</div> | ||
<Button as="a" href={`${config.get('MARKETPLACE_WEB_URL')}/names/mint`} target="_blank" className="empty-action" primary> | ||
{t('worlds_list_page.empty_list.cta')} | ||
</Button> | ||
</Empty> | ||
) | ||
} | ||
|
||
return ( | ||
<Table basic="very"> | ||
<Table.Header> | ||
<Table.Row> | ||
<Table.HeaderCell width="1">{t('worlds_list_page.table.name')}</Table.HeaderCell> | ||
<Table.HeaderCell width="1">{t('worlds_list_page.table.owner')}</Table.HeaderCell> | ||
<Table.HeaderCell width="2">{t('worlds_list_page.table.url')}</Table.HeaderCell> | ||
<Table.HeaderCell width="1">{t('worlds_list_page.table.published_scene')}</Table.HeaderCell> | ||
<Table.HeaderCell width="1">{t('worlds_list_page.table.size')}</Table.HeaderCell> | ||
<Table.HeaderCell width="1">{t('worlds_list_page.table.permissions')}</Table.HeaderCell> | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
{items.map((ens: ENS, index) => { | ||
const canUserDeploy = ens.userPermissions?.includes('deployment') | ||
const userPermissions = ens.userPermissions | ||
?.map(permission => t(`worlds_list_page.table.user_permissions.${permission}`)) | ||
.join('/') | ||
return ( | ||
<Table.Row className="TableRow" key={index}> | ||
<Table.Cell width={1}>{ens.name}</Table.Cell> | ||
<Table.Cell width={1}>{<Profile address={ens.nftOwnerAddress || ''} />}</Table.Cell> | ||
<Table.Cell width={2}>{renderWorldUrl(deploymentsByWorlds, ens)}</Table.Cell> | ||
<Table.Cell width={1}> | ||
{renderPublishSceneButton({ | ||
deploymentsByWorlds, | ||
ens, | ||
projects, | ||
onEditScene: canUserDeploy ? handleEditScene : undefined, | ||
onPublishScene: canUserDeploy ? handlePublishScene : undefined, | ||
onUnpublishScene: canUserDeploy ? handleUnpublishScene : undefined | ||
})} | ||
</Table.Cell> | ||
<Table.Cell width={1}>{formatNumber(fromBytesToMegabytes(Number(ens.size) || 0))}</Table.Cell> | ||
<Table.Cell width={1}>{userPermissions}</Table.Cell> | ||
</Table.Row> | ||
) | ||
})} | ||
</Table.Body> | ||
</Table> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/components/WorldListPage/WorldContributorTab/WorldContributorTab.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Dispatch } from 'redux' | ||
import { Deployment } from 'modules/deployment/types' | ||
import { ENS, ENSError } from 'modules/ens/types' | ||
import { Project } from 'modules/project/types' | ||
import { clearDeploymentRequest } from 'modules/deployment/actions' | ||
|
||
export type Props = { | ||
items: ENS[] | ||
projects: Project[] | ||
deploymentsByWorlds: Record<string, Deployment> | ||
loading: boolean | ||
error: ENSError | null | ||
onNavigate: (path: string) => void | ||
onUnpublishWorld: typeof clearDeploymentRequest | ||
} | ||
|
||
export type MapStateProp = Pick<Props, 'items' | 'deploymentsByWorlds' | 'projects' | 'loading' | 'error'> | ||
|
||
export type MapDispatchProps = Pick<Props, 'onNavigate' | 'onUnpublishWorld'> | ||
export type MapDispatch = Dispatch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import WorldContributorTab from './WorldContributorTab.container' | ||
|
||
export default WorldContributorTab |
Oops, something went wrong.