Skip to content

Commit

Permalink
merge: #3027
Browse files Browse the repository at this point in the history
3027: Wendy/eng 2114 modeling bugs and UI issues fixing the debug panel r=wendybujalski a=wendybujalski

- confirmation model for change set deletion
- resources tab has a empty state graphic
- code panel supports multiple code outputs

Co-authored-by: wendybujalski <[email protected]>
  • Loading branch information
si-bors-ng[bot] and wendybujalski authored Dec 8, 2023
2 parents d8da87a + 2aacd0f commit 9e62996
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 145 deletions.
2 changes: 1 addition & 1 deletion app/web/src/components/AssetFuncListPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AssetFuncAttachDropdown
v-if="assetStore.selectedAssetId"
:disabled="!assetStore.selectedAsset?.schemaVariantId"
label="Attach Function"
label="Attach"
@selected-attach-type="openAttachFuncModal"
/>
</SidebarSubpanelTitle>
Expand Down
1 change: 1 addition & 0 deletions app/web/src/components/AssetPalette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
v-tooltip="
'Drag the assets that you wish to include in your application into the canvas to the right.'
"
class="cursor-pointer"
name="question-circle"
/>
</SidebarSubpanelTitle>
Expand Down
90 changes: 35 additions & 55 deletions app/web/src/components/AttributeDebugView.vue
Original file line number Diff line number Diff line change
@@ -1,60 +1,39 @@
<template>
<div class="overflow-x-scroll my-2 p-4 border-opacity-10 border-l-2">
<div class="overflow-hidden my-xs p-xs border-opacity-10 border-l-2">
<dl>
<dt class="uppercase text-xs italic opacity-80">Attribute Value Id</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.valueId }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Type</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.kind ?? "any" }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Set By Function</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.funcName }} {{ data.funcId }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Input</dt>
<dd class="p-2 my-2 border-2 border-opacity-10 overflow-x-scroll">
<pre>{{ data.funcArgs ?? "NULL" }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Input sources</dt>
<dd class="p-2 my-2 border-2 border-opacity-10 overflow-x-scroll">
<ul v-if="data.argSources && Object.keys(data.argSources).length">
<li v-for="[k, v] in Object.entries(data.argSources)" :key="k">
<strong>{{ k }}</strong>
: {{ v ?? "?" }}
</li>
</ul>
<p v-else>No input sources</p>
</dd>
<dt class="uppercase text-xs italic opacity-80">Value</dt>
<dd class="p-2 my-2 border-2 border-opacity-10 overflow-x-scroll">
<pre>{{ data.value ?? "NULL" }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Prototype Id</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.prototypeId }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Prototype Context</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.prototypeContext }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">
Implicit Attribute Value
</dt>
<dd class="p-2 my-2 border-2 border-opacity-10 overflow-x-scroll">
<pre>{{
typeof data.implicitValue === "undefined"
? "none"
: data.implicitValue ?? "NULL"
}}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">
Implicit Set By Function
</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ data.implicitFuncName }} </pre>
</dd>
<DebugViewItem title="Attribute Value Id" :data="data.valueId" />
<DebugViewItem :data="data.kind ?? 'any'" title="Type" />
<DebugViewItem
:data="`${data.funcName} ${data.funcId}`"
title="Set By Function"
/>
<DebugViewItem title="Input" :data="data.funcArgs ?? 'NULL'" />
<DebugViewItem title="Input sources">
<template #data>
<ul v-if="data.argSources && Object.keys(data.argSources).length">
<li v-for="[k, v] in Object.entries(data.argSources)" :key="k">
<strong>{{ k }}</strong>
: {{ v ?? "?" }}
</li>
</ul>
<p v-else>No input sources</p>
</template>
</DebugViewItem>
<DebugViewItem title="Value" :data="data.value ?? 'NULL'" />
<DebugViewItem title="Prototype Id" :data="data.prototypeId" />
<DebugViewItem title="Prototype Context" :data="data.prototypeContext" />
<DebugViewItem
title="Implicit Attribute Value"
:data="
typeof data.implicitValue === 'undefined'
? 'none'
: data.implicitValue ?? 'NULL'
"
/>
<DebugViewItem
title="Implicit Set By Function"
:data="data.implicitFuncName"
/>
<p class="text-2xs p-2 my-2 border-2 border-opacity-10">
prototype in change set?
{{ data.prototypeInChangeSet ? "y" : "n" }} value in change set?
Expand All @@ -66,6 +45,7 @@
<script setup lang="ts">
import { AttributeDebugData } from "@/store/components.store";
import DebugViewItem from "./DebugViewItem.vue";
defineProps<{ data: AttributeDebugData }>();
</script>
23 changes: 14 additions & 9 deletions app/web/src/components/ComponentDebugDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
</template>
<template v-else-if="fetchDebugReqStatus.isSuccess && debugData">
<div class="border border-neutral-500 m-xs">
<!-- Component -->
<Collapsible label="Component" defaultOpen textSize="lg">
<dl class="border-l-2 p-2">
<dt class="uppercase text-xs italic opacity-80">Id</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ componentId }}</pre>
</dd>
<dt class="uppercase text-xs italic opacity-80">Variant Id</dt>
<dd class="p-2 my-2 border-2 border-opacity-10">
<pre>{{ debugData.schemaVariantId }}</pre>
</dd>
<dl class="border-l-2 p-xs">
<DebugViewItem title="Id" :data="componentId" />
<DebugViewItem
title="Variant Id"
:data="debugData.schemaVariantId"
/>
</dl>
</Collapsible>

<!-- Attributes -->
<Collapsible
label="Attributes"
:defaultOpen="false"
Expand All @@ -39,6 +39,8 @@
<AttributeDebugView :data="attribute.debugData" />
</Collapsible>
</Collapsible>

<!-- Input Sockets -->
<Collapsible
label="Input Sockets"
:defaultOpen="false"
Expand All @@ -56,6 +58,8 @@
<AttributeDebugView :data="attribute.debugData" />
</Collapsible>
</Collapsible>

<!-- Output Sockets -->
<Collapsible
label="Output Sockets"
:defaultOpen="false"
Expand Down Expand Up @@ -87,6 +91,7 @@ import {
import { PropType, computed, onMounted } from "vue";
import { ComponentId, useComponentsStore } from "@/store/components.store";
import AttributeDebugView from "./AttributeDebugView.vue";
import DebugViewItem from "./DebugViewItem.vue";
const componentsStore = useComponentsStore();
Expand Down
48 changes: 5 additions & 43 deletions app/web/src/components/ComponentDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,27 +91,7 @@
<AttributesPanel />
</TabGroupItem>
<TabGroupItem label="Code" slug="code">
<template v-if="codeReqStatus.isPending">
Loading code...</template
>
<template v-else-if="codeReqStatus.isError">
<ErrorMessage :requestStatus="codeReqStatus" />
</template>
<template
v-else-if="codeReqStatus.isSuccess && selectedComponentCode"
>
<div class="absolute inset-xs">
<ErrorMessage
v-if="selectedComponentCode[0]?.message"
class="mx-1 mb-2"
>
{{ selectedComponentCode[0]?.message }}
</ErrorMessage>
<CodeViewer
:code="formattedCode || '#No code generated yet'"
/>
</div>
</template>
<ComponentDetailsCode />
</TabGroupItem>
<TabGroupItem slug="qualifications">
<template #label>
Expand Down Expand Up @@ -177,7 +157,7 @@

<script lang="ts" setup>
import * as _ from "lodash-es";
import { computed, onBeforeMount, ref, watch } from "vue";
import { computed, watch, onBeforeMount, ref } from "vue";
import {
Icon,
ErrorMessage,
Expand All @@ -192,7 +172,6 @@ import {
import { useComponentsStore } from "@/store/components.store";
import { useStatusStore } from "@/store/status.store";
import { useChangeSetsStore } from "@/store/change_sets.store";
import CodeViewer from "@/components/CodeViewer.vue";
import { useQualificationsStore } from "@/store/qualifications.store";
import { useActionsStore } from "@/store/actions.store";
import ComponentCard from "./ComponentCard.vue";
Expand All @@ -205,6 +184,9 @@ import SidebarSubpanelTitle from "./SidebarSubpanelTitle.vue";
import AssetDiffDetails from "./AssetDiffDetails.vue";
import StatusIndicatorIcon from "./StatusIndicatorIcon.vue";
import AttributesPanel from "./AttributesPanel/AttributesPanel.vue";
import ComponentDetailsCode from "./ComponentDetailsCode.vue";
const emit = defineEmits(["delete", "restore"]);
const componentsStore = useComponentsStore();
const qualificationsStore = useQualificationsStore();
Expand Down Expand Up @@ -232,21 +214,6 @@ const selectedComponentFailingQualificationsCount = computed(
]?.failed || 0,
);
const selectedComponentCode = computed(
() => componentsStore.selectedComponentCode,
);
const formattedCode = computed(() => {
const compCode = componentsStore.selectedComponentCode;
if (compCode && compCode.length > 0) {
if (compCode[0]?.language === "json") {
return JSON.stringify(JSON.parse(compCode[0]?.code || ""), null, 2);
}
return compCode[0]?.code;
}
return "# No code generated yet";
});
const selectedComponentActionsCount = computed(() => {
return _.filter(
actionsStore.actionsByComponentId[selectedComponentId.value],
Expand All @@ -265,11 +232,6 @@ onBeforeMount(() => {
}
});
const codeReqStatus = componentsStore.getRequestStatus(
"FETCH_COMPONENT_CODE",
selectedComponentId,
);
const statusStore = useStatusStore();
const currentStatus = computed(() =>
selectedComponentId.value
Expand Down
57 changes: 57 additions & 0 deletions app/web/src/components/ComponentDetailsCode.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<div>
<template v-if="codeReqStatus.isPending"> Loading code...</template>
<template v-else-if="codeReqStatus.isError">
<ErrorMessage :requestStatus="codeReqStatus" />
</template>
<template v-else-if="codeReqStatus.isSuccess && selectedComponentCode">
<div v-if="selectedComponentCode[0]?.code" class="absolute inset-xs">
<template v-for="(item, index) in selectedComponentCode" :key="index">
<div v-if="item.code || item.message" class="pb-md">
<div
v-if="selectedComponentCode.length > 1"
class="text-lg font-bold pb-xs px-xs"
>
Code Output {{ index + 1 }}:
</div>
<ErrorMessage v-if="item.message" class="mx-1 mb-2">
{{ item.message }}
</ErrorMessage>
<div class="relative">
<CodeViewer v-if="item.code" :code="item.code" />
</div>
</div>
</template>
</div>
<div
v-else
class="flex flex-row items-center justify-center p-md text-lg italic text-neutral-500 dark:text-neutral-400"
>
No code generated yet
</div>
</template>
</div>
</template>

<script lang="ts" setup>
import { computed } from "vue";
import { ErrorMessage } from "@si/vue-lib/design-system";
import { useComponentsStore } from "@/store/components.store";
import CodeViewer from "./CodeViewer.vue";
const componentsStore = useComponentsStore();
const selectedComponentId = computed(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
() => componentsStore.selectedComponentId!,
);
const codeReqStatus = componentsStore.getRequestStatus(
"FETCH_COMPONENT_CODE",
selectedComponentId,
);
const selectedComponentCode = computed(
() => componentsStore.selectedComponentCode,
);
</script>
11 changes: 6 additions & 5 deletions app/web/src/components/ComponentDetailsResource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
</div>
</template>
</CodeViewer>
<div
v-else
class="w-full text-center text-lg mt-5 dark:text-neutral-50 text-neutral-900"
>
This component does not have a resource associated with it yet
<div v-else class="flex flex-col items-center p-sm">
<div class="w-64"><EmptyStateIcon name="no-changes" /></div>
<div class="w-full text-center text-xl text-neutral-400">
This component does not have a resource associated with it yet
</div>
</div>
</div>
</template>
Expand All @@ -66,6 +66,7 @@ import { useComponentsStore } from "@/store/components.store";
import CodeViewer from "./CodeViewer.vue";
import FixDetails from "./FixDetails.vue";
import StatusIndicatorIcon from "./StatusIndicatorIcon.vue";
import EmptyStateIcon from "./EmptyStateIcon.vue";
const componentsStore = useComponentsStore();
const selectedComponent = computed(() => componentsStore.selectedComponent);
Expand Down
24 changes: 24 additions & 0 deletions app/web/src/components/DebugViewItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div>
<dt class="uppercase text-xs italic opacity-80">
<template v-if="title">{{ title }}</template>
<slot v-else name="title" />
</dt>
<dd class="p-2 my-2 border-2 border-opacity-10 overflow-x-auto text-xs">
<pre><template v-if="data">{{ data }}</template><slot v-else name="data" /></pre>
</dd>
</div>
</template>

<script lang="ts" setup>
import { PropType } from "vue";
defineProps({
data: {
type: [Object, String, Number, Boolean, null] as PropType<
object | string | number | boolean | null
>,
},
title: { type: String },
});
</script>
Loading

0 comments on commit 9e62996

Please sign in to comment.