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
26fb57df
Commit
26fb57df
authored
Sep 06, 2021
by
Illya Klymov
Committed by
Jacques Erasmus
Sep 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address reviewer comments
- fix empty spaces - simplify helpers - add more tests
parent
36ed0aa9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
43 deletions
+94
-43
app/assets/javascripts/import_entities/import_groups/components/import_actions_cell.vue
...entities/import_groups/components/import_actions_cell.vue
+10
-11
app/assets/javascripts/import_entities/import_groups/components/import_source_cell.vue
..._entities/import_groups/components/import_source_cell.vue
+0
-1
app/assets/javascripts/import_entities/import_groups/components/import_table.vue
...import_entities/import_groups/components/import_table.vue
+20
-5
app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js
...s/import_entities/import_groups/graphql/client_factory.js
+6
-4
app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js
...s/import_groups/graphql/services/source_groups_manager.js
+1
-4
spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js
...ties/import_groups/components/import_actions_cell_spec.js
+44
-13
spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js
...ort_entities/import_groups/graphql/client_factory_spec.js
+13
-5
No files found.
app/assets/javascripts/import_entities/import_groups/components/import_actions_cell.vue
View file @
26fb57df
...
@@ -27,7 +27,6 @@ export default {
...
@@ -27,7 +27,6 @@ export default {
?
`
${
this
.
group
.
last_import_target
.
target_namespace
}
/
${
this
.
group
.
last_import_target
.
new_name
}
`
?
`
${
this
.
group
.
last_import_target
.
target_namespace
}
/
${
this
.
group
.
last_import_target
.
new_name
}
`
:
null
;
:
null
;
},
},
absoluteLastImportPath
()
{
absoluteLastImportPath
()
{
return
joinPaths
(
gon
.
relative_url_root
||
'
/
'
,
this
.
fullLastImportPath
);
return
joinPaths
(
gon
.
relative_url_root
||
'
/
'
,
this
.
fullLastImportPath
);
},
},
...
@@ -46,16 +45,6 @@ export default {
...
@@ -46,16 +45,6 @@ export default {
<
template
>
<
template
>
<span
class=
"gl-white-space-nowrap gl-inline-flex gl-align-items-center"
>
<span
class=
"gl-white-space-nowrap gl-inline-flex gl-align-items-center"
>
<gl-icon
v-if=
"isFinished"
v-gl-tooltip
:size=
"16"
name=
"information-o"
:title=
"
s__('BulkImports|Re-import creates a new group. It does not sync with the existing group.')
"
class=
"gl-mr-3"
/>
<gl-button
<gl-button
v-if=
"isAvailableForImport"
v-if=
"isAvailableForImport"
:disabled=
"isInvalid"
:disabled=
"isInvalid"
...
@@ -66,5 +55,15 @@ export default {
...
@@ -66,5 +55,15 @@ export default {
>
>
{{
isFinished
?
__
(
'
Re-import
'
)
:
__
(
'
Import
'
)
}}
{{
isFinished
?
__
(
'
Re-import
'
)
:
__
(
'
Import
'
)
}}
</gl-button>
</gl-button>
<gl-icon
v-if=
"isFinished"
v-gl-tooltip
:size=
"16"
name=
"information-o"
:title=
"
s__('BulkImports|Re-import creates a new group. It does not sync with the existing group.')
"
class=
"gl-ml-3"
/>
</span>
</span>
</
template
>
</
template
>
app/assets/javascripts/import_entities/import_groups/components/import_source_cell.vue
View file @
26fb57df
...
@@ -21,7 +21,6 @@ export default {
...
@@ -21,7 +21,6 @@ export default {
?
`
${
this
.
group
.
last_import_target
.
target_namespace
}
/
${
this
.
group
.
last_import_target
.
new_name
}
`
?
`
${
this
.
group
.
last_import_target
.
target_namespace
}
/
${
this
.
group
.
last_import_target
.
new_name
}
`
:
null
;
:
null
;
},
},
absoluteLastImportPath
()
{
absoluteLastImportPath
()
{
return
joinPaths
(
gon
.
relative_url_root
||
'
/
'
,
this
.
fullLastImportPath
);
return
joinPaths
(
gon
.
relative_url_root
||
'
/
'
,
this
.
fullLastImportPath
);
},
},
...
...
app/assets/javascripts/import_entities/import_groups/components/import_table.vue
View file @
26fb57df
...
@@ -189,6 +189,24 @@ export default {
...
@@ -189,6 +189,24 @@ export default {
},
},
methods
:
{
methods
:
{
isUnselectable
(
group
)
{
return
!
this
.
isAvailableForImport
(
group
)
||
this
.
isInvalid
(
group
);
},
rowClasses
(
group
)
{
const
DEFAULT_CLASSES
=
[
'
gl-border-gray-200
'
,
'
gl-border-0
'
,
'
gl-border-b-1
'
,
'
gl-border-solid
'
,
];
const
result
=
[...
DEFAULT_CLASSES
];
if
(
this
.
isUnselectable
(
group
))
{
result
.
push
(
'
gl-cursor-default!
'
);
}
return
result
;
},
qaRowAttributes
(
group
,
type
)
{
qaRowAttributes
(
group
,
type
)
{
if
(
type
===
'
row
'
)
{
if
(
type
===
'
row
'
)
{
return
{
return
{
...
@@ -250,10 +268,7 @@ export default {
...
@@ -250,10 +268,7 @@ export default {
const
table
=
this
.
getTableRef
();
const
table
=
this
.
getTableRef
();
this
.
groups
.
forEach
((
group
,
idx
)
=>
{
this
.
groups
.
forEach
((
group
,
idx
)
=>
{
if
(
if
(
table
.
isRowSelected
(
idx
)
&&
this
.
isUnselectable
(
group
))
{
table
.
isRowSelected
(
idx
)
&&
(
!
this
.
isAvailableForImport
(
group
)
||
this
.
isInvalid
(
group
))
)
{
table
.
unselectRow
(
idx
);
table
.
unselectRow
(
idx
);
}
}
});
});
...
@@ -338,7 +353,7 @@ export default {
...
@@ -338,7 +353,7 @@ export default {
ref=
"table"
ref=
"table"
class=
"gl-w-full"
class=
"gl-w-full"
data-qa-selector=
"import_table"
data-qa-selector=
"import_table"
tbody-tr-class=
"gl-border-gray-200 gl-border-0 gl-border-b-1 gl-border-solid
"
:tbody-tr-class=
"rowClasses
"
:tbody-tr-attr=
"qaRowAttributes"
:tbody-tr-attr=
"qaRowAttributes"
:items=
"groups"
:items=
"groups"
:fields=
"$options.fields"
:fields=
"$options.fields"
...
...
app/assets/javascripts/import_entities/import_groups/graphql/client_factory.js
View file @
26fb57df
...
@@ -239,8 +239,8 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
...
@@ -239,8 +239,8 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
});
});
},
},
async
updateImportStatus
(
_
,
{
id
,
status
},
{
client
,
getCacheKey
})
{
async
updateImportStatus
(
_
,
{
id
,
status
:
newStatus
},
{
client
,
getCacheKey
})
{
groupsManager
.
updateImportProgress
(
id
,
s
tatus
);
groupsManager
.
updateImportProgress
(
id
,
newS
tatus
);
const
progressItem
=
client
.
readFragment
({
const
progressItem
=
client
.
readFragment
({
fragment
:
bulkImportSourceGroupProgressFragment
,
fragment
:
bulkImportSourceGroupProgressFragment
,
...
@@ -251,7 +251,9 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
...
@@ -251,7 +251,9 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
}),
}),
});
});
if
(
status
===
STATUSES
.
FINISHED
&&
progressItem
&&
progressItem
.
status
!==
status
)
{
const
isInProgress
=
Boolean
(
progressItem
);
const
{
status
:
currentStatus
}
=
progressItem
??
{};
if
(
newStatus
===
STATUSES
.
FINISHED
&&
isInProgress
&&
currentStatus
!==
newStatus
)
{
const
groups
=
groupsManager
.
getImportedGroupsByJobId
(
id
);
const
groups
=
groupsManager
.
getImportedGroupsByJobId
(
id
);
groups
.
forEach
(
async
({
id
:
groupId
,
importTarget
})
=>
{
groups
.
forEach
(
async
({
id
:
groupId
,
importTarget
})
=>
{
...
@@ -269,7 +271,7 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
...
@@ -269,7 +271,7 @@ export function createResolvers({ endpoints, sourceUrl, GroupsManager = SourceGr
return
{
return
{
__typename
:
clientTypenames
.
BulkImportProgress
,
__typename
:
clientTypenames
.
BulkImportProgress
,
id
,
id
,
status
,
status
:
newStatus
,
};
};
},
},
...
...
app/assets/javascripts/import_entities/import_groups/graphql/services/source_groups_manager.js
View file @
26fb57df
...
@@ -38,10 +38,7 @@ export class SourceGroupsManager {
...
@@ -38,10 +38,7 @@ export class SourceGroupsManager {
this
.
importStates
[
importId
]
=
{
this
.
importStates
[
importId
]
=
{
status
:
jobConfig
.
status
,
status
:
jobConfig
.
status
,
groups
:
jobConfig
.
groups
.
map
((
g
)
=>
({
groups
:
jobConfig
.
groups
.
map
((
g
)
=>
({
importTarget
:
{
importTarget
:
{
...
g
.
import_target
},
target_namespace
:
g
.
import_target
.
target_namespace
,
new_name
:
g
.
import_target
.
new_name
,
},
id
:
g
.
id
,
id
:
g
.
id
,
})),
})),
};
};
...
...
spec/frontend/import_entities/import_groups/components/import_actions_cell_spec.js
View file @
26fb57df
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
STATUSES
}
from
'
~/import_entities/constants
'
;
import
{
STATUSES
}
from
'
~/import_entities/constants
'
;
import
ImportActionsCell
from
'
~/import_entities/import_groups/components/import_actions_cell.vue
'
;
import
ImportActionsCell
from
'
~/import_entities/import_groups/components/import_actions_cell.vue
'
;
...
@@ -20,23 +20,42 @@ describe('import actions cell', () => {
...
@@ -20,23 +20,42 @@ describe('import actions cell', () => {
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
it
(
'
renders import button when group status is NONE
'
,
()
=>
{
describe
(
'
when import status is NONE
'
,
()
=>
{
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
NONE
});
beforeEach
(()
=>
{
createComponent
({
group
});
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
NONE
});
createComponent
({
group
});
});
const
button
=
wrapper
.
findComponent
(
GlButton
);
it
(
'
renders import button
'
,
()
=>
{
const
button
=
wrapper
.
findComponent
(
GlButton
);
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
button
.
text
()).
toBe
(
'
Import
'
);
});
expect
(
button
.
exists
()).
toBe
(
true
);
it
(
'
does not render icon with a hint
'
,
()
=>
{
expect
(
button
.
text
()).
toBe
(
'
Import
'
);
expect
(
wrapper
.
findComponent
(
GlIcon
).
exists
()).
toBe
(
false
);
});
});
});
it
(
'
renders re-import button when group status is FINISHED
'
,
()
=>
{
describe
(
'
when import status is FINISHED
'
,
()
=>
{
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
FINISHED
});
beforeEach
(()
=>
{
createComponent
({
group
});
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
FINISHED
});
createComponent
({
group
});
});
const
button
=
wrapper
.
findComponent
(
GlButton
);
it
(
'
renders re-import button
'
,
()
=>
{
expect
(
button
.
exists
()).
toBe
(
true
);
const
button
=
wrapper
.
findComponent
(
GlButton
);
expect
(
button
.
text
()).
toBe
(
'
Re-import
'
);
expect
(
button
.
exists
()).
toBe
(
true
);
expect
(
button
.
text
()).
toBe
(
'
Re-import
'
);
});
it
(
'
renders icon with a hint
'
,
()
=>
{
const
icon
=
wrapper
.
findComponent
(
GlIcon
);
expect
(
icon
.
exists
()).
toBe
(
true
);
expect
(
icon
.
attributes
().
title
).
toBe
(
'
Re-import creates a new group. It does not sync with the existing group.
'
,
);
});
});
});
it
(
'
does not render import button when group import is in progress
'
,
()
=>
{
it
(
'
does not render import button when group import is in progress
'
,
()
=>
{
...
@@ -47,6 +66,18 @@ describe('import actions cell', () => {
...
@@ -47,6 +66,18 @@ describe('import actions cell', () => {
expect
(
button
.
exists
()).
toBe
(
false
);
expect
(
button
.
exists
()).
toBe
(
false
);
});
});
it
(
'
renders import button as disabled when there are validation errors
'
,
()
=>
{
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
NONE
,
validation_errors
:
[{
field
:
'
new_name
'
,
message
:
'
something
'
}],
});
createComponent
({
group
});
const
button
=
wrapper
.
findComponent
(
GlButton
);
expect
(
button
.
props
().
disabled
).
toBe
(
true
);
});
it
(
'
emits import-group event when import button is clicked
'
,
()
=>
{
it
(
'
emits import-group event when import button is clicked
'
,
()
=>
{
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
NONE
});
const
group
=
generateFakeEntry
({
id
:
1
,
status
:
STATUSES
.
NONE
});
createComponent
({
group
});
createComponent
({
group
});
...
...
spec/frontend/import_entities/import_groups/graphql/client_factory_spec.js
View file @
26fb57df
...
@@ -440,9 +440,10 @@ describe('Bulk import resolvers', () => {
...
@@ -440,9 +440,10 @@ describe('Bulk import resolvers', () => {
},
},
});
});
expect
(
lastImportTarget
).
to
MatchObject
(
IMPORT_TARGET
);
expect
(
lastImportTarget
).
to
StrictEqual
(
IMPORT_TARGET
);
expect
(
progress
).
toMatchObject
({
expect
(
progress
).
toStrictEqual
({
__typename
:
clientTypenames
.
BulkImportProgress
,
id
:
FAKE_JOB_ID
,
id
:
FAKE_JOB_ID
,
status
:
NEW_STATUS
,
status
:
NEW_STATUS
,
});
});
...
@@ -458,7 +459,8 @@ describe('Bulk import resolvers', () => {
...
@@ -458,7 +459,8 @@ describe('Bulk import resolvers', () => {
variables
:
{
id
:
FAKE_JOB_ID
,
status
:
NEW_STATUS
},
variables
:
{
id
:
FAKE_JOB_ID
,
status
:
NEW_STATUS
},
});
});
expect
(
statusInResponse
).
toMatchObject
({
expect
(
statusInResponse
).
toStrictEqual
({
__typename
:
clientTypenames
.
BulkImportProgress
,
id
:
FAKE_JOB_ID
,
id
:
FAKE_JOB_ID
,
status
:
NEW_STATUS
,
status
:
NEW_STATUS
,
});
});
...
@@ -476,7 +478,13 @@ describe('Bulk import resolvers', () => {
...
@@ -476,7 +478,13 @@ describe('Bulk import resolvers', () => {
variables
:
{
sourceGroupId
:
GROUP_ID
,
field
:
FAKE_FIELD
,
message
:
FAKE_MESSAGE
},
variables
:
{
sourceGroupId
:
GROUP_ID
,
field
:
FAKE_FIELD
,
message
:
FAKE_MESSAGE
},
});
});
expect
(
validationErrors
).
toMatchObject
([{
field
:
FAKE_FIELD
,
message
:
FAKE_MESSAGE
}]);
expect
(
validationErrors
).
toStrictEqual
([
{
__typename
:
clientTypenames
.
BulkImportValidationError
,
field
:
FAKE_FIELD
,
message
:
FAKE_MESSAGE
,
},
]);
});
});
it
(
'
removeValidationError removes error from group
'
,
async
()
=>
{
it
(
'
removeValidationError removes error from group
'
,
async
()
=>
{
...
@@ -497,7 +505,7 @@ describe('Bulk import resolvers', () => {
...
@@ -497,7 +505,7 @@ describe('Bulk import resolvers', () => {
variables
:
{
sourceGroupId
:
GROUP_ID
,
field
:
FAKE_FIELD
},
variables
:
{
sourceGroupId
:
GROUP_ID
,
field
:
FAKE_FIELD
},
});
});
expect
(
validationErrors
).
to
MatchObject
([]);
expect
(
validationErrors
).
to
StrictEqual
([]);
});
});
});
});
});
});
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