// Copyright (c) 2022, InfluxFramework LLC
// MIT License. See LICENSE

influxframework.ui.form.on("Role", {
	refresh: function (frm) {
		if (frm.doc.name === "All") {
			frm.dashboard.add_comment(
				__("Role 'All' will be given to all System Users."),
				"yellow"
			);
		}

		frm.set_df_property("is_custom", "read_only", influxframework.session.user !== "Administrator");

		frm.add_custom_button("Role Permissions Manager", function () {
			influxframework.route_options = { role: frm.doc.name };
			influxframework.set_route("permission-manager");
		});
		frm.add_custom_button("Show Users", function () {
			influxframework.route_options = { role: frm.doc.name };
			influxframework.set_route("List", "User", "Report");
		});
	},
});
