File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9393 <input class =" js-bulk-job" name =" jobChecked" type =" checkbox" />
9494 </div >
9595
96- <a role =" button" data-toggle =" collapse" href =" #collapse{{ hashIdAttr this.id }} " >
96+ <a role =" button" data-toggle =" collapse" href =" #collapse{{ hashIdAttr this }} " >
9797 <h4 class =" header-collapse" >
98- <span class =" label label-default" >{{ this.id }} </span >
98+ <span class =" label label-default" >{{ #if this.id }} {{ this.id }} {{ else }} < em >missing id</ em > {{ /if }} </span >
9999 {{ #if this.data.name }}
100100 <span style =" margin-left: 8px" >{{ this.data.name }} </span >
101101 {{ else if this.name}}
102102 <span style =" margin-left: 8px" >{{ this.name }} </span >
103103 {{ /if }}
104104 </h4 >
105105 </a >
106- <div id =" collapse{{ hashIdAttr this.id }} " class =" collapse" >
106+ <div id =" collapse{{ hashIdAttr this }} " class =" collapse" >
107107 {{~> dashboard/jobDetails this basePath =../basePath displayJobInline =true queueName =../queueName queueHost =../queueHost jobState =../state }}
108108 </div >
109109 </li >
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ const replacer = (key, value) => {
1414 }
1515} ;
1616
17+ // For jobs that don't have a valid ID, produce a random ID we can use in its place.
18+ const idMapping = new WeakMap ( ) ;
19+
1720const helpers = {
1821 json ( obj , pretty = false ) {
1922 const args = [ obj , replacer ] ;
@@ -44,8 +47,17 @@ const helpers = {
4447 block . push ( options . fn ( this ) ) ;
4548 } ,
4649
47- hashIdAttr ( id ) {
48- return crypto . createHash ( 'sha256' ) . update ( id ) . digest ( 'hex' ) ;
50+ hashIdAttr ( obj ) {
51+ const { id } = obj ;
52+ if ( typeof id === 'string' ) {
53+ return crypto . createHash ( 'sha256' ) . update ( id ) . digest ( 'hex' ) ;
54+ }
55+ let mapping = idMapping . get ( obj ) ;
56+ if ( ! mapping ) {
57+ mapping = crypto . randomBytes ( 32 ) . toString ( 'hex' ) ;
58+ idMapping . set ( obj , mapping ) ;
59+ }
60+ return mapping ;
4961 } ,
5062} ;
5163
You can’t perform that action at this time.
0 commit comments