refactor: move auto generations of icons to a command
This commit is contained in:
parent
219ba386ab
commit
586b62da05
5 changed files with 32 additions and 23 deletions
|
|
@ -1584,6 +1584,31 @@ def bypass_patch(context: CliCtxObj, patch_name: str, yes: bool):
|
|||
frappe.destroy()
|
||||
|
||||
|
||||
@click.command("create-desktop-icons-and-sidebar")
|
||||
@pass_context
|
||||
def create_icons_and_sidebar(context: CliCtxObj):
|
||||
"""Create desktop icons and workspace sidebars."""
|
||||
from frappe.desk.doctype.desktop_icon.desktop_icon import create_desktop_icons
|
||||
from frappe.desk.doctype.workspace_sidebar.workspace_sidebar import (
|
||||
create_workspace_sidebar_for_workspaces,
|
||||
)
|
||||
|
||||
if not context.sites:
|
||||
raise SiteNotSpecifiedError
|
||||
for site in context.sites:
|
||||
frappe.init(site)
|
||||
frappe.connect()
|
||||
try:
|
||||
print("Creating Desktop Icons")
|
||||
create_desktop_icons()
|
||||
frappe.db.commit()
|
||||
print("Creating Workspace Sidebars")
|
||||
create_workspace_sidebar_for_workspaces()
|
||||
frappe.db.commit()
|
||||
finally:
|
||||
frappe.destroy()
|
||||
|
||||
|
||||
commands = [
|
||||
add_system_manager,
|
||||
add_user_for_sites,
|
||||
|
|
@ -1620,4 +1645,5 @@ commands = [
|
|||
trim_database,
|
||||
clear_log_table,
|
||||
bypass_patch,
|
||||
create_icons_and_sidebar,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -437,6 +437,7 @@ def run_parallel_tests(
|
|||
@click.option("--parallel", is_flag=True, help="Run UI Test in parallel mode")
|
||||
@click.option("--with-coverage", is_flag=True, help="Generate coverage report")
|
||||
@click.option("--browser", default="chrome", help="Browser to run tests in")
|
||||
@click.option("--spec", help="Spec file to run")
|
||||
@click.option("--ci-build-id")
|
||||
@pass_context
|
||||
def run_ui_tests(
|
||||
|
|
@ -448,6 +449,7 @@ def run_ui_tests(
|
|||
browser="chrome",
|
||||
ci_build_id=None,
|
||||
cypressargs=None,
|
||||
spec=None,
|
||||
):
|
||||
"Run UI tests"
|
||||
site = get_site(context)
|
||||
|
|
@ -494,6 +496,8 @@ def run_ui_tests(
|
|||
|
||||
# run for headless mode
|
||||
run_or_open = f"run --browser {browser}" if headless else "open"
|
||||
if headless and spec:
|
||||
run_or_open += f" --spec {spec}"
|
||||
formatted_command = f"{site_env} {password_env} {coverage_env} {cypress_path} {run_or_open}"
|
||||
|
||||
if os.environ.get("CYPRESS_RECORD_KEY"):
|
||||
|
|
|
|||
|
|
@ -634,7 +634,7 @@ def create_desktop_icons_from_workspace():
|
|||
if app_icon:
|
||||
icon.parent_icon = app_icon
|
||||
|
||||
# Portal App (CRM Or Helpdesk) With Desk Workspace
|
||||
# Portal App With Desk Workspace
|
||||
if not frappe.db.get_value("Desktop Icon", app_icon, "link").startswith("/app"):
|
||||
icon.hidden = 1
|
||||
icon.parent_icon = None
|
||||
|
|
@ -645,21 +645,12 @@ def create_desktop_icons_from_workspace():
|
|||
):
|
||||
icon.hidden = 1
|
||||
icon.parent_icon = None
|
||||
print(f"Label {icon.label}")
|
||||
print(f"Icon Type {icon.icon_type}")
|
||||
print(f"Link Type {icon.link_type}")
|
||||
|
||||
try:
|
||||
if not frappe.db.exists("Desktop Icon", [{"label": icon.label, "icon_type": icon.icon_type}]):
|
||||
icon.insert(ignore_if_duplicate=True)
|
||||
except Exception as e:
|
||||
print(f"Error occurred while inserting icon: {e}")
|
||||
existing_icon = frappe.db.exists("Desktop Icon", [{"label": icon.label}])
|
||||
if existing_icon:
|
||||
old_icon = frappe.get_doc("Desktop Icon", existing_icon)
|
||||
print("Existing Icon Found:")
|
||||
print(f"Label {old_icon.label}")
|
||||
print(f"Icon Type {old_icon.icon_type}")
|
||||
print(f"Link Type {old_icon.link_type}")
|
||||
|
||||
|
||||
def generate_color():
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ from semantic_version import Version
|
|||
|
||||
import frappe
|
||||
from frappe.defaults import _clear_cache
|
||||
from frappe.desk.doctype.desktop_icon.desktop_icon import create_desktop_icons, sync_desktop_icons
|
||||
from frappe.desk.doctype.workspace_sidebar.workspace_sidebar import create_workspace_sidebar_for_workspaces
|
||||
from frappe.utils import cint, is_git_url
|
||||
from frappe.utils.dashboard import sync_dashboards
|
||||
from frappe.utils.synchronization import filelock
|
||||
|
|
@ -339,8 +337,6 @@ def install_app(name, verbose=False, set_as_patched=True, force=False):
|
|||
sync_fixtures(name)
|
||||
sync_customizations(name)
|
||||
sync_dashboards(name)
|
||||
create_desktop_icons()
|
||||
create_workspace_sidebar_for_workspaces()
|
||||
|
||||
for after_sync in app_hooks.after_sync or []:
|
||||
frappe.get_attr(after_sync)() #
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ from frappe.core.doctype.navbar_settings.navbar_settings import sync_standard_it
|
|||
from frappe.core.doctype.scheduled_job_type.scheduled_job_type import sync_jobs
|
||||
from frappe.database.schema import add_column
|
||||
from frappe.deferred_insert import save_to_db as flush_deferred_inserts
|
||||
from frappe.desk.doctype.desktop_icon.desktop_icon import create_desktop_icons
|
||||
from frappe.desk.doctype.workspace_sidebar.workspace_sidebar import create_workspace_sidebar_for_workspaces
|
||||
from frappe.desk.notifications import clear_notifications
|
||||
from frappe.modules.patch_handler import PatchType
|
||||
from frappe.modules.utils import sync_customizations
|
||||
|
|
@ -190,12 +188,6 @@ class SiteMigration:
|
|||
print("Updating installed applications...")
|
||||
frappe.get_single("Installed Applications").update_versions()
|
||||
|
||||
print("Creating Desktop Icons...")
|
||||
create_desktop_icons()
|
||||
|
||||
print("Creating Workspace Sidebars..")
|
||||
create_workspace_sidebar_for_workspaces()
|
||||
|
||||
print("Executing `after_migrate` hooks...")
|
||||
for app in frappe.get_installed_apps():
|
||||
for fn in frappe.get_hooks("after_migrate", app_name=app):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue