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
6cbbcbe2
Commit
6cbbcbe2
authored
May 06, 2021
by
Simon Knox
Committed by
Nicolò Maria Mezzopera
May 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use vue-router for Iteration Cadences
parent
a4e70544
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
66 additions
and
41 deletions
+66
-41
ee/app/assets/javascripts/iterations/components/app.vue
ee/app/assets/javascripts/iterations/components/app.vue
+3
-0
ee/app/assets/javascripts/iterations/components/iteration_cadence_form.vue
...ascripts/iterations/components/iteration_cadence_form.vue
+3
-15
ee/app/assets/javascripts/iterations/components/iteration_cadences_list.vue
...scripts/iterations/components/iteration_cadences_list.vue
+1
-0
ee/app/assets/javascripts/iterations/index.js
ee/app/assets/javascripts/iterations/index.js
+9
-10
ee/app/assets/javascripts/iterations/router.js
ee/app/assets/javascripts/iterations/router.js
+29
-0
ee/app/assets/javascripts/pages/groups/iteration_cadences/index.js
...sets/javascripts/pages/groups/iteration_cadences/index.js
+2
-2
ee/app/views/groups/iteration_cadences/edit.html.haml
ee/app/views/groups/iteration_cadences/edit.html.haml
+1
-1
ee/app/views/groups/iteration_cadences/index.html.haml
ee/app/views/groups/iteration_cadences/index.html.haml
+3
-0
ee/app/views/groups/iteration_cadences/new.html.haml
ee/app/views/groups/iteration_cadences/new.html.haml
+1
-1
ee/spec/frontend/iterations/components/iteration_cadence_form_spec.js
...tend/iterations/components/iteration_cadence_form_spec.js
+14
-12
No files found.
ee/app/assets/javascripts/iterations/components/app.vue
0 → 100644
View file @
6cbbcbe2
<
template
>
<router-view
/>
</
template
>
ee/app/assets/javascripts/iterations/components/iteration_cadence_form.vue
View file @
6cbbcbe2
...
...
@@ -9,7 +9,6 @@ import {
GlFormInput
,
GlFormSelect
,
}
from
'
@gitlab/ui
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
import
createCadence
from
'
../queries/create_cadence.mutation.graphql
'
;
...
...
@@ -65,14 +64,7 @@ export default {
GlFormInput
,
GlFormSelect
,
},
inject
:
[
'
groupPath
'
],
props
:
{
cadencesListPath
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
},
inject
:
[
'
groupPath
'
,
'
cadencesListPath
'
],
data
()
{
return
{
cadences
:
[],
...
...
@@ -150,11 +142,7 @@ export default {
return
this
.
createCadence
();
},
cancel
()
{
if
(
this
.
cadencesListPath
)
{
visitUrl
(
this
.
cadencesListPath
);
}
else
{
this
.
$emit
(
'
cancel
'
);
}
this
.
$router
.
push
({
name
:
'
index
'
});
},
createCadence
()
{
return
this
.
$apollo
...
...
@@ -175,7 +163,7 @@ export default {
return
;
}
visitUrl
(
this
.
cadencesListPath
);
this
.
$router
.
push
({
name
:
'
index
'
}
);
})
.
catch
((
e
)
=>
{
this
.
errorMessage
=
__
(
'
Unable to save cadence. Please try again
'
);
...
...
ee/app/assets/javascripts/iterations/components/iteration_cadences_list.vue
0 → 100644
View file @
6cbbcbe2
<
template
><ul></ul></
template
>
ee/app/assets/javascripts/iterations/index.js
View file @
6cbbcbe2
...
...
@@ -2,10 +2,11 @@ import Vue from 'vue';
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
IterationCadenceForm
from
'
./components/iteration_cadence_form
.vue
'
;
import
App
from
'
./components/app
.vue
'
;
import
IterationForm
from
'
./components/iteration_form.vue
'
;
import
IterationReport
from
'
./components/iteration_report.vue
'
;
import
Iterations
from
'
./components/iterations.vue
'
;
import
createRouter
from
'
./router
'
;
Vue
.
use
(
VueApollo
);
...
...
@@ -91,28 +92,26 @@ export function initIterationReport({ namespaceType, initiallyEditing } = {}) {
});
}
export
function
initCadence
Form
()
{
const
el
=
document
.
querySelector
(
'
.js-iteration-cadence-
form
'
);
export
function
initCadence
App
()
{
const
el
=
document
.
querySelector
(
'
.js-iteration-cadence-
app
'
);
if
(
!
el
)
{
return
null
;
}
const
{
groupFullPath
:
groupPath
,
cadenceId
,
cadencesListPath
}
=
el
.
dataset
;
const
{
groupFullPath
:
groupPath
,
cadencesListPath
}
=
el
.
dataset
;
const
router
=
createRouter
(
cadencesListPath
);
return
new
Vue
({
el
,
router
,
apolloProvider
,
provide
:
{
groupPath
,
cadencesListPath
,
},
render
(
createElement
)
{
return
createElement
(
IterationCadenceForm
,
{
props
:
{
cadenceId
,
cadencesListPath
,
},
});
return
createElement
(
App
);
},
});
}
ee/app/assets/javascripts/iterations/router.js
0 → 100644
View file @
6cbbcbe2
import
Vue
from
'
vue
'
;
import
VueRouter
from
'
vue-router
'
;
import
IterationCadenceForm
from
'
./components/iteration_cadence_form.vue
'
;
import
IterationCadenceList
from
'
./components/iteration_cadences_list.vue
'
;
Vue
.
use
(
VueRouter
);
const
routes
=
[
{
name
:
'
new
'
,
path
:
'
/new
'
,
component
:
IterationCadenceForm
,
},
{
name
:
'
index
'
,
path
:
'
/
'
,
component
:
IterationCadenceList
,
},
];
export
default
function
createRouter
(
base
)
{
const
router
=
new
VueRouter
({
base
,
mode
:
'
history
'
,
routes
,
});
return
router
;
}
ee/app/assets/javascripts/pages/groups/iteration_cadences/index.js
View file @
6cbbcbe2
import
{
initCadence
Form
}
from
'
ee/iterations
'
;
import
{
initCadence
App
}
from
'
ee/iterations
'
;
initCadence
Form
();
initCadence
App
();
ee/app/views/groups/iteration_cadences/edit.html.haml
View file @
6cbbcbe2
...
...
@@ -2,6 +2,6 @@
-
breadcrumb_title
params
[
:id
]
-
page_title
_
(
"Edit iteration cadence"
)
.js-iteration-cadence-
form
{
data:
{
group_full_path:
@group
.
full_path
,
.js-iteration-cadence-
app
{
data:
{
group_full_path:
@group
.
full_path
,
cadence_id:
params
[
:id
],
cadences_list_path:
group_iteration_cadences_path
(
@group
)
}
}
ee/app/views/groups/iteration_cadences/index.html.haml
0 → 100644
View file @
6cbbcbe2
-
page_title
_
(
"Iteration cadences"
)
.js-iteration-cadence-app
{
data:
{
group_full_path:
@group
.
full_path
,
cadences_list_path:
group_iteration_cadences_path
(
@group
)
}
}
ee/app/views/groups/iteration_cadences/new.html.haml
View file @
6cbbcbe2
...
...
@@ -2,4 +2,4 @@
-
breadcrumb_title
_
(
"New"
)
-
page_title
_
(
"New iteration cadence"
)
.js-iteration-cadence-
form
{
data:
{
group_full_path:
@group
.
full_path
,
cadences_list_path:
group_iteration_cadences_path
(
@group
)
}
}
.js-iteration-cadence-
app
{
data:
{
group_full_path:
@group
.
full_path
,
cadences_list_path:
group_iteration_cadences_path
(
@group
)
}
}
ee/spec/frontend/iterations/components/iteration_cadence_form_spec.js
View file @
6cbbcbe2
import
{
GlFormCheckbox
,
GlFormGroup
}
from
'
@gitlab/ui
'
;
import
{
createLocalVue
,
mount
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
IterationCadenceForm
from
'
ee/iterations/components/iteration_cadence_form.vue
'
;
import
createCadence
from
'
ee/iterations/queries/create_cadence.mutation.graphql
'
;
...
...
@@ -7,14 +8,14 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import
{
TEST_HOST
}
from
'
helpers/test_constants
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
jest
.
mock
(
'
~/lib/utils/url_utility
'
);
const
localVue
=
createLocalVue
();
const
push
=
jest
.
fn
();
const
$router
=
{
push
,
};
function
createMockApolloProvider
(
requestHandlers
)
{
local
Vue
.
use
(
VueApollo
);
Vue
.
use
(
VueApollo
);
return
createMockApollo
(
requestHandlers
);
}
...
...
@@ -39,17 +40,18 @@ describe('Iteration cadence form', () => {
iterationCadenceCreate
:
{
iterationCadence
,
errors
:
[
'
alas, your data is unchanged
'
]
},
},
};
const
defaultProps
=
{
cadencesListPath
:
TEST_HOST
};
function
createComponent
({
props
=
defaultProps
,
resolverMock
}
=
{})
{
function
createComponent
({
resolverMock
}
=
{})
{
const
apolloProvider
=
createMockApolloProvider
([[
createCadence
,
resolverMock
]]);
wrapper
=
extendedWrapper
(
mount
(
IterationCadenceForm
,
{
apolloProvider
,
localVue
,
propsData
:
props
,
mocks
:
{
$router
,
},
provide
:
{
groupPath
,
cadencesListPath
:
TEST_HOST
,
},
}),
);
...
...
@@ -86,7 +88,7 @@ describe('Iteration cadence form', () => {
it
(
'
cancel button links to list page
'
,
()
=>
{
clickCancel
();
expect
(
visitUrl
).
toHaveBeenCalledWith
(
TEST_HOST
);
expect
(
push
).
toHaveBeenCalledWith
({
name
:
'
index
'
}
);
});
describe
(
'
save
'
,
()
=>
{
...
...
@@ -131,7 +133,7 @@ describe('Iteration cadence form', () => {
await
waitForPromises
();
expect
(
visitUrl
).
toHaveBeenCalled
(
);
expect
(
push
).
toHaveBeenCalledWith
({
name
:
'
index
'
}
);
});
it
(
'
does not submit if required fields missing
'
,
()
=>
{
...
...
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