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
a7536d56
Commit
a7536d56
authored
Jul 08, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
3621ff92
008aa6af
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
17 deletions
+88
-17
app/assets/javascripts/ide/components/repo_editor.vue
app/assets/javascripts/ide/components/repo_editor.vue
+3
-1
app/assets/javascripts/ide/lib/files.js
app/assets/javascripts/ide/lib/files.js
+3
-2
app/assets/javascripts/ide/stores/mutations/file.js
app/assets/javascripts/ide/stores/mutations/file.js
+13
-13
app/assets/javascripts/vue_shared/components/content_viewer/lib/viewer_utils.js
.../vue_shared/components/content_viewer/lib/viewer_utils.js
+1
-0
changelogs/unreleased/60856-deleting-binary-file.yml
changelogs/unreleased/60856-deleting-binary-file.yml
+5
-0
spec/frontend/ide/lib/files_spec.js
spec/frontend/ide/lib/files_spec.js
+3
-1
spec/javascripts/ide/components/repo_editor_spec.js
spec/javascripts/ide/components/repo_editor_spec.js
+40
-0
spec/javascripts/ide/stores/mutations/file_spec.js
spec/javascripts/ide/stores/mutations/file_spec.js
+20
-0
No files found.
app/assets/javascripts/ide/components/repo_editor.vue
View file @
a7536d56
...
@@ -144,7 +144,9 @@ export default {
...
@@ -144,7 +144,9 @@ export default {
'
triggerFilesChange
'
,
'
triggerFilesChange
'
,
]),
]),
initEditor
()
{
initEditor
()
{
if
(
this
.
shouldHideEditor
)
return
;
if
(
this
.
shouldHideEditor
&&
(
this
.
file
.
content
||
this
.
file
.
raw
))
{
return
;
}
this
.
editor
.
clearEditor
();
this
.
editor
.
clearEditor
();
...
...
app/assets/javascripts/ide/lib/files.js
View file @
a7536d56
...
@@ -77,6 +77,7 @@ export const decorateFiles = ({
...
@@ -77,6 +77,7 @@ export const decorateFiles = ({
const
fileFolder
=
parent
&&
insertParent
(
parent
);
const
fileFolder
=
parent
&&
insertParent
(
parent
);
if
(
name
)
{
if
(
name
)
{
const
previewMode
=
viewerInformationForPath
(
name
);
parentPath
=
fileFolder
&&
fileFolder
.
path
;
parentPath
=
fileFolder
&&
fileFolder
.
path
;
file
=
decorateData
({
file
=
decorateData
({
...
@@ -92,9 +93,9 @@ export const decorateFiles = ({
...
@@ -92,9 +93,9 @@ export const decorateFiles = ({
changed
:
tempFile
,
changed
:
tempFile
,
content
,
content
,
base64
,
base64
,
binary
,
binary
:
(
previewMode
&&
previewMode
.
binary
)
||
binary
,
rawPath
,
rawPath
,
previewMode
:
viewerInformationForPath
(
name
)
,
previewMode
,
parentPath
,
parentPath
,
});
});
...
...
app/assets/javascripts/ide/stores/mutations/file.js
View file @
a7536d56
import
*
as
types
from
'
../mutation_types
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
{
sortTree
}
from
'
../utils
'
;
import
{
sortTree
}
from
'
../utils
'
;
import
{
diffModes
}
from
'
../../constants
'
;
import
{
diffModes
}
from
'
../../constants
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
export
default
{
export
default
{
[
types
.
SET_FILE_ACTIVE
](
state
,
{
path
,
active
})
{
[
types
.
SET_FILE_ACTIVE
](
state
,
{
path
,
active
})
{
...
@@ -35,19 +36,18 @@ export default {
...
@@ -35,19 +36,18 @@ export default {
}
}
},
},
[
types
.
SET_FILE_DATA
](
state
,
{
data
,
file
})
{
[
types
.
SET_FILE_DATA
](
state
,
{
data
,
file
})
{
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
const
stateEntry
=
state
.
entries
[
file
.
path
];
id
:
data
.
id
,
const
stagedFile
=
state
.
stagedFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
blamePath
:
data
.
blame_path
,
const
openFile
=
state
.
openFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
commitsPath
:
data
.
commits_path
,
const
changedFile
=
state
.
changedFiles
.
find
(
f
=>
f
.
path
===
file
.
path
);
permalink
:
data
.
permalink
,
rawPath
:
data
.
raw_path
,
[
stateEntry
,
stagedFile
,
openFile
,
changedFile
].
forEach
(
f
=>
{
binary
:
data
.
binary
,
if
(
f
)
{
renderError
:
data
.
render_error
,
Object
.
assign
(
f
,
convertObjectPropsToCamelCase
(
data
,
{
dropKeys
:
[
'
raw
'
,
'
baseRaw
'
]
}),
{
raw
:
(
state
.
entries
[
file
.
path
]
&&
state
.
entries
[
file
.
path
].
raw
)
||
null
,
raw
:
(
stateEntry
&&
stateEntry
.
raw
)
||
null
,
baseRaw
:
null
,
baseRaw
:
null
,
html
:
data
.
html
,
});
size
:
data
.
size
,
}
lastCommitSha
:
data
.
last_commit_sha
,
});
});
},
},
[
types
.
SET_FILE_RAW_DATA
](
state
,
{
file
,
raw
})
{
[
types
.
SET_FILE_RAW_DATA
](
state
,
{
file
,
raw
})
{
...
...
app/assets/javascripts/vue_shared/components/content_viewer/lib/viewer_utils.js
View file @
a7536d56
...
@@ -3,6 +3,7 @@ import { __ } from '~/locale';
...
@@ -3,6 +3,7 @@ import { __ } from '~/locale';
const
viewers
=
{
const
viewers
=
{
image
:
{
image
:
{
id
:
'
image
'
,
id
:
'
image
'
,
binary
:
true
,
},
},
markdown
:
{
markdown
:
{
id
:
'
markdown
'
,
id
:
'
markdown
'
,
...
...
changelogs/unreleased/60856-deleting-binary-file.yml
0 → 100644
View file @
a7536d56
---
title
:
Removing an image should not output binary data
merge_request
:
30314
author
:
type
:
fixed
spec/frontend/ide/lib/files_spec.js
View file @
a7536d56
...
@@ -12,6 +12,7 @@ const createEntries = paths => {
...
@@ -12,6 +12,7 @@ const createEntries = paths => {
const
{
name
,
parent
}
=
splitParent
(
path
);
const
{
name
,
parent
}
=
splitParent
(
path
);
const
parentEntry
=
acc
[
parent
];
const
parentEntry
=
acc
[
parent
];
const
previewMode
=
viewerInformationForPath
(
name
);
acc
[
path
]
=
{
acc
[
path
]
=
{
...
decorateData
({
...
decorateData
({
...
@@ -22,7 +23,8 @@ const createEntries = paths => {
...
@@ -22,7 +23,8 @@ const createEntries = paths => {
path
,
path
,
url
:
createUrl
(
`/
${
TEST_PROJECT_ID
}
/
${
type
}
/
${
TEST_BRANCH_ID
}
/-/
${
escapeFileUrl
(
path
)}
`
),
url
:
createUrl
(
`/
${
TEST_PROJECT_ID
}
/
${
type
}
/
${
TEST_BRANCH_ID
}
/-/
${
escapeFileUrl
(
path
)}
`
),
type
,
type
,
previewMode
:
viewerInformationForPath
(
path
),
previewMode
,
binary
:
(
previewMode
&&
previewMode
.
binary
)
||
false
,
parentPath
:
parent
,
parentPath
:
parent
,
parentTreeUrl
:
parentEntry
parentTreeUrl
:
parentEntry
?
parentEntry
.
url
?
parentEntry
.
url
...
...
spec/javascripts/ide/components/repo_editor_spec.js
View file @
a7536d56
...
@@ -30,6 +30,7 @@ describe('RepoEditor', () => {
...
@@ -30,6 +30,7 @@ describe('RepoEditor', () => {
Vue
.
set
(
vm
.
$store
.
state
.
entries
,
f
.
path
,
f
);
Vue
.
set
(
vm
.
$store
.
state
.
entries
,
f
.
path
,
f
);
spyOn
(
vm
,
'
getFileData
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOn
(
vm
,
'
getFileData
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOn
(
vm
,
'
getRawFileData
'
).
and
.
returnValue
(
Promise
.
resolve
());
vm
.
$mount
();
vm
.
$mount
();
...
@@ -407,6 +408,44 @@ describe('RepoEditor', () => {
...
@@ -407,6 +408,44 @@ describe('RepoEditor', () => {
});
});
});
});
describe
(
'
initEditor
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
vm
.
editor
,
'
createInstance
'
);
spyOnProperty
(
vm
,
'
shouldHideEditor
'
).
and
.
returnValue
(
true
);
});
it
(
'
is being initialised for files without content even if shouldHideEditor is `true`
'
,
done
=>
{
vm
.
file
.
content
=
''
;
vm
.
file
.
raw
=
''
;
vm
.
initEditor
();
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
getFileData
).
toHaveBeenCalled
();
expect
(
vm
.
getRawFileData
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
does not initialize editor for files already with content
'
,
done
=>
{
expect
(
vm
.
getFileData
.
calls
.
count
()).
toEqual
(
1
);
expect
(
vm
.
getRawFileData
.
calls
.
count
()).
toEqual
(
1
);
vm
.
file
.
content
=
'
foo
'
;
vm
.
initEditor
();
vm
.
$nextTick
()
.
then
(()
=>
{
expect
(
vm
.
getFileData
.
calls
.
count
()).
toEqual
(
1
);
expect
(
vm
.
getRawFileData
.
calls
.
count
()).
toEqual
(
1
);
expect
(
vm
.
editor
.
createInstance
).
not
.
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
calls removePendingTab when old file is pending
'
,
done
=>
{
it
(
'
calls removePendingTab when old file is pending
'
,
done
=>
{
spyOnProperty
(
vm
,
'
shouldHideEditor
'
).
and
.
returnValue
(
true
);
spyOnProperty
(
vm
,
'
shouldHideEditor
'
).
and
.
returnValue
(
true
);
spyOn
(
vm
,
'
removePendingTab
'
);
spyOn
(
vm
,
'
removePendingTab
'
);
...
@@ -416,6 +455,7 @@ describe('RepoEditor', () => {
...
@@ -416,6 +455,7 @@ describe('RepoEditor', () => {
vm
.
$nextTick
()
vm
.
$nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
vm
.
file
=
file
(
'
testing
'
);
vm
.
file
=
file
(
'
testing
'
);
vm
.
file
.
content
=
'
foo
'
;
// need to prevent full cycle of initEditor
return
vm
.
$nextTick
();
return
vm
.
$nextTick
();
})
})
...
...
spec/javascripts/ide/stores/mutations/file_spec.js
View file @
a7536d56
...
@@ -83,6 +83,26 @@ describe('IDE store file mutations', () => {
...
@@ -83,6 +83,26 @@ describe('IDE store file mutations', () => {
expect
(
localFile
.
raw
).
toBeNull
();
expect
(
localFile
.
raw
).
toBeNull
();
expect
(
localFile
.
baseRaw
).
toBeNull
();
expect
(
localFile
.
baseRaw
).
toBeNull
();
});
});
it
(
'
sets extra file data to all arrays concerned
'
,
()
=>
{
localState
.
stagedFiles
=
[
localFile
];
localState
.
changedFiles
=
[
localFile
];
localState
.
openFiles
=
[
localFile
];
const
rawPath
=
'
foo/bar/blah.md
'
;
mutations
.
SET_FILE_DATA
(
localState
,
{
data
:
{
raw_path
:
rawPath
,
},
file
:
localFile
,
});
expect
(
localState
.
stagedFiles
[
0
].
rawPath
).
toEqual
(
rawPath
);
expect
(
localState
.
changedFiles
[
0
].
rawPath
).
toEqual
(
rawPath
);
expect
(
localState
.
openFiles
[
0
].
rawPath
).
toEqual
(
rawPath
);
expect
(
localFile
.
rawPath
).
toEqual
(
rawPath
);
});
});
});
describe
(
'
SET_FILE_RAW_DATA
'
,
()
=>
{
describe
(
'
SET_FILE_RAW_DATA
'
,
()
=>
{
...
...
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