Allow overriding the href of a custom link #10561

Closed
opened 2025-12-29 21:33:09 +01:00 by adam · 6 comments
Owner

Originally created by @AliMickey on GitHub (Dec 11, 2024).

NetBox version

v4.1.5

Feature type

Data model extension

Triage priority

N/A

Proposed functionality

This is in reference to an original discussion https://github.com/netbox-community/netbox/discussions/18178

This issue tackles this in a different way, by allowing custom links to have an override href (for example #), the generated link wont contain the base domain URL, thus allowing a user to right click and copy to clipboard.

This doesn't resolve the current issue with how spaces are handled where %20 is used.

I am open to implementing this some other way, I have been unsuccessful with using custom fields and config contexts. Using a custom field/description and pasting in the plain text for each device is not feasible.

Use case

Dynamically rendered plaintext, that can be copied to clipboard either natively or via right click -> copy on the browser.

Example use case is to copy a SSH shortcut for a given device, using primary_ip, and other custom field data such as username.

Database changes

No response

External dependencies

No response

Originally created by @AliMickey on GitHub (Dec 11, 2024). ### NetBox version v4.1.5 ### Feature type Data model extension ### Triage priority N/A ### Proposed functionality This is in reference to an original discussion https://github.com/netbox-community/netbox/discussions/18178 This issue tackles this in a different way, by allowing custom links to have an override href (for example #), the generated link wont contain the base domain URL, thus allowing a user to right click and copy to clipboard. This doesn't resolve the current issue with how spaces are handled where %20 is used. I am open to implementing this some other way, I have been unsuccessful with using custom fields and config contexts. Using a custom field/description and pasting in the plain text for each device is not feasible. ### Use case Dynamically rendered plaintext, that can be copied to clipboard either natively or via right click -> copy on the browser. Example use case is to copy a SSH shortcut for a given device, using primary_ip, and other custom field data such as username. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: feature label 2025-12-29 21:33:09 +01:00
adam closed this issue 2025-12-29 21:33:10 +01:00
Author
Owner

@arthanson commented on GitHub (Feb 13, 2025):

@AliMickey can you please clarify this and the use case as it's not clear how this would be generally applicable. Using a special # does not sound like something we would want to do.

@arthanson commented on GitHub (Feb 13, 2025): @AliMickey can you please clarify this and the use case as it's not clear how this would be generally applicable. Using a special # does not sound like something we would want to do.
Author
Owner

@AliMickey commented on GitHub (Feb 14, 2025):

@arthanson Basically a button that allows for text to be copied to clipboard that is 'built' using the same template logic as custom links.

Any implementation is fine but I figured editing custom link logic to allow 'copy to clipboard' rather than 'open in new tab' would be easiest.

@AliMickey commented on GitHub (Feb 14, 2025): @arthanson Basically a button that allows for text to be copied to clipboard that is 'built' using the same template logic as custom links. Any implementation is fine but I figured editing custom link logic to allow 'copy to clipboard' rather than 'open in new tab' would be easiest.
Author
Owner

@jeremystretch commented on GitHub (Feb 20, 2025):

@AliMickey I'm not clear on exactly what you're proposing. Could you please provide a concrete example, complete with sample HTML?

@jeremystretch commented on GitHub (Feb 20, 2025): @AliMickey I'm not clear on exactly what you're proposing. Could you please provide a concrete example, complete with sample HTML?
Author
Owner

@AliMickey commented on GitHub (Feb 21, 2025):

Example custom link:

Image

If I click on this link button on a device page, it will take me to https://netbox.domain.com/dcim/devices/id/ssh%20device_name@bastion.domain.com as it gets treated as a link (correctly).

I'm suggesting that having a way to copy the rendered link to the clipboard when the button is clicked is useful. For example, in this SSH shortcut case, it would allow users to:

  1. Click the SSH button.
  2. ssh device_name@bastion.domain.com gets copied to clipboard.
  3. Open a terminal window and paste clipboard content to easily get connected to the device.
@AliMickey commented on GitHub (Feb 21, 2025): Example custom link: ![Image](https://github.com/user-attachments/assets/fb3f2b25-3eb5-4275-a47e-ba62dd6b267f) If I click on this link button on a device page, it will take me to https://netbox.domain.com/dcim/devices/id/ssh%20device_name@bastion.domain.com as it gets treated as a link (correctly). I'm suggesting that having a way to copy the rendered link to the clipboard when the button is clicked is useful. For example, in this SSH shortcut case, it would allow users to: 1. Click the SSH button. 2. `ssh device_name@bastion.domain.com` gets copied to clipboard. 3. Open a terminal window and paste clipboard content to easily get connected to the device.
Author
Owner

@jeremystretch commented on GitHub (Feb 21, 2025):

Custom links are to be used solely as that: hyperlinks. You can right-click on a custom link and select "copy link" or "copy URL" (whichever term your browser uses) to copy the link to the clipboard.

If you want something more advanced than that, consider using a plugin to embed custom content.

@jeremystretch commented on GitHub (Feb 21, 2025): Custom links are to be used solely as that: hyperlinks. You can right-click on a custom link and select "copy link" or "copy URL" (whichever term your browser uses) to copy the link to the clipboard. If you want something more advanced than that, consider using a plugin to [embed custom content](https://netboxlabs.com/docs/netbox/en/stable/plugins/development/views/#extra-template-content).
Author
Owner

@AliMickey commented on GitHub (Feb 22, 2025):

@jeremystretch

I understand that, and as such left a comment above saying "Any implementation is fine but I figured editing custom link logic to allow 'copy to clipboard' rather than 'open in new tab' would be easiest.".

--

Custom links are to be used solely as that: hyperlinks. You can right-click on a custom link and select "copy link" or "copy URL" (whichever term your browser uses) to copy the link to the clipboard.

This doesn't work because it copies https://netbox.domain.com/dcim/devices/id/ssh%20device_name@bastion.domain.com, this was the first thing I tried and wouldn't have opened a feature request if it were this simple.

@AliMickey commented on GitHub (Feb 22, 2025): @jeremystretch I understand that, and as such left a comment above saying "Any implementation is fine but I figured editing custom link logic to allow 'copy to clipboard' rather than 'open in new tab' would be easiest.". -- > Custom links are to be used solely as that: hyperlinks. You can right-click on a custom link and select "copy link" or "copy URL" (whichever term your browser uses) to copy the link to the clipboard. This doesn't work because it copies `https://netbox.domain.com/dcim/devices/id/ssh%20device_name@bastion.domain.com`, this was the first thing I tried and wouldn't have opened a feature request if it were this simple.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10561