FIX-1847 incident page changes with respect to length and width.
This commit is contained in:
1 parent
fe7afab57c
commit
751e83f909
3 files changed
+26
-27
No files matched your search
@@ -158,7 +158,7 @@ Select.propTypes = {
|
|||||||
sx: PropTypes.object,
|
sx: PropTypes.object,
|
||||||
labelControlSpacing: PropTypes.number,
|
labelControlSpacing: PropTypes.number,
|
||||||
truncate: PropTypes.bool, // New prop: enable/disable truncation
|
truncate: PropTypes.bool, // New prop: enable/disable truncation
|
||||||
maxTruncateLength: PropTypes.number, // New prop: configurable length
|
maxTruncateLength: PropTypes.number, // New prop: deafult is 15
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Select;
|
export default Select;
|
||||||
@@ -25,7 +25,6 @@ const OptionsHeader = ({
|
|||||||
direction: "row",
|
direction: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: theme.spacing(6),
|
gap: theme.spacing(6),
|
||||||
marginLeft: "5px",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!shouldRender) return <SkeletonLayout />;
|
if (!shouldRender) return <SkeletonLayout />;
|
||||||
@@ -68,15 +67,10 @@ const OptionsHeader = ({
|
|||||||
sx={{
|
sx={{
|
||||||
ml: "auto",
|
ml: "auto",
|
||||||
alignItems: "stretch",
|
alignItems: "stretch",
|
||||||
"& .MuiButtonBase-root": {
|
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
||||||
whiteSpace: "nowrap",
|
|
||||||
height: "auto",
|
|
||||||
"&.MuiButton-group": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"& .MuiButtonBase-root:hover": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
borderColor: theme.palette.primary.lowContrast,
|
||||||
|
width: "auto",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -115,15 +109,10 @@ const OptionsHeader = ({
|
|||||||
sx={{
|
sx={{
|
||||||
ml: "auto",
|
ml: "auto",
|
||||||
alignItems: "stretch",
|
alignItems: "stretch",
|
||||||
"& .MuiButtonBase-root": {
|
"& .MuiButtonBase-root, & .MuiButtonBase-root:hover": {
|
||||||
whiteSpace: "nowrap",
|
|
||||||
height: "auto",
|
|
||||||
"&.MuiButton-group": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"& .MuiButtonBase-root:hover": {
|
|
||||||
borderColor: theme.palette.primary.lowContrast,
|
borderColor: theme.palette.primary.lowContrast,
|
||||||
|
width: "auto",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,27 +1,37 @@
|
|||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function to render a truncated value with an optional title.
|
* Utility function to render a truncated value with an optional title.
|
||||||
* @param {string} value - The selected value (But this will always come as id).
|
* @param {string} displayName - The name or text to display.
|
||||||
* @param {array} items - The list of items to find the selected value from.
|
|
||||||
* @param {boolean} truncate - Whether to truncate the text or not.
|
* @param {boolean} truncate - Whether to truncate the text or not.
|
||||||
* @param {number} maxLength - The maximum length of the text.
|
* @param {number} maxLength - The maximum length of the text.
|
||||||
* @param {string} placeholder - Placeholder text if no value is selected.
|
* @param {string} placeholder - Placeholder text if no value is provided.
|
||||||
* @returns {JSX.Element} - The JSX element for the rendered value.
|
* @returns {JSX.Element} - The JSX element for the rendered value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const renderTruncatedValue = (displayName, truncate, maxLength, placeholder) => {
|
export const renderTruncatedValue = function (
|
||||||
// If no value or the value is '0', return the placeholder
|
displayName,
|
||||||
|
truncate,
|
||||||
|
maxLength,
|
||||||
|
placeholder
|
||||||
|
) {
|
||||||
if (!displayName || displayName === "0") return placeholder;
|
if (!displayName || displayName === "0") return placeholder;
|
||||||
|
|
||||||
// Function to truncate the text with a dotted end
|
const truncateTextWithDottedEnds = function (text, maxLength) {
|
||||||
const truncateTextWithDottedEnds = (text, maxLength) => {
|
|
||||||
if (!text || text.length <= maxLength) return text;
|
if (!text || text.length <= maxLength) return text;
|
||||||
return `${text.substring(0, maxLength)}...`;
|
return `${text.substring(0, maxLength)}...`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// If truncation is enabled, return the truncated text with a title for full value
|
|
||||||
return truncate ? (
|
return truncate ? (
|
||||||
<span title={displayName}>{truncateTextWithDottedEnds(displayName, maxLength)}</span>
|
<span title={displayName}>{truncateTextWithDottedEnds(displayName, maxLength)}</span>
|
||||||
) : (
|
) : (
|
||||||
displayName
|
<span title={displayName}>{displayName}</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderTruncatedValue.propTypes = {
|
||||||
|
displayName: PropTypes.string, // The name or text to display
|
||||||
|
truncate: PropTypes.bool, // Whether to truncate the text or not
|
||||||
|
maxLength: PropTypes.number, // The maximum length of the text
|
||||||
|
placeholder: PropTypes.string, // Placeholder text if no value is provided
|
||||||
|
};
|
||||||
Reference in new issue
Block a user