Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
eadff81f
Unverified
Commit
eadff81f
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Add root collection to effective_ancestors
parent
ecf627cd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/api/collection.clj
+1
-5
1 addition, 5 deletions
src/metabase/api/collection.clj
src/metabase/models/collection.clj
+10
-4
10 additions, 4 deletions
src/metabase/models/collection.clj
test/metabase/api/collection_test.clj
+1
-1
1 addition, 1 deletion
test/metabase/api/collection_test.clj
with
12 additions
and
10 deletions
src/metabase/api/collection.clj
+
1
−
5
View file @
eadff81f
...
...
@@ -135,11 +135,7 @@
;;; -------------------------------------------- GET /api/collection/root --------------------------------------------
(
defn-
root-collection
[]
;; add in some things for the FE to display since the 'Root' Collection isn't real and wouldn't normally have
;; these things
(
assoc
(
collection-detail
collection/root-collection
)
:name
(
tru
"Our analytics"
)
:id
"root"
))
(
collection-detail
collection/root-collection-with-ui-details
))
(
api/defendpoint
GET
"/root"
"Return the 'Root' Collection object with standard details added"
...
...
This diff is collapsed.
Click to expand it.
src/metabase/models/collection.clj
+
10
−
4
View file @
eadff81f
...
...
@@ -184,6 +184,12 @@
"Special placeholder object representing the Root Collection, which isn't really a real Collection."
(
map->RootCollection
{
::is-root?
true
}))
(
def
^
RootCollection
root-collection-with-ui-details
"The special Root Collection placeholder object with some extra details to facilitate displaying it on the FE."
(
assoc
root-collection
:name
(
tru
"Our analytics"
)
:id
"root"
))
(
defn-
is-root-collection?
[
x
]
(
instance?
RootCollection
x
))
...
...
@@ -273,7 +279,7 @@
(
when-let
[
ancestor-ids
(
seq
(
location-path->ids
location
))]
(
db/select
[
Collection
:name
:id
]
:id
[
:in
ancestor-ids
]
{
:order-by
[
:%lower.name
]})))
(
s/defn
effective-ancestors
:-
[
CollectionInstance
]
(
s/defn
effective-ancestors
:-
[
(
s/cond-pre
RootCollection
CollectionInstance
)
]
"Fetch the ancestors of a `collection`, filtering out any ones the current User isn't allowed to see. This is used
in the UI to power the 'breadcrumb' path to the location of a given Collection. For example, suppose we have four
Collections, nested like:
...
...
@@ -282,11 +288,11 @@
The ancestors of D are:
A > B > C
[Root] >
A > B > C
If the current User is allowed to see A and C, but not B, `effective-ancestors` of D will be:
A > C
[Root] >
A > C
Thus the existence of C will be kept hidden from the current User, and for all intents and purposes the current User
can effectively treat A as the parent of C."
...
...
@@ -294,7 +300,7 @@
[
collection
:-
CollectionWithLocationAndIDOrRoot
]
(
if
(
is-root-collection?
collection
)
[]
(
filter
i/can-read?
(
ancestors
collection
))))
(
filter
i/can-read?
(
cons
root-collection-with-ui-details
(
ancestors
collection
))))
)
(
s/defn
parent-id
:-
(
s/maybe
su/IntGreaterThanZero
)
"Get the immediate parent `collection` id, if set."
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/collection_test.clj
+
1
−
1
View file @
eadff81f
...
...
@@ -190,7 +190,7 @@
:can_write
true
:name
"Lucky Pigeon's Personal Collection"
:personal_owner_id
(
user->id
:lucky
)
:effective_ancestors
()
:effective_ancestors
[{
:metabase.models.collection/is-root?
true,
:name
"Our analytics"
,
:id
"root"
,
:can_write
true
}]
:effective_location
"/"
:parent_id
nil
:id
(
u/get-id
(
collection/user->personal-collection
(
user->id
:lucky
)))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment