Skip to content

Commit db5dc00

Browse files
authored
Feature/cluster name route update (#414)
* added cluster name to routes to enable switching cluster in future PR * fixing failing test
1 parent b51929e commit db5dc00

File tree

6 files changed

+96
-45
lines changed

6 files changed

+96
-45
lines changed

client/components/workflow-grid.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export default {
8383
:to="{
8484
name: 'workflow/summary',
8585
params: {
86+
clusterName: item.clusterName,
8687
domain: item.domainName,
8788
runId: item.runId,
8889
workflowId: item.workflowId,

client/containers/workflow-list/component.vue

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ import { delay, getEndTimeIsoString, getStartTimeIsoString } from '~helpers';
5555
import { httpService } from '~services';
5656
5757
export default {
58+
name: 'workflow-list',
5859
props: [
60+
'clusterName',
5961
'dateFormat',
6062
'domain',
6163
'fetchWorkflowListUrl',
@@ -145,9 +147,15 @@ export default {
145147
return getEndTimeIsoString(range, endTime);
146148
},
147149
formattedResults() {
148-
const { dateFormat, results, timeFormat, timezone } = this;
149-
150-
return getFormattedResults({ dateFormat, results, timeFormat, timezone });
150+
const { clusterName, dateFormat, results, timeFormat, timezone } = this;
151+
152+
return getFormattedResults({
153+
clusterName,
154+
dateFormat,
155+
results,
156+
timeFormat,
157+
timezone,
158+
});
151159
},
152160
minStartDate() {
153161
return this.getMinStartDate();
@@ -191,6 +199,11 @@ export default {
191199
192200
return getStartTimeIsoString(range, startTime);
193201
},
202+
crossRegionProps() {
203+
const { clusterName, domain } = this;
204+
205+
return { clusterName, domain };
206+
},
194207
},
195208
methods: {
196209
clearState() {
@@ -226,7 +239,10 @@ export default {
226239
this.abortController = new AbortController();
227240
const { signal } = this.abortController;
228241
229-
const request = await httpService.get(url, { query, signal });
242+
const request = await httpService.get(url, {
243+
query,
244+
signal,
245+
});
230246
231247
this.abortController = undefined;
232248
@@ -248,14 +264,18 @@ export default {
248264
249265
return { status: 'success', workflows, nextPageToken };
250266
},
251-
fetchDomain() {
267+
async fetchDomain() {
252268
const { domain, now } = this;
253269
254270
this.loading = true;
255271
256-
return httpService.get(`/api/domains/${domain}`).then(r => {
272+
try {
273+
const domainInfo = await httpService.get(`/api/domains/${domain}`);
274+
257275
this.maxRetentionDays =
258-
Number(r.configuration.workflowExecutionRetentionPeriodInDays) || 30;
276+
Number(
277+
domainInfo.configuration.workflowExecutionRetentionPeriodInDays
278+
) || 30;
259279
this.loading = false;
260280
261281
const minStartDate = this.getMinStartDate();
@@ -274,7 +294,12 @@ export default {
274294
this.setRange(`last-${Math.min(30, this.maxRetentionDays)}-days`);
275295
}
276296
}
277-
});
297+
} catch (error) {
298+
this.error =
299+
(error.json && error.json.message) || error.status || error.message;
300+
} finally {
301+
this.loading = false;
302+
}
278303
},
279304
async fetchWorkflowList() {
280305
if (!this.criteria || this.loading) {
@@ -451,11 +476,9 @@ export default {
451476
this.refreshWorkflows();
452477
}
453478
},
454-
async domain(newDomain, oldDomain) {
455-
if (newDomain && oldDomain && newDomain !== oldDomain) {
456-
await this.fetchDomain();
457-
this.refreshWorkflows();
458-
}
479+
async crossRegionProps() {
480+
await this.fetchDomain();
481+
this.refreshWorkflows();
459482
},
460483
},
461484
};

client/containers/workflow-list/helpers/get-formatted-results.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,18 @@
2222
import { STATUS_OPEN } from '../constants';
2323
import { getDatetimeFormattedString } from '~helpers';
2424

25-
const getFormattedResults = ({ dateFormat, results, timeFormat, timezone }) =>
25+
const getFormattedResults = ({
26+
clusterName,
27+
dateFormat,
28+
results,
29+
timeFormat,
30+
timezone,
31+
}) =>
2632
results.map(result => {
2733
const status = (result.closeStatus || STATUS_OPEN).toLowerCase();
2834

2935
return {
36+
clusterName,
3037
domainName: result.domainName,
3138
endTime: result.closeTime
3239
? getDatetimeFormattedString({

client/main.js

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,52 +100,53 @@ const routeOpts = {
100100
},
101101
{
102102
name: 'domain',
103-
path: '/domains/:domain',
104-
redirect: '/domains/:domain/workflows',
103+
path: '/domains/:domain/:clusterName?',
104+
redirect: '/domains/:domain/:clusterName?/workflows',
105105
component: Domain,
106106
props: ({ params }) => ({
107+
clusterName: params.clusterName,
107108
domain: params.domain,
108109
}),
109110
children: [
110111
{
111112
name: 'workflow-list',
112-
path: '/domains/:domain/workflows',
113+
path: '/domains/:domain/:clusterName?/workflows',
113114
components: {
114115
'workflow-list': WorkflowList,
115116
},
116117
},
117118
{
118119
name: 'domain-metrics',
119-
path: '/domains/:domain/metrics',
120+
path: '/domains/:domain/:clusterName?/metrics',
120121
components: {
121122
'domain-metrics': DomainMetrics,
122123
},
123124
},
124125
{
125126
name: 'domain-settings',
126-
path: '/domains/:domain/settings',
127+
path: '/domains/:domain/:clusterName?/settings',
127128
components: {
128129
'domain-settings': DomainSettings,
129130
},
130131
},
131132
{
132133
name: 'workflow-archival',
133-
path: '/domains/:domain/archival',
134-
redirect: '/domains/:domain/archival/basic',
134+
path: '/domains/:domain/:clusterName?/archival',
135+
redirect: '/domains/:domain/:clusterName?/archival/basic',
135136
components: {
136137
'workflow-archival': WorkflowArchival,
137138
},
138139
children: [
139140
{
140141
name: 'workflow-archival-advanced',
141-
path: '/domains/:domain/archival/advanced',
142+
path: '/domains/:domain/:clusterName?/archival/advanced',
142143
components: {
143144
'workflow-archival-advanced': WorkflowArchivalAdvanced,
144145
},
145146
},
146147
{
147148
name: 'workflow-archival-basic',
148-
path: '/domains/:domain/archival/basic',
149+
path: '/domains/:domain/:clusterName?/archival/basic',
149150
components: {
150151
'workflow-archival-basic': WorkflowArchivalBasic,
151152
},
@@ -156,9 +157,10 @@ const routeOpts = {
156157
},
157158
{
158159
name: 'workflow',
159-
path: '/domains/:domain/workflows/:workflowId/:runId',
160+
path: '/domains/:domain/:clusterName?/workflows/:workflowId/:runId',
160161
component: Workflow,
161162
props: ({ params }) => ({
163+
clusterName: params.clusterName,
162164
displayWorkflowId: params.workflowId,
163165
domain: params.domain,
164166
runId: params.runId,
@@ -167,7 +169,8 @@ const routeOpts = {
167169
children: [
168170
{
169171
name: 'workflow/summary',
170-
path: '/domains/:domain/workflows/:workflowId/:runId/summary',
172+
path:
173+
'/domains/:domain/:clusterName?/workflows/:workflowId/:runId/summary',
171174
components: {
172175
summary: WorkflowSummary,
173176
},
@@ -180,12 +183,14 @@ const routeOpts = {
180183
},
181184
{
182185
name: 'workflow/history',
183-
path: '/domains/:domain/workflows/:workflowId/:runId/history',
186+
path:
187+
'/domains/:domain/:clusterName?/workflows/:workflowId/:runId/history',
184188
components: {
185189
history: WorkflowHistory,
186190
},
187191
props: {
188192
history: ({ params, query }) => ({
193+
clusterName: params.clusterName,
189194
domain: params.domain,
190195
eventId: Number(query.eventId) || undefined,
191196
format: query.format || 'grid',
@@ -198,21 +203,24 @@ const routeOpts = {
198203
},
199204
{
200205
name: 'workflow/pending',
201-
path: '/domains/:domain/workflows/:workflowId/:runId/pending',
206+
path:
207+
'/domains/:domain/:clusterName?/workflows/:workflowId/:runId/pending',
202208
components: {
203209
pending: WorkflowPending,
204210
},
205211
},
206212
{
207213
name: 'workflow/stack-trace',
208-
path: '/domains/:domain/workflows/:workflowId/:runId/stack-trace',
214+
path:
215+
'/domains/:domain/:clusterName?/workflows/:workflowId/:runId/stack-trace',
209216
components: {
210217
stacktrace: StackTrace,
211218
},
212219
},
213220
{
214221
name: 'workflow/query',
215-
path: '/domains/:domain/workflows/:workflowId/:runId/query',
222+
path:
223+
'/domains/:domain/:clusterName?/workflows/:workflowId/:runId/query',
216224
components: {
217225
query: Query,
218226
},
@@ -221,31 +229,32 @@ const routeOpts = {
221229
},
222230
{
223231
name: 'task-list',
224-
path: '/domains/:domain/task-lists/:taskList',
225-
redirect: '/domains/:domain/task-lists/:taskList/pollers',
232+
path: '/domains/:domain/:clusterName?/task-lists/:taskList',
233+
redirect: '/domains/:domain/:clusterName?/task-lists/:taskList/pollers',
226234
component: TaskList,
227235
props: ({ params }) => ({
236+
clusterName: params.clusterName,
228237
domain: params.domain,
229238
taskList: params.taskList,
230239
}),
231240
children: [
232241
{
233242
name: 'task-list/pollers',
234-
path: '/domains/:domain/task-lists/:taskList/pollers',
243+
path: '/domains/:domain/:clusterName?/task-lists/:taskList/pollers',
235244
components: {
236245
pollers: TaskListPollers,
237246
},
238247
},
239248
{
240249
name: 'task-list/partition',
241-
path: '/domains/:domain/task-lists/:taskList/partition',
250+
path: '/domains/:domain/:clusterName?/task-lists/:taskList/partition',
242251
components: {
243252
partition: TaskListPartition,
244253
},
245254
},
246255
{
247256
name: 'task-list/metrics',
248-
path: '/domains/:domain/task-lists/:taskList/metrics',
257+
path: '/domains/:domain/:clusterName?/task-lists/:taskList/metrics',
249258
components: {
250259
partition: TaskListMetrics,
251260
},
@@ -262,11 +271,11 @@ const routeOpts = {
262271
},
263272
{
264273
name: 'domain-config-redirect',
265-
path: '/domains/:domain/config',
266-
redirect: '/domains/:domain/settings',
274+
path: '/domains/:domain/:clusterName?/config',
275+
redirect: '/domains/:domain/:clusterName?/settings',
267276
},
268277
{
269-
path: '/domains/:domain/history',
278+
path: '/domains/:domain/:clusterName?/history',
270279
redirect: ({ params, query }) => {
271280
if (!query.runId || !query.workflowId) {
272281
return {
@@ -278,6 +287,7 @@ const routeOpts = {
278287
const { runId, workflowId, ...queryWhitelist } = query;
279288

280289
const newParams = {
290+
clusterName: params.clusterName,
281291
runId,
282292
workflowId,
283293
domain: params.domain,

client/routes/domain/index.vue

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import { FeatureFlag, NavigationBar, NavigationLink } from '~components';
2424
2525
export default {
26-
props: ['dateFormat', 'domain', 'timeFormat', 'timezone'],
26+
props: ['clusterName', 'dateFormat', 'domain', 'timeFormat', 'timezone'],
2727
components: {
2828
'feature-flag': FeatureFlag,
2929
'navigation-bar': NavigationBar,
@@ -38,37 +38,47 @@ export default {
3838
<navigation-link
3939
icon="icon_search"
4040
label="Workflows"
41-
:to="{ name: 'workflow-list' }"
41+
:to="{ name: 'workflow-list', params: { clusterName } }"
4242
/>
4343
<navigation-link
4444
label="Settings"
4545
icon="icon_settings"
46-
:to="{ name: 'domain-settings' }"
46+
:to="{ name: 'domain-settings', params: { clusterName } }"
4747
/>
4848
<feature-flag display="inline" name="domainMetrics">
4949
<navigation-link
5050
label="Metrics"
5151
icon="icon_chart"
52-
:to="{ name: 'domain-metrics' }"
52+
:to="{ name: 'domain-metrics', params: { clusterName } }"
5353
/>
5454
</feature-flag>
5555
<navigation-link
5656
label="Archival"
5757
icon="icon_trip-history"
58-
:to="{ name: 'workflow-archival' }"
58+
:to="{ name: 'workflow-archival', params: { clusterName } }"
5959
/>
6060
</navigation-bar>
6161
<router-view
6262
name="workflow-list"
63+
:cluster-name="clusterName"
6364
:date-format="dateFormat"
6465
:domain="domain"
6566
:time-format="timeFormat"
6667
:timezone="timezone"
6768
/>
68-
<router-view name="domain-settings" :domain="domain" />
69-
<router-view name="domain-metrics" :domain="domain" />
69+
<router-view
70+
name="domain-settings"
71+
:cluster-name="clusterName"
72+
:domain="domain"
73+
/>
74+
<router-view
75+
name="domain-metrics"
76+
:cluster-name="clusterName"
77+
:domain="domain"
78+
/>
7079
<router-view
7180
name="workflow-archival"
81+
:cluster-name="clusterName"
7282
:date-format="dateFormat"
7383
:domain="domain"
7484
:time-format="timeFormat"

client/test/domain-settings.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Domain Settings', () => {
2323
async function domainConfigTest(mochaTest, desc) {
2424
const [testEl, scenario] = new Scenario(mochaTest)
2525
.withDomain('ci-test')
26-
.startingAt('/domains/ci-test/config')
26+
.startingAt('/domains/ci-test/settings')
2727
.withFeatureFlags()
2828
.withEmptyNewsFeed()
2929
.withDomainDescription('ci-test', desc)

0 commit comments

Comments
 (0)