Commit Graph

559 Commits

Author SHA1 Message Date
Zuul 1561fe775e Merge "Web UI: substring search for builds, buildsets" 2024-03-27 10:27:49 +00:00
Zuul 15e41212c9 Merge "Fix Gantt chart overlap on dup build names" 2024-03-26 09:04:59 +00:00
Zuul c4d1db0093 Merge "Fix web dequeue of post items" 2024-03-19 18:00:48 +00:00
James E. Blair f695820f2e Fix Gantt chart overlap on dup build names
If a buildset has more than one build with the same name, the
Gantt chart on the buildset page will render both of them on the
same line which can obscure one of them.

Correct this by telling the chart library that the independent
variable is the build uuid (which is unique) rather than the name,
and then override the axis labels to show the name.

Change-Id: I07b4059ca75748910633f72458db1b5fb8a84041
2024-03-19 10:54:07 -07:00
Flavio Percoco d7b79f05a6 Use the pipeline from the buildset
There's no pipeline key in the ref object. This causes the queue
action to fail with a 400 error due to the missing pipeline key
in the request payload.

This change switches to using the buildset.pipeline value, which was
being used in the past and changed in 24e1cbc26d

Signed-off-by: Flavio Percoco <flavio@pacerevenue.com>
Change-Id: Icaf65d798b03c083944280140d25267351d61f78
2024-03-19 09:19:36 +00:00
Benjamin Schanzel 00d55851f9
Web UI: substring search for builds, buildsets
Allow to search for builds and buildsets using substrings of job_name,
project, branch, and pipeline.

This is the user-facing part of 908420.

Change-Id: If3c8b870a4f9feb8c50a19cda8115aef048f75b9
2024-03-19 09:41:35 +01:00
James E. Blair c92b2c2221 Fix web dequeue of post items
This is a partial revert of 6c1c91f8ba
which relied on change.id being absent in the case that a queue item
was for a non-change ref; however, all queue items have an id.  This
reverts that section of code back to the previous regex-based
heuristic.

Change-Id: I07ff7c2925b44a7e85529491755b2f3d3f73eaf8
2024-03-15 07:37:24 -07:00
James E. Blair 9105ffe00b Add script to generate openapi spec
The existing openapi spec document (used to generate the swagger
ui page in the web app as well as the rst documentation) is
both incomplete and wrong due to bitrot.

This change adds a script which automatically generates much of
the api documentation from the code.  The output is still incomplete,
but it does include at least the same endpoints currently documented,
and of those, all of the inputs and outputs.

Due to its automatic generation, all of the endpoints and their
inputs are now documented.  Only some outputs are missing (as well
as explanatory text, which was pretty thin before).

It does the following:

* Inspects the cherrypy router object to determine the endpoints to
  include, and identifies their HTTP methods and the python functions
  that implement them.
* It inspects the function python docstring to get summary documentation
  for the endpoint.
* It inspects the function arguments and compares them to the
  router path to determine if each is a path or query parameter,
  as well as whether each is required.
* It merges type and descriptive information from the python docstring
  about each parameter.
* For output, a schema system similar to voluptuous is used to describe
  the output names and types, as well as optional descriptive information.
  One of two function decorators are used to describe the output.

It removes the documentation for the status page output format.  This API
is specially optimized for the Zuul status page, is very complex, and we
should therefore not encourage end-users to develop against it.  The
endpoint itself is documented as such, but the response value is
undocumented.

Future work:

More descriptive text and output formats can be documented.

Change-Id: Ib1a2aad728c4a7900841a8e3b617c146f2224953
2024-03-09 11:25:40 -08:00
James E. Blair 6dbdc407d5 Add filter actions menu to error table
To make it easier to use the filter interface for config errors,
use the patternfly react-table actions menu feature to put a single
search icon on the right of the table row which pops up a menu
that allows users to add a filter for each filterable column.

This makes it easy to "zoom in" to errors of a particular type o
for a particular project.

The action menu is not compatible with our custom "zuul-table" css,
so that class has been removed here.  The main difference at this point
is that it doesn't have the animated highlight on the left side during
mouseover.

Change-Id: I3ebac23296e61cfafcec3d5b37e65fffa4baad40
2024-02-28 17:11:46 -08:00
Zuul b85ad0494c Merge "Wrap long job names on status page" 2024-02-16 12:52:15 +00:00
Zuul 9146835a6f Merge "Fix subway graph line gap" 2024-02-15 22:28:31 +00:00
Zuul e19ef12ff1 Merge "Add dark mode images for status page" 2024-02-15 22:28:29 +00:00
James E. Blair 9e48b5af01 Wrap long job names on status page
Long job names should be wrapped so that they don't disrupt the layout
of the status page.  Job names with hyphens (the dominant style in
opendev) don't exhibit a problem because they will automatially wrap
at hyphenation points.  However, if jobs lack hyphens, then they will
appear as very long strings which widen the change boxes.

To address this, set the overflow-wrap css style in the change box
so that they are able to wrap at any point (but still preferentially
at hyphenation points).

Change-Id: Ieaedd722293dd9ca1ab7cffc378bceb05d3d5ee3
2024-02-12 10:17:48 -08:00
James E. Blair 5467388477 Fix subway graph line gap
In some cases a gap appears in the status page subway graph.
This change corrects that by only leaving a gap when necessary for
an icon or branch line.

Change-Id: I0abb156aa9d9b30fae4ec18ce2da9e4deaf7dbf1
2024-02-12 10:17:44 -08:00
James E. Blair ab71b7a8d4 Add dark mode images for status page
The status page has two images used when drawing the branch points
on the subway map (the T and the left-to-bottom angle).  The existing
images are black on white.  Add white on transparent options and
use them when in dark mode.

Change-Id: I304619c5ffd50e0b94d164d48578f5614535895f
2024-02-12 10:16:19 -08:00
James E. Blair a4b5394085 Fix filtering on status page
The status page filter is missing support for the new refs format
introduced by the circular dependency refactor.

Change-Id: I0324619a1a80ef99d7383549fd70823043d0c331
2024-02-12 06:52:20 -08:00
James E. Blair 24e1cbc26d Fix re-enqueue buildset in web ui
The re-enqueue buildset functionality in the web ui needs to be
updated to account for the bundle refactor.

Change-Id: I9b01d47051e805a56a6b90476736f9cd5babcbc8
2024-02-11 08:19:18 -08:00
James E. Blair 1cc276687a Change status json to use "refs" instead of "changes"
This is mostly an internal API change to replace the use of the
word "change" with "ref" in the status json.  This matches the
database and build/buildsets records.

Change-Id: Id468d16d6deb0af3d1c0f74beb1b25630455b8f9
2024-02-09 07:39:52 -08:00
James E. Blair 4a7e86f7f6 Update web ui for dependency refactor
This updates the web ui to handle multiple changes per item.  It
is compatible with the current data output as well as the upcoming
API.

Change-Id: I536967e51b22b60c8ff7baa46b902a36d1ea44dd
2024-02-05 15:38:59 -08:00
James E. Blair a9ff6b3410 Improve support for web enqueue/dequeue
This change:

* Returns the build/buildset oldrev through the REST API (this
  field was missing).
* Updates the web UI so that when enqueuing or dequeueing a ref it will
  send exactly the oldrev/newrev values it received, including None/null.
* No longer translate None to 40*'0' when creating internal management
  events.

In concert, these changes allow a user to re-enqueue exactly as
originally enqueued buildsets for branch tips (periodic pipeline) as
well as ref updates (tag/post pipelines).

Additionally, the re-enqueue method in the web UI is updated to support
re-enqueing tag and branch heads (it only worked on change and
ref-updates before).

Finally, the buildset page is updated to show the old and new revs
if they are non-null.

Change-Id: I9886cd44f8b4bae6f4a5ce3644f0598a73ecfe0a
2023-12-14 10:18:33 -08:00
James E. Blair 9efefec969 Update tenant error pagination total
On the config error page in the web ui, if we have no filters,
and we have performed the tenant info lookup, then we do know how
many total errors there are, so use that value in the pagination
header (but only under those circumstances).

Change-Id: Ia93d46927191ccbbc6577cb504ebe04054bc97af
2023-11-29 08:48:03 -08:00
James E. Blair a9688d6185 Use tenant-status endpoint to show the bell
We currently fetch all of the config errors in order to decide whether or
not to show the bell icon in the web ui (which indicates that there are
errors).  We recently added a tenant-status endpoint which returns a simple
error count instead of the entire data structure.  Use that to decide
whether to show the bell instead.

This builds on the previous change that fetches the config errors on-demand
rather than storing them in the redux store.  With that change and this
combined, we no longer need to store the errors in redux.  Instead we will
store the error count in redux so we only have to fetch it once when
switching tenants.

Change-Id: I3dfd911af9ba55dd55ca3649ee5ecf6edaa3581a
2023-11-28 09:47:14 -08:00
James E. Blair 4099919167 Use server-side filtering and pagination in config error page
This switches the config error page to use the new server-side
filtering and pagination support.  Note that we still fetch the
full set of config errors in order to display the bell icon.  That
will be updated in a future change.

Change-Id: I08a554c2a8151e24e5423608ef016f3273b3d663
2023-11-28 09:47:04 -08:00
Jeremy Stanley 29abf0ff0c Use moment-timezone for moment's tz method
After updating to the latest version of moment, many pages in the
Zuul web dashboard are observed to raise a TypeError about
"ne.utc(...).tz is not a function" which seems to correspond to the
recent moment library update in change
Id9d0cdec6d6a39542e8248c8690d8a94018296b5. Apparently, use of tz
needs explicit importing of moment from the separate moment-timezone
library, so the prior working state of these scripts likely had
something to do with global state and import order.

The moment-timezone library does not provide a duration method, so
use the plain moment library for that.

Change-Id: Ib75eb65cc29261f010df8c9ab8c15d6491205079
Co-Authored-By: James E. Blair <jim@acmegating.com>
2023-11-27 07:17:23 -08:00
James E. Blair 59a53b8c7b Update moment version
This updates the js moment dependency to the latest version.  There
have been some CVEs (unclear if they are applicable in Zuul).

Change-Id: Id9d0cdec6d6a39542e8248c8690d8a94018296b5
2023-11-08 13:55:29 -08:00
Zuul b6c8294d22 Merge "Add auth token to websocket" 2023-10-30 19:33:33 +00:00
James E. Blair beb4f97c13 Conditionally add index.html to the "view log" link
If the site has configured zuul manifest generation with
"index_links" set to true, they have indicated that the zuul web
ui needs to append "index.html" to all of the directory entries
listed in the zuul manifest when generating the "Logs" tab.

The same is almost certainly true for the raw link to the log
location (appearing as "View log" in the summary area), so once
we retrieve the manifest, if index_links is set there, then
set the "View log" link to also include an index.html.

If the manifest is missing, then we will fall back to returning
just the raw URL (and seeing the actual URL returned to Zuul may
be preferable when debugging log failures anyway). For most users,
most of the time, this should produce a reasonable "View log" link.

Change-Id: Ia63943742a7a20bbf271a4de692dd41f2fe0016d
2023-10-24 13:32:37 -07:00
James E. Blair 18fb324f1e Add auth token to websocket
When making a websocket request, browsers do not send the
"Authorization" header.  Therefore if a Zuul tenant is run in
a configuration where authz is required for read-only access,
the websocket-based log streaming will always fail.

To correct this, we will remove the http request authz check
from the console-stream endpoint, and add an optional token
parameter to the websocket message payload.  The JS web app
will be responsible for sending the auth token in the payload,
and the web server will validate it if it is required for the
tenant.  Thanks to Andrei Dmitriev for this suggestion.

Since we essentially have two different authz code paths in
zuul-web now, in order to share as much code as possible, the
authz sequence is refactored in such a way that the final authz
check can be deferred.  First we create an AuthContext at the
start of the request which stores tenant and header information,
then the actual validation is performed in a separate step where
the token can optionally be provided.

In the http code path, we create the AuthContext and validate
immediately, using the Authorization header, and we do all of that
in the cherrypy tool at the start of the request.

In the websocket code path, we create the AuthContext as the
websocket handler is being created by the cherrypy request handler,
then we perform validation after receiving a message on the
websocket.  We use the token supplied from the request.

Error handling is adjusted so in the http code path, exceptions
that return appropriate http errors are raised, but in the
websocket path, these are caught and translated into websocket
close calls.

A related issue is that we perform no validation that the
streaming build log being requested belongs to the tenant via
which the request is being sent.  This was unecessary before
read-only access was an option, but now that it is, we should
check that a streaming build request arrives via the correct
tenant URL.  This change adjusts that as well.

During testing, it was noted that the tenant configuration syntax
allows admin-rules and access-rules to use the scalar-or-list
pattern, however some parts of the code assumed only lists.  The
configloader is updated to use scalar-or-list for both of those
values.

Change-Id: Ifd4c21bb1fe962bf23acb5b4f10b3bbaba61e63a
Co-Authored-By: Andrei Dmitriev <andrei.dmitriev@nokia.com>
2023-10-24 07:29:55 -07:00
James E. Blair e429a90722 Load config errors less often
If we encounter network delays loading the config errors endpoint
(which is likely if it's large), then we can end up issuing multiple
outstanding GET requests for the same endpoint.  Avoid that by using
the isFetching pattern used by other members of the store.

Also, store the tenant name for the most recent fetch so that we
*can* have multiple outstanding requests for different tenants, but
we only accept the most recent one.

Change-Id: Ic49027e137b8c30004d43059db259d10c5443812
2023-09-22 07:05:09 -07:00
James E. Blair 8021fdf37b Indicate queue and window length on status page
For every pipeline, we already show the number of items in the
pipeline in a "badge" after the pipeline name.

This change extends that concept to show the length of the
individual change queues in the same way -- a new badge to the right
of the queue name.

Additionally, in the case of dependent pipelines, we add the current
window size to the badge.  So in check, a queue header might look like:

  Queue: [17]

If there are 17 changes in the queue.  And in gate it might look like:

  Queue: integrated [4 / 22]

If there are 4 changes in the queue and the window size is 22.

The new badge has a tooltip that breaks each of these values out so
that users can discover their individual meanings.  It looks like:

  Queue length: 4
  Window size: 22

Change-Id: I951e1b406926b2438a847874d64babee0d11fb6f
2023-08-29 15:44:36 -07:00
James E. Blair cfe7ca6155 Add early failure indication to the web UI
This changes the job progress bar to red, and also the job's component
of the queue item progress bar to red in the case where an early failure
in the job is detected.  This lets users see what has caused the queue
item to flip to the failure status before the first failure report.

It also adds some explanatory text to the job progress bar mouseover.

Change-Id: Ic9fd1eb000b6a6fce44d2c820dedc02fb0ca9438
2023-07-29 13:30:14 -07:00
James E. Blair 95814f7734 Fix URL generation for subdir deployments
We discovered that the build process strips trailing slashes
from PUBLIC_URL, which thwarted our plans in getHomepageUrl.
This ensures the function always returns a trailing slash.

Change-Id: I03c4ec79ee4566a8b7fbd4e04c18e86f4257fa8f
2023-07-26 07:04:50 -07:00
Zuul 19ae1f2f8a Merge "Add config metadata to identify project-templates" 2023-07-24 07:00:51 +00:00
Flavio Percoco e7c79dad8e Use built-in URL data type instead of custom parse
The getHomepageUrl function searches for /# when trying to find hash
anchors in the URL. This misses URLs that don't end with a trailing slash
(i.e http://localhost:3000/auth_callback#state=231231231)

To fix this, this commit switches to using the built-in URL data type
which handles this case and all the other cases.

Change-Id: I15827f4cb4c28f3163a4b4e84b872331b972b156
Signed-off-by: Flavio Percoco <flavio@pacerevenue.com>
Co-Authored-By: Radosław Piliszek <radoslaw.piliszek@gmail.com>
2023-07-18 12:23:20 +00:00
Jeremy Stanley 6ec55d9f39 Add config metadata to identify project-templates
Since project default branches were fixed in
Iddd5ef906c2bdbcc472615ffe25033c4ca961df7 the workaround in the
project detail view of the dashboard to distinguish actual project
configs from project-template configs will no longer work. Extend
the config model to incorporate a flag which indicates whether it
comes from a template or an actual project directly, and use that in
the dashboard rather than a (now broken) proxy value.

Change-Id: I2958a9bb01ca5261604773de742b6b652fca4cae
2023-06-07 03:24:03 +00:00
James E. Blair b63fc7bed6 Web: remove config error drawer
This changes the bell icon at the top to link directly to the
config-errors page.

Currently, the bell icon opens a notification drawer which shows
one rendition of a list of config errors, and if the user clicks
on any error, it navigates to the config-errors page which shows
another rendition.

Rather than having two ways of viewing config errors, let's just
have one.

Change-Id: I630fb2311ec5fa47c8a0dbf8a838c4e0453f32e1
2023-05-31 17:37:59 -07:00
James E. Blair bcae20f897 Web: convert config errors to table
This updates the config-errors page to show errors in table format
along with a filter bar.

This allows users to see all of the errors at a glance, or filter
by project or error type.

The table rows show a summary of error information, and each row
can be expanded to show the full error message.

Change-Id: Ie019d4193c730fe84f4bc2827106825093fa68a4
2023-05-31 17:37:54 -07:00
James E. Blair 68d705bad8 Conditionally render ANSI console text with a black background
We render ANSI colors in 3 places:
* Streaming console
* Build task summary tab
* Build console tab

(We do not render ANSI colors in the Build log tab.)

In the streaming console, the default color scheme is white-on-black
which is probably what most devs expect when they render color output.
The other two locations maintain the black-on-white Patternfly default
scheme.  This means that some colors (eg yellow) are difficult to read.

In order to accommodate cases where ANSI colors are used, the
color scheme of the preformatted sections in the Build task summary or
Build console tabs is changed to white on black iff an ANSI color
sequence is detected.  Otherwise, it remains the Patternfly default
of black on white.

Change-Id: If99d09f614c51495af4ee400891b9a8f2e217db8
2023-05-22 07:52:00 -07:00
Tobias Urdin 59cd5de78b web: add dark mode and theme selection
This adds a theme selection in the preferences in the
config modal and adds a new dark theme.

Removes the line.png image and instead uses CSS
linear-gradient that is available in all browsers
since around 2018, also fixes the 15 pixels spacing
issue that is there today.

You can select between three different themes.

Auto will use your system preference to choose either the
light or dark theme, changes dynamically based on your
system preference.

Light is the current theme.

Dark is the theme added by this patch series.

The UX this changes is that if somebody has their system
preferences set to dark, for example in Mac OS X that is
in System Settings -> Appearance -> Dark the user will
get the Zuul web UI in dark by default and same for the
opposite.

This uses a poor man's dark mode for swagger-ui
as per the comment in [1].

[1] https://github.com/swagger-api/swagger-ui/issues/5327#issuecomment-742375520

Change-Id: I01cf32f3decdb885307a76eb79d644667bbbf9a3
2023-04-21 11:23:56 +00:00
Tobias Urdin de9dfa2bc4 web: migrate pages to react-table
This migrates the Labels, Nodes and
Projects pages to using the react-table
component from patternfly.

Change-Id: Iaa75e70f4b0c25113369939f97a297571f2ea7a5
2023-03-22 16:10:53 +00:00
Zuul bac514e28c Merge "Zuul-Web: Filter input validation for "Change"" 2023-03-15 16:40:59 +00:00
Dong Zhang f848f251e4 Zuul-Web: Filter input validation for "Change"
User sometimes tends to copy the value from the "Change" column as a input
for filtering, which would cause a 500 error in API.

To fix this we do a input validation to indicate that the change must be
a integer for example a PR bumber. So that make it clear any other fomat
like a ref or a string with "," is not supported.

Change-Id: Ia25a60429acc48c5773c808be6a900ba9bdf608e
2023-03-15 09:08:35 +01:00
Zuul 7039d4f5f6 Merge "Add project-ssh-key to API docs" 2023-02-15 20:53:54 +00:00
Matthieu Huin d3f5b9890e GUI: Add tenant dropdown to top menu
On a non whitelabeled setup, allow a user to jump from one tenant to
another without having to go back to the tenants page.
On a whitelabeled setup, make the tenant item non-clickable (the click
doesn't do anything anyway).

Change-Id: I94d27445c65ed5c3f8d02fae9d47d426528d2332
2023-02-02 15:41:18 +01:00
Dmitriy Rabotyagov df7cb1ed3f Add project-ssh-key to API docs
At the moment API call for fetching SSH public key is not documented
anywhere. It's a bit confusing when a user tries to check through
available calls. This call documented only in ``job-content.rst``.

Change-Id: I69a8d8994b1b4e49ac2c5b07690ebb9ff2a62e38
2022-12-07 16:25:42 +01:00
Clark Boylan 4a50893388 Fix config-errors dedicated page
There was a type update to our configErrors state from a list of errors
to a dict containing a list of errors and a ready state flag. This broke
the map() call on configErrors in the dedicated config errors page
because you can't map an object only an Array. We fix this by mapping
the objects errors attribute into the page as the config errors allowing
us to keep mapping over it.

Change-Id: Ib84ca9241fb456f9493a07d1c7e1220f5fa925c8
2022-11-02 08:45:17 -07:00
James E. Blair f9b0cca24d Fix skipped builds filter in web ui
The change to automatically filter out skipped builds inadvertently
affected the buildsets tab as well since they share the query builder.
This caused the buildsets tab to automatically append a filter which
is invalid for buildsets and therefore return a 404.

This change adds an argument to the query builder to indicate whether
it should include the automatic filter.

Additionally, the query builder had an error which caused it to
append the query in all cases (which affects the otherwise working
builds tab).  This change corrects that as well.

Change-Id: Id03eee51b3551c4b32ae3c6b784b0993c4a3779c
2022-11-01 14:43:36 -07:00
Zuul 7606304159 Merge "Change merge mode default based on driver" 2022-10-27 02:25:37 +00:00
James E. Blair 9d2e1339ff Support authz for read-only web access
This updates the web UI to support the requirement for authn/z
for read-only access.

If authz is required for read access, we will automatically redirect.
If we return and still aren't authorized, we will display an
"Authorization required" page (rather than continuing and popping up
API error notifications).

The API methods are updated to send an authorization token whenever
one is present.

Change-Id: I31c13c943d05819b4122fcbcf2eaf41515c5b1d9
2022-10-25 20:22:42 -07:00
James E. Blair c2f2891bd3 Show login button any time auth is available
We currently only show the login button when in the context of a
tenant.  Now that we have an auth context for the "root" level of
a multi-tenant zuul, show the login button there as well.

Change-Id: Ic1d39951a0cf481c6fac4700ba9bb9338478cd7c
2022-10-25 20:19:42 -07:00