Skip to content

Commit

Permalink
Merge pull request #22 from intergral/watches
Browse files Browse the repository at this point in the history
fix(watches): fix issue when creating tracepoint with no watches
  • Loading branch information
Umaaz authored Nov 10, 2023
2 parents a454ac4 + 542d2e2 commit e4e9994
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<!-- 1.0.2 Start -->
# 1.0.2 (10/11/2023)

- **[BUGFIX]**: handle case when creating tracepoint with no watches [#22](https://github.com/intergral/deep/pull/22) [@Umaaz](https://github.com/Umaaz)

<!-- 1.0.2 END -->

<!-- 1.0.1 Start -->
# 1.0.1 (09/11/2023)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grafana-deep-datasource",
"version": "1.0.1",
"version": "1.0.2",
"description": "Datasource plugin for DEEP",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down
38 changes: 23 additions & 15 deletions src/components/tracepoints/TracepointCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,30 @@ export const TracepointCreate = ({datasource, query, onChange, onRunQuery, onBlu
</InlineLabel>
<div className={styles.watchGroup}>
<VerticalGroup>
{query.tpCreate.watches.map((watch, index) => {
{(query.tpCreate?.watches ?? []).map((watch, index) => {
return <div className={styles.watchLine} key={index}>
<Input
className={styles.watchInput}
value={watch}
type={"text"}
onChange={event => {
query.tpCreate = {
...query.tpCreate
}
query.tpCreate.watches = query.tpCreate?.watches ?? []
query.tpCreate.watches[index] = event.currentTarget.value
onChange({
...query,
})
}}/>
<span className={styles.watchButton}>
<IconButton name={"trash-alt"} aria-label={"delete"} onClick={() => {
query.tpCreate.watches.splice(index, 1);
onChange({
...query,
})
}}/>
</span>
<IconButton name={"trash-alt"} aria-label={"delete"} onClick={() => {
query.tpCreate.watches.splice(index, 1);
onChange({
...query,
})
}}/>
</span>
</div>
})}
</VerticalGroup>
Expand All @@ -274,13 +278,17 @@ export const TracepointCreate = ({datasource, query, onChange, onRunQuery, onBlu
setNewWatch(event.currentTarget.value)
}}/>
<span className={styles.watchButton}>
<IconButton name={"plus"} aria-label={"Create"} onClick={() => {
query.tpCreate.watches.push(newWatch)
onChange({
...query,
})
}}/>
</span>
<IconButton name={"plus"} aria-label={"Create"} onClick={() => {
query.tpCreate = {
...query.tpCreate
}
query.tpCreate.watches = query.tpCreate?.watches ?? []
query.tpCreate.watches.push(newWatch)
onChange({
...query,
})
}}/>
</span>
</div>
</div>
</div>
Expand Down

0 comments on commit e4e9994

Please sign in to comment.