Skip to content
Snippets Groups Projects
Unverified Commit 484f345b authored by Nick Fitzpatrick's avatar Nick Fitzpatrick Committed by GitHub
Browse files

Save on AdHoc Question Title Click (#23470)

parent 8e916de7
No related branches found
No related tags found
No related merge requests found
...@@ -161,7 +161,7 @@ function getDataSourceParts({ question, subHead, isObjectDetail }) { ...@@ -161,7 +161,7 @@ function getDataSourceParts({ question, subHead, isObjectDetail }) {
const database = query.database(); const database = query.database();
if (database) { if (database) {
parts.push({ parts.push({
icon: "database", icon: !subHead ? "database" : undefined,
name: database.displayName(), name: database.displayName(),
href: database.id >= 0 && Urls.browseDatabase(database), href: database.id >= 0 && Urls.browseDatabase(database),
}); });
......
...@@ -7,10 +7,13 @@ import QuestionDataSource from "./QuestionDataSource"; ...@@ -7,10 +7,13 @@ import QuestionDataSource from "./QuestionDataSource";
import StructuredQuery from "metabase-lib/lib/queries/StructuredQuery"; import StructuredQuery from "metabase-lib/lib/queries/StructuredQuery";
import { AggregationAndBreakoutDescription } from "./QuestionDescription.styled";
const QuestionDescription = ({ const QuestionDescription = ({
question, question,
originalQuestion, originalQuestion,
isObjectDetail, isObjectDetail,
onClick,
}) => { }) => {
const query = question.query(); const query = question.query();
if (query instanceof StructuredQuery) { if (query instanceof StructuredQuery) {
...@@ -39,14 +42,14 @@ const QuestionDescription = ({ ...@@ -39,14 +42,14 @@ const QuestionDescription = ({
breakouts.length, breakouts.length,
) )
: breakouts.map(breakout => breakout.displayName()).join(t` and `); : breakouts.map(breakout => breakout.displayName()).join(t` and `);
if (aggregationDescription && breakoutDescription) { if (aggregationDescription || breakoutDescription) {
return ( return (
<span>{t`${aggregationDescription} by ${breakoutDescription}`}</span> <AggregationAndBreakoutDescription onClick={onClick}>
{[aggregationDescription, breakoutDescription]
.filter(Boolean)
.join(t` by `)}
</AggregationAndBreakoutDescription>
); );
} else if (aggregationDescription) {
return <span>{aggregationDescription}</span>;
} else if (breakoutDescription) {
return <span>{breakoutDescription}</span>;
} }
} }
if (question.database()) { if (question.database()) {
......
import styled from "@emotion/styled";
export const AggregationAndBreakoutDescription = styled.span`
cursor: pointer;
`;
...@@ -242,6 +242,7 @@ AhHocQuestionLeftSide.propTypes = { ...@@ -242,6 +242,7 @@ AhHocQuestionLeftSide.propTypes = {
isNative: PropTypes.bool, isNative: PropTypes.bool,
isObjectDetail: PropTypes.bool, isObjectDetail: PropTypes.bool,
isSummarized: PropTypes.bool, isSummarized: PropTypes.bool,
onOpenModal: PropTypes.func,
}; };
function AhHocQuestionLeftSide(props) { function AhHocQuestionLeftSide(props) {
...@@ -251,11 +252,14 @@ function AhHocQuestionLeftSide(props) { ...@@ -251,11 +252,14 @@ function AhHocQuestionLeftSide(props) {
isNative, isNative,
isObjectDetail, isObjectDetail,
isSummarized, isSummarized,
onOpenModal,
} = props; } = props;
const handleTitleClick = () => onOpenModal(MODAL_TYPES.SAVE);
return ( return (
<div> <div>
<ViewHeaderMainLeftContentContainer> <ViewHeaderMainLeftContentContainer>
<AdHocViewHeading> <AdHocViewHeading color="medium">
{isNative ? ( {isNative ? (
t`New question` t`New question`
) : ( ) : (
...@@ -263,6 +267,7 @@ function AhHocQuestionLeftSide(props) { ...@@ -263,6 +267,7 @@ function AhHocQuestionLeftSide(props) {
question={question} question={question}
originalQuestion={originalQuestion} originalQuestion={originalQuestion}
isObjectDetail={isObjectDetail} isObjectDetail={isObjectDetail}
onClick={handleTitleClick}
/> />
)} )}
</AdHocViewHeading> </AdHocViewHeading>
...@@ -414,24 +419,6 @@ function ViewTitleHeaderRightSide(props) { ...@@ -414,24 +419,6 @@ function ViewTitleHeaderRightSide(props) {
className="ml-auto flex align-center" className="ml-auto flex align-center"
data-testid="qb-header-action-panel" data-testid="qb-header-action-panel"
> >
{hasSaveButton && (
<SaveButton
disabled={!question.canRun() || !canEditQuery}
tooltip={{
tooltip: t`You don't have permission to save this question.`,
isEnabled: !canEditQuery,
placement: "left",
}}
data-metabase-event={
isShowingNotebook
? `Notebook Mode; Click Save`
: `View Mode; Click Save`
}
onClick={() => onOpenModal("save")}
>
{t`Save`}
</SaveButton>
)}
{QuestionFilters.shouldRender(props) && ( {QuestionFilters.shouldRender(props) && (
<FilterHeaderToggle <FilterHeaderToggle
className="ml2 mr1" className="ml2 mr1"
...@@ -523,6 +510,24 @@ function ViewTitleHeaderRightSide(props) { ...@@ -523,6 +510,24 @@ function ViewTitleHeaderRightSide(props) {
onModelPersistenceChange={onModelPersistenceChange} onModelPersistenceChange={onModelPersistenceChange}
/> />
)} )}
{hasSaveButton && (
<SaveButton
disabled={!question.canRun() || !canEditQuery}
tooltip={{
tooltip: t`You don't have permission to save this question.`,
isEnabled: !canEditQuery,
placement: "left",
}}
data-metabase-event={
isShowingNotebook
? `Notebook Mode; Click Save`
: `View Mode; Click Save`
}
onClick={() => onOpenModal("save")}
>
{t`Save`}
</SaveButton>
)}
</div> </div>
); );
} }
......
...@@ -26,10 +26,6 @@ export const ViewHeaderLeftSubHeading = styled(ViewSubHeading)` ...@@ -26,10 +26,6 @@ export const ViewHeaderLeftSubHeading = styled(ViewSubHeading)`
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
&:not(:empty) {
margin-top: ${space(0)};
}
`; `;
export const AdHocViewHeading = styled(ViewHeading)` export const AdHocViewHeading = styled(ViewHeading)`
......
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