Skip to content
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

option to hide script classes from being visible #13795

Closed
FliesLikeABrick opened this issue Sep 18, 2023 · 7 comments
Closed

option to hide script classes from being visible #13795

FliesLikeABrick opened this issue Sep 18, 2023 · 7 comments
Labels
type: feature Introduction of new functionality to the application

Comments

@FliesLikeABrick
Copy link

FliesLikeABrick commented Sep 18, 2023

NetBox version

v3.6.1

Feature type

New functionality

Proposed functionality

We would like to add a way to hide certain script classes from the UI when they do not have user-facing functionality (no run method). There seem to be a few ways this could be implemented:

  • Hide scripts that do not contain a run() method. This check could potentially be added into is_script() so that scripts without a run() method are inherently hidden. That is, codify the fact that a script without a run() method is not actually a script.
  • Add an option to the script module similar to script_order that lists classes which should be suppressed (something like "script_hide=(MyScript)), then use that list in the creation of sxripts to exclude those scripts. Add a check like "if cls not in script_hide" to the logic that creates the list of scripts)
  • Add an option to the script module which says that "script_order" is an absolute/complete list, and those scripts not listed should not be visible. Right now, any script not listed in "script_order" is just appended to the end. Such an option perhaps would be a boolean script_display_unordered=True/False

Use case

We have a class hierarchy for our Netbox scripts, to abstract common functionality. We do not want our intermediate classes from the module(s) being visible in the UI, as those classes do not contain user functionality

Database changes

None

External dependencies

None

@FliesLikeABrick FliesLikeABrick added the type: feature Introduction of new functionality to the application label Sep 18, 2023
FliesLikeABrick pushed a commit to FliesLikeABrick/netbox that referenced this issue Sep 18, 2023
FliesLikeABrick pushed a commit to FliesLikeABrick/netbox that referenced this issue Sep 18, 2023
…ide scripts from user display, documentation adjustment
@FliesLikeABrick
Copy link
Author

I have a branch ready for a pull request, if this issue/request is accepted.

@netbox-community netbox-community deleted a comment from tibobo67 Nov 27, 2023
@FliesLikeABrick
Copy link
Author

Hello, it has been 5 months since this was reported and I have offered a code fix - is anyone available to triage this request or provide feedback on the solution offered? I am not sure why the last two comments were deleted.

@abhi1693 abhi1693 added the status: under review Further discussion is needed to determine this issue's scope and/or implementation label Jan 29, 2024
@jeremystretch
Copy link
Member

IIRC inheriting from BaseScript rather than Script prevents a class from being listed. @FliesLikeABrick have you tried that?

I'm going to mark this as blocked by #12510 for now as I want to avoid potential conflicts with work we're doing on the Script class for v4.0.

@jeremystretch jeremystretch added status: blocked Another issue or external requirement is preventing implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jan 29, 2024
@FliesLikeABrick
Copy link
Author

FliesLikeABrick commented Jan 29, 2024

@jeremystretch thank you for the reply - we are inheriting from Script currently and our intermediate class is appearing in the UI alongside our two subclasses of it

class CNVRScript(Script):
image

@arthanson
Copy link
Collaborator

@FliesLikeABrick I've tested this, if your class inherits from BaseScript it won't show up:

class NewBranchScript(Script):
    ...

class NewBranchScript1(BaseScript):
    ...

In the case above NewBranchScript will show up but NewBranchScript1 will not.

@arthanson
Copy link
Collaborator

Closing as can use BaseScript

@jeremystretch jeremystretch removed the status: blocked Another issue or external requirement is preventing implementation label May 22, 2024
@rizlas
Copy link
Contributor

rizlas commented Jul 31, 2024

Hi,
I have a case where an option to hide will be perfect. Inheriting from BaseScript is not possible because it would also make the script that inherits from the base class disappear.

I've opened a discussion with example here: #17040

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants