File tree Expand file tree Collapse file tree 6 files changed +80
-6
lines changed
Expand file tree Collapse file tree 6 files changed +80
-6
lines changed Original file line number Diff line number Diff line change 3333 </div >
3434 <div class =" action" >New File</div >
3535 </div >
36- <div class =" context-row" >
36+ <div class =" context-row" v-on:click = " openFolderModal " >
3737 <div class =" icon" >
3838 <Icon name =" folder-plus" class =" h-4" />
3939 </div >
5858 export default Vue .extend ({
5959 name: ' FileContextMenu' ,
6060 components: {Icon },
61+
62+ methods: {
63+ openFolderModal : function () {
64+ window .events .$emit (' server:files:open-directory-modal' );
65+ this .$emit (' close' );
66+ }
67+ }
6168 });
6269 </script >
Original file line number Diff line number Diff line change 1010 <div class =" flex-1 text-right text-neutral-600" >{{formatDate(file.modified)}}</div >
1111 <div class =" flex-none w-1/6" ></div >
1212 </div >
13- <FileContextMenu class =" context-menu" v-show =" contextMenuVisible" ref =" contextMenu" />
13+ <FileContextMenu
14+ class =" context-menu"
15+ v-show =" contextMenuVisible"
16+ v-on:close =" contextMenuVisible = false"
17+ ref =" contextMenu"
18+ />
1419 </div >
1520</template >
1621
Original file line number Diff line number Diff line change 1+ <template >
2+ <Modal :show =" visible" v-on:close =" visible = false" >
3+ <div >
4+ <h2 class =" font-medium text-neutral-900 mb-6" >{{ fm.currentDirectory }}</h2 >
5+ </div >
6+ </Modal >
7+ </template >
8+
9+ <script lang="ts">
10+ import Vue from ' vue' ;
11+ import Modal from ' @/components/core/Modal.vue' ;
12+ import {mapState } from " vuex" ;
13+
14+ export default Vue .extend ({
15+ name: ' CreateFolderModal' ,
16+ components: {Modal },
17+
18+ computed: {
19+ ... mapState (' server' , [' fm' ]),
20+ },
21+
22+ data : function () {
23+ return {
24+ visible: false ,
25+ };
26+ },
27+
28+ mounted : function () {
29+ window .events .$on (' server:files:open-directory-modal' , () => {
30+ this .visible = true ;
31+ });
32+ },
33+ });
34+ </script >
Original file line number Diff line number Diff line change 4242 <div class =" flex mt-6" v-if =" !loading && !errorMessage" >
4343 <div class =" flex-1" ></div >
4444 <div class =" mr-4" >
45- <a href =" #" class =" block btn btn-secondary btn-sm" >New Folder</a >
45+ <a href =" #" class =" block btn btn-secondary btn-sm" v-on:click.prevent = " openNewFolderModal " >New Folder</a >
4646 </div >
4747 <div >
4848 <a href =" #" class =" block btn btn-primary btn-sm" >New File</a >
4949 </div >
5050 </div >
51+ <CreateFolderModal />
5152 </div >
5253</template >
5354
5859 import getDirectoryContents from " @/api/server/getDirectoryContents" ;
5960 import FileRow from " @/components/server/components/filemanager/FileRow.vue" ;
6061 import FolderRow from " @/components/server/components/filemanager/FolderRow.vue" ;
62+ import CreateFolderModal from ' ../components/filemanager/modals/CreateFolderModal.vue' ;
6163
6264 type DataStructure = {
6365 loading: boolean ,
7072
7173 export default Vue .extend ({
7274 name: ' FileManager' ,
73- components: {FileRow , FolderRow },
75+ components: {CreateFolderModal , FileRow , FolderRow },
7476 computed: {
7577 ... mapState (' server' , [' server' , ' credentials' ]),
7678 ... mapState (' socket' , [' connected' ]),
110112 * Watch the current directory setting and when it changes update the file listing.
111113 */
112114 currentDirectory : function () {
115+ this .$store .dispatch (' server/updateCurrentDirectory' , this .currentDirectory );
116+
113117 this .listDirectory ();
114118 },
115119
167171 this .loading = false ;
168172 });
169173 },
174+
175+ openNewFolderModal : function () {
176+ window .events .$emit (' server:files:open-directory-modal' );
177+ }
170178 },
171179 });
172180 </script >
Original file line number Diff line number Diff line change 11// @ts -ignore
22import route from '../../../../../vendor/tightenco/ziggy/src/js/route' ;
33import { ActionContext } from "vuex" ;
4- import { ServerData } from "../.. /models/server" ;
5- import { ServerApplicationCredentials , ServerState } from "../types" ;
4+ import { ServerData } from "@ /models/server" ;
5+ import { FileManagerState , ServerApplicationCredentials , ServerState } from "../types" ;
66
77export default {
88 namespaced : true ,
99 state : {
1010 server : { } ,
1111 credentials : { node : '' , key : '' } ,
1212 console : [ ] ,
13+ fm : {
14+ currentDirectory : '/' ,
15+ } ,
1316 } ,
1417 getters : { } ,
1518 actions : {
@@ -63,8 +66,20 @@ export default {
6366 . catch ( reject ) ;
6467 } ) ;
6568 } ,
69+
70+ /**
71+ * Update the last viewed directory for the server the user is currently viewing. This allows
72+ * us to quickly navigate back to that directory, as well as ensure that actions taken are
73+ * performed aganist the correct directory without having to pass that mess everywhere.
74+ */
75+ updateCurrentDirectory : ( { commit} : ActionContext < ServerState , any > , directory : string ) => {
76+ commit ( 'SET_CURRENT_DIRECTORY' , directory ) ;
77+ } ,
6678 } ,
6779 mutations : {
80+ SET_CURRENT_DIRECTORY : function ( state : ServerState , directory : string ) {
81+ state . fm . currentDirectory = directory ;
82+ } ,
6883 SERVER_DATA : function ( state : ServerState , data : ServerData ) {
6984 state . server = data ;
7085 } ,
Original file line number Diff line number Diff line change @@ -19,10 +19,15 @@ export type ServerApplicationCredentials = {
1919 key : string ,
2020} ;
2121
22+ export type FileManagerState = {
23+ currentDirectory : string ,
24+ }
25+
2226export type ServerState = {
2327 server : ServerData ,
2428 credentials : ServerApplicationCredentials ,
2529 console : Array < string > ,
30+ fm : FileManagerState ,
2631} ;
2732
2833export type DashboardState = {
You can’t perform that action at this time.
0 commit comments