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
e0b33e27
Commit
e0b33e27
authored
Aug 02, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move edit button to its own view model abstract object
parent
ebec3843
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
45 deletions
+48
-45
app/assets/javascripts/repo/index.js
app/assets/javascripts/repo/index.js
+3
-8
app/assets/javascripts/repo/repo_edit_button.js
app/assets/javascripts/repo/repo_edit_button.js
+0
-36
app/assets/javascripts/repo/stores/repo_store.js
app/assets/javascripts/repo/stores/repo_store.js
+0
-1
app/assets/javascripts/repo/view_models/repo_edit_button_view_model.js
...vascripts/repo/view_models/repo_edit_button_view_model.js
+42
-0
app/assets/javascripts/repo/view_models/repo_view_model.js
app/assets/javascripts/repo/view_models/repo_view_model.js
+3
-0
No files found.
app/assets/javascripts/repo/index.js
View file @
e0b33e27
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
Translate
from
'
../vue_shared/translate
'
;
import
EditButton
from
'
./repo_edit_button
'
;
import
Service
from
'
./services/repo_service
'
;
import
Service
from
'
./services/repo_service
'
;
import
Store
from
'
./stores/repo_store
'
;
import
Store
from
'
./stores/repo_store
'
;
import
{
initRepoViewModel
}
from
'
./view_models/repo_view_model
'
;
import
{
initRepoViewModel
}
from
'
./view_models/repo_view_model
'
;
import
{
initRepoEditButtonViewModel
}
from
'
./view_models/repo_edit_button_view_model
'
;
Vue
.
use
(
Translate
);
function
initDropdowns
()
{
function
initDropdowns
()
{
$
(
'
.project-refs-target-form
'
).
hide
();
$
(
'
.project-refs-target-form
'
).
hide
();
...
@@ -42,15 +38,14 @@ function setInitialStore(data) {
...
@@ -42,15 +38,14 @@ function setInitialStore(data) {
function
initRepo
()
{
function
initRepo
()
{
const
repo
=
document
.
getElementById
(
'
repo
'
);
const
repo
=
document
.
getElementById
(
'
repo
'
);
const
editButton
=
document
.
getElementById
(
'
editable-mode
'
);
setInitialStore
(
repo
.
dataset
);
setInitialStore
(
repo
.
dataset
);
addEventsForNonVueEls
();
addEventsForNonVueEls
();
initDropdowns
();
initDropdowns
();
initRepoViewModel
(
repo
);
initRepoViewModel
(
repo
);
initRepoEditButtonViewModel
(
editButton
);
const
editButton
=
document
.
getElementById
(
'
editable-mode
'
);
Store
.
editButton
=
new
EditButton
(
editButton
);
}
}
$
(
initRepo
);
$
(
initRepo
);
...
...
app/assets/javascripts/repo/repo_edit_button.js
deleted
100644 → 0
View file @
ebec3843
import
Vue
from
'
vue
'
;
import
Store
from
'
./stores/repo_store
'
;
import
RepoMixin
from
'
./mixins/repo_mixin
'
;
import
{
__
}
from
'
../locale
'
;
export
default
class
RepoEditButton
{
constructor
(
el
)
{
this
.
initVue
(
el
);
}
initVue
(
el
)
{
this
.
vue
=
new
Vue
({
el
,
mixins
:
[
RepoMixin
],
data
:
()
=>
Store
,
computed
:
{
buttonLabel
()
{
return
this
.
editMode
?
__
(
'
Cancel edit
'
)
:
__
(
'
Edit
'
);
},
buttonIcon
()
{
return
this
.
editMode
?
[]
:
[
'
fa
'
,
'
fa-pencil
'
];
},
},
methods
:
{
editClicked
()
{
if
(
this
.
changedFiles
.
length
)
{
this
.
dialog
.
open
=
true
;
return
;
}
this
.
editMode
=
!
this
.
editMode
;
},
},
});
}
}
app/assets/javascripts/repo/stores/repo_store.js
View file @
e0b33e27
...
@@ -8,7 +8,6 @@ const RepoStore = {
...
@@ -8,7 +8,6 @@ const RepoStore = {
service
:
''
,
service
:
''
,
editor
:
''
,
editor
:
''
,
sidebar
:
''
,
sidebar
:
''
,
editButton
:
''
,
editMode
:
false
,
editMode
:
false
,
isTree
:
false
,
isTree
:
false
,
isRoot
:
false
,
isRoot
:
false
,
...
...
app/assets/javascripts/repo/view_models/repo_edit_button_view_model.js
0 → 100644
View file @
e0b33e27
import
Vue
from
'
vue
'
;
import
Store
from
'
../stores/repo_store
'
;
import
RepoMixin
from
'
../mixins/repo_mixin
'
;
import
Translate
from
'
../../vue_shared/translate
'
;
import
{
__
}
from
'
../../locale
'
;
Vue
.
use
(
Translate
);
const
RepoEditButton
=
{
el
:
undefined
,
mixins
:
[
RepoMixin
],
data
:
()
=>
Store
,
computed
:
{
buttonLabel
()
{
return
this
.
editMode
?
__
(
'
Cancel edit
'
)
:
__
(
'
Edit
'
);
},
buttonIcon
()
{
return
this
.
editMode
?
[]
:
[
'
fa
'
,
'
fa-pencil
'
];
},
},
methods
:
{
editClicked
()
{
if
(
this
.
changedFiles
.
length
)
{
this
.
dialog
.
open
=
true
;
return
;
}
this
.
editMode
=
!
this
.
editMode
;
},
},
};
function
initRepoEditButtonViewModel
(
el
)
{
RepoEditButton
.
el
=
el
;
return
new
Vue
(
RepoEditButton
);
}
export
{
RepoEditButton
as
default
,
initRepoEditButtonViewModel
,
};
app/assets/javascripts/repo/view_models/repo_view_model.js
View file @
e0b33e27
...
@@ -8,6 +8,9 @@ import RepoMixin from '../mixins/repo_mixin';
...
@@ -8,6 +8,9 @@ import RepoMixin from '../mixins/repo_mixin';
import
PopupDialog
from
'
../../vue_shared/components/popup_dialog.vue
'
;
import
PopupDialog
from
'
../../vue_shared/components/popup_dialog.vue
'
;
import
Store
from
'
../stores/repo_store
'
;
import
Store
from
'
../stores/repo_store
'
;
import
MonacoLoaderHelper
from
'
../helpers/monaco_loader_helper
'
;
import
MonacoLoaderHelper
from
'
../helpers/monaco_loader_helper
'
;
import
Translate
from
'
../../vue_shared/translate
'
;
Vue
.
use
(
Translate
);
const
Repo
=
{
const
Repo
=
{
el
:
undefined
,
el
:
undefined
,
...
...
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