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

feat: support swapping direction of truncation on resource names #8671

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface ApplicationDetailsState {
groupedResources?: ResourceStatus[];
slidingPanelPage?: number;
filteredGraph?: any[];
truncateNameOnRight?: boolean;
}

interface FilterInput {
Expand Down Expand Up @@ -69,7 +70,7 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{nam

constructor(props: RouteComponentProps<{name: string}>) {
super(props);
this.state = {page: 0, groupedResources: [], slidingPanelPage: 0, filteredGraph: []};
this.state = {page: 0, groupedResources: [], slidingPanelPage: 0, filteredGraph: [], truncateNameOnRight: false};
}

private get showOperationState() {
Expand Down Expand Up @@ -225,6 +226,9 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{nam
const setFilterGraph = (filterGraph: any[]) => {
this.setState({filteredGraph: filterGraph});
};
const toggleNameDirection = () => {
this.setState({truncateNameOnRight: !this.state.truncateNameOnRight});
};
return (
<div className='application-details'>
<Page
Expand Down Expand Up @@ -289,6 +293,19 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{nam
{((pref.view === 'tree' || pref.view === 'network') && (
<Filters pref={pref} tree={tree} resourceNodes={this.state.filteredGraph} onSetFilter={setFilter} onClearFilter={clearFilter}>
<div className='graph-options-panel'>
<a
className={`group-nodes-button`}
onClick={() => {
toggleNameDirection();
}}
title={this.state.truncateNameOnRight ? 'Truncate resource name right' : 'Truncate resource name left'}>
<i
className={classNames({
'fa fa-align-right': this.state.truncateNameOnRight,
'fa fa-align-left': !this.state.truncateNameOnRight
})}
/>
</a>
{pref.view === 'tree' && (
<a
className={`group-nodes-button group-nodes-button${!pref.groupNodes ? '' : '-on'}`}
Expand Down Expand Up @@ -322,6 +339,7 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{nam
onClearFilter={clearFilter}
onGroupdNodeClick={groupdedNodeIds => openGroupNodeDetails(groupdedNodeIds)}
zoom={pref.zoom}
nameDirection={this.state.truncateNameOnRight}
filters={pref.resourceFilter}
setTreeFilterGraph={setFilterGraph}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,20 @@
}

&__node-content {
padding: 10px;
padding: 10px 20px 10px 10px;
line-height: 0.95;
display: flex;
flex-direction: column;
}

&__node-title {
font-size: 0.8em;
padding-bottom: 5px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: left;

}

&__node-status-icon {
Expand All @@ -182,4 +190,11 @@
margin-right: 2px;
}
}
&__direction-left {
direction: ltl;
}
&__direction-right {
direction: rtl;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface ApplicationResourceTreeProps {
zoom: number;
filters?: string[];
setTreeFilterGraph?: (filterGraph: any[]) => void;
nameDirection: boolean;
}

interface Line {
Expand Down Expand Up @@ -329,7 +330,12 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod
'application-resource-tree__node--orphaned': node.orphaned
})}
title={describeNode(node)}
style={{left: node.x, top: node.y, width: node.width, height: node.height}}>
style={{
left: node.x,
top: node.y,
width: node.width,
height: node.height
}}>
{!appNode && <NodeUpdateAnimation resourceVersion={node.resourceVersion} />}
<div
className={classNames('application-resource-tree__node-kind-icon', {
Expand All @@ -340,9 +346,14 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod
{!rootNode && <div className='application-resource-tree__node-kind'>{ResourceLabel({kind: node.kind})}</div>}
</div>
<div className='application-resource-tree__node-content'>
<span className='application-resource-tree__node-title'>{node.name}</span>
<br />
<span
<div
className={classNames('application-resource-tree__node-title', {
'application-resource-tree__direction-right': props.nameDirection,
'application-resource-tree__direction-left': !props.nameDirection
})}>
{node.name}
</div>
<div
className={classNames('application-resource-tree__node-status-icon', {
'application-resource-tree__node-status-icon--offset': rootNode
})}>
Expand All @@ -359,7 +370,7 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod
</Consumer>
)}
<ApplicationURLs urls={rootNode ? extLinks : node.networkingInfo && node.networkingInfo.externalURLs} />
</span>
</div>
</div>
<div className='application-resource-tree__node-labels'>
{node.createdAt || rootNode ? (
Expand Down