Skip to content

Commit 331f355

Browse files
committed
const changes
1 parent a6b2714 commit 331f355

File tree

3 files changed

+48
-33
lines changed

3 files changed

+48
-33
lines changed

src/components/ClusterNodes/ClusterTerminal.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
CLUSTER_STATUS,
3737
CLUSTER_TERMINAL_MESSAGING,
3838
IMAGE_LIST,
39+
nodeSelect,
3940
SELECT_TITLE,
4041
} from './constants'
4142
import { OptionType } from '../userGroups/userGroups.types'
@@ -485,29 +486,7 @@ export default function ClusterTerminal({
485486
defaultValue={selectedNodeName}
486487
value={selectedNodeName}
487488
onChange={onChangeNodes}
488-
styles={{
489-
...clusterSelectStyle,
490-
group: (base) => ({
491-
...base,
492-
paddingTop: 0,
493-
paddingBottom: 0,
494-
}),
495-
menu: (base) => ({
496-
...base,
497-
zIndex: 9999,
498-
width: '300px',
499-
}),
500-
groupHeading: (base) => ({
501-
...base,
502-
fontWeight: 600,
503-
fontSize: '12px',
504-
textTransform: 'lowercase',
505-
height: '28px',
506-
color: 'var(--N900)',
507-
backgroundColor: 'var(--N100)',
508-
marginBottom: 0,
509-
}),
510-
}}
489+
styles={nodeSelect}
511490
components={{
512491
IndicatorSeparator: null,
513492
GroupHeading: groupHeading,

src/components/ClusterNodes/NodeListSearchFilter.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import ReactSelect, { MultiValue } from 'react-select'
77
import { OptionType } from '../app/types'
88
import { ColumnMetadataType, NodeListSearchFliterType } from './types'
99
import ColumnSelector from './ColumnSelector'
10-
import { NodeSearchOption } from './constants'
10+
import { NodeSearchOption, SEARCH_OPTION_LABEL } from './constants'
1111

1212
const ColumnFilterContext = React.createContext(null)
1313

@@ -76,7 +76,7 @@ export default function NodeListSearchFliter({
7676
if (!currentItem) {
7777
continue
7878
}
79-
if (selectedSearchTextType === 'label') {
79+
if (selectedSearchTextType === SEARCH_OPTION_LABEL.LABEL) {
8080
const element = currentItem.split('=')
8181
const key = element[0] ? element[0].trim() : null
8282
if (!key) {
@@ -113,14 +113,14 @@ export default function NodeListSearchFliter({
113113
}
114114
const renderTextFilter = (): JSX.Element => {
115115
let placeholderText = ''
116-
if(selectedSearchTextType === 'name'){
116+
if (selectedSearchTextType === SEARCH_OPTION_LABEL.NAME) {
117117
placeholderText = 'Search by node name Eg. ip-172-31-2-152.us-east-2.compute.internal'
118-
} else if (selectedSearchTextType === 'label'){
118+
} else if (selectedSearchTextType === SEARCH_OPTION_LABEL.LABEL) {
119119
placeholderText = 'Search by key=value Eg. environment=production, tier=frontend'
120120
} else {
121121
placeholderText = 'Search by node group name Eg. mainnode'
122122
}
123-
123+
124124
return (
125125
<div className="dc__position-rel" style={{ background: 'var(--N50)' }}>
126126
<div
@@ -131,7 +131,10 @@ export default function NodeListSearchFliter({
131131
{selectedSearchTextType ? (
132132
<>
133133
<span className="dc__position-rel bottom-2px">
134-
{selectedSearchTextType === 'nodeGroup' ? 'node group' : selectedSearchTextType}:
134+
{selectedSearchTextType === SEARCH_OPTION_LABEL.NODE_GROUP
135+
? SEARCH_OPTION_LABEL.NODE_GROUP_TEXT
136+
: selectedSearchTextType}
137+
:
135138
</span>
136139
<input
137140
autoComplete="off"
@@ -163,7 +166,9 @@ export default function NodeListSearchFliter({
163166
selectFilterType(o)
164167
}}
165168
>
166-
{o.label === 'nodeGroup' ? 'node group' : o.label}
169+
{o.label === SEARCH_OPTION_LABEL.NODE_GROUP
170+
? SEARCH_OPTION_LABEL.NODE_GROUP_TEXT
171+
: o.label}
167172
</div>
168173
)
169174
})}

src/components/ClusterNodes/constants.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,39 @@ export const clusterImageSelect = {
324324
}),
325325
}
326326

327+
export const SEARCH_OPTION_LABEL = {
328+
NAME: 'name',
329+
LABEL: 'label',
330+
NODE_GROUP: 'nodeGroup',
331+
NODE_GROUP_TEXT: 'node group',
332+
}
333+
327334
export const NodeSearchOption = [
328-
{ value: 1, label: 'name', type: 'main' },
329-
{ value: 2, label: 'label', type: 'main' },
330-
{ value: 3, label: 'nodeGroup', type: 'main' },
335+
{ value: 1, label: SEARCH_OPTION_LABEL.NAME, type: 'main' },
336+
{ value: 2, label: SEARCH_OPTION_LABEL.LABEL, type: 'main' },
337+
{ value: 3, label: SEARCH_OPTION_LABEL.NODE_GROUP, type: 'main' },
331338
]
339+
340+
export const nodeSelect = {
341+
...clusterSelectStyle,
342+
group: (base) => ({
343+
...base,
344+
paddingTop: 0,
345+
paddingBottom: 0,
346+
}),
347+
menu: (base) => ({
348+
...base,
349+
zIndex: 9999,
350+
width: '300px',
351+
}),
352+
groupHeading: (base) => ({
353+
...base,
354+
fontWeight: 600,
355+
fontSize: '12px',
356+
textTransform: 'lowercase',
357+
height: '28px',
358+
color: 'var(--N900)',
359+
backgroundColor: 'var(--N100)',
360+
marginBottom: 0,
361+
}),
362+
}

0 commit comments

Comments
 (0)