From 2480b9ad545704d2b97865538295c7ce21f163ac Mon Sep 17 00:00:00 2001 From: Egor Savkin Date: Tue, 26 Sep 2023 14:44:39 +0800 Subject: [PATCH] Leave opt-out option only to the first kasli Signed-off-by: Egor Savkin --- static/js/shop_components.jsx | 3 ++- static/js/shop_data.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/static/js/shop_components.jsx b/static/js/shop_components.jsx index 65d2b1c..f81eb00 100644 --- a/static/js/shop_components.jsx +++ b/static/js/shop_components.jsx @@ -443,9 +443,10 @@ export function OptionsSummaryPopup({id, options, data}) { export function FillExtData(data, index) { return { + has_previous_carrier: data.filter((value, item_index) => index > item_index && value.name === "Carrier").length > 0, has_other_dio: data.filter((value, item_index) => index !== item_index && value.name.endsWith("-TTL")).length > 0, has_dds: data.filter(((value, _) => value.name === "DDS" && (!value.options_data || !value.options_data.mono_eem))).length > 0, - has_sampler: data.filter(((value, _) => value.name === "Sampler" && (!value.options_data || !value.options_data.mono_eem))).length > 0 + has_sampler: data.filter(((value, _) => value.name === "Sampler" && (!value.options_data || !value.options_data.mono_eem))).length > 0, } } diff --git a/static/js/shop_data.js b/static/js/shop_data.js index 8a9ba72..65be0ac 100644 --- a/static/js/shop_data.js +++ b/static/js/shop_data.js @@ -79,7 +79,10 @@ const shop_data = { {type: "Line", args: {title: "IPv4", outvar: "ipv4", fallback: "192.168.1.75/24", tip: "Set up IPv4 address used by core device"}}, {type: "SwitchLine", args: {title: "IPv6", outvar: "ipv6"}}, {type: "SwitchLine", args: {title: "Ext CLK", outvar: "ext_clk", fallback: {text: "125 MHz", checked: false}, tip: "Use external clock reference: 10, 80 (beta), 100 or 125 MHz. Other variants may be provided if needed."}}, - {type: "Switch", args: {title: "Opt out from promotional USB-stick", outvar: "usb_opt_out", tip: "Do not ship a promotional USB-stick"}}, + {"if": [ + {"!": {"var": "ext_data.has_previous_carrier"}}, + {type: "Switch", args: {title: "Opt out from promotional USB-stick", outvar: "usb_opt_out", tip: "Do not ship a promotional USB-stick"}} + ]} ], [ {type: "Switch", args: {title: "Optic fiber", outvar: "optics", tip: "Use optic fiber instead of direct attach copper cable"}} @@ -163,7 +166,10 @@ const shop_data = { {type: "Line", args: {title: "IPv4", outvar: "ipv4", fallback: "192.168.1.75/24", tip: "Set up IPv4 address used by core device"}}, {type: "SwitchLine", args: {title: "IPv6", outvar: "ipv6"}}, {type: "SwitchLine", args: {title: "Ext CLK", outvar: "ext_clk", fallback: {text: "125 MHz", checked: false}, tip: "Use external clock reference: 10, 80 (beta), 100 or 125 MHz. Other variants may be provided if needed."}}, - {type: "Switch", args: {title: "Opt out from promotional USB-stick", outvar: "usb_opt_out", tip: "Do not ship a promotional USB-stick"}}, + {"if": [ + {"!": {"var": "ext_data.has_previous_carrier"}}, + {type: "Switch", args: {title: "Opt out from promotional USB-stick", outvar: "usb_opt_out", tip: "Do not ship a promotional USB-stick"}} + ]} ], [ {type: "Switch", args: {title: "Optic fiber", outvar: "optics", tip: "Use optic fiber instead of direct attach copper cable"}}