Skip to content

Commit

Permalink
Issue solved
Browse files Browse the repository at this point in the history
  • Loading branch information
TechSubham committed Dec 27, 2024
1 parent 9735a0a commit 9900d41
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { cloneBlocks } from '@plone/volto/helpers/Blocks/cloneBlocks';
import config from '@plone/volto/registry';

export const ADD_TO_FAVOURITES = 'ADD_TO_FAVOURITES';
export const REMOVE_FROM_FAVOURITES = 'REMOVE_FROM_FAVOURITES';
export const LOAD_FAVOURITES = 'LOAD_FAVOURITES';
export const ADD_TO_FAVORITES = 'ADD_TO_FAVORITES';
export const REMOVE_FROM_FAVORITES = 'REMOVE_FROM_FAVORITES';
export const LOAD_FAVORITES = 'LOAD_FAVORITES';

export function loadFavourites() {
export function loadFavorites() {
return {
type: LOAD_FAVOURITES,
type: LOAD_FAVORITES,
};
}

export function addToFavourites(blockData) {
export function addToFavorites(blockData) {
const { id, type, data } = blockData;
const blockConfig = config.blocks.blocksConfig[type];
const clonedData = blockConfig?.cloneData
? blockConfig.cloneData(data)
: cloneBlocks(data);

return {
type: ADD_TO_FAVOURITES,
type: ADD_TO_FAVORITES,
block: {
id,
type,
Expand All @@ -28,9 +28,9 @@ export function addToFavourites(blockData) {
};
}

export function removeFromFavourites(blockId) {
export function removeFromFavorites(blockId) {
return {
type: REMOVE_FROM_FAVOURITES,
type: REMOVE_FROM_FAVORITES,
blockId,
};
}
36 changes: 0 additions & 36 deletions packages/volto/src/actions/favourites/favourites.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const messages = defineMessages({
id: 'save',
defaultMessage: 'save',
},
addToFavourites: {
id: 'addToFavourites',
defaultMessage: 'Add to Favourites',
addToFavorites: {
id: 'addToFavorites',
defaultMessage: 'Add to Favorites',
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { useDispatch } from 'react-redux';
import { Button, Modal, Input, Header } from 'semantic-ui-react';
import { defineMessages, useIntl } from 'react-intl';
import { addToFavourites } from '@plone/volto/actions/favourites/favourites';
import { addToFavorites } from '@plone/volto/actions/favorites/favorites';
import config from '@plone/volto/registry';

const messages = defineMessages({
Expand Down Expand Up @@ -44,7 +44,7 @@ const SaveBlockDialog = ({ block, type, data, isOpen, onClose }) => {
if (blockConfig?.cloneData) {
blockData.data = blockConfig.cloneData(blockData.data)[1];
}
dispatch(addToFavourites(blockData));
dispatch(addToFavorites(blockData));
setName('');
onClose();
};
Expand Down
46 changes: 23 additions & 23 deletions packages/volto/src/components/manage/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import { setSidebarTab } from '@plone/volto/actions/sidebar/sidebar';
import expandSVG from '@plone/volto/icons/left-key.svg';
import collapseSVG from '@plone/volto/icons/right-key.svg';
import save from '@plone/volto/icons/save.svg';
import { removeFromFavourites } from '@plone/volto/actions/favourites/favourites';
import FavouriteItem from './FavouriteItem';
import { loadFavourites } from '../../../actions/favourites/favourites';
import { removeFromFavorites } from '@plone/volto/actions/favorites/favorites';
import FavoriteItem from './FavoriteItem';
import { loadFavorites } from '../../../actions/favorites/favorites';

const messages = defineMessages({
save: {
id: 'Save',
defaultMessage: 'Save',
},
Favourite: {
id: 'Favourite',
defaultMessage: 'Favourite',
Favorite: {
id: 'Favorite',
defaultMessage: 'Favorite',
},
document: {
id: 'Document',
Expand Down Expand Up @@ -62,7 +62,7 @@ const Sidebar = (props) => {
documentTab,
blockTab,
settingsTab,
FavouriteTab = true,
FavoriteTab = true,
orderTab = true,
} = props;

Expand All @@ -71,7 +71,7 @@ const Sidebar = (props) => {
);
const [size] = useState(0);
const [showFull, setshowFull] = useState(true);
const favouriteItems = useSelector((state) => state?.favourites?.items ?? []);
const FavoriteItems = useSelector((state) => state?.favorites?.items ?? []);
const tab = useSelector((state) => state?.sidebar?.tab ?? 0);
const toolbarExpanded = useSelector(
(state) => state?.toolbar?.expanded ?? false,
Expand All @@ -85,11 +85,11 @@ const Sidebar = (props) => {
};

useEffect(() => {
dispatch(loadFavourites());
dispatch(loadFavorites());
}, [dispatch]);

const handleRemoveFavourite = (blockId) => {
dispatch(removeFromFavourites(blockId));
const handleRemoveFavorite = (blockId) => {
dispatch(removeFromFavorites(blockId));
};

const resetFullSizeSidebar = useCallback(() => {
Expand Down Expand Up @@ -247,23 +247,23 @@ const Sidebar = (props) => {
</Tab.Pane>
),
},
!!FavouriteTab && {
menuItem: intl.formatMessage(messages.Favourite),
!!FavoriteTab && {
menuItem: intl.formatMessage(messages.Favorite),
pane: (
<Tab.Pane
key="Favourite"
key="Favorite"
className="tab-wrapper"
id="sidebar-Favourite"
id="sidebar-Favorite"
>
<div className="saved-items-container">
{Array.isArray(favouriteItems) &&
favouriteItems.length > 0 ? (
{Array.isArray(FavoriteItems) &&
FavoriteItems.length > 0 ? (
<div className="divide-y">
{favouriteItems.map((item) => (
<FavouriteItem
{FavoriteItems.map((item) => (
<FavoriteItem
key={item.id}
item={item}
onRemove={handleRemoveFavourite}
onRemove={handleRemoveFavorite}
/>
))}
</div>
Expand All @@ -275,7 +275,7 @@ const Sidebar = (props) => {
size="48px"
/>
<p className="mt-2 text-gray-500">
No favourite blocks saved
No Favorites blocks saved
</p>
</div>
)}
Expand All @@ -295,14 +295,14 @@ Sidebar.propTypes = {
documentTab: PropTypes.bool,
blockTab: PropTypes.bool,
settingsTab: PropTypes.bool,
FavouriteTab: PropTypes.bool,
FavoriteTab: PropTypes.bool,
};

Sidebar.defaultProps = {
documentTab: true,
blockTab: true,
settingsTab: false,
FavouriteTab: true,
FavoriteTab: true,
};

export default compose(withCookies)(Sidebar);
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Array [
className="item"
onClick={[Function]}
>
Favourite
Favorite
</a>
</div>
<div
Expand Down Expand Up @@ -147,7 +147,7 @@ Array [
</div>
<div
className="ui bottom attached segment tab tab-wrapper"
id="sidebar-Favourite"
id="sidebar-Favorite"
>
<div
className="saved-items-container"
Expand Down Expand Up @@ -176,7 +176,7 @@ Array [
<p
className="mt-2 text-gray-500"
>
No favourite blocks saved
No Favorites blocks saved
</p>
</div>
</div>
Expand Down
7 changes: 0 additions & 7 deletions packages/volto/src/icons/save1 2.crdownload

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ADD_TO_FAVOURITES,
REMOVE_FROM_FAVOURITES,
LOAD_FAVOURITES,
} from '../../actions/favourites/favourites';
ADD_TO_FAVORITES,
REMOVE_FROM_FAVORITES,
LOAD_FAVORITES,
} from '../../actions/favorites/favorites';

const STORAGE_KEY = 'volto_favourite_blocks';
const STORAGE_KEY = 'volto_favorite_blocks';

const extractPreviewData = (blockData) => {
if (!blockData) return null;
Expand Down Expand Up @@ -65,17 +65,17 @@ const initialState = {
items: loadFromStorage(),
};

export default function favouritesReducer(state = initialState, action) {
export default function favoritesReducer(state = initialState, action) {
let newState;
switch (action.type) {
case LOAD_FAVOURITES:
case LOAD_FAVORITES:
newState = {
...state,
items: loadFromStorage(),
};
break;

case ADD_TO_FAVOURITES: {
case ADD_TO_FAVORITES: {
const blockExists = state.items.some(function (item) {
return item.id === action.block.id;
});
Expand All @@ -98,7 +98,7 @@ export default function favouritesReducer(state = initialState, action) {
break;
}

case REMOVE_FROM_FAVOURITES: {
case REMOVE_FROM_FAVORITES: {
const newItems = state.items.filter((item) => item.id !== action.blockId);
newState = {
...state,
Expand Down
4 changes: 2 additions & 2 deletions packages/volto/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import upgrade from './upgrade/upgrade';
import userschema from './userschema/userschema';
import site from './site/site';
import navroot from './navroot/navroot';
import favourites from './favourites/favouritesReducer';
import favorites from './favorites/favoritesReducer';

/**
* Root reducer.
Expand Down Expand Up @@ -112,7 +112,7 @@ const reducers = {
userschema,
site,
navroot,
favourites,
favorites,
};

export default reducers;

0 comments on commit 9900d41

Please sign in to comment.