Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate in middle for the dropdown of sorting columns in Experiment View #5022

Merged
merged 13 commits into from Nov 10, 2021
Expand Up @@ -373,7 +373,7 @@ span.error-message {
}

.ExperimentView .sort-select {
width: 200px;
width: 350px;
}

.ExperimentView .start-time-select {
Expand Down
Expand Up @@ -720,7 +720,7 @@ export class ExperimentView extends Component {
) : (
<Icon type='arrow-down' />
)}{' '}
{metricKey}
{ExperimentViewUtil.middleTruncateKey(metricKey, 40)}
</Option>,
);
});
Expand All @@ -744,7 +744,7 @@ export class ExperimentView extends Component {
) : (
<Icon type='arrow-down' />
)}{' '}
{paramKey}
{ExperimentViewUtil.middleTruncateKey(paramKey, 40)}
</Option>,
);
});
Expand Down
Expand Up @@ -273,6 +273,20 @@ export default class ExperimentViewUtil {
return keyType + '.`' + keyName + '`';
}

static middleTruncateKey(keyName, maxLen) {
if (keyName.length > maxLen) {
const firstPartLen = Math.floor((maxLen - 3) / 2);
const lastPartLen = maxLen - 3 - firstPartLen;
return (
keyName.substring(0, firstPartLen) +
'...' +
keyName.substring(keyName.length - lastPartLen, keyName.length)
);
} else {
return keyName;
}
}

static getExpanderHeader(cellType) {
const CellComponent = `${cellType}`;
return (
Expand Down