// Copyright (c) 2023, JINGROW
// For license information, please see license.txt

jingrow.ui.form.on('MariaDB Variable', {
	refresh(frm) {
		let root = 'https://mariadb.com/kb/en/';
		frm.add_web_link(
			`${root}${frm.pg.pg_section}-system-variables/#${frm.pg.name}`,
			__('Check MariaDB Documentation'),
		);
		frm.add_custom_button(__('Set on all servers'), () => {
			jingrow.confirm(
				`Are you sure you want to set variable on all servers?
								If variable is not dynamic, mariadb will be restarted`,
				() =>
					frm.call('set_on_all_servers').then((r) => {
						if (r.message) {
							jingrow.msgprint(r.message);
						} else {
							frm.refresh();
						}
					}),
			);
		});
	},
});
