From 32ed0da447c5b8042541dd83c0d88108226bdbbd Mon Sep 17 00:00:00 2001 From: f0c1s Date: Tue, 4 Oct 2022 16:48:35 +0530 Subject: [PATCH] fix: Rest of the audit logs potential auto-merge errors. (#17192) * fix: EE-CE parity due to audit-logs * fix: rest of the audit-logs potential failures * fix: future conflict with RBAC --- app/client/src/AppRouter.tsx | 28 +++++------ .../CodeEditor/EvaluatedValuePopup.tsx | 46 ++++++++++++++----- app/client/src/entities/FeatureFlags.ts | 2 + app/client/src/pages/Applications/index.tsx | 8 ++-- .../src/pages/Settings/config/advanced.ts | 1 + app/client/src/pages/UserProfile/index.tsx | 3 +- app/client/src/utils/AnalyticsUtil.tsx | 1 + 7 files changed, 59 insertions(+), 30 deletions(-) diff --git a/app/client/src/AppRouter.tsx b/app/client/src/AppRouter.tsx index 7613f4bf9c..44eab475d2 100644 --- a/app/client/src/AppRouter.tsx +++ b/app/client/src/AppRouter.tsx @@ -3,30 +3,30 @@ import history from "utils/history"; import AppHeader from "pages/common/AppHeader"; import { Redirect, Route, Router, Switch } from "react-router-dom"; import { + ADMIN_SETTINGS_CATEGORY_DEFAULT_PATH, + ADMIN_SETTINGS_CATEGORY_PATH, + ADMIN_SETTINGS_PATH, APPLICATIONS_URL, AUTH_LOGIN_URL, BASE_LOGIN_URL, BASE_SIGNUP_URL, BASE_URL, - BUILDER_PATH, BUILDER_CUSTOM_PATH, - WORKSPACE_URL, - SIGN_UP_URL, - SIGNUP_SUCCESS_URL, - USER_AUTH_URL, - USERS_URL, + BUILDER_PATCH_PATH, + BUILDER_PATH, + BUILDER_PATH_DEPRECATED, PROFILE, SETUP, - VIEWER_PATH, - VIEWER_CUSTOM_PATH, - ADMIN_SETTINGS_PATH, - ADMIN_SETTINGS_CATEGORY_PATH, - ADMIN_SETTINGS_CATEGORY_DEFAULT_PATH, - BUILDER_PATH_DEPRECATED, - VIEWER_PATH_DEPRECATED, + SIGNUP_SUCCESS_URL, + SIGN_UP_URL, TEMPLATES_PATH, + USERS_URL, + USER_AUTH_URL, + VIEWER_CUSTOM_PATH, VIEWER_PATCH_PATH, - BUILDER_PATCH_PATH, + VIEWER_PATH, + VIEWER_PATH_DEPRECATED, + WORKSPACE_URL, } from "constants/routes"; import WorkspaceLoader from "pages/workspace/loader"; import ApplicationListLoader from "pages/Applications/loader"; diff --git a/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx b/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx index aa59752453..237e703817 100644 --- a/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/EvaluatedValuePopup.tsx @@ -1,6 +1,6 @@ import React, { memo, useMemo, useRef, useState } from "react"; import styled from "styled-components"; -import _ from "lodash"; +import { isObject, isString } from "lodash"; import equal from "fast-deep-equal/es6"; import Popper from "pages/Editor/Popper"; import ReactJson from "react-json-view"; @@ -10,15 +10,19 @@ import { } from "components/editorComponents/CodeEditor/EditorConfig"; import { theme } from "constants/DefaultTheme"; import { Placement } from "popper.js"; -import { ScrollIndicator } from "design-system"; +import { ScrollIndicator, TooltipComponent as Tooltip } from "design-system"; import { EvaluatedValueDebugButton } from "components/editorComponents/Debugger/DebugCTA"; import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory"; -import { TooltipComponent as Tooltip } from "design-system"; import { Toaster } from "components/ads/Toast"; -import { Classes, Collapse, Button, Icon } from "@blueprintjs/core"; +import { + Button, + Classes, + Collapse, + Icon, + IPopoverSharedProps, +} from "@blueprintjs/core"; import { IconNames } from "@blueprintjs/icons"; import { UNDEFINED_VALIDATION } from "utils/validation/common"; -import { IPopoverSharedProps } from "@blueprintjs/core"; import { ReactComponent as CopyIcon } from "assets/icons/menu/copy-snippet.svg"; import copy from "copy-to-clipboard"; @@ -169,14 +173,17 @@ function CollapseToggle(props: { isOpen: boolean }) { ); } -function copyContent(content: any) { - const stringifiedContent = _.isString(content) +function copyContent( + content: any, + onCopyContentText = `Evaluated value copied to clipboard`, +) { + const stringifiedContent = isString(content) ? content : JSON.stringify(content, null, 2); copy(stringifiedContent); Toaster.show({ - text: `Evaluated value copied to clipboard`, + text: onCopyContentText, variant: Variant.success, }); } @@ -267,7 +274,22 @@ export const CurrentValueViewer = memo( evaluatedValue: any; hideLabel?: boolean; preparedStatementViewer?: boolean; + /** @param {number} [collapseStringsAfterLength=20] + * This collapses the values visible in (say json) after these many characters and shows ellipsis. + */ + collapseStringsAfterLength?: number; + /** @param {string} [onCopyContentText=`Evaluated value copied to clipboard`] + * This parameter contains the string that is shown when the evaluatedValue is copied. + */ + onCopyContentText?: string; }) { + /* Setting the default value for collapseStringsAfterLength to 20; + This ensures that earlier code that depends on the value keeps working. + */ + const collapseStringsAfterLength = props.collapseStringsAfterLength || 20; + /* Setting the default value; ensuring that earlier code keeps working. */ + const onCopyContentText = + props.onCopyContentText || `Evaluated value copied to clipboard`; const codeWrapperRef = React.createRef(); const [openEvaluatedValue, setOpenEvaluatedValue] = useState(true); const toggleEvaluatedValue = () => { @@ -281,7 +303,7 @@ export const CurrentValueViewer = memo( ); if (props.evaluatedValue !== undefined) { if ( - _.isObject(props.evaluatedValue) || + isObject(props.evaluatedValue) || Array.isArray(props.evaluatedValue) ) { if (props.preparedStatementViewer) { @@ -305,7 +327,7 @@ export const CurrentValueViewer = memo( fontSize: "12px", }, collapsed: 2, - collapseStringsAfterLength: 20, + collapseStringsAfterLength, shouldCollapse: (field: any) => { const index = field.name * 1; return index >= 2; @@ -347,7 +369,9 @@ export const CurrentValueViewer = memo( copyContent(props.evaluatedValue)} + onClick={() => + copyContent(props.evaluatedValue, onCopyContentText) + } > diff --git a/app/client/src/entities/FeatureFlags.ts b/app/client/src/entities/FeatureFlags.ts index 6a5d8e44c8..d47041ba4e 100644 --- a/app/client/src/entities/FeatureFlags.ts +++ b/app/client/src/entities/FeatureFlags.ts @@ -5,6 +5,8 @@ type FeatureFlags = { SNIPPET?: boolean; GIT?: boolean; GIT_IMPORT?: boolean; + RBAC?: boolean; + AUDIT_LOGS?: boolean; }; export default FeatureFlags; diff --git a/app/client/src/pages/Applications/index.tsx b/app/client/src/pages/Applications/index.tsx index c27445a85d..301ddc4b79 100644 --- a/app/client/src/pages/Applications/index.tsx +++ b/app/client/src/pages/Applications/index.tsx @@ -55,6 +55,7 @@ import { IconSize, Menu, MenuItem, + notEmptyValidator, Size, Text, TextType, @@ -75,7 +76,6 @@ import EditableText, { EditInteractionKind, SavingState, } from "components/ads/EditableText"; -import { notEmptyValidator } from "design-system"; import { deleteWorkspace, saveWorkspace } from "actions/workspaceActions"; import { leaveWorkspace } from "actions/userActions"; import CenteredWrapper from "components/designSystems/appsmith/CenteredWrapper"; @@ -85,11 +85,11 @@ import { createWorkspaceSubmitHandler } from "@appsmith/pages/workspace/helpers" import ImportApplicationModal from "./ImportApplicationModal"; import { createMessage, - NO_APPS_FOUND, - WORKSPACES_HEADING, - SEARCH_APPS, INVITE_USERS_MESSAGE, INVITE_USERS_PLACEHOLDER, + NO_APPS_FOUND, + SEARCH_APPS, + WORKSPACES_HEADING, } from "@appsmith/constants/messages"; import { ReactComponent as NoAppsFoundIcon } from "assets/svg/no-apps-icon.svg"; diff --git a/app/client/src/pages/Settings/config/advanced.ts b/app/client/src/pages/Settings/config/advanced.ts index 907a1cac01..6f35d80b66 100644 --- a/app/client/src/pages/Settings/config/advanced.ts +++ b/app/client/src/pages/Settings/config/advanced.ts @@ -4,6 +4,7 @@ import { SettingSubtype, SettingTypes, } from "@appsmith/pages/AdminSettings/config/types"; + export const config: AdminConfigType = { type: SettingCategories.ADVANCED, controlType: SettingTypes.GROUP, diff --git a/app/client/src/pages/UserProfile/index.tsx b/app/client/src/pages/UserProfile/index.tsx index 38b4f6046b..a7fe89cde2 100644 --- a/app/client/src/pages/UserProfile/index.tsx +++ b/app/client/src/pages/UserProfile/index.tsx @@ -4,7 +4,6 @@ import styled from "styled-components"; import { TabComponent, TabProp } from "components/ads/Tabs"; import { Text, TextType } from "design-system"; import { Icon } from "@blueprintjs/core"; -// import { Link } from "react-router-dom"; import General from "./General"; import { Colors } from "constants/Colors"; import GitConfig from "./GitConfig"; @@ -23,9 +22,11 @@ const LinkToApplications = styled.div` margin-bottom: 35px; display: inline-block; width: auto; + &:hover { text-decoration: none; } + svg { cursor: pointer; } diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 45f6338c1c..2255efe46f 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -289,6 +289,7 @@ class AnalyticsUtil { static cachedAnonymoustId: string; static cachedUserId: string; static user?: User = undefined; + static initializeSmartLook(id: string) { smartlookClient.init(id); }