Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit abcaed7

Browse files
merge: #3480
3480: feat(web): Show "set by socket" option on dropdown for maps and arrays. r=vbustamante a=vbustamante <img width="408" alt="image" src="https://github.com/systeminit/si/assets/6564471/cad3b433-8dcd-419d-b998-08b768c32ae4"> This resets the value of a map, array or object back to the default function for the schema variant, as the x button does for text fields (string, number) Co-authored-by: Victor Bustamante <victor@systeminit.com>
2 parents ab23fd7 + 063077c commit abcaed7

2 files changed

Lines changed: 60 additions & 36 deletions

File tree

app/web/src/api/sdf/dal/property_editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface PropertyEditorProp {
9595
isReadonly: boolean;
9696
documentation?: string;
9797
validationFormat?: string;
98+
defaultCanBeSetBySocket: boolean;
9899
}
99100

100101
export interface PropertyEditorSchema {

app/web/src/components/AttributesPanel/AttributesPanelItem.vue

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,9 @@
105105
header
106106
/>
107107
<!-- DROPDOWN MENU FOR SELECT SOURCE -->
108-
<!-- TODO(Wendy) - currently we hide this menu if the prop is set manually since you can't select another option yet -->
109108
<template
110109
v-if="
111-
propSource !== 'manually' &&
112-
attributeDef.value?.ancestorManual &&
110+
validAttributeValueSources.length > 1 &&
113111
featureFlagsStore.INDICATORS_MANUAL_FUNCTION_SOCKET
114112
"
115113
>
@@ -125,11 +123,13 @@
125123
<Icon name="chevron--down" size="sm" />
126124
</div>
127125
</div>
126+
128127
<DropdownMenu ref="sourceSelectMenuRef">
129-
<!-- TODO(Wendy) - Currently you can't switch to anything but manually -->
130-
<template v-for="source in sourceKinds" :key="source">
128+
<template
129+
v-for="source in validAttributeValueSources"
130+
:key="source"
131+
>
131132
<DropdownMenuItem
132-
v-if="source === 'manually' || propSource === source"
133133
:checked="propSource === source"
134134
:label="source"
135135
@click="setSource(source)"
@@ -330,8 +330,8 @@
330330
<template v-else-if="widgetKind === 'text'">
331331
<input
332332
v-model="newValueString"
333-
spellcheck="false"
334333
:class="`${propLabelParts[0]}${propLabelParts[1]}`"
334+
spellcheck="false"
335335
type="text"
336336
@blur="onBlur"
337337
@focus="onFocus"
@@ -614,9 +614,6 @@ import SecretsModal from "../SecretsModal.vue";
614614
import SourceIconWithTooltip from "./SourceIconWithTooltip.vue";
615615
import CodeViewer from "../CodeViewer.vue";
616616
617-
const sourceKinds = ["manually", "via socket", "via attribute func"] as const;
618-
export type SourceKind = (typeof sourceKinds)[number];
619-
620617
const props = defineProps({
621618
parentPath: { type: String },
622619
attributeDef: { type: Object as PropType<AttributeTreeItem>, required: true },
@@ -767,12 +764,60 @@ const propManual = computed(
767764
propSetByDynamicFunc.value
768765
),
769766
);
770-
const propSource = computed<SourceKind>(() => {
771-
if (propHasSocket.value || propPopulatedBySocket.value) return "via socket";
772-
else if (propSetByDynamicFunc.value) return "via attribute func";
773-
else return "manually";
767+
768+
enum AttributeValueSource {
769+
Manual = "manually",
770+
Socket = "via socket",
771+
NonSocketAttributeFunc = "via attribute func",
772+
}
773+
774+
const validAttributeValueSources = computed(() => {
775+
const sources = [];
776+
777+
// TODO(victor): Get if default function is dynamic from the api to show NonSocketAttributeFunc option on the dropdown
778+
779+
if (props.attributeDef.propDef.defaultCanBeSetBySocket) {
780+
sources.push(AttributeValueSource.Socket);
781+
}
782+
783+
if (props.attributeDef.value?.isControlledByAncestor === false) {
784+
sources.push(AttributeValueSource.Manual);
785+
}
786+
if (!sources.includes(propSource.value)) {
787+
sources.push(propSource.value);
788+
}
789+
790+
return sources;
791+
});
792+
793+
const propSource = computed<AttributeValueSource>(() => {
794+
if (propHasSocket.value || propPopulatedBySocket.value)
795+
return AttributeValueSource.Socket;
796+
else if (propSetByDynamicFunc.value)
797+
return AttributeValueSource.NonSocketAttributeFunc;
798+
else return AttributeValueSource.Manual;
774799
});
775800
801+
const setSource = (source: AttributeValueSource) => {
802+
if (source === AttributeValueSource.Manual) {
803+
const value = props.attributeDef.value?.value ?? null;
804+
805+
attributesStore.UPDATE_PROPERTY_VALUE({
806+
update: {
807+
attributeValueId: props.attributeDef.valueId,
808+
parentAttributeValueId: props.attributeDef.parentValueId,
809+
propId: props.attributeDef.propId,
810+
componentId,
811+
value,
812+
},
813+
});
814+
} else {
815+
attributesStore.RESET_PROPERTY_VALUE({
816+
attributeValueId: props.attributeDef.valueId,
817+
});
818+
}
819+
};
820+
776821
const sourceIcon = computed(() => {
777822
if (propPopulatedBySocket.value) return "circle-full";
778823
else if (propSetByDynamicFunc.value) return "func";
@@ -997,28 +1042,6 @@ const confirmEdit = () => {
9971042
const editOverride = ref(false);
9981043
9991044
const sourceSelectMenuRef = ref<InstanceType<typeof DropdownMenu>>();
1000-
1001-
const setSource = (source: SourceKind) => {
1002-
if (source === "manually") {
1003-
const value = props.attributeDef.value?.value ?? null;
1004-
1005-
// console.log(value);
1006-
1007-
attributesStore.UPDATE_PROPERTY_VALUE({
1008-
update: {
1009-
attributeValueId: props.attributeDef.valueId,
1010-
parentAttributeValueId: props.attributeDef.parentValueId,
1011-
propId: props.attributeDef.propId,
1012-
componentId,
1013-
value,
1014-
},
1015-
});
1016-
} else if (source === "via socket") {
1017-
// TODO(Wendy) - Here's where we can put logic for selecting a socket to connect to this prop
1018-
} else {
1019-
// TODO(Wendy) - Here's where we can put logic for selecting an attribute function to populate this prop
1020-
}
1021-
};
10221045
</script>
10231046

10241047
<style lang="less">

0 commit comments

Comments
 (0)