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
09567e93
Commit
09567e93
authored
Jan 30, 2017
by
Fatih Acet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'document-how-to-vue' into 'master'
Document how to vue See merge request !8866
parents
067ce273
dd4cf31c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
18 deletions
+92
-18
changelogs/unreleased/document-how-to-vue.yml
changelogs/unreleased/document-how-to-vue.yml
+4
-0
doc/development/frontend.md
doc/development/frontend.md
+88
-18
No files found.
changelogs/unreleased/document-how-to-vue.yml
0 → 100644
View file @
09567e93
---
title
:
Adds documentation for how to use Vue.js
merge_request
:
8866
author
:
doc/development/frontend.md
View file @
09567e93
...
...
@@ -23,6 +23,69 @@ some ideas with React.js as well as Angular.
To get started with Vue, read through
[
their documentation
][
vue-docs
]
.
#### How to build a new feature with Vue.js
**Components, Stores and Services**
In some features implemented with Vue.js, like the
[
issue board
][
issue-boards
]
or
[
environments table
][
environments-table
]
you can find a clear separation of concerns:
```
new_feature
├── components
│ └── component.js.es6
│ └── ...
├── store
│ └── new_feature_store.js.es6
├── service
│ └── new_feature_service.js.es6
├── new_feature_bundle.js.es6
```
_For consistency purposes, we recommend you to follow the same structure._
Let's look into each of them:
**A `*_bundle.js` file**
This is the index file of your new feature. This is where the root Vue instance
of the new feature should be.
Don't forget to follow
[
these steps.
][
page-specific-javascript
]
**A folder for Components**
This folder holds all components that are specific of this new feature.
If you need to use or create a component that will probably be used somewhere
else, please refer to
`vue_shared/components`
.
A good thumb rule to know when you should create a component is to think if
it will be reusable elsewhere.
For example, tables are used in a quite amount of places across GitLab, a table
would be a good fit for a component.
On the other hand, a table cell used only in on table, would not be a good use
of this pattern.
You can read more about components in Vue.js site,
[
Component System
][
component-system
]
**A folder for the Store**
The Store is a simple object that allows us to manage the state in a single
source of truth.
The concept we are trying to follow is better explained by Vue documentation
itself, please read this guide:
[
State Management
][
state-management
]
**A folder for the Service**
The Service is used only to communicate with the server.
It does not store or manipulate any data.
We use
[
vue-resource
][
vue-resource-repo
]
to
communicate with the server.
The
[
issue boards service
][
issue-boards-service
]
is a good example of this pattern.
## Performance
### Resources
...
...
@@ -294,6 +357,13 @@ For our currently-supported browsers, see our [requirements][requirements].
[
xss
]:
https://en.wikipedia.org/wiki/Cross-site_scripting
[
scss-style-guide
]:
scss_styleguide.md
[
requirements
]:
../install/requirements.md#supported-web-browsers
[
issue-boards
]:
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/app/assets/javascripts/boards
[
environments-table
]:
https://gitlab.com/gitlab-org/gitlab-ce/tree/master/app/assets/javascripts/environments
[
page_specific_javascript
]:
https://docs.gitlab.com/ce/development/frontend.html#page-specific-javascript
[
component-system
]:
https://vuejs.org/v2/guide/#Composing-with-Components
[
state-management
]:
https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch
[
vue-resource-repo
]:
https://github.com/pagekit/vue-resource
[
issue-boards-service
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/boards/services/board_service.js.es6
## Gotchas
...
...
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