Skip to content

Commit

Permalink
Fix pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherCFleming committed Jan 14, 2022
1 parent 9978326 commit f0f42d1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,23 @@ const propTypes = {
templateParams: PropTypes.string,
};

function ExploreCtasResultsButton(props) {
function buildVizOptions() {
return {
datasourceName: props.table,
schema: props.schema,
dbId: props.dbId,
templateParams: props.templateParams,
};
}
const ExploreCtasResultsButton = ({
table,
schema,
dbId,
templateParams,
errorMessage,
actions: { createCtasDatasource, addInfoToast, addDangerToast },
}) => {
const buildVizOptions = {
datasourceName: table,
schema,
dbId,
templateParams,
};

function visualize() {
props.actions
.createCtasDatasource(buildVizOptions())
const visualize = () => {
createCtasDatasource(buildVizOptions())
.then(data => {
const formData = {
datasource: `${data.table_id}__table`,
Expand All @@ -58,42 +62,35 @@ function ExploreCtasResultsButton(props) {
all_columns: [],
row_limit: 1000,
};
props.actions.addInfoToast(
t('Creating a data source and creating a new tab'),
);
addInfoToast(t('Creating a data source and creating a new tab'));

// open new window for data visualization
exploreChart(formData);
})
.catch(() => {
props.actions.addDangerToast(
props.errorMessage || t('An error occurred'),
);
addDangerToast(errorMessage || t('An error occurred'));
});
}
};

function onClick() {
const onClick = () => {
visualize();
}
};

return (
<>
<Button
buttonSize="small"
onClick={onClick}
tooltip={t('Explore the result set in the data exploration view')}
>
<InfoTooltipWithTrigger
icon="line-chart"
placement="top"
label="explore"
/>{' '}
{/* NOTE TO SELF: Below, the text should be "Explore" instead of "This is the button" */}
{t('This Is the button')}
</Button>
</>
<Button
buttonSize="small"
onClick={onClick}
tooltip={t('Explore the result set in the data exploration view')}
>
<InfoTooltipWithTrigger
icon="line-chart"
placement="top"
label="explore"
/>{' '}
{t('Explore')}
</Button>
);
}
};
ExploreCtasResultsButton.propTypes = propTypes;

function mapStateToProps({ sqlLab, common }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ export default class ResultSet extends React.PureComponent<
if (query.ctas_method === CtasEnum.VIEW) {
object = 'View';
}

return (
<div>
<Alert
Expand Down

0 comments on commit f0f42d1

Please sign in to comment.