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

jingrow.ui.form.on('Version Upgrade', {
	refresh: function (frm) {
		if (['Scheduled', 'Failure'].includes(frm.pg.status)) {
			frm.add_custom_button(__('Start'), () => {
				jingrow.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://jingrow.com/dashboard/sites/${frm.pg.site}`);
			});
		}
	},
});
