New source found from dndbeyond.com
This commit is contained in:
@@ -2,13 +2,10 @@ import { orderBy } from "lodash";
|
||||
import React from "react";
|
||||
import { useContext } from "react";
|
||||
import { connect, DispatchProp } from "react-redux";
|
||||
import { AnyAction } from "redux";
|
||||
|
||||
import { Collapsible } from "@dndbeyond/character-components/es";
|
||||
import {
|
||||
ApiAdapterPromise,
|
||||
ApiAdapterRequestConfig,
|
||||
ApiResponse,
|
||||
BaseItemDefinitionContract,
|
||||
CharacterTheme,
|
||||
Constants,
|
||||
Container,
|
||||
@@ -36,6 +33,8 @@ import {
|
||||
CharacterCurrencyContract,
|
||||
FormatUtils,
|
||||
CoinManager,
|
||||
ItemPlanUtils,
|
||||
EntityUtils,
|
||||
} from "@dndbeyond/character-rules-engine/es";
|
||||
|
||||
import { EditableName } from "~/components/EditableName";
|
||||
@@ -67,7 +66,9 @@ import { AppNotificationUtils, PaneIdentifierUtils } from "../../../utils";
|
||||
import ItemDetailActions from "../../ItemDetailActions";
|
||||
import { CurrencyErrorTypeEnum } from "../CurrencyPane/CurrencyPaneConstants";
|
||||
|
||||
interface Props extends DispatchProp {
|
||||
// TODO: We are typing with AnyAction here to work around issues with UnknownAction, the type that was introduced in Redux 5.
|
||||
// If we decide to modernize to Redux 5, we will need to refactor much of the Rules Engine redux usage.
|
||||
interface Props extends DispatchProp<AnyAction> {
|
||||
weaponSpellDamageGroups: Array<WeaponSpellDamageGroup>;
|
||||
ruleData: RuleData;
|
||||
snippetData: SnippetData;
|
||||
@@ -75,7 +76,6 @@ interface Props extends DispatchProp {
|
||||
infusionChoiceLookup: InfusionChoiceLookup;
|
||||
identifiers: PaneIdentifiersContainer | null;
|
||||
isReadonly: boolean;
|
||||
proficiencyBonus: number;
|
||||
theme: CharacterTheme;
|
||||
containers: Array<Container>;
|
||||
globalModifiers: Array<Modifier>;
|
||||
@@ -343,6 +343,21 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
handleParentClick = (): void => {
|
||||
const { item } = this.state;
|
||||
const { paneHistoryPush } = this.props;
|
||||
if (item) {
|
||||
const itemPlan = item.getItemPlan();
|
||||
if (itemPlan) {
|
||||
const dataOrigin = ItemPlanUtils.getDataOrigin(itemPlan);
|
||||
let component = getDataOriginComponentInfo(dataOrigin);
|
||||
if (component.type !== PaneComponentEnum.ERROR_404) {
|
||||
paneHistoryPush(component.type, component.identifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { item, currentContainer, isCustomizeClosed } = this.state;
|
||||
const {
|
||||
@@ -352,7 +367,6 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
entityValueLookup,
|
||||
infusionChoiceLookup,
|
||||
isReadonly,
|
||||
proficiencyBonus,
|
||||
theme,
|
||||
containers,
|
||||
globalModifiers,
|
||||
@@ -360,7 +374,6 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
inventory,
|
||||
identifiers,
|
||||
partyInfo,
|
||||
inventoryManager,
|
||||
} = this.props;
|
||||
|
||||
if (currentContainer === null) {
|
||||
@@ -369,9 +382,12 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
|
||||
const shopOpenInitially = identifiers?.showAddItems ?? false;
|
||||
|
||||
const canCustomize = item
|
||||
? inventoryManager.canCustomizeItem(item.item)
|
||||
: false;
|
||||
let parentName: string | null = null;
|
||||
const itemPlan = item ? item.getItemPlan() : null;
|
||||
if (itemPlan) {
|
||||
const dataOrigin = ItemPlanUtils.getDataOrigin(itemPlan);
|
||||
parentName = EntityUtils.getDataOriginName(dataOrigin);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="ct-container-pane">
|
||||
@@ -379,6 +395,8 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
preview={
|
||||
<Preview imageUrl={item ? item.getAvatarUrl() : undefined} />
|
||||
}
|
||||
parent={parentName}
|
||||
onClick={this.handleParentClick}
|
||||
>
|
||||
{item ? (
|
||||
<EditableName onClick={this.handleOpenCustomize}>
|
||||
@@ -411,12 +429,12 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
entityValueLookup={entityValueLookup}
|
||||
infusionChoiceLookup={infusionChoiceLookup}
|
||||
isReadonly={isReadonly}
|
||||
proficiencyBonus={proficiencyBonus}
|
||||
showActions={false}
|
||||
showCustomize={canCustomize}
|
||||
showCustomize={!isReadonly}
|
||||
container={currentContainer.container}
|
||||
isCustomizeClosed={isCustomizeClosed}
|
||||
onCustomizeClick={this.handleOpenCustomize}
|
||||
partyInfo={partyInfo}
|
||||
/>
|
||||
</Collapsible>
|
||||
)}
|
||||
@@ -424,7 +442,6 @@ class ContainerPane extends React.PureComponent<Props, State> {
|
||||
currentContainer={currentContainer.container}
|
||||
containers={containers}
|
||||
ruleData={ruleData}
|
||||
proficiencyBonus={proficiencyBonus}
|
||||
theme={theme}
|
||||
globalModifiers={globalModifiers}
|
||||
valueLookupByType={valueLookupByType}
|
||||
@@ -484,7 +501,6 @@ function mapStateToProps(state: SharedAppState) {
|
||||
snippetData: rulesEngineSelectors.getSnippetData(state),
|
||||
infusionChoiceLookup: rulesEngineSelectors.getInfusionChoiceLookup(state),
|
||||
isReadonly: appEnvSelectors.getIsReadonly(state),
|
||||
proficiencyBonus: rulesEngineSelectors.getProficiencyBonus(state),
|
||||
theme: rulesEngineSelectors.getCharacterTheme(state),
|
||||
containers: rulesEngineSelectors.getInventoryContainers(state),
|
||||
globalModifiers: rulesEngineSelectors.getValidGlobalModifiers(state),
|
||||
|
||||
Reference in New Issue
Block a user