Skip to content

Commit f0242c4

Browse files
authored
Feature/active status actions (#421)
* adding expiry helpers for cache invalidation * dont forget to write tests * adding unit test for getExpiryDateTimeFromNow * adding unit test for has expired * domain container * app and vuex changes * removing unused file * Added active status getters * Added active status actions * adding merge domain config list * Added remaining files for active status actiosn * fix lint from merge conflict
1 parent f107658 commit f0242c4

File tree

12 files changed

+322
-9
lines changed

12 files changed

+322
-9
lines changed

client/App.vue

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
SelectInput,
3333
} from '~components';
3434
import {
35+
ActiveStatus,
3536
CrossRegion,
3637
Domain,
3738
DomainAutocomplete,
@@ -62,6 +63,7 @@ import { httpService } from '~services';
6263
6364
export default {
6465
components: {
66+
'active-status': ActiveStatus,
6567
'button-icon': ButtonIcon,
6668
'cross-region': CrossRegion,
6769
domain: Domain,
@@ -283,18 +285,16 @@ export default {
283285
<flex-grid-item v-if="$route.params.domain" margin="15px">
284286
<flex-grid align-items="center">
285287
<flex-grid-item>
286-
<a
288+
<router-link
287289
class="workflows"
288-
:class="{
289-
'router-link-active':
290-
$route.path ===
291-
`/domains/${$route.params.domain}/workflows`,
290+
:to="{
291+
name: 'workflow-list',
292+
params: { clusterName: $route.params.clusterName },
292293
}"
293-
:href="`/domains/${$route.params.domain}/workflows`"
294294
v-if="!isSearchingDomain"
295295
>
296296
{{ $route.params.domain }}
297-
</a>
297+
</router-link>
298298
<domain-autocomplete
299299
:focus="true"
300300
height="slim"
@@ -312,6 +312,13 @@ export default {
312312
@click="onEditDomainClick"
313313
/>
314314
</flex-grid-item>
315+
<flex-grid-item>
316+
<active-status
317+
:cluster-name="$route.params.clusterName"
318+
:domain="$route.params.domain"
319+
:workflow-id="$route.params.workflowId"
320+
/>
321+
</flex-grid-item>
315322
</flex-grid>
316323
</flex-grid-item>
317324

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
import { typePrefix } from './helpers';
23+
24+
export const ACTIVE_STATUS_ON_CHANGE = typePrefix('ON_CHANGE');
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
import { CROSS_REGION_ALLOWED_CROSS_ORIGIN } from '../cross-region/getter-types';
23+
import {
24+
ROUTE_PARAMS_CLUSTER_NAME,
25+
ROUTE_PARAMS_DOMAIN,
26+
} from '../route/getter-types';
27+
import { ACTIVE_STATUS_ON_CHANGE } from './action-types';
28+
import { getHrefFromCluster } from './helpers';
29+
30+
const actions = {
31+
[ACTIVE_STATUS_ON_CHANGE]: ({ dispatch, getters }, cluster) => {
32+
const allowedCrossOrigin = getters[CROSS_REGION_ALLOWED_CROSS_ORIGIN];
33+
const clusterName = getters[ROUTE_PARAMS_CLUSTER_NAME];
34+
const domainName = getters[ROUTE_PARAMS_DOMAIN];
35+
const { origin, pathname } = window.location;
36+
37+
const href = getHrefFromCluster({
38+
allowedCrossOrigin,
39+
cluster,
40+
clusterName,
41+
domainName,
42+
origin,
43+
pathname,
44+
});
45+
46+
window.location = href;
47+
},
48+
};
49+
50+
export default actions;
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<script>
2+
// Copyright (c) 2021 Uber Technologies Inc.
3+
//
4+
//
5+
// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
// of this software and associated documentation files (the "Software"), to deal
7+
// in the Software without restriction, including without limitation the rights
8+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
// copies of the Software, and to permit persons to whom the Software is
10+
// furnished to do so, subject to the following conditions:
11+
//
12+
// The above copyright notice and this permission notice shall be included in
13+
// all copies or substantial portions of the Software.
14+
//
15+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
// THE SOFTWARE.
22+
23+
import { FeatureFlag, SelectInput } from '~components';
24+
25+
export default {
26+
name: 'active-status',
27+
props: {
28+
classname: {
29+
type: String,
30+
},
31+
crossRegion: {
32+
type: Boolean,
33+
},
34+
cluster: {
35+
type: Object,
36+
},
37+
isReady: {
38+
type: Boolean,
39+
},
40+
label: {
41+
type: String,
42+
},
43+
selectList: {
44+
type: Array,
45+
},
46+
tag: {
47+
type: String,
48+
},
49+
},
50+
components: {
51+
'feature-flag': FeatureFlag,
52+
'select-input': SelectInput,
53+
},
54+
methods: {
55+
onClusterChange(cluster) {
56+
this.$emit('change', cluster);
57+
},
58+
},
59+
};
60+
</script>
61+
62+
<template>
63+
<feature-flag name="crossRegion.activeStatusTag" v-if="crossRegion">
64+
<component
65+
class="active-status"
66+
:class="{
67+
[classname]: classname,
68+
}"
69+
:is="tag"
70+
name="activeStatus"
71+
:options="selectList"
72+
:value="cluster"
73+
v-if="isReady && cluster"
74+
@change="onClusterChange"
75+
>
76+
{{ label }}
77+
</component>
78+
</feature-flag>
79+
</template>
80+
81+
<style lang="stylus">
82+
@require "../../styles/definitions"
83+
84+
.active-status {
85+
color: white !important;
86+
padding: 5px 10px;
87+
text-transform: uppercase;
88+
89+
&.active {
90+
background-color: uber-green;
91+
}
92+
93+
&.passive {
94+
background-color: uber-blue;
95+
}
96+
97+
&.select-input {
98+
padding: 0;
99+
100+
.v-select {
101+
.vs__dropdown-toggle {
102+
border: none;
103+
padding: 0;
104+
}
105+
106+
span.vs__selected {
107+
color: white;
108+
margin: 0;
109+
padding: 0;
110+
}
111+
}
112+
113+
.vs__actions {
114+
height: 24px;
115+
padding-top: 3px;
116+
}
117+
118+
.vs__dropdown-option {
119+
padding: 0 10px;
120+
}
121+
122+
.vs__open-indicator {
123+
fill: white;
124+
height: 10px;
125+
}
126+
127+
.vs__selected-options {
128+
padding: 0 4px 0 8px;
129+
}
130+
}
131+
}
132+
</style>

client/containers/active-status/connector.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ import {
2929
ACTIVE_STATUS_LABEL,
3030
ACTIVE_STATUS_TAG,
3131
} from './getter-types';
32+
import { ACTIVE_STATUS_ON_CHANGE } from './action-types';
33+
34+
const actionsToEvents = {
35+
change: ACTIVE_STATUS_ON_CHANGE,
36+
};
3237

3338
const gettersToProps = {
3439
classname: ACTIVE_STATUS_CLASSNAME,
@@ -41,5 +46,6 @@ const gettersToProps = {
4146
};
4247

4348
export default connect({
49+
actionsToEvents,
4450
gettersToProps,
4551
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
const getHrefFromCluster = ({
23+
allowedCrossOrigin,
24+
cluster: {
25+
isActive,
26+
isGlobalDomain,
27+
clusterName: clusterNamePath,
28+
origin: clusterOrigin,
29+
},
30+
clusterName,
31+
domainName,
32+
origin,
33+
pathname,
34+
}) => {
35+
if (!allowedCrossOrigin) {
36+
return `${clusterOrigin}${pathname}`;
37+
}
38+
39+
const replaceKey = `/domains/${domainName}/${
40+
clusterName ? clusterName + '/' : ''
41+
}`;
42+
const replaceValue = `/domains/${domainName}/${
43+
isGlobalDomain && isActive ? '' : clusterNamePath + '/'
44+
}`;
45+
46+
const newPathname = pathname.replace(replaceKey, replaceValue);
47+
48+
return `${origin}${newPathname}`;
49+
};
50+
51+
export default getHrefFromCluster;

client/containers/active-status/helpers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@
2222
export { default as getClusterFromClusterList } from './get-cluster-from-cluster-list';
2323
export { default as getClusterListFromDomainConfigList } from './get-cluster-list-from-domain-config-list';
2424
export { default as getFilteredClusterList } from './get-filtered-cluster-list';
25+
export { default as getHrefFromCluster } from './get-href-from-cluster';
2526
export { default as mergeDomainConfigList } from './merge-domain-config-list';
27+
export { default as statePrefix } from './state-prefix';
2628
export { default as typePrefix } from './type-prefix';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) 2021 Uber Technologies Inc.
2+
//
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
import { ACTIVE_STATUS_STATE_PREFIX } from '../constants';
23+
24+
const statePrefix = term => `${ACTIVE_STATUS_STATE_PREFIX}.${term}`;
25+
26+
export default statePrefix;

client/containers/active-status/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121

22+
import actions from './actions';
23+
import Component from './component';
24+
import connector from './connector';
2225
import getters from './getters';
2326

24-
export { getters };
27+
const container = connector(Component);
28+
29+
export { actions, container, getters };

client/containers/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121

22-
export { getters as activeStatusGetters } from './active-status';
22+
export {
23+
actions as activeStatusActions,
24+
container as ActiveStatus,
25+
getters as activeStatusGetters,
26+
} from './active-status';
2327
export {
2428
actions as clusterActions,
2529
getDefaultState as getClusterDefaultState,

0 commit comments

Comments
 (0)