Skip to content

Commit

Permalink
morgue/view: search for a view using the "%dashboard%" prefix
Browse files Browse the repository at this point in the history
The names of views created in the Backtrace dashboard are prefixed with
"%dashboard%". To hide this internal detail and to make the command
"morgue view delete" more convenient to use, automatically search for a
view including the "%dashboard%" prefix if a view cannot be found with that
name.

Addresses a problem reported where a "morgue view delete" command would
return "Error: View not found." unexpectedly.

Internal Ref BT-5397
  • Loading branch information
George Menhorn authored and gm4sl committed Feb 3, 2025
1 parent dfbe14b commit d74f264
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bin/morgue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4936,9 +4936,16 @@ function viewSetupFn(config, argv, opts, subcmd) {
}

if (subcmd !== 'create') {
// First search for a view by its query name.
opts.state.query = opts.state.model.query.find((query) =>
query.fields.name === opts.params.attrname
);
// If not found, search for a view using the dashboard query name.
if (!opts.state.query) {
opts.state.query = opts.state.model.query.find((query) =>
query.fields.name === "%dashboard% " + opts.params.attrname
);
}
if (!opts.state.query)
return viewUsageFn("View not found.");
opts.state.attr_key = {
Expand Down

0 comments on commit d74f264

Please sign in to comment.