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
f8f0676a
Commit
f8f0676a
authored
Sep 27, 2021
by
Jacques
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fork suggestion component
Added a fork suggestion component
parent
6b755868
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
0 deletions
+98
-0
app/assets/javascripts/repository/components/fork_suggestion.vue
...ets/javascripts/repository/components/fork_suggestion.vue
+43
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/repository/components/fork_suggestion_spec.js
spec/frontend/repository/components/fork_suggestion_spec.js
+52
-0
No files found.
app/assets/javascripts/repository/components/fork_suggestion.vue
0 → 100644
View file @
f8f0676a
<
script
>
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
{
i18n
:
{
message
:
__
(
'
You can’t edit files directly in this project. Fork this project and submit a merge request with your changes.
'
,
),
fork
:
__
(
'
Fork
'
),
cancel
:
__
(
'
Cancel
'
),
},
components
:
{
GlButton
,
},
props
:
{
forkPath
:
{
type
:
String
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<div
class=
"file-fork-suggestion"
>
<span
class=
"file-fork-suggestion-note"
data-testid=
"message"
>
{{
$options
.
i18n
.
message
}}
</span>
<gl-button
class=
"gl-mr-3"
category=
"secondary"
variant=
"confirm"
:href=
"forkPath"
data-testid=
"fork"
>
{{
$options
.
i18n
.
fork
}}
</gl-button>
<gl-button
class=
"gl-mr-3"
data-testid=
"cancel"
@
click=
"$emit('cancel')"
>
{{
$options
.
i18n
.
cancel
}}
</gl-button>
</div>
</
template
>
locale/gitlab.pot
View file @
f8f0676a
...
...
@@ -38773,6 +38773,9 @@ msgstr ""
msgid "You can’t %{tag_start}edit%{tag_end} files directly in this project. Fork this project and submit a merge request with your changes."
msgstr ""
msgid "You can’t edit files directly in this project. Fork this project and submit a merge request with your changes."
msgstr ""
msgid "You could not create a new trigger."
msgstr ""
...
...
spec/frontend/repository/components/fork_suggestion_spec.js
0 → 100644
View file @
f8f0676a
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ForkSuggestion
from
'
~/repository/components/fork_suggestion.vue
'
;
const
DEFAULT_PROPS
=
{
forkPath
:
'
some_file.js/fork
'
};
describe
(
'
ForkSuggestion component
'
,
()
=>
{
let
wrapper
;
const
createComponent
=
()
=>
{
wrapper
=
shallowMount
(
ForkSuggestion
,
{
propsData
:
{
...
DEFAULT_PROPS
},
});
};
beforeEach
(()
=>
createComponent
());
afterEach
(()
=>
wrapper
.
destroy
());
const
findMessage
=
()
=>
wrapper
.
find
(
'
[data-testid="message"]
'
);
const
findForkButton
=
()
=>
wrapper
.
find
(
'
[data-testid="fork"]
'
);
const
findCancelButton
=
()
=>
wrapper
.
find
(
'
[data-testid="cancel"]
'
);
it
(
'
renders a message
'
,
()
=>
{
expect
(
findMessage
().
exists
()).
toBe
(
true
);
expect
(
findMessage
().
text
()).
toBe
(
'
You can’t edit files directly in this project. Fork this project and submit a merge request with your changes.
'
,
);
});
it
(
'
renders component
'
,
()
=>
{
const
{
forkPath
}
=
DEFAULT_PROPS
;
expect
(
wrapper
.
props
()).
toMatchObject
({
forkPath
});
});
it
(
'
renders a Fork button
'
,
()
=>
{
expect
(
findForkButton
().
exists
()).
toBe
(
true
);
expect
(
findForkButton
().
text
()).
toBe
(
'
Fork
'
);
expect
(
findForkButton
().
attributes
(
'
href
'
)).
toBe
(
DEFAULT_PROPS
.
forkPath
);
});
it
(
'
renders a Cancel button
'
,
()
=>
{
expect
(
findCancelButton
().
exists
()).
toBe
(
true
);
expect
(
findCancelButton
().
text
()).
toBe
(
'
Cancel
'
);
});
it
(
'
emits a cancel event when Cancel button is clicked
'
,
()
=>
{
findCancelButton
().
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
cancel
'
)).
toEqual
([[]]);
});
});
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