update_lhs.ts

pull/719/head
Rick Carlino 2018-03-14 12:37:01 -05:00
parent 3042b20572
commit aa31ff76ca
4 changed files with 32 additions and 2 deletions

View File

@ -30,7 +30,7 @@ module CeleryScriptSettingsBag
ALLOWED_DATA_TYPES = %w(tool coordinate point)
ALLOWED_OPS = %w(< > is not is_undefined)
ALLOWED_AXIS = %w(x y z all)
ALLOWED_LHS_TYPES = [String, :peripheral, :sensor, :named_pin, :pin]
ALLOWED_LHS_TYPES = [String, :named_pin]
ALLOWED_LHS_STRINGS = [*(0..69)].map{|x| "pin#{x}"}.concat(%w(x y z))
STEPS = %w(_if execute execute_script find_home move_absolute
move_relative read_pin send_message take_photo wait

View File

@ -111,4 +111,9 @@ unless Rails.env == "production"
x: 10,
y: 10,
z: 10)
end
d = u.device
PinBindings::Create
.run!(device: d, sequence_id: d.sequences.sample.id, pin_num: 15,)
Sensors::Create
.run!(device: d, pin: 14, label: "Stub sensor", mode: 0)
end

View File

@ -0,0 +1,20 @@
interface LhsUpdateProps {
currentSequence: TaggedSequence;
currentStep: If;
dispatch: Function;
index: number;
resources: ResourceIndex;
}
export const updateLhs =
(props: IfParams) =>
(ddi: DropDownItem) => {
fancyDebug(e);
const stepCopy = defensiveClone(step);
const seqCopy = defensiveClone(sequence).body;
const val = e.value;
seqCopy.body = seqCopy.body || [];
if (_.isString(val)) { stepCopy.args[field] = val; }
seqCopy.body[index] = stepCopy;
dispatch(overwrite(sequence, seqCopy));
}

View File

@ -102,6 +102,11 @@ export enum MinVersionOverride {
export function shouldDisplay(
current: string | undefined, lookupData: MinOsFeatureLookup | undefined) {
return function (feature: Feature): boolean {
/** Escape hatch for platform developers doing offline development. */
if (localStorage.getItem("IM_A_DEVELOPER")) {
return true;
}
if (isString(current)) {
const min = (lookupData || {})[feature] || MinVersionOverride.NEVER;
switch (semverCompare(current, min)) {