pawarprasad123 commented on code in PR #728:
URL: https://github.com/apache/atlas/pull/728#discussion_r3860050595
##########
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:
One ResizeObserver per list row (up to 7) — acceptable for this widget, but
worth noting if reused widely
##########
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:
flex: 0 10 auto is non-standard (flex-shrink: 10). Works but is
magic-number-ish; flex: 1 1 auto; min-width: 0 or a short comment would help
##########
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:
triggerResize: any — prefer typed mock
##########
dashboard/src/views/DashboardOverview/__tests__/LatestEntitiesList.test.tsx:
##########
@@ -185,11 +185,9 @@ describe('LatestEntitiesList', () => {
/>
</MemoryRouter>,
)
- const row = screen.getByText('X').closest('li')
+ const row = screen.getByText('X').closest('li') as HTMLElement
expect(row).toBeTruthy()
- expect(
- within(row as HTMLElement).getByText(/^Created /),
- ).toBeInTheDocument()
+ expect(within(row).getByText(/ago/)).toBeInTheDocument()
Review Comment:
Since "Created " prefix was restored in formatCreatedRelativeFromMs, please
revert weakened assertions back to /^Created / (lines 190, 331, 537, 603) for
stronger regression protection.
##########
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:
LightTooltip still typed as any (pre-existing pattern, but PR claims
type-safety refactor)
PR description mentions type-safety refactor, but LightTooltip still uses
any. Consider typing it as TooltipProps for consistency.
##########
dashboard/src/views/DashboardOverview/LatestEntitiesList.tsx:
##########
@@ -136,6 +138,8 @@ const formatRelativeTime = (raw: unknown): string => {
return formatCreatedRelativeFromMs(ms);
};
+
Review Comment:
Remove extra blank line(s) between formatRelativeTime and the component
definition.
##########
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 {
Review Comment:
.latest-entities-type-name is missing truncation styles (overflow: hidden;
text-overflow: ellipsis; white-space: nowrap; min-width: 0) that were marked
resolved in review. Truncation currently relies only on OverflowTooltip inline
sx. Either add SCSS here for consistency, or document/update pr description
that truncation is intentionally delegated to the wrapper.
##########
dashboard/src/views/DashboardOverview/__tests__/LatestEntitiesList.test.tsx:
##########
@@ -624,4 +622,68 @@ describe('LatestEntitiesList', () => {
)
expect(screen.getByText('Created today')).toBeInTheDocument()
})
+
+ it('renders fallback Typography when detailHref is absent (no guid)',
() => {
+ render(
+ <MemoryRouter>
+ <LatestEntitiesList
+ entities={[
+ {
+ name:
'EntityWithoutGuid',
+ typeName: 'T',
+ attributes: {
__timestamp: Date.now() },
+ },
+ ]}
+ />
+ </MemoryRouter>,
+ )
+ const fallbackText = screen.getByText('EntityWithoutGuid')
+ expect(fallbackText).toBeInTheDocument()
+ expect(fallbackText.tagName).toBe('SPAN')
+
expect(fallbackText).toHaveClass('latest-entities-entity-name-fallback')
+ })
+
+
+ it('renders extremely long entity name without crashing', () => {
+ const longName = 'A'.repeat(500)
+ render(
+ <MemoryRouter>
+ <LatestEntitiesList
+ entities={[
+ {
+ guid: 'g1',
+ name: longName,
+ typeName: 'T',
+ attributes: {
__timestamp: Date.now() },
+ },
+ ]}
+ />
+ </MemoryRouter>,
+ )
+ const link = screen.getByRole('link', { name: longName })
+ expect(link).toBeInTheDocument()
+ expect(link.textContent).toBe(longName)
+
+ const span = link.parentElement
+ expect(span).toHaveStyle('overflow: hidden')
+ expect(span).toHaveStyle('text-overflow: ellipsis')
+ expect(span).toHaveStyle('white-space: nowrap')
+ })
+
+ it('renders gracefully when typeName is missing', () => {
+ render(
+ <MemoryRouter>
+ <LatestEntitiesList
+ entities={[
+ {
+ guid: 'g1',
+ name: 'NamelessType',
+ attributes: {
__timestamp: Date.now() },
+ },
+ ]}
+ />
+ </MemoryRouter>,
+ )
+ expect(screen.getByText('(Entity)')).toBeInTheDocument()
+ })
Review Comment:
Please add a test for extremely long typeName (e.g. 'B'.repeat(300))
asserting:
Row renders without layout break
Type wrapper has truncation styles
Optional: tooltip appears on hover when overflowed
--
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]