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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
5eb885e5
Commit
5eb885e5
authored
May 23, 2017
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build tree from server response
[ci skip]
parent
04917d05
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
13 deletions
+78
-13
app/assets/javascripts/groups/components/group_folder.vue
app/assets/javascripts/groups/components/group_folder.vue
+2
-2
app/assets/javascripts/groups/components/group_item.vue
app/assets/javascripts/groups/components/group_item.vue
+2
-2
app/assets/javascripts/groups/components/groups.vue
app/assets/javascripts/groups/components/groups.vue
+1
-1
app/assets/javascripts/groups/services/groups_service.js
app/assets/javascripts/groups/services/groups_service.js
+2
-4
app/assets/javascripts/groups/stores/groups_store.js
app/assets/javascripts/groups/stores/groups_store.js
+71
-4
No files found.
app/assets/javascripts/groups/components/group_folder.vue
View file @
5eb885e5
...
@@ -2,13 +2,13 @@
...
@@ -2,13 +2,13 @@
export
default
{
export
default
{
props
:
{
props
:
{
groups
:
{
groups
:
{
type
:
Array
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
},
},
computed
:
{
computed
:
{
hasGroups
()
{
hasGroups
()
{
return
this
.
groups
.
length
>
0
;
return
Object
.
keys
(
this
.
groups
)
.
length
>
0
;
},
},
},
},
};
};
...
...
app/assets/javascripts/groups/components/group_item.vue
View file @
5eb885e5
...
@@ -29,7 +29,7 @@ export default {
...
@@ -29,7 +29,7 @@ export default {
};
};
},
},
isExpandable
()
{
isExpandable
()
{
return
this
.
group
.
subGroups
.
length
>
0
;
return
Object
.
keys
(
this
.
group
.
subGroups
)
.
length
>
0
;
},
},
},
},
};
};
...
@@ -92,7 +92,7 @@ export default {
...
@@ -92,7 +92,7 @@ export default {
</div>
</div>
<div
class=
"title"
>
<div
class=
"title"
>
<a
:href=
"group.webUrl"
>
{{
group
.
fullN
ame
}}
</a>
<a
:href=
"group.webUrl"
>
{{
group
.
isOrphan
?
group
.
fullName
:
group
.
n
ame
}}
</a>
</div>
</div>
<div
class=
"description"
>
<div
class=
"description"
>
...
...
app/assets/javascripts/groups/components/groups.vue
View file @
5eb885e5
...
@@ -7,7 +7,7 @@ export default {
...
@@ -7,7 +7,7 @@ export default {
},
},
props
:
{
props
:
{
groups
:
{
groups
:
{
type
:
Array
,
type
:
Object
,
required
:
true
,
required
:
true
,
},
},
pageInfo
:
{
pageInfo
:
{
...
...
app/assets/javascripts/groups/services/groups_service.js
View file @
5eb885e5
...
@@ -13,11 +13,9 @@ export default class GroupsService {
...
@@ -13,11 +13,9 @@ export default class GroupsService {
if
(
parentId
)
{
if
(
parentId
)
{
data
.
parent_id
=
parentId
;
data
.
parent_id
=
parentId
;
}
else
{
// Do not send this param for sub groups
// Do not send this param for sub groups
if
(
page
)
{
}
else
if
(
page
)
{
data
.
page
=
page
;
data
.
page
=
page
;
}
}
}
return
this
.
groups
.
get
(
data
);
return
this
.
groups
.
get
(
data
);
...
...
app/assets/javascripts/groups/stores/groups_store.js
View file @
5eb885e5
export
default
class
GroupsStore
{
export
default
class
GroupsStore
{
constructor
()
{
constructor
()
{
this
.
state
=
{};
this
.
state
=
{};
this
.
state
.
groups
=
[]
;
this
.
state
.
groups
=
{}
;
this
.
state
.
pageInfo
=
{};
this
.
state
.
pageInfo
=
{};
return
this
;
return
this
;
...
@@ -11,9 +11,9 @@ export default class GroupsStore {
...
@@ -11,9 +11,9 @@ export default class GroupsStore {
const
parentGroup
=
parent
;
const
parentGroup
=
parent
;
if
(
parentGroup
)
{
if
(
parentGroup
)
{
parentGroup
.
subGroups
=
this
.
decorateGroups
(
rawGroups
);
parentGroup
.
subGroups
=
this
.
buildTree
(
rawGroups
);
}
else
{
}
else
{
this
.
state
.
groups
=
this
.
decorateGroups
(
rawGroups
);
this
.
state
.
groups
=
this
.
buildTree
(
rawGroups
);
}
}
return
rawGroups
;
return
rawGroups
;
...
@@ -32,6 +32,70 @@ export default class GroupsStore {
...
@@ -32,6 +32,70 @@ export default class GroupsStore {
this
.
state
.
pageInfo
=
paginationInfo
;
this
.
state
.
pageInfo
=
paginationInfo
;
}
}
buildTree
(
rawGroups
)
{
const
groups
=
this
.
decorateGroups
(
rawGroups
);
const
tree
=
{};
const
mappedGroups
=
{};
const
orphans
=
[];
// Map groups to an object
for
(
let
i
=
0
,
len
=
groups
.
length
;
i
<
len
;
i
+=
1
)
{
const
group
=
groups
[
i
];
mappedGroups
[
group
.
id
]
=
group
;
mappedGroups
[
group
.
id
].
subGroups
=
{};
}
Object
.
keys
(
mappedGroups
).
map
((
key
)
=>
{
const
currentGroup
=
mappedGroups
[
key
];
// If the group is not at the root level, add it to its parent array of subGroups.
const
parentGroup
=
mappedGroups
[
currentGroup
.
parentId
];
if
(
currentGroup
.
parentId
)
{
if
(
parentGroup
)
{
mappedGroups
[
currentGroup
.
parentId
].
subGroups
[
currentGroup
.
id
]
=
currentGroup
;
mappedGroups
[
currentGroup
.
parentId
].
isOpen
=
true
;
// Expand group if it has subgroups
}
else
{
// Means the groups hast no direct parent.
// Save for later processing, we will add them to its corresponding base group
orphans
.
push
(
currentGroup
);
}
}
else
{
// If the group is at the root level, add it to first level elements array.
tree
[
currentGroup
.
id
]
=
currentGroup
;
}
return
key
;
});
// Hopefully this array will be empty for most cases
if
(
orphans
.
length
)
{
orphans
.
map
((
orphan
)
=>
{
let
found
=
false
;
const
currentOrphan
=
orphan
;
Object
.
keys
(
tree
).
map
((
key
)
=>
{
const
group
=
tree
[
key
];
if
(
currentOrphan
.
fullPath
.
lastIndexOf
(
group
.
fullPath
)
===
0
)
{
group
.
subGroups
[
currentOrphan
.
id
]
=
currentOrphan
;
group
.
isOpen
=
true
;
currentOrphan
.
isOrphan
=
true
;
found
=
true
;
}
return
key
;
});
if
(
!
found
)
{
currentOrphan
.
isOrphan
=
true
;
tree
[
currentOrphan
.
id
]
=
currentOrphan
;
}
return
orphan
;
});
}
return
tree
;
}
decorateGroups
(
rawGroups
)
{
decorateGroups
(
rawGroups
)
{
this
.
groups
=
rawGroups
.
map
(
GroupsStore
.
decorateGroup
);
this
.
groups
=
rawGroups
.
map
(
GroupsStore
.
decorateGroup
);
return
this
.
groups
;
return
this
.
groups
;
...
@@ -41,14 +105,17 @@ export default class GroupsStore {
...
@@ -41,14 +105,17 @@ export default class GroupsStore {
return
{
return
{
id
:
rawGroup
.
id
,
id
:
rawGroup
.
id
,
fullName
:
rawGroup
.
full_name
,
fullName
:
rawGroup
.
full_name
,
fullPath
:
rawGroup
.
full_path
,
name
:
rawGroup
.
name
,
description
:
rawGroup
.
description
,
description
:
rawGroup
.
description
,
webUrl
:
rawGroup
.
web_url
,
webUrl
:
rawGroup
.
web_url
,
parentId
:
rawGroup
.
parent_id
,
parentId
:
rawGroup
.
parent_id
,
visibility
:
rawGroup
.
visibility
,
visibility
:
rawGroup
.
visibility
,
isOpen
:
false
,
isOpen
:
false
,
isOrphan
:
false
,
numberProjects
:
10
,
numberProjects
:
10
,
numberMembers
:
10
,
numberMembers
:
10
,
subGroups
:
[]
,
subGroups
:
{}
,
};
};
}
}
...
...
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