Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c5540cb

Browse files
Ingress table changes (#221)
* Save updated URLs to project * Combine the ingress route target service and port columns * Cleanup for eslint
1 parent 4538751 commit c5540cb

File tree

6 files changed

+70
-67
lines changed

6 files changed

+70
-67
lines changed

‎electron/app/locales/en/webui.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@
761761
"ingress-design-ingress-route-targetservicenamespace-label": "Target Service Namespace",
762762
"ingress-design-ingress-route-targetservicenamespace-help": "The target service namespace value points to the namespace where the domain is running.",
763763
"ingress-design-ingress-route-accesspoint-label": "Access Point",
764+
"ingress-design-ingress-route-target-label": "Target",
764765
"ingress-design-ingress-route-targetservice-label": "Target Service",
765766
"ingress-design-ingress-route-targetservice-placeholder": "Select Domain Service",
766767
"ingress-design-ingress-route-targetservice-placeholder-empty": "No Domain Services Available",

‎webui/src/js/models/vz-application-definition.js‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66
'use strict';
77

8-
define(['utils/observable-properties', 'utils/validation-helper', 'knockout','utils/wkt-logger'],
9-
function(props, validationHelper,ko) {
8+
define(['utils/observable-properties', 'utils/validation-helper', 'utils/wkt-logger'],
9+
function(props, validationHelper) {
1010
return function (name, k8sDomain) {
1111
function VerrazzanoApplicationModel() {
1212
let componentChanged = false;
@@ -30,10 +30,6 @@ define(['utils/observable-properties', 'utils/validation-helper', 'knockout', 'u
3030
'loggingTraitEnabled', 'loggingTraitImage', 'loggingTraitConfiguration' ];
3131
this.components = props.createListProperty(this.componentKeys).persistByKey('name');
3232

33-
// this is a transient ko observable that is not persisted
34-
this.hosts = ko.observableArray();
35-
this.generatedHost = ko.observable();
36-
3733
this.readFrom = (json) => {
3834
props.createGroup(name, this).readFrom(json);
3935
};

‎webui/src/js/viewModels/ingress-design-view-impl.js‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,10 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
129129
resizable: 'enabled'
130130
},
131131
{
132-
headerText: this.labelMapper('ingress-route-targetservice-label'),
132+
headerText: this.labelMapper('ingress-route-target-label'),
133133
sortProperty: 'targetService',
134134
resizable: 'enabled'
135135
},
136-
{
137-
headerText: this.labelMapper('ingress-route-targetport-label'),
138-
sortProperty: 'targetPort',
139-
resizable: 'enabled'
140-
},
141136
{
142137
headerText: this.labelMapper('ingress-route-accesspoint-label'),
143138
sortProperty: 'targetServiceNameSpace'
@@ -170,6 +165,18 @@ function(i18n, accUtils, ko, ArrayDataProvider, BufferingDataProvider, project,
170165
return 'r' + routeIndex;
171166
}
172167

168+
// display in the target column, example "host:port"
169+
this.getTargetText = (routeData) => {
170+
let result = routeData.targetService;
171+
if(result) {
172+
const port = routeData.targetPort;
173+
if(port != null) {
174+
result += `:${port}`;
175+
}
176+
}
177+
return result;
178+
};
179+
173180
this.handleAddRoute = () => {
174181
const uids = [];
175182
this.routes.observable().forEach(route => {

‎webui/src/js/viewModels/vz-application-design-view.js‎

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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) => {

‎webui/src/js/views/ingress-design-view.html‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,8 @@ <h6 class="wkt-subheading">
203203
<td data-bind="attr: { title: row.data.path }">
204204
<oj-bind-text value="[[row.data.path]]"></oj-bind-text>
205205
</td>
206-
<td data-bind="attr: { title: row.data.targetService }">
207-
<oj-bind-text value="[[row.data.targetService]]"></oj-bind-text>
208-
</td>
209-
<td>
210-
<oj-bind-text value="[[row.data.targetPort]]"></oj-bind-text>
206+
<td data-bind="attr: { title: getTargetText(row.data) }">
207+
<oj-bind-text value="[[getTargetText(row.data)]]"></oj-bind-text>
211208
</td>
212209
<oj-bind-if test="[[!isAccessPointDefined(row.data.accessPoint)]]">
213210
<td>

‎webui/src/js/views/vz-application-design-view.html‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ <h6 slot="header">
136136
<h6 class="wkt-subheading">
137137
<oj-bind-text value="[[labelMapper('ingress-trait-rules-table-title')]]"></oj-bind-text>
138138
</h6>
139-
<oj-button id="updateUrls" chroming="callToAction" on-oj-action="[[updateUrls]]">
139+
<oj-button id="updateUrls" chroming="callToAction"
140+
on-oj-action="[[() => updateUrls(component.data)]]">
140141
<oj-bind-text value="[[labelMapper('ingress-trait-rules-update-urls-button-label')]]"></oj-bind-text>
141142
</oj-button>
142143
</div>
@@ -157,14 +158,14 @@ <h6 class="wkt-subheading">
157158
<td>
158159
<oj-bind-text value="[[getFirstPathText(row.data)]]"></oj-bind-text>
159160
</td>
160-
<td data-bind="attr: { title: computedUrl(row.data) }">
161-
<oj-bind-if test="[[computedCanLink(row.data)]]">
162-
<a data-bind="attr: { href: computedUrl(row.data) }">
163-
<oj-bind-text value="[[computedUrl(row.data)]]"></oj-bind-text>
161+
<td data-bind="attr: { title: row.data.url }">
162+
<oj-bind-if test="[[row.data.canLink]]">
163+
<a data-bind="attr: { href: row.data.url }">
164+
<oj-bind-text value="[[row.data.url]]"></oj-bind-text>
164165
</a>
165166
</oj-bind-if>
166-
<oj-bind-if test="[[!computedCanLink(row.data)()]]">
167-
<oj-bind-text value="[[computedUrl(row.data)]]"></oj-bind-text>
167+
<oj-bind-if test="[[!row.data.canLink]]">
168+
<oj-bind-text value="[[row.data.url]]"></oj-bind-text>
168169
</oj-bind-if>
169170
</td>
170171
<td>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /