Skip to content
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

fix: Dashboard header negative margin on save #17690

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion superset-frontend/src/components/EditableTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
import React, { useEffect, useState, useRef } from 'react';
import cx from 'classnames';
import { t } from '@superset-ui/core';
import { styled, t } from '@superset-ui/core';
import { Tooltip } from 'src/components/Tooltip';
import CertifiedIcon from '../CertifiedIcon';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component probably shouldn't even exist, but that's a different discussion ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rusackas I think the name is misleading here. This is intended to be more than just an icon, it's more like a tiny component.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then maybe we can change the name to CertifiedBadge to avoid confusion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will open a separate PR


export interface EditableTitleProps {
canEdit?: boolean;
Expand All @@ -34,8 +35,14 @@ export interface EditableTitleProps {
title?: string;
defaultTitle?: string;
placeholder?: string;
certifiedBy?: string;
certificationDetails?: string;
}

const StyledCertifiedIcon = styled(CertifiedIcon)`
vertical-align: middle;
`;

export default function EditableTitle({
canEdit = false,
editing = false,
Expand All @@ -48,6 +55,8 @@ export default function EditableTitle({
title = '',
defaultTitle = '',
placeholder = '',
certifiedBy,
certificationDetails,
}: EditableTitleProps) {
const [isEditing, setIsEditing] = useState(editing);
const [currentTitle, setCurrentTitle] = useState(title);
Expand Down Expand Up @@ -222,6 +231,14 @@ export default function EditableTitle({
)}
style={style}
>
{certifiedBy && (
<>
<StyledCertifiedIcon
certifiedBy={certifiedBy}
details={certificationDetails}
/>{' '}
</>
)}
{titleComponent}
</span>
);
Expand Down
11 changes: 2 additions & 9 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import React from 'react';
import PropTypes from 'prop-types';
import { styled, t } from '@superset-ui/core';
import ButtonGroup from 'src/components/ButtonGroup';
import CertifiedIcon from 'src/components/CertifiedIcon';

import {
LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD,
Expand Down Expand Up @@ -499,19 +498,13 @@ class Header extends React.PureComponent {
data-test-id={`${dashboardInfo.id}`}
>
<div className="dashboard-component-header header-large">
{dashboardInfo.certified_by && (
<>
<CertifiedIcon
certifiedBy={dashboardInfo.certified_by}
details={dashboardInfo.certification_details}
/>{' '}
</>
)}
<EditableTitle
title={dashboardTitle}
canEdit={userCanEdit && editMode}
onSaveTitle={this.handleChangeText}
showTooltip={false}
certifiedBy={dashboardInfo.certified_by}
certificationDetails={dashboardInfo.certification_details}
/>
<PublishedStatus
dashboardId={dashboardInfo.id}
Expand Down