-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Published" feature to dashboards (#4725)
* Allow users to publish dashboards * Rework publish dashboards feature - The eye next to the title has been replaced with a [draft] badge - Published status is now toggled in the Header Action Dropdown - CRUD list shows published status * Fix linter errors * Update javascript tests * Add tests and change DashboardFilter Add some tests to make sure the published status is rendered and Make it so that users cannot see dashboards that are published if they don't have access to any of the slices within * Fix some linter errors * Remove commas from core.py * Fix some failing tests * More linter errors I introduced * Fix more linter errors I introduced * update alembic migration * Update design of publish dash feature * Upgrade migration version * Secure publish endpoint * Remove bad quotes * Give publish span its own style * fix publish rendering * Add new test for publish feature * Update migration * update slug in test * Update migration * Address reviwer comments * Fix linter errors * Add licenses * Remove fetchPublished(), use bootstrap data * Update migration * Update croniter to existing version * Fix linter errors * Upgrade DB Revisions * Fix flake8 linter error * Set all dashboards to published on migration * Migration proper line spacing * Fix migration to work with postgres * UPDATE statement works with postgresql and sqlite hopefully * Update wording to kick off travis
- Loading branch information
1 parent
8d81c30
commit 97ffb76
Showing
13 changed files
with
430 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
superset/assets/src/dashboard/components/PublishedStatus.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { t } from '@superset-ui/translation'; | ||
import TooltipWrapper from '../../components/TooltipWrapper'; | ||
|
||
const propTypes = { | ||
dashboardId: PropTypes.number.isRequired, | ||
isPublished: PropTypes.bool.isRequired, | ||
savePublished: PropTypes.func.isRequired, | ||
canEdit: PropTypes.bool.isRequired, | ||
canSave: PropTypes.bool.isRequired, | ||
}; | ||
|
||
const draftButtonTooltip = t( | ||
'This dashboard is not published, it will not show up in the list of dashboards. ' + | ||
'Click here to publish this dashboard.', | ||
); | ||
|
||
const draftDivTooltip = t( | ||
'This dashboard is not published which means it will not show up in the list of dashboards.' + | ||
' Favorite it to see it there or access it by using the URL directly.', | ||
); | ||
|
||
const publishedTooltip = t( | ||
'This dashboard is published. Click to make it a draft.', | ||
); | ||
|
||
const divStyle = { | ||
border: '1px dotted black', | ||
backgroundColor: '#F9F9F9', | ||
padding: '3px 7px 3px 7px', | ||
fontFamily: 'Monospace', | ||
fontSize: '16px', | ||
}; | ||
|
||
export default class PublishedStatus extends React.Component { | ||
componentDidMount() { | ||
this.togglePublished = this.togglePublished.bind(this); | ||
} | ||
|
||
togglePublished() { | ||
this.props.savePublished(this.props.dashboardId, !this.props.isPublished); | ||
} | ||
|
||
render() { | ||
// Show everybody the draft badge | ||
if (!this.props.isPublished) { | ||
// if they can edit the dash, make the badge a button | ||
if (this.props.canEdit && this.props.canSave) { | ||
return ( | ||
<TooltipWrapper | ||
label="Unpublished Dashboard" | ||
placement="bottom" | ||
tooltip={draftButtonTooltip} | ||
> | ||
<button | ||
style={divStyle} | ||
onClick={() => { | ||
this.togglePublished(); | ||
}} | ||
> | ||
Draft | ||
</button> | ||
</TooltipWrapper> | ||
); | ||
} | ||
return ( | ||
<TooltipWrapper | ||
label="Unpublished Dashboard" | ||
placement="bottom" | ||
tooltip={draftDivTooltip} | ||
> | ||
<div style={divStyle}>Draft</div> | ||
</TooltipWrapper> | ||
); | ||
} | ||
|
||
// Show the published badge for the owner of the dashboard to toggle | ||
else if (this.props.canEdit && this.props.canSave) { | ||
return ( | ||
<TooltipWrapper | ||
label="Published Dashboard" | ||
placement="bottom" | ||
tooltip={publishedTooltip} | ||
> | ||
<button | ||
style={divStyle} | ||
onClick={() => { | ||
this.togglePublished(); | ||
}} | ||
> | ||
Published | ||
</button> | ||
</TooltipWrapper> | ||
); | ||
} | ||
|
||
// Don't show anything if one doesn't own the dashboard and it is published | ||
return null; | ||
} | ||
} | ||
|
||
PublishedStatus.propTypes = propTypes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
superset/migrations/versions/d6ffdf31bdd4_add_published_column_to_dashboards.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""Add published column to dashboards | ||
Revision ID: d6ffdf31bdd4 | ||
Revises: 45e7da7cfeba | ||
Create Date: 2018-03-30 14:00:44.929483 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "d6ffdf31bdd4" | ||
down_revision = "d7c1a0d6f2da" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("dashboards") as batch_op: | ||
batch_op.add_column(sa.Column("published", sa.Boolean(), nullable=True)) | ||
op.execute("UPDATE dashboards SET published='1'") | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("dashboards") as batch_op: | ||
batch_op.drop_column("published") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.