Skip to content

Commit

Permalink
hooks up section selector usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed Oct 11, 2021
1 parent a683573 commit e1694f6
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions packages/cms/src/story/StorySectionEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import deepClone from "../utils/deepClone";

import {newEntity, updateEntity} from "../actions/profiles";

import {SELECTOR_TYPES} from "../utils/consts/cms";

class StorySectionEditor extends Component {

constructor(props) {
Expand Down Expand Up @@ -54,12 +56,22 @@ class StorySectionEditor extends Component {

render() {

const {minData, children} = this.props;
const {allSelectors, minData, children, variables} = this.props;
const {localeDefault, localeSecondary} = this.props.status;

const minDataState = this.state.minData;

if (!minData || !minDataState) return <Loading />;

const dataLoaded = minData && minDataState;
const varsLoaded = variables;
const defLoaded = localeSecondary || variables && !localeSecondary && variables[localeDefault];
const locLoaded = !localeSecondary || variables && localeSecondary && variables[localeDefault] && variables[localeSecondary];

if (!dataLoaded) return <Loading />;

const allLoaded = dataLoaded && varsLoaded && defLoaded && locLoaded;

const typeOptions = minData.types.map(t =>
<option key={t} value={t}>{t}</option>
);
Expand Down Expand Up @@ -120,6 +132,16 @@ class StorySectionEditor extends Component {
)}
/>

{allSelectors && allSelectors.length > 0 && allLoaded &&
<Deck title="Selector activation" entity="selectorUsage">
<SelectorUsage
key="selector-usage"
type={SELECTOR_TYPES.STORYSECTION_SELECTOR}
minData={minData}
/>
</Deck>
}

{/* Stats */}
<Deck
title="Stats"
Expand Down Expand Up @@ -173,8 +195,10 @@ class StorySectionEditor extends Component {
}

const mapStateToProps = (state, ownProps) => ({
variables: state.cms.variables,
status: state.cms.status,
minData: state.cms.stories.find(p => p.id === state.cms.status.currentStoryPid).storysections.find(s => s.id === ownProps.id)
minData: state.cms.stories.find(p => p.id === state.cms.status.currentStoryPid).storysections.find(s => s.id === ownProps.id),
allSelectors: state.cms.stories.find(p => p.id === state.cms.status.currentStoryPid).selectors
});

const mapDispatchToProps = dispatch => ({
Expand Down

0 comments on commit e1694f6

Please sign in to comment.