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

chore: Visual changes for core navigation elements on IDE #37880

Merged
merged 28 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ef1a8b6
chore: Visual changes for core navigation elements on IDE
hetunandu Dec 2, 2024
d0c3ad1
chore: Segmented Header changes
hetunandu Dec 2, 2024
b097fe8
chore: Improve color usage
hetunandu Dec 2, 2024
118f33f
chore: Add tooltip for datasources
hetunandu Dec 2, 2024
4dfab3d
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 2, 2024
5a27ec0
chore: data label and segment hover
hetunandu Dec 2, 2024
6bdd242
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 3, 2024
f1e832e
fix: Conflict override change
hetunandu Dec 3, 2024
808f0f5
yo
hetunandu Dec 3, 2024
977714c
fix selector
hetunandu Dec 3, 2024
3b341e5
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 3, 2024
dd75d92
Discard changes to app/client/cypress/support/Pages/IDE/Bottompane/Re…
hetunandu Dec 4, 2024
660f39c
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 4, 2024
167df2d
Merge branch 'chore/visual-changes-navigation' of github.com:/appsmit…
hetunandu Dec 4, 2024
8df1849
fix: Segmented header icon and hover
hetunandu Dec 4, 2024
5482fa0
chore: Remove one click binding
hetunandu Dec 4, 2024
64fdba1
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 4, 2024
1f57fea
Revert "chore: Remove one click binding"
hetunandu Dec 18, 2024
b8381a8
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 18, 2024
45d12ff
add icons
hetunandu Dec 18, 2024
56fddd3
chore: Add testId field
hetunandu Dec 18, 2024
06fadfa
chore: Update button selector
hetunandu Dec 18, 2024
66e4e06
fix: styles
hetunandu Dec 18, 2024
163b868
chore: Correct fix for selector
hetunandu Dec 18, 2024
4312fc1
chore: Address review comment
hetunandu Dec 18, 2024
065d489
chore: Add bold selected segment
hetunandu Dec 18, 2024
cec1885
Merge branch 'release' into chore/visual-changes-navigation
hetunandu Dec 19, 2024
a94e072
chore: Apply bold styles on the segment itself
hetunandu Dec 19, 2024
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
4 changes: 3 additions & 1 deletion app/client/cypress/support/Pages/EditorNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import { LeftPane } from "./IDE/LeftPane";
import PageList from "./PageList";

export enum AppSidebarButton {
Data = "Data",
Data = "Datasources",
Editor = "Editor",
Libraries = "Libraries",
Settings = "Settings",
}

export const AppSidebar = new Sidebar(Object.values(AppSidebarButton));

export enum PagePaneSegment {
Expand Down Expand Up @@ -42,6 +43,7 @@ export enum EntityType {
JSObject = "JSObject",
Page = "Page",
}

class EditorNavigation {
public locators = {
MaximizeBtn: "[data-testid='t--ide-maximize']",
Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/support/Pages/IDE/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export class Sidebar {
buttons: string[];
locators = {
sidebar: ".t--sidebar",
sidebarButton: (name: string) => `.t--sidebar-${name}`,
sidebarButton: (name: string) => `[data-testid='t--sidebar-${name}']`,
};

constructor(buttons: string[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ export const StyledSegment = styled.span`
& > * {
color: var(--ads-v2-colors-control-segment-value-default-fg);
}

&[data-selected="true"] {
span {
font-weight: var(--ads-v2-font-weight-bold);
}
}
`;

export const StyledControlContainer = styled.div`
Expand Down Expand Up @@ -81,6 +87,7 @@ export const StyledControlContainer = styled.div`

/* Select all segments which is not a selected and last child */
/* seperator */

&:not(:hover):not(:last-child):not([data-selected="true"]):not(
:has(+ [data-selected="true"])
):after {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/client/src/IDE/Components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function IDESidebar(props: IDESidebarProps) {
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
Expand All @@ -58,6 +59,7 @@ function IDESidebar(props: IDESidebarProps) {
key={button.state}
onClick={onClick}
selected={editorState === button.state}
testId={button.testId}
title={button.title}
tooltip={button.tooltip}
urlSuffix={button.urlSuffix}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ const sidebarButtonProps: SidebarButtonProps = {
selected: false,
title: "Test",
urlSuffix: "/test",
testId: "testId",
};

describe("SidebarButton", () => {
it("should render the button with the correct test id", () => {
const { getByTestId } = render(<SidebarButton {...sidebarButtonProps} />);

expect(getByTestId("t--sidebar-testId")).toBeDefined();
});

it("should render the warning icon in case the datasource list is empty", () => {
const withWarningCondition = {
...sidebarButtonProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ConditionConfig: Record<Condition, { icon: string; color: string }> = {

export interface SidebarButtonProps {
title?: string;
testId: string;
selected: boolean;
icon: string;
onClick: (urlSuffix: string) => void;
Expand All @@ -33,10 +34,8 @@ const Container = styled(Flex)`
padding: 8px 0;
`;

const IconContainer = styled.div<{ selected: boolean }>`
const IconContainer = styled.div`
padding: 2px;
background-color: ${(props) =>
props.selected ? "var(--colors-raw-orange-100, #fbe6dc)" : "white"};
border-radius: 3px;
width: 32px;
height: 32px;
Expand All @@ -46,11 +45,16 @@ const IconContainer = styled.div<{ selected: boolean }>`
cursor: pointer;
position: relative;

&:hover {
background: ${(props) =>
props.selected
? "var(--colors-raw-orange-100, #fbe6dc)"
: "var(--ads-v2-color-bg-subtle, #f1f5f9);"};
&[data-selected="false"] {
background-color: var(--ads-v2-color-bg);

&:hover {
background-color: var(--ads-v2-color-bg-subtle, #f1f5f9);
}
}

&[data-selected="true"] {
background-color: var(--ads-v2-color-bg-muted);
}
`;

Expand Down Expand Up @@ -85,9 +89,9 @@ function SidebarButton(props: SidebarButtonProps) {
<IconContainer
className={`t--sidebar-${title || tooltip}`}
data-selected={selected}
data-testid={"t--sidebar-" + props.testId}
onClick={handleOnClick}
role="button"
selected={selected}
>
<Icon name={icon} size="lg" />
{condition && (
Expand Down
14 changes: 9 additions & 5 deletions app/client/src/ce/entities/IDE/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export enum EditorState {
}

export const SidebarTopButtonTitles = {
DATA: "Data",
EDITOR: "Editor",
};

export const SidebarBottomButtonTitles = {
DATA: "Datasources",
SETTINGS: "Settings",
LIBRARIES: "Libraries",
};
Expand All @@ -62,27 +62,31 @@ export const TopButtons: IDESidebarButton[] = [
state: EditorState.EDITOR,
icon: "editor-v3",
title: SidebarTopButtonTitles.EDITOR,
testId: SidebarTopButtonTitles.EDITOR,
urlSuffix: "",
},
];

export const BottomButtons: IDESidebarButton[] = [
{
state: EditorState.DATA,
icon: "datasource-v3",
title: SidebarTopButtonTitles.DATA,
tooltip: SidebarBottomButtonTitles.DATA,
testId: SidebarBottomButtonTitles.DATA,
urlSuffix: "datasource",
},
];

export const BottomButtons: IDESidebarButton[] = [
{
state: EditorState.LIBRARIES,
icon: "packages-v3",
tooltip: SidebarBottomButtonTitles.LIBRARIES,
testId: SidebarBottomButtonTitles.LIBRARIES,
urlSuffix: "libraries",
},
{
state: EditorState.SETTINGS,
icon: "settings-v3",
tooltip: SidebarBottomButtonTitles.SETTINGS,
testId: SidebarBottomButtonTitles.SETTINGS,
urlSuffix: "settings",
},
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import { createMessage, EDITOR_PANE_TEXTS } from "ee/constants/messages";
import { EditorEntityTab } from "ee/entities/IDE/constants";
import { useCurrentEditorState, useSegmentNavigation } from "../../hooks";
Expand All @@ -8,23 +8,30 @@ const SegmentSwitcher = () => {
const { segment } = useCurrentEditorState();
const { onSegmentChange } = useSegmentNavigation();

const segmentOptions = useMemo(() => {
return [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this could just be moved to constants.

{
label: createMessage(EDITOR_PANE_TEXTS.queries_tab),
startIcon: "queries-line",
value: EditorEntityTab.QUERIES,
},
{
label: createMessage(EDITOR_PANE_TEXTS.js_tab),
startIcon: "content-type-json",
value: EditorEntityTab.JS,
},
{
label: createMessage(EDITOR_PANE_TEXTS.ui_tab),
startIcon: "dashboard-line",
value: EditorEntityTab.UI,
},
];
}, []);

return (
<EditorSegments
onSegmentChange={onSegmentChange}
options={[
{
label: createMessage(EDITOR_PANE_TEXTS.queries_tab),
value: EditorEntityTab.QUERIES,
},
{
label: createMessage(EDITOR_PANE_TEXTS.js_tab),
value: EditorEntityTab.JS,
},
{
label: createMessage(EDITOR_PANE_TEXTS.ui_tab),
value: EditorEntityTab.UI,
},
]}
options={segmentOptions}
selectedSegment={segment}
/>
);
Expand Down
12 changes: 6 additions & 6 deletions app/client/src/pages/Editor/IDE/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function Sidebar() {
const datasources = useSelector(getDatasources);
const datasourcesExist = datasources.length > 0;

// Updates the top button config based on datasource existence
const topButtons = React.useMemo(() => {
// Updates the bottom button config based on datasource existence
const bottomButtons = React.useMemo(() => {
return datasourcesExist
? TopButtons
: TopButtons.map((button) => {
? BottomButtons
: BottomButtons.map((button) => {
if (button.state === EditorState.DATA) {
return {
...button,
Expand Down Expand Up @@ -64,11 +64,11 @@ function Sidebar() {

return (
<IDESidebar
bottomButtons={BottomButtons}
bottomButtons={bottomButtons}
editorState={appState}
id={"t--app-sidebar"}
onClick={onClick}
topButtons={topButtons}
topButtons={TopButtons}
/>
);
}
Expand Down
Loading