Skip to content

Commit 55bab55

Browse files
committed
fix: remove useState for excludeTags and includeTags
1 parent dad642b commit 55bab55

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

ui/src/dashboard/Entry/DashboardEntryForm.tsx

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,23 @@ export const isValidDashboardEntry = (item: Dashboards_dashboards_items): boolea
3232
export const DashboardEntryForm: React.FC<EditPopupProps> = ({entry, onChange: setEntry, disabled = false, ranges}) => {
3333
const [staticRange, setStaticRange] = React.useState(!entry.statsSelection.rangeId);
3434

35-
const [excludeTags, setExcludeTags] = React.useState(
36-
(entry.statsSelection.excludeTags || []).map((tag) => ({
37-
tag: {
38-
key: tag.key,
39-
color: '',
40-
__typename: 'TagDefinition' as 'TagDefinition',
41-
},
42-
value: tag.value,
43-
}))
44-
);
45-
const [includeTags, setIncludeTags] = React.useState(
46-
(entry.statsSelection.includeTags || []).map((tag) => ({
47-
tag: {
48-
key: tag.key,
49-
color: '',
50-
__typename: 'TagDefinition' as 'TagDefinition',
51-
},
52-
value: tag.value,
53-
}))
54-
);
35+
const excludeTags = (entry.statsSelection.excludeTags || []).map((tag) => ({
36+
tag: {
37+
key: tag.key,
38+
color: '',
39+
__typename: 'TagDefinition' as 'TagDefinition',
40+
},
41+
value: tag.value,
42+
}));
43+
44+
const includeTags = (entry.statsSelection.includeTags || []).map((tag) => ({
45+
tag: {
46+
key: tag.key,
47+
color: '',
48+
__typename: 'TagDefinition' as 'TagDefinition',
49+
},
50+
value: tag.value,
51+
}));
5552

5653
const range: Dashboards_dashboards_items_statsSelection_range = entry.statsSelection.range
5754
? entry.statsSelection.range
@@ -215,7 +212,6 @@ export const DashboardEntryForm: React.FC<EditPopupProps> = ({entry, onChange: s
215212
type="Exclude"
216213
value={excludeTags}
217214
onChange={(tags) => {
218-
setExcludeTags(tags);
219215
entry.statsSelection.excludeTags = tags.map((tag) => ({
220216
key: tag.tag.key,
221217
value: tag.value,
@@ -228,7 +224,6 @@ export const DashboardEntryForm: React.FC<EditPopupProps> = ({entry, onChange: s
228224
type="Include"
229225
value={includeTags}
230226
onChange={(tags) => {
231-
setIncludeTags(tags);
232227
entry.statsSelection.includeTags = tags.map((tag) => ({
233228
key: tag.tag.key,
234229
value: tag.value,

0 commit comments

Comments
 (0)