Changes to show multiple messages for a log in the debugger (#5144)

This commit is contained in:
akash-codemonk 2021-06-28 09:44:06 +05:30 committed by GitHub
parent 9ab1113763
commit d4dfa836b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 40 deletions

View File

@ -33,10 +33,10 @@ describe("Binding the multiple input Widget", function() {
.first()
.invoke("attr", "value")
.should("contain", tabValue);
// cy.get(publish.inputWidget + " " + "input")
// .last()
// .invoke("attr", "value")
// .should("contain", tabValue);
// cy.get(publish.inputWidget + " " + "input")
// .last()
// .invoke("attr", "value")
// .should("contain", tabValue);
});
});
});

View File

@ -6,12 +6,12 @@ const widgetsPage = require("../../../../locators/Widgets.json");
const publish = require("../../../../locators/publishWidgetspage.json");
const testdata = require("../../../../fixtures/testdata.json");
describe("aTob and bToa library tests ", function () {
describe("aTob and bToa library tests ", function() {
before(() => {
cy.addDsl(dsl);
});
it("Input widget test with default value for atob method", function () {
it("Input widget test with default value for atob method", function() {
cy.SearchEntityandOpen("Input1");
cy.get(widgetsPage.defaultInput).type(testdata.atobInput);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -22,7 +22,7 @@ describe("aTob and bToa library tests ", function () {
);
});
it("Input widget test with default value for btoa method", function () {
it("Input widget test with default value for btoa method", function() {
cy.SearchEntityandOpen("Input2");
cy.get(widgetsPage.defaultInput).type(testdata.btoaInput);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -33,7 +33,7 @@ describe("aTob and bToa library tests ", function () {
);
});
it("publish widget and validate the data displayed in input widgets value for aToB and bToa", function () {
it("publish widget and validate the data displayed in input widgets value for aToB and bToa", function() {
cy.PublishtheApp();
cy.get(publish.inputWidget + " " + "input")
.first()

View File

@ -6,12 +6,12 @@ const widgetsPage = require("../../../../locators/Widgets.json");
const publish = require("../../../../locators/publishWidgetspage.json");
const testdata = require("../../../../fixtures/testdata.json");
describe("Loadash basic test with input Widget", function () {
describe("Loadash basic test with input Widget", function() {
before(() => {
cy.addDsl(dsl);
});
it("Input widget test with default value from another Input widget", function () {
it("Input widget test with default value from another Input widget", function() {
cy.SearchEntityandOpen("Input1");
cy.get(widgetsPage.defaultInput).type(testdata.defaultInputBinding);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -22,7 +22,7 @@ describe("Loadash basic test with input Widget", function () {
);
});
it("Input widget test with default value for loadash function", function () {
it("Input widget test with default value for loadash function", function() {
cy.SearchEntityandOpen("Input2");
cy.get(widgetsPage.defaultInput).type(testdata.loadashInput);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -33,7 +33,7 @@ describe("Loadash basic test with input Widget", function () {
);
});
it("publish widget and validate the data displayed in input widgets from loadash function", function () {
it("publish widget and validate the data displayed in input widgets from loadash function", function() {
cy.PublishtheApp();
cy.get(publish.inputWidget + " " + "input")
.first()

View File

@ -6,12 +6,12 @@ const widgetsPage = require("../../../../locators/Widgets.json");
const publish = require("../../../../locators/publishWidgetspage.json");
const testdata = require("../../../../fixtures/testdata.json");
describe("Moment basic test with input Widget", function () {
describe("Moment basic test with input Widget", function() {
before(() => {
cy.addDsl(dsl);
});
it("Input widget test with default value from another Input widget", function () {
it("Input widget test with default value from another Input widget", function() {
cy.SearchEntityandOpen("Input1");
cy.get(widgetsPage.defaultInput).type(testdata.defaultInputBinding);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -22,7 +22,7 @@ describe("Moment basic test with input Widget", function () {
);
});
it("Binding second input widget with first input widget and validating", function () {
it("Binding second input widget with first input widget and validating", function() {
cy.SearchEntityandOpen("Input2");
cy.get(widgetsPage.defaultInput).type(testdata.momentInput);
cy.get(commonlocators.editPropCrossButton).click({ force: true });
@ -33,7 +33,7 @@ describe("Moment basic test with input Widget", function () {
);
});
it("publish widget and validate the data displayed in input widgets", function () {
it("publish widget and validate the data displayed in input widgets", function() {
var currentTime = new Date();
cy.PublishtheApp();
cy.get(publish.inputWidget + " " + "input")

View File

@ -112,7 +112,7 @@ describe("Tab widget test", function() {
.should("be.visible");
cy.get(publish.backToEditor).click();
});
/* Test to be revisted as the undo action is inconsistent in automation
/* Test to be revisted as the undo action is inconsistent in automation
it("Tab Widget Functionality To Check undo action after delete", function() {
cy.openPropertyPane("tabswidget");
cy.get(Layoutpage.tabDelete)

View File

@ -5,7 +5,6 @@ import { Message, Severity, SourceEntity } from "entities/AppsmithConsole";
import React, { useCallback, useState } from "react";
import ReactJson from "react-json-view";
import styled from "styled-components";
import { isString } from "lodash";
import EntityLink, { DebuggerLinkUI } from "./EntityLink";
import { SeverityIcon, SeverityIconColor } from "./helpers";
import { useDispatch } from "react-redux";
@ -102,7 +101,7 @@ const Log = styled.div<{ collapsed: boolean }>`
`;
const JsonWrapper = styled.div`
padding-top: 4px;
padding-top: ${(props) => props.theme.spaces[1]}px;
svg {
color: ${(props) => props.theme.colors.debugger.jsonIcon} !important;
height: 12px !important;
@ -139,6 +138,10 @@ const StyledSearchIcon = styled(Icon)`
}
`;
const MessageWrapper = styled.div`
padding-top: ${(props) => props.theme.spaces[1]}px;
`;
export const getLogItemProps = (e: Message) => {
return {
icon: SeverityIcon[e.severity] as IconName,
@ -149,9 +152,9 @@ export const getLogItemProps = (e: Message) => {
timeTaken: e.timeTaken ? `${e.timeTaken}ms` : "",
severity: e.severity,
text: e.text,
message: e.message && isString(e.message) ? e.message : "",
state: e.state,
id: e.source ? e.source.id : undefined,
messages: e.messages,
};
};
@ -163,11 +166,11 @@ type LogItemProps = {
timeTaken: string;
severity: Severity;
text: string;
message: string;
state?: Record<string, any>;
id?: string;
source?: SourceEntity;
expand?: boolean;
messages: Message["messages"];
};
function LogItem(props: LogItemProps) {
@ -182,12 +185,12 @@ function LogItem(props: LogItemProps) {
},
collapsed: 1,
};
const showToggleIcon = props.state || props.message;
const showToggleIcon = props.state || props.messages;
const dispatch = useDispatch();
const openHelpModal = useCallback((e) => {
const openHelpModal = useCallback((e, message?: string) => {
e.stopPropagation();
const text = props.message || props.text;
const text = message || props.text;
AnalyticsUtil.logEvent("OPEN_OMNIBAR", {
source: "DEBUGGER",
@ -196,6 +199,7 @@ function LogItem(props: LogItemProps) {
dispatch(setGlobalSearchQuery(text || ""));
dispatch(toggleShowGlobalSearchModal());
}, []);
const messages = props.messages || [];
return (
<Log
@ -248,13 +252,18 @@ function LogItem(props: LogItemProps) {
{showToggleIcon && (
<StyledCollapse isOpen={isOpen} keepChildrenMounted>
{props.message && (
<div>
<span className="debugger-message" onClick={openHelpModal}>
{props.message}
</span>
</div>
)}
{messages.map((e) => {
return (
<MessageWrapper key={e.message}>
<span
className="debugger-message"
onClick={(event) => openHelpModal(event, e.message)}
>
{e.message}
</span>
</MessageWrapper>
);
})}
{props.state && (
<JsonWrapper
className="t--debugger-log-state"

View File

@ -50,9 +50,14 @@ export interface LogActionPayload {
// What is the log about. Is it a datasource update, widget update, eval error etc.
logType?: LOG_TYPE;
text: string;
// More contextual message
message?: string;
// Time taken for the event to complete
messages?: Array<{
// More contextual message than `text`
message: string;
// The section of code being referred to
// codeSegment?: string;
}>;
timeTaken?: string;
// "where" source entity and propertyPsath.
source?: SourceEntity;

View File

@ -534,7 +534,7 @@ export function* executeActionSaga(
id: actionId,
},
state: response.data?.request ?? null,
message: payload.body as string,
messages: [{ message: payload.body as string }],
});
PerformanceTracker.stopAsyncTracking(
PerformanceTransactionName.EXECUTE_ACTION,
@ -872,9 +872,13 @@ function* runActionSaga(
name: actionObject.name,
id: actionId,
},
message: !isString(payload.body)
? JSON.stringify(payload.body)
: payload.body,
messages: [
{
message: !isString(payload.body)
? JSON.stringify(payload.body)
: payload.body,
},
],
state: response.data?.request ?? null,
});
@ -983,7 +987,7 @@ function* executePageLoadAction(pageAction: PageAction) {
id: pageAction.id,
},
state: response.data?.request ?? null,
message: JSON.stringify(body),
messages: [{ message: JSON.stringify(body) }],
});
yield put(

View File

@ -108,13 +108,17 @@ function getLatestEvalPropertyErrors(
if (evalErrors.length) {
// TODO Rank and set the most critical error
const error = evalErrors[0];
const errorMessages = evalErrors.map((e) => ({
message: e.errorMessage,
}));
// Add or update
updatedDebuggerErrors[debuggerKey] = {
logType: LOG_TYPE.EVAL_ERROR,
text: PropertyEvalErrorTypeDebugMessage[error.errorType](
propertyPath,
),
message: JSON.stringify(error.errorMessage),
messages: errorMessages,
severity: error.severity,
timestamp: moment().format("hh:mm:ss"),
source: {
@ -124,7 +128,7 @@ function getLatestEvalPropertyErrors(
propertyPath: propertyPath,
},
state: {
value: evaluatedValue,
[propertyPath]: evaluatedValue,
},
};
} else if (debuggerKey in updatedDebuggerErrors) {