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
aafc8c24
Commit
aafc8c24
authored
Feb 22, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup initial Vue app for design management
parent
cab0468e
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
209 additions
and
13 deletions
+209
-13
app/assets/javascripts/issuable_suggestions/index.js
app/assets/javascripts/issuable_suggestions/index.js
+2
-2
app/assets/javascripts/lib/graphql.js
app/assets/javascripts/lib/graphql.js
+8
-6
doc/development/fe_guide/graphql.md
doc/development/fe_guide/graphql.md
+26
-2
ee/app/assets/javascripts/design_management/components/app.vue
...p/assets/javascripts/design_management/components/app.vue
+3
-0
ee/app/assets/javascripts/design_management/graphql.js
ee/app/assets/javascripts/design_management/graphql.js
+9
-0
ee/app/assets/javascripts/design_management/index.js
ee/app/assets/javascripts/design_management/index.js
+24
-0
ee/app/assets/javascripts/design_management/pages/design/index.vue
...sets/javascripts/design_management/pages/design/index.vue
+17
-0
ee/app/assets/javascripts/design_management/pages/index.vue
ee/app/assets/javascripts/design_management/pages/index.vue
+6
-0
ee/app/assets/javascripts/design_management/router.js
ee/app/assets/javascripts/design_management/router.js
+46
-0
ee/app/assets/javascripts/pages/projects/issues/show/index.js
...pp/assets/javascripts/pages/projects/issues/show/index.js
+6
-0
ee/app/controllers/ee/projects/issues_controller.rb
ee/app/controllers/ee/projects/issues_controller.rb
+3
-0
ee/app/views/projects/issues/_discussion.html.haml
ee/app/views/projects/issues/_discussion.html.haml
+3
-3
ee/spec/javascripts/design_management/router_spec.js
ee/spec/javascripts/design_management/router_spec.js
+56
-0
No files found.
app/assets/javascripts/issuable_suggestions/index.js
View file @
aafc8c24
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
d
efaultClient
from
'
~/lib/graphql
'
;
import
createD
efaultClient
from
'
~/lib/graphql
'
;
import
App
from
'
./components/app.vue
'
;
Vue
.
use
(
VueApollo
);
...
...
@@ -10,7 +10,7 @@ export default function() {
const
issueTitle
=
document
.
getElementById
(
'
issue_title
'
);
const
{
projectPath
}
=
el
.
dataset
;
const
apolloProvider
=
new
VueApollo
({
defaultClient
,
defaultClient
:
createDefaultClient
()
,
});
return
new
Vue
({
...
...
app/assets/javascripts/lib/graphql.js
View file @
aafc8c24
import
ApolloClient
from
'
apollo-boost
'
;
import
csrf
from
'
~/lib/utils/csrf
'
;
export
default
new
ApolloClient
({
uri
:
`
${
gon
.
relative_url_root
}
/api/graphql`
,
headers
:
{
[
csrf
.
headerKey
]:
csrf
.
token
,
},
});
export
default
(
clientState
=
{})
=>
new
ApolloClient
({
uri
:
`
${
gon
.
relative_url_root
}
/api/graphql`
,
headers
:
{
[
csrf
.
headerKey
]:
csrf
.
token
,
},
clientState
,
});
doc/development/fe_guide/graphql.md
View file @
aafc8c24
...
...
@@ -27,11 +27,11 @@ the Vue application is mounted.
```
javascript
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
d
efaultClient
from
'
~/lib/graphql
'
;
import
createD
efaultClient
from
'
~/lib/graphql
'
;
Vue
.
use
(
VueApollo
);
const
apolloProvider
=
new
VueApollo
({
defaultClient
,
defaultClient
:
createDefaultClient
()
,
});
new
Vue
({
...
...
@@ -43,6 +43,29 @@ new Vue({
Read more about
[
Vue Apollo
][
vue-apollo
]
in the
[
Vue Apollo documentation
][
vue-apollo-docs
]
.
### Local state with `apollo-link-state`
It is possible to use our Apollo setup with
[
apollo-link-state
][
apollo-link-state
]
by passing
in the client state object when creating the default client.
```
javascript
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
Vue
.
use
(
VueApollo
);
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
createDefaultClient
({
defaults
:
{
testing
:
true
,
},
resolvers
:
{
...
},
}),
});
```
### Testing
With
[
Vue test utils
][
vue-test-utils
]
it is easy to quickly test components that
...
...
@@ -81,3 +104,4 @@ Read more about the [Apollo] client in the [Apollo documentation][apollo-client-
[
default-client
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/lib/graphql.js
[
apollo-client-docs
]:
https://www.apollographql.com/docs/tutorial/client.html
[
vue-test-utils
]:
https://vue-test-utils.vuejs.org/
[
apollo-link-state
]:
https://www.apollographql.com/docs/link/links/state.html
ee/app/assets/javascripts/design_management/components/app.vue
0 → 100644
View file @
aafc8c24
<
template
>
<router-view
/>
</
template
>
ee/app/assets/javascripts/design_management/graphql.js
0 → 100644
View file @
aafc8c24
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
Vue
.
use
(
VueApollo
);
export
default
new
VueApollo
({
defaultClient
:
createDefaultClient
(),
});
ee/app/assets/javascripts/design_management/index.js
0 → 100644
View file @
aafc8c24
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
router
from
'
./router
'
;
import
App
from
'
./components/app.vue
'
;
import
apolloProvider
from
'
./graphql
'
;
export
default
()
=>
{
$
(
'
.js-issue-tabs
'
).
on
(
'
shown.bs.tab
'
,
({
target
:
{
id
}
})
=>
{
if
(
id
===
'
designs
'
&&
router
.
currentRoute
.
name
===
'
root
'
)
{
router
.
push
(
'
/designs
'
);
}
else
if
(
id
===
'
discussion
'
)
{
router
.
push
(
'
/
'
);
}
});
return
new
Vue
({
el
:
document
.
getElementById
(
'
js-design-management
'
),
router
,
apolloProvider
,
render
(
createElement
)
{
return
createElement
(
App
);
},
});
};
ee/app/assets/javascripts/design_management/pages/design/index.vue
0 → 100644
View file @
aafc8c24
<
script
>
export
default
{
props
:
{
id
:
{
type
:
Number
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<div>
Design detail for
{{
id
}}
<router-link
to=
"/designs"
>
All designs
</router-link>
</div>
</
template
>
ee/app/assets/javascripts/design_management/pages/index.vue
0 → 100644
View file @
aafc8c24
<
template
>
<div>
Home
<router-link
to=
"/designs/1"
>
Design
</router-link>
</div>
</
template
>
ee/app/assets/javascripts/design_management/router.js
0 → 100644
View file @
aafc8c24
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
VueRouter
from
'
vue-router
'
;
import
Home
from
'
./pages/index.vue
'
;
import
DesignDetail
from
'
./pages/design/index.vue
'
;
Vue
.
use
(
VueRouter
);
const
router
=
new
VueRouter
({
base
:
window
.
location
.
pathname
,
routes
:
[
{
name
:
'
root
'
,
path
:
'
/
'
,
component
:
null
,
meta
:
{
el
:
'
discussion
'
,
},
},
{
name
:
'
designs
'
,
path
:
'
/designs
'
,
component
:
Home
,
meta
:
{
el
:
'
designs
'
,
},
},
{
name
:
'
design
'
,
path
:
'
/designs/:id
'
,
component
:
DesignDetail
,
meta
:
{
el
:
'
designs
'
,
},
props
:
({
params
:
{
id
}
})
=>
({
id
:
parseInt
(
id
,
10
)
}),
},
],
});
router
.
beforeEach
(({
meta
:
{
el
}
},
from
,
next
)
=>
{
$
(
`#
${
el
}
`
).
tab
(
'
show
'
);
next
();
});
export
default
router
;
ee/app/assets/javascripts/pages/projects/issues/show/index.js
View file @
aafc8c24
...
...
@@ -8,6 +8,12 @@ document.addEventListener('DOMContentLoaded', () => {
initSidebarBundle
();
initRelatedIssues
();
if
(
gon
.
features
.
versionedDesigns
)
{
import
(
/* webpackChunkName: 'design_management' */
'
ee/design_management
'
)
.
then
(
module
=>
module
.
default
())
.
catch
(()
=>
{});
}
// eslint-disable-next-line no-new
new
UserCallout
({
className
:
'
js-epics-sidebar-callout
'
});
// eslint-disable-next-line no-new
...
...
ee/app/controllers/ee/projects/issues_controller.rb
View file @
aafc8c24
...
...
@@ -16,6 +16,9 @@ module EE
before_action
:check_export_issues_available!
,
only:
[
:export_csv
]
before_action
:check_service_desk_available!
,
only:
[
:service_desk
]
before_action
:whitelist_query_limiting_ee
,
only:
[
:update
]
before_action
only: :show
do
push_frontend_feature_flag
(
:versioned_designs
)
end
end
override
:issue_except_actions
...
...
ee/app/views/projects/issues/_discussion.html.haml
View file @
aafc8c24
-
if
Feature
.
enabled?
(
:versioned_designs
)
%ul
.nav-tabs.nav.nav-links
{
role:
'tablist'
}
%li
=
link_to
'#discussion-tab'
,
class:
'active'
,
id:
'discussion'
,
role:
'tab'
,
'aria-controls'
:
'js-discussion'
,
'aria-selected'
:
'true'
,
data:
{
toggle:
'tab'
,
target:
'#discussion-tab'
}
do
=
link_to
'#discussion-tab'
,
class:
'active
js-issue-tabs
'
,
id:
'discussion'
,
role:
'tab'
,
'aria-controls'
:
'js-discussion'
,
'aria-selected'
:
'true'
,
data:
{
toggle:
'tab'
,
target:
'#discussion-tab'
}
do
=
_
(
'Discussion'
)
%span
.badge.badge-pill.js-discussions-count
%li
=
link_to
'#designs-tab'
,
id:
'designs'
,
role:
'tab'
,
'aria-controls'
:
'js-designs'
,
'aria-selected'
:
'false'
,
data:
{
toggle:
'tab'
,
target:
'#designs-tab'
}
do
=
link_to
'#designs-tab'
,
class:
'js-issue-tabs'
,
id:
'designs'
,
role:
'tab'
,
'aria-controls'
:
'js-designs'
,
'aria-selected'
:
'false'
,
data:
{
toggle:
'tab'
,
target:
'#designs-tab'
}
do
=
_
(
'Designs'
)
%span
.badge.badge-pill.js-designs-count
.tab-content
#discussion-tab
.tab-pane.show.active
{
role:
'tabpanel'
,
'aria-labelledby'
:
'discussion'
}
=
render_ce
'projects/issues/discussion'
#designs-tab
.tab-pane
{
role:
'tabpanel'
,
'aria-labelledby'
:
'designs'
}
=
spinner
nil
,
true
#js-design-management
-
else
=
render_ce
'projects/issues/discussion'
ee/spec/javascripts/design_management/router_spec.js
0 → 100644
View file @
aafc8c24
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
VueRouter
from
'
vue-router
'
;
import
App
from
'
ee/design_management/components/app.vue
'
;
import
Designs
from
'
ee/design_management/pages/index.vue
'
;
import
DesignDetail
from
'
ee/design_management/pages/design/index.vue
'
;
import
router
from
'
ee/design_management/router
'
;
describe
(
'
Design management router
'
,
()
=>
{
let
vm
;
function
factory
()
{
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueRouter
);
vm
=
mount
(
App
,
{
localVue
,
router
});
}
beforeEach
(()
=>
{
factory
();
});
afterEach
(()
=>
{
vm
.
destroy
();
router
.
app
.
$destroy
();
window
.
location
.
hash
=
''
;
});
describe
(
'
root
'
,
()
=>
{
it
(
'
pushes empty component
'
,
()
=>
{
router
.
push
(
'
/
'
);
expect
(
vm
.
isEmpty
()).
toBe
(
true
);
});
});
describe
(
'
designs
'
,
()
=>
{
it
(
'
pushes designs root component
'
,
()
=>
{
router
.
push
(
'
/designs
'
);
expect
(
vm
.
find
(
Designs
).
exists
()).
toBe
(
true
);
});
});
describe
(
'
designs detail
'
,
()
=>
{
it
(
'
pushes designs detail component
'
,
()
=>
{
router
.
push
(
'
/designs/1
'
);
const
detail
=
vm
.
find
(
DesignDetail
);
expect
(
detail
.
exists
()).
toBe
(
true
);
expect
(
detail
.
props
(
'
id
'
)).
toEqual
(
1
);
});
});
});
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