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
ecef867f
Commit
ecef867f
authored
Feb 22, 2022
by
Jacques
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace form form props with provide/inject
Replaced the fork form paths with provide/inject
parent
61c0cd31
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
95 deletions
+32
-95
app/assets/javascripts/pages/projects/forks/new/components/app.vue
...s/javascripts/pages/projects/forks/new/components/app.vue
+1
-42
app/assets/javascripts/pages/projects/forks/new/components/fork_form.vue
...scripts/pages/projects/forks/new/components/fork_form.vue
+7
-18
app/assets/javascripts/pages/projects/forks/new/index.js
app/assets/javascripts/pages/projects/forks/new/index.js
+8
-10
spec/frontend/pages/projects/forks/new/components/app_spec.js
.../frontend/pages/projects/forks/new/components/app_spec.js
+3
-10
spec/frontend/pages/projects/forks/new/components/fork_form_spec.js
...end/pages/projects/forks/new/components/fork_form_spec.js
+13
-15
No files found.
app/assets/javascripts/pages/projects/forks/new/components/app.vue
View file @
ecef867f
...
...
@@ -10,38 +10,6 @@ export default {
type
:
String
,
required
:
true
,
},
endpoint
:
{
type
:
String
,
required
:
true
,
},
projectFullPath
:
{
type
:
String
,
required
:
true
,
},
projectId
:
{
type
:
String
,
required
:
true
,
},
projectName
:
{
type
:
String
,
required
:
true
,
},
projectPath
:
{
type
:
String
,
required
:
true
,
},
projectDescription
:
{
type
:
String
,
required
:
true
,
},
projectVisibility
:
{
type
:
String
,
required
:
true
,
},
restrictedVisibilityLevels
:
{
type
:
Array
,
required
:
true
,
},
},
};
</
script
>
...
...
@@ -62,16 +30,7 @@ export default {
</p>
</div>
<div
class=
"col-lg-9"
>
<fork-form
:endpoint=
"endpoint"
:project-full-path=
"projectFullPath"
:project-id=
"projectId"
:project-name=
"projectName"
:project-path=
"projectPath"
:project-description=
"projectDescription"
:project-visibility=
"projectVisibility"
:restricted-visibility-levels=
"restrictedVisibilityLevels"
/>
<fork-form
/>
</div>
</div>
</
template
>
app/assets/javascripts/pages/projects/forks/new/components/fork_form.vue
View file @
ecef867f
...
...
@@ -72,40 +72,29 @@ export default {
visibilityHelpPath
:
{
default
:
''
,
},
},
props
:
{
endpoint
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
projectFullPath
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
projectId
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
projectName
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
projectPath
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
projectDescription
:
{
type
:
String
,
required
:
false
,
default
:
''
,
},
projectVisibility
:
{
type
:
String
,
required
:
true
,
default
:
''
,
},
restrictedVisibilityLevels
:
{
type
:
Array
,
required
:
true
,
default
:
[],
},
},
data
()
{
...
...
app/assets/javascripts/pages/projects/forks/new/index.js
View file @
ecef867f
...
...
@@ -23,15 +23,8 @@ new Vue({
provide
:
{
newGroupPath
,
visibilityHelpPath
,
},
render
(
h
)
{
return
h
(
App
,
{
props
:
{
forkIllustration
,
endpoint
,
newGroupPath
,
projectFullPath
,
visibilityHelpPath
,
projectId
,
projectName
,
projectPath
,
...
...
@@ -39,6 +32,11 @@ new Vue({
projectVisibility
,
restrictedVisibilityLevels
:
JSON
.
parse
(
restrictedVisibilityLevels
),
},
render
(
h
)
{
return
h
(
App
,
{
props
:
{
forkIllustration
,
},
});
},
});
spec/frontend/pages/projects/forks/new/components/app_spec.js
View file @
ecef867f
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
App
from
'
~/pages/projects/forks/new/components/app.vue
'
;
import
ForkForm
from
'
~/pages/projects/forks/new/components/fork_form.vue
'
;
describe
(
'
App component
'
,
()
=>
{
let
wrapper
;
const
DEFAULT_PROPS
=
{
forkIllustration
:
'
illustrations/project-create-new-sm.svg
'
,
endpoint
:
'
/some/project-full-path/-/forks/new.json
'
,
projectFullPath
:
'
/some/project-full-path
'
,
projectId
:
'
10
'
,
projectName
:
'
Project Name
'
,
projectPath
:
'
project-name
'
,
projectDescription
:
'
some project description
'
,
projectVisibility
:
'
private
'
,
restrictedVisibilityLevels
:
[],
};
const
createComponent
=
(
props
=
{})
=>
{
...
...
@@ -37,7 +30,7 @@ describe('App component', () => {
expect
(
wrapper
.
find
(
'
img
'
).
attributes
(
'
src
'
)).
toBe
(
'
illustrations/project-create-new-sm.svg
'
);
});
it
(
'
renders ForkForm component
with prop
'
,
()
=>
{
expect
(
wrapper
.
props
()).
toEqual
(
expect
.
objectContaining
(
DEFAULT_PROPS
)
);
it
(
'
renders ForkForm component
'
,
()
=>
{
expect
(
wrapper
.
findComponent
(
ForkForm
).
exists
()).
toBe
(
true
);
});
});
spec/frontend/pages/projects/forks/new/components/fork_form_spec.js
View file @
ecef867f
...
...
@@ -40,7 +40,9 @@ describe('ForkForm component', () => {
},
];
const
DEFAULT_PROPS
=
{
const
DEFAULT_PROVIDE
=
{
newGroupPath
:
'
some/groups/path
'
,
visibilityHelpPath
:
'
some/visibility/help/path
'
,
endpoint
:
'
/some/project-full-path/-/forks/new.json
'
,
projectFullPath
:
'
/some/project-full-path
'
,
projectId
:
'
10
'
,
...
...
@@ -52,18 +54,14 @@ describe('ForkForm component', () => {
};
const
mockGetRequest
=
(
data
=
{},
statusCode
=
httpStatus
.
OK
)
=>
{
axiosMock
.
onGet
(
DEFAULT_PRO
PS
.
endpoint
).
replyOnce
(
statusCode
,
data
);
axiosMock
.
onGet
(
DEFAULT_PRO
VIDE
.
endpoint
).
replyOnce
(
statusCode
,
data
);
};
const
createComponentFactory
=
(
mountFn
)
=>
(
pro
ps
=
{},
data
=
{})
=>
{
const
createComponentFactory
=
(
mountFn
)
=>
(
pro
vide
=
{},
data
=
{})
=>
{
wrapper
=
mountFn
(
ForkForm
,
{
provide
:
{
newGroupPath
:
'
some/groups/path
'
,
visibilityHelpPath
:
'
some/visibility/help/path
'
,
},
propsData
:
{
...
DEFAULT_PROPS
,
...
props
,
...
DEFAULT_PROVIDE
,
...
provide
,
},
data
()
{
return
{
...
...
@@ -111,7 +109,7 @@ describe('ForkForm component', () => {
mockGetRequest
();
createComponent
();
const
{
projectFullPath
}
=
DEFAULT_PRO
PS
;
const
{
projectFullPath
}
=
DEFAULT_PRO
VIDE
;
const
cancelButton
=
wrapper
.
find
(
'
[data-testid="cancel-button"]
'
);
expect
(
cancelButton
.
attributes
(
'
href
'
)).
toBe
(
projectFullPath
);
...
...
@@ -130,10 +128,10 @@ describe('ForkForm component', () => {
mockGetRequest
();
createComponent
();
expect
(
findForkNameInput
().
attributes
(
'
value
'
)).
toBe
(
DEFAULT_PRO
PS
.
projectName
);
expect
(
findForkSlugInput
().
attributes
(
'
value
'
)).
toBe
(
DEFAULT_PRO
PS
.
projectPath
);
expect
(
findForkNameInput
().
attributes
(
'
value
'
)).
toBe
(
DEFAULT_PRO
VIDE
.
projectName
);
expect
(
findForkSlugInput
().
attributes
(
'
value
'
)).
toBe
(
DEFAULT_PRO
VIDE
.
projectPath
);
expect
(
findForkDescriptionTextarea
().
attributes
(
'
value
'
)).
toBe
(
DEFAULT_PRO
PS
.
projectDescription
,
DEFAULT_PRO
VIDE
.
projectDescription
,
);
});
...
...
@@ -164,7 +162,7 @@ describe('ForkForm component', () => {
it
(
'
make GET request from endpoint
'
,
async
()
=>
{
await
axios
.
waitForAll
();
expect
(
axiosMock
.
history
.
get
[
0
].
url
).
toBe
(
DEFAULT_PRO
PS
.
endpoint
);
expect
(
axiosMock
.
history
.
get
[
0
].
url
).
toBe
(
DEFAULT_PRO
VIDE
.
endpoint
);
});
it
(
'
generate default option
'
,
async
()
=>
{
...
...
@@ -469,7 +467,7 @@ describe('ForkForm component', () => {
projectName
,
projectPath
,
projectVisibility
,
}
=
DEFAULT_PRO
PS
;
}
=
DEFAULT_PRO
VIDE
;
const
url
=
`/api/
${
GON_API_VERSION
}
/projects/
${
projectId
}
/fork`
;
const
project
=
{
...
...
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