Skip to content

Commit

Permalink
Remove version chooser
Browse files Browse the repository at this point in the history
  • Loading branch information
dana-cfc4 committed Jan 23, 2023
1 parent 03216e3 commit 34ceaf9
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 97 deletions.
11 changes: 4 additions & 7 deletions src/Blocks/EmbedEEATableauBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const View = (props) => {
const data = React.useMemo(() => props.data || {}, [props.data]);
const { vis_url = '' } = data;
const show_sources = data?.show_sources ?? false;
const version = '2.8.0';

React.useEffect(() => {
if (vis_url) {
Expand All @@ -36,15 +37,13 @@ const View = (props) => {
<PrivacyProtection data={data} {...props}>
{data?.vis_url ? (
<>
{tableau_visualization?.general?.url &&
tableau_visualization?.general?.version ? (
{tableau_visualization?.general?.url ? (
<>
<div className="tableau-block">
{props.mode === 'edit' ? (
<div className="tableau-info">
<h3 className="tableau-version">
== Tableau {tableau_visualization?.general?.version}{' '}
loaded ==
== Tableau {version} loaded ==
</h3>
</div>
) : (
Expand All @@ -69,9 +68,7 @@ const View = (props) => {
</>
) : !tableau_visualization?.general?.url ? (
<div>Url is not set in the visualization</div>
) : (
<div>Version is not set in the visualization</div>
)}
) : null}
</>
) : (
<div>Please select a visualization from block editor.</div>
Expand Down
1 change: 0 additions & 1 deletion src/ConnectedTableau/ConnectedTableau.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const ConnectedTableau = (props) => {
setLoaded={setLoaded}
data={{ ...props?.general, ...props?.options, ...props?.extraOptions }}
url={props?.general?.url}
version={props?.general?.version}
{...props}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Tableau/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Tableau = (props) => {
screen = {},
setError = () => {},
setLoaded = () => {},
version = '',
version = '2.8.0',
} = props;
const {
autoScale = false,
Expand Down
13 changes: 3 additions & 10 deletions src/TableauBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ const View = (props) => {
description = null,
autoScale = false,
} = data;
const version = props.data.version || config.settings.tableauVersion;
const device = getDevice(config, screen.page?.width || Infinity);
const breakpointUrl = breakpointUrls.filter(
(breakpoint) => breakpoint.device === device,
)[0]?.url;
const url = breakpointUrl || data.url;

const displayCondition = url && version;
const version = '2.8.0';

React.useEffect(() => {
setMounted(true);
Expand Down Expand Up @@ -69,15 +67,10 @@ const View = (props) => {
return mounted ? (
<div className="tableau-block">
<div className="tableau-info">
{displayCondition && props.mode === 'edit' ? (
{url && props.mode === 'edit' ? (
<h3 className="tableau-version">== Tableau {version} loaded ==</h3>
) : null}
{!url ? <p className="tableau-error">URL required</p> : ''}
{url && !version ? (
<p className="tableau-error">Version required</p>
) : (
''
)}
{error ? <p className="tableau-error">{error}</p> : ''}
</div>

Expand All @@ -87,7 +80,7 @@ const View = (props) => {
) : (
''
)}
{displayCondition ? (
{url ? (
<Tableau
{...props}
canUpdateUrl={!breakpointUrl}
Expand Down
22 changes: 2 additions & 20 deletions src/TableauBlock/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default (config) => ({
{
id: 'default',
title: 'Default',
fields: ['version', 'url', 'title', 'description'],
fields: ['url', 'title', 'description'],
},
{
id: 'options',
Expand All @@ -66,24 +66,6 @@ export default (config) => ({
},
],
properties: {
version: {
title: 'Version',
type: 'array',
choices: [
...[
'2.8.0',
'2.7.0',
'2.6.0',
'2.5.0',
'2.4.0',
'2.3.0',
'2.2.2',
'2.1.2',
'2.0.3',
].map((version) => [version, `tableau-${version}`]),
],
default: config.settings.tableauVersion,
},
url: {
title: 'Url',
widget: 'textarea',
Expand Down Expand Up @@ -138,5 +120,5 @@ export default (config) => ({
description: 'Set different vizualization for specific breakpoint',
},
},
required: ['version', 'url'],
required: ['url'],
});
6 changes: 1 addition & 5 deletions src/Views/VisualizationView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const VisualizationView = (props) => {
<div className="tableau-info">
{!tableau_visualization_data.general?.url ? (
<p className="tableau-error">URL required</p>
) : !tableau_visualization_data.general?.version ? (
<p className="tableau-error">Version required</p>
) : tableauError ? (
<p className="tableau-error">{tableauError}</p>
) : (
Expand All @@ -25,9 +23,7 @@ const VisualizationView = (props) => {
};
return (
<div>
{!tableau_visualization_data?.general?.url ||
!tableau_visualization_data?.general?.version ||
tableauError ? (
{!tableau_visualization_data?.general?.url || tableauError ? (
<TableauNotDisplayed />
) : (
<TableauView
Expand Down
27 changes: 10 additions & 17 deletions src/Widgets/VisualizationWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const VisualizationWidget = (props) => {
<div className="tableau-info">
{intValue && intValue.general && !intValue.general.url ? (
<p className="tableau-error">URL required</p>
) : intValue && intValue.general && !intValue.general.version ? (
<p className="tableau-error">Version required</p>
) : tableauError ? (
<p className="tableau-error">{tableauError}</p>
) : (
Expand All @@ -55,15 +53,14 @@ const VisualizationWidget = (props) => {
let schema = Schema(config);

React.useEffect(() => {
if (!intValue?.general || !intValue?.general?.version) {
setIntValue({
...intValue,
general: {
url: intValue?.general?.url,
version: '',
},
});
}
// if (!intValue?.general) {
// setIntValue({
// ...intValue,
// general: {
// url: intValue?.general?.url,
// },
// });
// }
if (!intValue?.options) {
setIntValue({
...intValue,
Expand Down Expand Up @@ -118,9 +115,7 @@ const VisualizationWidget = (props) => {
/>
</Grid.Column>
<Grid.Column mobile={12} tablet={12} computer={7}>
{(intValue &&
intValue.general &&
(!intValue.general.url || !intValue.general.version)) ||
{(intValue && intValue.general && !intValue.general.url) ||
tableauError ? (
<TableauNotDisplayed />
) : (
Expand Down Expand Up @@ -152,9 +147,7 @@ const VisualizationWidget = (props) => {
</Modal.Actions>
</Modal>
)}
{(intValue &&
intValue.general &&
(!intValue.general.url || !intValue.general.version)) ||
{(intValue && intValue.general && !intValue.general.url) ||
tableauError ? (
<TableauNotDisplayed />
) : (
Expand Down
52 changes: 16 additions & 36 deletions src/Widgets/schema.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
const generalSchema = (config) => {
return {
title: 'General',
const generalSchema = {
title: 'General',

fieldsets: [
{
id: 'general',
title: 'General',
fields: ['version', 'url'],
},
],
fieldsets: [
{
id: 'general',
title: 'General',
fields: ['url'],
},
],

properties: {
version: {
title: 'Version',
type: 'array',
choices: [
...[
'2.8.0',
'2.7.0',
'2.6.0',
'2.5.0',
'2.4.0',
'2.3.0',
'2.2.2',
'2.1.2',
'2.0.3',
].map((version) => [version, `tableau-${version}`]),
],
default: config.settings.tableauVersion,
},
url: {
title: 'Url',
type: 'textarea',
},
properties: {
url: {
title: 'Url',
type: 'textarea',
},
required: ['url', 'version'],
};
},
required: ['url'],
};

const optionsSchema = {
Expand Down Expand Up @@ -186,7 +166,7 @@ export default (config) => {
schemas: [
{
id: 'general',
schema: generalSchema(config),
schema: generalSchema,
},
{
id: 'options',
Expand Down

0 comments on commit 34ceaf9

Please sign in to comment.