Skip to content

Commit

Permalink
chore: Move Add button to top (#29863)
Browse files Browse the repository at this point in the history
Moves the add pane to the top

Fixes #29861

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Improved the layout and conditional rendering logic in the editor pane
for enhanced user experience and interface clarity.
- Streamlined button visibility and interaction across various sections
of the IDE, ensuring a more intuitive workflow when adding new elements.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
hetunandu authored Dec 27, 2023
1 parent f266db2 commit 168053b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 48 deletions.
24 changes: 12 additions & 12 deletions app/client/src/pages/Editor/IDE/EditorPane/JS_Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ const JSSection = () => {
flexDirection="column"
overflow="hidden"
>
{JSObjects && JSObjects.length > 0 && canCreateActions && (
<Flex flexDirection="column" padding="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.js_add_button)}
</Button>
</Flex>
)}
<FilesContextProvider
canCreateActions={canCreateActions}
editorId={applicationId}
Expand Down Expand Up @@ -102,18 +114,6 @@ const JSSection = () => {
onClick={canCreateActions ? addButtonClickHandler : undefined}
/>
)}
{JSObjects && JSObjects.length > 0 && canCreateActions && (
<Flex flexDirection="column" padding="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.js_add_button)}
</Button>
</Flex>
)}
</JSContainer>
);
};
Expand Down
40 changes: 19 additions & 21 deletions app/client/src/pages/Editor/IDE/EditorPane/ListQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,25 @@ const ListQuery = () => {
}, [pageId]);

return (
<Flex
flex="1"
flexDirection="column"
gap="spaces-3"
overflow="hidden"
padding="spaces-3"
>
<Flex flexDirection={"column"} gap="spaces-3" overflowY="auto">
<Flex flex="1" flexDirection="column" overflow="hidden">
{Object.keys(files).length > 0 && canCreateActions && (
<Flex flexDirection={"column"} padding="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.query_add_button)}
</Button>
</Flex>
)}
<Flex
flexDirection={"column"}
gap="spaces-3"
overflowY="auto"
padding="spaces-3"
>
{Object.keys(files).map((key) => {
return (
<Flex flexDirection={"column"} gap="spaces-2" key={key}>
Expand Down Expand Up @@ -85,19 +96,6 @@ const ListQuery = () => {
})}
</Flex>

{Object.keys(files).length > 0 && canCreateActions && (
<Flex flexDirection={"column"} paddingBottom="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.query_add_button)}
</Button>
</Flex>
)}

{Object.keys(files).length === 0 && (
<EmptyState
buttonText={createMessage(PAGES_PANE_TEXTS.query_add_button)}
Expand Down
30 changes: 15 additions & 15 deletions app/client/src/pages/Editor/IDE/EditorPane/ListWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ const ListWidgets = () => {

return (
<Flex flexDirection="column" overflow="hidden">
{widgets &&
widgets.children &&
widgets.children.length > 0 &&
canManagePages && (
<Flex flexDirection="column" padding="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.widget_add_button)}
</Button>
</Flex>
)}
<Flex
flex="1"
flexDirection={"column"}
Expand Down Expand Up @@ -77,21 +92,6 @@ const ListWidgets = () => {
onClick={canManagePages ? addButtonClickHandler : undefined}
/>
)}
{widgets &&
widgets.children &&
widgets.children.length > 0 &&
canManagePages && (
<Flex flexDirection="column" padding="spaces-3">
<Button
kind={"secondary"}
onClick={addButtonClickHandler}
size={"sm"}
startIcon={"add-line"}
>
{createMessage(PAGES_PANE_TEXTS.widget_add_button)}
</Button>
</Flex>
)}
</Flex>
);
};
Expand Down

0 comments on commit 168053b

Please sign in to comment.