@@ -7,7 +7,7 @@ import Button from "@mui/material/Button";
77import { IconButton , Link } from "@mui/material" ;
88import Snackbar from "@mui/material/Snackbar" ;
99import CloseIcon from "@mui/icons-material/Close" ;
10- import { useSelector } from "react-redux" ;
10+ import { useSelector , useDispatch } from "react-redux" ;
1111
1212import { OSBApplications , Workspace } from "../../types/workspace" ;
1313import { WorkspaceEditor } from "../index" ;
@@ -18,13 +18,11 @@ import { bgDarkest, textColor } from "../../theme";
1818import * as Icons from "../icons" ;
1919import PrimaryDialog from "../dialogs/PrimaryDialog" ;
2020import { RootState } from "../../store/rootReducer" ;
21+ import { updateWorkspace , deleteWorkspace , refreshWorkspaces } from "../../store/actions/workspaces" ;
2122
2223
2324interface WorkspaceActionsMenuProps {
2425 workspace ?: Workspace ;
25- updateWorkspace ?: ( ws : Workspace ) => void ;
26- deleteWorkspace ?: ( wsId : number ) => void ;
27- refreshWorkspaces ?: ( ) => void ;
2826 isWorkspaceOpen ?: boolean ;
2927 ButtonComponent ?: React . ComponentType < any > ;
3028 [ other : string ] : any ;
@@ -41,6 +39,7 @@ const snackbarStyles = {
4139export const WorkspaceActionsMenu = ( props : WorkspaceActionsMenuProps ) => {
4240 const { ButtonComponent } = props ;
4341 const user = useSelector ( ( state : RootState ) => state . user ) ;
42+ const dispatch = useDispatch ( ) ;
4443
4544 const [ editWorkspaceOpen , setEditWorkspaceOpen ] = React . useState ( false ) ;
4645 const [ cloneInProgress , setCloneInProgress ] = React . useState < boolean > ( false ) ;
@@ -69,7 +68,7 @@ export const WorkspaceActionsMenu = (props: WorkspaceActionsMenuProps) => {
6968 } ;
7069
7170 const handleDeleteWorkspace = ( ) => {
72- props . deleteWorkspace ( props . workspace . id ) ;
71+ dispatch ( deleteWorkspace ( props . workspace . id ) ) ;
7372 handleCloseMenu ( ) ;
7473
7574 if ( window . location . pathname !== "/" ) {
@@ -78,20 +77,20 @@ export const WorkspaceActionsMenu = (props: WorkspaceActionsMenuProps) => {
7877 } ;
7978
8079 const handlePublicWorkspace = ( ) => {
81- props . updateWorkspace ( { ...props . workspace , publicable : true } ) ;
80+ dispatch ( updateWorkspace ( { ...props . workspace , publicable : true } ) ) ;
8281 handleCloseMenu ( ) ;
8382 } ;
8483
8584 const handlePrivateWorkspace = ( ) => {
86- props . updateWorkspace ( { ...props . workspace , publicable : false } ) ;
85+ dispatch ( updateWorkspace ( { ...props . workspace , publicable : false } ) ) ;
8786 handleCloseMenu ( ) ;
8887 } ;
8988
9089 const handleFeaturedWorkspace = ( ) => {
91- props . updateWorkspace ( {
90+ dispatch ( updateWorkspace ( {
9291 ...props . workspace ,
9392 featured : ! props . workspace . featured ,
94- } ) ;
93+ } ) ) ;
9594 handleCloseMenu ( ) ;
9695 } ;
9796
@@ -101,15 +100,15 @@ export const WorkspaceActionsMenu = (props: WorkspaceActionsMenuProps) => {
101100
102101 const handleCloseEditWorkspace = ( ) => {
103102 setEditWorkspaceOpen ( false ) ;
104- props . refreshWorkspaces ( ) ;
103+ dispatch ( refreshWorkspaces ( ) ) ;
105104 } ;
106105
107106 const handleCloneWorkspace = ( ) => {
108107 handleCloseMenu ( ) ;
109108 setCloneInProgress ( true ) ;
110109 WorkspaceService . cloneWorkspace ( props . workspace . id ) . then (
111110 ( res ) => {
112- props . refreshWorkspaces ( ) ;
111+ dispatch ( refreshWorkspaces ( ) ) ;
113112 setCloneInProgress ( false ) ;
114113 setCloneComplete ( true ) ;
115114 setClonedWSId ( res . id ) ;
0 commit comments