Skip to content
Open
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
35 changes: 22 additions & 13 deletions client/modules/IDE/components/Header/Nav.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { sortBy } from 'lodash';
import { Link } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { MenubarSubmenu } from '../../../../components/Menubar/MenubarSubmenu';
Expand All @@ -25,7 +25,8 @@ import {
newFolder,
showKeyboardShortcutModal,
startSketch,
stopSketch
stopSketch,
showErrorModal
} from '../../actions/ide';
import { logoutUser } from '../../../User/actions';
import { CmControllerContext } from '../../pages/IDEView';
Expand All @@ -34,7 +35,6 @@ import useIsMobile from '../../hooks/useIsMobile';

const Nav = ({ layout }) => {
const isMobile = useIsMobile();

return isMobile ? (
<MobileNav />
) : (
Expand Down Expand Up @@ -160,6 +160,7 @@ const ProjectMenu = () => {
const cmRef = useContext(CmControllerContext);

const dispatch = useDispatch();
const history = useHistory();

const { t } = useTranslation();
const {
Expand All @@ -182,12 +183,14 @@ const ProjectMenu = () => {
</MenubarItem>
<MenubarItem
id="file-save"
isDisabled={
!user.authenticated ||
!isLoginEnabled ||
(project?.owner && !isUserOwner)
}
onClick={() => saveSketch(cmRef.current)}
isDisabled={!isLoginEnabled || (project?.owner && !isUserOwner)}
onClick={() => {
if (!user.authenticated) {
dispatch(showErrorModal('forceAuthentication'));
return;
}
saveSketch(cmRef.current);
}}
>
{t('Common.Save')}
<span className="nav__keyboard-shortcut">{metaKeyName}+S</span>
Expand Down Expand Up @@ -222,10 +225,16 @@ const ProjectMenu = () => {
</MenubarItem>
<MenubarItem
id="file-add-to-collection"
isDisabled={
!isUiCollectionsEnabled || !user.authenticated || isUnsaved
}
href={`/${user.username}/sketches/${project?.id}/add-to-collection`}
isDisabled={!isUiCollectionsEnabled || isUnsaved}
onClick={() => {
if (!user.authenticated) {
dispatch(showErrorModal('forceAuthentication'));
return;
}
history.push(
`/${user.username}/sketches/${project?.id}/add-to-collection`
);
}}
>
{t('Nav.File.AddToCollection')}
</MenubarItem>
Expand Down