From 65aea71e37c014c1368f889f221c029225f3a9a8 Mon Sep 17 00:00:00 2001 From: navaneeth Date: Sat, 10 Apr 2021 12:53:51 +0530 Subject: [PATCH] Feature: Show component variables on sidebar --- frontend/src/Editor/Components/components.js | 10 +++ frontend/src/Editor/Editor.jsx | 87 ++++++++++++++++---- 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/frontend/src/Editor/Components/components.js b/frontend/src/Editor/Components/components.js index 448ff8e22a..eba4bae603 100644 --- a/frontend/src/Editor/Components/components.js +++ b/frontend/src/Editor/Components/components.js @@ -20,6 +20,7 @@ export const componentTypes = [ backgroundColor: { type: 'color'}, textColor: { type: 'color'} }, + exposedVariables: {}, definition: { properties: { 'text': { value: 'Button' }, @@ -61,6 +62,9 @@ export const componentTypes = [ styles: { textColor: { type: 'color'} }, + exposedVariables: { + 'selectedRow': {}, + }, definition: { properties: { 'title': { value: 'Table' }, @@ -102,6 +106,7 @@ export const componentTypes = [ styles: { }, + exposedVariables: {}, definition: { properties: { 'placeholder': { value: 'Placeholder text' } @@ -132,6 +137,7 @@ export const componentTypes = [ styles: { }, + exposedVariables: {}, definition: { properties: { 'placeholder': { value: 'Placeholder text' } @@ -163,6 +169,7 @@ export const componentTypes = [ styles: { textColor: { type: 'color'} }, + exposedVariables: {}, definition: { properties: { 'text': { value: 'Text goes here !' }, @@ -195,6 +202,7 @@ export const componentTypes = [ styles: { }, + exposedVariables: {}, definition: { properties: { 'source': { value: 'https://www.svgrepo.com/show/34217/image.svg' }, @@ -224,6 +232,7 @@ export const componentTypes = [ styles: { }, + exposedVariables: {}, definition: { properties: { 'label': { value: 'Select' }, @@ -255,6 +264,7 @@ export const componentTypes = [ styles: { }, + exposedVariables: {}, definition: { properties: { 'label': { value: 'https://www.svgrepo.com/show/46775/drop-down-list.svg' }, diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index 054e31c70f..1ae458d6a7 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -177,6 +177,33 @@ class Editor extends React.Component { }) } + renderComponentVariables = (id, component) => { + const componentType = component.component.component; + const componentMeta = componentTypes.find(comp => componentType === comp.component); + const exposedVariables = Object.keys(componentMeta.exposedVariables); + + return ( +
+ table1 {exposedVariables.length} keys +
+ {exposedVariables.map((variable) => +
+
+ {variable} +
+
+ toast.success('Reference copied to clipboard', { hideProgressBar: true, position: "bottom-center", })}> + + +
+
+ )} +
+
+ ) + } + render() { const { currentSidebarTab, @@ -365,27 +392,53 @@ class Editor extends React.Component {
-
-
-
-
-

- -

-
-
- -
+
+
+
Globals
+
+ currentUser 2 keys +
+
+
+ name +
+
+ toast.success('Reference copied to clipboard', { hideProgressBar: true, position: "bottom-center", })}> + + +
+
+
+
+ email +
+
+ toast.success('Reference copied to clipboard', { hideProgressBar: true, position: "bottom-center", })}> + + +
+
+
+ +
+ +
+
Components
+
+ {appDefinition.components && + <> + {Object.keys(appDefinition.components).map((key => + this.renderComponentVariables(key, appDefinition.components[key]) + ))} + + }
+