Skip to content

Commit

Permalink
pexdax refactor (#16333)
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi authored and eschutho committed Jan 12, 2022
1 parent 1183c00 commit f180e58
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import DeleteModal from 'src/components/DeleteModal';
import ReportModal from 'src/components/ReportModal';
import { ChartState } from 'src/explore/types';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import { fetchUISpecificReport } from 'src/reports/actions/reports';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';

const deleteColor = (theme: SupersetTheme) => css`
color: ${theme.colors.error.base};
Expand Down
60 changes: 29 additions & 31 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class Header extends React.PureComponent {
this.overwriteDashboard = this.overwriteDashboard.bind(this);
this.showPropertiesModal = this.showPropertiesModal.bind(this);
this.hidePropertiesModal = this.hidePropertiesModal.bind(this);
this.showReportModal = this.showReportModal.bind(this);
this.hideReportModal = this.hideReportModal.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -382,27 +384,6 @@ class Header extends React.PureComponent {
this.setState({ showingPropertiesModal: false });
}

<<<<<<< HEAD
canAddReports() {
if (!isFeatureEnabled(FeatureFlag.ALERT_REPORTS)) {
return false;
}
const { user } = this.props;
if (!user?.userId) {
// this is in the case that there is an anonymous user.
return false;
}
const roles = Object.keys(user.roles || []);
const permissions = roles.map(key =>
user.roles[key].filter(
perms => perms[0] === 'menu_access' && perms[1] === 'Manage',
),
);
return permissions[0].length > 0;
}

=======
>>>>>>> code dry (#16358)
render() {
const {
dashboardTitle,
Expand Down Expand Up @@ -578,16 +559,33 @@ class Header extends React.PureComponent {
</>
)}

<PropertiesModal
dashboardId={dashboardInfo.id}
dashboardInfo={dashboardInfo}
dashboardTitle={dashboardTitle}
show={this.state.showingPropertiesModal}
onHide={this.hidePropertiesModal}
colorScheme={this.props.colorScheme}
onSubmit={handleOnPropertiesChange}
onlyApply
/>
{this.state.showingPropertiesModal && (
<PropertiesModal
dashboardId={dashboardInfo.id}
show={this.state.showingPropertiesModal}
onHide={this.hidePropertiesModal}
colorScheme={this.props.colorScheme}
onSubmit={updates => {
const {
dashboardInfoChanged,
dashboardTitleChanged,
} = this.props;
dashboardInfoChanged({
slug: updates.slug,
metadata: JSON.parse(updates.jsonMetadata),
});
setColorSchemeAndUnsavedChanges(updates.colorScheme);
dashboardTitleChanged(updates.title);
if (updates.slug) {
window.history.pushState(
{ event: 'dashboard_properties_changed' },
'',
`/superset/dashboard/${updates.slug}/`,
);
}
}}
/>
)}

{this.state.showingReportModal && (
<ReportModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import PropTypes from 'prop-types';
import Icons from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
import ReportModal from 'src/components/ReportModal';
import {
CategoricalColorNamespace,
SupersetClient,
Expand Down

0 comments on commit f180e58

Please sign in to comment.