From 855208c59d782710e07f65c5f558f81c7c9beda1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 25 Sep 2019 19:42:06 +0200 Subject: [PATCH] luci-mod-system: flash.js: disable mtdblock downloads on mtd-less systems Ref: https://github.com/openwrt/luci/commit/3c40a7450a9b7d340cdc9e233818c63a8092fec2#commitcomment-35233073 Signed-off-by: Jo-Philipp Wich --- .../resources/view/system/flash.js | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js index bea587625d..08c97650ea 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js @@ -508,20 +508,22 @@ return L.view.extend({ o.onclick = L.bind(this.handleRestore, this); - o = s.option(form.SectionValue, 'actions', form.NamedSection, 'actions', 'actions', _('Save mtdblock contents'), _('Click "Save mtdblock" to download specified mtdblock file. (NOTE: THIS FEATURE IS FOR PROFESSIONALS! )')); - ss = o.subsection; - - o = ss.option(form.ListValue, 'mtdselect', _('Choose mtdblock')); - procmtd.split(/\n/).forEach(function(ln) { - var match = ln.match(/^mtd(\d+): .+ "(.+?)"$/); - if (match) - o.value(match[1], match[2]); - }); + if (procmtd.length) { + o = s.option(form.SectionValue, 'actions', form.NamedSection, 'actions', 'actions', _('Save mtdblock contents'), _('Click "Save mtdblock" to download specified mtdblock file. (NOTE: THIS FEATURE IS FOR PROFESSIONALS! )')); + ss = o.subsection; + + o = ss.option(form.ListValue, 'mtdselect', _('Choose mtdblock')); + procmtd.split(/\n/).forEach(function(ln) { + var match = ln.match(/^mtd(\d+): .+ "(.+?)"$/); + if (match) + o.value(match[1], match[2]); + }); - o = ss.option(form.Button, 'mtddownload', _('Download mtdblock')); - o.inputstyle = 'action important'; - o.inputtitle = _('Save mtdblock'); - o.onclick = L.bind(this.handleBlock, this, hostname); + o = ss.option(form.Button, 'mtddownload', _('Download mtdblock')); + o.inputstyle = 'action important'; + o.inputtitle = _('Save mtdblock'); + o.onclick = L.bind(this.handleBlock, this, hostname); + } o = s.option(form.SectionValue, 'actions', form.NamedSection, 'actions', 'actions', _('Flash new firmware image'), -- 2.30.2