-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: let users modify hook resolution order Since hook resolution depends on the order in which apps were installed on site, it should be made configurable as escape hatch in case a different resolution order is desired. Keep in mind that changing order affects every hook, page, customization so you can't pick and choose priority for individual hooks as of now. Separate proposals are welcome for such configurabilty. (cherry picked from commit 1796cae) # Conflicts: # frappe/core/doctype/installed_applications/installed_applications.js # frappe/core/doctype/installed_applications/test_installed_applications.py * fix: log changes made to installed_apps order (cherry picked from commit c14379c) * chore: conflicts * fix(UX): drag handles on app resolution order table (#19672) [skip ci] Co-Authored-By: Suraj Shetty <surajshetty3416@gmail.com> Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com> Co-authored-by: Ankush Menat <ankush@frappe.io> Co-authored-by: Suraj Shetty <surajshetty3416@gmail.com>
- Loading branch information
1 parent
30729a2
commit 76e0974
Showing
3 changed files
with
129 additions
and
9 deletions.
There are no files selected for viewing
65 changes: 62 additions & 3 deletions
65
frappe/core/doctype/installed_applications/installed_applications.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,67 @@ | ||
// Copyright (c) 2020, Frappe Technologies and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('Installed Applications', { | ||
// refresh: function(frm) { | ||
frappe.ui.form.on("Installed Applications", { | ||
refresh: function (frm) { | ||
frm.add_custom_button(__("Update Hooks Resolution Order"), () => { | ||
frm.trigger("show_update_order_dialog"); | ||
}); | ||
}, | ||
|
||
// } | ||
show_update_order_dialog() { | ||
const dialog = new frappe.ui.Dialog({ | ||
title: __("Update Hooks Resolution Order"), | ||
fields: [ | ||
{ | ||
fieldname: "apps", | ||
fieldtype: "Table", | ||
label: __("Installed Apps"), | ||
cannot_add_rows: true, | ||
cannot_delete_rows: true, | ||
in_place_edit: true, | ||
data: [], | ||
fields: [ | ||
{ | ||
fieldtype: "Data", | ||
fieldname: "app_name", | ||
label: __("App Name"), | ||
in_list_view: 1, | ||
read_only: 1, | ||
}, | ||
], | ||
}, | ||
], | ||
primary_action: function () { | ||
const new_order = this.get_values()["apps"].map((row) => row.app_name); | ||
frappe.call({ | ||
method: "frappe.core.doctype.installed_applications.installed_applications.update_installed_apps_order", | ||
freeze: true, | ||
args: { | ||
new_order: new_order, | ||
}, | ||
}); | ||
this.hide(); | ||
}, | ||
primary_action_label: __("Update Order"), | ||
}); | ||
|
||
frappe | ||
.xcall( | ||
"frappe.core.doctype.installed_applications.installed_applications.get_installed_app_order" | ||
) | ||
.then((data) => { | ||
data.forEach((app) => { | ||
dialog.fields_dict.apps.df.data.push({ | ||
app_name: app, | ||
}); | ||
}); | ||
|
||
dialog.fields_dict.apps.grid.refresh(); | ||
// hack: change checkboxes to drag handles. | ||
let grid = $(dialog.fields_dict.apps.grid.parent); | ||
grid.find(".grid-row-check:first").remove() && | ||
grid.find(".grid-row-check").replaceWith(frappe.utils.icon("menu")); | ||
dialog.show(); | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 12 additions & 6 deletions
18
frappe/core/doctype/installed_applications/test_installed_applications.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2020, Frappe Technologies and Contributors | ||
# See license.txt | ||
from __future__ import unicode_literals | ||
# License: MIT. See LICENSE | ||
|
||
# import frappe | ||
import unittest | ||
import frappe | ||
from frappe.core.doctype.installed_applications.installed_applications import ( | ||
InvalidAppOrder, | ||
update_installed_apps_order, | ||
) | ||
from frappe.tests.utils import FrappeTestCase | ||
|
||
|
||
class TestInstalledApplications(unittest.TestCase): | ||
pass | ||
class TestInstalledApplications(FrappeTestCase): | ||
def test_order_change(self): | ||
update_installed_apps_order(["frappe"]) | ||
self.assertRaises(InvalidAppOrder, update_installed_apps_order, []) | ||
self.assertRaises(InvalidAppOrder, update_installed_apps_order, ["frappe", "deepmind"]) |