Brijesh619 commented on code in PR #728:
URL: https://github.com/apache/atlas/pull/728#discussion_r3923560044
##########
dashboard/src/components/muiComponents.tsx:
##########
@@ -51,6 +52,8 @@ import MuiAccordionSummary, {
AccordionSummaryProps
} from "@mui/material/AccordionSummary";
import MuiAccordionDetails from "@mui/material/AccordionDetails";
+import { TooltipProps } from "@mui/material/Tooltip";
+import { SxProps, Theme } from "@mui/material/styles";
const LightTooltip = styled(({ className, ...props }: any) => (
Review Comment:
Fixed in this commit. Replaced the any type on LightTooltip's props with
TooltipProps (already imported from @mui/material/Tooltip), making it fully
type-safe and consistent with the PR's type-safety refactor goal.
##########
dashboard/src/components/__tests__/muiComponents.test.tsx:
##########
@@ -69,6 +70,100 @@ describe('muiComponents', () => {
expect(screen.getByText('Tooltip Child')).toBeTruthy()
})
+ describe('OverflowTooltip', () => {
+ let triggerResize: any
Review Comment:
Fixed. Replaced triggerResize: any with ResizeObserverCallback | undefined
(the correct built-in DOM type) and updated the constructor parameter and call
sites accordingly.
##########
dashboard/src/views/DashboardOverview/LatestEntitiesList.scss:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.latest-entities-paper {
+ padding: 16px;
+ border-radius: 8px;
+ min-height: 340px;
+ min-width: 0;
+ width: 100%;
+ flex: 1;
+ box-sizing: border-box;
+ transition: box-shadow 0.3s ease;
+
+ &:hover {
+ box-shadow: 0px 2px 4px -1px rgba(0, 0, 0, 0.2), 0px 4px 5px 0px rgba(0,
0, 0, 0.14), 0px 1px 10px 0px rgba(0, 0, 0, 0.12);
+ }
+}
+
+.latest-entities-header {
+ padding-bottom: 16px;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.12);
+}
+
+.latest-entities-title {
+ font-size: 1rem;
+ font-weight: 600;
+ color: rgba(0, 0, 0, 0.87);
+}
+
+.latest-entities-view-all {
+ font-size: 0.875rem;
+ cursor: pointer;
+ text-decoration: none;
+}
+
+.latest-entities-empty {
+ padding-top: 16px;
+}
+
+.latest-entities-list {
+ padding-top: 16px;
+}
+
+.latest-entities-list-item {
+ padding-top: 8px;
+ padding-bottom: 8px;
+ border-bottom: 1px solid rgba(0, 0, 0, 0.12);
+
+ &:last-child {
+ border-bottom: none;
+ }
+}
+
+.latest-entities-entity-name {
+ font-size: 0.875rem;
+}
+
+.latest-entities-entity-name-link {
+ cursor: pointer;
+}
+
+.latest-entities-entity-name-fallback {
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.87);
+}
+
+.latest-entities-type-name {
+ font-size: 0.875rem;
+ color: rgba(0, 0, 0, 0.6);
+}
+
+.latest-entities-timestamp {
+ font-size: 0.8125rem;
+ color: rgba(0, 0, 0, 0.6);
+ flex-shrink: 0;
+ margin-left: 8px;
+ white-space: nowrap;
+}
+
+.latest-entities-name-wrapper {
+ display: block;
+ flex: 0 10 auto;
Review Comment:
Replaced flex: 0 10 auto with the standard flex: 1 1 auto; min-width: 0
pattern and added an inline comment explaining the intent. min-width: 0 is what
enables text truncation inside a flex container — no magic numbers needed.
##########
dashboard/src/components/muiComponents.tsx:
##########
@@ -68,58 +71,94 @@ const LightTooltip = styled(({ className, ...props }: any)
=> (
}
}));
-interface ButtonProps {
- children?: any;
- variant?: string;
- color: string;
- onClick: any;
- sx?: any;
- size?: string;
- endIcon?: any;
- startIcon?: any;
- className?: string;
- disabled?: boolean;
+
+interface OverflowTooltipProps extends Omit<TooltipProps, "children"> {
+ children: React.ReactElement;
+ wrapperSx?: SxProps<Theme>;
+ wrapperClassName?: string;
}
+const OverflowTooltip = ({ title, children, wrapperSx, wrapperClassName,
...props }: OverflowTooltipProps) => {
+ const textElementRef = React.useRef<HTMLElement>(null);
+ const [isOverflowed, setIsOverflowed] = React.useState(false);
+
+ const checkOverflow = React.useCallback(() => {
+ if (textElementRef.current) {
+ const el = textElementRef.current;
+ setIsOverflowed(
+ el.scrollWidth > el.clientWidth ||
+ el.scrollWidth > el.getBoundingClientRect().width
+ );
+ }
+ }, []);
+
+ React.useEffect(() => {
Review Comment:
Acknowledged with an inline comment. The per-instance ResizeObserver is
intentional and fine for the current use (≤7 rows in the dashboard widget).
Added a note documenting the trade-off and the recommended approach (shared
observer via context) if this component is ever reused in large virtualized
lists.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]