@@ -507,57 +507,50 @@ function (project, accUtils, utils, ko, i18n, BufferingDataProvider, ArrayDataPr
507507 return null ;
508508 }
509509
510- this . computedUrl = ( rowData ) => {
511- return ko . computed ( ( ) => {
512- let urlHost = '<host>' ;
513- const generatedHost = project . vzApplication . generatedHost ( ) ;
514- if ( generatedHost && generatedHost . length ) {
515- urlHost = generatedHost ;
516- }
510+ function getUrl ( ruleData , generatedHostname ) {
511+ let urlHost = '<host>' ;
512+ if ( generatedHostname && generatedHostname . length ) {
513+ urlHost = generatedHostname ;
514+ }
517515
518- const ruleHost = getRuleHost ( rowData ) ;
519- if ( ruleHost ) {
520- urlHost = ruleHost ;
521- }
516+ const ruleHost = getRuleHost ( ruleData ) ;
517+ if ( ruleHost ) {
518+ urlHost = ruleHost ;
519+ }
522520
523- let result = 'https://' + urlHost ;
521+ let result = 'https://' + urlHost ;
524522
525- let urlPath = '<path>' ;
526- const paths = rowData . paths ;
527- if ( paths && paths . length ) {
528- urlPath = paths [ 0 ] . path ;
529- if ( urlPath && urlPath . length ) {
530- result += urlPath ;
531- }
523+ let urlPath = '<path>' ;
524+ const paths = ruleData . paths ;
525+ if ( paths && paths . length ) {
526+ urlPath = paths [ 0 ] . path ;
527+ if ( urlPath && urlPath . length ) {
528+ result += urlPath ;
532529 }
530+ }
533531
534- return result ;
535- } ) ;
536- } ;
532+ return result ;
533+ }
537534
538- // resolves to true if the row data can make a clickable link
539- this . computedCanLink = ( rowData ) => {
540- return ko . computed ( ( ) => {
541- const appHosts = project . vzApplication . hosts ( ) ;
542- if ( ! appHosts . length ) {
543- return false ;
544- }
535+ function isLinkable ( ruleData , hostnames ) {
536+ if ( ! hostnames || ! hostnames . length ) {
537+ return false ;
538+ }
545539
546- const ruleHost = getRuleHost ( rowData ) ;
547- if ( ruleHost && ! appHosts . includes ( ruleHost ) ) {
548- return false ;
549- }
540+ const ruleHost = getRuleHost ( ruleData ) ;
541+ if ( ruleHost && ! hostnames . includes ( ruleHost ) ) {
542+ return false ;
543+ }
550544
551- const paths = rowData . paths ;
552- if ( ! paths || ! paths . length ) {
553- return false ;
554- }
545+ const paths = ruleData . paths ;
546+ if ( ! paths || ! paths . length ) {
547+ return false ;
548+ }
555549
556- return paths [ 0 ] . pathType !== 'regex' ;
557- } ) ;
558- } ;
550+ return paths [ 0 ] . pathType !== 'regex' ;
551+ }
559552
560- this . updateUrls = async ( ) => {
553+ this . updateUrls = async ( component ) => {
561554 const busyDialogMessage = this . labelMapper ( 'get-hosts-in-progress' ) ;
562555 dialogHelper . openBusyDialog ( busyDialogMessage , 'bar' , 1 / 2.0 ) ;
563556
@@ -577,8 +570,16 @@ function (project, accUtils, utils, ko, i18n, BufferingDataProvider, ArrayDataPr
577570 return ;
578571 }
579572
580- project . vzApplication . hosts ( hostsResult . hostnames ) ;
581- project . vzApplication . generatedHost ( hostsResult . generatedHostname ) ;
573+ const observableRules = this . componentObservable ( component , 'ingressTraitRules' ) ;
574+ for ( const ruleData of observableRules ( ) ) {
575+ const canLink = isLinkable ( ruleData , hostsResult . hostnames ) ;
576+ const url = getUrl ( ruleData , hostsResult . generatedHostname ) ;
577+ 578+ if ( ( ruleData . url !== url ) || ( ruleData . canLink !== canLink ) ) {
579+ const newData = { ...ruleData , canLink : canLink , url : url } ;
580+ observableRules . replace ( ruleData , newData ) ;
581+ }
582+ }
582583 } ;
583584
584585 this . componentsIngressTraitRulesDataProvider = ( component ) => {
0 commit comments