Skip to content

Commit

Permalink
Merge pull request #5231 from systeminit/brit/support-documentation-f…
Browse files Browse the repository at this point in the history
…or-props

fix(dal): When creating props, include documentation if it exists
  • Loading branch information
stack72 authored Jan 13, 2025
2 parents 967b60c + d740d48 commit f348981
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 3 deletions.
5 changes: 5 additions & 0 deletions app/web/src/components/AttributesPanel/TreeFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@
name="nested-arrow-right"
size="none"
/>
<!-- todo: Brit/Wendy: Need to truncate if it's too long, add an ability to pop a modal,
and ensure this works if the prop is a header and has documentation -->
<div
v-tooltip="propDocumentation"
:title="`${propLabelParts[0]}${propLabelParts[1]}`"
class="cursor-default shrink truncate py-2xs px-0 [&_i]:opacity-50"
>
Expand Down Expand Up @@ -944,6 +947,7 @@ export type TreeFormProp = {
widgetKind: PropertyEditorPropWidgetKind;
isHidden: boolean;
isReadonly: boolean;
documentation?: string;
};
export type TreeFormData = {
Expand Down Expand Up @@ -1058,6 +1062,7 @@ const widgetOptions = computed(
() => (fullPropDef.value.widgetKind as any).options,
);
const propName = computed(() => fullPropDef.value.name);
const propDocumentation = computed(() => fullPropDef.value.documentation);
const propLabelParts = computed(() => {
if (isChildOfArray.value)
return [`${propName.value}[${props.treeDef.arrayIndex}]`];
Expand Down
2 changes: 2 additions & 0 deletions lib/dal/src/pkg/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,6 +1628,7 @@ async fn create_dal_prop(
kind,
data.hidden,
data.doc_link.as_ref().map(|l| l.to_string()),
data.documentation.clone(),
Some(((&data.widget_kind).into(), data.widget_options.to_owned())),
data.validation_format.clone(),
parent_info.prop_id,
Expand All @@ -1640,6 +1641,7 @@ async fn create_dal_prop(
kind,
data.hidden,
data.doc_link.as_ref().map(|l| l.to_string()),
data.documentation.clone(),
Some(((&data.widget_kind).into(), data.widget_options.to_owned())),
data.validation_format.clone(),
schema_variant_id,
Expand Down
9 changes: 8 additions & 1 deletion lib/dal/src/prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ impl Prop {
None,
None,
None,
None,
parent_prop_id,
)
.await
Expand All @@ -420,6 +421,7 @@ impl Prop {
kind: PropKind,
hidden: bool,
doc_link: Option<String>,
documentation: Option<String>,
widget_kind_and_options: Option<(WidgetKind, Option<Value>)>,
validation_format: Option<String>,
parent_prop_id: PropId,
Expand All @@ -430,6 +432,7 @@ impl Prop {
kind,
hidden,
doc_link,
documentation,
widget_kind_and_options,
validation_format,
)
Expand All @@ -449,6 +452,7 @@ impl Prop {
kind: PropKind,
hidden: bool,
doc_link: Option<String>,
documentation: Option<String>,
widget_kind_and_options: Option<(WidgetKind, Option<Value>)>,
validation_format: Option<String>,
schema_variant_id: SchemaVariantId,
Expand All @@ -459,6 +463,7 @@ impl Prop {
kind,
hidden,
doc_link,
documentation,
widget_kind_and_options,
validation_format,
)
Expand All @@ -481,12 +486,14 @@ impl Prop {
///
/// A corresponding [`AttributePrototype`] and [`AttributeValue`] will be created when the
/// provided [`SchemaVariant`] is [`finalized`](SchemaVariant::finalize).
#[allow(clippy::too_many_arguments)]
async fn new_inner(
ctx: &DalContext,
name: impl Into<String>,
kind: PropKind,
hidden: bool,
doc_link: Option<String>,
documentation: Option<String>,
widget_kind_and_options: Option<(WidgetKind, Option<Value>)>,
validation_format: Option<String>,
) -> PropResult<Self> {
Expand All @@ -513,7 +520,7 @@ impl Prop {
widget_kind,
widget_options,
doc_link,
documentation: None,
documentation,
hidden,
refers_to_prop_id: None,
diff_func_id: None,
Expand Down
16 changes: 16 additions & 0 deletions lib/dal/src/schema/variant/root_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl RootProp {
None,
None,
None,
None,
schema_variant_id,
)
.await?;
Expand Down Expand Up @@ -154,6 +155,7 @@ impl RootProp {
None,
None,
None,
None,
root_prop_id,
)
.await?;
Expand Down Expand Up @@ -191,6 +193,7 @@ impl RootProp {
None,
None,
None,
None,
root_prop_id,
)
.await?;
Expand All @@ -203,6 +206,7 @@ impl RootProp {
None,
None,
None,
None,
leaf_prop.id(),
)
.await?;
Expand Down Expand Up @@ -231,6 +235,7 @@ impl RootProp {
PropKind::String,
false,
None,
None,
Some((
WidgetKind::Select,
Some(serde_json::json!([
Expand Down Expand Up @@ -264,6 +269,7 @@ impl RootProp {
PropKind::String,
false,
None,
None,
Some((WidgetKind::Color, None)),
None,
si_prop.id(),
Expand All @@ -287,6 +293,7 @@ impl RootProp {
None,
None,
None,
None,
root_prop_id,
)
.await?;
Expand All @@ -300,6 +307,7 @@ impl RootProp {
None,
None,
None,
None,
resource_prop.id(),
)
.await?;
Expand All @@ -313,6 +321,7 @@ impl RootProp {
None,
None,
None,
None,
resource_prop.id(),
)
.await?;
Expand All @@ -326,6 +335,7 @@ impl RootProp {
None,
None,
None,
None,
resource_prop.id(),
)
.await?;
Expand All @@ -339,6 +349,7 @@ impl RootProp {
None,
None,
None,
None,
resource_prop.id(),
)
.await?;
Expand All @@ -358,6 +369,7 @@ impl RootProp {
None,
None,
None,
None,
root_prop_id,
)
.await?;
Expand All @@ -377,6 +389,7 @@ impl RootProp {
None,
None,
None,
None,
code_map_item_prop_id,
)
.await?;
Expand All @@ -389,6 +402,7 @@ impl RootProp {
None,
None,
None,
None,
code_map_item_prop_id,
)
.await?;
Expand All @@ -411,6 +425,7 @@ impl RootProp {
None,
None,
None,
None,
qualification_map_item_prop_id,
)
.await?;
Expand All @@ -423,6 +438,7 @@ impl RootProp {
None,
None,
None,
None,
qualification_map_item_prop_id,
)
.await?;
Expand Down
Loading

0 comments on commit f348981

Please sign in to comment.