-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to declare "embed" content to be displayed as iframe #556
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
src/modules/RA/DataLayer/components/tabs/EmbedTab/EmbedConfigField.js
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,35 @@ | ||
import React from 'react'; | ||
import { | ||
useTranslate, | ||
useInput, | ||
ArrayInput, | ||
SimpleFormIterator, | ||
} from 'react-admin'; | ||
import Typography from '@material-ui/core/Typography'; | ||
|
||
import EmbedItemInput from './EmbedItemInput'; | ||
|
||
const EmbedConfigField = ({ label, ...rest }) => { | ||
const translate = useTranslate(); | ||
const { | ||
meta: { error }, | ||
} = useInput(rest); | ||
|
||
return ( | ||
<> | ||
<Typography variant="h5" component="h2">{translate(label)}</Typography> | ||
|
||
{error && error.length > 0 && error.flatMap(err => | ||
err && Object.entries(err).map(([key, value]) => ( | ||
<Typography color="error">{key}: {translate(value)}</Typography>)))} | ||
|
||
<ArrayInput source="settings.embed" label=""> | ||
<SimpleFormIterator> | ||
<EmbedItemInput /> | ||
</SimpleFormIterator> | ||
</ArrayInput> | ||
</> | ||
); | ||
}; | ||
|
||
export default EmbedConfigField; |
101 changes: 101 additions & 0 deletions
101
src/modules/RA/DataLayer/components/tabs/EmbedTab/EmbedItemInput.js
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,101 @@ | ||
import React from 'react'; | ||
import { SelectInput, TextInput } from 'react-admin'; | ||
|
||
import { Icon } from '@blueprintjs/core'; | ||
|
||
const bpIcons = [ | ||
'chart', | ||
'curved-range-chart', | ||
'database', | ||
'diagram-tree', | ||
'doughnut-chart', | ||
'flow-branch', | ||
'flow-end', | ||
'flow-linear', | ||
'flow-review', | ||
'flow-review-branch', | ||
'flows', | ||
'form', | ||
'full-stacked-chart', | ||
'gantt-chart', | ||
'graph', | ||
'grid', | ||
'grouped-bar-chart', | ||
'heat-grid', | ||
'heatmap', | ||
'horizontal-bar-chart', | ||
'horizontal-bar-chart-asc', | ||
'horizontal-bar-chart-desc', | ||
'layout', | ||
'layout-auto', | ||
'layout-balloon', | ||
'layout-circle', | ||
'layout-grid', | ||
'layout-group-by', | ||
'layout-hierarchy', | ||
'layout-linear', | ||
'layout-skew-grid', | ||
'layout-sorted-clusters', | ||
'many-to-many', | ||
'many-to-one', | ||
'one-to-many', | ||
'one-to-one', | ||
'pie-chart', | ||
'polygon-filter', | ||
'regression-chart', | ||
'scatter-plot', | ||
'series-add', | ||
'series-configuration', | ||
'series-derived', | ||
'series-filtered', | ||
'series-search', | ||
'stacked-chart', | ||
'step-chart', | ||
'timeline-area-chart', | ||
'timeline-bar-chart', | ||
'timeline-line-chart', | ||
'trending-down', | ||
'trending-up', | ||
'vertical-bar-chart-asc', | ||
'vertical-bar-chart-desc', | ||
'waterfall-chart', | ||
].sort(); | ||
|
||
const EmbedItemInput = ({ source }) => { | ||
const iconChoices = React.useMemo( | ||
() => bpIcons.map(bpIcon => ({ | ||
id: bpIcon, | ||
name: <><Icon icon={bpIcon} style={{ marginRight: '1em' }} /> {bpIcon}</>, | ||
})), | ||
[], | ||
); | ||
|
||
return ( | ||
<div style={{ display: 'flex', alignItems: 'flex-start', gap: '1em' }}> | ||
<SelectInput | ||
source={`${source}.icon`} | ||
label="datalayer.form.embed.icon" | ||
choices={iconChoices} | ||
translateChoice={false} | ||
helperText={false} | ||
/> | ||
|
||
<TextInput | ||
label="datalayer.form.embed.title" | ||
source={`${source}.title`} | ||
type="text" | ||
helperText="datalayer.form.embed.title-help" | ||
/> | ||
|
||
<TextInput | ||
label="datalayer.form.embed.src" | ||
source={`${source}.src`} | ||
type="url" | ||
placeholder="https://myiframe.page" | ||
helperText="datalayer.form.embed.src-help" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EmbedItemInput; |
70 changes: 70 additions & 0 deletions
70
src/modules/RA/DataLayer/components/tabs/EmbedTab/index.js
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,70 @@ | ||
import React from 'react'; | ||
|
||
import { BooleanInput, useTranslate } from 'react-admin'; | ||
import { useField } from 'react-final-form'; | ||
|
||
import Typography from '@material-ui/core/Typography'; | ||
import Placeholder from '../../../../../../components/Placeholder'; | ||
|
||
import EmbedConfigField from './EmbedConfigField'; | ||
|
||
const validateEmbedFields = data => { | ||
const valid = !data.some(({ label }) => label && !label.length); | ||
if (!valid) { | ||
return 'datalayer.form.embed.row-in-error'; | ||
} | ||
return undefined; | ||
}; | ||
|
||
const EmbedConfigTabContent = props => { | ||
const { input: { value: embedEnable, onChange: onEmbedEnableChange } } = useField('settings.embed_enable'); | ||
const { input: { value: source } } = useField('source'); | ||
const { input: { value: embedExportEnable } } = useField('embed_export_enable'); | ||
const translate = useTranslate(); | ||
|
||
if (!source) { | ||
return ( | ||
<Placeholder> | ||
<Typography variant="h5" component="h2"> | ||
{translate('datalayer.form.embed.no-source')} | ||
</Typography> | ||
</Placeholder> | ||
); | ||
} | ||
|
||
// No embed yet | ||
if (!embedEnable) { | ||
return ( | ||
<Placeholder> | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: '1em', alignItems: 'center' }}> | ||
<Typography variant="h5" component="h2">{translate('datalayer.form.embed.no-embed')}</Typography> | ||
<BooleanInput | ||
source="settings.embed_enable" | ||
label="datalayer.form.embed.allow" | ||
onChange={onEmbedEnableChange} | ||
/> | ||
</div> | ||
</Placeholder> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<BooleanInput | ||
source="settings.embed_enable" | ||
label="datalayer.form.embed.allow-display-data-embed" | ||
onChange={onEmbedEnableChange} | ||
/> | ||
<EmbedConfigField | ||
source="fields" | ||
label="datalayer.form.embed.all-fields" | ||
exportEnabled={embedExportEnable} | ||
validate={validateEmbedFields} | ||
{...props} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
|
||
export default EmbedConfigTabContent; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have this in a seperate file? A list of all usable bp icons is not a bad idea and could be used elsewhere