Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Move special case funcs to intrinsics" #5478

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/web/src/api/sdf/dal/func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ export enum FuncBackendKind {
JsReconciliation = "JsReconciliation",
JsSchemaVariantDefinition = "JsSchemaVariantDefinition",
Map = "Map",
NormalizeToArray = "NormalizeToArray",
Object = "Object",
ResourcePayloadToValue = "ResourcePayloadToValue",
String = "String",
Unset = "Unset",
Validation = "Validation",
Expand Down
89 changes: 17 additions & 72 deletions app/web/src/components/AssetDetailIntrinsicInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
:label="label"
:options="optionsForIntrinsicDisplay"
compact
:iconRight="icon"
:iconRight="
display.funcId === identityFuncId ? 'input-socket' : 'circle-slash'
"
:disabled="isLocked || display.funcId === unsetFuncId"
:showCautionLines="display.funcId === unsetFuncId"
iconRightRotate="down"
Expand All @@ -28,38 +30,17 @@
:checked="selectedFilter === 'unset'"
@select="selectFilter('unset')"
/>
<span class="pl-xs text-neutral-500">Identity</span>
<DropdownMenuItem
label="Bind to Input Socket"
checkable
:checked="selectedFilter === 'inputSocketForIdentity'"
@select="selectFilter('inputSocketForIdentity')"
:checked="selectedFilter === 'inputSocket'"
@select="selectFilter('inputSocket')"
/>
<DropdownMenuItem
label="Bind to Prop"
checkable
:checked="selectedFilter === 'propForIdentity'"
@select="selectFilter('propForIdentity')"
/>
<span v-if="normalizeToArrayFuncId" class="flex pl-xs text-neutral-500"
>Normalize to Array</span
>
<span v-else class="flex pl-xs text-neutral-500"
>Normalize to Array (Regenerate to Install)</span
>
<DropdownMenuItem
label="Bind to Input Socket"
checkable
:disabled="!normalizeToArrayFuncId"
:checked="selectedFilter === 'inputSocketForNormalizeToArray'"
@select="selectFilter('inputSocketForNormalizeToArray')"
/>
<DropdownMenuItem
label="Bind to Prop"
checkable
:disabled="!normalizeToArrayFuncId"
:checked="selectedFilter === 'propForNormalizeToArray'"
@select="selectFilter('propForNormalizeToArray')"
:checked="selectedFilter === 'prop'"
@select="selectFilter('prop')"
/>
</DropdownMenu>
<DetailsPanelMenuIcon
Expand Down Expand Up @@ -103,12 +84,7 @@ const props = defineProps<{
isLocked: boolean;
}>();

type DropdownFilter =
| "unset"
| "propForIdentity"
| "inputSocketForIdentity"
| "propForNormalizeToArray"
| "inputSocketForNormalizeToArray";
type DropdownFilter = "unset" | "prop" | "inputSocket";

const display = ref<PropDisplay | IntrinsicDisplay | undefined>();

Expand Down Expand Up @@ -141,7 +117,7 @@ watch(
{ immediate: true },
);

const emit = defineEmits(["change", "changeIntrinsicFunc"]);
const emit = defineEmits(["change", "changeToUnset", "changeToIdentity"]);

const funcStore = useFuncStore();
const assetStore = useAssetStore();
Expand All @@ -153,66 +129,41 @@ const identityFuncId = computed(() => {
return func?.funcId as FuncId;
});

const normalizeToArrayFuncId = computed(() => {
const func = funcStore.funcList.find(
(func) =>
func.kind === FuncKind.Intrinsic && func.name === "si:normalizeToArray",
);
return func?.funcId as FuncId;
});

const unsetFuncId = computed(() => {
const func = funcStore.funcList.find(
(func) => func.kind === FuncKind.Intrinsic && func.name === "si:unset",
);
return func?.funcId as FuncId;
});

const icon = computed(() => {
if (display.value?.funcId === identityFuncId.value) return "input-socket";
else if (display.value?.funcId === normalizeToArrayFuncId.value)
return "brackets-square";
return "circle-slash";
});

const initialFilter = (): DropdownFilter | null => {
if (display.value?.value?.startsWith("s_")) {
if (display.value?.funcId === normalizeToArrayFuncId.value)
return "inputSocketForNormalizeToArray";
return "inputSocketForIdentity";
return "inputSocket";
} else if (display.value?.value?.startsWith("p_")) {
if (display.value?.funcId === normalizeToArrayFuncId.value)
return "propForNormalizeToArray";
return "propForIdentity";
return "prop";
} else if (display.value?.funcId === unsetFuncId.value) {
return "unset";
} else if ("socketName" in props.data) {
// NOTE(nick): fallback to the input data if the display is empty. We need this in case a "emit" blows the
// component away. This could be cleaner to avoid having multiple branches.
return "inputSocketForIdentity";
return "inputSocket";
} else if ("path" in props.data) {
// NOTE(nick): fallback to the input data if the display is empty. We need this in case a "emit" blows the
// component away. This could be cleaner to avoid having multiple branches.
return "propForIdentity";
return "prop";
}
return null;
};

const selectedFilter = ref<DropdownFilter | null>(initialFilter());
const selectFilter = (item: DropdownFilter) => {
if (props.isLocked) return;

selectedFilter.value = item;

if (item === "unset") {
emit("changeIntrinsicFunc", "unset", display.value);
} else if (
item === "propForNormalizeToArray" ||
item === "inputSocketForNormalizeToArray"
) {
emit("changeIntrinsicFunc", "normalizeToArray", display.value);
emit("changeToUnset", display.value);
} else {
emit("changeIntrinsicFunc", "identity", display.value);
emit("changeToIdentity", display.value, null);
}
};

Expand All @@ -221,15 +172,9 @@ const optionsForIntrinsicDisplay = computed(() => {
const variant = assetStore.variantFromListById[props.schemaVariantId];
if (!variant) return {};

if (
selectedFilter.value === "propForIdentity" ||
selectedFilter.value === "propForNormalizeToArray"
) {
if (selectedFilter.value === "prop") {
return groupedPropsFor(variant);
} else if (
selectedFilter.value === "inputSocketForIdentity" ||
selectedFilter.value === "inputSocketForNormalizeToArray"
) {
} else if (selectedFilter.value === "inputSocket") {
return inputSocketsFor(variant);
}
return {};
Expand Down
Loading