-
Notifications
You must be signed in to change notification settings - Fork 25
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
New React-based UI for the plugin #58
base: master
Are you sure you want to change the base?
Conversation
Nice! I didn't like how the working hours plugin ran separately |
Avoids having two copies of node_modules when running npm outside of maven.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Tim Jacomb <t.jacomb@kainos.com>
cc @fqueiruga Tabs look interesting, I wouldn't have the header colour though |
Thinking aloud here, I've been considering the concept of 'Built-in roles', or separating Roles from Scope Consider the following roles:
These are all very re-usable roles I would expect, and could be defined by the plugin by default. A problem with the current implementation is that roles are defined at 'Global, Agent or Folder' What if roles were defined separately and then assigned to a scope level? Feel free to disregard as out of scope but bringing it up here because a UI re-design could be a good time to implement this |
That's just the default color that comes with the library. They have a palette customization option: https://material-ui.com/customization/palette/ If there's a color theme specification for Jenkins, it can be easily added.
An Admin role is automatically created when the plugin is initialized for the first time. All these things look like they are suitable for Global roles. Just like the admin role, we can create more roles if it helps. |
This sounds like its exactly https://docs.cloudbees.com/docs/admin-resources/latest/plugins/rbac |
Looks very similar, although that plugin is proprietary and has a very dated looking UI 👅 |
This is a great initiative. I have 2 pieces of feedback for now:
|
It has one really nice feature which users who perhaps have folder level admin can grant other users permissions from that level onwards |
Thanks @fqueiruga !
Does that mean using function components along with
Would you suggest using React Bootstrap or picking up components from npm and writing my own CSS? |
I tried using react-bootstrap with Bootstrap 4 but the CSS conflicts with that exported by Jenkins. Will have to look for something else. |
there's a flag on layout.jelly you can use to not load the ~'bootstrap 3' grid |
That looks interesting. I'll try it out. Thanks! |
@@ -1,309 +1,10 @@ | |||
<?jelly escape-by-default='true'?> | |||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout"> | |||
<l:layout permission="${app.ADMINISTER}" norefresh="true" title="${%title}"> | |||
<l:layout permission="${app.ADMINISTER}" norefresh="true" title="${%title}" nogrid="true"> |
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.
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.
@uhafner thoughts? I'm guessing there's some minimal styles you can add to fix the sidebar, or the sidebar shouldn't be relying on those styles and should be fixed in Jenkins core, cc @fqueiruga
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.
Which Jenkins version are you using? It still shows the old UI. Maybe that is the problem? I am already using the nogrid
flag and the sidebar does not break.
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.
When you use something that loads Bootstrap 4 then you also need jquery3, which leads to some additional problems. I needed to add the following fix on all my pages:
https://github.com/jenkinsci/bootstrap4-api-plugin/blob/master/src/main/webapp/js/no-prototype.js
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.
@uhafner Jenkins 2.235
When you use something that loads Bootstrap 4 then you also need jquery3, which leads to some additional problems. I needed to add the following fix on all my pages
I'm using react-bootstrap which does not need jquery. Quoting from their website:
React-Bootstrap replaces the Bootstrap JavaScript. Each component has been built from scratch as a true React component, without unneeded dependencies like jQuery.
So we only need the bootstrap css
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.
@uhafner is there any way to load the bootstrap layout just for the CSS without loading the bootstrap JS? That would be a huge win for many plugins.
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.
Yes, that should be possible. Currently
<st:adjunct includes="io.jenkins.plugins.bootstrap4"/>
includes both. But you can already include it using
<link type="text/css" rel="stylesheet" href="${resURL}/plugin/bootstrap4-api/css/bootstrap.min.css"/>
The. problem is: you don't know which components require JS and which not.
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.
@uhafner Jenkins 2.235
Maybe the problem is, that if you do not load the BS3 grid then you rather need to load the BS4 grid. So in my layouts I am using nogrid
and BS4 grid. If you do not load a grid it might break things.
@@ -0,0 +1,5 @@ | |||
a.tab:link, | |||
a.tab:visited { | |||
color: #007bff; |
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.
Hack to unset global a:link
and a:visited
.
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.
Yeah, that's a known PITA, I want to fix that
pom.xml
Outdated
@@ -27,9 +27,11 @@ | |||
<properties> | |||
<revision>1.3</revision> | |||
<changelist>-SNAPSHOT</changelist> | |||
<jenkins.version>2.164.1</jenkins.version> | |||
<jenkins.version>2.235</jenkins.version> |
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.
Also needs a version bump to at least 2.235
Indeed.
Depends on what you're most comfortable doing. I'd vote for custom components. There is already CSS for tabs on Jenkins, and I don't see it changing. You could use those CSS classes (for tabbarFrame, tab, etc) |
response.setCharacterEncoding("utf-8"); | ||
Writer writer = response.getWriter(); | ||
FolderBasedAuthorizationStrategyWrapper wrapper = new FolderBasedAuthorizationStrategyWrapper((FolderBasedAuthorizationStrategy) strategy); | ||
JsonGenerator generator = jsonFactory.createGenerator(writer); |
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.
net.sf.json
was able to convert the AuthorizationStrategy
to JSON but during the process it was generating over 1000 lines of warnings. I think using Jackson for it is a better solution. Please let me know if there is some better alternative.
Writer writer = response.getWriter(); | ||
FolderBasedAuthorizationStrategyWrapper wrapper = new FolderBasedAuthorizationStrategyWrapper((FolderBasedAuthorizationStrategy) strategy); | ||
JsonGenerator generator = jsonFactory.createGenerator(writer); | ||
generator.setCodec(new ObjectMapper()); |
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.
best to cache this, you only need to create one once
Is it ok if I pick up work on this? I don't have much experience with Java, but I know js/ts and React pretty well and I think a new manage UI would be golden. |
@vonEdfa thanks a lot. This would be great! I started working on this last year but it got lost thanks to to me having way too much work. I will try to build this branch and share resources to help you get started tomorrow. |
I did a trial run and did get it up and running and made a small demo front-end design. I am tempted to update some dependencies on the node side, but I didn't really dare to at this point. Only snag I met was that the folder-auth api only provides the IDs for the enabled permissions and I think we'd need a list of all available permissions to get react to draw them (if we don't want to hard code them, that is, but I'm assuming that is risky as new permissions can be introduced by other plugins, right?). Could perhaps be done by changing the structure of the json so each role includes all permission IDs together with a bool or having a second set of data where we ask Jenkins to give us all currently available permissions for the role type we're editing right now. |
We use https://github.com/eirslett/frontend-maven-plugin which downloads and installs node and npm. Node is installed in Webpack is configured to output the JS bundle to
Right. The plugin currently has no API that exposes loaded permissions and permission groups. There could be one from Jenkins core but I would need to check on that. Otherwise, we will need to build one.
Yes, permissions can be added by other plugins. Hard coding them is not really an option.
The data visible inside the folder roles tab right now is just a slightly modified version of the JCasC YAML in JSON. I think that the current draft could actually be better version of #69. Currently, there is no hot-reloading for the plugin UI. When you're running the plugin with Another major change needed is to fix the sidebar CSS to not depend on bootstrap as described in #58 (comment). Again, we need to check with a new Jenkins version. I'll try to check that later today. @vonEdfa Thanks a lot for working on this. I hope that this information is useful. If you have any other questions, I would be happy to help. |
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.
@vonEdfa When you run The UI prototype looks great! I was also thinking of something along these lines. I don't like the checkbox matrix either. It can get confusing when there are a lot of permissions. Copying the discord permission modification view looks like a great idea. I would probably suggest a modal dialog instead of a taking to a new screen to avoid routing complications on the server side. |
New React-based UI for the plugin