Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
02f5ed95
Commit
02f5ed95
authored
Dec 17, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update IDE to track mimeType
- Add mimeType to file object - Add mimeType handling to upload file
parent
e10ab985
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
5 deletions
+28
-5
app/assets/javascripts/ide/components/new_dropdown/upload.vue
...assets/javascripts/ide/components/new_dropdown/upload.vue
+1
-0
app/assets/javascripts/ide/lib/files.js
app/assets/javascripts/ide/lib/files.js
+10
-1
app/assets/javascripts/ide/stores/actions.js
app/assets/javascripts/ide/stores/actions.js
+4
-1
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+3
-0
spec/frontend/ide/components/new_dropdown/upload_spec.js
spec/frontend/ide/components/new_dropdown/upload_spec.js
+4
-2
spec/frontend/ide/lib/files_spec.js
spec/frontend/ide/lib/files_spec.js
+4
-1
spec/frontend/ide/stores/actions_spec.js
spec/frontend/ide/stores/actions_spec.js
+2
-0
No files found.
app/assets/javascripts/ide/components/new_dropdown/upload.vue
View file @
02f5ed95
...
...
@@ -36,6 +36,7 @@ export default {
type
:
'
blob
'
,
content
,
rawPath
:
!
isText
?
URL
.
createObjectURL
(
file
)
:
''
,
mimeType
:
file
.
type
,
});
if
(
isText
)
{
...
...
app/assets/javascripts/ide/lib/files.js
View file @
02f5ed95
...
...
@@ -11,8 +11,16 @@ export const splitParent = path => {
/**
* Create file objects from a list of file paths.
*
* @param options.blobData Values to initialize each blob with
*/
export
const
decorateFiles
=
({
data
,
tempFile
=
false
,
content
=
''
,
rawPath
=
''
})
=>
{
export
const
decorateFiles
=
({
data
,
tempFile
=
false
,
content
=
''
,
rawPath
=
''
,
blobData
=
{},
})
=>
{
const
treeList
=
[];
const
entries
=
{};
...
...
@@ -73,6 +81,7 @@ export const decorateFiles = ({ data, tempFile = false, content = '', rawPath =
content
,
rawPath
,
parentPath
,
...
blobData
,
});
Object
.
assign
(
entries
,
{
...
...
app/assets/javascripts/ide/stores/actions.js
View file @
02f5ed95
...
...
@@ -31,7 +31,7 @@ export const setResizingStatus = ({ commit }, resizing) => {
export
const
createTempEntry
=
(
{
state
,
commit
,
dispatch
,
getters
},
{
name
,
type
,
content
=
''
,
rawPath
=
''
,
openFile
=
true
,
makeFileActive
=
true
},
{
name
,
type
,
content
=
''
,
rawPath
=
''
,
openFile
=
true
,
makeFileActive
=
true
,
mimeType
=
''
},
)
=>
{
const
fullName
=
name
.
slice
(
-
1
)
!==
'
/
'
&&
type
===
'
tree
'
?
`
${
name
}
/`
:
name
;
...
...
@@ -56,6 +56,9 @@ export const createTempEntry = (
tempFile
:
true
,
content
,
rawPath
,
blobData
:
{
mimeType
,
},
});
const
{
file
,
parentPath
}
=
data
;
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
02f5ed95
...
...
@@ -31,6 +31,7 @@ export const dataStructure = () => ({
mrChange
:
null
,
deleted
:
false
,
prevPath
:
undefined
,
mimeType
:
''
,
});
export
const
decorateData
=
entity
=>
{
...
...
@@ -47,6 +48,7 @@ export const decorateData = entity => {
rawPath
=
''
,
file_lock
,
parentPath
=
''
,
mimeType
=
''
,
}
=
entity
;
return
Object
.
assign
(
dataStructure
(),
{
...
...
@@ -63,6 +65,7 @@ export const decorateData = entity => {
rawPath
,
file_lock
,
parentPath
,
mimeType
,
});
};
...
...
spec/frontend/ide/components/new_dropdown/upload_spec.js
View file @
02f5ed95
...
...
@@ -62,8 +62,8 @@ describe('new dropdown upload', () => {
result
:
'
base64,8PDw8A==
'
,
// ðððð
};
const
textFile
=
new
File
([
'
plain text
'
],
'
textFile
'
);
const
binaryFile
=
new
File
([
'
😺
'
],
'
binaryFile
'
);
const
textFile
=
new
File
([
'
plain text
'
],
'
textFile
'
,
{
type
:
'
test/mime-text
'
}
);
const
binaryFile
=
new
File
([
'
😺
'
],
'
binaryFile
'
,
{
type
:
'
test/mime-binary
'
}
);
beforeEach
(()
=>
{
jest
.
spyOn
(
FileReader
.
prototype
,
'
readAsText
'
);
...
...
@@ -83,6 +83,7 @@ describe('new dropdown upload', () => {
type
:
'
blob
'
,
content
:
'
plain text
'
,
rawPath
:
''
,
mimeType
:
'
test/mime-text
'
,
});
})
.
then
(
done
)
...
...
@@ -99,6 +100,7 @@ describe('new dropdown upload', () => {
type
:
'
blob
'
,
content
:
'
ðððð
'
,
rawPath
:
'
blob:https://gitlab.com/048c7ac1-98de-4a37-ab1b-0206d0ea7e1b
'
,
mimeType
:
'
test/mime-binary
'
,
});
});
});
...
...
spec/frontend/ide/lib/files_spec.js
View file @
02f5ed95
import
{
decorateFiles
,
splitParent
}
from
'
~/ide/lib/files
'
;
import
{
decorateData
}
from
'
~/ide/stores/utils
'
;
const
TEST_BLOB_DATA
=
{
mimeType
:
'
test/mime
'
};
const
createEntries
=
paths
=>
{
const
createEntry
=
(
acc
,
{
path
,
type
,
children
})
=>
{
const
{
name
,
parent
}
=
splitParent
(
path
);
...
...
@@ -14,6 +16,7 @@ const createEntries = paths => {
parentPath
:
parent
,
}),
tree
:
children
.
map
(
childName
=>
expect
.
objectContaining
({
name
:
childName
})),
...(
type
===
'
blob
'
?
TEST_BLOB_DATA
:
{}),
};
return
acc
;
...
...
@@ -43,7 +46,7 @@ describe('IDE lib decorate files', () => {
{
path
:
'
README.md
'
,
type
:
'
blob
'
,
children
:
[]
},
]);
const
{
entries
,
treeList
}
=
decorateFiles
({
data
});
const
{
entries
,
treeList
}
=
decorateFiles
({
data
,
blobData
:
TEST_BLOB_DATA
});
// Here we test the keys and then each key/value individually because `expect(entries).toEqual(expectedEntries)`
// was taking a very long time for some reason. Probably due to large objects and nested `expect.objectContaining`.
...
...
spec/frontend/ide/stores/actions_spec.js
View file @
02f5ed95
...
...
@@ -195,11 +195,13 @@ describe('Multi-file store actions', () => {
.
dispatch
(
'
createTempEntry
'
,
{
name
,
type
:
'
blob
'
,
mimeType
:
'
test/mime
'
,
})
.
then
(()
=>
{
const
f
=
store
.
state
.
entries
[
name
];
expect
(
f
.
tempFile
).
toBeTruthy
();
expect
(
f
.
mimeType
).
toBe
(
'
test/mime
'
);
expect
(
store
.
state
.
trees
[
'
abcproject/mybranch
'
].
tree
.
length
).
toBe
(
1
);
done
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment