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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
bdac5569
Commit
bdac5569
authored
Oct 26, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed some state bugs with the tabs
[ci skip]
parent
1543679e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
38 deletions
+53
-38
app/assets/javascripts/repo/components/new_dropdown/index.vue
...assets/javascripts/repo/components/new_dropdown/index.vue
+0
-7
app/assets/javascripts/repo/components/new_dropdown/modal.vue
...assets/javascripts/repo/components/new_dropdown/modal.vue
+14
-7
app/assets/javascripts/repo/components/repo_editor.vue
app/assets/javascripts/repo/components/repo_editor.vue
+3
-1
app/assets/javascripts/repo/components/repo_file_buttons.vue
app/assets/javascripts/repo/components/repo_file_buttons.vue
+0
-8
app/assets/javascripts/repo/components/repo_tab.vue
app/assets/javascripts/repo/components/repo_tab.vue
+3
-3
app/assets/javascripts/repo/stores/actions.js
app/assets/javascripts/repo/stores/actions.js
+11
-3
app/assets/javascripts/repo/stores/actions/file.js
app/assets/javascripts/repo/stores/actions/file.js
+19
-5
app/assets/javascripts/repo/stores/actions/tree.js
app/assets/javascripts/repo/stores/actions/tree.js
+1
-0
app/assets/javascripts/repo/stores/state.js
app/assets/javascripts/repo/stores/state.js
+1
-1
app/views/shared/repo/_repo.html.haml
app/views/shared/repo/_repo.html.haml
+1
-3
No files found.
app/assets/javascripts/repo/components/new_dropdown/index.vue
View file @
bdac5569
<
script
>
<
script
>
import
{
mapState
}
from
'
vuex
'
;
import
newModal
from
'
./modal.vue
'
;
import
newModal
from
'
./modal.vue
'
;
export
default
{
export
default
{
...
@@ -12,11 +11,6 @@
...
@@ -12,11 +11,6 @@
modalType
:
''
,
modalType
:
''
,
};
};
},
},
computed
:
{
...
mapState
({
currentPath
:
'
path
'
,
}),
},
methods
:
{
methods
:
{
createNewItem
(
type
)
{
createNewItem
(
type
)
{
this
.
modalType
=
type
;
this
.
modalType
=
type
;
...
@@ -70,7 +64,6 @@
...
@@ -70,7 +64,6 @@
<new-modal
<new-modal
v-if=
"openModal"
v-if=
"openModal"
:type=
"modalType"
:type=
"modalType"
:current-path=
"currentPath"
@
toggle=
"toggleModalOpen"
@
toggle=
"toggleModalOpen"
/>
/>
</div>
</div>
...
...
app/assets/javascripts/repo/components/new_dropdown/modal.vue
View file @
bdac5569
<
script
>
<
script
>
import
{
mapActions
}
from
'
vuex
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
__
}
from
'
../../../locale
'
;
import
{
__
}
from
'
../../../locale
'
;
import
popupDialog
from
'
../../../vue_shared/components/popup_dialog.vue
'
;
import
popupDialog
from
'
../../../vue_shared/components/popup_dialog.vue
'
;
export
default
{
export
default
{
props
:
{
props
:
{
currentPath
:
{
type
:
String
,
required
:
true
,
},
type
:
{
type
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -16,7 +12,7 @@
...
@@ -16,7 +12,7 @@
},
},
data
()
{
data
()
{
return
{
return
{
entryName
:
this
.
currentPath
!==
''
?
`
${
this
.
currentPath
}
/`
:
''
,
entryName
:
''
,
};
};
},
},
components
:
{
components
:
{
...
@@ -39,6 +35,17 @@
...
@@ -39,6 +35,17 @@
},
},
},
},
computed
:
{
computed
:
{
...
mapState
([
'
path
'
,
]),
name
:
{
get
()
{
return
this
.
path
!==
''
?
`
${
this
.
path
}
/
${
this
.
entryName
}
`
:
this
.
entryName
;
},
set
(
newVal
)
{
this
.
entryName
=
newVal
.
replace
(
`
${
this
.
path
}
/`
,
''
);
},
},
modalTitle
()
{
modalTitle
()
{
if
(
this
.
type
===
'
tree
'
)
{
if
(
this
.
type
===
'
tree
'
)
{
return
__
(
'
Create new directory
'
);
return
__
(
'
Create new directory
'
);
...
@@ -88,7 +95,7 @@
...
@@ -88,7 +95,7 @@
<input
<input
type=
"text"
type=
"text"
class=
"form-control"
class=
"form-control"
v-model=
"
entryN
ame"
v-model=
"
n
ame"
ref=
"fieldName"
ref=
"fieldName"
/>
/>
</div>
</div>
...
...
app/assets/javascripts/repo/components/repo_editor.vue
View file @
bdac5569
...
@@ -51,6 +51,8 @@ export default {
...
@@ -51,6 +51,8 @@ export default {
.
catch
(()
=>
flash
(
'
Error setting up monaco. Please try again.
'
));
.
catch
(()
=>
flash
(
'
Error setting up monaco. Please try again.
'
));
},
},
setupEditor
()
{
setupEditor
()
{
if
(
!
this
.
activeFile
)
return
;
const
foundLang
=
this
.
languages
.
find
(
lang
=>
const
foundLang
=
this
.
languages
.
find
(
lang
=>
lang
.
extensions
&&
lang
.
extensions
.
indexOf
(
this
.
activeFileExtension
)
===
0
,
lang
.
extensions
&&
lang
.
extensions
.
indexOf
(
this
.
activeFileExtension
)
===
0
,
);
);
...
@@ -71,7 +73,7 @@ export default {
...
@@ -71,7 +73,7 @@ export default {
},
},
watch
:
{
watch
:
{
activeFile
(
oldVal
,
newVal
)
{
activeFile
(
oldVal
,
newVal
)
{
if
(
newVal
.
active
)
{
if
(
!
newVal
.
active
)
{
this
.
initMonaco
();
this
.
initMonaco
();
}
}
},
},
...
...
app/assets/javascripts/repo/components/repo_file_buttons.vue
View file @
bdac5569
...
@@ -52,13 +52,5 @@ export default {
...
@@ -52,13 +52,5 @@ export default {
Permalink
Permalink
</a>
</a>
</div>
</div>
<!--
<a
v-if=
"canPreview"
href=
"#"
@
click.prevent=
"rawPreviewToggle"
class=
"btn btn-default preview"
>
{{
activeFileLabel
}}
</a>
-->
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/repo/components/repo_tab.vue
View file @
bdac5569
...
@@ -11,7 +11,7 @@ export default {
...
@@ -11,7 +11,7 @@ export default {
computed
:
{
computed
:
{
closeLabel
()
{
closeLabel
()
{
if
(
this
.
tab
.
changed
)
{
if
(
this
.
tab
.
changed
||
this
.
tab
.
tempFile
)
{
return
`
${
this
.
tab
.
name
}
changed`
;
return
`
${
this
.
tab
.
name
}
changed`
;
}
}
return
`Close
${
this
.
tab
.
name
}
`
;
return
`Close
${
this
.
tab
.
name
}
`
;
...
@@ -42,7 +42,7 @@ export default {
...
@@ -42,7 +42,7 @@ export default {
<button
<button
type=
"button"
type=
"button"
class=
"close-btn"
class=
"close-btn"
@
click.stop.prevent=
"closeFile(
tab
)"
@
click.stop.prevent=
"closeFile(
{ file: tab }
)"
:aria-label="closeLabel">
:aria-label="closeLabel">
<i
<i
class=
"fa"
class=
"fa"
...
@@ -55,7 +55,7 @@ export default {
...
@@ -55,7 +55,7 @@ export default {
href=
"#"
href=
"#"
class=
"repo-tab"
class=
"repo-tab"
:title=
"tab.url"
:title=
"tab.url"
@
click.prevent=
"setFileActive(tab)"
>
@
click.prevent
.stop
=
"setFileActive(tab)"
>
{{
tab
.
name
}}
{{
tab
.
name
}}
</a>
</a>
</li>
</li>
...
...
app/assets/javascripts/repo/stores/actions.js
View file @
bdac5569
...
@@ -10,14 +10,22 @@ export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DAT
...
@@ -10,14 +10,22 @@ export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DAT
export
const
closeDiscardPopup
=
({
commit
})
=>
commit
(
types
.
TOGGLE_DISCARD_POPUP
,
false
);
export
const
closeDiscardPopup
=
({
commit
})
=>
commit
(
types
.
TOGGLE_DISCARD_POPUP
,
false
);
export
const
discardAllChanges
=
({
commit
,
getters
})
=>
{
export
const
discardAllChanges
=
({
state
,
commit
,
getters
,
dispatch
})
=>
{
if
(
state
.
editMode
)
return
;
const
changedFiles
=
getters
.
changedFiles
;
const
changedFiles
=
getters
.
changedFiles
;
changedFiles
.
forEach
(
file
=>
commit
(
types
.
DISCARD_FILE_CHANGES
,
file
));
changedFiles
.
forEach
((
file
)
=>
{
commit
(
types
.
DISCARD_FILE_CHANGES
,
file
);
if
(
file
.
tempFile
)
{
dispatch
(
'
closeFile
'
,
{
file
,
force
:
true
});
}
});
};
};
export
const
closeAllFiles
=
({
state
,
dispatch
})
=>
{
export
const
closeAllFiles
=
({
state
,
dispatch
})
=>
{
state
.
openFiles
.
forEach
(
file
=>
dispatch
(
'
closeFile
'
,
file
));
state
.
openFiles
.
forEach
(
file
=>
dispatch
(
'
closeFile
'
,
{
file
}
));
};
};
export
const
toggleEditMode
=
({
commit
,
getters
,
dispatch
},
force
=
false
)
=>
{
export
const
toggleEditMode
=
({
commit
,
getters
,
dispatch
},
force
=
false
)
=>
{
...
...
app/assets/javascripts/repo/stores/actions/file.js
View file @
bdac5569
import
{
normalizeHeaders
}
from
'
../../../lib/utils/common_utils
'
;
import
flash
from
'
../../../flash
'
;
import
flash
from
'
../../../flash
'
;
import
service
from
'
../../services
'
;
import
service
from
'
../../services
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
{
import
{
pushState
,
setPageTitle
,
createTemp
,
createTemp
,
findIndexOfFile
,
findIndexOfFile
,
}
from
'
../utils
'
;
}
from
'
../utils
'
;
export
const
closeFile
=
({
commit
,
state
,
dispatch
},
file
)
=>
{
export
const
closeFile
=
({
commit
,
state
,
dispatch
},
{
file
,
force
=
false
}
)
=>
{
if
(
file
.
changed
||
file
.
tempFil
e
)
return
;
if
(
(
file
.
changed
||
file
.
tempFile
)
&&
!
forc
e
)
return
;
const
indexOfClosedFile
=
findIndexOfFile
(
state
.
openFiles
,
file
);
const
indexOfClosedFile
=
findIndexOfFile
(
state
.
openFiles
,
file
);
const
fileWasActive
=
file
.
active
;
const
fileWasActive
=
file
.
active
;
...
@@ -20,12 +23,16 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
...
@@ -20,12 +23,16 @@ export const closeFile = ({ commit, state, dispatch }, file) => {
const
nextFileToOpen
=
state
.
openFiles
[
nextIndexToOpen
];
const
nextFileToOpen
=
state
.
openFiles
[
nextIndexToOpen
];
dispatch
(
'
setFileActive
'
,
nextFileToOpen
);
dispatch
(
'
setFileActive
'
,
nextFileToOpen
);
}
else
if
(
!
state
.
openFiles
.
length
)
{
pushState
(
file
.
parentTreeUrl
);
}
}
};
};
export
const
setFileActive
=
({
commit
,
state
,
getters
,
dispatch
},
file
)
=>
{
export
const
setFileActive
=
({
commit
,
state
,
getters
,
dispatch
},
file
)
=>
{
const
currentActiveFile
=
getters
.
activeFile
;
const
currentActiveFile
=
getters
.
activeFile
;
if
(
file
.
active
)
return
;
if
(
currentActiveFile
)
{
if
(
currentActiveFile
)
{
commit
(
types
.
SET_FILE_ACTIVE
,
{
file
:
currentActiveFile
,
active
:
false
});
commit
(
types
.
SET_FILE_ACTIVE
,
{
file
:
currentActiveFile
,
active
:
false
});
}
}
...
@@ -34,17 +41,24 @@ export const setFileActive = ({ commit, state, getters, dispatch }, file) => {
...
@@ -34,17 +41,24 @@ export const setFileActive = ({ commit, state, getters, dispatch }, file) => {
dispatch
(
'
scrollToTab
'
);
dispatch
(
'
scrollToTab
'
);
};
};
export
const
getFileData
=
({
commit
,
dispatch
},
file
)
=>
{
export
const
getFileData
=
({
state
,
commit
,
dispatch
},
file
)
=>
{
commit
(
types
.
TOGGLE_LOADING
,
file
);
commit
(
types
.
TOGGLE_LOADING
,
file
);
service
.
getFileData
(
file
.
url
)
service
.
getFileData
(
file
.
url
)
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
const
pageTitle
=
decodeURI
(
normalizeHeaders
(
res
.
headers
)[
'
PAGE-TITLE
'
]);
setPageTitle
(
pageTitle
);
return
res
.
json
();
})
.
then
((
data
)
=>
{
.
then
((
data
)
=>
{
commit
(
types
.
SET_FILE_DATA
,
{
data
,
file
});
commit
(
types
.
SET_FILE_DATA
,
{
data
,
file
});
commit
(
types
.
SET_PREVIEW_MODE
);
commit
(
types
.
TOGGLE_FILE_OPEN
,
file
);
commit
(
types
.
TOGGLE_FILE_OPEN
,
file
);
dispatch
(
'
setFileActive
'
,
file
);
dispatch
(
'
setFileActive
'
,
file
);
commit
(
types
.
TOGGLE_LOADING
,
file
);
commit
(
types
.
TOGGLE_LOADING
,
file
);
pushState
(
file
.
url
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
commit
(
types
.
TOGGLE_LOADING
,
file
);
commit
(
types
.
TOGGLE_LOADING
,
file
);
...
...
app/assets/javascripts/repo/stores/actions/tree.js
View file @
bdac5569
...
@@ -93,6 +93,7 @@ export const createTempTree = ({ state, commit, dispatch }, name) => {
...
@@ -93,6 +93,7 @@ export const createTempTree = ({ state, commit, dispatch }, name) => {
parent
:
tree
,
parent
:
tree
,
tmpEntry
,
tmpEntry
,
});
});
commit
(
types
.
TOGGLE_TREE_OPEN
,
tmpEntry
);
tree
=
tmpEntry
;
tree
=
tmpEntry
;
}
else
{
}
else
{
...
...
app/assets/javascripts/repo/stores/state.js
View file @
bdac5569
...
@@ -14,7 +14,7 @@ export default {
...
@@ -14,7 +14,7 @@ export default {
onTopOfBranch
:
false
,
onTopOfBranch
:
false
,
editMode
:
false
,
editMode
:
false
,
loading
:
false
,
loading
:
false
,
currentBlobView
:
''
,
currentBlobView
:
'
repo-preview
'
,
discardPopupOpen
:
false
,
discardPopupOpen
:
false
,
tree
:
[],
tree
:
[],
openFiles
:
[],
openFiles
:
[],
...
...
app/views/shared/repo/_repo.html.haml
View file @
bdac5569
#repo
{
data:
{
root:
@path
.
empty?
.
to_s
,
#repo
{
data:
{
root:
@path
.
empty?
.
to_s
,
root_url:
project_tree_path
(
@
project
),
root_url:
project_tree_path
(
project
),
url:
content_url
,
url:
content_url
,
ref:
@commit
.
id
,
ref:
@commit
.
id
,
project_name:
project
.
name
,
project_name:
project
.
name
,
refs_url:
refs_project_path
(
project
,
format: :json
),
project_url:
project_path
(
project
),
project_url:
project_path
(
project
),
project_id:
project
.
id
,
project_id:
project
.
id
,
blob_url:
namespace_project_blob_path
(
project
.
namespace
,
project
,
'
{{
branch
}}
'
),
new_merge_request_url:
namespace_project_new_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
''
}),
new_merge_request_url:
namespace_project_new_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
''
}),
can_commit:
(
!!
can_push_branch?
(
project
,
@ref
)).
to_s
,
can_commit:
(
!!
can_push_branch?
(
project
,
@ref
)).
to_s
,
on_top_of_branch:
(
!!
on_top_of_branch?
(
project
,
@ref
)).
to_s
,
on_top_of_branch:
(
!!
on_top_of_branch?
(
project
,
@ref
)).
to_s
,
...
...
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