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 }) {
const database = query.database();
if (database) {
parts.push({
icon: "database",
icon: !subHead ? "database" : undefined,
name: database.displayName(),
href: database.id >= 0 && Urls.browseDatabase(database),
});
......
......@@ -7,10 +7,13 @@ import QuestionDataSource from "./QuestionDataSource";
import StructuredQuery from "metabase-lib/lib/queries/StructuredQuery";
import { AggregationAndBreakoutDescription } from "./QuestionDescription.styled";
const QuestionDescription = ({
question,
originalQuestion,
isObjectDetail,
onClick,
}) => {
const query = question.query();
if (query instanceof StructuredQuery) {
......@@ -39,14 +42,14 @@ const QuestionDescription = ({
breakouts.length,
)
: breakouts.map(breakout => breakout.displayName()).join(t` and `);
if (aggregationDescription && breakoutDescription) {
if (aggregationDescription || breakoutDescription) {
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()) {
......
import styled from "@emotion/styled";
export const AggregationAndBreakoutDescription = styled.span`
cursor: pointer;
`;
......@@ -242,6 +242,7 @@ AhHocQuestionLeftSide.propTypes = {
isNative: PropTypes.bool,
isObjectDetail: PropTypes.bool,
isSummarized: PropTypes.bool,
onOpenModal: PropTypes.func,
};
function AhHocQuestionLeftSide(props) {
......@@ -251,11 +252,14 @@ function AhHocQuestionLeftSide(props) {
isNative,
isObjectDetail,
isSummarized,
onOpenModal,
} = props;
const handleTitleClick = () => onOpenModal(MODAL_TYPES.SAVE);
return (
<div>
<ViewHeaderMainLeftContentContainer>
<AdHocViewHeading>
<AdHocViewHeading color="medium">
{isNative ? (
t`New question`
) : (
......@@ -263,6 +267,7 @@ function AhHocQuestionLeftSide(props) {
question={question}
originalQuestion={originalQuestion}
isObjectDetail={isObjectDetail}
onClick={handleTitleClick}
/>
)}
</AdHocViewHeading>
......@@ -414,24 +419,6 @@ function ViewTitleHeaderRightSide(props) {
className="ml-auto flex align-center"
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) && (
<FilterHeaderToggle
className="ml2 mr1"
......@@ -523,6 +510,24 @@ function ViewTitleHeaderRightSide(props) {
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>
);
}
......
......@@ -26,10 +26,6 @@ export const ViewHeaderLeftSubHeading = styled(ViewSubHeading)`
display: flex;
align-items: center;
flex-wrap: wrap;
&:not(:empty) {
margin-top: ${space(0)};
}
`;
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