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
a79f88fe
Unverified
Commit
a79f88fe
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Return can_write with Root Collection
parent
aec5ae51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/collection.clj
+5
-5
5 additions, 5 deletions
src/metabase/api/collection.clj
test/metabase/api/collection_test.clj
+13
-8
13 additions, 8 deletions
test/metabase/api/collection_test.clj
with
18 additions
and
13 deletions
src/metabase/api/collection.clj
+
5
−
5
View file @
a79f88fe
...
...
@@ -83,11 +83,10 @@
unspecified, it will return objects of all types."
[
id
model
]
{
model
(
s/maybe
(
s/enum
"cards"
"dashboards"
"pulses"
))}
(
merge
(
as->
(
api/read-check
Collection
id,
:archived
false
)
<>
(
hydrate
<>
:effective_location
:effective_children
:effective_ancestors
)
(
assoc
<>
:can_write
(
mi/can-write?
<>
)))
(
collection-children
model
model->collection-children-fn
id
)))
(
->
(
api/read-check
Collection
id,
:archived
false
)
(
hydrate
:effective_location
:effective_children
:effective_ancestors
:can_write
)
(
merge
(
collection-children
model
model->collection-children-fn
id
))))
(
api/defendpoint
GET
"/root"
"Fetch objects in the 'root' Collection. (The 'root' Collection doesn't actually exist at this point, so this just
...
...
@@ -97,6 +96,7 @@
(
merge
{
:name
(
tru
"Root Collection"
)
:id
"root"
:can_write
api/*is-superuser?*
; temporary until Root Collection perms are merged !
:effective_location
"/"
:effective_children
(
collection/effective-children
collection/root-collection
)
:effective_ancestors
[]}
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/collection_test.clj
+
13
−
8
View file @
a79f88fe
...
...
@@ -102,7 +102,7 @@
(
defn-
remove-ids-from-collection-detail
[
results
&
{
:keys
[
keep-collection-id?
]
:or
{
keep-collection-id?
false
}}]
(
into
{}
(
for
[[
k
items
]
(
select-keys
results
(
cond->>
[
:name
:cards
:dashboards
:pulses
]
(
into
{}
(
for
[[
k
items
]
(
select-keys
results
(
cond->>
[
:name
:cards
:dashboards
:pulses
:can_write
]
keep-collection-id?
(
cons
:id
)))]
[
k
(
if-not
(
sequential?
items
)
items
...
...
@@ -125,7 +125,8 @@
{
:name
"Debt Collection"
:cards
[{
:name
"Birthday Card"
,
:collection_position
nil
}]
:dashboards
[{
:name
"Dine & Dashboard"
,
:collection_position
nil
}]
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]}
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]
:can_write
false
}
(
tt/with-temp
Collection
[
collection
{
:name
"Debt Collection"
}]
(
perms/grant-collection-read-permissions!
(
group/all-users
)
collection
)
(
with-some-children-of-collection
collection
...
...
@@ -135,7 +136,8 @@
;; ...and that you can also filter so that you only see the children you want to see
(
expect
{
:name
"Art Collection"
:dashboards
[{
:name
"Dine & Dashboard"
,
:collection_position
nil
}]}
:dashboards
[{
:name
"Dine & Dashboard"
,
:collection_position
nil
}]
:can_write
false
}
(
tt/with-temp
Collection
[
collection
{
:name
"Art Collection"
}]
(
perms/grant-collection-read-permissions!
(
group/all-users
)
collection
)
(
with-some-children-of-collection
collection
...
...
@@ -245,7 +247,8 @@
:id
"root"
:cards
[{
:name
"Birthday Card"
,
:collection_position
nil
}]
:dashboards
[{
:name
"Dine & Dashboard"
,
:collection_position
nil
}]
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]}
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]
:can_write
true
}
(
with-some-children-of-collection
nil
(
->
((
user->client
:crowberto
)
:get
200
"collection/root"
)
(
remove-ids-from-collection-detail
:keep-collection-id?
true
))))
...
...
@@ -256,7 +259,8 @@
:id
"root"
:cards
[]
:dashboards
[{
:name
"Dine & Dashboard"
,
:collection_position
nil
}]
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]}
:pulses
[{
:name
"Electro-Magnetic Pulse"
,
:collection_position
nil
}]
:can_write
false
}
;; create a fake DB and don't give all users perms to it
(
tt/with-temp*
[
Database
[
db
]
Table
[
table
{
:db_id
(
u/get-id
db
)}]]
...
...
@@ -272,9 +276,10 @@
;; Make sure this endpoint can also filter things
(
expect
{
:name
"Root Collection"
:id
"root"
:cards
[{
:name
"Birthday Card"
,
:collection_position
nil
}]}
{
:name
"Root Collection"
:id
"root"
:cards
[{
:name
"Birthday Card"
,
:collection_position
nil
}]
:can_write
true
}
(
with-some-children-of-collection
nil
(
->
((
user->client
:crowberto
)
:get
200
"collection/root?model=cards"
)
(
remove-ids-from-collection-detail
:keep-collection-id?
true
))))
...
...
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