-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Clone existing monitor #2489
Changes from 8 commits
608e3f5
4d0bdae
239910a
f0ae67f
54cd7a0
4a5a424
f9a6d7e
43c797a
4fed0c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -682,13 +682,23 @@ export default { | |
}, | ||
|
||
pageName() { | ||
return this.$t((this.isAdd) ? "Add New Monitor" : "Edit"); | ||
let name = "Add New Monitor"; | ||
if (this.isClone) { | ||
name = "Clone Monitor"; | ||
} else if (this.isEdit) { | ||
name = "Edit"; | ||
} | ||
return this.$t(name); | ||
}, | ||
|
||
isAdd() { | ||
return this.$route.path === "/add"; | ||
}, | ||
|
||
isClone() { | ||
return this.$route.path.startsWith("/clone"); | ||
}, | ||
|
||
isEdit() { | ||
return this.$route.path.startsWith("/edit"); | ||
}, | ||
|
@@ -906,11 +916,22 @@ message HealthCheckResponse { | |
this.monitor.notificationIDList[this.$root.notificationList[i].id] = true; | ||
} | ||
} | ||
} else if (this.isEdit) { | ||
} else if (this.isEdit || this.isClone) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would disagree |
||
this.$root.getSocket().emit("getMonitor", this.$route.params.id, (res) => { | ||
if (res.ok) { | ||
this.monitor = res.monitor; | ||
|
||
if (this.isClone) { | ||
/** | ||
* Cloning a monitor will include properties that can not be posted to backend | ||
* as they are not valid columns in the SQLite table. | ||
*/ | ||
this.monitor.id = undefined; // Remove id when cloning as we want a new id | ||
this.monitor.includeSensitiveData = undefined; | ||
this.monitor.maintenance = undefined; | ||
this.monitor.tags = undefined; // FIXME: Cloning tags does not work yet | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noticed that, maybe fix it in another pr. |
||
} | ||
|
||
// Handling for monitors that are created before 1.7.0 | ||
if (this.monitor.retryInterval === 0) { | ||
this.monitor.retryInterval = this.monitor.interval; | ||
|
@@ -981,7 +1002,7 @@ message HealthCheckResponse { | |
this.monitor.url = this.monitor.url.trim(); | ||
} | ||
|
||
if (this.isAdd) { | ||
if (this.isAdd || this.isClone) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would split it into two conditions so that it would be easier to make changes to either case in the future There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And in general I would suggest a redo on the switchcases, it's not clear or obvious that the logic for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would disagree. There is a lot of things that could be improved in this repo, but duplicating code does not make it better There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make another PR for making it more clear that |
||
this.$root.add(this.monitor, async (res) => { | ||
|
||
if (res.ok) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would do as:
And I would add in en.js: Wrong Monitor Action
Also, it's not quite clear to me why the Edit Monitor translation key wouldn't be added, so that when you change the Edit key for other purposes, you don't risk making this one case incomprehensible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed the name value for isAdd and isEdit?
Adding translations would be good yes, I just did as little as possible