Skip to content
Snippets Groups Projects
Commit 76161874 authored by Sameer Al-Sakran's avatar Sameer Al-Sakran
Browse files

pull complicated logic outside of the template

parent 85fe2f01
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,22 @@ const isGuideEmpty = ({
important_tables && important_tables.length !== 0 ? false :
true;
const exploreLinksForMetric = (metricId, guide, metadataFields, tables) => {
if (guide.metric_important_fields[metricId]) {
return guide.metric_important_fields[metricId]
.map(fieldId => metadataFields[fieldId])
.map(field => ({
name: field.display_name || field.name,
url: getQuestionUrl({
dbId: tables[field.table_id] && tables[field.table_id].db_id,
tableId: field.table_id,
fieldId: field.id,
metricId
})
}))
}
}
const mapStateToProps = (state, props) => ({
guide: getGuide(state, props),
user: getUser(state, props),
......@@ -162,19 +178,7 @@ export default class GettingStartedGuide extends Component {
type="metric"
entity={metrics[metricId]}
tables={tables}
exploreLinks={guide.metric_important_fields[metricId] &&
guide.metric_important_fields[metricId]
.map(fieldId => metadataFields[fieldId])
.map(field => ({
name: field.display_name || field.name,
url: getQuestionUrl({
dbId: tables[field.table_id] && tables[field.table_id].db_id,
tableId: field.table_id,
fieldId: field.id,
metricId
})
}))
}
exploreLinks={exploreLinksForMetric(metricId, guide, metadataFields, tables)}
/>
)}
</div>
......
......@@ -60,8 +60,8 @@ export default class GettingStartedGuideContainer extends Component {
<div>
{ this.props.isEditing ?
<GettingStartedGuideEditForm {...this.props} /> :
<GettingStartedGuide {...this.props} />
<GettingStartedGuideEditForm {...this.props} /> :
<GettingStartedGuide {...this.props} />
}
</div>
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment