Skip to content

Commit

Permalink
Add file to links in file list, update Yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Jan 22, 2024
1 parent cc9c700 commit 6921e60
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"eslint.autoFixOnSave": true,
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"search.exclude": {
"**/.yarn": true,
Expand Down
7 changes: 5 additions & 2 deletions imports/dashboard/files/fileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ const FileListItemRenderer = ({ index, data, style }: ListChildComponentProps):
.filter(e => !filesSelected.includes(e))
setFilesSelected([...filesSelected, ...filesToSelect])
}
const subpath = file.folder ? joinPath(path, file.name) : path
const params = new URLSearchParams()
if (router.query.node) params.append('node', router.query.node as string)
if (!file.folder) params.append('file', file.name)
return (
<FileListItem
style={style}
Expand All @@ -106,8 +110,7 @@ const FileListItemRenderer = ({ index, data, style }: ListChildComponentProps):
? selectItem()
: !e.ctrlKey && e.shiftKey && !e.metaKey && !e.altKey ? shiftClickItem() : onClick(file)}
onCheck={(e) => e.shiftKey ? shiftClickItem() : selectItem()}
url={`/dashboard/${router.query.server}/files${file.folder ? joinPath(path, file.name) : path
}${typeof router.query.node === 'string' ? '?node=' + router.query.node : ''}`}
url={`/dashboard/${router.query.server}/files${subpath}${params.size ? '?' : ''}${params}`}
/>
)
}
Expand Down
8 changes: 4 additions & 4 deletions imports/dashboard/files/fileManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ const FileManager = (props: {
// When an editor is open, no actions can be performed, so this is not a problem.
if (!files) return
// Check if the file exists, and depending on its metadata, act accordingly.
const file = files.find(file => file.name === filename)
if (!file) {
const fileInf = files.find(f => f.name === filename)
if (!fileInf) {
updatePath(path) // Remove file from path.
return setMessage('The requested file does not exist!')
} else if (
file.size < 2 * 1024 * 1024 &&
(editorExts.includes(filename.split('.').pop() ?? '') || file.mimeType.startsWith('text/'))
fileInf.size < 2 * 1024 * 1024 &&
(editorExts.includes(filename.split('.').pop() ?? '') || fileInf.mimeType.startsWith('text/'))
) {
loadFileInEditor(filename).catch(err => {
console.error(err)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Ibrahim Ansari <ansari.ibrahim1@gmail.com>",
"license": "Apache-2.0",
"private": true,
"packageManager": "yarn@4.0.0-rc.49",
"packageManager": "yarn@4.0.2",
"scripts": {
"test": "jest",
"dev": "next",
Expand Down

0 comments on commit 6921e60

Please sign in to comment.