// Copyright (c) 2022, Frappe and contributors
// For license information, please see license.txt

frappe.ui.form.on('Version Upgrade', {
	refresh: function (frm) {
		if (['Scheduled', 'Failure'].includes(frm.pg.status)) {
			frm.add_custom_button(__('Start'), () => {
				frappe.confirm('Are you sure you want to try an update?', () =>
					frm.call('start'),
				);
			});
		}
		if (frm.pg.status == 'Success') {
			frm.add_custom_button(__('Show on FC'), () => {
				window.open(`https://jcloud.jingrow.com/dashboard/sites/${frm.pg.site}`);
			});
		}
	},
});
