11import React from "react" ;
22import { useDispatch , useSelector } from "react-redux" ;
33import { useTranslation } from "react-i18next" ;
4- import useNewComponentButton from "../../../../hooks/useNewComponentButton" ;
54
65import FileMenu from "../../FileMenu/FileMenu" ;
76import DesignSystemButton from "../../../DesignSystemButton/DesignSystemButton" ;
87import {
98 openFile ,
109 setFocussedFileIndex ,
1110 hideSidebar ,
11+ showNewFileModal ,
1212} from "../../../../redux/EditorSlice" ;
1313
1414import "../../../../assets/stylesheets/FilePanel.scss" ;
1515import "../../../../assets/stylesheets/Sidebar.scss" ;
1616import SidebarPanel from "../SidebarPanel" ;
1717import FileIcon from "../../../../utils/FileIcon" ;
18+ import PlusIcon from "../../../../assets/icons/plus.svg" ;
1819
1920const FilePanel = ( { isMobile } ) => {
2021 const project = useSelector ( ( state ) => state . editor . project ) ;
2122 const openFiles = useSelector ( ( state ) => state . editor . openFiles ) ;
2223 const readOnly = useSelector ( ( state ) => state . editor . readOnly ) ;
23-
24+ const { t } = useTranslation ( ) ;
2425 const dispatch = useDispatch ( ) ;
25- const newFileButtons = useNewComponentButton ( ) ;
2626
2727 const switchToFileTab = ( panelIndex , fileIndex ) => {
2828 dispatch ( setFocussedFileIndex ( { panelIndex, fileIndex } ) ) ;
@@ -43,9 +43,23 @@ const FilePanel = ({ isMobile }) => {
4343 dispatch ( hideSidebar ( ) ) ;
4444 }
4545 } ;
46- const { t } = useTranslation ( ) ;
4746
48- const buttons = readOnly ? [ ] : newFileButtons ;
47+ const openNewFileModal = ( ) => {
48+ dispatch ( showNewFileModal ( ) ) ;
49+ } ;
50+
51+ const buttons = readOnly
52+ ? [ ]
53+ : [
54+ {
55+ text : t ( "filePanel.newFileButton" ) ,
56+ textAlways : true ,
57+ icon : < PlusIcon /> ,
58+ onClick : openNewFileModal ,
59+ className : "btn--primary" ,
60+ fill : true ,
61+ } ,
62+ ] ;
4963
5064 if ( ! project || ! project . components ) {
5165 return null ;
0 commit comments