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 there's no publish button on mobile query page #4760

Merged
merged 3 commits into from
Mar 30, 2020
Merged
Changes from 2 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
27 changes: 20 additions & 7 deletions client/app/pages/queries/components/QueryPageHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Button from "antd/lib/button";
import Dropdown from "antd/lib/dropdown";
import Menu from "antd/lib/menu";
import Icon from "antd/lib/icon";
import useMedia from "use-media";
import EditInPlace from "@/components/EditInPlace";
import FavoritesControl from "@/components/FavoritesControl";
import { QueryTagsControl } from "@/components/tags-control/TagsControl";
Expand Down Expand Up @@ -68,8 +69,8 @@ export default function QueryPageHeader({
headerExtra,
tagsExtra,
onChange,
onRefresh,
}) {
const isMobile = !useMedia({ minWidth: 768 });
kravets-levko marked this conversation as resolved.
Show resolved Hide resolved
const queryFlags = useQueryFlags(query, dataSource);
const updateName = useRenameQuery(query, onChange);
const updateTags = useUpdateQueryTags(query, onChange);
Expand Down Expand Up @@ -107,6 +108,12 @@ export default function QueryPageHeader({
title: "Manage Permissions",
onClick: openPermissionsEditorDialog,
},
publish: {
isAvailable:
isMobile && queryFlags.isDraft && !queryFlags.isArchived && !queryFlags.isNew && queryFlags.canEdit,
title: "Publish",
onClick: publishQuery,
},
unpublish: {
isAvailable: !queryFlags.isNew && queryFlags.canEdit && !queryFlags.isDraft,
title: "Unpublish",
Expand All @@ -122,13 +129,19 @@ export default function QueryPageHeader({
},
]),
[
queryFlags,
queryFlags.isNew,
queryFlags.canFork,
queryFlags.canEdit,
queryFlags.isArchived,
queryFlags.isDraft,
isDuplicating,
duplicateQuery,
archiveQuery,
openPermissionsEditorDialog,
isMobile,
publishQuery,
unpublishQuery,
openApiKeyDialog,
openPermissionsEditorDialog,
isDuplicating,
duplicateQuery,
]
);

Expand Down Expand Up @@ -157,8 +170,8 @@ export default function QueryPageHeader({
</div>
<div className="header-actions">
{headerExtra}
{queryFlags.isDraft && !queryFlags.isArchived && !queryFlags.isNew && queryFlags.canEdit && (
<Button className="hidden-xs m-r-5" onClick={publishQuery}>
{!isMobile && queryFlags.isDraft && !queryFlags.isArchived && !queryFlags.isNew && queryFlags.canEdit && (
<Button className="m-r-5" onClick={publishQuery}>
<i className="fa fa-paper-plane m-r-5" /> Publish
</Button>
)}
Expand Down