Skip to content

Commit

Permalink
Merge pull request #342 from pratikb64/app-switcher
Browse files Browse the repository at this point in the history
feat: add app switcher logo & name field
  • Loading branch information
pratikb64 authored Feb 18, 2025
2 parents a4e3080 + 3b1ae53 commit d08e4e8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 11 deletions.
3 changes: 2 additions & 1 deletion wiki/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ wiki.wiki.doctype.wiki_space.patches.wiki_sidebar_migration
wiki.wiki.doctype.wiki_settings.patches.wiki_navbar_item_migration
wiki.wiki.doctype.wiki_page.patches.convert_wiki_content_to_markdown
wiki.wiki.doctype.wiki_page.patches.update_escaped_code_content
wiki.wiki.doctype.wiki_page.patches.update_escaped_chars
wiki.wiki.doctype.wiki_page.patches.update_escaped_chars
wiki.wiki.doctype.wiki_space.patches.wiki_navbar_app_switcher_migration
18 changes: 14 additions & 4 deletions wiki/public/scss/dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
position: absolute;
left: 10px;
top: 100%;
background-color: var(--navbar-dropdown-bg-color);
background-color: var(--search-modal-bg-color);
color: var(--search-modal-color);
width: 96%;
border-radius: 8px;
box-shadow: 0 10px 24px -3px #0000001a;
Expand All @@ -30,20 +31,29 @@
.app-switcher {
display: flex;
flex-direction: column;
gap: 2px;
gap: 4px;
font-size: 14px;
padding: 10px;
height: 350px;
height: 100%;
max-height: 350px;
overflow: auto;
font-weight: 500;
}

.space-link {
padding: 4px;
padding-left: 8px;
display: flex;
align-items: center;
gap: 8px;

img {
width: 22px;
}
}

.space-link:hover {
background-color: var(--sidebar-hover-color);
background-color: var(--search-modal-hover-color);
border-radius: 4px;
}
}
Expand Down
9 changes: 7 additions & 2 deletions wiki/wiki/doctype/wiki_page/templates/wiki_navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<span>{{ (frappe.get_hooks("brand_html") or [_("Home")])[0] }}</span>
{%- endif -%}
</a>
{% if spaces and spaces|length > 0 %}
<div id="navbar-dropdown">
<svg viewBox="0 0 24 24" width="16" height="16" stroke="currentColor" stroke-width="2" fill="none"
stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1">
Expand All @@ -21,12 +22,16 @@
<div id="navbar-dropdown-content" class="hide">
<div class="app-switcher">
{% for space in spaces %}
<a href="/{{ space.url }}" class="space-link">
{{ space.name }}
<a href="/{{ space.route }}" class="space-link">
<img src="{{space.app_switcher_logo or '/app-icon.png'}}" alt="{{space.space_name}} logo" />
<span>
{{ space.space_name }}
</span>
</a>
{% endfor %}
</div>
</div>
{% endif %}
</div>

{% if navbar_search %}
Expand Down
9 changes: 6 additions & 3 deletions wiki/wiki/doctype/wiki_page/wiki_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,13 @@ def get_context(self, context):
self.verify_permission()
self.set_breadcrumbs(context)

allSpaces = get_all_spaces()
allSpaces = frappe.get_all(
"Wiki Space",
fields=["route", "space_name", "app_switcher_logo"],
filters={"show_in_navbar_app_switcher": 1},
)

filtered_spaces = [space for space in allSpaces if "/" not in space]
context.spaces = [{"url": space, "name": space.capitalize()} for space in filtered_spaces]
context.spaces = allSpaces

wiki_settings = frappe.get_single("Wiki Settings")
wiki_space_name = frappe.get_value("Wiki Group Item", {"wiki_page": self.name}, "parent")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import frappe


def execute():
wiki_spaces = frappe.db.get_all("Wiki Space", fields=["*"])
for space in wiki_spaces:
if space["space_name"] is None:
frappe.db.set_value(
"Wiki Space", space["name"], "space_name", space["route"].replace("/", " ").capitalize()
)
23 changes: 22 additions & 1 deletion wiki/wiki/doctype/wiki_space/wiki_space.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"engine": "InnoDB",
"field_order": [
"general_tab",
"space_name",
"route",
"show_in_navbar_app_switcher",
"app_switcher_logo",
"wiki_sidebars",
"navbar_tab",
"logo_section",
Expand Down Expand Up @@ -67,11 +70,29 @@
{
"fieldname": "section_break_fhui",
"fieldtype": "Section Break"
},
{
"default": "0",
"fieldname": "show_in_navbar_app_switcher",
"fieldtype": "Check",
"label": "Show in navbar app switcher"
},
{
"fieldname": "space_name",
"fieldtype": "Data",
"label": "Space Name"
},
{
"depends_on": "eval:doc.show_in_navbar_app_switcher==1;",
"fieldname": "app_switcher_logo",
"fieldtype": "Attach Image",
"label": "App Switcher Logo",
"make_attachment_public": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-12-11 15:27:44.629602",
"modified": "2025-02-18 14:09:29.088972",
"modified_by": "Administrator",
"module": "Wiki",
"name": "Wiki Space",
Expand Down
Binary file added wiki/www/app-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d08e4e8

Please sign in to comment.