Skip to content

Commit ccc5f7d

Browse files
authored
Merge pull request #248 from reasig/resource-visibility-support
Support hiding menu entries
2 parents 68a0875 + a2601f4 commit ccc5f7d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ defmodule MyApp.Kaffy.Config do
167167
resources: [ # this line used to be "schemas" in pre v0.9
168168
post: [schema: MyApp.Blog.Post, admin: MyApp.SomeModule.Anywhere.PostAdmin],
169169
comment: [schema: MyApp.Blog.Comment],
170-
tag: [schema: MyApp.Blog.Tag]
170+
tag: [schema: MyApp.Blog.Tag, in_menu: false]
171171
]
172172
],
173173
inventory: [

lib/kaffy/utils.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,4 +428,8 @@ defmodule Kaffy.Utils do
428428
def get_task_modules() do
429429
env(:scheduled_tasks, [])
430430
end
431+
432+
def visible?(options) do
433+
Keyword.get(options, :in_menu, true)
434+
end
431435
end

lib/kaffy_web/templates/layout/app.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<div class="collapse<%= if @conn.assigns[:context] == to_string(context) do %> show<% end %>" id="<%= context %>-context">
101101
<ul class="nav flex-column sub-menu">
102102
<%= for {resource, options} <- Kaffy.Utils.schemas_for_context(@conn, context) do %>
103-
<%= if Kaffy.ResourceAdmin.authorized?(options, @conn) do %>
103+
<%= if Kaffy.ResourceAdmin.authorized?(options, @conn) && Kaffy.Utils.visible?(options) do %>
104104
<li class="nav-item"><%= link Kaffy.ResourceAdmin.plural_name(options), to: Kaffy.Utils.router().kaffy_resource_path(@conn, :index, context, resource), class: "nav-link" %></li>
105105
<%= for custom_link <- Kaffy.ResourceAdmin.custom_links(options, :sub) do %>
106106
<li class="nav-item"><%= link custom_link.name, to: custom_link.url, class: "nav-link", target: custom_link.target %></li>

0 commit comments

Comments
 (0)