Skip to content

Commit 95c60ba

Browse files
fix: Hide debugger errors until onPageLoadActions are run (#6786)
1 parent 0b1e426 commit 95c60ba

File tree

15 files changed

+76
-21
lines changed

15 files changed

+76
-21
lines changed

app/client/cypress/fixtures/debuggerTableDsl.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
"parentId": "0",
3737
"widgetId": "7miqot30xy",
3838
"dynamicBindingPathList": []
39+
},
40+
{
41+
"isVisible": true,
42+
"text": "{{test}}",
43+
"buttonStyle": "PRIMARY_BUTTON",
44+
"widgetName": "Button1",
45+
"isDisabled": false,
46+
"isDefaultClickDisabled": true,
47+
"type": "BUTTON_WIDGET",
48+
"isLoading": false,
49+
"parentColumnSpace": 74,
50+
"parentRowSpace": 40,
51+
"leftColumn": 5,
52+
"rightColumn": 7,
53+
"topRow": 2,
54+
"bottomRow": 3,
55+
"parentId": "0",
56+
"widgetId": "3qg87le9t4"
3957
}
4058
]
4159
}

app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Debugger/PageOnLoad_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ describe("Check debugger logs state when there are onPageLoad actions", function
1818
cy.get(explorer.addWidget).click();
1919

2020
cy.reload();
21+
// Wait for the debugger icon to be visible
22+
cy.get(".t--debugger").should("be.visible");
2123
cy.get(debuggerLocators.errorCount).should("not.exist");
24+
cy.wait("@postExecute");
25+
cy.contains(debuggerLocators.errorCount, 1);
2226
});
2327
});

app/client/src/actions/debuggerActions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ export const logDebuggerErrorAnalytics = (
6868
type: ReduxActionTypes.DEBUGGER_ERROR_ANALYTICS,
6969
payload,
7070
});
71+
72+
export const hideDebuggerErrors = (payload: boolean) => ({
73+
type: ReduxActionTypes.HIDE_DEBUGGER_ERRORS,
74+
payload,
75+
});

app/client/src/components/editorComponents/Debugger/Errors.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect } from "react";
22
import { useSelector } from "react-redux";
33
import styled from "styled-components";
4-
import { getDebuggerErrors } from "selectors/debuggerSelectors";
4+
import { getFilteredErrors } from "selectors/debuggerSelectors";
55
import LogItem, { getLogItemProps } from "./LogItem";
66
import { BlankState } from "./helpers";
77
import { createMessage, NO_ERRORS } from "constants/messages";
@@ -19,7 +19,7 @@ const ListWrapper = styled.div`
1919
`;
2020

2121
function Errors(props: { hasShortCut?: boolean }) {
22-
const errors = useSelector(getDebuggerErrors);
22+
const errors = useSelector(getFilteredErrors);
2323
const currentUser = useSelector(getCurrentUser);
2424

2525
useEffect(() => {

app/client/src/components/editorComponents/Debugger/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
} from "./helpers";
2222
import history from "utils/history";
2323
import { getSelectedWidget } from "selectors/ui";
24-
import { getDebuggerErrors } from "selectors/debuggerSelectors";
24+
import { getFilteredErrors } from "selectors/debuggerSelectors";
2525
import { isEqual, keyBy } from "lodash";
2626
import {
2727
getPluginIcon,
@@ -158,7 +158,7 @@ export const useEntityLink = () => {
158158

159159
export const useGetEntityInfo = (name: string) => {
160160
const entity = useSelector((state: AppState) => state.evaluations.tree[name]);
161-
const debuggerErrors = useSelector(getDebuggerErrors);
161+
const debuggerErrors = useSelector(getFilteredErrors);
162162
const action = useSelector((state: AppState) =>
163163
isAction(entity) ? getAction(state, entity.actionId) : undefined,
164164
);

app/client/src/components/editorComponents/Debugger/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Colors } from "constants/Colors";
1212
import { getTypographyByKey } from "constants/DefaultTheme";
1313
import { Layers } from "constants/Layers";
1414
import { stopEventPropagation } from "utils/AppsmithUtils";
15+
import { getFilteredErrors } from "selectors/debuggerSelectors";
1516

1617
const Container = styled.div<{ errorCount: number }>`
1718
z-index: ${Layers.debugger};
@@ -56,7 +57,7 @@ const Container = styled.div<{ errorCount: number }>`
5657
function Debugger() {
5758
const dispatch = useDispatch();
5859
const errorCount = useSelector(
59-
(state: AppState) => Object.keys(state.ui.debugger.errors).length,
60+
(state: AppState) => Object.keys(getFilteredErrors(state)).length,
6061
);
6162
const showDebugger = useSelector(
6263
(state: AppState) => state.ui.debugger.isOpen,

app/client/src/components/editorComponents/WidgetNameComponent/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { getIsTableFilterPaneVisible } from "selectors/tableFilterSelectors";
1717
import { useWidgetSelection } from "utils/hooks/useWidgetSelection";
1818
import { snipingModeSelector } from "selectors/editorSelectors";
1919
import { bindDataToWidget } from "../../../actions/propertyPaneActions";
20+
import { hideErrors } from "selectors/debuggerSelectors";
2021

2122
const PositionStyle = styled.div<{ topRow: number; isSnipingMode: boolean }>`
2223
position: absolute;
@@ -77,6 +78,8 @@ export function WidgetNameComponent(props: WidgetNameComponentProps) {
7778
(state: AppState) => state.ui.widgetDragResize.isDragging,
7879
);
7980

81+
const shouldHideErrors = useSelector(hideErrors);
82+
8083
const isTableFilterPaneVisible = useSelector(getIsTableFilterPaneVisible);
8184

8285
const togglePropertyEditor = (e: any) => {
@@ -133,7 +136,7 @@ export function WidgetNameComponent(props: WidgetNameComponentProps) {
133136
((focusedWidget === props.widgetId || showAsSelected) &&
134137
!isDragging &&
135138
!isResizing) ||
136-
!!props.errorCount)
139+
(!!props.errorCount && !shouldHideErrors))
137140
);
138141
};
139142

@@ -165,7 +168,7 @@ export function WidgetNameComponent(props: WidgetNameComponentProps) {
165168
<ControlGroup>
166169
<SettingsControl
167170
activity={currentActivity}
168-
errorCount={props.errorCount}
171+
errorCount={shouldHideErrors ? 0 : props.errorCount}
169172
name={props.widgetName}
170173
toggleSettings={togglePropertyEditor}
171174
/>

app/client/src/constants/ReduxActionConstants.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const ReduxActionTypes = {
145145
DEBUGGER_DELETE_ERROR_LOG_INIT: "DEBUGGER_DELETE_ERROR_LOG_INIT",
146146
CLEAR_DEBUGGER_LOGS: "CLEAR_DEBUGGER_LOGS",
147147
SHOW_DEBUGGER: "SHOW_DEBUGGER",
148+
HIDE_DEBUGGER_ERRORS: "HIDE_DEBUGGER_ERRORS",
148149
SET_ACTION_TABS_INITIAL_INDEX: "SET_ACTION_TABS_INITIAL_INDEX",
149150
SET_THEME: "SET_THEME",
150151
FETCH_WIDGET_CARDS: "FETCH_WIDGET_CARDS",

app/client/src/pages/Editor/PropertyPane/PropertyPaneConnections.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
doesEntityHaveErrors,
2121
getDependenciesFromInverseDependencies,
2222
} from "components/editorComponents/Debugger/helpers";
23-
import { getDebuggerErrors } from "selectors/debuggerSelectors";
23+
import { getFilteredErrors } from "selectors/debuggerSelectors";
2424
import { ENTITY_TYPE, Log } from "entities/AppsmithConsole";
2525
import { DebugButton } from "components/editorComponents/Debugger/DebugCTA";
2626
import { showDebugger } from "actions/debuggerActions";
@@ -315,7 +315,7 @@ TriggerNode.displayName = "TriggerNode";
315315
function PropertyPaneConnections(props: PropertyPaneConnectionsProps) {
316316
const dependencies = useDependencyList(props.widgetName);
317317
const { navigateToEntity } = useEntityLink();
318-
const debuggerErrors = useSelector(getDebuggerErrors);
318+
const debuggerErrors = useSelector(getFilteredErrors);
319319

320320
const errorIncomingConnections = useMemo(() => {
321321
return doConnectionsHaveErrors(

app/client/src/reducers/uiReducers/debuggerReducer.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
import { createReducer } from "utils/AppsmithUtils";
2-
import { Log, Severity } from "entities/AppsmithConsole";
2+
import { Log } from "entities/AppsmithConsole";
33
import { ReduxAction, ReduxActionTypes } from "constants/ReduxActionConstants";
44
import { omit, isUndefined } from "lodash";
55

66
const initialState: DebuggerReduxState = {
77
logs: [],
8-
errorCount: 0,
98
isOpen: false,
109
errors: {},
1110
expandId: "",
11+
hideErrors: true,
1212
};
1313

1414
const debuggerReducer = createReducer(initialState, {
1515
[ReduxActionTypes.DEBUGGER_LOG]: (
1616
state: DebuggerReduxState,
1717
action: ReduxAction<Log>,
1818
) => {
19-
const isError = action.payload.severity === Severity.ERROR;
20-
2119
return {
2220
...state,
2321
logs: [...state.logs, action.payload],
24-
errorCount: isError ? state.errorCount + 1 : state.errorCount,
2522
};
2623
},
2724
[ReduxActionTypes.CLEAR_DEBUGGER_LOGS]: (state: DebuggerReduxState) => {
2825
return {
2926
...state,
3027
logs: [],
31-
errorCount: 0,
3228
};
3329
},
3430
[ReduxActionTypes.SHOW_DEBUGGER]: (
@@ -64,6 +60,15 @@ const debuggerReducer = createReducer(initialState, {
6460
errors: omit(state.errors, action.payload),
6561
};
6662
},
63+
[ReduxActionTypes.HIDE_DEBUGGER_ERRORS]: (
64+
state: DebuggerReduxState,
65+
action: ReduxAction<boolean>,
66+
) => {
67+
return {
68+
...state,
69+
hideErrors: action.payload,
70+
};
71+
},
6772
[ReduxActionTypes.INIT_CANVAS_LAYOUT]: () => {
6873
return {
6974
...initialState,
@@ -73,10 +78,10 @@ const debuggerReducer = createReducer(initialState, {
7378

7479
export interface DebuggerReduxState {
7580
logs: Log[];
76-
errorCount: number;
7781
isOpen: boolean;
7882
errors: Record<string, Log>;
7983
expandId: string;
84+
hideErrors: boolean;
8085
}
8186

8287
export default debuggerReducer;

0 commit comments

Comments
 (0)