github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/views/jobs/jobDescriptionCell.tsx (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import React from "react"; 12 import {Link} from "react-router-dom"; 13 import {Tooltip} from "src/components"; 14 import Job = cockroach.server.serverpb.JobsResponse.IJob; 15 import {cockroach} from "src/js/protos"; 16 17 export class JobDescriptionCell extends React.PureComponent<{ job: Job }> { 18 render() { 19 // If a [SQL] job.statement exists, it means that job.description 20 // is a human-readable message. Otherwise job.description is a SQL 21 // statement. 22 const job = this.props.job; 23 const additionalStyle = (job.statement ? "" : " jobs-table__cell--sql"); 24 const description = job.description && job.description.length > 425 ? `${job.description.slice(0, 425)}...` : job.description; 25 return ( 26 <Link className={`${additionalStyle}`} to={`jobs/${String(job.id)}`}> 27 <div className="cl-table-link__tooltip"> 28 <Tooltip 29 arrowPointAtCenter 30 placement="bottom" 31 title={ 32 <pre style={{whiteSpace: "pre-wrap"}} className="cl-table-link__description">{description}</pre> 33 } 34 overlayClassName="cl-table-link__statement-tooltip--fixed-width" 35 > 36 <div className="jobs-table__cell--description">{job.statement || job.description}</div> 37 </Tooltip> 38 </div> 39 </Link> 40 ); 41 } 42 }