Merge "Remove old diff cache"
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 9e73f6f..84e68ed 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -5340,13 +5340,27 @@
[[tracing.traceid.requestUriPattern]]tracing.<trace-id>.requestUriPattern::
+
Regular expression to match request URIs for which request tracing
-should be always enabled. Request URIs are only available for REST
-requests. Request URIs never include the '/a' prefix.
+should be enabled except if they match
+link:tracing.traceid.excludedRequestUriPattern[excludedRequestUriPattern].
+Request URIs are only available for REST requests. Request URIs never include
+the '/a' prefix.
+
May be specified multiple times.
+
By default, unset (all request URIs are matched).
+[[tracing.traceid.excludedRequestUriPattern]]tracing.<trace-id>.excludedRequestUriPattern::
++
+Regular expression to match request URIs for which request tracing
+should not be enabled even if they match
+link:#tracing.traceid.requestUriPattern[requestUriPattern].
+Request URIs are only available for REST requests. Request URIs never include
+the '/a' prefix.
++
+May be specified multiple times.
++
+By default, unset (no request URIs are excluded).
+
[[tracing.traceid.account]]tracing.<trace-id>.account::
+
Account ID of an account for which request tracing should be always
@@ -5413,7 +5427,9 @@
[[deadline.id.requestUriPattern]]deadline.<id>.requestUriPattern::
+
-Regular expression to match request URIs to which the deadline applies. Request
+Regular expression to match request URIs to which the deadline applies except if
+they match
+link:#deadline.id.excludedRequestUriPattern[excludedRequestUriPattern]. Request
URIs are only available for REST requests. Request URIs never include the '/a'
prefix.
+
@@ -5421,6 +5437,17 @@
+
By default, unset (all request URIs are matched).
+[[deadline.id.excludedRequestUriPattern]]deadline.<id>.excludedRequestUriPattern::
++
+Regular expression to match request URIs to which the deadline should not be
+applied even if they match
+link:#deadline.id.requestUriPattern[requestUriPattern]. Request URIs are only
+available for REST requests. Request URIs never include the '/a' prefix.
++
+May be specified multiple times.
++
+By default, unset (no request URIs are excluded).
+
[[deadline.id.account]]deadline.<id>.account::
+
Account ID of an account to which the deadline applies.
@@ -5610,7 +5637,7 @@
Email address that Gerrit refers to itself as when it creates a
new Git commit, such as a merge commit during change submission.
+
-If not set, Gerrit generates this as "gerrit@`hostname`", where
+If not set, Gerrit generates this as "gerrit@``hostname``", where
`hostname` is the hostname of the system Gerrit is running on.
+
By default, not set, generating the value at startup.
diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt
index 8f36cfb..36b3473 100644
--- a/Documentation/metrics.txt
+++ b/Documentation/metrics.txt
@@ -12,35 +12,121 @@
* `build/label`: Version of Gerrit server software.
* `events`: Triggered events.
+** `type`:
+ The type of the event.
=== Actions
* `action/retry_attempt_count`: Number of retry attempts made
-by RetryHelper to execute an action (0 == single attempt, no retry)
+ by RetryHelper to execute an action (0 == single attempt, no retry)
+** `action_type`:
+ The type of the action that was retried.
+** `operation_name`:
+ The name of the operation that was retried.
+** `cause`:
+ The original cause that triggered the retry.
* `action/retry_timeout_count`: Number of action executions of RetryHelper
-that ultimately timed out
+ that ultimately timed out
+** `action_type`:
+ The type of the action that was retried.
+** `operation_name`:
+ The name of the operation that was retried.
+** `cause`:
+ The original cause that triggered the retry.
* `action/auto_retry_count`: Number of automatic retries with tracing
+** `action_type`:
+ The type of the action that was retried.
+** `operation_name`:
+ The name of the operation that was retried.
+** `cause`:
+ The cause for the retry.
* `action/failures_on_auto_retry_count`: Number of failures on auto retry
+** `action_type`:
+ The type of the action that was retried.
+** `operation_name`:
+ The name of the operation that was retried.
+** `cause`:
+ The cause for the retry.
[[cancellations]]
=== Cancellations
* `cancellation/advisory_deadline_count`: Exceeded advisory deadlines by request
+** `request_type`:
+ The type of the request to which the advisory deadline applied.
+** `request_uri`:
+ The redacted URI of the request to which the advisory deadline applied (only
+ set for request_type = REST).
+** `deadline_id`:
+ The ID of the advisory deadline.
* `cancellation/cancelled_requests_count`: Number of request cancellations by
request
+** `request_type`:
+ The type of the request that was cancelled.
+** `request_uri`:
+ The redacted URI of the request that was cancelled (only set for
+ request_type = REST).
+** `cancellation_reason`:
+ The reason why the request was cancelled.
* `cancellation/receive_timeout_count`: Number of requests that are cancelled
because link:config.html#receive.timeout[receive.timout] is exceeded
+** `cancellation_type`:
+ The cancellation type (graceful or forceful).
+
+[[performance]]
+=== Performance
+
+* `performance/operations`: Latency of performing operations
+** `operation_name`:
+ The operation that was performed.
+** `change_identifier`:
+ The ID of the change for which the operation was performed (format =
+ '<project>~<numeric-change-id>').
+** `trace_id`:
+ The ID of the trace if tracing was done.
+* `performance/operations_count`: Number of performed operations
+** `operation_name`:
+ The operation that was performed.
+** `trace_id`:
+ The ID of the trace if tracing was done.
+** `request`:
+ The request for which the operation was performed (format = '<request-type>
+ <redacted-request-uri>').
+* `performance/plugin_operations_count`: Number of performed operations by
+ plugin
+** `operation_name`:
+ The operation that was performed.
+** `plugin`:
+ The name of the plugin that performed the operation.
+** `trace_id`:
+ The ID of the trace if tracing was done.
+
=== Pushes
-* `receivecommits/changes`: histogram of number of changes processed
-in a single upload, split up by update type (change created/updated,
-change autoclosed).
-* `receivecommits/latency`: latency per change for processing a push,
-split up by update type (create+replace, and autoclose)
-* `receivecommits/push_latency`: total latency for processing a push,
-split up by update type (create+replace, autoclose, normal)
-* `receivecommits/timeout`: number of timeouts during push processing.
+* `receivecommits/changes`: histogram of number of changes processed in a single
+ upload
+** `type`:
+ type of push (create/replace, autoclose)
+* `receivecommits/latency_per_push`: processing delay for a processing single
+ push
+** `type`:
+ type of push (create/replace, autoclose, normal)
+* `receivecommits/latency_per_push_per_change`: Processing delay per push
+ divided by the number of changes in said push. (Only includes pushes which
+ contain changes.)
+** `type`:
+ type of push (create/replace, autoclose, normal)
+* `receivecommits/timeout`: rate of push timeouts
+* `receivecommits/ps_revision_missing`: errors due to patch set revision missing
+* `receivecommits/push_count`: number of pushes
+** `kind`:
+ The push kind (direct vs. magic).
+** `project`:
+ The name of the project for which the push is done.
+** `type`:
+ The type of the update (CREATE, UPDATE, CREATE/UPDATE, UPDATE_NONFASTFORWARD,
+ DELETE).
=== Process
@@ -58,27 +144,58 @@
* `proc/jvm/memory/object_pending_finalization_count`: Approximate number of
objects needing finalization.
* `proc/jvm/gc/count`: Number of GCs.
+** `gc_name`:
+ The name of the garbage collector.
* `proc/jvm/gc/time`: Approximate accumulated GC elapsed time.
-* `proc/jvm/memory/pool/committed/<pool name>`: Committed amount of memory for pool.
-* `proc/jvm/memory/pool/max/<pool name>`: Maximum amount of memory for pool.
-* `proc/jvm/memory/pool/used/<pool name>`: Used amount of memory for pool.
+** `gc_name`:
+ The name of the garbage collector.
+* `proc/jvm/memory/pool/committed`: Committed amount of memory for pool.
+** `pool_name`:
+ The name of the memory pool.
+* `proc/jvm/memory/pool/max`: Maximum amount of memory for pool.
+** `pool_name`:
+ The name of the memory pool.
+* `proc/jvm/memory/pool/used`: Used amount of memory for pool.
+** `pool_name`:
+ The name of the memory pool.
* `proc/jvm/thread/num_live`: Current live thread count.
* `proc/jvm/thread/num_daemon_live`: Current live daemon threads count.
-* `proc/jvm/thread/num_peak_live`: Peak live thread count since the Java virtual machine started or peak was reset.
-* `proc/jvm/thread/num_total_started`: Total number of threads created and also started since the Java virtual machine started.
-* `proc/jvm/thread/num_deadlocked_threads`: Number of threads that are deadlocked waiting for object monitors or ownable synchronizers.
- If deadlocks waiting for ownable synchronizers can be monitored depends on the capabilities of the used JVM.
+* `proc/jvm/thread/num_peak_live`: Peak live thread count since the Java virtual
+ machine started or peak was reset.
+* `proc/jvm/thread/num_total_started`: Total number of threads created and also
+ started since the Java virtual machine started.
+* `proc/jvm/thread/num_deadlocked_threads`: Number of threads that are
+ deadlocked waiting for object monitors or ownable synchronizers.
+ If deadlocks waiting for ownable synchronizers can be monitored depends on the
+ capabilities of the used JVM.
=== Caches
* `caches/memory_cached`: Memory entries.
+** `cache_name`:
+ The name of the cache.
* `caches/memory_hit_ratio`: Memory hit ratio.
+** `cache_name`:
+ The name of the cache.
* `caches/memory_eviction_count`: Memory eviction count.
+** `cache_name`:
+ The name of the cache.
* `caches/disk_cached`: Disk entries used by persistent cache.
+** `cache_name`:
+ The name of the cache.
* `caches/disk_hit_ratio`: Disk hit ratio for persistent cache.
-* `caches/refresh_count`: The number of refreshes per cache with an indicator if a reload was necessary.
-* `caches/diff/timeouts`: The number of git file diff computations that resulted in timeouts.
-* `caches/diff/legacy/timeouts`: The number of git file diff computations (using the legacy cache) that resulted in timeouts.
+** `cache_name`:
+ The name of the cache.
+* `caches/refresh_count`: The number of refreshes per cache with an indicator if
+ a reload was necessary.
+** `cache`:
+ The name of the cache.
+** `outdated`:
+ Whether the cache entry was outdated on reload.
+* `caches/diff/timeouts`: The number of git file diff computations that resulted
+ in timeouts.
+* `caches/diff/legacy/timeouts`: The number of git file diff computations (using
+ the legacy cache) that resulted in timeouts.
Cache disk metrics are expensive to compute on larger installations and are not
computed by default. They can be enabled via the
@@ -87,65 +204,110 @@
=== Change
-* `change/submit_rule_evaluation`: Latency for evaluating submit rules on a change.
-* `change/submit_type_evaluation`: Latency for evaluating the submit type on a change.
+* `change/submit_rule_evaluation`: Latency for evaluating submit rules on a
+ change.
+* `change/submit_type_evaluation`: Latency for evaluating the submit type on a
+ change.
+* `change/post_review/draft_handling`: Total number of draft handling option
+ (KEEP, PUBLISH, PUBLISH_ALL_REVISIONS) selected by users while posting a
+ review.
+** `type`:
+ The type of the draft handling option (KEEP, PUBLISH, PUBLISH_ALL_REVISIONS).
=== Comments
-* `ported_comments/as_patchset_level`: Total number of comments ported as patchset-level comments.
-* `ported_comments/as_file_level`: Total number of comments ported as file-level comments.
-* `ported_comments/as_range_comments`: Total number of comments having line/range values in the ported patchset.
+* `ported_comments/as_patchset_level`: Total number of comments ported as
+ patchset-level comments.
+* `ported_comments/as_file_level`: Total number of comments ported as file-level
+ comments.
+* `ported_comments/as_range_comments`: Total number of comments having
+ line/range values in the ported patchset.
=== HTTP
==== Jetty
-* `http/server/jetty/connections/connections`: The current number of open connections
-* `http/server/jetty/connections/connections_total`: The total number of connections opened
-* `http/server/jetty/connections/connections_duration_max`: The max duration of a connection in ms
-* `http/server/jetty/connections/connections_duration_mean`: The mean duration of a connection in ms
-* `http/server/jetty/connections/connections_duration_stdev`: The standard deviation of the duration of a connection in ms
-* `http/server/jetty/connections/received_messages`: The total number of messages received
-* `http/server/jetty/connections/sent_messages`: The total number of messages sent
-* `http/server/jetty/connections/received_bytes`: Total number of bytes received by tracked connections
-* `http/server/jetty/connections/sent_bytes`: Total number of bytes sent by tracked connections"
+* `http/server/jetty/connections/connections`: The current number of open
+ connections
+* `http/server/jetty/connections/connections_total`: The total number of
+ connections opened
+* `http/server/jetty/connections/connections_duration_max`: The max duration of
+ a connection in ms
+* `http/server/jetty/connections/connections_duration_mean`: The mean duration
+ of a connection in ms
+* `http/server/jetty/connections/connections_duration_stdev`: The standard
+ deviation of the duration of a connection in ms
+* `http/server/jetty/connections/received_messages`: The total number of
+ messages received
+* `http/server/jetty/connections/sent_messages`: The total number of messages
+ sent
+* `http/server/jetty/connections/received_bytes`: Total number of bytes received
+ by tracked connections
+* `http/server/jetty/connections/sent_bytes`: Total number of bytes sent by
+ tracked connections
* `http/server/jetty/threadpool/active_threads`: Active threads
* `http/server/jetty/threadpool/idle_threads`: Idle threads
* `http/server/jetty/threadpool/reserved_threads`: Reserved threads
* `http/server/jetty/threadpool/max_pool_size`: Maximum thread pool size
* `http/server/jetty/threadpool/min_pool_size`: Minimum thread pool size
* `http/server/jetty/threadpool/pool_size`: Current thread pool size
-* `http/server/jetty/threadpool/queue_size`: Queued requests waiting for a thread
+* `http/server/jetty/threadpool/queue_size`: Queued requests waiting for a
+ thread
+* `http/server/jetty/threadpool/is_low_on_threads`: Whether thread pool is low
+ on threads
==== LDAP
* `ldap/login_latency`: Latency of logins.
* `ldap/user_search_latency`: Latency for searching the user account.
-* `ldap/group_search_latency`: Latency for querying the group memberships of an account.
+* `ldap/group_search_latency`: Latency for querying the group memberships of an
+ account.
* `ldap/group_expansion_latency`: Latency for expanding nested groups.
==== REST API
* `http/server/error_count`: Rate of REST API error responses.
+** `status`:
+ HTTP status code
* `http/server/success_count`: Rate of REST API success responses.
+** `status`:
+ HTTP status code
* `http/server/rest_api/count`: Rate of REST API calls by view.
+** `view`:
+ view implementation class
* `http/server/rest_api/change_id_type`: Rate of REST API calls by change ID type.
+** `change_id_type`:
+ The type of the change identifier.
* `http/server/rest_api/error_count`: Rate of REST API calls by view.
+** `view`:
+ view implementation class
+** `error_code`:
+ HTTP status code
+** `cause`:
+ The cause of the error.
* `http/server/rest_api/server_latency`: REST API call latency by view.
+** `view`:
+ view implementation class
* `http/server/rest_api/response_bytes`: Size of REST API response on network
-(may be gzip compressed) by view.
+ (may be gzip compressed) by view.
+** `view`:
+ view implementation class
* `http/server/rest_api/change_json/to_change_info_latency`: Latency for
-toChangeInfo invocations in ChangeJson.
+ toChangeInfo invocations in ChangeJson.
* `http/server/rest_api/change_json/to_change_infos_latency`: Latency for
-toChangeInfos invocations in ChangeJson.
+ toChangeInfos invocations in ChangeJson.
* `http/server/rest_api/change_json/format_query_results_latency`: Latency for
-formatQueryResults invocations in ChangeJson.
-* `http/server/rest_api/ui_actions/latency`: Latency for RestView#getDescription calls.
+ formatQueryResults invocations in ChangeJson.
+* `http/server/rest_api/ui_actions/latency`: Latency for RestView#getDescription
+ calls.
+** `view`:
+ view implementation class
=== Query
* `query/query_latency`: Successful query latency, accumulated over the life
-of the process.
+ of the process.
+** `index`: index name
=== Core Queues
@@ -164,11 +326,15 @@
Each queue provides the following metrics:
* `queue/<queue_name>/pool_size`: Current number of threads in the pool
-* `queue/<queue_name>/max_pool_size`: Maximum allowed number of threads in the pool
-* `queue/<queue_name>/active_threads`: Number of threads that are actively executing tasks
+* `queue/<queue_name>/max_pool_size`: Maximum allowed number of threads in the
+ pool
+* `queue/<queue_name>/active_threads`: Number of threads that are actively
+ executing tasks
* `queue/<queue_name>/scheduled_tasks`: Number of scheduled tasks in the queue
-* `queue/<queue_name>/total_scheduled_tasks_count`: Total number of tasks that have been scheduled
-* `queue/<queue_name>/total_completed_tasks_count`: Total number of tasks that have completed execution
+* `queue/<queue_name>/total_scheduled_tasks_count`: Total number of tasks that
+ have been scheduled
+* `queue/<queue_name>/total_completed_tasks_count`: Total number of tasks that
+ have completed execution
=== SSH sessions
@@ -180,7 +346,7 @@
* `topic/cross_project_submit`: number of cross-project topic submissions.
* `topic/cross_project_submit_completed`: number of cross-project
-topic submissions that concluded successfully.
+ topic submissions that concluded successfully.
=== JGit
@@ -197,23 +363,34 @@
* `load_success_count` : Successful cache loads for JGit block cache.
* `miss_count` : Cache misses for JGit block cache.
* `miss_ratio` : Cache miss ratio for JGit block cache.
-* `cache_used_per_repository` : Bytes of memory retained per repository for the top N repositories
-having most data in the cache. The number N of reported repositories is limited to 1000.
+* `cache_used_per_repository` : Bytes of memory retained per repository for the
+ top N repositories having most data in the cache. The number N of reported
+ repositories is limited to 1000.
+** `repository_name`: The name of the repository.
=== Git
* `git/upload-pack/request_count`: Total number of git-upload-pack requests.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/upload-pack/phase_counting`: Time spent in the 'Counting...' phase.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/upload-pack/phase_compressing`: Time spent in the 'Compressing...' phase.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/upload-pack/phase_writing`: Time spent transferring bytes to client.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/upload-pack/pack_bytes`: Distribution of sizes of packs sent to clients.
+** `operation`:
+ The name of the operation (CLONE, FETCH).
* `git/auto-merge/num_operations`: Number of auto merge operations and context.
+** `operation`:
+ The type of the operation (CACHE_LOAD, IN_MEMORY_WRITE, ON_DISK_WRITE).
* `git/auto-merge/latency`: Latency of auto merge operations and context.
-
-=== BatchUpdate
-
-* `batch_update/execute_change_ops`: BatchUpdate change update latency,
-excluding reindexing
+** `operation`:
+ The type of the operation (CACHE_LOAD, IN_MEMORY_WRITE, ON_DISK_WRITE).
=== NoteDb
@@ -223,43 +400,63 @@
* `notedb/parse_latency`: NoteDb parse latency for changes.
* `notedb/external_id_cache_load_count`: Total number of times the external ID
cache loader was called.
-* `notedb/external_id_partial_read_latency`: Latency for generating a new external ID
- cache state from a prior state.
+** `partial`:
+ Whether the reload was partial.
+* `notedb/external_id_partial_read_latency`: Latency for generating a new
+ external ID cache state from a prior state.
* `notedb/external_id_update_count`: Total number of external ID updates.
* `notedb/read_all_external_ids_latency`: Latency for reading all
-external ID's from NoteDb.
+ external ID's from NoteDb.
* `notedb/read_single_account_config_latency`: Latency for reading a single
-account config from NoteDb.
+ account config from NoteDb.
* `notedb/read_single_external_id_latency`: Latency for reading a single
-external ID from NoteDb.
+ external ID from NoteDb.
=== Permissions
-* `permissions/permission_collection/filter_latency`: Latency to filter access sections
-by user and ref.
+* `permissions/permission_collection/filter_latency`: Latency for access filter
+ computations in PermissionCollection
* `permissions/ref_filter/full_filter_count`: Rate of full ref filter operations
-* `permissions/ref_filter/skip_filter_count`: Rate of ref filter operations where
-we skip full evaluation because the user can read all refs
+* `permissions/ref_filter/skip_filter_count`: Rate of ref filter operations
+ where we skip full evaluation because the user can read all refs
=== Reviewer Suggestion
* `reviewer_suggestion/query_accounts`: Latency for querying accounts for
-reviewer suggestion.
+ reviewer suggestion.
* `reviewer_suggestion/recommend_accounts`: Latency for recommending accounts
-for reviewer suggestion.
+ for reviewer suggestion.
* `reviewer_suggestion/load_accounts`: Latency for loading accounts for
-reviewer suggestion.
+ reviewer suggestion.
* `reviewer_suggestion/query_groups`: Latency for querying groups for reviewer
-suggestion.
+ suggestion.
+* `reviewer_suggestion/filter_visibility`: Latency for removing users that can't
+ see the change
=== Repo Sequences
* `sequence/next_id_latency`: Latency of requesting IDs from repo sequences.
+** `sequence`:
+ The sequence from which IDs were retrieved.
+** `multiple`:
+ Whether more than one ID was retrieved.
=== Plugin
* `plugin/latency`: Latency for plugin invocation.
+** `plugin_name`"
+ The name of the plugin.
+** `class`:
+ The class of the plugin that was invoked.
+** `export_value`:
+ The export name under which the invoked class is registered.
* `plugin/error_count`: Number of plugin errors.
+** `plugin_name`"
+ The name of the plugin.
+** `class`:
+ The class of the plugin that was invoked.
+** `export_value`:
+ The export name under which the invoked class is registered.
=== Group
@@ -268,11 +465,19 @@
=== Replication Plugin
* `plugins/replication/replication_latency`: Time spent pushing to remote
-destination.
+ destination.
+** `destination`: The destination of the replication.
* `plugins/replication/replication_delay`: Time spent waiting before pushing to
-remote destination.
+ remote destination.
+** `destination`: The destination of the replication.
* `plugins/replication/replication_retries`: Number of retries when pushing to
-remote destination.
+ remote destination.
+** `destination`: The destination of the replication.
+* `plugins/replication/latency_slower_than_threshold`: latency for project to
+ destination, where latency was slower than threshold
+** `slow_threshold`: The threshold.
+** `project`: The name of the project.
+** `destination`: The destination of the replication.
=== License
diff --git a/Documentation/rest-api-accounts.txt b/Documentation/rest-api-accounts.txt
index a613c7e..ae0c0a6 100644
--- a/Documentation/rest-api-accounts.txt
+++ b/Documentation/rest-api-accounts.txt
@@ -1343,6 +1343,7 @@
"time_format": "HHMM_12",
"size_bar_in_change_table": true,
"disable_keyboard_shortcuts": true,
+ "disable_token_highlighting": true,
"diff_view": "SIDE_BY_SIDE",
"mute_common_path_prefixes": true,
"my": [
@@ -1394,6 +1395,7 @@
"diff_view": "SIDE_BY_SIDE",
"publish_comments_on_push": true,
"disable_keyboard_shortcuts": true,
+ "disable_token_highlighting": true,
"work_in_progress_by_default": true,
"mute_common_path_prefixes": true,
"my": [
@@ -2704,6 +2706,8 @@
Allowed values are `AUTO_MERGE` and `FIRST_PARENT`.
|`disable_keyboard_shortcuts` |not set if `false`|
Whether to disable all keyboard shortcuts.
+|`disable_token_highlighting` [not set if `false`]
+Whether to disable token highlighting on hover.
|`publish_comments_on_push` |not set if `false`|
Whether to link:user-upload.html#publish-comments[publish draft comments] on
push by default.
diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt
index 2b6796b..d83ef0e 100644
--- a/Documentation/rest-api-changes.txt
+++ b/Documentation/rest-api-changes.txt
@@ -600,8 +600,9 @@
----
As a response, two link:#change-info[ChangeInfo] entities are returned
-that describe information added and removed from the `old` change state.
-Only fields that differ between the change's two states are returned.
+that describe information added and removed from the `old` change state, and
+the two link:#change-info[ChangeInfo] entities that generated the diff are
+returned. Only fields that differ between the change's two states are returned.
.Response
----
@@ -625,9 +626,55 @@
"topic": "new-topic"
},
"removed": {
- "updated": "2013-02-20 12:05:34.111000000",
+ "updated": "2013-02-01 09:59:32.126000000",
"topic": "old-topic"
- }
+ },
+ "old_change_info": {
+ "id": "myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940",
+ "project": "myProject",
+ "branch": "master",
+ "attention_set": [],
+ "change_id": "I8473b95934b5732ac55d26311a706c9c2bde9940",
+ "subject": "Implementing Feature X",
+ "status": "NEW",
+ "topic": "old-topic",
+ "created": "2013-02-01 09:59:32.126000000",
+ "updated": "2013-02-01 09:59:32.126000000",
+ "mergeable": true,
+ "insertions": 34,
+ "deletions": 101,
+ "_number": 3965,
+ "owner": {
+ "name": "John Doe"
+ }
+ },
+ "new_change_info": {
+ "id": "myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940",
+ "project": "myProject",
+ "branch": "master",
+ "attention_set": [
+ {
+ "account": {
+ "name": "John Doe"
+ },
+ "last_update": "2013-02-21 11:16:36.775000000",
+ "reason": "reviewer or cc replied"
+ }
+ ],
+ "change_id": "I8473b95934b5732ac55d26311a706c9c2bde9940",
+ "subject": "Implementing Feature X",
+ "status": "NEW",
+ "topic": "new-topic",
+ "created": "2013-02-01 09:59:32.126000000",
+ "updated": "2013-02-21 11:16:36.775000000",
+ "mergeable": true,
+ "insertions": 34,
+ "deletions": 101,
+ "_number": 3965,
+ "owner": {
+ "name": "John Doe"
+ }
+ },
}
----
@@ -3228,6 +3275,8 @@
* are visible to the calling user
* are not already reviewer on the change
* don't own the change
+* are not service users (unless
+ link:config.html#suggest.skipServiceUsers[skipServiceUsers] is set to `false`)
Groups can be excluded from the results by specifying the 'exclude-groups'
request parameter:
@@ -6486,6 +6535,9 @@
Actions the caller might be able to perform on this revision. The
information is a map of view name to link:#action-info[ActionInfo]
entities.
+|`submit_records` ||
+List of the link:rest-api-changes.html#submit-record-info[SubmitRecordInfo]
+containing the submit records for the change at the latest patchset.
|`requirements` |optional|
List of the link:rest-api-changes.html#requirement[requirements] to be met before this change
can be submitted. This field is deprecated in favour of `submit_requirements`.
@@ -8127,6 +8179,37 @@
the failure of the rule predicate.
|===========================
+[[submit-record-info]]
+=== SubmitRecordInfo
+The `SubmitRecordInfo` entity describes results from a submit_rule.
+
+[options="header",cols="1,^1,5"]
+|===========================
+|Field Name ||Description
+|`rule_name`||
+The name of the submit rule that created this submit record. The submit rule is
+specified in the form of "$plugin~$rule" where `$plugin` is the plugin name
+and `$rule` is the name of the class that implemented the submit rule.
+|`status`||
+`OK`, the change can be submitted. +
+`NOT_READY`, additional labels are required before submit. +
+`CLOSED`, closed changes cannot be submitted. +
+`FORCED`, the change was submitted bypassing the submit rule. +
+`RULE_ERROR`, rule code failed with an error.
+|`labels`|optional|
+A list of labels, each containing the following fields. +
+ * `label`: the label name. +
+ * `status`: the label status: {`OK`, `REJECT`, `MAY`, `NEED`, `IMPOSSIBLE`}. +
+ * `appliedBy`: the link:rest-api-accounts.html#account-info[AccountInfo]
+ that applied the vote to the label.
+|`requirements`|optional|
+List of the link:rest-api-changes.html#requirement[requirements] to be met
+before this change can be submitted.
+|`error_message`|optional|
+When status is RULE_ERROR this message provides some text describing
+the failure of the rule predicate.
+|===========================
+
[[submit-requirement-expression-info]]
=== SubmitRequirementExpressionInfo
The `SubmitRequirementExpressionInfo` describes the result of evaluating a
diff --git a/Documentation/user-search.txt b/Documentation/user-search.txt
index 2ebe6bd..3977278 100644
--- a/Documentation/user-search.txt
+++ b/Documentation/user-search.txt
@@ -427,6 +427,11 @@
+
True if the change has unresolved comments.
+has:attention::
++
+True if the change has attention by the current user.
+
+
[[is]]
is:assigned::
+
@@ -442,6 +447,10 @@
+
True if the change does not have an assignee.
+is:attention::
++
+True if the change has attention by the current user.
+
is:watched::
+
True if this change matches one of the current user's watch filters,
@@ -728,6 +737,10 @@
to one of the fields in the
link:rest-api-changes.html#submit-record[SubmitRecord] REST API entity.
+`label:Code-Review\<=-1`::
++
+Matches changes with either a -1, -2, or any lower score.
+
`label:Code-Review=MAX`::
+
Matches changes with label voted with the highest possible score.
@@ -778,10 +791,6 @@
Matches changes with a +1 code review where the reviewer is in the
ldap/linux.workflow group.
-`label:Code-Review\<=-1`::
-+
-Matches changes with either a -1, -2, or any lower score.
-
`is:open label:Code-Review+2 label:Verified+1 NOT label:Verified-1 NOT label:Code-Review-2`::
`is:open label:Code-Review=ok label:Verified=ok`::
+
diff --git a/WORKSPACE b/WORKSPACE
index 5c38224..93cae7d 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -922,7 +922,6 @@
yarn_install(
name = "npm",
- data = ["//:twinkie.patch"],
frozen_lockfile = False,
package_json = "//:package.json",
package_path = "",
diff --git a/java/com/google/gerrit/acceptance/ExtensionRegistry.java b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
index 85c4c13..1e5598e 100644
--- a/java/com/google/gerrit/acceptance/ExtensionRegistry.java
+++ b/java/com/google/gerrit/acceptance/ExtensionRegistry.java
@@ -25,6 +25,8 @@
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
import com.google.gerrit.extensions.events.GroupIndexedListener;
import com.google.gerrit.extensions.events.ProjectIndexedListener;
+import com.google.gerrit.extensions.events.ReviewerAddedListener;
+import com.google.gerrit.extensions.events.ReviewerDeletedListener;
import com.google.gerrit.extensions.events.RevisionCreatedListener;
import com.google.gerrit.extensions.events.TopicEditedListener;
import com.google.gerrit.extensions.events.WorkInProgressStateChangedListener;
@@ -91,6 +93,8 @@
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
private final DynamicSet<PluginPushOption> pluginPushOptions;
private final DynamicSet<OnPostReview> onPostReviews;
+ private final DynamicSet<ReviewerAddedListener> reviewerAddedListeners;
+ private final DynamicSet<ReviewerDeletedListener> reviewerDeletedListeners;
@Inject
ExtensionRegistry(
@@ -125,7 +129,9 @@
DynamicMap<PluginProjectPermissionDefinition> pluginProjectPermissionDefinitions,
DynamicMap<ProjectConfigEntry> pluginConfigEntries,
DynamicSet<PluginPushOption> pluginPushOption,
- DynamicSet<OnPostReview> onPostReviews) {
+ DynamicSet<OnPostReview> onPostReviews,
+ DynamicSet<ReviewerAddedListener> reviewerAddedListeners,
+ DynamicSet<ReviewerDeletedListener> reviewerDeletedListeners) {
this.accountIndexedListeners = accountIndexedListeners;
this.changeIndexedListeners = changeIndexedListeners;
this.groupIndexedListeners = groupIndexedListeners;
@@ -158,6 +164,8 @@
this.pluginConfigEntries = pluginConfigEntries;
this.pluginPushOptions = pluginPushOption;
this.onPostReviews = onPostReviews;
+ this.reviewerAddedListeners = reviewerAddedListeners;
+ this.reviewerDeletedListeners = reviewerDeletedListeners;
}
public Registration newRegistration() {
@@ -302,6 +310,14 @@
return add(onPostReviews, onPostReview);
}
+ public Registration add(ReviewerAddedListener reviewerAddedListener) {
+ return add(reviewerAddedListeners, reviewerAddedListener);
+ }
+
+ public Registration add(ReviewerDeletedListener reviewerDeletedListener) {
+ return add(reviewerDeletedListeners, reviewerDeletedListener);
+ }
+
private <T> Registration add(DynamicSet<T> dynamicSet, T extension) {
return add(dynamicSet, extension, "gerrit");
}
diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java
index 9732d2c..4d87f4d 100644
--- a/java/com/google/gerrit/acceptance/GerritServer.java
+++ b/java/com/google/gerrit/acceptance/GerritServer.java
@@ -293,7 +293,6 @@
* @param baseConfig default config values; merged with config from {@code desc} and then written
* into {@code site/etc/gerrit.config}.
* @param site temp directory where site will live.
- * @throws Exception
*/
public static void init(Description desc, Config baseConfig, Path site) throws Exception {
checkArgument(!desc.memory(), "can't initialize site path for in-memory test: %s", desc);
@@ -347,7 +346,6 @@
* @param testSysModule additional Guice module to use.
* @param testSshModule additional Guice module to use.
* @return started server.
- * @throws Exception
*/
public static GerritServer initAndStart(
TemporaryFolder temporaryFolder,
@@ -384,7 +382,6 @@
* @param additionalArgs additional command-line arguments for the daemon program; only allowed if
* the test is not in-memory.
* @return started server.
- * @throws Exception
*/
public static GerritServer start(
Description desc,
diff --git a/java/com/google/gerrit/acceptance/SshSessionMina.java b/java/com/google/gerrit/acceptance/SshSessionMina.java
index 4d8691b..3b0ba3b 100644
--- a/java/com/google/gerrit/acceptance/SshSessionMina.java
+++ b/java/com/google/gerrit/acceptance/SshSessionMina.java
@@ -107,13 +107,11 @@
@Override
public int execAndReturnStatus(String command) throws Exception {
Process process = getMinaSession().exec(command, 0);
- InputStream in = process.getInputStream();
InputStream err = process.getErrorStream();
Scanner s = new Scanner(err, UTF_8.name()).useDelimiter("\\A");
error = s.hasNext() ? s.next() : null;
- s = new Scanner(in, UTF_8.name()).useDelimiter("\\A");
try {
return process.exitValue();
} catch (IllegalThreadStateException e) {
diff --git a/java/com/google/gerrit/acceptance/config/GlobalPluginConfig.java b/java/com/google/gerrit/acceptance/config/GlobalPluginConfig.java
index ae88e37..87063c9 100644
--- a/java/com/google/gerrit/acceptance/config/GlobalPluginConfig.java
+++ b/java/com/google/gerrit/acceptance/config/GlobalPluginConfig.java
@@ -28,12 +28,12 @@
/** Name of the plugin, corresponding to {@code $site/etc/@pluginName.config}. */
String pluginName();
- /** @see GerritConfig#name() */
+ /** See {@link GerritConfig#name()} */
String name();
- /** @see GerritConfig#value() */
+ /** See {@link GerritConfig#value()} */
String value() default "";
- /** @see GerritConfig#values() */
+ /** See {@link GerritConfig#values()} */
String[] values() default "";
}
diff --git a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
index 738be4d..2dd3f91 100644
--- a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
+++ b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
@@ -81,11 +81,11 @@
*
* <p>Example:
*
- * <pre>
+ * <pre>{@code
* projectOperations.forInvalidation()
* .addProjectConfigUpdater(cfg -> cfg.setString("invalidSection", null, "foo", "bar"))
* .invalidate();
- * </pre>
+ * }</pre>
*
* <p><strong>Note:</strong> The invalidation will fail with an exception if the project to
* invalidate doesn't exist.
diff --git a/java/com/google/gerrit/common/data/GitwebType.java b/java/com/google/gerrit/common/data/GitwebType.java
index 9cc408b..e69eacf 100644
--- a/java/com/google/gerrit/common/data/GitwebType.java
+++ b/java/com/google/gerrit/common/data/GitwebType.java
@@ -29,7 +29,7 @@
private char pathSeparator = '/';
private boolean urlEncode = true;
- /** @return name displayed in links. */
+ /** Returns name displayed in links. */
public String getLinkName() {
return name;
}
@@ -43,7 +43,7 @@
this.name = name;
}
- /** @return parameterized string for the branch URL. */
+ /** Returns parameterized string for the branch URL. */
public String getBranch() {
return branch;
}
@@ -57,7 +57,7 @@
branch = str;
}
- /** @return parameterized string for the tag URL. */
+ /** Returns parameterized string for the tag URL. */
public String getTag() {
return tag;
}
@@ -71,7 +71,7 @@
tag = str;
}
- /** @return parameterized string for the file URL. */
+ /** Returns parameterized string for the file URL. */
public String getFile() {
return file;
}
@@ -85,7 +85,7 @@
file = str;
}
- /** @return parameterized string for the file history URL. */
+ /** Returns parameterized string for the file history URL. */
public String getFileHistory() {
return fileHistory;
}
@@ -99,7 +99,7 @@
fileHistory = str;
}
- /** @return parameterized string for the project URL. */
+ /** Returns parameterized string for the project URL. */
public String getProject() {
return project;
}
@@ -113,7 +113,7 @@
project = str;
}
- /** @return parameterized string for the revision URL. */
+ /** Returns parameterized string for the revision URL. */
public String getRevision() {
return revision;
}
@@ -127,7 +127,7 @@
revision = str;
}
- /** @return parameterized string for the root tree URL. */
+ /** Returns parameterized string for the root tree URL. */
public String getRootTree() {
return rootTree;
}
@@ -141,7 +141,7 @@
rootTree = str;
}
- /** @return path separator used for branch and project names. */
+ /** Returns path separator used for branch and project names. */
public char getPathSeparator() {
return pathSeparator;
}
@@ -155,7 +155,7 @@
this.pathSeparator = separator;
}
- /** @return whether to URL encode path segments. */
+ /** Returns whether to URL encode path segments. */
public boolean getUrlEncode() {
return urlEncode;
}
diff --git a/java/com/google/gerrit/common/data/GlobalCapability.java b/java/com/google/gerrit/common/data/GlobalCapability.java
index 8bfd960..253266d 100644
--- a/java/com/google/gerrit/common/data/GlobalCapability.java
+++ b/java/com/google/gerrit/common/data/GlobalCapability.java
@@ -165,17 +165,17 @@
}
}
- /** @return all valid capability names. */
+ /** Returns all valid capability names. */
public static Collection<String> getAllNames() {
return Collections.unmodifiableList(NAMES_ALL);
}
- /** @return true if the name is recognized as a capability name. */
+ /** Returns true if the name is recognized as a capability name. */
public static boolean isGlobalCapability(String varName) {
return NAMES_LC.contains(varName.toLowerCase());
}
- /** @return true if the capability should have a range attached. */
+ /** Returns true if the capability should have a range attached. */
public static boolean hasRange(String varName) {
for (String n : RANGE_NAMES) {
if (n.equalsIgnoreCase(varName)) {
@@ -189,7 +189,7 @@
return Collections.unmodifiableList(Arrays.asList(RANGE_NAMES));
}
- /** @return the valid range for the capability if it has one, otherwise null. */
+ /** Returns the valid range for the capability if it has one, otherwise null. */
public static PermissionRange.WithDefaults getRange(String varName) {
if (QUERY_LIMIT.equalsIgnoreCase(varName)) {
return new PermissionRange.WithDefaults(
diff --git a/java/com/google/gerrit/elasticsearch/ElasticVersion.java b/java/com/google/gerrit/elasticsearch/ElasticVersion.java
index c6400df..b5bf44b 100644
--- a/java/com/google/gerrit/elasticsearch/ElasticVersion.java
+++ b/java/com/google/gerrit/elasticsearch/ElasticVersion.java
@@ -45,7 +45,6 @@
*
* @param version for which to return an ElasticVersion
* @return the corresponding ElasticVersion if supported
- * @throws UnsupportedVersion
*/
public static ElasticVersion forVersion(String version) {
for (ElasticVersion value : ElasticVersion.values()) {
diff --git a/java/com/google/gerrit/entities/AccessSection.java b/java/com/google/gerrit/entities/AccessSection.java
index d97bca8..69a234a 100644
--- a/java/com/google/gerrit/entities/AccessSection.java
+++ b/java/com/google/gerrit/entities/AccessSection.java
@@ -52,7 +52,7 @@
return new AutoValue_AccessSection.Builder().setName(name).setPermissions(ImmutableList.of());
}
- /** @return true if the name is likely to be a valid reference section name. */
+ /** Returns true if the name is likely to be a valid reference section name. */
public static boolean isValidRefSectionName(String name) {
return name.startsWith("refs/") || name.startsWith("^refs/");
}
diff --git a/java/com/google/gerrit/entities/AccountGroup.java b/java/com/google/gerrit/entities/AccountGroup.java
index 0b2a346..001a544 100644
--- a/java/com/google/gerrit/entities/AccountGroup.java
+++ b/java/com/google/gerrit/entities/AccountGroup.java
@@ -54,7 +54,7 @@
return uuid();
}
- /** @return true if the UUID is for a group managed within Gerrit. */
+ /** Returns true if the UUID is for a group managed within Gerrit. */
public boolean isInternalGroup() {
return get().matches("^[0-9a-f]{40}$");
}
diff --git a/java/com/google/gerrit/entities/Address.java b/java/com/google/gerrit/entities/Address.java
index 2324330..5d63476 100644
--- a/java/com/google/gerrit/entities/Address.java
+++ b/java/com/google/gerrit/entities/Address.java
@@ -15,6 +15,7 @@
package com.google.gerrit.entities;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.gerrit.common.Nullable;
/** Represents an address (name + email) in an email message. */
@@ -66,8 +67,9 @@
public abstract String email();
+ @Memoized
@Override
- public final int hashCode() {
+ public int hashCode() {
return email().hashCode();
}
diff --git a/java/com/google/gerrit/entities/GroupDescription.java b/java/com/google/gerrit/entities/GroupDescription.java
index e950257..7054bed 100644
--- a/java/com/google/gerrit/entities/GroupDescription.java
+++ b/java/com/google/gerrit/entities/GroupDescription.java
@@ -22,22 +22,22 @@
public class GroupDescription {
/** The Basic information required to be exposed by any Group. */
public interface Basic {
- /** @return the non-null UUID of the group. */
+ /** Returns the non-null UUID of the group. */
AccountGroup.UUID getGroupUUID();
- /** @return the non-null name of the group. */
+ /** Returns the non-null name of the group. */
String getName();
/**
- * @return optional email address to send to the group's members. If provided, Gerrit will use
- * this email address to send change notifications to the group.
+ * Returns optional email address to send to the group's members. If provided, Gerrit will use
+ * this email address to send change notifications to the group.
*/
@Nullable
String getEmailAddress();
/**
- * @return optional URL to information about the group. Typically a URL to a web page that
- * permits users to apply to join the group, or manage their membership.
+ * Returns optional URL to information about the group. Typically a URL to a web page that
+ * permits users to apply to join the group, or manage their membership.
*/
@Nullable
String getUrl();
diff --git a/java/com/google/gerrit/entities/GroupReference.java b/java/com/google/gerrit/entities/GroupReference.java
index 208ba0f..125153e 100644
--- a/java/com/google/gerrit/entities/GroupReference.java
+++ b/java/com/google/gerrit/entities/GroupReference.java
@@ -17,6 +17,7 @@
import static java.util.Objects.requireNonNull;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.gerrit.common.Nullable;
/** Describes a group within a projects {@link AccessSection}s. */
@@ -78,8 +79,9 @@
return "?";
}
+ @Memoized
@Override
- public final int hashCode() {
+ public int hashCode() {
return uuid(this).hashCode();
}
diff --git a/java/com/google/gerrit/entities/ImmutableConfig.java b/java/com/google/gerrit/entities/ImmutableConfig.java
index a5efc14..83a44d1 100644
--- a/java/com/google/gerrit/entities/ImmutableConfig.java
+++ b/java/com/google/gerrit/entities/ImmutableConfig.java
@@ -51,27 +51,27 @@
return cfg;
}
- /** @see Config#getSections() */
+ /** See {@link Config#getSections()} */
public Set<String> getSections() {
return cfg.getSections();
}
- /** @see Config#getNames(String) */
+ /** See {@link Config#getNames(String)} */
public Set<String> getNames(String section) {
return cfg.getNames(section);
}
- /** @see Config#getNames(String, String) */
+ /** See {@link Config#getNames(String, String)} */
public Set<String> getNames(String section, String subsection) {
return cfg.getNames(section, subsection);
}
- /** @see Config#getStringList(String, String, String) */
+ /** See {@link Config#getStringList(String, String, String)} */
public String[] getStringList(String section, String subsection, String name) {
return cfg.getStringList(section, subsection, name);
}
- /** @see Config#getSubsections(String) */
+ /** See {@link Config#getSubsections(String)} */
public Set<String> getSubsections(String section) {
return cfg.getSubsections(section);
}
diff --git a/java/com/google/gerrit/entities/NotifyConfig.java b/java/com/google/gerrit/entities/NotifyConfig.java
index 17da81f..5c0a3db 100644
--- a/java/com/google/gerrit/entities/NotifyConfig.java
+++ b/java/com/google/gerrit/entities/NotifyConfig.java
@@ -15,6 +15,7 @@
package com.google.gerrit.entities;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.common.Nullable;
@@ -106,8 +107,9 @@
return getName().compareTo(o.getName());
}
+ @Memoized
@Override
- public final int hashCode() {
+ public int hashCode() {
return getName().hashCode();
}
diff --git a/java/com/google/gerrit/entities/PatchSetApproval.java b/java/com/google/gerrit/entities/PatchSetApproval.java
index a4bb251..f853f77 100644
--- a/java/com/google/gerrit/entities/PatchSetApproval.java
+++ b/java/com/google/gerrit/entities/PatchSetApproval.java
@@ -41,7 +41,7 @@
}
public static Builder builder() {
- return new AutoValue_PatchSetApproval.Builder().postSubmit(false);
+ return new AutoValue_PatchSetApproval.Builder().postSubmit(false).copied(false);
}
@AutoValue.Builder
@@ -72,6 +72,8 @@
public abstract Builder postSubmit(boolean isPostSubmit);
+ public abstract Builder copied(boolean isCopied);
+
abstract PatchSetApproval autoBuild();
public PatchSetApproval build() {
@@ -111,10 +113,12 @@
public abstract boolean postSubmit();
+ public abstract boolean copied();
+
public abstract Builder toBuilder();
public PatchSetApproval copyWithPatchSet(PatchSet.Id psId) {
- return toBuilder().key(key(psId, key().accountId(), key().labelId())).build();
+ return toBuilder().key(key(psId, key().accountId(), key().labelId())).copied(true).build();
}
public PatchSet.Id patchSetId() {
diff --git a/java/com/google/gerrit/entities/Permission.java b/java/com/google/gerrit/entities/Permission.java
index 322c79e..95164bd 100644
--- a/java/com/google/gerrit/entities/Permission.java
+++ b/java/com/google/gerrit/entities/Permission.java
@@ -95,7 +95,7 @@
LABEL_AS_INDEX = NAMES_LC.indexOf(Permission.LABEL_AS.toLowerCase());
}
- /** @return true if the name is recognized as a permission name. */
+ /** Returns true if the name is recognized as a permission name. */
public static boolean isPermission(String varName) {
return isLabel(varName) || isLabelAs(varName) || NAMES_LC.contains(varName.toLowerCase());
}
@@ -104,22 +104,22 @@
return isLabel(varName) || isLabelAs(varName);
}
- /** @return true if the permission name is actually for a review label. */
+ /** Returns true if the permission name is actually for a review label. */
public static boolean isLabel(String varName) {
return varName.startsWith(LABEL) && LABEL.length() < varName.length();
}
- /** @return true if the permission is for impersonated review labels. */
+ /** Returns true if the permission is for impersonated review labels. */
public static boolean isLabelAs(String var) {
return var.startsWith(LABEL_AS) && LABEL_AS.length() < var.length();
}
- /** @return permission name for the given review label. */
+ /** Returns permission name for the given review label. */
public static String forLabel(String labelName) {
return LABEL + labelName;
}
- /** @return permission name to apply a label for another user. */
+ /** Returns permission name to apply a label for another user. */
public static String forLabelAs(String labelName) {
return LABEL_AS + labelName;
}
diff --git a/java/com/google/gerrit/entities/PermissionRange.java b/java/com/google/gerrit/entities/PermissionRange.java
index fa9f4c2..d283069 100644
--- a/java/com/google/gerrit/entities/PermissionRange.java
+++ b/java/com/google/gerrit/entities/PermissionRange.java
@@ -46,7 +46,7 @@
defaultMax = max;
}
- /** @return all values between {@link #getMin()} and {@link #getMax()} */
+ /** Returns all values between {@link #getMin()} and {@link #getMax()} */
public List<Integer> getValuesAsList() {
ArrayList<Integer> r = new ArrayList<>(getRangeSize());
for (int i = min; i <= max; i++) {
@@ -55,7 +55,7 @@
return r;
}
- /** @return number of values between {@link #getMin()} and {@link #getMax()} */
+ /** Returns number of values between {@link #getMin()} and {@link #getMax()} */
public int getRangeSize() {
return max - min;
}
diff --git a/java/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverter.java b/java/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverter.java
index 78a35ff..9e77025 100644
--- a/java/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverter.java
+++ b/java/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverter.java
@@ -39,7 +39,8 @@
.setKey(patchSetApprovalKeyProtoConverter.toProto(patchSetApproval.key()))
.setValue(patchSetApproval.value())
.setGranted(patchSetApproval.granted().getTime())
- .setPostSubmit(patchSetApproval.postSubmit());
+ .setPostSubmit(patchSetApproval.postSubmit())
+ .setCopied(patchSetApproval.copied());
patchSetApproval.tag().ifPresent(builder::setTag);
Account.Id realAccountId = patchSetApproval.realAccountId();
@@ -61,7 +62,8 @@
.key(patchSetApprovalKeyProtoConverter.fromProto(proto.getKey()))
.value(proto.getValue())
.granted(new Timestamp(proto.getGranted()))
- .postSubmit(proto.getPostSubmit());
+ .postSubmit(proto.getPostSubmit())
+ .copied(proto.getCopied());
if (proto.hasTag()) {
builder.tag(proto.getTag());
}
diff --git a/java/com/google/gerrit/extensions/BUILD b/java/com/google/gerrit/extensions/BUILD
index 21949f7..f36018b 100644
--- a/java/com/google/gerrit/extensions/BUILD
+++ b/java/com/google/gerrit/extensions/BUILD
@@ -34,6 +34,7 @@
"//java/com/google/gerrit/common:annotations",
"//lib:guava",
"//lib/auto:auto-value-annotations",
+ "//lib/errorprone:annotations",
"//lib/guice",
"//lib/guice:guice-assistedinject",
],
diff --git a/java/com/google/gerrit/extensions/api/accounts/Accounts.java b/java/com/google/gerrit/extensions/api/accounts/Accounts.java
index 15fca9a..285b385 100644
--- a/java/com/google/gerrit/extensions/api/accounts/Accounts.java
+++ b/java/com/google/gerrit/extensions/api/accounts/Accounts.java
@@ -38,7 +38,11 @@
*/
AccountApi id(String id) throws RestApiException;
- /** @see #id(String) */
+ /**
+ * Look up an account by ID. #id(String)
+ *
+ * <p>See #id(String)
+ */
AccountApi id(int id) throws RestApiException;
/**
diff --git a/java/com/google/gerrit/extensions/api/changes/ChangeApi.java b/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
index ab98aa6..690ba4e 100644
--- a/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
+++ b/java/com/google/gerrit/extensions/api/changes/ChangeApi.java
@@ -324,7 +324,6 @@
* Get hashtags on a change.
*
* @return hashtags
- * @throws RestApiException
*/
Set<String> getHashtags() throws RestApiException;
@@ -359,7 +358,6 @@
*
* @return comments in a map keyed by path; comments have the {@code revision} field set to
* indicate their patch set.
- * @throws RestApiException
* @deprecated Callers should use {@link #commentsRequest()} instead
*/
@Deprecated
@@ -372,7 +370,6 @@
*
* @return comments as a list; comments have the {@code revision} field set to indicate their
* patch set.
- * @throws RestApiException
* @deprecated Callers should use {@link #commentsRequest()} instead
*/
@Deprecated
@@ -393,7 +390,6 @@
*
* @return robot comments in a map keyed by path; robot comments have the {@code revision} field
* set to indicate their patch set.
- * @throws RestApiException
*/
Map<String, List<RobotCommentInfo>> robotComments() throws RestApiException;
@@ -402,7 +398,6 @@
*
* @return drafts in a map keyed by path; comments have the {@code revision} field set to indicate
* their patch set.
- * @throws RestApiException
*/
default Map<String, List<CommentInfo>> drafts() throws RestApiException {
return draftsRequest().get();
@@ -413,7 +408,6 @@
*
* @return drafts as a list; comments have the {@code revision} field set to indicate their patch
* set.
- * @throws RestApiException
*/
default List<CommentInfo> draftsAsList() throws RestApiException {
return draftsRequest().getAsList();
@@ -443,7 +437,6 @@
* Get all messages of a change with detailed account info.
*
* @return a list of messages sorted by their creation time.
- * @throws RestApiException
*/
List<ChangeMessageInfo> messages() throws RestApiException;
@@ -466,7 +459,6 @@
*
* @return comments in a map keyed by path; comments have the {@code revision} field set to
* indicate their patch set.
- * @throws RestApiException
*/
public abstract Map<String, List<CommentInfo>> get() throws RestApiException;
diff --git a/java/com/google/gerrit/extensions/api/changes/FileApi.java b/java/com/google/gerrit/extensions/api/changes/FileApi.java
index 26f9452..e20ac56 100644
--- a/java/com/google/gerrit/extensions/api/changes/FileApi.java
+++ b/java/com/google/gerrit/extensions/api/changes/FileApi.java
@@ -29,10 +29,18 @@
/** Diff against the revision's parent version of the file. */
DiffInfo diff() throws RestApiException;
- /** @param base revision id of the revision to be used as the diff base */
+ /**
+ * Diff against the specified base
+ *
+ * @param base revision id of the revision to be used as the diff base
+ */
DiffInfo diff(String base) throws RestApiException;
- /** @param parent 1-based parent number to diff against */
+ /**
+ * Diff against the specified parent
+ *
+ * @param parent 1-based parent number to diff against
+ */
DiffInfo diff(int parent) throws RestApiException;
/**
diff --git a/java/com/google/gerrit/extensions/api/changes/RevisionApi.java b/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
index 229b9d4..1307516 100644
--- a/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
+++ b/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
@@ -160,7 +160,6 @@
*
* @param format the format of the archive
* @return the archive as {@link BinaryResult}
- * @throws RestApiException
*/
BinaryResult getArchive(ArchiveFormat format) throws RestApiException;
diff --git a/java/com/google/gerrit/extensions/api/config/Config.java b/java/com/google/gerrit/extensions/api/config/Config.java
index eb7288d..041e1dd 100644
--- a/java/com/google/gerrit/extensions/api/config/Config.java
+++ b/java/com/google/gerrit/extensions/api/config/Config.java
@@ -17,7 +17,7 @@
import com.google.gerrit.extensions.restapi.NotImplementedException;
public interface Config {
- /** @return An API for getting server related configurations. */
+ /** Returns an API for getting server related configurations. */
Server server();
/**
diff --git a/java/com/google/gerrit/extensions/api/config/ConsistencyCheckInfo.java b/java/com/google/gerrit/extensions/api/config/ConsistencyCheckInfo.java
index e582f1b..9fb57ad 100644
--- a/java/com/google/gerrit/extensions/api/config/ConsistencyCheckInfo.java
+++ b/java/com/google/gerrit/extensions/api/config/ConsistencyCheckInfo.java
@@ -14,6 +14,7 @@
package com.google.gerrit.extensions.api.config;
+import com.google.errorprone.annotations.FormatMethod;
import java.util.List;
import java.util.Objects;
@@ -80,10 +81,12 @@
return status.name() + ": " + message;
}
+ @FormatMethod
public static ConsistencyProblemInfo warning(String fmt, Object... args) {
return new ConsistencyProblemInfo(Status.WARNING, String.format(fmt, args));
}
+ @FormatMethod
public static ConsistencyProblemInfo error(String fmt, Object... args) {
return new ConsistencyProblemInfo(Status.ERROR, String.format(fmt, args));
}
diff --git a/java/com/google/gerrit/extensions/api/config/Server.java b/java/com/google/gerrit/extensions/api/config/Server.java
index 70d1bff..8b69ded 100644
--- a/java/com/google/gerrit/extensions/api/config/Server.java
+++ b/java/com/google/gerrit/extensions/api/config/Server.java
@@ -24,7 +24,7 @@
import java.util.List;
public interface Server {
- /** @return Version of server. */
+ /** Returns version of server. */
String getVersion() throws RestApiException;
ServerInfo getInfo() throws RestApiException;
diff --git a/java/com/google/gerrit/extensions/api/groups/GroupApi.java b/java/com/google/gerrit/extensions/api/groups/GroupApi.java
index 067f120..e1b3a9f 100644
--- a/java/com/google/gerrit/extensions/api/groups/GroupApi.java
+++ b/java/com/google/gerrit/extensions/api/groups/GroupApi.java
@@ -24,53 +24,49 @@
import java.util.List;
public interface GroupApi {
- /** @return group info with no {@code ListGroupsOption}s set. */
+ /** Returns group info with no {@code ListGroupsOption}s set. */
GroupInfo get() throws RestApiException;
- /** @return group info with all {@code ListGroupsOption}s set. */
+ /** Returns group info with all {@code ListGroupsOption}s set. */
GroupInfo detail() throws RestApiException;
- /** @return group name. */
+ /** Returns group name. */
String name() throws RestApiException;
/**
* Set group name.
*
* @param name new name.
- * @throws RestApiException
*/
void name(String name) throws RestApiException;
- /** @return owning group info. */
+ /** Returns owning group info. */
GroupInfo owner() throws RestApiException;
/**
* Set group owner.
*
* @param owner identifier of new group owner.
- * @throws RestApiException
*/
void owner(String owner) throws RestApiException;
- /** @return group description. */
+ /** Returns group description. */
String description() throws RestApiException;
/**
* Set group decsription.
*
* @param description new description.
- * @throws RestApiException
*/
void description(String description) throws RestApiException;
- /** @return group options. */
+ /** Returns group options. */
GroupOptionsInfo options() throws RestApiException;
/**
* Set group options.
*
* @param options new options.
- * @throws RestApiException
*/
void options(GroupOptionsInfo options) throws RestApiException;
@@ -78,7 +74,6 @@
* List group members, non-recursively.
*
* @return group members.
- * @throws RestApiException
*/
List<AccountInfo> members() throws RestApiException;
@@ -87,7 +82,6 @@
*
* @param recursive whether to recursively included groups.
* @return group members.
- * @throws RestApiException
*/
List<AccountInfo> members(boolean recursive) throws RestApiException;
@@ -96,7 +90,6 @@
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
- * @throws RestApiException
*/
void addMembers(List<String> members) throws RestApiException;
@@ -105,7 +98,6 @@
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
- * @throws RestApiException
*/
default void addMembers(String... members) throws RestApiException {
addMembers(Arrays.asList(members));
@@ -116,7 +108,6 @@
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
- * @throws RestApiException
*/
void removeMembers(List<String> members) throws RestApiException;
@@ -125,7 +116,6 @@
*
* @param members list of member identifiers, in any format accepted by {@link
* com.google.gerrit.extensions.api.accounts.Accounts#id(String)}
- * @throws RestApiException
*/
default void removeMembers(String... members) throws RestApiException {
removeMembers(Arrays.asList(members));
@@ -135,7 +125,6 @@
* Lists the subgroups of this group.
*
* @return the found subgroups
- * @throws RestApiException
*/
List<GroupInfo> includedGroups() throws RestApiException;
@@ -143,7 +132,6 @@
* Adds subgroups to this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
- * @throws RestApiException
*/
void addGroups(List<String> groups) throws RestApiException;
@@ -151,7 +139,6 @@
* Adds subgroups to this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
- * @throws RestApiException
*/
default void addGroups(String... groups) throws RestApiException {
addGroups(Arrays.asList(groups));
@@ -161,7 +148,6 @@
* Removes subgroups from this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
- * @throws RestApiException
*/
void removeGroups(List<String> groups) throws RestApiException;
@@ -169,7 +155,6 @@
* Removes subgroups from this group.
*
* @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)}
- * @throws RestApiException
*/
default void removeGroups(String... groups) throws RestApiException {
removeGroups(Arrays.asList(groups));
@@ -179,7 +164,6 @@
* Returns the audit log of the group.
*
* @return list of audit events of the group.
- * @throws RestApiException
*/
List<? extends GroupAuditEventInfo> auditLog() throws RestApiException;
@@ -187,8 +171,6 @@
* Reindexes the group.
*
* <p>Only supported for internal groups.
- *
- * @throws RestApiException
*/
void index() throws RestApiException;
diff --git a/java/com/google/gerrit/extensions/api/groups/Groups.java b/java/com/google/gerrit/extensions/api/groups/Groups.java
index 81b5f47..1a46930 100644
--- a/java/com/google/gerrit/extensions/api/groups/Groups.java
+++ b/java/com/google/gerrit/extensions/api/groups/Groups.java
@@ -47,7 +47,7 @@
/** Create a new group. */
GroupApi create(GroupInput input) throws RestApiException;
- /** @return new request for listing groups. */
+ /** Returns new request for listing groups. */
ListRequest list();
/**
diff --git a/java/com/google/gerrit/extensions/auth/oauth/OAuthServiceProvider.java b/java/com/google/gerrit/extensions/auth/oauth/OAuthServiceProvider.java
index 417f55a..c3d760b 100644
--- a/java/com/google/gerrit/extensions/auth/oauth/OAuthServiceProvider.java
+++ b/java/com/google/gerrit/extensions/auth/oauth/OAuthServiceProvider.java
@@ -40,9 +40,7 @@
* After establishing of secure communication channel, this method supossed to access the
* protected resoure and retrieve the username.
*
- * @param token
* @return OAuth user information
- * @throws IOException
*/
OAuthUserInfo getUserInfo(OAuthToken token) throws IOException;
diff --git a/java/com/google/gerrit/extensions/client/GeneralPreferencesInfo.java b/java/com/google/gerrit/extensions/client/GeneralPreferencesInfo.java
index 21b319e..b26f435 100644
--- a/java/com/google/gerrit/extensions/client/GeneralPreferencesInfo.java
+++ b/java/com/google/gerrit/extensions/client/GeneralPreferencesInfo.java
@@ -148,6 +148,7 @@
public DefaultBase defaultBaseForMerges;
public Boolean publishCommentsOnPush;
public Boolean disableKeyboardShortcuts;
+ public Boolean disableTokenHighlighting;
public Boolean workInProgressByDefault;
public List<MenuItem> my;
public List<String> changeTable;
@@ -207,6 +208,7 @@
p.defaultBaseForMerges = DefaultBase.FIRST_PARENT;
p.publishCommentsOnPush = false;
p.disableKeyboardShortcuts = false;
+ p.disableTokenHighlighting = false;
p.workInProgressByDefault = false;
return p;
}
diff --git a/java/com/google/gerrit/extensions/common/ChangeInfo.java b/java/com/google/gerrit/extensions/common/ChangeInfo.java
index 6afe8ac..2bb3dd7 100644
--- a/java/com/google/gerrit/extensions/common/ChangeInfo.java
+++ b/java/com/google/gerrit/extensions/common/ChangeInfo.java
@@ -112,6 +112,7 @@
public List<PluginDefinedInfo> plugins;
public Collection<TrackingIdInfo> trackingIds;
public Collection<LegacySubmitRequirementInfo> requirements;
+ public Collection<SubmitRecordInfo> submitRecords;
public Collection<SubmitRequirementResultInfo> submitRequirements;
public ChangeInfo() {}
diff --git a/java/com/google/gerrit/extensions/common/ChangeInfoDiffer.java b/java/com/google/gerrit/extensions/common/ChangeInfoDiffer.java
index 0447e80..ad112d3 100644
--- a/java/com/google/gerrit/extensions/common/ChangeInfoDiffer.java
+++ b/java/com/google/gerrit/extensions/common/ChangeInfoDiffer.java
@@ -63,9 +63,12 @@
*/
public static ChangeInfoDifference getDifference(
ChangeInfo oldChangeInfo, ChangeInfo newChangeInfo) {
- return ChangeInfoDifference.create(
- /* added= */ getAdded(oldChangeInfo, newChangeInfo),
- /* removed= */ getAdded(newChangeInfo, oldChangeInfo));
+ return ChangeInfoDifference.builder()
+ .setOldChangeInfo(oldChangeInfo)
+ .setNewChangeInfo(newChangeInfo)
+ .setAdded(getAdded(oldChangeInfo, newChangeInfo))
+ .setRemoved(getAdded(newChangeInfo, oldChangeInfo))
+ .build();
}
@SuppressWarnings("unchecked") // reflection is used to construct instances of T
@@ -143,7 +146,7 @@
}
}
- /** @return {@code null} if nothing has been added to {@code oldCollection} */
+ /** Returns {@code null} if nothing has been added to {@code oldCollection} */
private static ImmutableList<?> getAddedForCollection(
Collection<?> oldCollection, Collection<?> newCollection) {
ImmutableList<?> notInOldCollection = getAdditions(oldCollection, newCollection);
@@ -165,7 +168,7 @@
return duplicatesMap.values().stream().flatMap(Collection::stream).collect(toImmutableList());
}
- /** @return {@code null} if nothing has been added to {@code oldMap} */
+ /** Returns {@code null} if nothing has been added to {@code oldMap} */
private static ImmutableMap<Object, Object> getAddedForMap(Map<?, ?> oldMap, Map<?, ?> newMap) {
ImmutableMap.Builder<Object, Object> additionsBuilder = ImmutableMap.builder();
for (Map.Entry<?, ?> entry : newMap.entrySet()) {
diff --git a/java/com/google/gerrit/extensions/common/ChangeInfoDifference.java b/java/com/google/gerrit/extensions/common/ChangeInfoDifference.java
index 269c673..997c3ee 100644
--- a/java/com/google/gerrit/extensions/common/ChangeInfoDifference.java
+++ b/java/com/google/gerrit/extensions/common/ChangeInfoDifference.java
@@ -20,11 +20,29 @@
@AutoValue
public abstract class ChangeInfoDifference {
+ public abstract ChangeInfo oldChangeInfo();
+
+ public abstract ChangeInfo newChangeInfo();
+
public abstract ChangeInfo added();
public abstract ChangeInfo removed();
- public static ChangeInfoDifference create(ChangeInfo added, ChangeInfo removed) {
- return new AutoValue_ChangeInfoDifference(added, removed);
+ public static Builder builder() {
+ return new AutoValue_ChangeInfoDifference.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder setOldChangeInfo(ChangeInfo oldChangeInfo);
+
+ public abstract Builder setNewChangeInfo(ChangeInfo newChangeInfo);
+
+ public abstract Builder setAdded(ChangeInfo added);
+
+ public abstract Builder setRemoved(ChangeInfo removed);
+
+ public abstract ChangeInfoDifference build();
}
}
diff --git a/java/com/google/gerrit/extensions/common/SubmitRecordInfo.java b/java/com/google/gerrit/extensions/common/SubmitRecordInfo.java
new file mode 100644
index 0000000..09c9841
--- /dev/null
+++ b/java/com/google/gerrit/extensions/common/SubmitRecordInfo.java
@@ -0,0 +1,48 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.extensions.common;
+
+import java.util.List;
+
+/** API response containing a {@link com.google.gerrit.entities.SubmitRecord} entity. */
+public class SubmitRecordInfo {
+ public enum Status {
+ OK,
+ NOT_READY,
+ CLOSED,
+ FORCED,
+ RULE_ERROR
+ }
+
+ public static class Label {
+ public enum Status {
+ OK,
+ REJECT,
+ NEED,
+ MAY,
+ IMPOSSIBLE
+ }
+
+ public String label;
+ public Status status;
+ public AccountInfo appliedBy;
+ }
+
+ public String ruleName;
+ public Status status;
+ public List<Label> labels;
+ public List<LegacySubmitRequirementInfo> requirements;
+ public String errorMessage;
+}
diff --git a/java/com/google/gerrit/extensions/common/TestSubmitRuleInfo.java b/java/com/google/gerrit/extensions/common/TestSubmitRuleInfo.java
index deb03b0..2af9a767 100644
--- a/java/com/google/gerrit/extensions/common/TestSubmitRuleInfo.java
+++ b/java/com/google/gerrit/extensions/common/TestSubmitRuleInfo.java
@@ -19,7 +19,7 @@
import java.util.Objects;
public class TestSubmitRuleInfo {
- /** @see com.google.gerrit.entities.SubmitRecord.Status */
+ /** See {@link com.google.gerrit.entities.SubmitRecord.Status} */
public String status;
public String errorMessage;
diff --git a/java/com/google/gerrit/extensions/conditions/BooleanCondition.java b/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
index 162dd99..9c354fb 100644
--- a/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
+++ b/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
@@ -48,7 +48,7 @@
BooleanCondition() {}
- /** @return evaluate the condition and return its value. */
+ /** Evaluates the condition and return its value. */
public abstract boolean value();
/**
@@ -63,7 +63,9 @@
* Reduce evaluation tree by cutting off branches that evaluate trivially and replacing them with
* a leave note corresponding to the value the branch evaluated to.
*
- * <p><code>
+ * <p>
+ *
+ * <pre>{@code
* Example 1 (T=True, F=False, C=non-trivial check):
* OR
* / \ => T
@@ -76,7 +78,7 @@
* AND
* / \ => F
* T F
- * </code>
+ * }</pre>
*
* <p>There is no guarantee that the resulting tree is minimal. The only guarantee made is that
* branches that evaluate trivially will be cut off and replaced by primitive values.
diff --git a/java/com/google/gerrit/extensions/config/DownloadScheme.java b/java/com/google/gerrit/extensions/config/DownloadScheme.java
index d81657a..96b5878 100644
--- a/java/com/google/gerrit/extensions/config/DownloadScheme.java
+++ b/java/com/google/gerrit/extensions/config/DownloadScheme.java
@@ -26,12 +26,12 @@
*/
public abstract String getUrl(String project);
- /** @return whether this scheme requires authentication */
+ /** Returns whether this scheme requires authentication */
public abstract boolean isAuthRequired();
- /** @return whether this scheme supports authentication */
+ /** Returns whether this scheme supports authentication */
public abstract boolean isAuthSupported();
- /** @return whether the download scheme is enabled */
+ /** Returns whether the download scheme is enabled */
public abstract boolean isEnabled();
}
diff --git a/java/com/google/gerrit/extensions/events/GarbageCollectorListener.java b/java/com/google/gerrit/extensions/events/GarbageCollectorListener.java
index edb3e69..45c33c9 100644
--- a/java/com/google/gerrit/extensions/events/GarbageCollectorListener.java
+++ b/java/com/google/gerrit/extensions/events/GarbageCollectorListener.java
@@ -22,8 +22,9 @@
public interface GarbageCollectorListener {
interface Event extends ProjectEvent {
/**
- * @return Properties describing the result of the garbage collection performed by JGit.
- * @see org.eclipse.jgit.api.GarbageCollectCommand#call()
+ * Returns properties describing the result of the garbage collection performed by JGit.
+ *
+ * <p>See {@link org.eclipse.jgit.api.GarbageCollectCommand#call }
*/
Properties getStatistics();
}
diff --git a/java/com/google/gerrit/extensions/restapi/BinaryResult.java b/java/com/google/gerrit/extensions/restapi/BinaryResult.java
index bdddfd9..2ee376e 100644
--- a/java/com/google/gerrit/extensions/restapi/BinaryResult.java
+++ b/java/com/google/gerrit/extensions/restapi/BinaryResult.java
@@ -63,7 +63,7 @@
private boolean base64;
private String attachmentName;
- /** @return the MIME type of the result, for HTTP clients. */
+ /** Returns the MIME type of the result, for HTTP clients. */
public String getContentType() {
Charset enc = getCharacterEncoding();
if (enc != null) {
@@ -100,7 +100,7 @@
return this;
}
- /** @return length in bytes of the result; -1 if not known. */
+ /** Returns length in bytes of the result; -1 if not known. */
public long getContentLength() {
return contentLength;
}
@@ -111,7 +111,7 @@
return this;
}
- /** @return true if this result can be gzip compressed to clients. */
+ /** Returns true if this result can be gzip compressed to clients. */
public boolean canGzip() {
return gzip;
}
@@ -122,7 +122,7 @@
return this;
}
- /** @return true if the result must be base64 encoded. */
+ /** Returns true if the result must be base64 encoded. */
public boolean isBase64() {
return base64;
}
diff --git a/java/com/google/gerrit/extensions/restapi/IdString.java b/java/com/google/gerrit/extensions/restapi/IdString.java
index 736c3ba..b2538fa 100644
--- a/java/com/google/gerrit/extensions/restapi/IdString.java
+++ b/java/com/google/gerrit/extensions/restapi/IdString.java
@@ -36,17 +36,17 @@
urlEncoded = s;
}
- /** @return the decoded value of the string. */
+ /** Returns the decoded value of the string. */
public String get() {
return Url.decode(urlEncoded);
}
- /** @return true if the string is the empty string. */
+ /** Returns true if the string is the empty string. */
public boolean isEmpty() {
return urlEncoded.isEmpty();
}
- /** @return the original URL encoding supplied by the client. */
+ /** Returns the original URL encoding supplied by the client. */
public String encoded() {
return urlEncoded;
}
diff --git a/java/com/google/gerrit/extensions/restapi/RestResource.java b/java/com/google/gerrit/extensions/restapi/RestResource.java
index cc5d48d..3c8144a 100644
--- a/java/com/google/gerrit/extensions/restapi/RestResource.java
+++ b/java/com/google/gerrit/extensions/restapi/RestResource.java
@@ -26,7 +26,7 @@
/** A resource with a last modification date. */
public interface HasLastModified {
- /** @return time for the Last-Modified header. HTTP truncates the header value to seconds. */
+ /** Returns time for the Last-Modified header. HTTP truncates the header value to seconds. */
Timestamp getLastModified();
}
diff --git a/java/com/google/gerrit/extensions/webui/WebUiPlugin.java b/java/com/google/gerrit/extensions/webui/WebUiPlugin.java
index 2d49e1c..4f129b0 100644
--- a/java/com/google/gerrit/extensions/webui/WebUiPlugin.java
+++ b/java/com/google/gerrit/extensions/webui/WebUiPlugin.java
@@ -44,7 +44,7 @@
private String pluginName;
- /** @return installed name of the plugin that provides this UI feature. */
+ /** Returns installed name of the plugin that provides this UI feature. */
public final String getPluginName() {
return pluginName;
}
@@ -54,7 +54,7 @@
this.pluginName = pluginName;
}
- /** @return path to initialization script within the plugin's JAR. */
+ /** Returns path to initialization script within the plugin's JAR. */
public abstract String getJavaScriptResourcePath();
@Override
diff --git a/java/com/google/gerrit/git/GitUpdateFailureException.java b/java/com/google/gerrit/git/GitUpdateFailureException.java
index 76ef217..7fcb828 100644
--- a/java/com/google/gerrit/git/GitUpdateFailureException.java
+++ b/java/com/google/gerrit/git/GitUpdateFailureException.java
@@ -46,12 +46,12 @@
.collect(toImmutableList());
}
- /** @return the names of the refs for which the update failed. */
+ /** Returns the names of the refs for which the update failed. */
public ImmutableList<String> getFailedRefs() {
return failures.stream().map(GitUpdateFailure::ref).collect(toImmutableList());
}
- /** @return the failures that caused this exception. */
+ /** Returns the failures that caused this exception. */
@UsedAt(UsedAt.Project.GOOGLE)
public ImmutableList<GitUpdateFailure> getFailures() {
return failures;
diff --git a/java/com/google/gerrit/gpg/CheckResult.java b/java/com/google/gerrit/gpg/CheckResult.java
index 8655b2a..2743e74 100644
--- a/java/com/google/gerrit/gpg/CheckResult.java
+++ b/java/com/google/gerrit/gpg/CheckResult.java
@@ -62,22 +62,22 @@
this.problems = problems;
}
- /** @return whether the result has status {@link Status#OK} or better. */
+ /** Returns whether the result has status {@link Status#OK} or better. */
public boolean isOk() {
return status.compareTo(Status.OK) >= 0;
}
- /** @return whether the result has status {@link Status#TRUSTED} or better. */
+ /** Returns whether the result has status {@link Status#TRUSTED} or better. */
public boolean isTrusted() {
return status.compareTo(Status.TRUSTED) >= 0;
}
- /** @return the status enum value associated with the object. */
+ /** Returns the status enum value associated with the object. */
public Status getStatus() {
return status;
}
- /** @return any problems encountered during checking. */
+ /** Returns any problems encountered during checking. */
public List<String> getProblems() {
return problems;
}
diff --git a/java/com/google/gerrit/gpg/PushCertificateChecker.java b/java/com/google/gerrit/gpg/PushCertificateChecker.java
index 82b3892..36a4af7 100644
--- a/java/com/google/gerrit/gpg/PushCertificateChecker.java
+++ b/java/com/google/gerrit/gpg/PushCertificateChecker.java
@@ -154,8 +154,11 @@
protected abstract Repository getRepository() throws IOException;
/**
+ * Specifies whether this repository should be closed before returning froms {@link
+ * #check(PushCertificate)}
+ *
* @param repo a repository previously returned by {@link #getRepository()}.
- * @return whether this repository should be closed before returning from {@link
+ * @return true if this repository should be closed before returning from {@link
* #check(PushCertificate)}.
*/
protected abstract boolean shouldClose(Repository repo);
diff --git a/java/com/google/gerrit/gpg/testing/TestKeys.java b/java/com/google/gerrit/gpg/testing/TestKeys.java
index de66889..0423474 100644
--- a/java/com/google/gerrit/gpg/testing/TestKeys.java
+++ b/java/com/google/gerrit/gpg/testing/TestKeys.java
@@ -436,13 +436,13 @@
/**
* A key with an additional user ID.
*
- * <pre>
+ * <pre>{@code
* pub 2048R/98C51DBF 2015-07-30
* Key fingerprint = 42B3 294D 1924 D7EB AF4A A99F 5024 BB44 98C5 1DBF
* uid foo:myId
* uid Testuser Five <test5@example.com>
* sub 2048R/C781A9E3 2015-07-30
- * </pre>
+ * }</pre>
*/
public static TestKey validKeyWithSecondUserId() {
return new TestKey(
@@ -1033,13 +1033,13 @@
/**
* Master Key without expiration with subkey with expiration.
*
- * <pre>
+ * <pre>{@code
* pub rsa1024 2018-11-17 [C]
* 5734 2C37 982A 843B 19C0 622B 6AAF 2D26 B481 02DB
* uid [ultimate] Testuser 10 <testuser10@example.com>
* sub rsa1024 2018-11-17 [S] [expires: 2065-11-05]
* 0A4A 9660 1B96 2DFC E898 E686 4305 C92E 626E B485
- * </pre>
+ * }</pre>
*/
public static TestKey validKeyWithoutExpirationWithSubkeyWithExpiration() throws Exception {
return new TestKey(
diff --git a/java/com/google/gerrit/httpd/RequestMetricsFilter.java b/java/com/google/gerrit/httpd/RequestMetricsFilter.java
index c97b9ad..0ff1a79 100644
--- a/java/com/google/gerrit/httpd/RequestMetricsFilter.java
+++ b/java/com/google/gerrit/httpd/RequestMetricsFilter.java
@@ -55,17 +55,17 @@
startedMemory = threadMxBean.getCurrentThreadAllocatedBytes();
}
- /** @return total CPU time in milliseconds for executing request */
+ /** Returns total CPU time in milliseconds for executing request */
public long getTotalCpuTime() {
return (threadMxBean.getCurrentThreadCpuTime() - startedTotalCpu) / 1_000_000;
}
- /** @return CPU time in user mode in milliseconds for executing request */
+ /** Returns CPU time in user mode in milliseconds for executing request */
public long getUserCpuTime() {
return (threadMxBean.getCurrentThreadUserTime() - startedUserCpu) / 1_000_000;
}
- /** @return memory allocated in bytes for executing request */
+ /** Returns memory allocated in bytes for executing request */
public long getAllocatedMemory() {
return startedMemory == -1
? -1
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 3c39ea1..369ea29 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -768,13 +768,12 @@
}
} else {
res.reset();
- traceContext.getTraceId().ifPresent(traceId -> res.addHeader(X_GERRIT_TRACE, traceId));
+ TraceContext.getTraceId().ifPresent(traceId -> res.addHeader(X_GERRIT_TRACE, traceId));
if (status.isPresent()) {
- responseBytes = reply(req, res, e, status.get(), getUserMessages(traceContext, e));
+ responseBytes = reply(req, res, e, status.get(), getUserMessages(e));
} else {
- responseBytes =
- replyInternalServerError(req, res, e, getUserMessages(traceContext, e));
+ responseBytes = replyInternalServerError(req, res, e, getUserMessages(e));
}
}
}
@@ -984,7 +983,7 @@
throws Exception {
RetryableAction<T> retryableAction = globals.retryHelper.action(actionType, caller, action);
AtomicReference<Optional<String>> traceId = new AtomicReference<>(Optional.empty());
- if (!traceContext.isTracing()) {
+ if (!TraceContext.isTracing()) {
// enable automatic retry with tracing in case of non-recoverable failure
retryableAction
.retryWithTrace(t -> !(t instanceof RestApiException))
@@ -1427,7 +1426,6 @@
* @param config config parameters for the JSON formatting
* @param result the object that should be formatted as JSON
* @return the length of the response
- * @throws IOException
*/
public static long replyJson(
@Nullable HttpServletRequest req,
@@ -1876,9 +1874,9 @@
.findFirst();
}
- private ImmutableList<String> getUserMessages(TraceContext traceContext, Throwable err) {
+ private ImmutableList<String> getUserMessages(Throwable err) {
return globals.exceptionHooks.stream()
- .flatMap(h -> h.getUserMessages(err, traceContext.getTraceId().orElse(null)).stream())
+ .flatMap(h -> h.getUserMessages(err, TraceContext.getTraceId().orElse(null)).stream())
.collect(toImmutableList());
}
@@ -1971,7 +1969,6 @@
* set to {@code true} if the reply may contain sensitive data
* @param text the text reply
* @return the length of the response
- * @throws IOException
*/
static long replyText(
@Nullable HttpServletRequest req, HttpServletResponse res, boolean allowTracing, String text)
diff --git a/java/com/google/gerrit/index/FieldDef.java b/java/com/google/gerrit/index/FieldDef.java
index eb64c1d..76aa7cc 100644
--- a/java/com/google/gerrit/index/FieldDef.java
+++ b/java/com/google/gerrit/index/FieldDef.java
@@ -138,17 +138,17 @@
return name;
}
- /** @return name of the field. */
+ /** Returns name of the field. */
public String getName() {
return name;
}
- /** @return type of the field; for repeatable fields, the inner type, not the iterable type. */
+ /** Returns type of the field; for repeatable fields, the inner type, not the iterable type. */
public FieldType<?> getType() {
return type;
}
- /** @return whether the field should be stored in the index. */
+ /** Returns whether the field should be stored in the index. */
public boolean isStored() {
return stored;
}
@@ -203,7 +203,7 @@
return false;
}
- /** @return whether the field is repeatable. */
+ /** Returns whether the field is repeatable. */
public boolean isRepeatable() {
return repeatable;
}
diff --git a/java/com/google/gerrit/index/Index.java b/java/com/google/gerrit/index/Index.java
index 529cd78..ead302d 100644
--- a/java/com/google/gerrit/index/Index.java
+++ b/java/com/google/gerrit/index/Index.java
@@ -33,7 +33,7 @@
* <p>Implementations must be thread-safe and should batch inserts/updates where appropriate.
*/
public interface Index<K, V> {
- /** @return the schema version used by this index. */
+ /** Returns the schema version used by this index. */
Schema<V> getSchema();
/** Close this index. */
diff --git a/java/com/google/gerrit/index/IndexConfig.java b/java/com/google/gerrit/index/IndexConfig.java
index 29b8ea6..8676fb2 100644
--- a/java/com/google/gerrit/index/IndexConfig.java
+++ b/java/com/google/gerrit/index/IndexConfig.java
@@ -101,27 +101,27 @@
}
/**
- * @return maximum limit supported by the underlying index, or limited for performance reasons.
+ * Returns maximum limit supported by the underlying index, or limited for performance reasons.
*/
public abstract int maxLimit();
/**
- * @return maximum number of pages (limit / start) supported by the underlying index, or limited
- * for performance reasons.
+ * Returns maximum number of pages (limit / start) supported by the underlying index, or limited
+ * for performance reasons.
*/
public abstract int maxPages();
/**
- * @return maximum number of total index query terms supported by the underlying index, or limited
- * for performance reasons.
+ * Returns maximum number of total index query terms supported by the underlying index, or limited
+ * for performance reasons.
*/
public abstract int maxTerms();
- /** @return index type. */
+ /** Returns index type. */
public abstract String type();
/**
- * @return whether different subsets of changes may be stored in different physical sub-indexes.
+ * Returns whether different subsets of changes may be stored in different physical sub-indexes.
*/
public abstract boolean separateChangeSubIndexes();
}
diff --git a/java/com/google/gerrit/index/Schema.java b/java/com/google/gerrit/index/Schema.java
index 3aa9de0..91c3f70 100644
--- a/java/com/google/gerrit/index/Schema.java
+++ b/java/com/google/gerrit/index/Schema.java
@@ -134,7 +134,7 @@
return fields;
}
- /** @return all fields in this schema where {@link FieldDef#isStored()} is true. */
+ /** Returns all fields in this schema where {@link FieldDef#isStored()} is true. */
public final ImmutableMap<String, FieldDef<T, ?>> getStoredFields() {
return storedFields;
}
diff --git a/java/com/google/gerrit/index/query/DataSource.java b/java/com/google/gerrit/index/query/DataSource.java
index 2c2ba53..518d153 100644
--- a/java/com/google/gerrit/index/query/DataSource.java
+++ b/java/com/google/gerrit/index/query/DataSource.java
@@ -15,12 +15,12 @@
package com.google.gerrit.index.query;
public interface DataSource<T> {
- /** @return an estimate of the number of results from {@link #read()}. */
+ /** Returns an estimate of the number of results from {@link #read()}. */
int getCardinality();
- /** @return read from the database and return the results. */
+ /** Returns read from the database and return the results. */
ResultSet<T> read();
- /** @return read from the database and return the raw results. */
+ /** Returns read from the database and return the raw results. */
ResultSet<FieldBundle> readRaw();
}
diff --git a/java/com/google/gerrit/index/query/Matchable.java b/java/com/google/gerrit/index/query/Matchable.java
index 7a16ae8..f416149 100644
--- a/java/com/google/gerrit/index/query/Matchable.java
+++ b/java/com/google/gerrit/index/query/Matchable.java
@@ -18,6 +18,6 @@
/** Does this predicate match this object? */
boolean match(T object);
- /** @return a cost estimate to run this predicate, higher figures cost more. */
+ /** Returns a cost estimate to run this predicate, higher figures cost more. */
int getCost();
}
diff --git a/java/com/google/gerrit/index/query/Predicate.java b/java/com/google/gerrit/index/query/Predicate.java
index 2382d30..2791f2c 100644
--- a/java/com/google/gerrit/index/query/Predicate.java
+++ b/java/com/google/gerrit/index/query/Predicate.java
@@ -159,7 +159,7 @@
return (Matchable<T>) this;
}
- /** @return a cost estimate to run this predicate, higher figures cost more. */
+ /** Returns a cost estimate to run this predicate, higher figures cost more. */
public int estimateCost() {
if (!isMatchable()) {
return 1;
diff --git a/java/com/google/gerrit/index/query/QueryResult.java b/java/com/google/gerrit/index/query/QueryResult.java
index 33fcef0..d03a68b 100644
--- a/java/com/google/gerrit/index/query/QueryResult.java
+++ b/java/com/google/gerrit/index/query/QueryResult.java
@@ -34,19 +34,19 @@
return new AutoValue_QueryResult<>(query, predicate, ImmutableList.copyOf(entities), more);
}
- /** @return the original query string, or null if the query was created programmatically. */
+ /** Returns the original query string, or null if the query was created programmatically. */
@Nullable
public abstract String query();
- /** @return the predicate after all rewriting and other modification by the query subsystem. */
+ /** Returns the predicate after all rewriting and other modification by the query subsystem. */
public abstract Predicate<T> predicate();
- /** @return the query results. */
+ /** Returns the query results. */
public abstract ImmutableList<T> entities();
/**
- * @return whether the query could be retried with a higher start/limit to produce more results.
- * Never true if {@link #entities()} is empty.
+ * Returns whether the query could be retried with a higher start/limit to produce more results.
+ * Never true if {@link #entities()} is empty.
*/
public abstract boolean more();
}
diff --git a/java/com/google/gerrit/json/OutputFormat.java b/java/com/google/gerrit/json/OutputFormat.java
index 3e7c319..c5504bb 100644
--- a/java/com/google/gerrit/json/OutputFormat.java
+++ b/java/com/google/gerrit/json/OutputFormat.java
@@ -42,12 +42,12 @@
*/
JSON_COMPACT;
- /** @return true when the format is either JSON or JSON_COMPACT. */
+ /** Returns true when the format is either JSON or JSON_COMPACT. */
public boolean isJson() {
return this == JSON_COMPACT || this == JSON;
}
- /** @return a new Gson instance configured according to the format. */
+ /** Returns a new Gson instance configured according to the format. */
public GsonBuilder newGsonBuilder() {
if (!isJson()) {
throw new IllegalStateException(String.format("%s is not JSON", this));
@@ -63,7 +63,7 @@
return gb;
}
- /** @return a new Gson instance configured according to the format. */
+ /** Returns a new Gson instance configured according to the format. */
public Gson newGson() {
return newGsonBuilder().create();
}
diff --git a/java/com/google/gerrit/lifecycle/LifecycleModule.java b/java/com/google/gerrit/lifecycle/LifecycleModule.java
index 0fb4653..efe1518 100644
--- a/java/com/google/gerrit/lifecycle/LifecycleModule.java
+++ b/java/com/google/gerrit/lifecycle/LifecycleModule.java
@@ -24,13 +24,16 @@
/** Module to support registering a unique LifecyleListener. */
public abstract class LifecycleModule extends FactoryModule {
/**
- * @return a unique listener binding.
- * <p>To create a listener binding use:
- * <pre>
+ * Returns a unique listener binding.
+ *
+ * <p>To create a listener binding use:
+ *
+ * <pre>
* listener().to(MyListener.class);
* </pre>
- * where {@code MyListener} is a {@link Singleton} implementing the {@link LifecycleListener}
- * interface.
+ *
+ * where {@code MyListener} is a {@link Singleton} implementing the {@link LifecycleListener}
+ * interface.
*/
protected LinkedBindingBuilder<LifecycleListener> listener() {
final Annotation id = UniqueAnnotations.create();
diff --git a/java/com/google/gerrit/mail/TextParser.java b/java/com/google/gerrit/mail/TextParser.java
index 95ab10c..c43d200 100644
--- a/java/com/google/gerrit/mail/TextParser.java
+++ b/java/com/google/gerrit/mail/TextParser.java
@@ -30,7 +30,7 @@
/**
* Parses comments from plaintext email.
*
- * @param email @param email the message as received from the email service
+ * @param email the message as received from the email service
* @param comments list of {@link HumanComment}s previously persisted on the change that caused
* the original notification email to be sent out. Ordering must be the same as in the
* outbound email
diff --git a/java/com/google/gerrit/metrics/Description.java b/java/com/google/gerrit/metrics/Description.java
index 10568bc..f5963af 100644
--- a/java/com/google/gerrit/metrics/Description.java
+++ b/java/com/google/gerrit/metrics/Description.java
@@ -133,27 +133,27 @@
return this;
}
- /** @return true if the metric value never changes after startup. */
+ /** Returns true if the metric value never changes after startup. */
public boolean isConstant() {
return TRUE_VALUE.equals(annotations.get(CONSTANT));
}
- /** @return true if the metric may be interpreted as a rate over time. */
+ /** Returns true if the metric may be interpreted as a rate over time. */
public boolean isRate() {
return TRUE_VALUE.equals(annotations.get(RATE));
}
- /** @return true if the metric is an instantaneous sample. */
+ /** Returns true if the metric is an instantaneous sample. */
public boolean isGauge() {
return TRUE_VALUE.equals(annotations.get(GAUGE));
}
- /** @return true if the metric accumulates over the lifespan of the process. */
+ /** Returns true if the metric accumulates over the lifespan of the process. */
public boolean isCumulative() {
return TRUE_VALUE.equals(annotations.get(CUMULATIVE));
}
- /** @return the suggested field ordering. */
+ /** Returns the suggested field ordering. */
public FieldOrdering getFieldOrdering() {
String o = annotations.get(FIELD_ORDERING);
return o != null ? FieldOrdering.valueOf(o) : FieldOrdering.AT_END;
@@ -187,7 +187,7 @@
return u;
}
- /** @return immutable copy of all annotations (configurable properties). */
+ /** Returns an immutable copy of all annotations (configurable properties). */
public ImmutableMap<String, String> getAnnotations() {
return ImmutableMap.copyOf(annotations);
}
diff --git a/java/com/google/gerrit/metrics/Field.java b/java/com/google/gerrit/metrics/Field.java
index bdae854..5508819 100644
--- a/java/com/google/gerrit/metrics/Field.java
+++ b/java/com/google/gerrit/metrics/Field.java
@@ -102,19 +102,19 @@
.metadataMapper(metadataMapper);
}
- /** @return name of this field within the metric. */
+ /** Returns name of this field within the metric. */
public abstract String name();
- /** @return type of value used within the field. */
+ /** Returns type of value used within the field. */
public abstract Class<T> valueType();
- /** @return mapper that maps a field value to a field in the {@link Metadata} class. */
+ /** Returns mapper that maps a field value to a field in the {@link Metadata} class. */
public abstract BiConsumer<Metadata.Builder, T> metadataMapper();
- /** @return description text for the field explaining its range of values. */
+ /** Returns description text for the field explaining its range of values. */
public abstract Optional<String> description();
- /** @return formatter to format field values. */
+ /** Returns formatter to format field values. */
public abstract Function<T, String> formatter();
@AutoValue.Builder
diff --git a/java/com/google/gerrit/metrics/TimerContext.java b/java/com/google/gerrit/metrics/TimerContext.java
index 62eb030..a3754c5 100644
--- a/java/com/google/gerrit/metrics/TimerContext.java
+++ b/java/com/google/gerrit/metrics/TimerContext.java
@@ -29,7 +29,7 @@
*/
public abstract void record(long elapsed);
- /** @return the start time in system time nanoseconds. */
+ /** Returns the start time in system time nanoseconds. */
public long getStartTime() {
return startNanos;
}
diff --git a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java
index e8611b3..d64bd19 100644
--- a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java
+++ b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java
@@ -184,7 +184,9 @@
+ "having most data in the cache.")
.setGauge()
.setUnit("byte"),
- Field.ofString("repository_name", Metadata.Builder::projectName).build());
+ Field.ofString("repository_name", Metadata.Builder::projectName)
+ .description("The name of the repository.")
+ .build());
metrics.newTrigger(
repoEnt,
() -> {
diff --git a/java/com/google/gerrit/pgm/ChangeExternalIdCaseSensitivity.java b/java/com/google/gerrit/pgm/ChangeExternalIdCaseSensitivity.java
index fbc6065..01c76c1 100644
--- a/java/com/google/gerrit/pgm/ChangeExternalIdCaseSensitivity.java
+++ b/java/com/google/gerrit/pgm/ChangeExternalIdCaseSensitivity.java
@@ -27,6 +27,7 @@
import com.google.gerrit.server.account.externalids.DisabledExternalIdCache;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIdFactory;
+import com.google.gerrit.server.account.externalids.ExternalIdKeyFactory;
import com.google.gerrit.server.account.externalids.ExternalIdNotes;
import com.google.gerrit.server.account.externalids.ExternalIdUpsertPreprocessor;
import com.google.gerrit.server.account.externalids.ExternalIds;
@@ -157,8 +158,15 @@
private void recomputeExternalIdNoteId(ExternalIdNotes extIdNotes, ExternalId extId)
throws DuplicateKeyException, IOException {
if (extId.isScheme(SCHEME_GERRIT) || extId.isScheme(SCHEME_USERNAME)) {
- ExternalId.Key updatedKey =
- ExternalId.Key.create(extId.key().scheme(), extId.key().id(), !isUserNameCaseInsensitive);
+ ExternalIdKeyFactory keyFactory =
+ new ExternalIdKeyFactory(
+ new ExternalIdKeyFactory.Config() {
+ @Override
+ public boolean isUserNameCaseInsensitive() {
+ return !isUserNameCaseInsensitive;
+ }
+ });
+ ExternalId.Key updatedKey = keyFactory.create(extId.key().scheme(), extId.key().id());
if (!extId.key().sha1().getName().equals(updatedKey.sha1().getName())) {
logger.atInfo().log("Converting note name of external ID: %s", extId.key());
ExternalId updatedExtId =
diff --git a/java/com/google/gerrit/pgm/Daemon.java b/java/com/google/gerrit/pgm/Daemon.java
index a3605f7..0a9b4d8 100644
--- a/java/com/google/gerrit/pgm/Daemon.java
+++ b/java/com/google/gerrit/pgm/Daemon.java
@@ -181,7 +181,7 @@
private String devCdn = "";
@Option(name = "--dev-cdn", usage = "Use specified cdn for serving static content.")
- private void setDevCdn(String cdn) {
+ void setDevCdn(String cdn) {
if (cdn == null) {
cdn = "";
}
diff --git a/java/com/google/gerrit/pgm/init/BaseInit.java b/java/com/google/gerrit/pgm/init/BaseInit.java
index c4b0040..c083296 100644
--- a/java/com/google/gerrit/pgm/init/BaseInit.java
+++ b/java/com/google/gerrit/pgm/init/BaseInit.java
@@ -164,7 +164,6 @@
* Invoked before site init is called.
*
* @param init initializer instance.
- * @throws Exception
*/
protected boolean beforeInit(SiteInit init) throws Exception {
return false;
@@ -174,7 +173,6 @@
* Invoked after site init is called.
*
* @param run completed run instance.
- * @throws Exception
*/
protected void afterInit(SiteRun run) throws Exception {}
diff --git a/java/com/google/gerrit/pgm/init/InitAuth.java b/java/com/google/gerrit/pgm/init/InitAuth.java
index c15cff3..948ec49 100644
--- a/java/com/google/gerrit/pgm/init/InitAuth.java
+++ b/java/com/google/gerrit/pgm/init/InitAuth.java
@@ -26,6 +26,7 @@
import com.google.gerrit.pgm.init.api.InitFlags;
import com.google.gerrit.pgm.init.api.InitStep;
import com.google.gerrit.pgm.init.api.Section;
+import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.mail.SignedToken;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -42,11 +43,13 @@
private final Section ldap;
private final Section receive;
private final InitFlags flags;
+ private final SitePaths site;
@Inject
- InitAuth(InitFlags flags, ConsoleUI ui, Section.Factory sections) {
+ InitAuth(InitFlags flags, ConsoleUI ui, final SitePaths site, Section.Factory sections) {
this.flags = flags;
this.ui = ui;
+ this.site = site;
this.auth = sections.get("auth", null);
this.ldap = sections.get("ldap", null);
this.receive = sections.get(RECEIVE, null);
@@ -62,6 +65,10 @@
}
initSignedPush();
+
+ if (site.isNew) {
+ initUserNameCaseSensitivity();
+ }
}
private void initAuthType() {
@@ -156,4 +163,9 @@
boolean enable = ui.yesno(def, "Enable signed push support");
receive.set("enableSignedPush", Boolean.toString(enable));
}
+
+ private void initUserNameCaseSensitivity() {
+ boolean enableCaseInsensitivity = ui.yesno(true, "Use case insensitive usernames");
+ auth.set("userNameCaseInsensitive", Boolean.toString(enableCaseInsensitivity));
+ }
}
diff --git a/java/com/google/gerrit/pgm/init/InitJGitConfig.java b/java/com/google/gerrit/pgm/init/InitJGitConfig.java
index bad55b4..b68e9f7 100644
--- a/java/com/google/gerrit/pgm/init/InitJGitConfig.java
+++ b/java/com/google/gerrit/pgm/init/InitJGitConfig.java
@@ -53,7 +53,8 @@
ConfigConstants.CONFIG_RECEIVE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOGC, false);
jgitConfig.save();
ui.error(
- "Auto-configured \"receive.autogc = false\" to disable auto-gc after git-receive-pack.");
+ "Auto-configured \"receive.autogc = false\" to disable auto-gc after"
+ + " git-receive-pack.");
} else if (jgitConfig.getBoolean(
ConfigConstants.CONFIG_RECEIVE_SECTION, ConfigConstants.CONFIG_KEY_AUTOGC, true)) {
ui.error(
@@ -72,12 +73,9 @@
ConfigConstants.CONFIG_PROTOCOL_SECTION, null, ConfigConstants.CONFIG_KEY_VERSION);
if (!TransferConfig.ProtocolVersion.V2.version().equals(version)) {
ui.error(
- String.format(
- "HINT: JGit option \"%s.%s = %s\". It's recommended to activate git\n"
- + "wire protocol version 2 to improve git fetch performance.",
- ConfigConstants.CONFIG_PROTOCOL_SECTION,
- ConfigConstants.CONFIG_KEY_VERSION,
- version));
+ "HINT: JGit option \"%s.%s = %s\". It's recommended to activate git\n"
+ + "wire protocol version 2 to improve git fetch performance.",
+ ConfigConstants.CONFIG_PROTOCOL_SECTION, ConfigConstants.CONFIG_KEY_VERSION, version);
}
}
} catch (IOException e) {
diff --git a/java/com/google/gerrit/pgm/init/PluginsDistribution.java b/java/com/google/gerrit/pgm/init/PluginsDistribution.java
index 73720c4..65c96ec 100644
--- a/java/com/google/gerrit/pgm/init/PluginsDistribution.java
+++ b/java/com/google/gerrit/pgm/init/PluginsDistribution.java
@@ -24,6 +24,8 @@
public interface Processor {
/**
+ * Processes the plugin
+ *
* @param pluginName the name of the plugin (without the .jar extension)
* @param in the content of the plugin .jar file. Implementors don't have to close this stream.
* @throws IOException implementations will typically propagate any IOException caused by
diff --git a/java/com/google/gerrit/pgm/init/api/BUILD b/java/com/google/gerrit/pgm/init/api/BUILD
index 693d319..733b9e3 100644
--- a/java/com/google/gerrit/pgm/init/api/BUILD
+++ b/java/com/google/gerrit/pgm/init/api/BUILD
@@ -11,6 +11,7 @@
"//java/com/google/gerrit/server",
"//lib:guava",
"//lib:jgit",
+ "//lib/errorprone:annotations",
"//lib/flogger:api",
"//lib/guice",
"//lib/guice:guice-assistedinject",
diff --git a/java/com/google/gerrit/pgm/init/api/ConsoleUI.java b/java/com/google/gerrit/pgm/init/api/ConsoleUI.java
index ea39a44..dffdde7 100644
--- a/java/com/google/gerrit/pgm/init/api/ConsoleUI.java
+++ b/java/com/google/gerrit/pgm/init/api/ConsoleUI.java
@@ -14,6 +14,8 @@
package com.google.gerrit.pgm.init.api;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
import com.google.gerrit.common.Die;
import java.io.Console;
import java.util.EnumSet;
@@ -37,7 +39,7 @@
return new Die("aborted by user");
}
- /** @return true if this is a batch UI that has no user interaction. */
+ /** Returns true if this is a batch UI that has no user interaction. */
public abstract boolean isBatch();
/** Display a header message before a series of prompts. */
@@ -75,6 +77,7 @@
public abstract String password(String fmt, Object... args);
/** Display an error message on the system stderr. */
+ @FormatMethod
public void error(String format, Object... args) {
System.err.println(String.format(format, args));
System.err.flush();
@@ -97,6 +100,7 @@
}
@Override
+ @FormatMethod
public boolean yesno(Boolean def, String fmt, Object... args) {
final String prompt = String.format(fmt, args);
for (; ; ) {
@@ -135,7 +139,8 @@
}
@Override
- public String readString(String def, String fmt, Object... args) {
+ @FormatMethod
+ public String readString(String def, @FormatString String fmt, Object... args) {
final String prompt = String.format(fmt, args);
String r;
if (def != null) {
@@ -154,7 +159,9 @@
}
@Override
- public String readString(String def, Set<String> allowedValues, String fmt, Object... args) {
+ @FormatMethod
+ public String readString(
+ String def, Set<String> allowedValues, @FormatString String fmt, Object... args) {
for (; ; ) {
String r = readString(def, fmt, args);
if (allowedValues.contains(r.toLowerCase())) {
@@ -171,6 +178,7 @@
}
@Override
+ @FormatMethod
public String password(String fmt, Object... args) {
final String prompt = String.format(fmt, args);
for (; ; ) {
@@ -195,6 +203,7 @@
}
@Override
+ @FormatMethod
public <T extends Enum<?>, A extends EnumSet<? extends T>> T readEnum(
T def, A options, String fmt, Object... args) {
final String prompt = String.format(fmt, args);
diff --git a/java/com/google/gerrit/pgm/util/SiteProgram.java b/java/com/google/gerrit/pgm/util/SiteProgram.java
index c3be0a4..c1ba896 100644
--- a/java/com/google/gerrit/pgm/util/SiteProgram.java
+++ b/java/com/google/gerrit/pgm/util/SiteProgram.java
@@ -52,7 +52,7 @@
name = "--site-path",
aliases = {"-d"},
usage = "Local directory containing site data")
- private void setSitePath(String path) {
+ void setSitePath(String path) {
sitePath = Paths.get(path).normalize();
}
@@ -64,7 +64,7 @@
this.sitePath = sitePath.normalize();
}
- /** @return the site path specified on the command line. */
+ /** Returns the site path specified on the command line. */
protected Path getSitePath() {
return sitePath;
}
@@ -76,12 +76,12 @@
}
}
- /** @return provides database connectivity and site path. */
+ /** Provides database connectivity and site path. */
protected Injector createDbInjector() {
return createDbInjector(false);
}
- /** @return provides database connectivity and site path. */
+ /** Provides database connectivity and site path. */
protected Injector createDbInjector(boolean enableMetrics) {
List<Module> modules = new ArrayList<>();
diff --git a/java/com/google/gerrit/server/CancellationMetrics.java b/java/com/google/gerrit/server/CancellationMetrics.java
index 2d0b878..f534ccb 100644
--- a/java/com/google/gerrit/server/CancellationMetrics.java
+++ b/java/com/google/gerrit/server/CancellationMetrics.java
@@ -14,11 +14,6 @@
package com.google.gerrit.server;
-import static com.google.common.base.Preconditions.checkState;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Splitter;
import com.google.gerrit.common.UsedAt;
import com.google.gerrit.metrics.Counter1;
import com.google.gerrit.metrics.Counter3;
@@ -48,7 +43,7 @@
.build(),
Field.ofString("request_uri", Metadata.Builder::restViewName)
.description(
- "The URI of the request to which the advisory deadline applied"
+ "The redacted URI of the request to which the advisory deadline applied"
+ " (only set for request_type = REST).")
.build(),
Field.ofString("deadline_id", (metadataBuilder, resolveAllUsers) -> {})
@@ -64,7 +59,7 @@
.build(),
Field.ofString("request_uri", Metadata.Builder::restViewName)
.description(
- "The URI of the request that was cancelled"
+ "The redacted URI of the request that was cancelled"
+ " (only set for request_type = REST).")
.build(),
Field.ofEnum(
@@ -87,17 +82,13 @@
public void countAdvisoryDeadline(RequestInfo requestInfo, String deadlineId) {
advisoryDeadlineCount.increment(
- requestInfo.requestType(),
- requestInfo.requestUri().map(CancellationMetrics::redactRequestUri).orElse(""),
- deadlineId);
+ requestInfo.requestType(), requestInfo.redactedRequestUri().orElse(""), deadlineId);
}
public void countCancelledRequest(
RequestInfo requestInfo, RequestStateProvider.Reason cancellationReason) {
cancelledRequestsCount.increment(
- requestInfo.requestType(),
- requestInfo.requestUri().map(CancellationMetrics::redactRequestUri).orElse(""),
- cancellationReason);
+ requestInfo.requestType(), requestInfo.redactedRequestUri().orElse(""), cancellationReason);
}
public void countCancelledRequest(
@@ -105,7 +96,7 @@
String requestUri,
RequestStateProvider.Reason cancellationReason) {
cancelledRequestsCount.increment(
- requestType.name(), CancellationMetrics.redactRequestUri(requestUri), cancellationReason);
+ requestType.name(), RequestInfo.redactRequestUri(requestUri), cancellationReason);
}
@UsedAt(UsedAt.Project.GOOGLE)
@@ -123,58 +114,4 @@
public void countForcefulReceiveTimeout() {
receiveTimeoutCount.increment("forceful");
}
-
- /**
- * Redacts resource IDs from the given request URI.
- *
- * <p>resource IDs in the request URI are replaced with '*'.
- *
- * @param requestUri a REST URI that has path segments that alternate between view name and
- * resource IDs (e.g. "/<view>", "/<view>/<id>", "/<view>/<id>/<view>",
- * "/<view>/<id>/<view>/<id>", "/<view>/<id>/<view>/<id>/<view>" etc.), must be given without
- * the '/a' prefix
- * @return the redacted request URI
- */
- @VisibleForTesting
- static String redactRequestUri(String requestUri) {
- requireNonNull(requestUri, "requestUri");
- checkState(
- !requestUri.startsWith("/a/"), "request URI must not start with '/a/': %s", requestUri);
-
- StringBuilder redactedRequestUri = new StringBuilder();
-
- boolean hasLeadingSlash = false;
- boolean hasTrailingSlash = false;
- if (requestUri.startsWith("/")) {
- hasLeadingSlash = true;
- requestUri = requestUri.substring(1);
- }
- if (requestUri.endsWith("/")) {
- hasTrailingSlash = true;
- requestUri = requestUri.substring(0, requestUri.length() - 1);
- }
-
- boolean idPathSegment = false;
- for (String pathSegment : Splitter.on('/').split(requestUri)) {
- if (!idPathSegment) {
- redactedRequestUri.append("/" + pathSegment);
- idPathSegment = true;
- } else {
- redactedRequestUri.append("/");
- if (!pathSegment.isEmpty()) {
- redactedRequestUri.append("*");
- }
- idPathSegment = false;
- }
- }
-
- if (!hasLeadingSlash) {
- redactedRequestUri.deleteCharAt(0);
- }
- if (hasTrailingSlash) {
- redactedRequestUri.append('/');
- }
-
- return redactedRequestUri.toString();
- }
}
diff --git a/java/com/google/gerrit/server/ChangeMessagesUtil.java b/java/com/google/gerrit/server/ChangeMessagesUtil.java
index d8b5d87..8366b09 100644
--- a/java/com/google/gerrit/server/ChangeMessagesUtil.java
+++ b/java/com/google/gerrit/server/ChangeMessagesUtil.java
@@ -127,8 +127,9 @@
}
/**
+ * Determines whether the tag starts with the autogenerated prefix
+ *
* @param tag value of a tag, or null.
- * @return whether the tag starts with the autogenerated prefix.
*/
public static boolean isAutogenerated(@Nullable String tag) {
return tag != null && tag.startsWith(AUTOGENERATED_TAG_PREFIX);
diff --git a/java/com/google/gerrit/server/ChangeUtil.java b/java/com/google/gerrit/server/ChangeUtil.java
index 46e8d33..d9edf42 100644
--- a/java/com/google/gerrit/server/ChangeUtil.java
+++ b/java/com/google/gerrit/server/ChangeUtil.java
@@ -53,7 +53,7 @@
public static final Ordering<PatchSet> PS_ID_ORDER =
Ordering.from(comparingInt(PatchSet::number));
- /** @return a new unique identifier for change message entities. */
+ /** Returns a new unique identifier for change message entities. */
public static String messageUuid() {
byte[] buf = new byte[8];
UUID_RANDOM.nextBytes(buf);
diff --git a/java/com/google/gerrit/server/CommentsUtil.java b/java/com/google/gerrit/server/CommentsUtil.java
index b18f499..3d3603f 100644
--- a/java/com/google/gerrit/server/CommentsUtil.java
+++ b/java/com/google/gerrit/server/CommentsUtil.java
@@ -450,12 +450,6 @@
/**
* Get NoteDb draft refs for a change.
*
- * <p>Works if NoteDb is not enabled, but the results are not meaningful.
- *
- * <p>This is just a simple ref scan, so the results may potentially include refs for zombie draft
- * comments. A zombie draft is one which has been published but the write to delete the draft ref
- * from All-Users failed.
- *
* @param changeId change ID.
* @return raw refs from All-Users repo.
*/
diff --git a/java/com/google/gerrit/server/CurrentUser.java b/java/com/google/gerrit/server/CurrentUser.java
index 7012944..0b5600d 100644
--- a/java/com/google/gerrit/server/CurrentUser.java
+++ b/java/com/google/gerrit/server/CurrentUser.java
@@ -103,7 +103,7 @@
return Optional.empty();
}
- /** @return unique name of the user for logging, never {@code null} */
+ /** Returns unique name of the user for logging, never {@code null} */
public String getLoggableName() {
return getUserName().orElseGet(() -> getClass().getSimpleName());
}
diff --git a/java/com/google/gerrit/server/DeadlineChecker.java b/java/com/google/gerrit/server/DeadlineChecker.java
index 5662e50..f41b1e3 100644
--- a/java/com/google/gerrit/server/DeadlineChecker.java
+++ b/java/com/google/gerrit/server/DeadlineChecker.java
@@ -30,6 +30,7 @@
import com.google.gerrit.server.cancellation.RequestStateProvider;
import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.util.time.TimeUtil;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import java.util.HashSet;
@@ -134,7 +135,7 @@
this(
serverConfig,
cancellationsMetrics,
- System.nanoTime(),
+ TimeUtil.nowNanos(),
requestInfo,
clientProvidedTimeoutValue);
}
@@ -236,7 +237,7 @@
@Override
public void checkIfCancelled(OnCancelled onCancelled) {
- long now = System.nanoTime();
+ long now = TimeUtil.nowNanos();
Set<String> exceededAdvisoryDeadlines = new HashSet<>();
advisoryDeadlines
diff --git a/java/com/google/gerrit/server/IdentifiedUser.java b/java/com/google/gerrit/server/IdentifiedUser.java
index 24ea9d2..eb3e324 100644
--- a/java/com/google/gerrit/server/IdentifiedUser.java
+++ b/java/com/google/gerrit/server/IdentifiedUser.java
@@ -343,15 +343,15 @@
}
/**
- * @return the user's user name; null if one has not been selected/assigned or if the user name is
- * empty.
+ * Returns the user's user name; null if one has not been selected/assigned or if the user name is
+ * empty.
*/
@Override
public Optional<String> getUserName() {
return state().userName();
}
- /** @return unique name of the user for logging, never {@code null} */
+ /** Returns unique name of the user for logging, never {@code null} */
@Override
public String getLoggableName() {
return getUserName()
diff --git a/java/com/google/gerrit/server/PerformanceMetrics.java b/java/com/google/gerrit/server/PerformanceMetrics.java
new file mode 100644
index 0000000..85452ce
--- /dev/null
+++ b/java/com/google/gerrit/server/PerformanceMetrics.java
@@ -0,0 +1,137 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server;
+
+import com.google.gerrit.common.Nullable;
+import com.google.gerrit.metrics.Counter3;
+import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
+import com.google.gerrit.metrics.MetricMaker;
+import com.google.gerrit.metrics.Timer3;
+import com.google.gerrit.server.logging.Metadata;
+import com.google.gerrit.server.logging.PerformanceLogger;
+import com.google.gerrit.server.logging.TraceContext;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import java.util.concurrent.TimeUnit;
+
+/** Performance logger that records the execution times as a metric. */
+@Singleton
+public class PerformanceMetrics implements PerformanceLogger {
+ private static final String OPERATION_LATENCY_METRIC_NAME = "performance/operations";
+ private static final String OPERATION_COUNT_METRIC_NAME = "performance/operations_count";
+ private static final String PLUGIN_OPERATION_COUNT_METRIC_NAME =
+ "performance/plugin_operations_count";
+
+ public final Timer3<String, String, String> operationsLatency;
+ public final Counter3<String, String, String> operationsCounter;
+ public final Counter3<String, String, String> pluginOperationsCounter;
+
+ @Inject
+ PerformanceMetrics(MetricMaker metricMaker) {
+ Field<String> operationNameField =
+ Field.ofString(
+ "operation_name",
+ (metadataBuilder, fieldValue) -> metadataBuilder.operationName(fieldValue))
+ .description("The operation that was performed.")
+ .build();
+ Field<String> changeIdentifierField =
+ Field.ofString("change_identifier", (metadataBuilder, fieldValue) -> {})
+ .description(
+ "The ID of the change for which the operation was performed"
+ + " (format = '<project>~<numeric-change-id>').")
+ .build();
+ Field<String> traceIdField =
+ Field.ofString("trace_id", (metadataBuilder, fieldValue) -> {})
+ .description("The ID of the trace if tracing was done.")
+ .build();
+ Field<String> requestField =
+ Field.ofString("request", (metadataBuilder, fieldValue) -> {})
+ .description(
+ "The request for which the operation was performed"
+ + " (format = '<request-type> <redacted-request-uri>').")
+ .build();
+ Field<String> pluginField =
+ Field.ofString(
+ "plugin", (metadataBuilder, fieldValue) -> metadataBuilder.pluginName(fieldValue))
+ .description("The name of the plugin that performed the operation.")
+ .build();
+
+ this.operationsLatency =
+ metricMaker.newTimer(
+ OPERATION_LATENCY_METRIC_NAME,
+ new Description("Latency of performing operations")
+ .setCumulative()
+ .setUnit(Description.Units.MILLISECONDS),
+ operationNameField,
+ changeIdentifierField,
+ traceIdField);
+ this.operationsCounter =
+ metricMaker.newCounter(
+ OPERATION_COUNT_METRIC_NAME,
+ new Description("Number of performed operations").setRate(),
+ operationNameField,
+ traceIdField,
+ requestField);
+ this.pluginOperationsCounter =
+ metricMaker.newCounter(
+ PLUGIN_OPERATION_COUNT_METRIC_NAME,
+ new Description("Number of performed operations by plugin").setRate(),
+ operationNameField,
+ pluginField,
+ traceIdField);
+ }
+
+ @Override
+ public void log(String operation, long durationMs) {
+ log(operation, durationMs, /* metadata= */ null);
+ }
+
+ @Override
+ public void log(String operation, long durationMs, @Nullable Metadata metadata) {
+ if (OPERATION_LATENCY_METRIC_NAME.equals(operation)) {
+ // Recording the timer metric below triggers writing a performance log entry. If we are called
+ // for this performance log entry we must abort to avoid an endless loop.
+ // In practice this should not happen since PerformanceLoggers are only called on close() of
+ // the PerformanceLogContext, and hence the performance log that gets written by the metric
+ // below gets ignored.
+ return;
+ }
+
+ String traceId = TraceContext.getTraceId().orElse("");
+
+ operationsLatency.record(
+ operation, formatChangeIdentifier(metadata), traceId, durationMs, TimeUnit.MILLISECONDS);
+
+ String requestTag = TraceContext.getTag(TraceRequestListener.TAG_REQUEST).orElse("");
+ operationsCounter.increment(operation, traceId, requestTag);
+
+ TraceContext.getPluginTag()
+ .ifPresent(pluginName -> pluginOperationsCounter.increment(operation, pluginName, traceId));
+ }
+
+ private String formatChangeIdentifier(@Nullable Metadata metadata) {
+ if (metadata == null
+ || (!metadata.projectName().isPresent() && !metadata.changeId().isPresent())) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(metadata.projectName().orElse("n/a"));
+ sb.append('~');
+ sb.append(metadata.changeId().map(String::valueOf).orElse("n/a"));
+ return sb.toString();
+ }
+}
diff --git a/java/com/google/gerrit/server/RequestConfig.java b/java/com/google/gerrit/server/RequestConfig.java
index 960907d..83cea5b 100644
--- a/java/com/google/gerrit/server/RequestConfig.java
+++ b/java/com/google/gerrit/server/RequestConfig.java
@@ -41,6 +41,7 @@
RequestConfig.Builder requestConfig = RequestConfig.builder(cfg, section, id);
requestConfig.requestTypes(parseRequestTypes(cfg, section, id));
requestConfig.requestUriPatterns(parseRequestUriPatterns(cfg, section, id));
+ requestConfig.excludedRequestUriPatterns(parseExcludedRequestUriPatterns(cfg, section, id));
requestConfig.accountIds(parseAccounts(cfg, section, id));
requestConfig.projectPatterns(parseProjectPatterns(cfg, section, id));
requestConfigs.add(requestConfig.build());
@@ -61,6 +62,11 @@
return parsePatterns(cfg, section, id, "requestUriPattern");
}
+ private static ImmutableSet<Pattern> parseExcludedRequestUriPatterns(
+ Config cfg, String section, String id) throws ConfigInvalidException {
+ return parsePatterns(cfg, section, id, "excludedRequestUriPattern");
+ }
+
private static ImmutableSet<Account.Id> parseAccounts(Config cfg, String section, String id)
throws ConfigInvalidException {
ImmutableSet.Builder<Account.Id> accountIds = ImmutableSet.builder();
@@ -115,6 +121,9 @@
/** pattern matching request URIs */
abstract ImmutableSet<Pattern> requestUriPatterns();
+ /** pattern matching request URIs to be excluded */
+ abstract ImmutableSet<Pattern> excludedRequestUriPatterns();
+
/** accounts IDs matching calling user */
abstract ImmutableSet<Account.Id> accountIds();
@@ -154,6 +163,13 @@
}
}
+ // If the request URI matches an excluded request URI pattern, then the request is not matched.
+ if (requestInfo.requestUri().isPresent()
+ && excludedRequestUriPatterns().stream()
+ .anyMatch(p -> p.matcher(requestInfo.requestUri().get()).matches())) {
+ return false;
+ }
+
// If in the request config accounts are set and none of them matches, then the request is not
// matched.
if (!accountIds().isEmpty()) {
@@ -200,6 +216,8 @@
abstract Builder requestUriPatterns(ImmutableSet<Pattern> requestUriPatterns);
+ abstract Builder excludedRequestUriPatterns(ImmutableSet<Pattern> excludedRequestUriPatterns);
+
abstract Builder accountIds(ImmutableSet<Account.Id> accountIds);
abstract Builder projectPatterns(ImmutableSet<Pattern> projectPatterns);
diff --git a/java/com/google/gerrit/server/RequestInfo.java b/java/com/google/gerrit/server/RequestInfo.java
index 053b3ac..791e228 100644
--- a/java/com/google/gerrit/server/RequestInfo.java
+++ b/java/com/google/gerrit/server/RequestInfo.java
@@ -14,7 +14,12 @@
package com.google.gerrit.server;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
+import com.google.common.base.Splitter;
import com.google.gerrit.common.UsedAt;
import com.google.gerrit.entities.Project;
import com.google.gerrit.server.logging.TraceContext;
@@ -55,6 +60,16 @@
*/
public abstract Optional<String> requestUri();
+ /**
+ * Redacted request URI.
+ *
+ * <p>Request URI where resource IDs are replaced by '*'.
+ */
+ @Memoized
+ public Optional<String> redactedRequestUri() {
+ return requestUri().map(RequestInfo::redactRequestUri);
+ }
+
/** The user that has sent the request. */
public abstract CurrentUser callingUser();
@@ -68,6 +83,67 @@
*/
public abstract Optional<Project.NameKey> project();
+ @Memoized
+ public String formatForLogging() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(requestType());
+ redactedRequestUri().ifPresent(redactedRequestUri -> sb.append(' ').append(redactedRequestUri));
+ return sb.toString();
+ }
+
+ /**
+ * Redacts resource IDs from the given request URI.
+ *
+ * <p>resource IDs in the request URI are replaced with '*'.
+ *
+ * @param requestUri a REST URI that has path segments that alternate between view name and
+ * resource IDs (e.g. "/<view>", "/<view>/<id>", "/<view>/<id>/<view>",
+ * "/<view>/<id>/<view>/<id>", "/<view>/<id>/<view>/<id>/<view>" etc.), must be given without
+ * the '/a' prefix
+ * @return the redacted request URI
+ */
+ static String redactRequestUri(String requestUri) {
+ requireNonNull(requestUri, "requestUri");
+ checkState(
+ !requestUri.startsWith("/a/"), "request URI must not start with '/a/': %s", requestUri);
+
+ StringBuilder redactedRequestUri = new StringBuilder();
+
+ boolean hasLeadingSlash = false;
+ boolean hasTrailingSlash = false;
+ if (requestUri.startsWith("/")) {
+ hasLeadingSlash = true;
+ requestUri = requestUri.substring(1);
+ }
+ if (requestUri.endsWith("/")) {
+ hasTrailingSlash = true;
+ requestUri = requestUri.substring(0, requestUri.length() - 1);
+ }
+
+ boolean idPathSegment = false;
+ for (String pathSegment : Splitter.on('/').split(requestUri)) {
+ if (!idPathSegment) {
+ redactedRequestUri.append("/" + pathSegment);
+ idPathSegment = true;
+ } else {
+ redactedRequestUri.append("/");
+ if (!pathSegment.isEmpty()) {
+ redactedRequestUri.append("*");
+ }
+ idPathSegment = false;
+ }
+ }
+
+ if (!hasLeadingSlash) {
+ redactedRequestUri.deleteCharAt(0);
+ }
+ if (hasTrailingSlash) {
+ redactedRequestUri.append('/');
+ }
+
+ return redactedRequestUri.toString();
+ }
+
public static RequestInfo.Builder builder(
RequestType requestType, CurrentUser callingUser, TraceContext traceContext) {
return builder().requestType(requestType).callingUser(callingUser).traceContext(traceContext);
diff --git a/java/com/google/gerrit/server/TraceRequestListener.java b/java/com/google/gerrit/server/TraceRequestListener.java
index 7136e47..6cc0982 100644
--- a/java/com/google/gerrit/server/TraceRequestListener.java
+++ b/java/com/google/gerrit/server/TraceRequestListener.java
@@ -28,6 +28,9 @@
*/
@Singleton
public class TraceRequestListener implements RequestListener {
+ public static String TAG_REQUEST = "request";
+
+ private static String TAG_PROJECT = "project";
private static String SECTION_TRACING = "tracing";
private final ImmutableList<RequestConfig> traceConfigs;
@@ -39,7 +42,8 @@
@Override
public void onRequest(RequestInfo requestInfo) {
- requestInfo.project().ifPresent(p -> requestInfo.traceContext().addTag("project", p));
+ requestInfo.traceContext().addTag(TAG_REQUEST, requestInfo.formatForLogging());
+ requestInfo.project().ifPresent(p -> requestInfo.traceContext().addTag(TAG_PROJECT, p));
traceConfigs.stream()
.filter(traceConfig -> traceConfig.matches(requestInfo))
.forEach(
diff --git a/java/com/google/gerrit/server/WebLinks.java b/java/com/google/gerrit/server/WebLinks.java
index 53a7661..3c69573 100644
--- a/java/com/google/gerrit/server/WebLinks.java
+++ b/java/com/google/gerrit/server/WebLinks.java
@@ -92,11 +92,12 @@
}
/**
+ * Returns links for patch sets
+ *
* @param project Project name.
* @param commit SHA1 of commit.
* @param commitMessage the commit message of the commit.
* @param branchName branch of the commit.
- * @return Links for patch sets.
*/
public ImmutableList<WebLinkInfo> getPatchSetLinks(
Project.NameKey project, String commit, String commitMessage, String branchName) {
@@ -106,11 +107,12 @@
}
/**
+ * Returns links for resolving conflicts
+ *
* @param project Project name.
* @param commit SHA1 of commit.
* @param commitMessage the commit message of the commit.
* @param branchName branch of the commit.
- * @return Links for resolving comflicts.
*/
public ImmutableList<WebLinkInfo> getResolveConflictsLinks(
Project.NameKey project, String commit, String commitMessage, String branchName) {
@@ -121,11 +123,12 @@
}
/**
+ * Returns links for patch sets
+ *
* @param project Project name.
* @param revision SHA1 of the parent revision.
* @param commitMessage the commit message of the parent revision.
* @param branchName branch of the revision (and parent revision).
- * @return Links for patch sets.
*/
public ImmutableList<WebLinkInfo> getParentLinks(
Project.NameKey project, String revision, String commitMessage, String branchName) {
@@ -135,10 +138,11 @@
}
/**
+ * Returns links for editing
+ *
* @param project Project name.
* @param revision SHA1 of revision.
* @param file File name.
- * @return Links for editing.
*/
public ImmutableList<WebLinkInfo> getEditLinks(String project, String revision, String file) {
return Patch.isMagic(file)
@@ -147,10 +151,11 @@
}
/**
+ * Returns links for files
+ *
* @param project Project name.
* @param revision SHA1 of revision.
* @param file File name.
- * @return Links for files.
*/
public ImmutableList<WebLinkInfo> getFileLinks(String project, String revision, String file) {
return Patch.isMagic(file)
@@ -159,10 +164,11 @@
}
/**
+ * Returns links for file history
+ *
* @param project Project name.
* @param revision SHA1 of revision.
* @param file File name.
- * @return Links for file history
*/
public ImmutableList<WebLinkInfo> getFileHistoryLinks(
String project, String revision, String file) {
@@ -176,6 +182,8 @@
}
/**
+ * Returns links for file diffs
+ *
* @param project Project name.
* @param patchSetIdA Patch set ID of side A, <code>null</code> if no base patch set was selected.
* @param revisionA SHA1 of revision of side A.
@@ -183,7 +191,6 @@
* @param patchSetIdB Patch set ID of side B.
* @param revisionB SHA1 of revision of side B.
* @param fileB File name of side B.
- * @return Links for file diffs.
*/
public ImmutableList<DiffWebLinkInfo> getDiffLinks(
String project,
@@ -214,26 +221,29 @@
}
/**
+ * Returns links for projects
+ *
* @param project Project name.
- * @return Links for projects.
*/
public ImmutableList<WebLinkInfo> getProjectLinks(String project) {
return filterLinks(projectLinks, webLink -> webLink.getProjectWeblink(project));
}
/**
+ * Returns links for branches
+ *
* @param project Project name
* @param branch Branch name
- * @return Links for branches.
*/
public ImmutableList<WebLinkInfo> getBranchLinks(String project, String branch) {
return filterLinks(branchLinks, webLink -> webLink.getBranchWebLink(project, branch));
}
/**
+ * Returns links for the tag
+ *
* @param project Project name
* @param tag Tag name
- * @return Links for tags.
*/
public ImmutableList<WebLinkInfo> getTagLinks(String project, String tag) {
return filterLinks(tagLinks, webLink -> webLink.getTagWebLink(project, tag));
diff --git a/java/com/google/gerrit/server/account/AccountLimits.java b/java/com/google/gerrit/server/account/AccountLimits.java
index 1845f5b..5549d28 100644
--- a/java/com/google/gerrit/server/account/AccountLimits.java
+++ b/java/com/google/gerrit/server/account/AccountLimits.java
@@ -51,7 +51,7 @@
user = currentUser;
}
- /** @return which priority queue the user's tasks should be submitted to. */
+ /** Returns which priority queue the user's tasks should be submitted to. */
public QueueProvider.QueueType getQueueType() {
// If a non-generic group (that is not Anonymous Users or Registered Users)
// grants us INTERACTIVE permission, use the INTERACTIVE queue even if
@@ -99,7 +99,7 @@
return getRange(GlobalCapability.QUERY_LIMIT).getMax();
}
- /** @return true if the user has a permission rule specifying the range. */
+ /** Returns true if the user has a permission rule specifying the range. */
public boolean hasExplicitRange(String permission) {
return GlobalCapability.hasRange(permission) && !getRules(permission).isEmpty();
}
diff --git a/java/com/google/gerrit/server/account/AccountManager.java b/java/com/google/gerrit/server/account/AccountManager.java
index 987e7e3..407d2f7 100644
--- a/java/com/google/gerrit/server/account/AccountManager.java
+++ b/java/com/google/gerrit/server/account/AccountManager.java
@@ -118,7 +118,7 @@
this.externalIdKeyFactory = externalIdKeyFactory;
}
- /** @return user identified by this external identity string */
+ /** Returns a user identified by this external identity string */
public Optional<Account.Id> lookup(String externalId) throws AccountException {
try {
return externalIds.get(externalIdKeyFactory.parse(externalId)).map(ExternalId::accountId);
diff --git a/java/com/google/gerrit/server/account/GroupBackend.java b/java/com/google/gerrit/server/account/GroupBackend.java
index d6360c5..91edaf2 100644
--- a/java/com/google/gerrit/server/account/GroupBackend.java
+++ b/java/com/google/gerrit/server/account/GroupBackend.java
@@ -26,7 +26,7 @@
/** Implementations of GroupBackend provide lookup and membership accessors to a group system. */
@ExtensionPoint
public interface GroupBackend {
- /** @return {@code true} if the backend can operate on the UUID. */
+ /** Returns {@code true} if the backend can operate on the UUID. */
boolean handles(AccountGroup.UUID uuid);
/**
@@ -38,12 +38,12 @@
@Nullable
GroupDescription.Basic get(AccountGroup.UUID uuid);
- /** @return suggestions for the group name sorted by name. */
+ /** Returns suggestions for the group name sorted by name. */
Collection<GroupReference> suggest(String name, @Nullable ProjectState project);
- /** @return the group membership checker for the backend. */
+ /** Returns the group membership checker for the backend. */
GroupMembership membershipsOf(CurrentUser user);
- /** @return {@code true} if the group with the given UUID is visible to all registered users. */
+ /** Returns {@code true} if the group with the given UUID is visible to all registered users. */
boolean isVisibleToAll(AccountGroup.UUID uuid);
}
diff --git a/java/com/google/gerrit/server/account/GroupCache.java b/java/com/google/gerrit/server/account/GroupCache.java
index d8cac71..1e28d7d 100644
--- a/java/com/google/gerrit/server/account/GroupCache.java
+++ b/java/com/google/gerrit/server/account/GroupCache.java
@@ -103,6 +103,10 @@
*/
void evict(AccountGroup.UUID groupUuid);
- /** @see #evict(AccountGroup.UUID) */
+ /**
+ * Removes the association of the given UUIDs with groups
+ *
+ * <p>See {@link #evict(AccountGroup.UUID)}
+ */
void evict(Collection<AccountGroup.UUID> groupUuid);
}
diff --git a/java/com/google/gerrit/server/account/GroupIncludeCache.java b/java/com/google/gerrit/server/account/GroupIncludeCache.java
index 6547619..d92d9fc 100644
--- a/java/com/google/gerrit/server/account/GroupIncludeCache.java
+++ b/java/com/google/gerrit/server/account/GroupIncludeCache.java
@@ -37,7 +37,7 @@
*/
Collection<AccountGroup.UUID> parentGroupsOf(AccountGroup.UUID groupId);
- /** @return set of any UUIDs that are not internal groups. */
+ /** Returns set of any UUIDs that are not internal groups. */
Collection<AccountGroup.UUID> allExternalMembers();
void evictGroupsWithMember(Account.Id memberId);
diff --git a/java/com/google/gerrit/server/account/Realm.java b/java/com/google/gerrit/server/account/Realm.java
index d56ed07..3f642f7 100644
--- a/java/com/google/gerrit/server/account/Realm.java
+++ b/java/com/google/gerrit/server/account/Realm.java
@@ -41,10 +41,10 @@
void onCreateAccount(AuthRequest who, Account account);
- /** @return true if the user has the given email address. */
+ /** Returns true if the user has the given email address. */
boolean hasEmailAddress(IdentifiedUser who, String email);
- /** @return all known email addresses for the identified user. */
+ /** Returns all known email addresses for the identified user. */
Set<String> getEmailAddresses(IdentifiedUser who);
/**
@@ -56,19 +56,13 @@
*/
Account.Id lookup(String accountName) throws IOException;
- /**
- * @return true if the account is active.
- * @throws NamingException
- * @throws LoginException
- * @throws AccountException
- * @throws IOException
- */
+ /** Returns true if the account is active. */
default boolean isActive(@SuppressWarnings("unused") String username)
throws LoginException, NamingException, AccountException, IOException {
return true;
}
- /** @return true if the account is backed by the realm, false otherwise. */
+ /** Returns true if the account is backed by the realm, false otherwise. */
default boolean accountBelongsToRealm(
@SuppressWarnings("unused") Collection<ExternalId> externalIds) {
return false;
diff --git a/java/com/google/gerrit/server/account/ServiceUserClassifierImpl.java b/java/com/google/gerrit/server/account/ServiceUserClassifierImpl.java
index 27ac9f4..db030f9 100644
--- a/java/com/google/gerrit/server/account/ServiceUserClassifierImpl.java
+++ b/java/com/google/gerrit/server/account/ServiceUserClassifierImpl.java
@@ -76,7 +76,7 @@
.get(toTraverse.remove(0))
.orElseThrow(() -> new IllegalStateException("invalid subgroup"));
if (seen.contains(currentGroup.getGroupUUID())) {
- logger.atWarning().log(
+ logger.atFine().log(
"Skipping %s because it's a cyclic subgroup", currentGroup.getGroupUUID());
continue;
}
diff --git a/java/com/google/gerrit/server/account/VersionedAuthorizedKeys.java b/java/com/google/gerrit/server/account/VersionedAuthorizedKeys.java
index 30021e6..555a2c1 100644
--- a/java/com/google/gerrit/server/account/VersionedAuthorizedKeys.java
+++ b/java/com/google/gerrit/server/account/VersionedAuthorizedKeys.java
@@ -206,7 +206,6 @@
*
* @param pub the public SSH key to be added
* @return the new SSH key
- * @throws InvalidSshKeyException
*/
private AccountSshKey addKey(String pub) throws InvalidSshKeyException {
checkLoaded();
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalId.java b/java/com/google/gerrit/server/account/externalids/ExternalId.java
index bbee1b2..30f4094 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalId.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalId.java
@@ -19,6 +19,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
@@ -190,6 +191,7 @@
* notes branch.
*/
@SuppressWarnings("deprecation") // Use Hashing.sha1 for compatibility.
+ @Memoized
public ObjectId sha1() {
String keyString = isCaseInsensitive() ? get().toLowerCase(Locale.US) : get();
return ObjectId.fromRaw(Hashing.sha1().hashString(keyString, UTF_8).asBytes());
@@ -225,7 +227,8 @@
}
@Override
- public final int hashCode() {
+ @Memoized
+ public int hashCode() {
return Objects.hash(sha1());
}
@@ -301,8 +304,9 @@
&& Objects.equals(password(), o.password());
}
+ @Memoized
@Override
- public final int hashCode() {
+ public int hashCode() {
return Objects.hash(key(), accountId(), isCaseInsensitive(), email(), password());
}
@@ -320,7 +324,8 @@
* </pre>
*/
@Override
- public final String toString() {
+ @Memoized
+ public String toString() {
Config c = new Config();
writeToConfig(c);
return c.toText();
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java b/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
index 5d81a25..72d703b 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalIdCacheLoader.java
@@ -95,7 +95,9 @@
new Description("Total number of external ID cache reloads from Git.")
.setRate()
.setUnit("updates"),
- Field.ofBoolean("partial", Metadata.Builder::partial).build());
+ Field.ofBoolean("partial", Metadata.Builder::partial)
+ .description("Whether the reload was partial.")
+ .build());
this.reloadDifferential =
metricMaker.newTimer(
"notedb/external_id_partial_read_latency",
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalIdFactory.java b/java/com/google/gerrit/server/account/externalids/ExternalIdFactory.java
index 0c96f58..ee42d67 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalIdFactory.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalIdFactory.java
@@ -24,9 +24,9 @@
import com.google.gerrit.entities.Account;
import com.google.gerrit.server.account.HashedPassword;
import com.google.gerrit.server.account.externalids.ExternalId.Key;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
import java.util.Set;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
diff --git a/java/com/google/gerrit/server/account/externalids/ExternalIdKeyFactory.java b/java/com/google/gerrit/server/account/externalids/ExternalIdKeyFactory.java
index 37c2604..95df4a9 100644
--- a/java/com/google/gerrit/server/account/externalids/ExternalIdKeyFactory.java
+++ b/java/com/google/gerrit/server/account/externalids/ExternalIdKeyFactory.java
@@ -14,18 +14,46 @@
package com.google.gerrit.server.account.externalids;
+import com.google.common.annotations.VisibleForTesting;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.server.config.AuthConfig;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
+import com.google.inject.ImplementedBy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
@Singleton
public class ExternalIdKeyFactory {
+ @ImplementedBy(ConfigImpl.class)
+ public interface Config {
+ boolean isUserNameCaseInsensitive();
+ }
+
+ /**
+ * Default implementation {@link Config}
+ *
+ * <p>Internally in google we are using different implementation.
+ */
+ @Singleton
+ public static class ConfigImpl implements Config {
+ private final boolean isUserNameCaseInsensitive;
+
+ @VisibleForTesting
+ @Inject
+ public ConfigImpl(AuthConfig authConfig) {
+ this.isUserNameCaseInsensitive = authConfig.isUserNameCaseInsensitive();
+ }
+
+ @Override
+ public boolean isUserNameCaseInsensitive() {
+ return isUserNameCaseInsensitive;
+ }
+ }
+
private final boolean isUserNameCaseInsensitive;
@Inject
- public ExternalIdKeyFactory(AuthConfig authConfig) {
- this.isUserNameCaseInsensitive = authConfig.isUserNameCaseInsensitive();
+ public ExternalIdKeyFactory(Config config) {
+ this.isUserNameCaseInsensitive = config.isUserNameCaseInsensitive();
}
/**
diff --git a/java/com/google/gerrit/server/approval/ApprovalCacheImpl.java b/java/com/google/gerrit/server/approval/ApprovalCacheImpl.java
index a01931c..fd31da9 100644
--- a/java/com/google/gerrit/server/approval/ApprovalCacheImpl.java
+++ b/java/com/google/gerrit/server/approval/ApprovalCacheImpl.java
@@ -36,7 +36,7 @@
import com.google.protobuf.ByteString;
import java.util.concurrent.ExecutionException;
-/** @see ApprovalCache */
+/** Implementation of the {@link ApprovalCache} interface */
public class ApprovalCacheImpl implements ApprovalCache {
private static final String CACHE_NAME = "approvals";
diff --git a/java/com/google/gerrit/server/approval/ApprovalInference.java b/java/com/google/gerrit/server/approval/ApprovalInference.java
index dfc5bdb..4cb080a 100644
--- a/java/com/google/gerrit/server/approval/ApprovalInference.java
+++ b/java/com/google/gerrit/server/approval/ApprovalInference.java
@@ -101,20 +101,29 @@
*/
Iterable<PatchSetApproval> forPatchSet(
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig) {
+ PatchSet patchset = notes.getPatchSets().get(psId);
+ if (patchset == null) {
+ return Collections.emptyList();
+ }
+ return forPatchSet(notes, patchset, rw, repoConfig);
+ }
+
+ Iterable<PatchSetApproval> forPatchSet(
+ ChangeNotes notes, PatchSet ps, @Nullable RevWalk rw, @Nullable Config repoConfig) {
ProjectState project;
try (TraceTimer traceTimer =
TraceContext.newTimer(
"Computing labels for patch set",
Metadata.builder()
.changeId(notes.load().getChangeId().get())
- .patchSetId(psId.get())
+ .patchSetId(ps.id().get())
.build())) {
project =
projectCache
.get(notes.getProjectName())
.orElseThrow(illegalState(notes.getProjectName()));
Collection<PatchSetApproval> approvals =
- getForPatchSetWithoutNormalization(notes, project, psId, rw, repoConfig);
+ getForPatchSetWithoutNormalization(notes, project, ps, rw, repoConfig);
return labelNormalizer.normalize(notes, approvals).getNormalized();
}
}
@@ -311,13 +320,13 @@
private boolean canCopyBasedOnCopyCondition(
ChangeNotes changeNotes,
PatchSetApproval psa,
- PatchSet.Id psId,
+ PatchSet patchSet,
LabelType type,
ChangeKind changeKind) {
if (!type.getCopyCondition().isPresent()) {
return false;
}
- ApprovalContext ctx = ApprovalContext.create(changeNotes, psa, psId, changeKind);
+ ApprovalContext ctx = ApprovalContext.create(changeNotes, psa, patchSet, changeKind);
try {
// Use a request context to run checks as an internal user with expanded visibility. This is
// so that the output of the copy condition does not depend on who is running the current
@@ -336,7 +345,7 @@
private Collection<PatchSetApproval> getForPatchSetWithoutNormalization(
ChangeNotes notes,
ProjectState project,
- PatchSet.Id psId,
+ PatchSet patchSet,
@Nullable RevWalk rw,
@Nullable Config repoConfig) {
checkState(
@@ -345,15 +354,11 @@
project.getNameKey(),
notes.getProjectName());
- PatchSet ps = notes.load().getPatchSets().get(psId);
- if (ps == null) {
- return Collections.emptyList();
- }
-
+ PatchSet.Id psId = patchSet.id();
// Add approvals on the given patch set to the result
Table<String, Account.Id, PatchSetApproval> resultByUser = HashBasedTable.create();
ImmutableList<PatchSetApproval> approvalsForGivenPatchSet =
- notes.load().getApprovals().get(ps.id());
+ notes.load().getApprovals().get(patchSet.id());
approvalsForGivenPatchSet.forEach(psa -> resultByUser.put(psa.label(), psa.accountId(), psa));
// Bail out immediately if this is the first patch set. Return only approvals granted on the
@@ -376,23 +381,27 @@
Iterable<PatchSetApproval> priorApprovals =
getForPatchSetWithoutNormalization(
- notes, project, priorPatchSet.getValue().id(), rw, repoConfig);
+ notes, project, priorPatchSet.getValue(), rw, repoConfig);
if (!priorApprovals.iterator().hasNext()) {
return resultByUser.values();
}
// Add labels from the previous patch set to the result in case the label isn't already there
// and settings as well as change kind allow copying.
- ChangeKind kind =
+ ChangeKind changeKind =
changeKindCache.getChangeKind(
project.getNameKey(),
rw,
repoConfig,
priorPatchSet.getValue().commitId(),
- ps.commitId());
+ patchSet.commitId());
logger.atFine().log(
"change kind for patch set %d of change %d against prior patch set %s is %s",
- ps.id().get(), ps.id().changeId().get(), priorPatchSet.getValue().id().changeId(), kind);
+ patchSet.id().get(),
+ patchSet.id().changeId().get(),
+ priorPatchSet.getValue().id().changeId(),
+ changeKind);
+
Map<String, FileDiffOutput> modifiedFiles = null;
Map<String, FileDiffOutput> modifiedFilesLastPatchSet = null;
LabelTypes labelTypes = project.getLabelTypes();
@@ -405,7 +414,7 @@
if (modifiedFiles == null
&& type.isPresent()
&& type.get().isCopyAllScoresIfListOfFilesDidNotChange()) {
- modifiedFiles = listModifiedFiles(project, ps);
+ modifiedFiles = listModifiedFiles(project, patchSet);
modifiedFilesLastPatchSet = listModifiedFiles(project, priorPatchSet.getValue());
}
if (!type.isPresent()) {
@@ -421,11 +430,17 @@
continue;
}
if (!canCopyBasedOnBooleanLabelConfigs(
- project, psa, ps.id(), kind, type.get(), modifiedFiles, modifiedFilesLastPatchSet)
- && !canCopyBasedOnCopyCondition(notes, psa, ps.id(), type.get(), kind)) {
+ project,
+ psa,
+ patchSet.id(),
+ changeKind,
+ type.get(),
+ modifiedFiles,
+ modifiedFilesLastPatchSet)
+ && !canCopyBasedOnCopyCondition(notes, psa, patchSet, type.get(), changeKind)) {
continue;
}
- resultByUser.put(psa.label(), psa.accountId(), psa.copyWithPatchSet(ps.id()));
+ resultByUser.put(psa.label(), psa.accountId(), psa.copyWithPatchSet(patchSet.id()));
}
return resultByUser.values();
}
diff --git a/java/com/google/gerrit/server/approval/ApprovalsUtil.java b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
index a1cdd99..c2e35d2 100644
--- a/java/com/google/gerrit/server/approval/ApprovalsUtil.java
+++ b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
@@ -278,7 +278,6 @@
* @param ps patch set being approved.
* @param user user adding approvals.
* @param approvals approvals to add.
- * @throws RestApiException
*/
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
ChangeUpdate update,
@@ -349,6 +348,10 @@
return approvalInference.forPatchSet(notes, psId, rw, repoConfig);
}
+ public Iterable<PatchSetApproval> byPatchSet(ChangeNotes notes, PatchSet patchSet) {
+ return approvalInference.forPatchSet(notes, patchSet, /* rw= */ null, /* repoConfig= */ null);
+ }
+
public Iterable<PatchSetApproval> byPatchSet(ChangeNotes notes, PatchSet.Id psId) {
return approvalCache.get(notes, psId);
}
diff --git a/java/com/google/gerrit/server/auth/AuthBackend.java b/java/com/google/gerrit/server/auth/AuthBackend.java
index 9ec3366..424ee43 100644
--- a/java/com/google/gerrit/server/auth/AuthBackend.java
+++ b/java/com/google/gerrit/server/auth/AuthBackend.java
@@ -20,7 +20,7 @@
@ExtensionPoint
public interface AuthBackend {
- /** @return an identifier that uniquely describes the backend. */
+ /** Returns an identifier that uniquely describes the backend. */
String getDomain();
/**
diff --git a/java/com/google/gerrit/server/auth/AuthUser.java b/java/com/google/gerrit/server/auth/AuthUser.java
index 987f086..9e1c5ec 100644
--- a/java/com/google/gerrit/server/auth/AuthUser.java
+++ b/java/com/google/gerrit/server/auth/AuthUser.java
@@ -52,18 +52,18 @@
this.username = username;
}
- /** @return the globally unique identifier. */
+ /** Returns the globally unique identifier. */
public final UUID getUUID() {
return uuid;
}
- /** @return the backend specific user name, or null if one does not exist. */
+ /** Returns the backend specific user name, or null if one does not exist. */
@Nullable
public final String getUsername() {
return username;
}
- /** @return {@code true} if {@link #getUsername()} is not null. */
+ /** Returns {@code true} if {@link #getUsername()} is not null. */
public final boolean hasUsername() {
return getUsername() != null;
}
diff --git a/java/com/google/gerrit/server/cache/CacheMetrics.java b/java/com/google/gerrit/server/cache/CacheMetrics.java
index 12194e7..f1fd4a8 100644
--- a/java/com/google/gerrit/server/cache/CacheMetrics.java
+++ b/java/com/google/gerrit/server/cache/CacheMetrics.java
@@ -35,7 +35,9 @@
@Singleton
public class CacheMetrics {
private static final Field<String> F_NAME =
- Field.ofString("cache_name", Metadata.Builder::cacheName).build();
+ Field.ofString("cache_name", Metadata.Builder::cacheName)
+ .description("The name of the cache.")
+ .build();
@Inject
public CacheMetrics(
diff --git a/java/com/google/gerrit/server/cache/ForwardingRemovalListener.java b/java/com/google/gerrit/server/cache/ForwardingRemovalListener.java
index ee672cd..28d57e6 100644
--- a/java/com/google/gerrit/server/cache/ForwardingRemovalListener.java
+++ b/java/com/google/gerrit/server/cache/ForwardingRemovalListener.java
@@ -25,9 +25,6 @@
/**
* This listener dispatches removal events to all other RemovalListeners attached via the DynamicSet
* API.
- *
- * @param <K>
- * @param <V>
*/
@SuppressWarnings("rawtypes")
public class ForwardingRemovalListener<K, V> implements RemovalListener<K, V> {
diff --git a/java/com/google/gerrit/server/change/AddReviewersOp.java b/java/com/google/gerrit/server/change/AddReviewersOp.java
index a333ce5..cbbd01a 100644
--- a/java/com/google/gerrit/server/change/AddReviewersOp.java
+++ b/java/com/google/gerrit/server/change/AddReviewersOp.java
@@ -219,8 +219,13 @@
.map(r -> accountCache.get(r.accountId()))
.flatMap(Streams::stream)
.collect(toList());
- reviewerAdded.fire(
- ctx.getChangeData(change), patchSet, reviewers, ctx.getAccount(), ctx.getWhen());
+ eventSender =
+ () ->
+ reviewerAdded.fire(
+ ctx.getChangeData(change), patchSet, reviewers, ctx.getAccount(), ctx.getWhen());
+ if (sendEvent) {
+ sendEvent();
+ }
}
}
}
diff --git a/java/com/google/gerrit/server/change/ChangeFinder.java b/java/com/google/gerrit/server/change/ChangeFinder.java
index ba104d8..9f253de 100644
--- a/java/com/google/gerrit/server/change/ChangeFinder.java
+++ b/java/com/google/gerrit/server/change/ChangeFinder.java
@@ -96,6 +96,7 @@
.setRate()
.setUnit("requests"),
Field.ofEnum(ChangeIdType.class, "change_id_type", Metadata.Builder::changeIdType)
+ .description("The type of the change identifier.")
.build());
}
diff --git a/java/com/google/gerrit/server/change/ChangeJson.java b/java/com/google/gerrit/server/change/ChangeJson.java
index 5efcf59..db25dc7 100644
--- a/java/com/google/gerrit/server/change/ChangeJson.java
+++ b/java/com/google/gerrit/server/change/ChangeJson.java
@@ -79,6 +79,7 @@
import com.google.gerrit.extensions.common.ProblemInfo;
import com.google.gerrit.extensions.common.ReviewerUpdateInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
+import com.google.gerrit.extensions.common.SubmitRecordInfo;
import com.google.gerrit.extensions.common.SubmitRequirementExpressionInfo;
import com.google.gerrit.extensions.common.SubmitRequirementResultInfo;
import com.google.gerrit.extensions.common.TrackingIdInfo;
@@ -369,6 +370,14 @@
return reqInfos;
}
+ private Collection<SubmitRecordInfo> submitRecordsFor(ChangeData cd) {
+ List<SubmitRecordInfo> submitRecordInfos = new ArrayList<>();
+ for (SubmitRecord record : cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT)) {
+ submitRecordInfos.add(submitRecordToInfo(record));
+ }
+ return submitRecordInfos;
+ }
+
private static Collection<SubmitRequirementResultInfo> submitRequirementsFor(ChangeData cd) {
Collection<SubmitRequirementResultInfo> reqInfos = new ArrayList<>();
Map<SubmitRequirement, SubmitRequirementResult> requirements = cd.submitRequirements();
@@ -383,6 +392,34 @@
return new LegacySubmitRequirementInfo(status.name(), req.fallbackText(), req.type());
}
+ private SubmitRecordInfo submitRecordToInfo(SubmitRecord record) {
+ SubmitRecordInfo info = new SubmitRecordInfo();
+ if (record.status != null) {
+ info.status = SubmitRecordInfo.Status.valueOf(record.status.name());
+ }
+ info.ruleName = record.ruleName;
+ info.errorMessage = record.errorMessage;
+ if (record.labels != null) {
+ info.labels = new ArrayList<>();
+ for (SubmitRecord.Label label : record.labels) {
+ SubmitRecordInfo.Label labelInfo = new SubmitRecordInfo.Label();
+ labelInfo.label = label.label;
+ if (label.status != null) {
+ labelInfo.status = SubmitRecordInfo.Label.Status.valueOf(label.status.name());
+ }
+ labelInfo.appliedBy = accountLoader.get(label.appliedBy);
+ info.labels.add(labelInfo);
+ }
+ }
+ if (record.requirements != null) {
+ info.requirements = new ArrayList<>();
+ for (LegacySubmitRequirement requirement : record.requirements) {
+ info.requirements.add(requirementToInfo(requirement, record.status));
+ }
+ }
+ return info;
+ }
+
private static SubmitRequirementResultInfo submitRequirementToInfo(
SubmitRequirement req, SubmitRequirementResult result) {
SubmitRequirementResultInfo info = new SubmitRequirementResultInfo();
@@ -662,6 +699,7 @@
out.labels = labelsJson.labelsFor(accountLoader, cd, has(LABELS), has(DETAILED_LABELS));
out.requirements = requirementsFor(cd);
+ out.submitRecords = submitRecordsFor(cd);
if (has(SUBMIT_REQUIREMENTS)) {
out.submitRequirements = submitRequirementsFor(cd);
}
diff --git a/java/com/google/gerrit/server/change/ChangeResource.java b/java/com/google/gerrit/server/change/ChangeResource.java
index 0d0df0d..970f1b5 100644
--- a/java/com/google/gerrit/server/change/ChangeResource.java
+++ b/java/com/google/gerrit/server/change/ChangeResource.java
@@ -140,7 +140,7 @@
return changeData.getId();
}
- /** @return true if {@link #getUser()} is the change's owner. */
+ /** Returns true if {@link #getUser()} is the change's owner. */
public boolean isUserOwner() {
Account.Id owner = getChange().getOwner();
return user.isIdentifiedUser() && user.asIdentifiedUser().getAccountId().equals(owner);
diff --git a/java/com/google/gerrit/server/change/DeleteReviewerOp.java b/java/com/google/gerrit/server/change/DeleteReviewerOp.java
index a26f107..1e40429 100644
--- a/java/com/google/gerrit/server/change/DeleteReviewerOp.java
+++ b/java/com/google/gerrit/server/change/DeleteReviewerOp.java
@@ -202,16 +202,23 @@
"Cannot email update for change %s", currChange.getId());
}
}
- reviewerDeleted.fire(
- ctx.getChangeData(currChange),
- patchSet,
- accountCache.get(reviewer.id()).orElse(AccountState.forAccount(reviewer)),
- ctx.getAccount(),
- mailMessage,
- newApprovals,
- oldApprovals,
- notify.handling(),
- ctx.getWhen());
+
+ NotifyHandling notifyHandling = notify.handling();
+ eventSender =
+ () ->
+ reviewerDeleted.fire(
+ ctx.getChangeData(currChange),
+ patchSet,
+ accountCache.get(reviewer.id()).orElse(AccountState.forAccount(reviewer)),
+ ctx.getAccount(),
+ mailMessage,
+ newApprovals,
+ oldApprovals,
+ notifyHandling,
+ ctx.getWhen());
+ if (sendEvent) {
+ sendEvent();
+ }
}
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId) {
diff --git a/java/com/google/gerrit/server/change/EmailReviewComments.java b/java/com/google/gerrit/server/change/EmailReviewComments.java
index d433c4e..3c7ea44 100644
--- a/java/com/google/gerrit/server/change/EmailReviewComments.java
+++ b/java/com/google/gerrit/server/change/EmailReviewComments.java
@@ -45,6 +45,8 @@
// TODO(dborowitz/wyatta): Rationalize these arguments so HTML and text templates are operating
// on the same set of inputs.
/**
+ * Creates handle for sending email
+ *
* @param notify setting for handling notification.
* @param notes change notes.
* @param patchSet patch set corresponding to the top-level op
@@ -57,7 +59,6 @@
* contents should *not* include a "Patch set N" header or "(M comments)" footer, as these
* will be added automatically in soy in a structured way.
* @param labels labels applied as part of this review operation.
- * @return handle for sending email.
*/
EmailReviewComments create(
NotifyResolver.Result notify,
diff --git a/java/com/google/gerrit/server/change/FileContentUtil.java b/java/com/google/gerrit/server/change/FileContentUtil.java
index 49c1fe2..c54b902 100644
--- a/java/com/google/gerrit/server/change/FileContentUtil.java
+++ b/java/com/google/gerrit/server/change/FileContentUtil.java
@@ -76,8 +76,6 @@
* @param parent A 1-based parent index to get the content from instead. Null if the content
* should be obtained from {@code revstr} instead.
* @return Content of the file as {@code BinaryResult}.
- * @throws ResourceNotFoundException
- * @throws IOException
*/
public BinaryResult getContent(
ProjectState project, ObjectId revstr, String path, @Nullable Integer parent)
diff --git a/java/com/google/gerrit/server/change/GetRelatedChangesUtil.java b/java/com/google/gerrit/server/change/GetRelatedChangesUtil.java
new file mode 100644
index 0000000..b1f9726
--- /dev/null
+++ b/java/com/google/gerrit/server/change/GetRelatedChangesUtil.java
@@ -0,0 +1,119 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.change;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.stream.Collectors.toSet;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.index.IndexConfig;
+import com.google.gerrit.server.permissions.PermissionBackendException;
+import com.google.gerrit.server.query.change.ChangeData;
+import com.google.gerrit.server.query.change.InternalChangeQuery;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/** Utility class that gets the ancestor changes and the descendent changes of a specific change. */
+@Singleton
+public class GetRelatedChangesUtil {
+ private static final FluentLogger logger = FluentLogger.forEnclosingClass();
+
+ private final Provider<InternalChangeQuery> queryProvider;
+ private final RelatedChangesSorter sorter;
+ private final IndexConfig indexConfig;
+ private final ChangeData.Factory changeDataFactory;
+
+ @Inject
+ GetRelatedChangesUtil(
+ Provider<InternalChangeQuery> queryProvider,
+ RelatedChangesSorter sorter,
+ IndexConfig indexConfig,
+ ChangeData.Factory changeDataFactory) {
+ this.queryProvider = queryProvider;
+ this.sorter = sorter;
+ this.indexConfig = indexConfig;
+ this.changeDataFactory = changeDataFactory;
+ }
+
+ /**
+ * Gets related changes of a specific change revision.
+ *
+ * @param changeData the change of the inputted revision.
+ * @param basePs the revision that the method checks for related changes.
+ * @return list of related changes, sorted via {@link RelatedChangesSorter}
+ */
+ public List<RelatedChangesSorter.PatchSetData> getRelated(ChangeData changeData, PatchSet basePs)
+ throws IOException, PermissionBackendException {
+ Set<String> groups = getAllGroups(changeData.patchSets());
+ logger.atFine().log("groups = %s", groups);
+ if (groups.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ List<ChangeData> cds =
+ InternalChangeQuery.byProjectGroups(
+ queryProvider, indexConfig, changeData.project(), groups);
+ if (cds.isEmpty()) {
+ return Collections.emptyList();
+ }
+ if (cds.size() == 1 && cds.get(0).getId().equals(changeData.getId())) {
+ return Collections.emptyList();
+ }
+
+ cds = reloadChangeIfStale(cds, changeData, basePs);
+
+ return sorter.sort(cds, basePs);
+ }
+
+ private List<ChangeData> reloadChangeIfStale(
+ List<ChangeData> changeDatasFromIndex, ChangeData wantedChange, PatchSet wantedPs) {
+ checkArgument(
+ wantedChange.getId().equals(wantedPs.id().changeId()),
+ "change of wantedPs (%s) doesn't match wantedChange (%s)",
+ wantedPs.id().changeId(),
+ wantedChange.getId());
+
+ List<ChangeData> changeDatas = new ArrayList<>(changeDatasFromIndex.size() + 1);
+ changeDatas.addAll(changeDatasFromIndex);
+
+ // Reload the change in case the patch set is absent.
+ changeDatas.stream()
+ .filter(
+ cd -> cd.getId().equals(wantedPs.id().changeId()) && cd.patchSet(wantedPs.id()) == null)
+ .forEach(ChangeData::reloadChange);
+
+ if (changeDatas.stream().noneMatch(cd -> cd.getId().equals(wantedPs.id().changeId()))) {
+ // The change of the wanted patch set is missing in the result from the index.
+ // Load it from NoteDb and add it to the result.
+ changeDatas.add(changeDataFactory.create(wantedChange.change()));
+ }
+
+ return changeDatas;
+ }
+
+ @VisibleForTesting
+ public static Set<String> getAllGroups(Collection<PatchSet> patchSets) {
+ return patchSets.stream().flatMap(ps -> ps.groups().stream()).collect(toSet());
+ }
+}
diff --git a/java/com/google/gerrit/server/change/LabelNormalizer.java b/java/com/google/gerrit/server/change/LabelNormalizer.java
index b5527d7..aeb9db0 100644
--- a/java/com/google/gerrit/server/change/LabelNormalizer.java
+++ b/java/com/google/gerrit/server/change/LabelNormalizer.java
@@ -77,10 +77,11 @@
}
/**
+ * Returns copies of approvals normalized to the defined ranges for the label type. Approvals for
+ * unknown labels are not included in the output
+ *
* @param notes change notes containing the given approvals.
* @param approvals list of approvals.
- * @return copies of approvals normalized to the defined ranges for the label type. Approvals for
- * unknown labels are not included in the output.
*/
public Result normalize(ChangeNotes notes, Collection<PatchSetApproval> approvals) {
List<PatchSetApproval> unchanged = Lists.newArrayListWithCapacity(approvals.size());
diff --git a/java/com/google/gerrit/server/change/PatchSetInserter.java b/java/com/google/gerrit/server/change/PatchSetInserter.java
index d25dba0..f093958 100644
--- a/java/com/google/gerrit/server/change/PatchSetInserter.java
+++ b/java/com/google/gerrit/server/change/PatchSetInserter.java
@@ -285,6 +285,11 @@
throw new BadRequestException(ex.getMessage());
}
}
+
+ // Approvals that are being set in the new patch-set during this operation are not available yet
+ // outside of the scope of this method. Only copied approvals are set here.
+ approvalsUtil.byPatchSet(ctx.getNotes(), patchSet).forEach(a -> update.putCopiedApproval(a));
+
return true;
}
diff --git a/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java b/java/com/google/gerrit/server/change/RelatedChangesSorter.java
similarity index 95%
rename from java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java
rename to java/com/google/gerrit/server/change/RelatedChangesSorter.java
index 1d550f1..547452e 100644
--- a/java/com/google/gerrit/server/restapi/change/RelatedChangesSorter.java
+++ b/java/com/google/gerrit/server/change/RelatedChangesSorter.java
@@ -11,14 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-
-package com.google.gerrit.server.restapi.change;
+package com.google.gerrit.server.change;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toMap;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ListMultimap;
@@ -29,6 +29,7 @@
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.server.change.RelatedChangesSorter.PatchSetData;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.permissions.ChangePermission;
import com.google.gerrit.server.permissions.PermissionBackend;
@@ -56,7 +57,7 @@
import org.eclipse.jgit.revwalk.RevWalk;
@Singleton
-class RelatedChangesSorter {
+public class RelatedChangesSorter {
private final GitRepositoryManager repoManager;
private final PermissionBackend permissionBackend;
private final ProjectCache projectCache;
@@ -246,28 +247,29 @@
}
@AutoValue
- abstract static class PatchSetData {
+ public abstract static class PatchSetData {
@VisibleForTesting
static PatchSetData create(ChangeData cd, PatchSet ps, RevCommit commit) {
return new AutoValue_RelatedChangesSorter_PatchSetData(cd, ps, commit);
}
- abstract ChangeData data();
+ public abstract ChangeData data();
- abstract PatchSet patchSet();
+ public abstract PatchSet patchSet();
- abstract RevCommit commit();
+ public abstract RevCommit commit();
- PatchSet.Id psId() {
+ public PatchSet.Id psId() {
return patchSet().id();
}
- Change.Id id() {
+ public Change.Id id() {
return psId().changeId();
}
+ @Memoized
@Override
- public final int hashCode() {
+ public int hashCode() {
return Objects.hash(patchSet().id(), commit());
}
diff --git a/java/com/google/gerrit/server/change/ReviewerModifier.java b/java/com/google/gerrit/server/change/ReviewerModifier.java
index f3c5193..fffb107 100644
--- a/java/com/google/gerrit/server/change/ReviewerModifier.java
+++ b/java/com/google/gerrit/server/change/ReviewerModifier.java
@@ -201,9 +201,6 @@
* @return handle describing the addition operation. If the {@code op} field is present, this
* operation may be added to a {@code BatchUpdate}. Otherwise, the {@code error} field
* contains information about an error that occurred
- * @throws IOException
- * @throws PermissionBackendException
- * @throws ConfigInvalidException
*/
public ReviewerModification prepare(
ChangeNotes notes, CurrentUser user, ReviewerInput input, boolean allowGroup)
diff --git a/java/com/google/gerrit/server/change/ReviewerOp.java b/java/com/google/gerrit/server/change/ReviewerOp.java
index 716ac5e..12227c2 100644
--- a/java/com/google/gerrit/server/change/ReviewerOp.java
+++ b/java/com/google/gerrit/server/change/ReviewerOp.java
@@ -32,6 +32,8 @@
public class ReviewerOp implements BatchUpdateOp {
protected boolean sendEmail = true;
+ protected boolean sendEvent = true;
+ protected Runnable eventSender = () -> {};
protected PatchSet patchSet;
protected Result opResult;
@@ -42,6 +44,14 @@
this.sendEmail = false;
}
+ public void suppressEvent() {
+ this.sendEvent = false;
+ }
+
+ public void sendEvent() {
+ eventSender.run();
+ }
+
void setPatchSet(PatchSet patchSet) {
this.patchSet = requireNonNull(patchSet);
}
diff --git a/java/com/google/gerrit/server/config/AuthConfig.java b/java/com/google/gerrit/server/config/AuthConfig.java
index 2ac551d..1760378 100644
--- a/java/com/google/gerrit/server/config/AuthConfig.java
+++ b/java/com/google/gerrit/server/config/AuthConfig.java
@@ -229,7 +229,7 @@
return trustContainerAuth;
}
- /** @return true if users with Run As capability can impersonate others. */
+ /** Returns true if users with Run As capability can impersonate others. */
public boolean isRunAsEnabled() {
return enableRunAs;
}
diff --git a/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java b/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
index b37e489..4032e63 100644
--- a/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
+++ b/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
@@ -32,9 +32,9 @@
* <p>1. Help the callers figure out if any action should be taken, depending on which entries are
* updated in gerrit.config.
*
- * <p>2. Provide the callers with a mechanism to accept/reject the entries of interest: @see
- * accept(Set<ConfigKey> entries), @see accept(String section), @see reject(Set<ConfigKey> entries)
- * (+ various overloaded versions of these)
+ * <p>2. Provide the callers with a mechanism to accept/reject the entries of interest: {@link
+ * #accept(Set)}, {@link #accept(String)}, {@link #reject(Set)} (+ various overloaded versions of
+ * these)
*/
public class ConfigUpdatedEvent {
public static final ImmutableMultimap<UpdateResult, ConfigUpdateEntry> NO_UPDATES =
diff --git a/java/com/google/gerrit/server/config/ConfigUtil.java b/java/com/google/gerrit/server/config/ConfigUtil.java
index 27ded63..c44b0fd 100644
--- a/java/com/google/gerrit/server/config/ConfigUtil.java
+++ b/java/com/google/gerrit/server/config/ConfigUtil.java
@@ -282,7 +282,6 @@
* @param sub subsection
* @param s instance of class with config values
* @param defaults instance of class with default values
- * @throws ConfigInvalidException
*/
public static <T> void storeSection(Config cfg, String section, String sub, T s, T defaults)
throws ConfigInvalidException {
@@ -341,7 +340,6 @@
* @param i instance to merge during the load. When present, the boolean fields are not nullified
* when their values are false
* @return loaded instance
- * @throws ConfigInvalidException
*/
public static <T> T loadSection(Config cfg, String section, String sub, T s, T defaults, T i)
throws ConfigInvalidException {
diff --git a/java/com/google/gerrit/server/config/GerritGlobalModule.java b/java/com/google/gerrit/server/config/GerritGlobalModule.java
index ef1c0ae..35b16b4 100644
--- a/java/com/google/gerrit/server/config/GerritGlobalModule.java
+++ b/java/com/google/gerrit/server/config/GerritGlobalModule.java
@@ -85,6 +85,7 @@
import com.google.gerrit.server.ExceptionHookImpl;
import com.google.gerrit.server.ExternalUser;
import com.google.gerrit.server.IdentifiedUser;
+import com.google.gerrit.server.PerformanceMetrics;
import com.google.gerrit.server.RequestListener;
import com.google.gerrit.server.TraceRequestListener;
import com.google.gerrit.server.account.AccountCacheImpl;
@@ -431,6 +432,7 @@
DynamicSet.setOf(binder(), SubmitRule.class);
DynamicSet.setOf(binder(), QuotaEnforcer.class);
DynamicSet.setOf(binder(), PerformanceLogger.class);
+ DynamicSet.bind(binder(), PerformanceLogger.class).to(PerformanceMetrics.class);
DynamicSet.setOf(binder(), RequestListener.class);
DynamicSet.bind(binder(), RequestListener.class).to(TraceRequestListener.class);
DynamicSet.setOf(binder(), ChangeETagComputation.class);
diff --git a/java/com/google/gerrit/server/config/GerritIsReplica.java b/java/com/google/gerrit/server/config/GerritIsReplica.java
index 154fdcd..ab6aa8b 100644
--- a/java/com/google/gerrit/server/config/GerritIsReplica.java
+++ b/java/com/google/gerrit/server/config/GerritIsReplica.java
@@ -19,7 +19,7 @@
import com.google.inject.BindingAnnotation;
import java.lang.annotation.Retention;
-/* Marker on {@link Boolean} indicating whether Gerrit is run as a read-only replica. */
+/** Marker on {@link Boolean} indicating whether Gerrit is run as a read-only replica. */
@Retention(RUNTIME)
@BindingAnnotation
public @interface GerritIsReplica {}
diff --git a/java/com/google/gerrit/server/config/GitwebCgiConfig.java b/java/com/google/gerrit/server/config/GitwebCgiConfig.java
index d7fb83c..1ed0f16 100644
--- a/java/com/google/gerrit/server/config/GitwebCgiConfig.java
+++ b/java/com/google/gerrit/server/config/GitwebCgiConfig.java
@@ -118,22 +118,22 @@
this.logoPng = null;
}
- /** @return local path to the CGI executable; null if we shouldn't execute. */
+ /** Returns local path to the CGI executable; null if we shouldn't execute. */
public Path getGitwebCgi() {
return cgi;
}
- /** @return local path of the {@code gitweb.css} matching the CGI. */
+ /** Returns local path of the {@code gitweb.css} matching the CGI. */
public Path getGitwebCss() {
return css;
}
- /** @return local path of the {@code gitweb.js} for the CGI. */
+ /** Returns local path of the {@code gitweb.js} for the CGI. */
public Path getGitwebJs() {
return js;
}
- /** @return local path of the {@code git-logo.png} for the CGI. */
+ /** Returns local path of the {@code git-logo.png} for the CGI. */
public Path getGitLogoPng() {
return logoPng;
}
diff --git a/java/com/google/gerrit/server/config/GitwebConfig.java b/java/com/google/gerrit/server/config/GitwebConfig.java
index f90a72e..5632978 100644
--- a/java/com/google/gerrit/server/config/GitwebConfig.java
+++ b/java/com/google/gerrit/server/config/GitwebConfig.java
@@ -213,16 +213,16 @@
}
}
- /** @return GitwebType for gitweb viewer. */
+ /** Returns GitwebType for gitweb viewer. */
@Nullable
public GitwebType getGitwebType() {
return type;
}
/**
- * @return URL of the entry point into gitweb. This URL may be relative to our context if gitweb
- * is hosted by ourselves; or absolute if its hosted elsewhere; or null if gitweb has not been
- * configured.
+ * Returns URL of the entry point into gitweb. This URL may be relative to our context if gitweb
+ * is hosted by ourselves; or absolute if its hosted elsewhere; or null if gitweb has not been
+ * configured.
*/
public String getUrl() {
return url;
diff --git a/java/com/google/gerrit/server/config/ProjectConfigEntry.java b/java/com/google/gerrit/server/config/ProjectConfigEntry.java
index fcfa5e9..c09988e3 100644
--- a/java/com/google/gerrit/server/config/ProjectConfigEntry.java
+++ b/java/com/google/gerrit/server/config/ProjectConfigEntry.java
@@ -206,16 +206,18 @@
}
/**
+ * Returns whether the project is editable
+ *
* @param project project state.
- * @return whether the project is editable.
*/
public boolean isEditable(ProjectState project) {
return true;
}
/**
+ * Returns any warning associated with the project
+ *
* @param project project state.
- * @return any warning associated with the project.
*/
public String getWarning(ProjectState project) {
return null;
diff --git a/java/com/google/gerrit/server/edit/ChangeEditUtil.java b/java/com/google/gerrit/server/edit/ChangeEditUtil.java
index 710916e..6b018ce 100644
--- a/java/com/google/gerrit/server/edit/ChangeEditUtil.java
+++ b/java/com/google/gerrit/server/edit/ChangeEditUtil.java
@@ -146,9 +146,6 @@
* @param edit change edit to publish
* @param notify Notify handling that defines to whom email notifications should be sent after the
* change edit is published.
- * @throws IOException
- * @throws UpdateException
- * @throws RestApiException
*/
public void publish(
BatchUpdate.Factory updateFactory,
@@ -209,7 +206,6 @@
* Delete change edit.
*
* @param edit change edit to delete
- * @throws IOException
*/
public void delete(ChangeEdit edit) throws IOException {
Change change = edit.getChange();
diff --git a/java/com/google/gerrit/server/events/EventsMetrics.java b/java/com/google/gerrit/server/events/EventsMetrics.java
index 3c87cca..6d48c37 100644
--- a/java/com/google/gerrit/server/events/EventsMetrics.java
+++ b/java/com/google/gerrit/server/events/EventsMetrics.java
@@ -32,7 +32,9 @@
metricMaker.newCounter(
"events",
new Description("Triggered events").setRate().setUnit("triggered events"),
- Field.ofString("type", Metadata.Builder::eventType).build());
+ Field.ofString("type", Metadata.Builder::eventType)
+ .description("The type of the event.")
+ .build());
}
@Override
diff --git a/java/com/google/gerrit/server/experiments/ExperimentFeaturesConstants.java b/java/com/google/gerrit/server/experiments/ExperimentFeaturesConstants.java
index 5e9ce97..b060d3e 100644
--- a/java/com/google/gerrit/server/experiments/ExperimentFeaturesConstants.java
+++ b/java/com/google/gerrit/server/experiments/ExperimentFeaturesConstants.java
@@ -26,13 +26,6 @@
"GerritBackendRequestFeature__remove_revision_etag";
/**
- * Whether git pushes are cancelled if the client disconnects or the configured receive.timeout is
- * exceeded.
- */
- public static final String GERRIT_BACKEND_REQUEST_FEATURE_ENABLE_PUSH_CANCELLATION =
- "GerritBackendRequestFeature__enable_push_cencallation";
-
- /**
* Allow legacy {@link com.google.gerrit.entities.SubmitRecord}s to be converted and returned as
* submit requirements by the {@link
* com.google.gerrit.server.project.SubmitRequirementsEvaluator}.
diff --git a/java/com/google/gerrit/server/extensions/webui/UiActions.java b/java/com/google/gerrit/server/extensions/webui/UiActions.java
index a7f6b48..34c3c20 100644
--- a/java/com/google/gerrit/server/extensions/webui/UiActions.java
+++ b/java/com/google/gerrit/server/extensions/webui/UiActions.java
@@ -72,7 +72,9 @@
new com.google.gerrit.metrics.Description("Latency for RestView#getDescription calls")
.setCumulative()
.setUnit(Units.MILLISECONDS),
- Field.ofString("view", Metadata.Builder::restViewName).build());
+ Field.ofString("view", Metadata.Builder::restViewName)
+ .description("view implementation class")
+ .build());
}
public <R extends RestResource> Iterable<UiAction.Description> from(
diff --git a/java/com/google/gerrit/server/git/GitRepositoryManager.java b/java/com/google/gerrit/server/git/GitRepositoryManager.java
index 8142089a..8dba3e1 100644
--- a/java/com/google/gerrit/server/git/GitRepositoryManager.java
+++ b/java/com/google/gerrit/server/git/GitRepositoryManager.java
@@ -73,7 +73,7 @@
Repository createRepository(Project.NameKey name)
throws RepositoryNotFoundException, RepositoryExistsException, IOException;
- /** @return set of all known projects, sorted by natural NameKey order. */
+ /** Returns set of all known projects, sorted by natural NameKey order. */
SortedSet<Project.NameKey> list();
/**
diff --git a/java/com/google/gerrit/server/git/MergeTip.java b/java/com/google/gerrit/server/git/MergeTip.java
index 204f453..4ffa1a8 100644
--- a/java/com/google/gerrit/server/git/MergeTip.java
+++ b/java/com/google/gerrit/server/git/MergeTip.java
@@ -52,8 +52,8 @@
}
/**
- * @return the initial tip of the branch before the merge operation started; may be null,
- * indicating a previously unborn branch.
+ * Returns the initial tip of the branch before the merge operation started; may be null,
+ * indicating a previously unborn branch.
*/
public CodeReviewCommit getInitialTip() {
return initialTip;
@@ -82,8 +82,8 @@
}
/**
- * @return The current tip of the current merge operation; may be null, indicating an unborn
- * branch.
+ * Returns The current tip of the current merge operation; may be null, indicating an unborn
+ * branch.
*/
@Nullable
public CodeReviewCommit getCurrentTip() {
diff --git a/java/com/google/gerrit/server/git/MergeUtil.java b/java/com/google/gerrit/server/git/MergeUtil.java
index 3385969..3a4d407 100644
--- a/java/com/google/gerrit/server/git/MergeUtil.java
+++ b/java/com/google/gerrit/server/git/MergeUtil.java
@@ -512,9 +512,6 @@
* <li>Change-Id
* </ul>
*
- * @param n
- * @param notes
- * @param psId
* @return new message
*/
private String createDetailedCommitMessage(RevCommit n, ChangeNotes notes, PatchSet.Id psId) {
@@ -630,10 +627,6 @@
* Plugins implementing {@link ChangeMessageModifier} can modify the resulting commit message
* arbitrarily.
*
- * @param n
- * @param mergeTip
- * @param notes
- * @param id
* @return new message
*/
public String createCommitMessageOnSubmit(
diff --git a/java/com/google/gerrit/server/git/MultiProgressMonitor.java b/java/com/google/gerrit/server/git/MultiProgressMonitor.java
index 3faafd1..a4b1033 100644
--- a/java/com/google/gerrit/server/git/MultiProgressMonitor.java
+++ b/java/com/google/gerrit/server/git/MultiProgressMonitor.java
@@ -23,8 +23,6 @@
import com.google.common.util.concurrent.UncheckedExecutionException;
import com.google.gerrit.server.CancellationMetrics;
import com.google.gerrit.server.cancellation.RequestStateProvider;
-import com.google.gerrit.server.experiments.ExperimentFeatures;
-import com.google.gerrit.server.experiments.ExperimentFeaturesConstants;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import java.io.IOException;
@@ -169,7 +167,6 @@
}
private final CancellationMetrics cancellationMetrics;
- private final ExperimentFeatures experimentFeatures;
private final OutputStream out;
private final TaskKind taskKind;
private final String taskName;
@@ -193,11 +190,10 @@
@AssistedInject
private MultiProgressMonitor(
CancellationMetrics cancellationMetrics,
- ExperimentFeatures experimentFeatures,
@Assisted OutputStream out,
@Assisted TaskKind taskKind,
@Assisted String taskName) {
- this(cancellationMetrics, experimentFeatures, out, taskKind, taskName, 500, MILLISECONDS);
+ this(cancellationMetrics, out, taskKind, taskName, 500, MILLISECONDS);
}
/**
@@ -211,14 +207,12 @@
@AssistedInject
private MultiProgressMonitor(
CancellationMetrics cancellationMetrics,
- ExperimentFeatures experimentFeatures,
@Assisted OutputStream out,
@Assisted TaskKind taskKind,
@Assisted String taskName,
@Assisted long maxIntervalTime,
@Assisted TimeUnit maxIntervalUnit) {
this.cancellationMetrics = cancellationMetrics;
- this.experimentFeatures = experimentFeatures;
this.out = out;
this.taskKind = taskKind;
this.taskName = taskName;
@@ -469,12 +463,6 @@
@Override
public void checkIfCancelled(OnCancelled onCancelled) {
- if (taskKind == TaskKind.RECEIVE_COMMITS
- && !experimentFeatures.isFeatureEnabled(
- ExperimentFeaturesConstants.GERRIT_BACKEND_REQUEST_FEATURE_ENABLE_PUSH_CANCELLATION)) {
- return;
- }
-
if (clientDisconnected) {
onCancelled.onCancel(RequestStateProvider.Reason.CLIENT_CLOSED_REQUEST, /* message= */ null);
} else if (deadlineExceeded) {
diff --git a/java/com/google/gerrit/server/git/RepoRefCache.java b/java/com/google/gerrit/server/git/RepoRefCache.java
index 6b2493a..c69f9a6 100644
--- a/java/com/google/gerrit/server/git/RepoRefCache.java
+++ b/java/com/google/gerrit/server/git/RepoRefCache.java
@@ -46,7 +46,7 @@
return id;
}
- /** @return an unmodifiable view of the refs that have been cached by this instance. */
+ /** Returns an unmodifiable view of the refs that have been cached by this instance. */
public Map<String, Optional<ObjectId>> getCachedRefs() {
return Collections.unmodifiableMap(ids);
}
diff --git a/java/com/google/gerrit/server/git/TransferConfig.java b/java/com/google/gerrit/server/git/TransferConfig.java
index 55b9448..728e4ed 100644
--- a/java/com/google/gerrit/server/git/TransferConfig.java
+++ b/java/com/google/gerrit/server/git/TransferConfig.java
@@ -52,7 +52,7 @@
packConfig.fromConfig(cfg);
}
- /** @return configured timeout, in seconds. 0 if the timeout is infinite. */
+ /** Returns configured timeout, in seconds. 0 if the timeout is infinite. */
public int getTimeout() {
return timeout;
}
diff --git a/java/com/google/gerrit/server/git/UploadPackMetricsHook.java b/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
index 4afff2b..1619add 100644
--- a/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
+++ b/java/com/google/gerrit/server/git/UploadPackMetricsHook.java
@@ -45,7 +45,9 @@
@Inject
UploadPackMetricsHook(MetricMaker metricMaker) {
Field<Operation> operationField =
- Field.ofEnum(Operation.class, "operation", Metadata.Builder::gitOperation).build();
+ Field.ofEnum(Operation.class, "operation", Metadata.Builder::gitOperation)
+ .description("The name of the operation (CLONE, FETCH).")
+ .build();
requestCount =
metricMaker.newCounter(
"git/upload-pack/request_count",
diff --git a/java/com/google/gerrit/server/git/meta/MetaDataUpdate.java b/java/com/google/gerrit/server/git/meta/MetaDataUpdate.java
index e90f58b..27d5da9 100644
--- a/java/com/google/gerrit/server/git/meta/MetaDataUpdate.java
+++ b/java/com/google/gerrit/server/git/meta/MetaDataUpdate.java
@@ -160,7 +160,7 @@
return create(name, null);
}
- /** @see User#create(Project.NameKey, IdentifiedUser, BatchRefUpdate) */
+ /** See {@link User#create(Project.NameKey, IdentifiedUser, BatchRefUpdate)} */
public MetaDataUpdate create(Project.NameKey name, BatchRefUpdate batch)
throws RepositoryNotFoundException, IOException {
Repository repo = mgr.openRepository(name);
@@ -234,7 +234,7 @@
this.closeRepository = closeRepository;
}
- /** @return batch in which to run the update, or {@code null} for no batch. */
+ /** Returns batch in which to run the update, or {@code null} for no batch. */
BatchRefUpdate getBatch() {
return batch;
}
diff --git a/java/com/google/gerrit/server/git/meta/VersionedMetaData.java b/java/com/google/gerrit/server/git/meta/VersionedMetaData.java
index 999ed4e..a42ab8f 100644
--- a/java/com/google/gerrit/server/git/meta/VersionedMetaData.java
+++ b/java/com/google/gerrit/server/git/meta/VersionedMetaData.java
@@ -100,7 +100,7 @@
protected ObjectInserter inserter;
protected DirCache newTree;
- /** @return name of the reference storing this configuration. */
+ /** Returns name of the reference storing this configuration. */
protected abstract String getRefName();
/** Set up the metadata, parsing any state from the loaded revision. */
@@ -110,13 +110,11 @@
* Save any changes to the metadata in a commit.
*
* @return true if the commit should proceed, false to abort.
- * @throws IOException
- * @throws ConfigInvalidException
*/
protected abstract boolean onSave(CommitBuilder commit)
throws IOException, ConfigInvalidException;
- /** @return revision of the metadata that was loaded. */
+ /** Returns revision of the metadata that was loaded. */
@Nullable
public ObjectId getRevision() {
return ObjectIds.copyOrNull(revision);
@@ -130,8 +128,6 @@
*
* @param projectName the name of the project
* @param db repository to access.
- * @throws IOException
- * @throws ConfigInvalidException
*/
public void load(Project.NameKey projectName, Repository db)
throws IOException, ConfigInvalidException {
@@ -152,8 +148,6 @@
* @param projectName the name of the project
* @param db repository to access.
* @param id revision to load.
- * @throws IOException
- * @throws ConfigInvalidException
*/
public void load(Project.NameKey projectName, Repository db, @Nullable ObjectId id)
throws IOException, ConfigInvalidException {
@@ -176,8 +170,6 @@
* @param projectName the name of the project
* @param walk open walk to access to access.
* @param id revision to load.
- * @throws IOException
- * @throws ConfigInvalidException
*/
public void load(Project.NameKey projectName, RevWalk walk, ObjectId id)
throws IOException, ConfigInvalidException {
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index 42fc916..c1cd30c 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -102,7 +102,9 @@
import com.google.gerrit.extensions.validators.CommentValidationFailure;
import com.google.gerrit.extensions.validators.CommentValidator;
import com.google.gerrit.metrics.Counter0;
+import com.google.gerrit.metrics.Counter3;
import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.server.CancellationMetrics;
import com.google.gerrit.server.ChangeUtil;
@@ -323,6 +325,7 @@
@Singleton
private static class Metrics {
private final Counter0 psRevisionMissing;
+ private final Counter3<String, String, String> pushCount;
@Inject
Metrics(MetricMaker metricMaker) {
@@ -330,6 +333,23 @@
metricMaker.newCounter(
"receivecommits/ps_revision_missing",
new Description("errors due to patch set revision missing"));
+ pushCount =
+ metricMaker.newCounter(
+ "receivecommits/push_count",
+ new Description("number of pushes"),
+ Field.ofString("kind", (metadataBuilder, fieldValue) -> {})
+ .description("The push kind (direct vs. magic).")
+ .build(),
+ Field.ofString(
+ "project",
+ (metadataBuilder, fieldValue) -> metadataBuilder.projectName(fieldValue))
+ .description("The name of the project for which the push is done.")
+ .build(),
+ Field.ofString("type", (metadataBuilder, fieldValue) -> {})
+ .description(
+ "The type of the update (CREATE, UPDATE, CREATE/UPDATE,"
+ + " UPDATE_NONFASTFORWARD, DELETE).")
+ .build());
}
}
@@ -627,7 +647,7 @@
ReceiveCommitsResult processCommands(
Collection<ReceiveCommand> commands, MultiProgressMonitor progress) throws StorageException {
checkState(!used, "Tried to re-use a ReceiveCommits objects that is single-use only");
- long start = System.nanoTime();
+ long start = TimeUtil.nowNanos();
parsePushOptions();
String clientProvidedDeadlineValue =
Iterables.getLast(pushOptions.get("deadline"), /* defaultValue= */ null);
@@ -727,6 +747,13 @@
return;
}
+ if (!magicCommands.isEmpty()) {
+ metrics.pushCount.increment("magic", project.getName(), getUpdateType(magicCommands));
+ }
+ if (!regularCommands.isEmpty()) {
+ metrics.pushCount.increment("direct", project.getName(), getUpdateType(regularCommands));
+ }
+
try {
if (!regularCommands.isEmpty()) {
handleRegularCommands(regularCommands, progress);
@@ -777,6 +804,15 @@
lazy(() -> commands.stream().map(ReceiveCommits::commandToString).collect(joining(","))));
}
+ private String getUpdateType(List<ReceiveCommand> commands) {
+ return commands.stream()
+ .map(ReceiveCommand::getType)
+ .map(ReceiveCommand.Type::name)
+ .distinct()
+ .sorted()
+ .collect(joining("/"));
+ }
+
private void sendErrorMessages() {
if (!errors.isEmpty()) {
logger.atFine().log("Handling error conditions: %s", errors.keySet());
@@ -1726,6 +1762,7 @@
}
@UsedAt(UsedAt.Project.GOOGLE)
+ @SuppressWarnings("unused") // unused in upstream, but used at Google
@Option(name = "--create-cod-token", usage = "create a token for consistency-on-demand")
private boolean createCodToken;
@@ -2882,8 +2919,6 @@
* </ul>
*
* @return whether the new commit is valid
- * @throws IOException
- * @throws PermissionBackendException
*/
boolean validateNewPatchSet() throws IOException, PermissionBackendException {
try (TraceTimer traceTimer = newTimer("validateNewPatchSet")) {
diff --git a/java/com/google/gerrit/server/git/receive/ReplaceOp.java b/java/com/google/gerrit/server/git/receive/ReplaceOp.java
index b2a31b9..a9ef70e 100644
--- a/java/com/google/gerrit/server/git/receive/ReplaceOp.java
+++ b/java/com/google/gerrit/server/git/receive/ReplaceOp.java
@@ -345,8 +345,11 @@
update.putReviewer(ctx.getAccountId(), REVIEWER);
}
- mailMessage = insertChangeMessage(update, ctx, reviewMessage);
+ // Approvals that are being set in the new patch-set during this operation are not available yet
+ // outside of the scope of this method. Only copied approvals are set here.
+ approvalsUtil.byPatchSet(ctx.getNotes(), newPatchSet).forEach(a -> update.putCopiedApproval(a));
+ mailMessage = insertChangeMessage(update, ctx, reviewMessage);
if (mergedByPushOp == null) {
resetChange(ctx);
} else {
diff --git a/java/com/google/gerrit/server/git/validators/OnSubmitValidationListener.java b/java/com/google/gerrit/server/git/validators/OnSubmitValidationListener.java
index 432dda3..98f2aa2 100644
--- a/java/com/google/gerrit/server/git/validators/OnSubmitValidationListener.java
+++ b/java/com/google/gerrit/server/git/validators/OnSubmitValidationListener.java
@@ -76,8 +76,8 @@
}
/**
- * @return a map from ref to commands covering all ref operations to be performed on this
- * repository as part of the ongoing submit operation.
+ * Returns a map from ref to commands covering all ref operations to be performed on this
+ * repository as part of the ongoing submit operation.
*/
public ImmutableMap<String, ReceiveCommand> getCommands() {
return commands;
diff --git a/java/com/google/gerrit/server/group/db/GroupDelta.java b/java/com/google/gerrit/server/group/db/GroupDelta.java
index 4ef2450..69cb936 100644
--- a/java/com/google/gerrit/server/group/db/GroupDelta.java
+++ b/java/com/google/gerrit/server/group/db/GroupDelta.java
@@ -121,19 +121,39 @@
@AutoValue.Builder
public abstract static class Builder {
- /** @see #getName() */
+ /**
+ * Defines the new name of the group
+ *
+ * <p>See {@link #getName}.
+ */
public abstract Builder setName(AccountGroup.NameKey name);
- /** @see #getDescription() */
+ /**
+ * Defines the new description of the group
+ *
+ * <p>See {@link #getDescription()}}
+ */
public abstract Builder setDescription(String description);
- /** @see #getOwnerGroupUUID() */
+ /**
+ * Defines the new owner of the group
+ *
+ * <p>See {@link #getOwnerGroupUUID()}
+ */
public abstract Builder setOwnerGroupUUID(AccountGroup.UUID ownerGroupUUID);
- /** @see #getVisibleToAll() */
+ /**
+ * Defines the new state of the 'visibleToAll' flag of the group
+ *
+ * <p>See {@link #getVisibleToAll()}
+ */
public abstract Builder setVisibleToAll(boolean visibleToAll);
- /** @see #getMemberModification() */
+ /**
+ * Set {@link MemberModification} for the prospective {@link GroupDelta}
+ *
+ * <p>See {@link #getMemberModification()}
+ */
public abstract Builder setMemberModification(MemberModification memberModification);
/**
@@ -146,7 +166,11 @@
*/
public abstract MemberModification getMemberModification();
- /** @see #getSubgroupModification() */
+ /**
+ * Set {@link SubgroupModification} for the prospective {@link GroupDelta}
+ *
+ * <p>See {@link #getSubgroupModification()}
+ */
public abstract Builder setSubgroupModification(SubgroupModification subgroupModification);
/**
@@ -159,7 +183,12 @@
*/
public abstract SubgroupModification getSubgroupModification();
- /** @see #getUpdatedOn() */
+ /**
+ * Defines the {@code Timestamp} to be used for the NoteDb commits of the update. If not
+ * specified, the current {@code Timestamp} when creating the commit will be used.
+ *
+ * <p>See {@link #getUpdatedOn()}
+ */
public abstract Builder setUpdatedOn(Timestamp timestamp);
public abstract GroupDelta build();
diff --git a/java/com/google/gerrit/server/group/db/GroupsNoteDbConsistencyChecker.java b/java/com/google/gerrit/server/group/db/GroupsNoteDbConsistencyChecker.java
index 01ee811..24bcaf0 100644
--- a/java/com/google/gerrit/server/group/db/GroupsNoteDbConsistencyChecker.java
+++ b/java/com/google/gerrit/server/group/db/GroupsNoteDbConsistencyChecker.java
@@ -22,6 +22,7 @@
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
+import com.google.errorprone.annotations.FormatMethod;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.AccountGroup;
import com.google.gerrit.entities.GroupReference;
@@ -138,8 +139,7 @@
Optional<Ref> maybeRef =
refs.stream().filter(r -> r.getName().equals(RefNames.REFS_GROUPNAMES)).findFirst();
if (!maybeRef.isPresent()) {
- String msg = String.format("ref %s does not exist", RefNames.REFS_GROUPNAMES);
- result.problems.add(error(msg));
+ result.problems.add(error("ref %s does not exist", RefNames.REFS_GROUPNAMES));
return;
}
Ref ref = maybeRef.get();
@@ -280,6 +280,7 @@
}
}
+ @FormatMethod
public static void logConsistencyProblemAsWarning(String fmt, Object... args) {
logConsistencyProblem(warning(fmt, args));
}
diff --git a/java/com/google/gerrit/server/group/db/InternalGroupCreation.java b/java/com/google/gerrit/server/group/db/InternalGroupCreation.java
index f4bf6e6..291c354 100644
--- a/java/com/google/gerrit/server/group/db/InternalGroupCreation.java
+++ b/java/com/google/gerrit/server/group/db/InternalGroupCreation.java
@@ -26,13 +26,13 @@
@AutoValue
public abstract class InternalGroupCreation {
- /** Defines the numeric ID the group should have. */
+ /** Defines the numeric ID the group should have */
public abstract AccountGroup.Id getId();
- /** Defines the name the group should have. */
+ /** Defines the name the group should have */
public abstract AccountGroup.NameKey getNameKey();
- /** Defines the UUID the group should have. */
+ /** Defines the UUID the group should have */
public abstract AccountGroup.UUID getGroupUUID();
public static Builder builder() {
@@ -41,13 +41,13 @@
@AutoValue.Builder
public abstract static class Builder {
- /** @see #getId() */
+ /** Defines the name the group should have */
public abstract InternalGroupCreation.Builder setId(AccountGroup.Id id);
- /** @see #getNameKey() */
+ /** Defines the name the group should have */
public abstract InternalGroupCreation.Builder setNameKey(AccountGroup.NameKey name);
- /** @see #getGroupUUID() */
+ /** Defines the UUID the group should have */
public abstract InternalGroupCreation.Builder setGroupUUID(AccountGroup.UUID groupUuid);
public abstract InternalGroupCreation build();
diff --git a/java/com/google/gerrit/server/index/VersionManager.java b/java/com/google/gerrit/server/index/VersionManager.java
index 56ce604..cdb69c6 100644
--- a/java/com/google/gerrit/server/index/VersionManager.java
+++ b/java/com/google/gerrit/server/index/VersionManager.java
@@ -107,7 +107,6 @@
* @param name index name
* @param force start re-index
* @return true if started, otherwise false.
- * @throws ReindexerAlreadyRunningException
*/
public synchronized boolean startReindexer(String name, boolean force)
throws ReindexerAlreadyRunningException {
@@ -125,7 +124,6 @@
*
* @param name index name
* @return true if index was activated, otherwise false.
- * @throws ReindexerAlreadyRunningException
*/
public synchronized boolean activateLatestIndex(String name)
throws ReindexerAlreadyRunningException {
diff --git a/java/com/google/gerrit/server/index/change/ChangeField.java b/java/com/google/gerrit/server/index/change/ChangeField.java
index 02ec5ea..bfe1ee1 100644
--- a/java/com/google/gerrit/server/index/change/ChangeField.java
+++ b/java/com/google/gerrit/server/index/change/ChangeField.java
@@ -342,6 +342,11 @@
integer(ChangeQueryBuilder.FIELD_ATTENTION_SET_USERS)
.buildRepeatable(ChangeField::getAttentionSetUserIds);
+ /** Number of changes that contain attention set. */
+ public static final FieldDef<ChangeData, Integer> ATTENTION_SET_USERS_COUNT =
+ intRange(ChangeQueryBuilder.FIELD_ATTENTION_SET_USERS_COUNT)
+ .build(cd -> additionsOnly(cd.attentionSet()).size());
+
/**
* The full attention set data including timestamp, reason and possible future fields.
*
diff --git a/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java b/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java
index a758377..30ab6e6a 100644
--- a/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java
+++ b/java/com/google/gerrit/server/index/change/ChangeSchemaDefinitions.java
@@ -173,9 +173,14 @@
new Schema.Builder<ChangeData>().add(V67).add(ChangeField.SUBMIT_RULE_RESULT).build();
/** Added new field {@link ChangeField#CHERRY_PICK}. */
+ @Deprecated
static final Schema<ChangeData> V69 =
new Schema.Builder<ChangeData>().add(V68).add(ChangeField.CHERRY_PICK).build();
+ /** Added new field {@link ChangeField#ATTENTION_SET_USERS_COUNT}. */
+ static final Schema<ChangeData> V70 =
+ new Schema.Builder<ChangeData>().add(V69).add(ChangeField.ATTENTION_SET_USERS_COUNT).build();
+
/**
* Name of the change index to be used when contacting index backends or loading configurations.
*/
diff --git a/java/com/google/gerrit/server/ioutil/HostPlatform.java b/java/com/google/gerrit/server/ioutil/HostPlatform.java
index 39e9c07..e27d17c 100644
--- a/java/com/google/gerrit/server/ioutil/HostPlatform.java
+++ b/java/com/google/gerrit/server/ioutil/HostPlatform.java
@@ -21,7 +21,7 @@
private static final boolean win32 = compute("windows");
private static final boolean mac = compute("mac");
- /** @return true if this JVM is running on a Windows platform. */
+ /** Returns true if this JVM is running on a Windows platform. */
public static boolean isWin32() {
return win32;
}
diff --git a/java/com/google/gerrit/server/ioutil/LimitedByteArrayOutputStream.java b/java/com/google/gerrit/server/ioutil/LimitedByteArrayOutputStream.java
index 015887b..a58d9ae 100644
--- a/java/com/google/gerrit/server/ioutil/LimitedByteArrayOutputStream.java
+++ b/java/com/google/gerrit/server/ioutil/LimitedByteArrayOutputStream.java
@@ -57,7 +57,7 @@
buffer.write(b, off, len);
}
- /** @return a newly allocated byte array with contents of the buffer. */
+ /** Returns a newly allocated byte array with contents of the buffer. */
public byte[] toByteArray() {
return buffer.toByteArray();
}
diff --git a/java/com/google/gerrit/server/logging/CallerFinder.java b/java/com/google/gerrit/server/logging/CallerFinder.java
index bd7e608..4cb4b7f 100644
--- a/java/com/google/gerrit/server/logging/CallerFinder.java
+++ b/java/com/google/gerrit/server/logging/CallerFinder.java
@@ -41,7 +41,7 @@
*
* <p>E.g. the stacktrace could look like this:
*
- * <pre>
+ * <pre>{@code
* GroupQueryProcessor(QueryProcessor<T>).query(List<String>, List<Predicate<T>>) line: 216
* GroupQueryProcessor(QueryProcessor<T>).query(List<Predicate<T>>) line: 188
* GroupQueryProcessor(QueryProcessor<T>).query(Predicate<T>) line: 171
@@ -52,7 +52,7 @@
* GroupCacheImpl$ByNameLoader.load(Object) line: 1
* LocalCache$LoadingValueReference<K,V>.loadFuture(K, CacheLoader<? super K,V>) line: 3527
* ...
- * </pre>
+ * }</pre>
*
* <p>The first interesting caller is {@code GroupCacheImpl$ByNameLoader.load(String) line: 166}. To
* find this caller from the stacktrace we could specify {@link
diff --git a/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java b/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
index 3c4c563..1bba018 100644
--- a/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
+++ b/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
@@ -28,24 +28,24 @@
*
* <p>Example:
*
- * <pre>
- * try (TraceContext traceContext = TraceContext.newTrace(true, ...)) {
- * executor
- * .submit(new LoggingContextAwareRunnable(
- * () -> {
- * // Tracing is enabled since the runnable is created within the TraceContext.
- * // Tracing is even enabled if the executor runs the runnable only after the
- * // TraceContext was closed.
+ * <pre>{@code
+ * try (TraceContext traceContext = TraceContext.newTrace(true, ...)) {
+ * executor
+ * .submit(new LoggingContextAwareRunnable(
+ * () -> {
+ * // Tracing is enabled since the runnable is created within the TraceContext.
+ * // Tracing is even enabled if the executor runs the runnable only after the
+ * // TraceContext was closed.
*
- * // The tag "foo=bar" is not set, since it was added to the logging context only
- * // after this runnable was created.
+ * // The tag "foo=bar" is not set, since it was added to the logging context only
+ * // after this runnable was created.
*
- * // do stuff
- * }))
- * .get();
- * traceContext.addTag("foo", "bar");
- * }
- * </pre>
+ * // do stuff
+ * }))
+ * .get();
+ * traceContext.addTag("foo", "bar");
+ * }
+ * }</pre>
*
* @see LoggingContextAwareCallable
*/
diff --git a/java/com/google/gerrit/server/logging/TraceContext.java b/java/com/google/gerrit/server/logging/TraceContext.java
index 681dfbc..487e0af 100644
--- a/java/com/google/gerrit/server/logging/TraceContext.java
+++ b/java/com/google/gerrit/server/logging/TraceContext.java
@@ -268,15 +268,23 @@
return this;
}
- public boolean isTracing() {
+ public static boolean isTracing() {
return LoggingContext.getInstance().isLoggingForced();
}
- public Optional<String> getTraceId() {
+ public static Optional<String> getTraceId() {
return LoggingContext.getInstance().getTagsAsMap().get(RequestId.Type.TRACE_ID.name()).stream()
.findFirst();
}
+ public static Optional<String> getPluginTag() {
+ return getTag(PLUGIN_TAG);
+ }
+
+ public static Optional<String> getTag(String tagName) {
+ return LoggingContext.getInstance().getTagsAsMap().get(tagName).stream().findFirst();
+ }
+
public TraceContext enableAclLogging() {
if (stopAclLoggingOnClose) {
return this;
@@ -286,11 +294,7 @@
return this;
}
- public boolean isAclLoggingEnabled() {
- return LoggingContext.getInstance().isAclLogging();
- }
-
- public ImmutableList<String> getAclLogRecords() {
+ public static ImmutableList<String> getAclLogRecords() {
return LoggingContext.getInstance().getAclLogRecords();
}
diff --git a/java/com/google/gerrit/server/mail/receive/MailReceiver.java b/java/com/google/gerrit/server/mail/receive/MailReceiver.java
index dc99b46..e383207 100644
--- a/java/com/google/gerrit/server/mail/receive/MailReceiver.java
+++ b/java/com/google/gerrit/server/mail/receive/MailReceiver.java
@@ -110,8 +110,6 @@
* requestDeletion will enqueue an email for deletion and delete it the next time we connect to
* the email server. This does not guarantee deletion as the Gerrit instance might fail before we
* connect to the email server.
- *
- * @param messageId
*/
public void requestDeletion(String messageId) {
pendingDeletion.add(messageId);
diff --git a/java/com/google/gerrit/server/mail/send/CommentSender.java b/java/com/google/gerrit/server/mail/send/CommentSender.java
index 4593584..5a7352a 100644
--- a/java/com/google/gerrit/server/mail/send/CommentSender.java
+++ b/java/com/google/gerrit/server/mail/send/CommentSender.java
@@ -14,6 +14,7 @@
package com.google.gerrit.server.mail.send;
+import static com.google.gerrit.entities.Patch.PATCHSET_LEVEL;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Strings;
@@ -71,23 +72,23 @@
public PatchFile fileData;
public List<Comment> comments = new ArrayList<>();
- /** @return a web link to a comment for a change. */
+ /** Returns a web link to a comment for a change. */
public String getCommentLink(String uuid) {
return args.urlFormatter.get().getInlineCommentView(change, uuid).orElse(null);
}
- /** @return a web link to the comment tab view of a change. */
+ /** Returns a web link to the comment tab view of a change. */
public String getCommentsTabLink() {
return args.urlFormatter.get().getCommentsTabView(change).orElse(null);
}
- /** @return a web link to the findings tab view of a change. */
+ /** Returns a web link to the findings tab view of a change. */
public String getFindingsTabLink() {
return args.urlFormatter.get().getFindingsTabView(change).orElse(null);
}
/**
- * @return A title for the group, i.e. "Commit Message", "Merge List", or "File [[filename]]".
+ * Returns a title for the group, i.e. "Commit Message", "Merge List", or "File [[filename]]".
*/
public String getTitle() {
if (Patch.COMMIT_MSG.equals(filename)) {
@@ -180,8 +181,8 @@
}
/**
- * @return a list of FileCommentGroup objects representing the inline comments grouped by the
- * file.
+ * Returns a list of FileCommentGroup objects representing the inline comments grouped by the
+ * file.
*/
private List<CommentSender.FileCommentGroup> getGroupedInlineComments(Repository repo) {
List<CommentSender.FileCommentGroup> groups = new ArrayList<>();
@@ -220,7 +221,7 @@
}
}
- if (currentGroup.fileData != null) {
+ if (currentGroup.filename.equals(PATCHSET_LEVEL) || currentGroup.fileData != null) {
currentGroup.comments.add(c);
}
}
@@ -267,7 +268,7 @@
}
/**
- * @return the lines of file content in fileData that are encompassed by range on the given side.
+ * Returns the lines of file content in fileData that are encompassed by range on the given side.
*/
private List<String> getLinesByRange(Comment.Range range, PatchFile fileData, short side) {
List<String> lines = new ArrayList<>();
@@ -330,9 +331,9 @@
}
/**
- * @return a shortened version of the given comment's message. Will be shortened to 100 characters
- * or the first line, or following the last period within the first 100 characters, whichever
- * is shorter. If the message is shortened, an ellipsis is appended.
+ * Returns a shortened version of the given comment's message. Will be shortened to 100 characters
+ * or the first line, or following the last period within the first 100 characters, whichever is
+ * shorter. If the message is shortened, an ellipsis is appended.
*/
protected static String getShortenedCommentMessage(String message) {
int threshold = 100;
@@ -368,8 +369,8 @@
}
/**
- * @return grouped inline comment data mapped to data structures that are suitable for passing
- * into Soy.
+ * Returns grouped inline comment data mapped to data structures that are suitable for passing
+ * into Soy.
*/
private List<Map<String, Object>> getCommentGroupsTemplateData(Repository repo) {
List<Map<String, Object>> commentGroups = new ArrayList<>();
@@ -382,7 +383,9 @@
List<Map<String, Object>> commentsList = new ArrayList<>();
for (Comment comment : group.comments) {
Map<String, Object> commentData = new HashMap<>();
- commentData.put("lines", getLinesOfComment(comment, group.fileData));
+ if (group.fileData != null) {
+ commentData.put("lines", getLinesOfComment(comment, group.fileData));
+ }
commentData.put("message", comment.message.trim());
List<CommentFormatter.Block> blocks = CommentFormatter.parse(comment.message);
commentData.put("messageBlocks", commentBlocksToSoyData(blocks));
diff --git a/java/com/google/gerrit/server/mail/send/MessageIdGenerator.java b/java/com/google/gerrit/server/mail/send/MessageIdGenerator.java
index aa683f6..b32c43a 100644
--- a/java/com/google/gerrit/server/mail/send/MessageIdGenerator.java
+++ b/java/com/google/gerrit/server/mail/send/MessageIdGenerator.java
@@ -58,8 +58,6 @@
/**
* Create a {@link MessageId} as a result of a change update.
*
- * @param repoView
- * @param patchsetId
* @return MessageId that depends on the patchset.
*/
public MessageId fromChangeUpdate(RepoView repoView, PatchSet.Id patchsetId) {
@@ -89,8 +87,9 @@
}
/**
- * @param accountId Create a {@link MessageId} as a result of an account update.
- * @return MessageId that depends on the account id.
+ * Create a {@link MessageId} as a result of an account update
+ *
+ * @return {@link MessageId} that depends on the account id.
*/
public MessageId fromAccountUpdate(Account.Id accountId) {
String userRef = RefNames.refsUsers(accountId);
@@ -113,8 +112,6 @@
* Create a {@link MessageId} from a reason, Account.Id, and timestamp.
*
* @param reason for performing this account update
- * @param accountId
- * @param timestamp
* @return MessageId that depends on the reason, accountId, and timestamp.
*/
public MessageId fromReasonAccountIdAndTimestamp(
diff --git a/java/com/google/gerrit/server/mail/send/OutgoingEmail.java b/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
index 8547336..8824cbd 100644
--- a/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
+++ b/java/com/google/gerrit/server/mail/send/OutgoingEmail.java
@@ -95,11 +95,7 @@
this.messageId = messageId;
}
- /**
- * Format and enqueue the message for delivery.
- *
- * @throws EmailException
- */
+ /** Format and enqueue the message for delivery. */
public void send() throws EmailException {
try {
args.retryHelper
@@ -185,7 +181,8 @@
// drop them from the recipient lists, but only if the user is not being impersonated.
//
logger.atFine().log(
- "Not CCing email sender %s because the email strategy of this user is not %s but %s",
+ "Not CCing email sender %s because the email strategy of this user is not %s but"
+ + " %s",
fromUser.get().account().id(),
CC_ON_OWN_COMMENTS,
senderPrefs != null ? senderPrefs.getEmailStrategy() : null);
@@ -543,9 +540,9 @@
}
/**
+ * Returns whether this email is visible to the given account
+ *
* @param to account.
- * @throws PermissionBackendException
- * @return whether this email is visible to the given account.
*/
protected boolean isVisibleTo(Account.Id to) throws PermissionBackendException {
return true;
diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
index a7c7757..d71f9ff 100644
--- a/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
+++ b/java/com/google/gerrit/server/notedb/AbstractChangeNotes.java
@@ -134,7 +134,7 @@
return changeId;
}
- /** @return revision of the metadata that was loaded. */
+ /** Returns revision of the metadata that was loaded. */
public ObjectId getRevision() {
return revision;
}
@@ -210,12 +210,12 @@
protected abstract void loadDefaults();
/**
- * @return the NameKey for the project where the notes should be stored, which is not necessarily
- * the same as the change's project.
+ * Returns the NameKey for the project where the notes should be stored, which is not necessarily
+ * the same as the change's project.
*/
public abstract Project.NameKey getProjectName();
- /** @return name of the reference storing this configuration. */
+ /** Returns name of the reference storing this configuration. */
protected abstract String getRefName();
/** Set up the metadata, parsing any state from the loaded revision. */
diff --git a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java
index 8e6606e..6677490 100644
--- a/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java
+++ b/java/com/google/gerrit/server/notedb/AbstractChangeUpdate.java
@@ -122,12 +122,11 @@
}
/**
- * @return notes for the state of this change prior to this update. If this update is part of a
- * series managed by a {@link NoteDbUpdateManager}, then this reflects the state prior to the
- * first update in the series. A null return value can only happen when the change is being
- * rebuilt from NoteDb. A change that is in the process of being created will result in a
- * non-null return value from this method, but a null return value from {@link
- * ChangeNotes#getRevision()}.
+ * Returns notes for the state of this change prior to this update. If this update is part of a
+ * series managed by a {@link NoteDbUpdateManager}, then this reflects the state prior to the
+ * first update in the series. A null return value can only happen when the change is being
+ * rebuilt from NoteDb. A change that is in the process of being created will result in a non-null
+ * return value from this method, but a null return value from {@link ChangeNotes#getRevision()}.
*/
@Nullable
public ChangeNotes getNotes() {
@@ -173,8 +172,8 @@
}
/**
- * @return the NameKey for the project where the update will be stored, which is not necessarily
- * the same as the change's project.
+ * Returns the NameKey for the project where the update will be stored, which is not necessarily
+ * the same as the change's project.
*/
protected abstract Project.NameKey getProjectName();
diff --git a/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java b/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
index afd8316..28ab711 100644
--- a/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
+++ b/java/com/google/gerrit/server/notedb/ChangeNoteUtil.java
@@ -40,6 +40,7 @@
static final FooterKey FOOTER_GROUPS = new FooterKey("Groups");
static final FooterKey FOOTER_HASHTAGS = new FooterKey("Hashtags");
static final FooterKey FOOTER_LABEL = new FooterKey("Label");
+ static final FooterKey FOOTER_COPIED_LABEL = new FooterKey("Copied-Label");
static final FooterKey FOOTER_PATCH_SET = new FooterKey("Patch-set");
static final FooterKey FOOTER_PATCH_SET_DESCRIPTION = new FooterKey("Patch-set-description");
static final FooterKey FOOTER_PRIVATE = new FooterKey("Private");
diff --git a/java/com/google/gerrit/server/notedb/ChangeNotes.java b/java/com/google/gerrit/server/notedb/ChangeNotes.java
index 6684493..f2034af 100644
--- a/java/com/google/gerrit/server/notedb/ChangeNotes.java
+++ b/java/com/google/gerrit/server/notedb/ChangeNotes.java
@@ -16,6 +16,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.gerrit.entities.RefNames.changeMetaRef;
import static java.util.Comparator.comparing;
@@ -31,11 +32,11 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.MultimapBuilder;
-import com.google.common.collect.Multimaps;
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import com.google.common.flogger.FluentLogger;
+import com.google.errorprone.annotations.FormatMethod;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.AttentionSetUpdate;
@@ -90,6 +91,7 @@
public static final Ordering<ChangeMessage> MESSAGE_BY_TIME =
Ordering.from(comparing(ChangeMessage::getWrittenOn));
+ @FormatMethod
public static ConfigInvalidException parseException(
Change.Id changeId, String fmt, Object... args) {
return new ConfigInvalidException("Change " + changeId + ": " + String.format(fmt, args));
@@ -336,6 +338,7 @@
// ChangeNotesCache from handlers.
private ImmutableSortedMap<PatchSet.Id, PatchSet> patchSets;
private ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvals;
+ private ImmutableListMultimap<PatchSet.Id, PatchSetApproval> approvalsWithCopied;
private ImmutableSet<Comment.Key> commentKeys;
public ChangeNotes(
@@ -373,28 +376,49 @@
return patchSets;
}
+ /**
+ * Gets the approvals, not including the copied approvals. To get copied approvals as well, use
+ * {@link #getApprovalsWithCopied}, or use {@code ApprovalInference}.
+ */
public ImmutableListMultimap<PatchSet.Id, PatchSetApproval> getApprovals() {
if (approvals == null) {
- approvals = ImmutableListMultimap.copyOf(state.approvals());
+ approvals =
+ state.approvals().stream()
+ .filter(e -> !e.getValue().copied())
+ .collect(toImmutableListMultimap(e -> e.getKey(), e -> e.getValue()));
}
return approvals;
}
+ /**
+ * This method is currently used only in tests. TODO(paiking): Use this method to fetch approvals
+ * (including copied approvals) instead of computing copied approvals on demand. This will be used
+ * by {@code ApprovalCache}.
+ *
+ * @return all approvals, including copied approvals.
+ */
+ public ImmutableListMultimap<PatchSet.Id, PatchSetApproval> getApprovalsWithCopied() {
+ if (approvalsWithCopied == null) {
+ approvalsWithCopied = ImmutableListMultimap.copyOf(state.approvals());
+ }
+ return approvalsWithCopied;
+ }
+
public ReviewerSet getReviewers() {
return state.reviewers();
}
- /** @return reviewers that do not currently have a Gerrit account and were added by email. */
+ /** Returns reviewers that do not currently have a Gerrit account and were added by email. */
public ReviewerByEmailSet getReviewersByEmail() {
return state.reviewersByEmail();
}
- /** @return reviewers that were modified during this change's current WIP phase. */
+ /** Returns reviewers that were modified during this change's current WIP phase. */
public ReviewerSet getPendingReviewers() {
return state.pendingReviewers();
}
- /** @return reviewers by email that were modified during this change's current WIP phase. */
+ /** Returns reviewers by email that were modified during this change's current WIP phase. */
public ReviewerByEmailSet getPendingReviewersByEmail() {
return state.pendingReviewersByEmail();
}
@@ -424,8 +448,8 @@
}
/**
- * @return an ImmutableSet of Account.Ids of all users that have been assigned to this change. The
- * order of the set is the order in which they were assigned.
+ * Returns an ImmutableSet of Account.Ids of all users that have been assigned to this change. The
+ * order of the set is the order in which they were assigned.
*/
public ImmutableSet<Account.Id> getPastAssignees() {
return Lists.reverse(state.assigneeUpdates()).stream()
@@ -436,37 +460,37 @@
}
/**
- * @return an ImmutableList of AssigneeStatusUpdate of all the updates to the assignee field to
- * this change. The order of the list is from most recent updates to least recent.
+ * Returns an ImmutableList of AssigneeStatusUpdate of all the updates to the assignee field to
+ * this change. The order of the list is from most recent updates to least recent.
*/
public ImmutableList<AssigneeStatusUpdate> getAssigneeUpdates() {
return state.assigneeUpdates();
}
- /** @return a ImmutableSet of all hashtags for this change sorted in alphabetical order. */
+ /** Returns an ImmutableSet of all hashtags for this change sorted in alphabetical order. */
public ImmutableSet<String> getHashtags() {
return ImmutableSortedSet.copyOf(state.hashtags());
}
- /** @return a list of all users who have ever been a reviewer on this change. */
+ /** Returns a list of all users who have ever been a reviewer on this change. */
public ImmutableList<Account.Id> getAllPastReviewers() {
return state.allPastReviewers();
}
/**
- * @return submit records stored during the most recent submit; only for changes that were
- * actually submitted.
+ * Returns submit records stored during the most recent submit; only for changes that were
+ * actually submitted.
*/
public ImmutableList<SubmitRecord> getSubmitRecords() {
return state.submitRecords();
}
- /** @return all change messages, in chronological order, oldest first. */
+ /** Returns all change messages, in chronological order, oldest first. */
public ImmutableList<ChangeMessage> getChangeMessages() {
return state.changeMessages();
}
- /** @return inline comments on each revision. */
+ /** Returns inline comments on each revision. */
public ImmutableListMultimap<ObjectId, HumanComment> getHumanComments() {
return state.publishedComments();
}
@@ -486,7 +510,7 @@
return state.updateCount();
}
- /** @return {@link Optional} value of time when the change was merged. */
+ /** Returns {@link Optional} value of time when the change was merged. */
public Optional<Timestamp> getMergedOn() {
return Optional.ofNullable(state.mergedOn());
}
@@ -498,12 +522,7 @@
public ImmutableListMultimap<ObjectId, HumanComment> getDraftComments(
Account.Id author, @Nullable Ref ref) {
loadDraftComments(author, ref);
- // Filter out any zombie draft comments. These are drafts that are also in
- // the published map, and arise when the update to All-Users to delete them
- // during the publish operation failed.
- return ImmutableListMultimap.copyOf(
- Multimaps.filterEntries(
- draftCommentNotes.getComments(), e -> !getCommentKeys().contains(e.getValue().key)));
+ return draftCommentNotes.getComments();
}
public ImmutableListMultimap<ObjectId, RobotComment> getRobotComments() {
diff --git a/java/com/google/gerrit/server/notedb/ChangeNotesParser.java b/java/com/google/gerrit/server/notedb/ChangeNotesParser.java
index f82349a..5cf3a64 100644
--- a/java/com/google/gerrit/server/notedb/ChangeNotesParser.java
+++ b/java/com/google/gerrit/server/notedb/ChangeNotesParser.java
@@ -21,6 +21,7 @@
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHANGE_ID;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHERRY_PICK_OF;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COMMIT;
+import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COPIED_LABEL;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CURRENT;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_GROUPS;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
@@ -55,6 +56,7 @@
import com.google.common.collect.Tables;
import com.google.common.flogger.FluentLogger;
import com.google.common.primitives.Ints;
+import com.google.errorprone.annotations.FormatMethod;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.Address;
@@ -413,6 +415,9 @@
for (String line : commit.getFooterLineValues(FOOTER_LABEL)) {
parseApproval(psId, accountId, realAccountId, commitTimestamp, line);
}
+ for (String line : commit.getFooterLineValues(FOOTER_COPIED_LABEL)) {
+ parseCopiedApproval(psId, commitTimestamp, line);
+ }
for (ReviewerStateInternal state : ReviewerStateInternal.values()) {
for (String line : commit.getFooterLineValues(state.getFooterKey())) {
@@ -796,6 +801,69 @@
}
}
+ // Footer example: Copied-Label: <LABEL>=VOTE <Gerrit Account>,<Gerrit Real Account> :"<TAG>"
+ // ":<"TAG>"" is optional. <Gerrit Real Account> is also optional, if it was not set.
+ // The label, vote, and the Gerrit account are mandatory (unlike FOOTER_LABEL where Gerrit
+ // Account is also optional since by default it's the committer).
+ private void parseCopiedApproval(PatchSet.Id psId, Timestamp ts, String line)
+ throws ConfigInvalidException {
+ // Copied approvals can't be explicitly removed. They are removed the same way as non-copied
+ // approvals.
+ checkFooter(!line.startsWith("-"), FOOTER_COPIED_LABEL, line);
+
+ Account.Id accountId, realAccountId = null;
+ String labelVoteStr;
+ String tag = null;
+ int s = line.indexOf(' ');
+ int tagStart = line.indexOf(":\"");
+
+ // The first account is the accountId, and second (if applicable) is the realAccountId.
+ try {
+ labelVoteStr = line.substring(0, s);
+ } catch (StringIndexOutOfBoundsException ex) {
+ throw new ConfigInvalidException(ex.getMessage(), ex);
+ }
+ String[] identities =
+ line.substring(s + 1, tagStart == -1 ? line.length() : tagStart).split(",");
+ PersonIdent ident = RawParseUtils.parsePersonIdent(identities[0]);
+ checkFooter(ident != null, FOOTER_COPIED_LABEL, line);
+ accountId = parseIdent(ident);
+
+ if (identities.length > 1) {
+ PersonIdent realIdent = RawParseUtils.parsePersonIdent(identities[1]);
+ checkFooter(realIdent != null, FOOTER_COPIED_LABEL, line);
+ realAccountId = parseIdent(realIdent);
+ }
+
+ LabelVote l;
+ try {
+ l = LabelVote.parseWithEquals(labelVoteStr);
+ } catch (IllegalArgumentException e) {
+ ConfigInvalidException pe = parseException("invalid %s: %s", FOOTER_COPIED_LABEL, line);
+ pe.initCause(e);
+ throw pe;
+ }
+
+ if (tagStart != -1) {
+ // tagStart+2 skips ":\"" to parse the actual tag. Tags are in brackets.
+ // line.length()-1 skips the last ".
+ tag = line.substring(tagStart + 2, line.length() - 1);
+ }
+
+ PatchSetApproval.Builder psa =
+ PatchSetApproval.builder()
+ .key(PatchSetApproval.key(psId, accountId, LabelId.create(l.label())))
+ .value(l.value())
+ .granted(ts)
+ .tag(Optional.ofNullable(tag))
+ .copied(true);
+ if (realAccountId != null) {
+ psa.realAccountId(realAccountId);
+ }
+ approvals.putIfAbsent(psa.key(), psa);
+ bufferedApprovals.add(psa);
+ }
+
private void parseApproval(
PatchSet.Id psId, Account.Id accountId, Account.Id realAccountId, Timestamp ts, String line)
throws ConfigInvalidException {
@@ -1172,6 +1240,7 @@
}
if (!missing.isEmpty()) {
throw parseException(
+ "%s",
"Missing footers: " + missing.stream().map(FooterKey::getName).collect(joining(", ")));
}
}
@@ -1205,6 +1274,7 @@
return pending != null && pending.commitId().isPresent();
}
+ @FormatMethod
private ConfigInvalidException parseException(String fmt, Object... args) {
return ChangeNotes.parseException(id, fmt, args);
}
diff --git a/java/com/google/gerrit/server/notedb/ChangeUpdate.java b/java/com/google/gerrit/server/notedb/ChangeUpdate.java
index 004ad40..5acea1b 100644
--- a/java/com/google/gerrit/server/notedb/ChangeUpdate.java
+++ b/java/com/google/gerrit/server/notedb/ChangeUpdate.java
@@ -24,6 +24,7 @@
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHANGE_ID;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CHERRY_PICK_OF;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COMMIT;
+import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_COPIED_LABEL;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_CURRENT;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_GROUPS;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
@@ -52,6 +53,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Table;
+import com.google.common.collect.Table.Cell;
import com.google.common.collect.TreeBasedTable;
import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.Address;
@@ -61,6 +63,7 @@
import com.google.gerrit.entities.Comment;
import com.google.gerrit.entities.HumanComment;
import com.google.gerrit.entities.LabelId;
+import com.google.gerrit.entities.PatchSetApproval;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RobotComment;
import com.google.gerrit.entities.SubmissionId;
@@ -128,6 +131,7 @@
private final ServiceUserClassifier serviceUserClassifier;
private final Table<String, Account.Id, Optional<Short>> approvals;
+ private final List<PatchSetApproval> copiedApprovals = new ArrayList<>();
private final Map<Account.Id, ReviewerStateInternal> reviewers = new LinkedHashMap<>();
private final Map<Address, ReviewerStateInternal> reviewersByEmail = new LinkedHashMap<>();
private final List<HumanComment> comments = new ArrayList<>();
@@ -273,6 +277,15 @@
approvals.put(label, reviewer, Optional.empty());
}
+ /**
+ * We expect the {@code copied} flag of {@code copiedPatchSetApproval} to be set, since this
+ * method is only meant for copied approvals.
+ */
+ public void putCopiedApproval(PatchSetApproval copiedPatchSetApproval) {
+ checkArgument(copiedPatchSetApproval.copied(), "Approval that should be copied is not copied.");
+ copiedApprovals.add(copiedPatchSetApproval);
+ }
+
public void merge(SubmissionId submissionId, Iterable<SubmitRecord> submitRecords) {
this.status = Change.Status.MERGED;
this.submissionId = submissionId.toString();
@@ -492,7 +505,7 @@
this.cherryPickOf = Optional.empty();
}
- /** @return the tree id for the updated tree */
+ /** Returns the tree id for the updated tree */
private ObjectId storeRevisionNotes(RevWalk rw, ObjectInserter inserter, ObjectId curr)
throws ConfigInvalidException, IOException {
if (submitRequirementResults.isEmpty() && comments.isEmpty() && pushCert == null) {
@@ -705,18 +718,10 @@
}
for (Table.Cell<String, Account.Id, Optional<Short>> c : approvals.cellSet()) {
- addFooter(msg, FOOTER_LABEL);
- // Label names/values are safe to append without sanitizing.
- if (!c.getValue().isPresent()) {
- msg.append('-').append(c.getRowKey());
- } else {
- msg.append(LabelVote.create(c.getRowKey(), c.getValue().get()).formatWithEquals());
- }
- Account.Id id = c.getColumnKey();
- if (!id.equals(getAccountId())) {
- noteUtil.appendAccountIdIdentString(msg.append(' '), id);
- }
- msg.append('\n');
+ addLabelFooter(msg, c);
+ }
+ for (PatchSetApproval patchSetApproval : copiedApprovals) {
+ addCopiedLabelFooter(msg, patchSetApproval);
}
if (submissionId != null) {
@@ -797,6 +802,47 @@
return cb;
}
+ private void addLabelFooter(StringBuilder msg, Cell<String, Account.Id, Optional<Short>> c) {
+ addFooter(msg, FOOTER_LABEL);
+ // Label names/values are safe to append without sanitizing.
+ if (!c.getValue().isPresent()) {
+ msg.append('-').append(c.getRowKey());
+ } else {
+ msg.append(LabelVote.create(c.getRowKey(), c.getValue().get()).formatWithEquals());
+ }
+ Account.Id id = c.getColumnKey();
+ if (!id.equals(getAccountId())) {
+ noteUtil.appendAccountIdIdentString(msg.append(' '), id);
+ }
+ msg.append('\n');
+ }
+
+ private void addCopiedLabelFooter(StringBuilder msg, PatchSetApproval patchSetApproval) {
+ if (patchSetApproval.value() == 0) {
+ // Can only happen if we removed a vote. There is no need to persist removed votes.
+ return;
+ }
+ addFooter(msg, FOOTER_COPIED_LABEL);
+ // Label names/values are safe to append without sanitizing.
+ msg.append(
+ LabelVote.create(patchSetApproval.label(), patchSetApproval.value()).formatWithEquals());
+ Account.Id id = patchSetApproval.accountId();
+ noteUtil.appendAccountIdIdentString(msg.append(' '), id);
+
+ // In the non-copied labels, we don't need to pass the real account id since it's already
+ // in FOOTER_REAL_USER. Here, we want to retain the original real account id.
+ if (patchSetApproval.realAccountId() != null) {
+ noteUtil.appendAccountIdIdentString(msg.append(","), patchSetApproval.realAccountId());
+ }
+
+ // In the non-copied labels, we don't need to pass the tag since it's already in
+ // FOOTER_TAG, but in this chase we want to retain the original tag, and not the current tag.
+ if (patchSetApproval.tag().isPresent()) {
+ msg.append(":\"" + sanitizeFooter(patchSetApproval.tag().get()) + "\"");
+ }
+ msg.append('\n');
+ }
+
private void clearAttentionSet(String reason) {
if (getNotes().getAttentionSet() == null) {
return;
@@ -992,6 +1038,7 @@
public boolean isEmpty() {
return commitSubject == null
&& approvals.isEmpty()
+ && copiedApprovals.isEmpty()
&& changeMessage == null
&& comments.isEmpty()
&& reviewers.isEmpty()
diff --git a/java/com/google/gerrit/server/notedb/CommitRewriter.java b/java/com/google/gerrit/server/notedb/CommitRewriter.java
index 7d743dc..3cbe546 100644
--- a/java/com/google/gerrit/server/notedb/CommitRewriter.java
+++ b/java/com/google/gerrit/server/notedb/CommitRewriter.java
@@ -20,6 +20,7 @@
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_LABEL;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_REAL_USER;
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_SUBMITTED_WITH;
+import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TAG;
import static com.google.gerrit.server.util.AccountTemplateUtil.ACCOUNT_TEMPLATE_PATTERN;
import static com.google.gerrit.server.util.AccountTemplateUtil.ACCOUNT_TEMPLATE_REGEX;
@@ -39,6 +40,7 @@
import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.git.RefUpdateUtil;
import com.google.gerrit.json.OutputFormat;
+import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.externalids.ExternalId;
@@ -58,7 +60,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -170,7 +171,8 @@
Pattern.compile("Assignee changed from: (.*) to: (.*)");
private static final Pattern REMOVED_REVIEWER_PATTERN =
- Pattern.compile("Removed (cc|reviewer) (.*)(\\.| with the following votes)");
+ Pattern.compile(
+ "Removed (cc|reviewer) (.*)(\\.| with the following votes:\n.*)", Pattern.DOTALL);
private static final Pattern REMOVED_VOTE_PATTERN = Pattern.compile("Removed (.*) by (.*)");
@@ -186,12 +188,18 @@
private static final Pattern ON_CODE_OWNER_ADD_REVIEWER_PATTERN =
Pattern.compile("(.*) who was added as reviewer owns the following files");
+
+ private static final String CODE_OWNER_ADD_REVIEWER_TAG =
+ ChangeMessagesUtil.AUTOGENERATED_BY_GERRIT_TAG_PREFIX + "code-owners:addReviewer";
+
private static final String ON_CODE_OWNER_APPROVAL_REGEX = "code-owner approved by (.*):";
private static final String ON_CODE_OWNER_OVERRIDE_REGEX =
"code-owners submit requirement .* overridden by (.*)";
private static final Pattern ON_CODE_OWNER_REVIEW_PATTERN =
Pattern.compile(ON_CODE_OWNER_APPROVAL_REGEX + "|" + ON_CODE_OWNER_OVERRIDE_REGEX);
+ private static final Pattern ON_CODE_OWNER_POST_REVIEW_PATTERN =
+ Pattern.compile("Patch Set [0-9]+:[\\s\\S]*By (voting|removing)[\\s\\S]*");
private static final Pattern REPLY_BY_REASON_PATTERN =
Pattern.compile("(.*) replied on the change");
@@ -386,7 +394,7 @@
RevCommit originalCommit;
boolean rewriteStarted = false;
- ChangeFixProgress changeFixProgress = new ChangeFixProgress();
+ ChangeFixProgress changeFixProgress = new ChangeFixProgress(ref.getName());
while ((originalCommit = revWalk.next()) != null) {
changeFixProgress.updateAuthorId =
@@ -538,7 +546,9 @@
return Optional.of(
"Assignee deleted: "
+ getPossibleAccountReplacement(
- changeFixProgress, oldAssignee, assigneeDeletedMatcher.group(1)));
+ changeFixProgress,
+ oldAssignee,
+ ParsedAccountInfo.create(assigneeDeletedMatcher.group(1))));
}
return Optional.empty();
}
@@ -549,7 +559,9 @@
return Optional.of(
"Assignee added: "
+ getPossibleAccountReplacement(
- changeFixProgress, newAssignee, assigneeAddedMatcher.group(1)));
+ changeFixProgress,
+ newAssignee,
+ ParsedAccountInfo.create(assigneeAddedMatcher.group(1))));
}
return Optional.empty();
}
@@ -561,9 +573,13 @@
String.format(
"Assignee changed from: %s to: %s",
getPossibleAccountReplacement(
- changeFixProgress, oldAssignee, assigneeChangedMatcher.group(1)),
+ changeFixProgress,
+ oldAssignee,
+ ParsedAccountInfo.create(assigneeChangedMatcher.group(1))),
getPossibleAccountReplacement(
- changeFixProgress, newAssignee, assigneeChangedMatcher.group(2))));
+ changeFixProgress,
+ newAssignee,
+ ParsedAccountInfo.create(assigneeChangedMatcher.group(2)))));
}
return Optional.empty();
}
@@ -576,7 +592,7 @@
}
Matcher matcher = REMOVED_REVIEWER_PATTERN.matcher(originalChangeMessage);
- if (matcher.find() && !ACCOUNT_TEMPLATE_PATTERN.matcher(matcher.group(2)).matches()) {
+ if (matcher.matches() && !ACCOUNT_TEMPLATE_PATTERN.matcher(matcher.group(2)).matches()) {
// Since we do not use change messages for reviewer updates on UI, it does not matter what we
// rewrite it to.
return Optional.of(originalChangeMessage.substring(0, matcher.end(1)));
@@ -599,7 +615,7 @@
"Removed %s by %s",
matcher.group(1),
getPossibleAccountReplacement(
- changeFixProgress, reviewer, getNameFromNameEmail(matcher.group(2)))));
+ changeFixProgress, reviewer, getAccountInfoFromNameEmail(matcher.group(2)))));
}
return Optional.empty();
}
@@ -612,21 +628,27 @@
}
String[] lines = originalChangeMessage.split("\\r?\\n");
StringBuilder fixedLines = new StringBuilder();
+ boolean anyFixed = false;
for (int i = 1; i < lines.length; i++) {
if (lines[i].isEmpty()) {
continue;
}
Matcher matcher = REMOVED_VOTES_CHANGE_MESSAGE_PATTERN.matcher(lines[i]);
+ String replacementLine = lines[i];
if (matcher.matches() && !NON_REPLACE_ACCOUNT_PATTERN.matcher(matcher.group(2)).matches()) {
- fixedLines.append(
+ anyFixed = true;
+ replacementLine =
String.format(
"* %s by %s\n",
matcher.group(1),
getPossibleAccountReplacement(
- changeFixProgress, Optional.empty(), getNameFromNameEmail(matcher.group(2)))));
+ changeFixProgress,
+ Optional.empty(),
+ getAccountInfoFromNameEmail(matcher.group(2))));
}
+ fixedLines.append(replacementLine);
}
- if (fixedLines.length() == 0) {
+ if (!anyFixed) {
return Optional.empty();
}
return Optional.of(REMOVED_VOTES_CHANGE_MESSAGE_START + "\n" + fixedLines);
@@ -687,7 +709,8 @@
while (onAddReviewerMatcher.find()) {
String reviewerName = normalizeOnCodeOwnerAddReviewerMatch(onAddReviewerMatcher.group(1));
String replacementName =
- getPossibleAccountReplacement(changeFixProgress, Optional.empty(), reviewerName);
+ getPossibleAccountReplacement(
+ changeFixProgress, Optional.empty(), ParsedAccountInfo.create(reviewerName));
onAddReviewerMatcher.appendReplacement(
sb, replacementName + ", who was added as reviewer owns the following files");
}
@@ -717,7 +740,11 @@
if (Strings.isNullOrEmpty(originalMessage)) {
return Optional.empty();
}
-
+ Matcher onCodeOwnerPostReviewMatcher =
+ ON_CODE_OWNER_POST_REVIEW_PATTERN.matcher(originalMessage);
+ if (!onCodeOwnerPostReviewMatcher.matches()) {
+ return Optional.empty();
+ }
Matcher onCodeOwnerReviewMatcher = ON_CODE_OWNER_REVIEW_PATTERN.matcher(originalMessage);
while (onCodeOwnerReviewMatcher.find()) {
String accountName =
@@ -809,7 +836,9 @@
for (FooterLine fl : footerLines) {
String footerKey = fl.getKey();
String footerValue = fl.getValue();
- if (footerKey.equalsIgnoreCase(FOOTER_ASSIGNEE.getName())) {
+ if (footerKey.equalsIgnoreCase(FOOTER_TAG.getName())) {
+ fixProgress.tag = footerValue;
+ } else if (footerKey.equalsIgnoreCase(FOOTER_ASSIGNEE.getName())) {
Account.Id oldAssignee = fixProgress.assigneeId;
FixIdentResult fixedAssignee = null;
if (footerValue.equals("")) {
@@ -940,7 +969,8 @@
fixedChangeMessage =
fixCodeOwnersOnReviewChangeMessage(fixProgress.updateAuthorId, originalChangeMessage);
}
- if (!fixedChangeMessage.isPresent()) {
+ if (!fixedChangeMessage.isPresent()
+ && Objects.equals(fixProgress.tag, CODE_OWNER_ADD_REVIEWER_TAG)) {
fixedChangeMessage =
fixCodeOwnersOnAddReviewerChangeMessage(fixProgress, originalChangeMessage);
}
@@ -971,9 +1001,10 @@
private Optional<Account.Id> parseIdent(ChangeFixProgress changeFixProgress, PersonIdent ident) {
Optional<Account.Id> account = NoteDbUtil.parseIdent(ident);
if (account.isPresent()) {
- changeFixProgress.parsedAccounts.putIfAbsent(account.get(), "");
+ changeFixProgress.parsedAccounts.putIfAbsent(account.get(), Optional.empty());
} else {
- logger.atWarning().log("Failed to parse id %s", ident);
+ logger.atWarning().log(
+ "Fixing ref %s, failed to parse id %s", changeFixProgress.changeMetaRef, ident);
}
return account;
}
@@ -1022,10 +1053,16 @@
return fixIdentResult;
}
- /** Extracts {@link Account#getName} from {@link Account#getNameEmail} */
- private String getNameFromNameEmail(String nameEmail) {
+ /** Extracts {@link ParsedAccountInfo} from {@link Account#getNameEmail} */
+ private ParsedAccountInfo getAccountInfoFromNameEmail(String nameEmail) {
Matcher nameEmailMatcher = NAME_EMAIL_PATTERN.matcher(nameEmail);
- return nameEmailMatcher.matches() ? nameEmailMatcher.group(1) : nameEmail;
+ if (!nameEmailMatcher.matches()) {
+ return ParsedAccountInfo.create(nameEmail);
+ }
+
+ return ParsedAccountInfo.create(
+ nameEmailMatcher.group(1),
+ nameEmailMatcher.group(2).substring(1, nameEmailMatcher.group(2).length() - 1));
}
/**
@@ -1038,39 +1075,73 @@
*
* @param changeFixProgress see {@link ChangeFixProgress}
* @param account account that should be used for replacement, if known
- * @param accountName {@link Account#getName} to replace.
+ * @param accountInfo {@link ParsedAccountInfo} to replace.
* @return replacement for {@code accountName}
*/
private String getPossibleAccountReplacement(
- ChangeFixProgress changeFixProgress, Optional<Account.Id> account, String accountName) {
+ ChangeFixProgress changeFixProgress,
+ Optional<Account.Id> account,
+ ParsedAccountInfo accountInfo) {
if (account.isPresent()) {
return AccountTemplateUtil.getAccountTemplate(account.get());
}
// Retrieve reviewer accounts from cache and try to match by their name.
- Map<Account.Id, AccountState> missingUserNameReviewers =
+ Map<Account.Id, AccountState> missingAccountStateReviewers =
accountCache.get(
changeFixProgress.parsedAccounts.entrySet().stream()
- .filter(entry -> entry.getValue().isEmpty())
+ .filter(entry -> !entry.getValue().isPresent())
.map(Map.Entry::getKey)
.collect(ImmutableSet.toImmutableSet()));
changeFixProgress.parsedAccounts.putAll(
- missingUserNameReviewers.entrySet().stream()
+ missingAccountStateReviewers.entrySet().stream()
.collect(
ImmutableMap.toImmutableMap(
- Map.Entry::getKey, e -> e.getValue().account().getName())));
- Set<Account.Id> possibleReplacements =
- changeFixProgress.parsedAccounts.entrySet().stream()
- .filter(e -> e.getValue().equals(accountName))
- .map(Entry::getKey)
- .collect(ImmutableSet.toImmutableSet());
+ Map.Entry::getKey, e -> Optional.ofNullable(e.getValue()))));
+ Map<Account.Id, AccountState> possibleReplacements = ImmutableMap.of();
+ if (accountInfo.email().isPresent()) {
+ possibleReplacements =
+ changeFixProgress.parsedAccounts.entrySet().stream()
+ .filter(
+ e ->
+ e.getValue().isPresent()
+ && Objects.equals(
+ e.getValue().get().account().preferredEmail(),
+ accountInfo.email().get()))
+ .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, e -> e.getValue().get()));
+ // Filter further so we match both email & name
+ if (possibleReplacements.size() > 1) {
+ logger.atWarning().log(
+ "Fixing ref %s, multiple accounts found with the same email address, while replacing %s",
+ changeFixProgress.changeMetaRef, accountInfo);
+ possibleReplacements =
+ possibleReplacements.entrySet().stream()
+ .filter(e -> Objects.equals(e.getValue().account().getName(), accountInfo.name()))
+ .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));
+ }
+ }
+ if (possibleReplacements.isEmpty()) {
+ possibleReplacements =
+ changeFixProgress.parsedAccounts.entrySet().stream()
+ .filter(
+ e ->
+ e.getValue().isPresent()
+ && Objects.equals(
+ e.getValue().get().account().getName(), accountInfo.name()))
+ .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, e -> e.getValue().get()));
+ }
String replacementName = DEFAULT_ACCOUNT_REPLACEMENT;
if (possibleReplacements.isEmpty()) {
- logger.atWarning().log("Could not find reviewer account matching name %s", accountName);
+ logger.atWarning().log(
+ "Fixing ref %s, could not find reviewer account matching name %s",
+ changeFixProgress.changeMetaRef, accountInfo);
} else if (possibleReplacements.size() > 1) {
- logger.atWarning().log("Found multiple reviewer account matching name %s", accountName);
+ logger.atWarning().log(
+ "Fixing ref %s found multiple reviewer account matching name %s",
+ changeFixProgress.changeMetaRef, accountInfo);
} else {
replacementName =
- AccountTemplateUtil.getAccountTemplate(Iterables.getOnlyElement(possibleReplacements));
+ AccountTemplateUtil.getAccountTemplate(
+ Iterables.getOnlyElement(possibleReplacements.keySet()));
}
return replacementName;
}
@@ -1135,6 +1206,13 @@
* recent update.
*/
private static class ChangeFixProgress {
+
+ /** {@link RefNames#changeMetaRef} of the change that is being fixed. */
+ final String changeMetaRef;
+
+ /** Tag at current commit update. */
+ String tag = null;
+
/** Assignee at current commit update. */
Account.Id assigneeId = null;
@@ -1146,7 +1224,7 @@
* #accountCache} if needed by rewrite. Maps to empty string if was not requested from cache
* yet.
*/
- Map<Account.Id, String> parsedAccounts = new HashMap<>();
+ Map<Account.Id, Optional<AccountState>> parsedAccounts = new HashMap<>();
/** Id of the current commit in rewriter walk. */
ObjectId newTipId = null;
@@ -1160,5 +1238,29 @@
boolean isValidAfterFix = true;
List<CommitDiff> commitDiffs = new ArrayList<>();
+
+ public ChangeFixProgress(String changeMetaRef) {
+ this.changeMetaRef = changeMetaRef;
+ }
+ }
+
+ /**
+ * Account info parsed from {@link Account#getNameEmail}. See {@link
+ * #getAccountInfoFromNameEmail}.
+ */
+ @AutoValue
+ abstract static class ParsedAccountInfo {
+
+ static ParsedAccountInfo create(String fullName, String email) {
+ return new AutoValue_CommitRewriter_ParsedAccountInfo(fullName, Optional.ofNullable(email));
+ }
+
+ static ParsedAccountInfo create(String fullName) {
+ return new AutoValue_CommitRewriter_ParsedAccountInfo(fullName, Optional.empty());
+ }
+
+ abstract String name();
+
+ abstract Optional<String> email();
}
}
diff --git a/java/com/google/gerrit/server/notedb/DeleteChangeMessageRewriter.java b/java/com/google/gerrit/server/notedb/DeleteChangeMessageRewriter.java
index e07c793..6d6d53d 100644
--- a/java/com/google/gerrit/server/notedb/DeleteChangeMessageRewriter.java
+++ b/java/com/google/gerrit/server/notedb/DeleteChangeMessageRewriter.java
@@ -110,7 +110,6 @@
* @param commitMessage the full commit message of the new commit.
* @param inserter the {@code ObjectInserter} for the rewrite process.
* @return the {@code objectId} of the new commit.
- * @throws IOException
*/
private ObjectId rewriteOneCommit(
RevCommit originalCommit,
diff --git a/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java b/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java
index d0b6247..e8c0fda 100644
--- a/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java
+++ b/java/com/google/gerrit/server/notedb/DeleteCommentRewriter.java
@@ -191,8 +191,6 @@
* @param putInComments the comments put in by this commit.
* @param deletedComments the comments deleted by this commit.
* @return the {@code objectId} of the new commit.
- * @throws IOException
- * @throws ConfigInvalidException
*/
private ObjectId rewriteCommit(
RevCommit originalCommit,
diff --git a/java/com/google/gerrit/server/notedb/Sequences.java b/java/com/google/gerrit/server/notedb/Sequences.java
index 7a8e28f..7ae98778 100644
--- a/java/com/google/gerrit/server/notedb/Sequences.java
+++ b/java/com/google/gerrit/server/notedb/Sequences.java
@@ -112,8 +112,11 @@
.setCumulative()
.setUnit(Units.MILLISECONDS),
Field.ofEnum(SequenceType.class, "sequence", Metadata.Builder::noteDbSequenceType)
+ .description("The sequence from which IDs were retrieved.")
.build(),
- Field.ofBoolean("multiple", Metadata.Builder::multiple).build());
+ Field.ofBoolean("multiple", Metadata.Builder::multiple)
+ .description("Whether more than one ID was retrieved.")
+ .build());
}
public int nextAccountId() {
diff --git a/java/com/google/gerrit/server/patch/AutoMerger.java b/java/com/google/gerrit/server/patch/AutoMerger.java
index 97910400..2529c04 100644
--- a/java/com/google/gerrit/server/patch/AutoMerger.java
+++ b/java/com/google/gerrit/server/patch/AutoMerger.java
@@ -100,18 +100,22 @@
MetricMaker metricMaker,
@GerritServerConfig Config cfg,
@GerritPersonIdent Provider<PersonIdent> gerritIdentProvider) {
+ Field<OperationType> operationTypeField =
+ Field.ofEnum(OperationType.class, "type", Metadata.Builder::operationName)
+ .description("The type of the operation (CACHE_LOAD, IN_MEMORY_WRITE, ON_DISK_WRITE).")
+ .build();
this.counter =
metricMaker.newCounter(
"git/auto-merge/num_operations",
new Description("AutoMerge computations").setRate().setUnit("auto merge computations"),
- Field.ofEnum(OperationType.class, "type", Metadata.Builder::operationName).build());
+ operationTypeField);
this.latency =
metricMaker.newTimer(
"git/auto-merge/latency",
new Description("AutoMerge computation latency")
.setCumulative()
.setUnit("milliseconds"),
- Field.ofEnum(OperationType.class, "type", Metadata.Builder::operationName).build());
+ operationTypeField);
this.save = cacheAutomerge(cfg);
this.gerritIdentProvider = gerritIdentProvider;
this.configuredMergeStrategy = MergeUtil.getMergeStrategy(cfg);
diff --git a/java/com/google/gerrit/server/patch/PatchFile.java b/java/com/google/gerrit/server/patch/PatchFile.java
index 3cc89f85..81355cc 100644
--- a/java/com/google/gerrit/server/patch/PatchFile.java
+++ b/java/com/google/gerrit/server/patch/PatchFile.java
@@ -62,6 +62,11 @@
.findFirst()
.orElse(FileDiffOutput.empty(fileName, ObjectId.zeroId(), ObjectId.zeroId()));
+ if (Patch.PATCHSET_LEVEL.equals(fileName)) {
+ aTree = null;
+ bTree = null;
+ return;
+ }
try (ObjectReader reader = repo.newObjectReader();
RevWalk rw = new RevWalk(reader)) {
final RevCommit bCommit = rw.parseCommit(diff.newCommitId());
@@ -117,7 +122,6 @@
* @param line the line number to extract (1 based; 1 is the first line).
* @return the string version of the file line.
* @throws IOException the patch or complete file content cannot be read.
- * @throws NoSuchEntityException
*/
public String getLine(int file, int line) throws IOException, NoSuchEntityException {
switch (file) {
@@ -144,7 +148,7 @@
private Text load(ObjectId tree, String path)
throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException,
IOException {
- if (path == null) {
+ if (path == null || Patch.PATCHSET_LEVEL.equals(path)) {
return Text.EMPTY;
}
final TreeWalk tw = TreeWalk.forPath(repo, path, tree);
diff --git a/java/com/google/gerrit/server/patch/PatchList.java b/java/com/google/gerrit/server/patch/PatchList.java
index cb95553..b983fb8 100644
--- a/java/com/google/gerrit/server/patch/PatchList.java
+++ b/java/com/google/gerrit/server/patch/PatchList.java
@@ -140,17 +140,17 @@
return Collections.unmodifiableList(Arrays.asList(patches));
}
- /** @return the comparison type */
+ /** Returns the comparison type */
public ComparisonType getComparisonType() {
return comparisonType;
}
- /** @return total number of new lines added. */
+ /** Returns total number of new lines added. */
public int getInsertions() {
return insertions;
}
- /** @return total number of lines removed. */
+ /** Returns total number of lines removed. */
public int getDeletions() {
return deletions;
}
diff --git a/java/com/google/gerrit/server/patch/diff/ModifiedFilesCache.java b/java/com/google/gerrit/server/patch/diff/ModifiedFilesCache.java
index 56f49c9..76d1710 100644
--- a/java/com/google/gerrit/server/patch/diff/ModifiedFilesCache.java
+++ b/java/com/google/gerrit/server/patch/diff/ModifiedFilesCache.java
@@ -35,9 +35,10 @@
public interface ModifiedFilesCache {
/**
+ * Returns the list of {@link ModifiedFile}s between the 2 git commits identified by the key
+ *
* @param key used to identify two git commits and contains other attributes to control the diff
* calculation.
- * @return the list of {@link ModifiedFile}s between the 2 git commits identified by the key.
* @throws DiffNotAvailableException the supplied commits IDs of the key do no exist, are not IDs
* of a commit, or an exception occurred while reading a pack file.
*/
diff --git a/java/com/google/gerrit/server/patch/diff/ModifiedFilesCacheKey.java b/java/com/google/gerrit/server/patch/diff/ModifiedFilesCacheKey.java
index 2ac3f5e..4a406c8 100644
--- a/java/com/google/gerrit/server/patch/diff/ModifiedFilesCacheKey.java
+++ b/java/com/google/gerrit/server/patch/diff/ModifiedFilesCacheKey.java
@@ -32,10 +32,10 @@
/** A specific git project / repository. */
public abstract Project.NameKey project();
- /** @return the old commit ID used in the git tree diff */
+ /** Returns the old commit ID used in the git tree diff */
public abstract ObjectId aCommit();
- /** @return the new commit ID used in the git tree diff */
+ /** Returns the new commit ID used in the git tree diff */
public abstract ObjectId bCommit();
/**
diff --git a/java/com/google/gerrit/server/permissions/LabelPermission.java b/java/com/google/gerrit/server/permissions/LabelPermission.java
index 268570c..c266caa 100644
--- a/java/com/google/gerrit/server/permissions/LabelPermission.java
+++ b/java/com/google/gerrit/server/permissions/LabelPermission.java
@@ -71,12 +71,12 @@
this.name = LabelType.checkName(name);
}
- /** @return {@code SELF} or {@code ON_BEHALF_OF} (or labelAs). */
+ /** Returns {@code SELF} or {@code ON_BEHALF_OF} (or labelAs). */
public ForUser forUser() {
return forUser;
}
- /** @return name of the label, e.g. {@code "Code-Review"}. */
+ /** Returns name of the label, e.g. {@code "Code-Review"}. */
public String label() {
return name;
}
@@ -199,17 +199,17 @@
this.label = requireNonNull(label, "LabelVote");
}
- /** @return {@code SELF} or {@code ON_BEHALF_OF} (or labelAs). */
+ /** Returns {@code SELF} or {@code ON_BEHALF_OF} (or labelAs). */
public ForUser forUser() {
return forUser;
}
- /** @return name of the label, e.g. {@code "Code-Review"}. */
+ /** Returns name of the label, e.g. {@code "Code-Review"}. */
public String label() {
return label.label();
}
- /** @return specific value of the label, e.g. 1 or 2. */
+ /** Returns specific value of the label, e.g. 1 or 2. */
public short value() {
return label.value();
}
diff --git a/java/com/google/gerrit/server/permissions/PermissionCollection.java b/java/com/google/gerrit/server/permissions/PermissionCollection.java
index ddba52b..4b8db1c 100644
--- a/java/com/google/gerrit/server/permissions/PermissionCollection.java
+++ b/java/com/google/gerrit/server/permissions/PermissionCollection.java
@@ -277,8 +277,8 @@
}
/**
- * @return true if a "${username}" pattern might need to be expanded to build this collection,
- * making the results user specific.
+ * Returns true if a "${username}" pattern might need to be expanded to build this collection,
+ * making the results user specific.
*/
public boolean isUserSpecific() {
return perUser;
diff --git a/java/com/google/gerrit/server/permissions/ProjectControl.java b/java/com/google/gerrit/server/permissions/ProjectControl.java
index a92fde0..1203049 100644
--- a/java/com/google/gerrit/server/permissions/ProjectControl.java
+++ b/java/com/google/gerrit/server/permissions/ProjectControl.java
@@ -154,8 +154,8 @@
}
/**
- * @return {@code Capable.OK} if the user can upload to at least one reference. Does not check
- * Contributor Agreements.
+ * Returns {@code Capable.OK} if the user can upload to at least one reference. Does not check
+ * Contributor Agreements.
*/
boolean canPushToAtLeastOneRef() {
return canPerformOnAnyRef(Permission.PUSH)
diff --git a/java/com/google/gerrit/server/permissions/RefControl.java b/java/com/google/gerrit/server/permissions/RefControl.java
index f800207..6b51335 100644
--- a/java/com/google/gerrit/server/permissions/RefControl.java
+++ b/java/com/google/gerrit/server/permissions/RefControl.java
@@ -135,19 +135,19 @@
return hasReadPermissionOnRef;
}
- /** @return true if this user can add a new patch set to this ref */
+ /** Returns true if this user can add a new patch set to this ref */
boolean canAddPatchSet() {
return projectControl
.controlForRef(MagicBranch.NEW_CHANGE + refName)
.canPerform(Permission.ADD_PATCH_SET);
}
- /** @return true if this user can rebase changes on this ref */
+ /** Returns true if this user can rebase changes on this ref */
boolean canRebase() {
return canPerform(Permission.REBASE);
}
- /** @return true if this user can submit patch sets to this ref */
+ /** Returns true if this user can submit patch sets to this ref */
boolean canSubmit(boolean isChangeOwner) {
if (RefNames.REFS_CONFIG.equals(refName)) {
// Always allow project owners to submit configuration changes.
@@ -160,12 +160,12 @@
return canPerform(Permission.SUBMIT, isChangeOwner, false);
}
- /** @return true if this user can force edit topic names. */
+ /** Returns true if this user can force edit topic names. */
boolean canForceEditTopicName() {
return canPerform(Permission.EDIT_TOPIC_NAME, false, true);
}
- /** @return true if this user can delete changes. */
+ /** Returns true if this user can delete changes. */
boolean canDeleteChanges(boolean isChangeOwner) {
return canPerform(Permission.DELETE_CHANGES)
|| (isChangeOwner && canPerform(Permission.DELETE_OWN_CHANGES, isChangeOwner, false));
@@ -201,12 +201,12 @@
return canPerform(Permission.REVERT);
}
- /** @return true if this user can submit merge patch sets to this ref */
+ /** Returns true if this user can submit merge patch sets to this ref */
private boolean canUploadMerges() {
return projectControl.controlForRef("refs/for/" + refName).canPerform(Permission.PUSH_MERGE);
}
- /** @return true if the user can update the reference as a fast-forward. */
+ /** Returns true if the user can update the reference as a fast-forward. */
private boolean canUpdate() {
if (RefNames.REFS_CONFIG.equals(refName) && !projectControl.isOwner()) {
// Pushing requires being at least project owner, in addition to push.
@@ -225,7 +225,7 @@
return canPerform(Permission.PUSH);
}
- /** @return true if the user can rewind (force push) the reference. */
+ /** Returns true if the user can rewind (force push) the reference. */
private boolean canForceUpdate() {
if (canPushWithForce()) {
return true;
@@ -281,7 +281,7 @@
}
}
- /** @return true if this user can forge the author line in a commit. */
+ /** Returns true if this user can forge the author line in a commit. */
private boolean canForgeAuthor() {
if (canForgeAuthor == null) {
canForgeAuthor = canPerform(Permission.FORGE_AUTHOR);
@@ -289,7 +289,7 @@
return canForgeAuthor;
}
- /** @return true if this user can forge the committer line in a commit. */
+ /** Returns true if this user can forge the committer line in a commit. */
private boolean canForgeCommitter() {
if (canForgeCommitter == null) {
canForgeCommitter = canPerform(Permission.FORGE_COMMITTER);
@@ -297,7 +297,7 @@
return canForgeCommitter;
}
- /** @return true if this user can forge the server on the committer line. */
+ /** Returns true if this user can forge the server on the committer line. */
private boolean canForgeGerritServerIdentity() {
return canPerform(Permission.FORGE_SERVER);
}
@@ -364,7 +364,9 @@
}
return new PermissionRange(
- permissionName, Math.max(voteMin, blockAllowMin), Math.min(voteMax, blockAllowMax));
+ permissionName,
+ /* min= */ Math.max(voteMin, blockAllowMin),
+ /* max= */ Math.min(voteMax, blockAllowMax));
}
private boolean isBlocked(String permissionName, boolean isChangeOwner, boolean withForce) {
@@ -560,7 +562,8 @@
break;
case FORGE_COMMITTER:
pde.setAdvice(
- "You need 'Forge Committer' rights to push commits with another user as committer.");
+ "You need 'Forge Committer' rights to push commits with another user as"
+ + " committer.");
break;
case FORGE_SERVER:
pde.setAdvice(
diff --git a/java/com/google/gerrit/server/permissions/SectionSortCache.java b/java/com/google/gerrit/server/permissions/SectionSortCache.java
index d800782..e64f8b6 100644
--- a/java/com/google/gerrit/server/permissions/SectionSortCache.java
+++ b/java/com/google/gerrit/server/permissions/SectionSortCache.java
@@ -17,6 +17,7 @@
import static com.google.common.collect.ImmutableList.toImmutableList;
import com.google.auto.value.AutoValue;
+import com.google.auto.value.extension.memoized.Memoized;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger;
@@ -126,22 +127,22 @@
public abstract List<String> patterns();
- public abstract int cachedHashCode();
-
static EntryKey create(String refName, List<AccessSection> sections) {
- int hc = refName.hashCode();
List<String> patterns = new ArrayList<>(sections.size());
for (AccessSection s : sections) {
- String n = s.getName();
- patterns.add(n);
- hc = hc * 31 + n.hashCode();
+ patterns.add(s.getName());
}
- return new AutoValue_SectionSortCache_EntryKey(refName, ImmutableList.copyOf(patterns), hc);
+ return new AutoValue_SectionSortCache_EntryKey(refName, ImmutableList.copyOf(patterns));
}
+ @Memoized
@Override
- public final int hashCode() {
- return cachedHashCode();
+ public int hashCode() {
+ int hc = ref().hashCode();
+ for (String n : patterns()) {
+ hc = hc * 31 + n.hashCode();
+ }
+ return hc;
}
}
diff --git a/java/com/google/gerrit/server/plugincontext/PluginContext.java b/java/com/google/gerrit/server/plugincontext/PluginContext.java
index 3c30745..a5fad56 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginContext.java
@@ -54,7 +54,7 @@
* <p>A plugin context can be manually opened by invoking the newTrace methods. This should only be
* needed if an extension throws multiple exceptions that need to be handled:
*
- * <pre>
+ * <pre>{@code
* public interface Foo {
* void doFoo() throws Exception1, Exception2, Exception3;
* }
@@ -66,7 +66,7 @@
* fooExtension.get().doFoo();
* }
* }
- * </pre>
+ * }</pre>
*
* <p>This class hosts static methods with generic functionality to invoke plugin extensions with a
* trace context that are commonly used by {@link PluginItemContext}, {@link PluginSetContext} and
@@ -121,11 +121,17 @@
@Inject
PluginMetrics(MetricMaker metricMaker) {
Field<String> pluginNameField =
- Field.ofString("plugin_name", Metadata.Builder::pluginName).build();
+ Field.ofString("plugin_name", Metadata.Builder::pluginName)
+ .description("The name of the plugin.")
+ .build();
Field<String> classNameField =
- Field.ofString("class_name", Metadata.Builder::className).build();
+ Field.ofString("class_name", Metadata.Builder::className)
+ .description("The class of the plugin that was invoked.")
+ .build();
Field<String> exportValueField =
- Field.ofString("export_value", Metadata.Builder::exportValue).build();
+ Field.ofString("export_value", Metadata.Builder::exportValue)
+ .description("The export name under which the invoked class is registered.")
+ .build();
this.latency =
metricMaker.newTimer(
diff --git a/java/com/google/gerrit/server/plugincontext/PluginItemContext.java b/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
index 421b3ad..e88a6fe 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
@@ -40,46 +40,46 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginItemContext.run(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginItemContext.run(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginItemContext.call(foo -> foo.getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginItemContext.call(foo -> foo.getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* try (TraceContext traceContext = PluginContext.newTrace(fooDynamicItem.getEntry())) {
* fooDynamicItem.get().doFoo();
* } catch (MyException1 | MyException2 | MyException3 e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*/
public class PluginItemContext<T> {
@Nullable private final DynamicItem<T> dynamicItem;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginMapContext.java b/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
index b02ad27..fb50cd5 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
@@ -33,15 +33,15 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* fooPluginMapContext.runEach(
* extension -> results.put(extension.getExportName(), extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* fooPluginMapContext.runEach(
@@ -50,22 +50,22 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* for (PluginMapEntryContext<Foo> c : fooPluginMapContext) {
* if (c.call(extension -> extension.get().handles(x))) {
* c.run(extension -> results.put(extension.getExportName(), extension.get().getFoo());
* }
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* for (PluginMapEntryContext<Foo> c : fooPluginMapContext) {
@@ -77,11 +77,11 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicMap) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -89,7 +89,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginMapContext<T> implements Iterable<PluginMapEntryContext<T>> {
private final DynamicMap<T> dynamicMap;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java b/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
index 68589cf..27181cb 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
@@ -35,15 +35,15 @@
*
* <p>The call* methods execute the extension and deliver a result back to the caller.
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* fooPluginMapEntryContext.run(
* extension -> results.put(extension.getExportName(), extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* fooPluginMapEntryContext.run(
@@ -52,28 +52,28 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginMapEntryContext.call(extension -> extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginMapEntryContext.call(extension -> extension.get().getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicMap) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -81,7 +81,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginMapEntryContext<T> {
private final Extension<T> extension;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginSetContext.java b/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
index b64cfeb..43c9552 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
@@ -34,33 +34,33 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginSetContext.runEach(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginSetContext.runEach(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* for (PluginSetEntryContext<Foo> c : fooPluginSetContext) {
* if (c.call(foo -> foo.handles(x))) {
* c.run(foo -> foo.doFoo());
* }
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* try {
* for (PluginSetEntryContext<Foo> c : fooPluginSetContext) {
* if (c.call(foo -> foo.handles(x), MyException.class)) {
@@ -70,11 +70,11 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicSet.entries()) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -82,7 +82,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginSetContext<T> implements Iterable<PluginSetEntryContext<T>> {
private final DynamicSet<T> dynamicSet;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
index 2268c07..be97b52 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
@@ -37,40 +37,40 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginSetEntryContext.run(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginSetEntryContext.run(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginSetEntryContext.call(foo -> foo.getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginSetEntryContext.call(foo -> foo.getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicSet.entries()) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -78,7 +78,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginSetEntryContext<T> {
private final Extension<T> extension;
diff --git a/java/com/google/gerrit/server/project/ProjectCache.java b/java/com/google/gerrit/server/project/ProjectCache.java
index cd41ce5..fee7105 100644
--- a/java/com/google/gerrit/server/project/ProjectCache.java
+++ b/java/com/google/gerrit/server/project/ProjectCache.java
@@ -42,10 +42,10 @@
return () -> new NoSuchProjectException(nameKey);
}
- /** @return the parent state for all projects on this server. */
+ /** Returns the parent state for all projects on this server. */
ProjectState getAllProjects();
- /** @return the project state of the project storing meta data for all users. */
+ /** Returns the project state of the project storing meta data for all users. */
ProjectState getAllUsers();
/**
@@ -84,12 +84,12 @@
*/
void remove(Project.NameKey name);
- /** @return sorted iteration of projects. */
+ /** Returns sorted iteration of projects. */
ImmutableSortedSet<Project.NameKey> all();
/**
- * @return estimated set of relevant groups extracted from hot project access rules. If the cache
- * is cold or too small for the entire project set of the server, this set may be incomplete.
+ * Returns estimated set of relevant groups extracted from hot project access rules. If the cache
+ * is cold or too small for the entire project set of the server, this set may be incomplete.
*/
Set<AccountGroup.UUID> guessRelevantGroupUUIDs();
diff --git a/java/com/google/gerrit/server/project/ProjectCacheImpl.java b/java/com/google/gerrit/server/project/ProjectCacheImpl.java
index 2874a34..de27afa 100644
--- a/java/com/google/gerrit/server/project/ProjectCacheImpl.java
+++ b/java/com/google/gerrit/server/project/ProjectCacheImpl.java
@@ -345,9 +345,16 @@
refreshCounter =
metricMaker.newCounter(
"caches/refresh_count",
- new Description("count").setRate(),
- Field.ofString("cache", Metadata.Builder::className).build(),
- Field.ofBoolean("outdated", Metadata.Builder::outdated).build());
+ new Description(
+ "The number of refreshes per cache with an indicator if a reload was"
+ + " necessary.")
+ .setRate(),
+ Field.ofString("cache", Metadata.Builder::className)
+ .description("The name of the cache.")
+ .build(),
+ Field.ofBoolean("outdated", Metadata.Builder::outdated)
+ .description("Whether the cache entry was outdated on reload.")
+ .build());
this.allProjectsName = allProjectsName;
this.allProjectsConfigProvider = allProjectsConfigProvider;
}
diff --git a/java/com/google/gerrit/server/project/ProjectConfig.java b/java/com/google/gerrit/server/project/ProjectConfig.java
index a23bb39..513aeed 100644
--- a/java/com/google/gerrit/server/project/ProjectConfig.java
+++ b/java/com/google/gerrit/server/project/ProjectConfig.java
@@ -560,32 +560,32 @@
groupList.renameGroup(uuid, newName);
}
- /** @return the group reference, if the group is used by at least one rule. */
+ /** Returns the group reference, if the group is used by at least one rule. */
public GroupReference getGroup(AccountGroup.UUID uuid) {
return groupList.byUUID(uuid);
}
/**
- * @return the group reference corresponding to the specified group name if the group is used by
- * at least one rule or plugin value.
+ * Returns the group reference corresponding to the specified group name if the group is used by
+ * at least one rule or plugin value.
*/
public GroupReference getGroup(String groupName) {
return groupList.byName(groupName);
}
/**
- * @return the project's rules.pl ObjectId, if present in the branch. Null if it doesn't exist.
+ * Returns the project's rules.pl ObjectId, if present in the branch. Null if it doesn't exist.
*/
public ObjectId getRulesId() {
return rulesId;
}
- /** @return the maxObjectSizeLimit configured on this project, or zero if not configured. */
+ /** Returns the maxObjectSizeLimit configured on this project, or zero if not configured. */
public long getMaxObjectSizeLimit() {
return maxObjectSizeLimit;
}
- /** @return the checkReceivedObjects for this project, default is true. */
+ /** Returns the checkReceivedObjects for this project, default is true. */
public boolean getCheckReceivedObjects() {
return checkReceivedObjects;
}
diff --git a/java/com/google/gerrit/server/project/ProjectState.java b/java/com/google/gerrit/server/project/ProjectState.java
index 4569027..69e6036 100644
--- a/java/com/google/gerrit/server/project/ProjectState.java
+++ b/java/com/google/gerrit/server/project/ProjectState.java
@@ -138,8 +138,8 @@
}
/**
- * @return cached computation of all global capabilities. This should only be invoked on the state
- * from {@link ProjectCache#getAllProjects()}. Null on any other project.
+ * Returns cached computation of all global capabilities. This should only be invoked on the state
+ * from {@link ProjectCache#getAllProjects()}. Null on any other project.
*/
public CapabilityCollection getCapabilityCollection() {
return capabilities;
@@ -316,9 +316,9 @@
}
/**
- * @return all {@link AccountGroup}'s to which the owner privilege for 'refs/*' is assigned for
- * this project (the local owners), if there are no local owners the local owners of the
- * nearest parent project that has local owners are returned
+ * Returns all {@link AccountGroup}'s to which the owner privilege for 'refs/*' is assigned for
+ * this project (the local owners), if there are no local owners the local owners of the nearest
+ * parent project that has local owners are returned
*/
public Set<AccountGroup.UUID> getOwners() {
for (ProjectState p : tree()) {
@@ -330,10 +330,10 @@
}
/**
- * @return all {@link AccountGroup}'s that are allowed to administrate the complete project. This
- * includes all groups to which the owner privilege for 'refs/*' is assigned for this project
- * (the local owners) and all groups to which the owner privilege for 'refs/*' is assigned for
- * one of the parent projects (the inherited owners).
+ * Returns all {@link AccountGroup}'s that are allowed to administrate the complete project. This
+ * includes all groups to which the owner privilege for 'refs/*' is assigned for this project (the
+ * local owners) and all groups to which the owner privilege for 'refs/*' is assigned for one of
+ * the parent projects (the inherited owners).
*/
public Set<AccountGroup.UUID> getAllOwners() {
Set<AccountGroup.UUID> result = new HashSet<>();
@@ -346,16 +346,16 @@
}
/**
- * @return an iterable that walks through this project and then the parents of this project.
- * Starts from this project and progresses up the hierarchy to All-Projects.
+ * Returns an iterable that walks through this project and then the parents of this project.
+ * Starts from this project and progresses up the hierarchy to All-Projects.
*/
public Iterable<ProjectState> tree() {
return () -> new ProjectHierarchyIterator(projectCache, allProjectsName, ProjectState.this);
}
/**
- * @return an iterable that walks in-order from All-Projects through the project hierarchy to this
- * project.
+ * Returns an iterable that walks in-order from All-Projects through the project hierarchy to this
+ * project.
*/
public Iterable<ProjectState> treeInOrder() {
List<ProjectState> projects = Lists.newArrayList(tree());
@@ -364,8 +364,8 @@
}
/**
- * @return an iterable that walks through the parents of this project. Starts from the immediate
- * parent of this project and progresses up the hierarchy to All-Projects.
+ * Returns an iterable that walks through the parents of this project. Starts from the immediate
+ * parent of this project and progresses up the hierarchy to All-Projects.
*/
public FluentIterable<ProjectState> parents() {
return FluentIterable.from(tree()).skip(1);
diff --git a/java/com/google/gerrit/server/project/Reachable.java b/java/com/google/gerrit/server/project/Reachable.java
index 2adebe7..342c2bc 100644
--- a/java/com/google/gerrit/server/project/Reachable.java
+++ b/java/com/google/gerrit/server/project/Reachable.java
@@ -55,9 +55,9 @@
}
/**
- * @return true if a commit is reachable from a given set of refs. This method enforces
- * permissions on the given set of refs and performs a reachability check. Tags are not
- * filtered separately and will only be returned if reachable by a provided ref.
+ * Returns true if a commit is reachable from a given set of refs. This method enforces
+ * permissions on the given set of refs and performs a reachability check. Tags are not filtered
+ * separately and will only be returned if reachable by a provided ref.
*/
public boolean fromRefs(
Project.NameKey project, Repository repo, RevCommit commit, List<Ref> refs) {
diff --git a/java/com/google/gerrit/server/project/RefResource.java b/java/com/google/gerrit/server/project/RefResource.java
index ac2735d..fcf6048 100644
--- a/java/com/google/gerrit/server/project/RefResource.java
+++ b/java/com/google/gerrit/server/project/RefResource.java
@@ -22,9 +22,9 @@
super(projectState, user);
}
- /** @return the ref's name */
+ /** Returns the ref's name */
public abstract String getRef();
- /** @return the ref's revision */
+ /** Returns the ref's revision */
public abstract String getRevision();
}
diff --git a/java/com/google/gerrit/server/project/RemoveReviewerControl.java b/java/com/google/gerrit/server/project/RemoveReviewerControl.java
index 652c49f..0336e8e 100644
--- a/java/com/google/gerrit/server/project/RemoveReviewerControl.java
+++ b/java/com/google/gerrit/server/project/RemoveReviewerControl.java
@@ -62,7 +62,7 @@
checkRemoveReviewer(notes, currentUser, reviewer, 0);
}
- /** @return true if the user is allowed to remove this reviewer. */
+ /** Returns true if the user is allowed to remove this reviewer. */
public boolean testRemoveReviewer(
ChangeData cd, CurrentUser currentUser, Account.Id reviewer, int value)
throws PermissionBackendException {
diff --git a/java/com/google/gerrit/server/project/SubmitRequirementsAdapter.java b/java/com/google/gerrit/server/project/SubmitRequirementsAdapter.java
index 0383cdc..f028def 100644
--- a/java/com/google/gerrit/server/project/SubmitRequirementsAdapter.java
+++ b/java/com/google/gerrit/server/project/SubmitRequirementsAdapter.java
@@ -16,6 +16,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.MoreCollectors;
+import com.google.common.flogger.FluentLogger;
import com.google.gerrit.entities.LabelType;
import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.entities.SubmitRecord.Label;
@@ -24,6 +25,7 @@
import com.google.gerrit.entities.SubmitRequirementExpressionResult;
import com.google.gerrit.entities.SubmitRequirementExpressionResult.Status;
import com.google.gerrit.entities.SubmitRequirementResult;
+import com.google.gerrit.server.query.change.ChangeQueryBuilder;
import java.util.List;
import org.eclipse.jgit.lib.ObjectId;
@@ -32,14 +34,20 @@
* com.google.gerrit.entities.SubmitRequirementResult}s.
*/
public class SubmitRequirementsAdapter {
+ private static final FluentLogger logger = FluentLogger.forEnclosingClass();
+
private SubmitRequirementsAdapter() {}
public static List<SubmitRequirementResult> createResult(
SubmitRecord record, List<LabelType> labelTypes, ObjectId psCommitId) {
+ List<SubmitRequirementResult> results;
if (record.ruleName.equals("gerrit~DefaultSubmitRule")) {
- return createFromDefaultSubmitRecord(record.labels, labelTypes, psCommitId);
+ results = createFromDefaultSubmitRecord(record.labels, labelTypes, psCommitId);
+ } else {
+ results = createFromCustomSubmitRecord(record, psCommitId);
}
- return createFromCustomSubmitRecord(record, psCommitId);
+ logger.atFine().log("Converted submit record %s to submit requirements %s", record, results);
+ return results;
}
private static List<SubmitRequirementResult> createFromDefaultSubmitRecord(
@@ -106,7 +114,7 @@
.submittabilityExpressionResult(
createExpressionResult(
sr.submittabilityExpression(),
- mapStatus(record),
+ mapStatus(label),
ImmutableList.of(expressionString)))
.patchSetCommitId(psCommitId)
.build());
@@ -123,15 +131,18 @@
}
private static ImmutableList<String> toExpressionAtomList(LabelType lt) {
+ String ignoreSelfApproval =
+ lt.isIgnoreSelfApproval() ? ",user=" + ChangeQueryBuilder.ARG_ID_NON_UPLOADER : "";
switch (lt.getFunction()) {
case MAX_WITH_BLOCK:
return ImmutableList.of(
- String.format("label:%s=MAX", lt.getName()),
+ String.format("label:%s=MAX", lt.getName()) + ignoreSelfApproval,
String.format("-label:%s=MIN", lt.getName()));
case ANY_WITH_BLOCK:
return ImmutableList.of(String.format(String.format("-label:%s=MIN", lt.getName())));
case MAX_NO_BLOCK:
- return ImmutableList.of(String.format(String.format("label:%s=MAX", lt.getName())));
+ return ImmutableList.of(
+ String.format(String.format("label:%s=MAX", lt.getName())) + ignoreSelfApproval);
case NO_BLOCK:
case NO_OP:
case PATCH_SET_LOCK:
diff --git a/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java b/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java
index cb8b686..6c5559c 100644
--- a/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java
+++ b/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java
@@ -18,15 +18,19 @@
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
import com.google.common.collect.Streams;
+import com.google.common.flogger.FluentLogger;
import com.google.gerrit.entities.Change;
import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.entities.SubmitTypeRecord;
import com.google.gerrit.exceptions.StorageException;
+import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.metrics.Description;
import com.google.gerrit.metrics.Description.Units;
import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.metrics.Timer0;
+import com.google.gerrit.server.change.ChangeJson;
import com.google.gerrit.server.index.OnlineReindexMode;
+import com.google.gerrit.server.logging.CallerFinder;
import com.google.gerrit.server.plugincontext.PluginSetContext;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.rules.DefaultSubmitRule;
@@ -42,12 +46,15 @@
* the results through rules found in the parent projects, all the way up to All-Projects.
*/
public class SubmitRuleEvaluator {
+ private static final FluentLogger logger = FluentLogger.forEnclosingClass();
+
private final ProjectCache projectCache;
private final PrologRule prologRule;
private final PluginSetContext<SubmitRule> submitRules;
private final Timer0 submitRuleEvaluationLatency;
private final Timer0 submitTypeEvaluationLatency;
private final SubmitRuleOptions opts;
+ private final CallerFinder callerFinder;
public interface Factory {
/** Returns a new {@link SubmitRuleEvaluator} with the specified options */
@@ -78,6 +85,14 @@
.setUnit(Units.MILLISECONDS));
this.opts = options;
+
+ this.callerFinder =
+ CallerFinder.builder()
+ .addTarget(ChangeApi.class)
+ .addTarget(ChangeJson.class)
+ .addTarget(ChangeData.class)
+ .addTarget(SubmitRequirementsEvaluatorImpl.class)
+ .build();
}
/**
@@ -88,6 +103,9 @@
* @param cd ChangeData to evaluate
*/
public List<SubmitRecord> evaluate(ChangeData cd) {
+ logger.atFine().log(
+ "Evaluate submit rules for change %d (caller: %s)",
+ cd.change().getId().get(), callerFinder.findCallerLazy());
try (Timer0.Context ignored = submitRuleEvaluationLatency.start()) {
Change change;
ProjectState projectState;
@@ -146,7 +164,6 @@
* Evaluate the submit type rules to get the submit type.
*
* @return record from the evaluated rules.
- * @param cd
*/
public SubmitTypeRecord getSubmitType(ChangeData cd) {
try (Timer0.Context ignored = submitTypeEvaluationLatency.start()) {
diff --git a/java/com/google/gerrit/server/query/approval/ApprovalContext.java b/java/com/google/gerrit/server/query/approval/ApprovalContext.java
index 3bf072a..4dedbb5 100644
--- a/java/com/google/gerrit/server/query/approval/ApprovalContext.java
+++ b/java/com/google/gerrit/server/query/approval/ApprovalContext.java
@@ -28,8 +28,12 @@
/** Approval on the source patch set to be copied. */
public abstract PatchSetApproval patchSetApproval();
- /** Target change and patch set for the approval. */
- public abstract PatchSet.Id target();
+ /**
+ * Target change and patch set for the approval. This must be used instead of getting the PatchSet
+ * from {@link #changeNotes()} because it is possible we are now creating the patch-set, so it
+ * doesn't exist in changeNotes yet.
+ */
+ public abstract PatchSet target();
/** {@link ChangeNotes} of the change in question. */
public abstract ChangeNotes changeNotes();
@@ -38,18 +42,18 @@
public abstract ChangeKind changeKind();
public static ApprovalContext create(
- ChangeNotes changeNotes, PatchSetApproval psa, PatchSet.Id id, ChangeKind changeKind) {
+ ChangeNotes changeNotes, PatchSetApproval psa, PatchSet patchSet, ChangeKind changeKind) {
checkState(
- psa.patchSetId().changeId().equals(id.changeId()),
+ psa.patchSetId().changeId().equals(patchSet.id().changeId()),
"approval and target must be the same change. got: %s, %s",
psa.patchSetId(),
- id);
+ patchSet.id());
// TODO(ekempin): Use checkState to verify that psa.patchSetId().get() + 1 == id.get() so that
// it's ensured that approvals are only copied to the next consecutive patch set. To add back
// this verification https://gerrit-review.googlesource.com/c/gerrit/+/312633 can be reverted.
// As explained in the commit message of this change doing this check is only possible if there
// are no changes with gaps in patch set numbers. Since it's planned to fix-up old changes with
// gaps in patch set numbers, this todo is a reminder to add back the check once this is done.
- return new AutoValue_ApprovalContext(psa, id, changeNotes, changeKind);
+ return new AutoValue_ApprovalContext(psa, patchSet, changeNotes, changeKind);
}
}
diff --git a/java/com/google/gerrit/server/query/approval/ListOfFilesUnchangedPredicate.java b/java/com/google/gerrit/server/query/approval/ListOfFilesUnchangedPredicate.java
index ec658ac..55c27be 100644
--- a/java/com/google/gerrit/server/query/approval/ListOfFilesUnchangedPredicate.java
+++ b/java/com/google/gerrit/server/query/approval/ListOfFilesUnchangedPredicate.java
@@ -14,6 +14,7 @@
package com.google.gerrit.server.query.approval;
+import com.google.gerrit.entities.Patch;
import com.google.gerrit.entities.Patch.ChangeType;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Project;
@@ -27,8 +28,10 @@
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevWalk;
@@ -48,7 +51,7 @@
@Override
public boolean match(ApprovalContext ctx) {
- PatchSet targetPatchSet = ctx.changeNotes().getPatchSets().get(ctx.target());
+ PatchSet targetPatchSet = ctx.target();
PatchSet sourcePatchSet =
ctx.changeNotes().getPatchSets().get(ctx.patchSetApproval().patchSetId());
@@ -77,13 +80,16 @@
*/
public boolean match(
Map<String, FileDiffOutput> modifiedFiles1, Map<String, FileDiffOutput> modifiedFiles2) {
- if (modifiedFiles1.size() != modifiedFiles2.size()) {
- return false;
- }
- for (String file : modifiedFiles1.keySet()) {
+ Set<String> allFiles = new HashSet<>();
+ allFiles.addAll(modifiedFiles1.keySet());
+ allFiles.addAll(modifiedFiles2.keySet());
+ for (String file : allFiles) {
+ if (Patch.isMagic(file)) {
+ continue;
+ }
FileDiffOutput fileDiffOutput1 = modifiedFiles1.get(file);
FileDiffOutput fileDiffOutput2 = modifiedFiles2.get(file);
- if (fileDiffOutput2 == null) {
+ if (fileDiffOutput1 == null || fileDiffOutput2 == null) {
return false;
}
if (!fileDiffOutput2.changeType().equals(fileDiffOutput1.changeType())) {
diff --git a/java/com/google/gerrit/server/query/approval/UserInPredicate.java b/java/com/google/gerrit/server/query/approval/UserInPredicate.java
index 7e16fcb..ac6720d 100644
--- a/java/com/google/gerrit/server/query/approval/UserInPredicate.java
+++ b/java/com/google/gerrit/server/query/approval/UserInPredicate.java
@@ -39,7 +39,7 @@
public boolean match(ApprovalContext ctx) {
Account.Id accountId;
if (field == Field.UPLOADER) {
- PatchSet patchSet = ctx.changeNotes().getPatchSets().get(ctx.target());
+ PatchSet patchSet = ctx.target();
accountId = patchSet.uploader();
} else if (field == Field.APPROVER) {
accountId = ctx.patchSetApproval().accountId();
diff --git a/java/com/google/gerrit/server/query/change/ChangeData.java b/java/com/google/gerrit/server/query/change/ChangeData.java
index 5b83dd5..c551cd2 100644
--- a/java/com/google/gerrit/server/query/change/ChangeData.java
+++ b/java/com/google/gerrit/server/query/change/ChangeData.java
@@ -728,7 +728,7 @@
this.attentionSet = attentionSet;
}
- /** @return patches for the change, in patch set ID order. */
+ /** Returns patches for the change, in patch set ID order. */
public Collection<PatchSet> patchSets() {
if (patchSets == null) {
patchSets = psUtil.byChange(notes());
@@ -741,7 +741,7 @@
this.patchSets = patchSets;
}
- /** @return patch with the given ID, or null if it does not exist. */
+ /** Returns patch with the given ID, or null if it does not exist. */
public PatchSet patchSet(PatchSet.Id psId) {
if (currentPatchSet != null && currentPatchSet.id().equals(psId)) {
return currentPatchSet;
@@ -755,8 +755,8 @@
}
/**
- * @return all patch set approvals for the change, keyed by ID, ordered by timestamp within each
- * patch set.
+ * Returns all patch set approvals for the change, keyed by ID, ordered by timestamp within each
+ * patch set.
*/
public ListMultimap<PatchSet.Id, PatchSetApproval> approvals() {
if (allApprovals == null) {
@@ -1199,8 +1199,8 @@
}
/**
- * @return {@code null} if {@code revertOf} is {@code null}; true if the change is a pure revert;
- * false otherwise.
+ * Returns {@code null} if {@code revertOf} is {@code null}; true if the change is a pure revert;
+ * false otherwise.
*/
@Nullable
public Boolean isPureRevert() {
@@ -1347,14 +1347,7 @@
draftsByUser = new HashMap<>();
for (Ref ref : commentsUtil.getDraftRefs(notes().getChangeId())) {
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
- if (account != null
- // Double-check that any drafts exist for this user after
- // filtering out zombies. If some but not all drafts in the ref
- // were zombies, the returned Ref still includes those zombies;
- // this is suboptimal, but is ok for the purposes of
- // draftsByUser(), and easier than trying to rebuild the change at
- // this point.
- && !notes().getDraftComments(account, ref).isEmpty()) {
+ if (account != null) {
draftsByUser.put(account, ref.getObjectId());
}
}
diff --git a/java/com/google/gerrit/server/query/change/ChangeDataSource.java b/java/com/google/gerrit/server/query/change/ChangeDataSource.java
index 34579a9..26ce46c 100644
--- a/java/com/google/gerrit/server/query/change/ChangeDataSource.java
+++ b/java/com/google/gerrit/server/query/change/ChangeDataSource.java
@@ -17,6 +17,6 @@
import com.google.gerrit.index.query.DataSource;
public interface ChangeDataSource extends DataSource<ChangeData> {
- /** @return true if all returned ChangeData.hasChange() will be true. */
+ /** Returns true if all returned ChangeData.hasChange() will be true. */
boolean hasChange();
}
diff --git a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
index 8525eb4..f1fe520 100644
--- a/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
+++ b/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java
@@ -142,6 +142,7 @@
public static final String FIELD_ADDED = "added";
public static final String FIELD_AGE = "age";
public static final String FIELD_ATTENTION_SET_USERS = "attentionusers";
+ public static final String FIELD_ATTENTION_SET_USERS_COUNT = "attentionuserscount";
public static final String FIELD_ATTENTION_SET_FULL = "attentionfull";
public static final String FIELD_ASSIGNEE = "assignee";
public static final String FIELD_AUTHOR = "author";
@@ -614,6 +615,14 @@
return ChangePredicates.editBy(self());
}
+ if ("attention".equalsIgnoreCase(value)) {
+ if (!args.index.getSchema().hasField(ChangeField.ATTENTION_SET_USERS)) {
+ throw new QueryParseException(
+ "'has:attention' operator is not supported by change index version");
+ }
+ return new IsAttentionPredicate();
+ }
+
if ("unresolved".equalsIgnoreCase(value)) {
return new IsUnresolvedPredicate();
}
@@ -687,6 +696,14 @@
"'is:private' operator is not supported by change index version");
}
+ if ("attention".equalsIgnoreCase(value)) {
+ if (!args.index.getSchema().hasField(ChangeField.ATTENTION_SET_USERS)) {
+ throw new QueryParseException(
+ "'is:attention' operator is not supported by change index version");
+ }
+ return new IsAttentionPredicate();
+ }
+
if ("assigned".equalsIgnoreCase(value)) {
return Predicate.not(ChangePredicates.assignee(Account.id(ChangeField.NO_ASSIGNEE)));
}
diff --git a/java/com/google/gerrit/server/query/change/IsAttentionPredicate.java b/java/com/google/gerrit/server/query/change/IsAttentionPredicate.java
new file mode 100644
index 0000000..d20d64a
--- /dev/null
+++ b/java/com/google/gerrit/server/query/change/IsAttentionPredicate.java
@@ -0,0 +1,33 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gerrit.server.query.change;
+
+import com.google.gerrit.index.query.QueryParseException;
+import com.google.gerrit.server.index.change.ChangeField;
+
+public class IsAttentionPredicate extends IntegerRangeChangePredicate {
+ public IsAttentionPredicate() throws QueryParseException {
+ this(">0");
+ }
+
+ public IsAttentionPredicate(String value) throws QueryParseException {
+ super(ChangeField.ATTENTION_SET_USERS_COUNT, value);
+ }
+
+ @Override
+ protected Integer getValueInt(ChangeData changeData) {
+ return ChangeField.ATTENTION_SET_USERS_COUNT.get(changeData);
+ }
+}
diff --git a/java/com/google/gerrit/server/query/change/LabelPredicate.java b/java/com/google/gerrit/server/query/change/LabelPredicate.java
index 989b4bb..5f017fb 100644
--- a/java/com/google/gerrit/server/query/change/LabelPredicate.java
+++ b/java/com/google/gerrit/server/query/change/LabelPredicate.java
@@ -87,7 +87,7 @@
try {
MagicLabelVote mlv = MagicLabelVote.parseWithEquals(v);
- return ImmutableList.of(new MagicLabelPredicate(args, mlv));
+ return ImmutableList.of(magicLabelPredicate(args, mlv));
} catch (IllegalArgumentException e) {
// Try next format.
}
@@ -157,6 +157,17 @@
return or(r);
}
+ protected static Predicate<ChangeData> magicLabelPredicate(Args args, MagicLabelVote mlv) {
+ if (args.accounts == null || args.accounts.isEmpty()) {
+ return new MagicLabelPredicate(args, mlv, /* account= */ null);
+ }
+ List<Predicate<ChangeData>> r = new ArrayList<>();
+ for (Account.Id a : args.accounts) {
+ r.add(new MagicLabelPredicate(args, mlv, a));
+ }
+ return or(r);
+ }
+
@Override
public String toString() {
return ChangeQueryBuilder.FIELD_LABEL + ":" + value;
diff --git a/java/com/google/gerrit/server/query/change/MagicLabelPredicate.java b/java/com/google/gerrit/server/query/change/MagicLabelPredicate.java
index 2c56322..3917c79 100644
--- a/java/com/google/gerrit/server/query/change/MagicLabelPredicate.java
+++ b/java/com/google/gerrit/server/query/change/MagicLabelPredicate.java
@@ -14,6 +14,7 @@
package com.google.gerrit.server.query.change;
+import com.google.gerrit.entities.Account;
import com.google.gerrit.entities.Change;
import com.google.gerrit.entities.LabelType;
import com.google.gerrit.entities.LabelTypes;
@@ -28,9 +29,12 @@
public class MagicLabelPredicate extends ChangeIndexPredicate {
protected final LabelPredicate.Args args;
private final MagicLabelVote magicLabelVote;
+ private final Account.Id account;
- public MagicLabelPredicate(LabelPredicate.Args args, MagicLabelVote magicLabelVote) {
+ public MagicLabelPredicate(
+ LabelPredicate.Args args, MagicLabelVote magicLabelVote, Account.Id account) {
super(ChangeField.LABEL, magicLabelVote.formatLabel());
+ this.account = account;
this.args = args;
this.magicLabelVote = magicLabelVote;
}
@@ -83,7 +87,7 @@
}
private EqualsLabelPredicate numericPredicate(String label, short value) {
- return new EqualsLabelPredicate(args, label, value, /* account= */ null);
+ return new EqualsLabelPredicate(args, label, value, account);
}
protected static LabelType type(LabelTypes types, String toFind) {
diff --git a/java/com/google/gerrit/server/query/change/PredicateArgs.java b/java/com/google/gerrit/server/query/change/PredicateArgs.java
index ad7917e..d82b9bc 100644
--- a/java/com/google/gerrit/server/query/change/PredicateArgs.java
+++ b/java/com/google/gerrit/server/query/change/PredicateArgs.java
@@ -40,7 +40,6 @@
* name]}.
*
* @param args arguments to be parsed
- * @throws QueryParseException
*/
PredicateArgs(String args) throws QueryParseException {
positional = new ArrayList<>();
diff --git a/java/com/google/gerrit/server/restapi/BUILD b/java/com/google/gerrit/server/restapi/BUILD
index 6d3e222..f70379b 100644
--- a/java/com/google/gerrit/server/restapi/BUILD
+++ b/java/com/google/gerrit/server/restapi/BUILD
@@ -33,6 +33,7 @@
"//lib/auto:auto-value-annotations",
"//lib/commons:compress",
"//lib/commons:lang",
+ "//lib/errorprone:annotations",
"//lib/flogger:api",
"//lib/guice",
"//lib/guice:guice-assistedinject",
diff --git a/java/com/google/gerrit/server/restapi/change/GetRelated.java b/java/com/google/gerrit/server/restapi/change/GetRelated.java
index ba1a1dc..0eef468 100644
--- a/java/com/google/gerrit/server/restapi/change/GetRelated.java
+++ b/java/com/google/gerrit/server/restapi/change/GetRelated.java
@@ -14,10 +14,6 @@
package com.google.gerrit.server.restapi.change;
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.stream.Collectors.toSet;
-
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable;
@@ -29,56 +25,39 @@
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
-import com.google.gerrit.index.IndexConfig;
import com.google.gerrit.server.ChangeUtil;
import com.google.gerrit.server.CommonConverters;
-import com.google.gerrit.server.PatchSetUtil;
+import com.google.gerrit.server.change.GetRelatedChangesUtil;
+import com.google.gerrit.server.change.RelatedChangesSorter;
import com.google.gerrit.server.change.RevisionResource;
-import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.query.change.ChangeData;
-import com.google.gerrit.server.query.change.InternalChangeQuery;
import com.google.inject.Inject;
-import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
-import java.util.Set;
-import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.revwalk.RevCommit;
@Singleton
public class GetRelated implements RestReadView<RevisionResource> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
- private final Provider<InternalChangeQuery> queryProvider;
- private final PatchSetUtil psUtil;
- private final RelatedChangesSorter sorter;
- private final IndexConfig indexConfig;
private final ChangeData.Factory changeDataFactory;
+ private final GetRelatedChangesUtil getRelatedChangesUtil;
@Inject
- GetRelated(
- Provider<InternalChangeQuery> queryProvider,
- PatchSetUtil psUtil,
- RelatedChangesSorter sorter,
- IndexConfig indexConfig,
- ChangeData.Factory changeDataFactory) {
- this.queryProvider = queryProvider;
- this.psUtil = psUtil;
- this.sorter = sorter;
- this.indexConfig = indexConfig;
+ GetRelated(ChangeData.Factory changeDataFactory, GetRelatedChangesUtil getRelatedChangesUtil) {
this.changeDataFactory = changeDataFactory;
+ this.getRelatedChangesUtil = getRelatedChangesUtil;
}
@Override
public Response<RelatedChangesInfo> apply(RevisionResource rsrc)
- throws RepositoryNotFoundException, IOException, NoSuchProjectException,
- PermissionBackendException {
+ throws IOException, NoSuchProjectException, PermissionBackendException {
RelatedChangesInfo relatedChangesInfo = new RelatedChangesInfo();
relatedChangesInfo.changes = getRelated(rsrc);
return Response.ok(relatedChangesInfo);
@@ -86,30 +65,15 @@
public List<RelatedChangeAndCommitInfo> getRelated(RevisionResource rsrc)
throws IOException, PermissionBackendException {
- Set<String> groups = getAllGroups(rsrc.getNotes(), psUtil);
- logger.atFine().log("groups = %s", groups);
- if (groups.isEmpty()) {
- return Collections.emptyList();
- }
-
- List<ChangeData> cds =
- InternalChangeQuery.byProjectGroups(
- queryProvider, indexConfig, rsrc.getChange().getProject(), groups);
- if (cds.isEmpty()) {
- return Collections.emptyList();
- }
- if (cds.size() == 1 && cds.get(0).getId().equals(rsrc.getChange().getId())) {
- return Collections.emptyList();
- }
- List<RelatedChangeAndCommitInfo> result = new ArrayList<>(cds.size());
-
boolean isEdit = rsrc.getEdit().isPresent();
PatchSet basePs = isEdit ? rsrc.getEdit().get().getBasePatchSet() : rsrc.getPatchSet();
logger.atFine().log("isEdit = %s, basePs = %s", isEdit, basePs);
- cds = reloadChangeIfStale(cds, rsrc.getChange(), basePs);
+ List<RelatedChangesSorter.PatchSetData> sortedResult =
+ getRelatedChangesUtil.getRelated(changeDataFactory.create(rsrc.getNotes()), basePs);
- for (RelatedChangesSorter.PatchSetData d : sorter.sort(cds, basePs)) {
+ List<RelatedChangeAndCommitInfo> result = new ArrayList<>(sortedResult.size());
+ for (RelatedChangesSorter.PatchSetData d : sortedResult) {
PatchSet ps = d.patchSet();
RevCommit commit;
if (isEdit && ps.id().equals(basePs.id())) {
@@ -134,37 +98,6 @@
return result;
}
- @VisibleForTesting
- public static Set<String> getAllGroups(ChangeNotes notes, PatchSetUtil psUtil) {
- return psUtil.byChange(notes).stream().flatMap(ps -> ps.groups().stream()).collect(toSet());
- }
-
- private List<ChangeData> reloadChangeIfStale(
- List<ChangeData> changeDatasFromIndex, Change wantedChange, PatchSet wantedPs) {
- checkArgument(
- wantedChange.getId().equals(wantedPs.id().changeId()),
- "change of wantedPs (%s) doesn't match wantedChange (%s)",
- wantedPs.id().changeId(),
- wantedChange.getId());
-
- List<ChangeData> changeDatas = new ArrayList<>(changeDatasFromIndex.size() + 1);
- changeDatas.addAll(changeDatasFromIndex);
-
- // Reload the change in case the patch set is absent.
- changeDatas.stream()
- .filter(
- cd -> cd.getId().equals(wantedPs.id().changeId()) && cd.patchSet(wantedPs.id()) == null)
- .forEach(ChangeData::reloadChange);
-
- if (changeDatas.stream().noneMatch(cd -> cd.getId().equals(wantedPs.id().changeId()))) {
- // The change of the wanted patch set is missing in the result from the index.
- // Load it from NoteDb and add it to the result.
- changeDatas.add(changeDataFactory.create(wantedChange));
- }
-
- return changeDatas;
- }
-
static RelatedChangeAndCommitInfo newChangeAndCommit(
Project.NameKey project, @Nullable Change change, @Nullable PatchSet ps, RevCommit c) {
RelatedChangeAndCommitInfo info = new RelatedChangeAndCommitInfo();
diff --git a/java/com/google/gerrit/server/restapi/change/PostReview.java b/java/com/google/gerrit/server/restapi/change/PostReview.java
index 4dbb6ee..5c252f4 100644
--- a/java/com/google/gerrit/server/restapi/change/PostReview.java
+++ b/java/com/google/gerrit/server/restapi/change/PostReview.java
@@ -80,6 +80,10 @@
import com.google.gerrit.extensions.validators.CommentValidationContext;
import com.google.gerrit.extensions.validators.CommentValidationFailure;
import com.google.gerrit.extensions.validators.CommentValidator;
+import com.google.gerrit.metrics.Counter1;
+import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
+import com.google.gerrit.metrics.MetricMaker;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.ChangeUtil;
import com.google.gerrit.server.CommentsUtil;
@@ -88,7 +92,9 @@
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.PublishCommentUtil;
import com.google.gerrit.server.ReviewerSet;
+import com.google.gerrit.server.account.AccountCache;
import com.google.gerrit.server.account.AccountResolver;
+import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.approval.ApprovalsUtil;
import com.google.gerrit.server.change.ChangeResource;
import com.google.gerrit.server.change.EmailReviewComments;
@@ -101,6 +107,7 @@
import com.google.gerrit.server.change.WorkInProgressOp;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.extensions.events.CommentAdded;
+import com.google.gerrit.server.extensions.events.ReviewerAdded;
import com.google.gerrit.server.logging.Metadata;
import com.google.gerrit.server.logging.TraceContext;
import com.google.gerrit.server.notedb.ChangeNotes;
@@ -151,6 +158,29 @@
public class PostReview implements RestModifyView<RevisionResource, ReviewInput> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
+ @Singleton
+ private static class Metrics {
+ final Counter1<String> draftHandling;
+
+ @Inject
+ Metrics(MetricMaker metricMaker) {
+ draftHandling =
+ metricMaker.newCounter(
+ "change/post_review/draft_handling",
+ new Description(
+ "Total number of draft handling option "
+ + "(KEEP, PUBLISH, PUBLISH_ALL_REVISIONS) "
+ + "selected by users while posting a review.")
+ .setRate()
+ .setUnit("count"),
+ Field.ofString("type", Metadata.Builder::eventType)
+ .description(
+ "The type of the draft handling option"
+ + " (KEEP, PUBLISH, PUBLISH_ALL_REVISIONS).")
+ .build());
+ }
+ }
+
private static final String ERROR_ADDING_REVIEWER = "error adding reviewer";
public static final String ERROR_WIP_READY_MUTUALLY_EXCLUSIVE =
"work_in_progress and ready are mutually exclusive";
@@ -160,6 +190,7 @@
private final BatchUpdate.Factory updateFactory;
private final ChangeResource.Factory changeResourceFactory;
private final ChangeData.Factory changeDataFactory;
+ private final AccountCache accountCache;
private final ApprovalsUtil approvalsUtil;
private final ChangeMessagesUtil cmUtil;
private final CommentsUtil commentsUtil;
@@ -170,6 +201,7 @@
private final EmailReviewComments.Factory email;
private final CommentAdded commentAdded;
private final ReviewerModifier reviewerModifier;
+ private final Metrics metrics;
private final ModifyReviewersEmail modifyReviewersEmail;
private final NotifyResolver notifyResolver;
private final WorkInProgressOp.Factory workInProgressOpFactory;
@@ -178,6 +210,7 @@
private final PluginSetContext<CommentValidator> commentValidators;
private final PluginSetContext<OnPostReview> onPostReviews;
private final ReplyAttentionSetUpdates replyAttentionSetUpdates;
+ private final ReviewerAdded reviewerAdded;
private final boolean strictLabels;
private final boolean publishPatchSetLevelComment;
@@ -186,6 +219,7 @@
BatchUpdate.Factory updateFactory,
ChangeResource.Factory changeResourceFactory,
ChangeData.Factory changeDataFactory,
+ AccountCache accountCache,
ApprovalsUtil approvalsUtil,
ChangeMessagesUtil cmUtil,
CommentsUtil commentsUtil,
@@ -196,6 +230,7 @@
EmailReviewComments.Factory email,
CommentAdded commentAdded,
ReviewerModifier reviewerModifier,
+ Metrics metrics,
ModifyReviewersEmail modifyReviewersEmail,
NotifyResolver notifyResolver,
@GerritServerConfig Config gerritConfig,
@@ -204,10 +239,12 @@
PermissionBackend permissionBackend,
PluginSetContext<CommentValidator> commentValidators,
PluginSetContext<OnPostReview> onPostReviews,
- ReplyAttentionSetUpdates replyAttentionSetUpdates) {
+ ReplyAttentionSetUpdates replyAttentionSetUpdates,
+ ReviewerAdded reviewerAdded) {
this.updateFactory = updateFactory;
this.changeResourceFactory = changeResourceFactory;
this.changeDataFactory = changeDataFactory;
+ this.accountCache = accountCache;
this.commentsUtil = commentsUtil;
this.publishCommentUtil = publishCommentUtil;
this.psUtil = psUtil;
@@ -218,6 +255,7 @@
this.email = email;
this.commentAdded = commentAdded;
this.reviewerModifier = reviewerModifier;
+ this.metrics = metrics;
this.modifyReviewersEmail = modifyReviewersEmail;
this.notifyResolver = notifyResolver;
this.workInProgressOpFactory = workInProgressOpFactory;
@@ -226,6 +264,7 @@
this.commentValidators = commentValidators;
this.onPostReviews = onPostReviews;
this.replyAttentionSetUpdates = replyAttentionSetUpdates;
+ this.reviewerAdded = reviewerAdded;
this.strictLabels = gerritConfig.getBoolean("change", "strictLabels", false);
this.publishPatchSetLevelComment =
gerritConfig.getBoolean("event", "comment-added", "publishPatchSetLevelComment", true);
@@ -252,6 +291,7 @@
logger.atFine().log("strict label checking is %s", (strictLabels ? "enabled" : "disabled"));
+ metrics.draftHandling.increment(input.drafts == null ? "N/A" : input.drafts.name());
input.drafts = firstNonNull(input.drafts, DraftHandling.KEEP);
logger.atFine().log("draft handling = %s", input.drafts);
@@ -340,6 +380,7 @@
logger.atFine().log("adding reviewer additions");
for (ReviewerModification reviewerResult : reviewerResults) {
reviewerResult.op.suppressEmail(); // Send a single batch email below.
+ reviewerResult.op.suppressEvent(); // Send events below, if possible as batch.
bu.addOp(revision.getChange().getId(), reviewerResult.op);
if (!ccOrReviewer && reviewerResult.reviewers.contains(account)) {
logger.atFine().log("calling user is explicitly added as reviewer or CC");
@@ -355,6 +396,7 @@
ReviewerModification selfAddition =
reviewerModifier.ccCurrentUser(revision.getUser(), revision);
selfAddition.op.suppressEmail();
+ selfAddition.op.suppressEvent();
bu.addOp(revision.getChange().getId(), selfAddition.op);
}
@@ -402,8 +444,10 @@
reviewerResult.gatherResults(cd);
}
- // Sending from AddReviewersOp was suppressed so we can send a single batch email here.
+ // Sending emails and events from ReviewersOps was suppressed so we can send a single batch
+ // email/event here.
batchEmailReviewers(revision.getUser(), revision.getChange(), reviewerResults, notify);
+ batchReviewerEvents(revision.getUser(), cd, revision.getPatchSet(), reviewerResults, ts);
}
return Response.ok(output);
@@ -481,6 +525,35 @@
}
}
+ private void batchReviewerEvents(
+ CurrentUser user,
+ ChangeData cd,
+ PatchSet patchSet,
+ List<ReviewerModification> reviewerModifications,
+ Timestamp when) {
+ List<AccountState> newlyAddedReviewers = new ArrayList<>();
+
+ // There are no events for CCs and reviewers added/deleted by email.
+ for (ReviewerModification modification : reviewerModifications) {
+ Result reviewerAdditionResult = modification.op.getResult();
+ if (modification.state() == ReviewerState.REVIEWER) {
+ newlyAddedReviewers.addAll(
+ reviewerAdditionResult.addedReviewers().stream()
+ .map(psa -> psa.accountId())
+ .map(accountId -> accountCache.get(accountId))
+ .flatMap(Streams::stream)
+ .collect(toList()));
+ } else if (modification.state() == ReviewerState.REMOVED) {
+ // There is no batch event for reviewer removals, hence fire the event for each
+ // modification that deleted a reviewer immediately.
+ modification.op.sendEvent();
+ }
+ }
+
+ // Fire a batch event for all newly added reviewers.
+ reviewerAdded.fire(cd, patchSet, newlyAddedReviewers, user.asIdentifiedUser().state(), when);
+ }
+
private RevisionResource onBehalfOf(RevisionResource rev, LabelTypes labelTypes, ReviewInput in)
throws BadRequestException, AuthException, UnprocessableEntityException,
PermissionBackendException, IOException, ConfigInvalidException {
diff --git a/java/com/google/gerrit/server/restapi/project/CheckAccess.java b/java/com/google/gerrit/server/restapi/project/CheckAccess.java
index 37616cd..5c2f932 100644
--- a/java/com/google/gerrit/server/restapi/project/CheckAccess.java
+++ b/java/com/google/gerrit/server/restapi/project/CheckAccess.java
@@ -95,7 +95,6 @@
} catch (AuthException e) {
return Response.ok(
createInfo(
- traceContext,
HttpServletResponse.SC_FORBIDDEN,
String.format("user %s cannot see project %s", match, rsrc.getName())));
}
@@ -126,7 +125,6 @@
} catch (AuthException e) {
return Response.ok(
createInfo(
- traceContext,
HttpServletResponse.SC_FORBIDDEN,
String.format(
"user %s lacks permission %s for %s in project %s",
@@ -141,15 +139,15 @@
}
}
}
- return Response.ok(createInfo(traceContext, HttpServletResponse.SC_OK, message));
+ return Response.ok(createInfo(HttpServletResponse.SC_OK, message));
}
}
- private AccessCheckInfo createInfo(TraceContext traceContext, int statusCode, String message) {
+ private AccessCheckInfo createInfo(int statusCode, String message) {
AccessCheckInfo info = new AccessCheckInfo();
info.status = statusCode;
info.message = message;
- info.debugLogs = traceContext.getAclLogRecords();
+ info.debugLogs = TraceContext.getAclLogRecords();
if (info.debugLogs.isEmpty()) {
info.debugLogs =
ImmutableList.of("Found no rules that apply, so defaulting to no permission");
diff --git a/java/com/google/gerrit/server/restapi/project/CommitsCollection.java b/java/com/google/gerrit/server/restapi/project/CommitsCollection.java
index ae7f540..09951b2 100644
--- a/java/com/google/gerrit/server/restapi/project/CommitsCollection.java
+++ b/java/com/google/gerrit/server/restapi/project/CommitsCollection.java
@@ -116,14 +116,14 @@
}
/**
- * @return true if {@code commit} is visible to the caller and {@code commit} is reachable from
- * the given branch.
+ * Returns true if {@code commit} is visible to the caller and {@code commit} is reachable from
+ * the given branch.
*/
public boolean canRead(ProjectState state, Repository repo, RevCommit commit, Ref ref) {
return reachable.fromRefs(state.getNameKey(), repo, commit, ImmutableList.of(ref));
}
- /** @return true if {@code commit} is visible to the caller. */
+ /** Returns true if {@code commit} is visible to the caller. */
public boolean canRead(ProjectState state, Repository repo, RevCommit commit) throws IOException {
Project.NameKey project = state.getNameKey();
if (indexes.getSearchIndex() == null) {
diff --git a/java/com/google/gerrit/server/restapi/project/DeleteRef.java b/java/com/google/gerrit/server/restapi/project/DeleteRef.java
index 4e13ba9..60405a6 100644
--- a/java/com/google/gerrit/server/restapi/project/DeleteRef.java
+++ b/java/com/google/gerrit/server/restapi/project/DeleteRef.java
@@ -86,8 +86,6 @@
*
* @param projectState the {@code ProjectState} of the project containing the target ref.
* @param ref the ref to be deleted.
- * @throws IOException
- * @throws ResourceConflictException
*/
public void deleteSingleRef(ProjectState projectState, String ref)
throws IOException, ResourceConflictException, AuthException, PermissionBackendException {
@@ -100,8 +98,6 @@
* @param projectState the {@code ProjectState} of the project containing the target ref.
* @param ref the ref to be deleted.
* @param prefix the prefix of the ref.
- * @throws IOException
- * @throws ResourceConflictException
*/
public void deleteSingleRef(ProjectState projectState, String ref, @Nullable String prefix)
throws IOException, ResourceConflictException, AuthException, PermissionBackendException {
@@ -161,9 +157,6 @@
* @param projectState the {@code ProjectState} of the project whose refs are to be deleted.
* @param refsToDelete the refs to be deleted.
* @param prefix the prefix to add to abbreviated refs, eg. "refs/heads/".
- * @throws IOException
- * @throws ResourceConflictException
- * @throws PermissionBackendException
*/
public void deleteMultipleRefs(
ProjectState projectState, ImmutableSet<String> refsToDelete, String prefix)
diff --git a/java/com/google/gerrit/server/restapi/project/ListProjects.java b/java/com/google/gerrit/server/restapi/project/ListProjects.java
index c4ae33a..4d8005b 100644
--- a/java/com/google/gerrit/server/restapi/project/ListProjects.java
+++ b/java/com/google/gerrit/server/restapi/project/ListProjects.java
@@ -490,7 +490,7 @@
continue;
}
- List<Ref> refs = retrieveBranchRefs(e);
+ List<Ref> refs = retrieveBranchRefs(e, git);
if (!hasValidRef(refs)) {
continue;
}
@@ -578,17 +578,12 @@
}
}
- private List<Ref> retrieveBranchRefs(ProjectState e) throws PermissionBackendException {
- boolean canReadAllRefs = e.statePermitsRead();
- if (canReadAllRefs) {
- try {
- permissionBackend.user(currentUser).project(e.getNameKey()).check(ProjectPermission.READ);
- } catch (AuthException exp) {
- canReadAllRefs = false;
- }
+ private List<Ref> retrieveBranchRefs(ProjectState e, Repository git) {
+ if (!e.statePermitsRead()) {
+ return ImmutableList.of();
}
- return getBranchRefs(e.getNameKey(), canReadAllRefs);
+ return getBranchRefs(e.getNameKey(), git);
}
private void addParentProjectInfo(
@@ -708,15 +703,13 @@
stdout.flush();
}
- private List<Ref> getBranchRefs(Project.NameKey projectName, boolean canReadAllRefs) {
+ private List<Ref> getBranchRefs(Project.NameKey projectName, Repository git) {
Ref[] result = new Ref[showBranch.size()];
- try (Repository git = repoManager.openRepository(projectName)) {
+ try {
PermissionBackend.ForProject perm = permissionBackend.user(currentUser).project(projectName);
for (int i = 0; i < showBranch.size(); i++) {
Ref ref = git.findRef(showBranch.get(i));
- if (all && canReadAllRefs) {
- result[i] = ref;
- } else if (ref != null && ref.getObjectId() != null) {
+ if (ref != null && ref.getObjectId() != null) {
try {
perm.ref(ref.getLeaf().getName()).check(RefPermission.READ);
result[i] = ref;
diff --git a/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java b/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
index efc739c..6174798 100644
--- a/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
+++ b/java/com/google/gerrit/server/restapi/project/ProjectsCollection.java
@@ -105,7 +105,6 @@
* @throws RestApiException thrown if the project ID cannot be resolved or if the project is not
* visible to the calling user
* @throws IOException thrown when there is an error.
- * @throws PermissionBackendException
*/
public ProjectResource parse(String id)
throws RestApiException, IOException, PermissionBackendException {
@@ -121,7 +120,6 @@
* @throws RestApiException thrown if the project ID cannot be resolved or if the project is not
* visible to the calling user and checkVisibility is true.
* @throws IOException thrown when there is an error.
- * @throws PermissionBackendException
*/
public ProjectResource parse(String id, boolean checkAccess)
throws RestApiException, IOException, PermissionBackendException {
diff --git a/java/com/google/gerrit/server/securestore/SecureStore.java b/java/com/google/gerrit/server/securestore/SecureStore.java
index b5aebee..b53e38c 100644
--- a/java/com/google/gerrit/server/securestore/SecureStore.java
+++ b/java/com/google/gerrit/server/securestore/SecureStore.java
@@ -39,13 +39,7 @@
public final String section;
public final String subsection;
- /**
- * Creates EntryKey.
- *
- * @param section
- * @param subsection
- * @param name
- */
+ /** Creates EntryKey */
public EntryKey(String section, String subsection, String name) {
this.name = name;
this.section = section;
@@ -57,9 +51,6 @@
* Extract decrypted value of stored property from SecureStore or {@code null} when property was
* not found.
*
- * @param section
- * @param subsection
- * @param name
* @return decrypted String value or {@code null} if not found
*/
public final String get(String section, String subsection, String name) {
@@ -74,10 +65,6 @@
* Extract decrypted value of stored plugin config property from SecureStore or {@code null} when
* property was not found.
*
- * @param pluginName
- * @param section
- * @param subsection
- * @param name
* @return decrypted String value or {@code null} if not found
*/
public final String getForPlugin(
@@ -93,10 +80,6 @@
* Extract list of plugin config values from SecureStore and decrypt every value in that list, or
* {@code null} when property was not found.
*
- * @param pluginName
- * @param section
- * @param subsection
- * @param name
* @return decrypted list of string values or {@code null}
*/
public abstract String[] getListForPlugin(
@@ -106,9 +89,6 @@
* Extract list of values from SecureStore and decrypt every value in that list or {@code null}
* when property was not found.
*
- * @param section
- * @param subsection
- * @param name
* @return decrypted list of string values or {@code null}
*/
public abstract String[] getList(String section, String subsection, String name);
@@ -118,9 +98,6 @@
*
* <p>This method is responsible for encrypting value and storing it.
*
- * @param section
- * @param subsection
- * @param name
* @param value plain text value
*/
public final void set(String section, String subsection, String name, String value) {
@@ -132,26 +109,19 @@
*
* <p>This method is responsible for encrypting all values in the list and storing them.
*
- * @param section
- * @param subsection
- * @param name
* @param values list of plain text values
*/
public abstract void setList(String section, String subsection, String name, List<String> values);
/**
* Remove value for given {@code section}, {@code subsection} and {@code name} from SecureStore.
- *
- * @param section
- * @param subsection
- * @param name
*/
public abstract void unset(String section, String subsection, String name);
- /** @return list of stored entries. */
+ /** Returns list of stored entries. */
public abstract Iterable<EntryKey> list();
- /** @return <code>true</code> if currently loaded values are outdated */
+ /** Returns <code>true</code> if currently loaded values are outdated */
public abstract boolean isOutdated();
/** Reload the values */
diff --git a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
index f181c36..7d428eb 100644
--- a/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
+++ b/java/com/google/gerrit/server/submit/SubmitStrategyOp.java
@@ -521,32 +521,22 @@
}
}
- /**
- * @see #updateRepo(RepoContext)
- * @param ctx
- */
+ /** See {@link #updateRepo(RepoContext)} */
protected void updateRepoImpl(RepoContext ctx) throws Exception {}
/**
- * @see #updateChange(ChangeContext)
- * @param ctx
- * @return a new patch set if one was created by the submit strategy, or null if not.
+ * Returns a new patch set if one was created by the submit strategy, or null if not
+ *
+ * <p>See {@link #updateChange(ChangeContext)}
*/
protected PatchSet updateChangeImpl(ChangeContext ctx) throws Exception {
return null;
}
- /**
- * @see #postUpdate(PostUpdateContext)
- * @param ctx
- */
+ /** See {@link #postUpdate(PostUpdateContext)} */
protected void postUpdateImpl(PostUpdateContext ctx) throws Exception {}
- /**
- * Amend the commit with gitlink update
- *
- * @param commit
- */
+ /** Amend the commit with gitlink update */
protected CodeReviewCommit amendGitlink(CodeReviewCommit commit)
throws IntegrationConflictException {
if (!args.subscriptionGraph.hasSubscription(args.destBranch)) {
diff --git a/java/com/google/gerrit/server/tools/ToolsCatalog.java b/java/com/google/gerrit/server/tools/ToolsCatalog.java
index aaa366c..9c1483f 100644
--- a/java/com/google/gerrit/server/tools/ToolsCatalog.java
+++ b/java/com/google/gerrit/server/tools/ToolsCatalog.java
@@ -175,28 +175,28 @@
return type;
}
- /** @return the preferred UNIX file mode, e.g. {@code 0755}. */
+ /** Returns the preferred UNIX file mode, e.g. {@code 0755}. */
public int getMode() {
return mode;
}
- /** @return path of the entry, relative to the catalog root. */
+ /** Returns path of the entry, relative to the catalog root. */
public String getPath() {
return path;
}
- /** @return name of the entry, within its parent directory. */
+ /** Returns the name of the entry, within its parent directory. */
public String getName() {
final int s = path.lastIndexOf('/');
return s < 0 ? path : path.substring(s + 1);
}
- /** @return collection of entries below this one, if this is a directory. */
+ /** Returns collection of entries below this one, if this is a directory. */
public List<Entry> getChildren() {
return Collections.unmodifiableList(children);
}
- /** @return a copy of the file's contents. */
+ /** Returns a copy of the file's contents. */
public byte[] getBytes() {
byte[] data = read(getPath());
diff --git a/java/com/google/gerrit/server/update/ChainedReceiveCommands.java b/java/com/google/gerrit/server/update/ChainedReceiveCommands.java
index c223aec..99c72f2 100644
--- a/java/com/google/gerrit/server/update/ChainedReceiveCommands.java
+++ b/java/com/google/gerrit/server/update/ChainedReceiveCommands.java
@@ -118,7 +118,7 @@
}
}
- /** @return an unmodifiable view of commands. */
+ /** Returns an unmodifiable view of commands. */
public Map<String, ReceiveCommand> getCommands() {
return Collections.unmodifiableMap(commands);
}
diff --git a/java/com/google/gerrit/server/update/ChangeContext.java b/java/com/google/gerrit/server/update/ChangeContext.java
index 5a53e2a..aeabde4 100644
--- a/java/com/google/gerrit/server/update/ChangeContext.java
+++ b/java/com/google/gerrit/server/update/ChangeContext.java
@@ -69,7 +69,7 @@
*/
void deleteChange();
- /** @return change corresponding to {@link #getNotes()}. */
+ /** Returns change corresponding to {@link #getNotes()}. */
default Change getChange() {
return requireNonNull(getNotes().getChange());
}
diff --git a/java/com/google/gerrit/server/update/RepoContext.java b/java/com/google/gerrit/server/update/RepoContext.java
index 9faf628..66831cd 100644
--- a/java/com/google/gerrit/server/update/RepoContext.java
+++ b/java/com/google/gerrit/server/update/RepoContext.java
@@ -22,9 +22,9 @@
/** Context for performing the {@link BatchUpdateOp#updateRepo} phase. */
public interface RepoContext extends Context {
/**
- * @return inserter for writing to the repo. Callers should not flush; the walk returned by {@link
- * #getRevWalk()} is able to read back objects inserted by this inserter without flushing
- * first.
+ * Returns inserter for writing to the repo. Callers should not flush; the walk returned by {@link
+ * #getRevWalk()} is able to read back objects inserted by this inserter without flushing first.
+ *
* @throws IOException if an error occurred opening the repo.
*/
ObjectInserter getInserter() throws IOException;
diff --git a/java/com/google/gerrit/server/update/RetryHelper.java b/java/com/google/gerrit/server/update/RetryHelper.java
index 2249b0e..7e6974c 100644
--- a/java/com/google/gerrit/server/update/RetryHelper.java
+++ b/java/com/google/gerrit/server/update/RetryHelper.java
@@ -121,7 +121,9 @@
@Inject
Metrics(MetricMaker metricMaker) {
Field<String> actionTypeField =
- Field.ofString("action_type", Metadata.Builder::actionType).build();
+ Field.ofString("action_type", Metadata.Builder::actionType)
+ .description("The type of the action that was retried.")
+ .build();
Field<String> operationNameField =
Field.ofString("operation_name", Metadata.Builder::operationName)
.description("The name of the operation that was retried.")
@@ -479,7 +481,7 @@
}
String cause = formatCause(t);
- if (!traceContext.isTracing()) {
+ if (!TraceContext.isTracing()) {
String traceId = "retry-on-failure-" + new RequestId();
traceContext.addTag(RequestId.Type.TRACE_ID, traceId).forceLogging();
logger.atWarning().withCause(t).log(
diff --git a/java/com/google/gerrit/server/util/RequestScopePropagator.java b/java/com/google/gerrit/server/util/RequestScopePropagator.java
index dc8a136..10c46fc 100644
--- a/java/com/google/gerrit/server/util/RequestScopePropagator.java
+++ b/java/com/google/gerrit/server/util/RequestScopePropagator.java
@@ -160,7 +160,11 @@
};
}
- /** @see #wrap(Callable) */
+ /**
+ * Ensures that the current request state is available when the passed in Callable is invoked
+ *
+ * <p>See {@link #wrap(Callable)}
+ */
protected abstract <T> Callable<T> wrapImpl(Callable<T> callable);
protected <T> Callable<T> context(RequestContext context, Callable<T> callable) {
diff --git a/java/com/google/gerrit/server/util/time/TimeUtil.java b/java/com/google/gerrit/server/util/time/TimeUtil.java
index 639d0a6..54ef305 100644
--- a/java/com/google/gerrit/server/util/time/TimeUtil.java
+++ b/java/com/google/gerrit/server/util/time/TimeUtil.java
@@ -20,6 +20,7 @@
import com.google.gerrit.server.util.git.DelegateSystemReader;
import java.sql.Timestamp;
import java.time.Instant;
+import java.util.concurrent.TimeUnit;
import java.util.function.LongSupplier;
import org.eclipse.jgit.util.SystemReader;
@@ -35,6 +36,10 @@
return currentMillisSupplier.getAsLong();
}
+ public static long nowNanos() {
+ return TimeUnit.NANOSECONDS.convert(TimeUtil.nowMs(), TimeUnit.MILLISECONDS);
+ }
+
public static Instant now() {
return Instant.ofEpochMilli(nowMs());
}
diff --git a/java/com/google/gerrit/sshd/BaseCommand.java b/java/com/google/gerrit/sshd/BaseCommand.java
index 42aabfb..f1be04e 100644
--- a/java/com/google/gerrit/sshd/BaseCommand.java
+++ b/java/com/google/gerrit/sshd/BaseCommand.java
@@ -73,6 +73,7 @@
static final int STATUS_NOT_FOUND = PRIVATE_STATUS | 2;
public static final int STATUS_NOT_ADMIN = PRIVATE_STATUS | 3;
+ @SuppressWarnings("unused") // unused here, but triggers logic in EndOfOptionsHandler
@Option(name = "--", usage = "end of options", handler = EndOfOptionsHandler.class)
private boolean endOfOptions;
diff --git a/java/com/google/gerrit/sshd/SshLog.java b/java/com/google/gerrit/sshd/SshLog.java
index 616f7d1..7c96342 100644
--- a/java/com/google/gerrit/sshd/SshLog.java
+++ b/java/com/google/gerrit/sshd/SshLog.java
@@ -92,7 +92,7 @@
}
}
- /** @return true if a change in state has occurred */
+ /** Returns true if a change in state has occurred */
public boolean enableLogging() {
synchronized (lock) {
if (async == null) {
@@ -112,7 +112,7 @@
}
}
- /** @return true if a change in state has occurred */
+ /** Returns true if a change in state has occurred */
public boolean disableLogging() {
synchronized (lock) {
if (async != null) {
diff --git a/java/com/google/gerrit/sshd/SshSession.java b/java/com/google/gerrit/sshd/SshSession.java
index b39eaed..d545844 100644
--- a/java/com/google/gerrit/sshd/SshSession.java
+++ b/java/com/google/gerrit/sshd/SshSession.java
@@ -114,7 +114,7 @@
identity.setAccessPath(path);
}
- /** @return {@code true} if the authentication did not succeed. */
+ /** Returns {@code true} if the authentication did not succeed. */
boolean isAuthenticationError() {
return authError != null;
}
diff --git a/java/com/google/gerrit/testing/GerritJUnit.java b/java/com/google/gerrit/testing/GerritJUnit.java
index 0771c39..e80afa9 100644
--- a/java/com/google/gerrit/testing/GerritJUnit.java
+++ b/java/com/google/gerrit/testing/GerritJUnit.java
@@ -26,11 +26,11 @@
* <p>This construction is recommended by the Truth team for use in conjunction with asserting
* over a {@code ThrowableSubject} on the return type:
*
- * <pre>
- * MyException e = assertThrows(MyException.class, () -> doSomething(foo));
- * assertThat(e).isInstanceOf(MySubException.class);
- * assertThat(e).hasMessageThat().contains("sub-exception occurred");
- * </pre>
+ * <pre>{@code
+ * MyException e = assertThrows(MyException.class, () -> doSomething(foo));
+ * assertThat(e).isInstanceOf(MySubException.class);
+ * assertThat(e).hasMessageThat().contains("sub-exception occurred");
+ * }</pre>
*
* @param throwableClass expected exception type.
* @param runnable runnable containing arbitrary code.
diff --git a/java/com/google/gerrit/testing/GerritServerTests.java b/java/com/google/gerrit/testing/GerritServerTests.java
index 363a07d..752c13d 100644
--- a/java/com/google/gerrit/testing/GerritServerTests.java
+++ b/java/com/google/gerrit/testing/GerritServerTests.java
@@ -26,7 +26,6 @@
@RunWith(ConfigSuite.class)
public class GerritServerTests {
@ConfigSuite.Parameter public Config config;
- @ConfigSuite.Name private String configName;
@Rule
public TestRule testRunner =
diff --git a/java/com/google/gerrit/util/http/RequestUtil.java b/java/com/google/gerrit/util/http/RequestUtil.java
index 92d9967..f64ce5a 100644
--- a/java/com/google/gerrit/util/http/RequestUtil.java
+++ b/java/com/google/gerrit/util/http/RequestUtil.java
@@ -31,8 +31,8 @@
}
/**
- * @return the same value as {@link HttpServletRequest#getPathInfo()}, but without decoding
- * URL-encoded characters.
+ * Returns the same value as {@link HttpServletRequest#getPathInfo()}, but without decoding
+ * URL-encoded characters.
*/
public static String getEncodedPathInfo(HttpServletRequest req) {
// CS IGNORE LineLength FOR NEXT 3 LINES. REASON: URL.
diff --git a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
index c7cd47d..4c17800 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/ChangeIT.java
@@ -99,10 +99,12 @@
import com.google.gerrit.entities.LabelFunction;
import com.google.gerrit.entities.LabelId;
import com.google.gerrit.entities.LabelType;
+import com.google.gerrit.entities.LegacySubmitRequirement;
import com.google.gerrit.entities.PatchSet;
import com.google.gerrit.entities.Permission;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.RefNames;
+import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.entities.SubmitRequirement;
import com.google.gerrit.entities.SubmitRequirementExpression;
import com.google.gerrit.entities.SubmitRequirementExpressionResult;
@@ -148,7 +150,9 @@
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.GitPerson;
import com.google.gerrit.extensions.common.LabelInfo;
+import com.google.gerrit.extensions.common.LegacySubmitRequirementInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
+import com.google.gerrit.extensions.common.SubmitRecordInfo;
import com.google.gerrit.extensions.common.SubmitRequirementResultInfo;
import com.google.gerrit.extensions.common.SubmitRequirementResultInfo.Status;
import com.google.gerrit.extensions.common.TrackingIdInfo;
@@ -184,6 +188,7 @@
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.query.change.ChangeQueryBuilder.ChangeOperatorFactory;
import com.google.gerrit.server.restapi.change.PostReview;
+import com.google.gerrit.server.rules.SubmitRule;
import com.google.gerrit.server.update.BatchUpdate;
import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext;
@@ -4024,6 +4029,51 @@
}
@Test
+ public void submitRecords() throws Exception {
+ PushOneCommit.Result r = createChange();
+ TestSubmitRule testSubmitRule = new TestSubmitRule();
+ try (Registration registration = extensionRegistry.newRegistration().add(testSubmitRule)) {
+ String changeId = r.getChangeId();
+
+ ChangeInfo change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRecords).hasSize(2);
+ // Check the default submit record for the code-review label
+ SubmitRecordInfo codeReviewRecord = Iterables.get(change.submitRecords, 0);
+ assertThat(codeReviewRecord.ruleName).isEqualTo("gerrit~DefaultSubmitRule");
+ assertThat(codeReviewRecord.status).isEqualTo(SubmitRecordInfo.Status.NOT_READY);
+ assertThat(codeReviewRecord.labels).hasSize(1);
+ SubmitRecordInfo.Label label = Iterables.getOnlyElement(codeReviewRecord.labels);
+ assertThat(label.label).isEqualTo("Code-Review");
+ assertThat(label.status).isEqualTo(SubmitRecordInfo.Label.Status.NEED);
+ assertThat(label.appliedBy).isNull();
+ // Check the custom test record created by the TestSubmitRule
+ SubmitRecordInfo testRecord = Iterables.get(change.submitRecords, 1);
+ assertThat(testRecord.ruleName).isEqualTo("gerrit~TestSubmitRule");
+ assertThat(testRecord.status).isEqualTo(SubmitRecordInfo.Status.OK);
+ assertThat(testRecord.requirements)
+ .containsExactly(new LegacySubmitRequirementInfo("OK", "fallback text", "type"));
+ assertThat(testRecord.labels).hasSize(1);
+ SubmitRecordInfo.Label testLabel = Iterables.getOnlyElement(testRecord.labels);
+ assertThat(testLabel.label).isEqualTo("label");
+ assertThat(testLabel.status).isEqualTo(SubmitRecordInfo.Label.Status.OK);
+ assertThat(testLabel.appliedBy).isNull();
+
+ voteLabel(changeId, "code-review", 2);
+ // Code review record is satisfied after voting +2
+ change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRecords).hasSize(2);
+ codeReviewRecord = Iterables.get(change.submitRecords, 0);
+ assertThat(codeReviewRecord.ruleName).isEqualTo("gerrit~DefaultSubmitRule");
+ assertThat(codeReviewRecord.status).isEqualTo(SubmitRecordInfo.Status.OK);
+ assertThat(codeReviewRecord.labels).hasSize(1);
+ label = Iterables.getOnlyElement(codeReviewRecord.labels);
+ assertThat(label.label).isEqualTo("Code-Review");
+ assertThat(label.status).isEqualTo(SubmitRecordInfo.Label.Status.OK);
+ assertThat(label.appliedBy._accountId).isEqualTo(admin.id().get());
+ }
+ }
+
+ @Test
public void submitRequirement_withLabelEqualsMax() throws Exception {
configSubmitRequirement(
project,
@@ -4050,6 +4100,46 @@
}
@Test
+ public void submitRequirement_withLabelEqualsMax_fromNonUploader() throws Exception {
+ configLabel("my-label", LabelFunction.NO_OP); // label function has no effect
+ projectOperations
+ .project(project)
+ .forUpdate()
+ .add(allowLabel("my-label").ref("refs/heads/master").group(REGISTERED_USERS).range(-1, 1))
+ .update();
+ configSubmitRequirement(
+ project,
+ SubmitRequirement.builder()
+ .setName("my-label")
+ .setSubmittabilityExpression(
+ SubmitRequirementExpression.create("label:my-label=MAX,user=non_uploader"))
+ .setAllowOverrideInChildProjects(false)
+ .build());
+
+ PushOneCommit.Result r = createChange();
+ String changeId = r.getChangeId();
+ ChangeInfo change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.UNSATISFIED, /* isLegacy= */ false);
+
+ // Voting with a max vote as the uploader will not satisfy the submit requirement.
+ voteLabel(changeId, "my-label", 1);
+ change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.UNSATISFIED, /* isLegacy= */ false);
+
+ // Voting as a non-uploader will satisfy the submit requirement.
+ requestScopeOperations.setApiUser(user.id());
+ voteLabel(changeId, "my-label", 1);
+ change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.SATISFIED, /* isLegacy= */ false);
+ }
+
+ @Test
public void submitRequirement_withLabelEqualsMinBlockingSubmission() throws Exception {
configSubmitRequirement(
project,
@@ -4085,6 +4175,54 @@
}
@Test
+ public void submitRequirement_withMaxWithBlock_ignoringSelfApproval() throws Exception {
+ configLabel("my-label", LabelFunction.MAX_WITH_BLOCK);
+ projectOperations
+ .project(project)
+ .forUpdate()
+ .add(allowLabel("my-label").ref("refs/heads/master").group(REGISTERED_USERS).range(-1, 1))
+ .update();
+
+ configSubmitRequirement(
+ project,
+ SubmitRequirement.builder()
+ .setName("my-label")
+ .setSubmittabilityExpression(
+ SubmitRequirementExpression.create(
+ "label:my-label=MAX,user=non_uploader -label:my-label=MIN"))
+ .setAllowOverrideInChildProjects(false)
+ .build());
+
+ // Create the change as admin
+ requestScopeOperations.setApiUser(admin.id());
+ PushOneCommit.Result r = createChange();
+ String changeId = r.getChangeId();
+
+ // Admin (a.k.a uploader) adds a -1 min vote. This is going to block submission.
+ voteLabel(changeId, "my-label", -1);
+ ChangeInfo change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.UNSATISFIED, /* isLegacy= */ false);
+
+ // user (i.e. non_uploader) votes 1. Requirement is still blocking because of -1 of uploader.
+ requestScopeOperations.setApiUser(user.id());
+ voteLabel(changeId, "my-label", 1);
+ change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.UNSATISFIED, /* isLegacy= */ false);
+
+ // Admin (a.k.a uploader) removes -1. Now requirement is fulfilled.
+ requestScopeOperations.setApiUser(admin.id());
+ voteLabel(changeId, "my-label", 0);
+ change = gApi.changes().id(changeId).get();
+ assertThat(change.submitRequirements).hasSize(1);
+ assertSubmitRequirementStatus(
+ change.submitRequirements, "my-label", Status.SATISFIED, /* isLegacy= */ false);
+ }
+
+ @Test
public void submitRequirement_withLabelEqualsAny() throws Exception {
configSubmitRequirement(
project,
@@ -4831,6 +4969,28 @@
}
@Test
+ @GerritConfig(name = "trackingid.jira-bug.footer", value = "Bug:")
+ @GerritConfig(name = "trackingid.jira-bug.match", value = "\\d+")
+ @GerritConfig(name = "trackingid.jira-bug.system", value = "JIRA")
+ public void multipleTrackingIdsInSingleFooter() throws Exception {
+ PushOneCommit push =
+ pushFactory.create(
+ admin.newIdent(),
+ testRepo,
+ PushOneCommit.SUBJECT + "\n\n" + "Bug: 123, 456",
+ PushOneCommit.FILE_NAME,
+ PushOneCommit.FILE_CONTENT);
+ PushOneCommit.Result result = push.to("refs/for/master");
+ result.assertOkStatus();
+
+ ChangeInfo change = gApi.changes().id(result.getChangeId()).get(TRACKING_IDS);
+ Collection<TrackingIdInfo> trackingIds = change.trackingIds;
+ assertThat(trackingIds).isNotNull();
+ assertThat(trackingIds).hasSize(2);
+ assertThat(trackingIds.stream().map(t -> t.id)).containsExactly("123", "456");
+ }
+
+ @Test
public void starUnstar() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration =
@@ -5064,4 +5224,25 @@
.update();
return project;
}
+
+ /** Returns a hard-coded submit record containing all fields. */
+ private static class TestSubmitRule implements SubmitRule {
+ @Override
+ public Optional<SubmitRecord> evaluate(ChangeData changeData) {
+ SubmitRecord record = new SubmitRecord();
+ record.ruleName = "testSubmitRule";
+ record.status = SubmitRecord.Status.OK;
+ SubmitRecord.Label label = new SubmitRecord.Label();
+ label.label = "label";
+ label.status = SubmitRecord.Label.Status.OK;
+ record.labels = Arrays.asList(label);
+ record.requirements =
+ Arrays.asList(
+ LegacySubmitRequirement.builder()
+ .setType("type")
+ .setFallbackText("fallback text")
+ .build());
+ return Optional.of(record);
+ }
+ }
}
diff --git a/javatests/com/google/gerrit/acceptance/api/change/PostReviewIT.java b/javatests/com/google/gerrit/acceptance/api/change/PostReviewIT.java
index b79be80..96bc65d 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/PostReviewIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/PostReviewIT.java
@@ -27,6 +27,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.truth.Correspondence;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@@ -56,6 +57,8 @@
import com.google.gerrit.extensions.common.RobotCommentInfo;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.extensions.events.CommentAddedListener;
+import com.google.gerrit.extensions.events.ReviewerAddedListener;
+import com.google.gerrit.extensions.events.ReviewerDeletedListener;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException;
@@ -74,6 +77,7 @@
import com.google.inject.Inject;
import com.google.inject.Module;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -699,6 +703,61 @@
}
@Test
+ public void addingReviewers() throws Exception {
+ PushOneCommit.Result r = createChange();
+
+ TestAccount user2 = accountCreator.user2();
+
+ TestReviewerAddedListener testReviewerAddedListener = new TestReviewerAddedListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(testReviewerAddedListener)) {
+ // add user and user2
+ ReviewResult reviewResult =
+ gApi.changes()
+ .id(r.getChangeId())
+ .current()
+ .review(ReviewInput.create().reviewer(user.email()).reviewer(user2.email()));
+
+ assertThat(
+ reviewResult.reviewers.values().stream()
+ .filter(a -> a.reviewers != null)
+ .map(a -> Iterables.getOnlyElement(a.reviewers).name)
+ .collect(toImmutableSet()))
+ .containsExactly(user.fullName(), user2.fullName());
+ }
+
+ assertThat(
+ gApi.changes().id(r.getChangeId()).reviewers().stream()
+ .map(a -> a.name)
+ .collect(toImmutableSet()))
+ .containsExactly(user.fullName(), user2.fullName());
+
+ // Ensure only one batch email was sent for this operation
+ FakeEmailSender.Message message = Iterables.getOnlyElement(sender.getMessages());
+ assertThat(message.body())
+ .containsMatch(
+ Pattern.quote("Hello ")
+ + "("
+ + Pattern.quote(String.format("%s, %s", user.fullName(), user2.fullName()))
+ + "|"
+ + Pattern.quote(String.format("%s, %s", user2.fullName(), user.fullName()))
+ + ")");
+ assertThat(message.htmlBody())
+ .containsMatch(
+ "("
+ + Pattern.quote(String.format("%s and %s", user.fullName(), user2.fullName()))
+ + "|"
+ + Pattern.quote(String.format("%s and %s", user2.fullName(), user.fullName()))
+ + ")"
+ + Pattern.quote(" to <strong>review</strong> this change"));
+
+ // Ensure that a batch event has been sent:
+ // * 1 batch event for adding user and user2 as reviewers
+ assertThat(testReviewerAddedListener.receivedEvents).hasSize(1);
+ assertThat(testReviewerAddedListener.getReviewerIds()).containsExactly(user.id(), user2.id());
+ }
+
+ @Test
public void deletingReviewers() throws Exception {
PushOneCommit.Result r = createChange();
@@ -712,21 +771,25 @@
sender.clear();
- // remove user and user2
- ReviewResult reviewResult =
- gApi.changes()
- .id(r.getChangeId())
- .current()
- .review(
- ReviewInput.create()
- .reviewer(user.email(), ReviewerState.REMOVED, /* confirmed= */ true)
- .reviewer(user2.email(), ReviewerState.REMOVED, /* confirmed= */ true));
+ TestReviewerDeletedListener testReviewerDeletedListener = new TestReviewerDeletedListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(testReviewerDeletedListener)) {
+ // remove user and user2
+ ReviewResult reviewResult =
+ gApi.changes()
+ .id(r.getChangeId())
+ .current()
+ .review(
+ ReviewInput.create()
+ .reviewer(user.email(), ReviewerState.REMOVED, /* confirmed= */ true)
+ .reviewer(user2.email(), ReviewerState.REMOVED, /* confirmed= */ true));
- assertThat(
- reviewResult.reviewers.values().stream()
- .map(a -> a.removed.name)
- .collect(toImmutableSet()))
- .containsExactly(user.fullName(), user2.fullName());
+ assertThat(
+ reviewResult.reviewers.values().stream()
+ .map(a -> a.removed.name)
+ .collect(toImmutableSet()))
+ .containsExactly(user.fullName(), user2.fullName());
+ }
assertThat(gApi.changes().id(r.getChangeId()).reviewers()).isEmpty();
@@ -748,6 +811,12 @@
+ "|"
+ Pattern.quote(String.format("%s and %s", user2.fullName(), user.fullName()))
+ ")");
+
+ // Ensure that events have been sent:
+ // * 2 events for removing user and user2 as reviewers (one event per removed reviewer, batch
+ // event not available for reviewer removal)
+ assertThat(testReviewerDeletedListener.receivedEvents).hasSize(2);
+ assertThat(testReviewerDeletedListener.getReviewerIds()).containsExactly(user.id(), user2.id());
}
@Test
@@ -766,30 +835,38 @@
sender.clear();
- // remove user and user2 while adding user3 and user4
- ReviewResult reviewResult =
- gApi.changes()
- .id(r.getChangeId())
- .current()
- .review(
- ReviewInput.create()
- .reviewer(user.email(), ReviewerState.REMOVED, /* confirmed= */ true)
- .reviewer(user2.email(), ReviewerState.REMOVED, /* confirmed= */ true)
- .reviewer(user3.email())
- .reviewer(user4.email()));
+ TestReviewerAddedListener testReviewerAddedListener = new TestReviewerAddedListener();
+ TestReviewerDeletedListener testReviewerDeletedListener = new TestReviewerDeletedListener();
+ try (Registration registration =
+ extensionRegistry
+ .newRegistration()
+ .add(testReviewerAddedListener)
+ .add(testReviewerDeletedListener)) {
+ // remove user and user2 while adding user3 and user4
+ ReviewResult reviewResult =
+ gApi.changes()
+ .id(r.getChangeId())
+ .current()
+ .review(
+ ReviewInput.create()
+ .reviewer(user.email(), ReviewerState.REMOVED, /* confirmed= */ true)
+ .reviewer(user2.email(), ReviewerState.REMOVED, /* confirmed= */ true)
+ .reviewer(user3.email())
+ .reviewer(user4.email()));
- assertThat(
- reviewResult.reviewers.values().stream()
- .filter(a -> a.removed != null)
- .map(a -> a.removed.name)
- .collect(toImmutableSet()))
- .containsExactly(user.fullName(), user2.fullName());
- assertThat(
- reviewResult.reviewers.values().stream()
- .filter(a -> a.reviewers != null)
- .map(a -> Iterables.getOnlyElement(a.reviewers).name)
- .collect(toImmutableSet()))
- .containsExactly(user3.fullName(), user4.fullName());
+ assertThat(
+ reviewResult.reviewers.values().stream()
+ .filter(a -> a.removed != null)
+ .map(a -> a.removed.name)
+ .collect(toImmutableSet()))
+ .containsExactly(user.fullName(), user2.fullName());
+ assertThat(
+ reviewResult.reviewers.values().stream()
+ .filter(a -> a.reviewers != null)
+ .map(a -> Iterables.getOnlyElement(a.reviewers).name)
+ .collect(toImmutableSet()))
+ .containsExactly(user3.fullName(), user4.fullName());
+ }
assertThat(
gApi.changes().id(r.getChangeId()).reviewers().stream()
@@ -832,6 +909,15 @@
+ "|"
+ Pattern.quote(String.format("%s and %s", user2.fullName(), user.fullName()))
+ ")");
+
+ // Ensure that events have been sent:
+ // * 1 batch event for adding user3 and user4 as reviewers
+ // * 2 events for removing user and user2 as reviewers (one event per removed reviewer, batch
+ // event not available for reviewer removal)
+ assertThat(testReviewerAddedListener.receivedEvents).hasSize(1);
+ assertThat(testReviewerAddedListener.getReviewerIds()).containsExactly(user3.id(), user4.id());
+ assertThat(testReviewerDeletedListener.receivedEvents).hasSize(2);
+ assertThat(testReviewerDeletedListener.getReviewerIds()).containsExactly(user.id(), user2.id());
}
@Test
@@ -964,4 +1050,36 @@
return Optional.empty();
}
}
+
+ private static class TestReviewerAddedListener implements ReviewerAddedListener {
+ List<ReviewerAddedListener.Event> receivedEvents = new ArrayList<>();
+
+ @Override
+ public void onReviewersAdded(ReviewerAddedListener.Event event) {
+ receivedEvents.add(event);
+ }
+
+ public ImmutableSet<Account.Id> getReviewerIds() {
+ return receivedEvents.stream()
+ .flatMap(e -> e.getReviewers().stream())
+ .map(accountInfo -> Account.id(accountInfo._accountId))
+ .collect(toImmutableSet());
+ }
+ }
+
+ private static class TestReviewerDeletedListener implements ReviewerDeletedListener {
+ List<ReviewerDeletedListener.Event> receivedEvents = new ArrayList<>();
+
+ @Override
+ public void onReviewerDeleted(ReviewerDeletedListener.Event event) {
+ receivedEvents.add(event);
+ }
+
+ public ImmutableSet<Account.Id> getReviewerIds() {
+ return receivedEvents.stream()
+ .map(ReviewerDeletedListener.Event::getReviewer)
+ .map(accountInfo -> Account.id(accountInfo._accountId))
+ .collect(toImmutableSet());
+ }
+ }
}
diff --git a/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java b/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
index f966fc8..cd9e876 100644
--- a/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/change/StickyApprovalsIT.java
@@ -14,6 +14,7 @@
package com.google.gerrit.acceptance.api.change;
+import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.gerrit.acceptance.testsuite.project.TestProjectUpdate.allowLabel;
@@ -28,9 +29,11 @@
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.server.project.testing.TestLabels.labelBuilder;
import static com.google.gerrit.server.project.testing.TestLabels.value;
+import static java.util.Comparator.comparing;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -44,17 +47,21 @@
import com.google.gerrit.entities.LabelId;
import com.google.gerrit.entities.LabelType;
import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.entities.PatchSetApproval;
import com.google.gerrit.entities.RefNames;
import com.google.gerrit.extensions.api.changes.ReviewInput;
+import com.google.gerrit.extensions.api.changes.RevisionApi;
import com.google.gerrit.extensions.client.ChangeKind;
import com.google.gerrit.extensions.common.ApprovalInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
+import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.server.change.ChangeKindCacheImpl;
import com.google.gerrit.server.project.testing.TestLabels;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.jgit.lib.ObjectId;
@@ -902,6 +909,52 @@
}
@Test
+ public void copyWithListOfFilesUnchangedButAddedMergeList() throws Exception {
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig()
+ .updateLabelType(LabelId.CODE_REVIEW, b -> b.setCopyCondition("has:unchanged-files"));
+ u.save();
+ }
+ Change.Id parent1ChangeId = changeOperations.newChange().create();
+ Change.Id parent2ChangeId = changeOperations.newChange().create();
+ Change.Id dummyParentChangeId = changeOperations.newChange().create();
+ Change.Id changeId =
+ changeOperations
+ .newChange()
+ .mergeOf()
+ .change(parent1ChangeId)
+ .and()
+ .change(parent2ChangeId)
+ .create();
+
+ Map<String, FileInfo> changedFilesFirstPatchset =
+ gApi.changes().id(changeId.get()).current().files();
+
+ assertThat(changedFilesFirstPatchset.keySet()).containsExactly("/COMMIT_MSG", "/MERGE_LIST");
+
+ // Make a Code-Review vote that should be sticky.
+ gApi.changes().id(changeId.get()).current().review(ReviewInput.approve());
+
+ changeOperations
+ .change(changeId)
+ .newPatchset()
+ .parent()
+ .patchset(PatchSet.id(dummyParentChangeId, 1))
+ .create();
+
+ Map<String, FileInfo> changedFilesSecondPatchset =
+ gApi.changes().id(changeId.get()).current().files();
+
+ // Only "/MERGE_LIST" was removed.
+ assertThat(changedFilesSecondPatchset.keySet()).containsExactly("/COMMIT_MSG");
+ ApprovalInfo approvalInfo =
+ Iterables.getOnlyElement(
+ gApi.changes().id(changeId.get()).current().votes().get(LabelId.CODE_REVIEW));
+ assertThat(approvalInfo._accountId).isEqualTo(admin.id().get());
+ assertThat(approvalInfo.value).isEqualTo(2);
+ }
+
+ @Test
public void deleteStickyVote() throws Exception {
String label = LabelId.CODE_REVIEW;
try (ProjectConfigUpdate u = updateProject(project)) {
@@ -948,6 +1001,237 @@
assertThat(r.getChange().approvals().get(PatchSet.id(r.getChange().getId(), 2))).hasSize(1);
}
+ @Test
+ public void stickyVoteStoredOnUpload() throws Exception {
+ // Code-Review will be sticky.
+ String label = LabelId.CODE_REVIEW;
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig().updateLabelType(label, b -> b.setCopyAnyScore(true));
+ u.save();
+ }
+
+ PushOneCommit.Result r = createChange();
+ // Add a new vote.
+ ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 2);
+ input.tag = "tag";
+ gApi.changes().id(r.getChangeId()).current().review(input);
+
+ // Make new patchsets, keeping the Code-Review +2 vote.
+ for (int i = 0; i < 9; i++) {
+ amendChange(r.getChangeId());
+ }
+
+ List<PatchSetApproval> patchSetApprovals =
+ r.getChange().notes().getApprovalsWithCopied().values().stream()
+ .sorted(comparing(a -> a.patchSetId().get()))
+ .collect(toImmutableList());
+
+ for (int i = 0; i < 10; i++) {
+ int patchSet = i + 1;
+ assertThat(patchSetApprovals.get(i).patchSetId().get()).isEqualTo(patchSet);
+ assertThat(patchSetApprovals.get(i).accountId().get()).isEqualTo(admin.id().get());
+ assertThat(patchSetApprovals.get(i).realAccountId().get()).isEqualTo(admin.id().get());
+ assertThat(patchSetApprovals.get(i).label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(patchSetApprovals.get(i).value()).isEqualTo((short) 2);
+ assertThat(patchSetApprovals.get(i).tag().get()).isEqualTo("tag");
+ if (patchSet == 1) {
+ assertThat(patchSetApprovals.get(i).copied()).isFalse();
+ } else {
+ assertThat(patchSetApprovals.get(i).copied()).isTrue();
+ }
+ }
+ }
+
+ @Test
+ public void stickyVoteStoredOnRebase() throws Exception {
+ // Code-Review will be sticky.
+ String label = LabelId.CODE_REVIEW;
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig().updateLabelType(label, b -> b.setCopyAnyScore(true));
+ u.save();
+ }
+
+ // Create two changes both with the same parent
+ PushOneCommit.Result r = createChange();
+ testRepo.reset("HEAD~1");
+ PushOneCommit.Result r2 = createChange();
+
+ // Approve and submit the first change
+ RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
+ revision.review(ReviewInput.approve().label(LabelId.VERIFIED, 1));
+ revision.submit();
+
+ // Add an approval whose score should be copied.
+ gApi.changes().id(r2.getChangeId()).current().review(ReviewInput.recommend());
+
+ // Rebase the second change
+ gApi.changes().id(r2.getChangeId()).rebase();
+
+ List<PatchSetApproval> patchSetApprovals =
+ r2.getChange().notes().getApprovalsWithCopied().values().stream()
+ .sorted(comparing(a -> a.patchSetId().get()))
+ .collect(toImmutableList());
+ PatchSetApproval nonCopied = patchSetApprovals.get(0);
+
+ assertThat(nonCopied.patchSetId().get()).isEqualTo(1);
+ assertThat(nonCopied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(nonCopied.value()).isEqualTo((short) 1);
+ assertThat(nonCopied.copied()).isFalse();
+
+ PatchSetApproval copied = patchSetApprovals.get(1);
+ assertThat(copied.patchSetId().get()).isEqualTo(2);
+ assertThat(copied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(copied.value()).isEqualTo((short) 1);
+ assertThat(copied.copied()).isTrue();
+ }
+
+ @Test
+ public void stickyVoteStoredOnUploadWithRealAccount() throws Exception {
+ // Give "user" permission to vote on behalf of other users.
+ projectOperations
+ .project(project)
+ .forUpdate()
+ .add(
+ allowLabel(TestLabels.codeReview().getName())
+ .impersonation(true)
+ .ref("refs/heads/*")
+ .group(REGISTERED_USERS)
+ .range(-1, 1))
+ .update();
+
+ // Code-Review will be sticky.
+ String label = LabelId.CODE_REVIEW;
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig().updateLabelType(label, b -> b.setCopyAnyScore(true));
+ u.save();
+ }
+
+ PushOneCommit.Result r = createChange();
+
+ // Add a new vote as user
+ requestScopeOperations.setApiUser(user.id());
+ ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 1);
+ input.onBehalfOf = admin.email();
+ gApi.changes().id(r.getChangeId()).current().review(input);
+
+ // Make a new patchset, keeping the Code-Review +1 vote.
+ amendChange(r.getChangeId());
+
+ List<PatchSetApproval> patchSetApprovals =
+ r.getChange().notes().getApprovalsWithCopied().values().stream()
+ .sorted(comparing(a -> a.patchSetId().get()))
+ .collect(toImmutableList());
+
+ PatchSetApproval nonCopied = patchSetApprovals.get(0);
+ assertThat(nonCopied.patchSetId().get()).isEqualTo(1);
+ assertThat(nonCopied.accountId().get()).isEqualTo(admin.id().get());
+ assertThat(nonCopied.realAccountId().get()).isEqualTo(user.id().get());
+ assertThat(nonCopied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(nonCopied.value()).isEqualTo((short) 1);
+ assertThat(nonCopied.copied()).isFalse();
+
+ PatchSetApproval copied = patchSetApprovals.get(1);
+ assertThat(copied.patchSetId().get()).isEqualTo(2);
+ assertThat(copied.accountId().get()).isEqualTo(admin.id().get());
+ assertThat(copied.realAccountId().get()).isEqualTo(user.id().get());
+ assertThat(copied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(copied.value()).isEqualTo((short) 1);
+ assertThat(copied.copied()).isTrue();
+ }
+
+ @Test
+ public void stickyVoteStoredOnUploadWithRealAccountAndTag() throws Exception {
+ // Give "user" permission to vote on behalf of other users.
+ projectOperations
+ .project(project)
+ .forUpdate()
+ .add(
+ allowLabel(TestLabels.codeReview().getName())
+ .impersonation(true)
+ .ref("refs/heads/*")
+ .group(REGISTERED_USERS)
+ .range(-1, 1))
+ .update();
+
+ // Code-Review will be sticky.
+ String label = LabelId.CODE_REVIEW;
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig().updateLabelType(label, b -> b.setCopyAnyScore(true));
+ u.save();
+ }
+
+ PushOneCommit.Result r = createChange();
+
+ // Add a new vote as user
+ requestScopeOperations.setApiUser(user.id());
+ ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 1);
+ input.onBehalfOf = admin.email();
+ input.tag = "tag";
+ gApi.changes().id(r.getChangeId()).current().review(input);
+
+ // Make a new patchset, keeping the Code-Review +1 vote.
+ amendChange(r.getChangeId());
+
+ List<PatchSetApproval> patchSetApprovals =
+ r.getChange().notes().getApprovalsWithCopied().values().stream()
+ .sorted(comparing(a -> a.patchSetId().get()))
+ .collect(toImmutableList());
+
+ PatchSetApproval nonCopied = patchSetApprovals.get(0);
+ assertThat(nonCopied.patchSetId().get()).isEqualTo(1);
+ assertThat(nonCopied.accountId().get()).isEqualTo(admin.id().get());
+ assertThat(nonCopied.realAccountId().get()).isEqualTo(user.id().get());
+ assertThat(nonCopied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(nonCopied.value()).isEqualTo((short) 1);
+ assertThat(nonCopied.tag().get()).isEqualTo("tag");
+ assertThat(nonCopied.copied()).isFalse();
+
+ PatchSetApproval copied = patchSetApprovals.get(1);
+ assertThat(copied.patchSetId().get()).isEqualTo(2);
+ assertThat(copied.accountId().get()).isEqualTo(admin.id().get());
+ assertThat(copied.realAccountId().get()).isEqualTo(user.id().get());
+ assertThat(copied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(copied.value()).isEqualTo((short) 1);
+ assertThat(nonCopied.tag().get()).isEqualTo("tag");
+ assertThat(copied.copied()).isTrue();
+ }
+
+ @Test
+ public void stickyVoteStoredCanBeRemoved() throws Exception {
+ // Code-Review will be sticky.
+ String label = LabelId.CODE_REVIEW;
+ try (ProjectConfigUpdate u = updateProject(project)) {
+ u.getConfig().updateLabelType(label, b -> b.setCopyAnyScore(true));
+ u.save();
+ }
+
+ PushOneCommit.Result r = createChange();
+
+ // Add a new vote
+ ReviewInput input = new ReviewInput().label(LabelId.CODE_REVIEW, 2);
+ gApi.changes().id(r.getChangeId()).current().review(input);
+
+ // Make a new patchset, keeping the Code-Review +2 vote.
+ amendChange(r.getChangeId());
+ assertVotes(detailedChange(r.getChangeId()), admin, label, 2, null);
+
+ gApi.changes().id(r.getChangeId()).current().review(ReviewInput.noScore());
+
+ PatchSetApproval nonCopiedSecondPatchsetRemovedVote =
+ Iterables.getOnlyElement(
+ r.getChange()
+ .notes()
+ .getApprovalsWithCopied()
+ .get(r.getChange().change().currentPatchSetId()));
+
+ assertThat(nonCopiedSecondPatchsetRemovedVote.patchSetId().get()).isEqualTo(2);
+ assertThat(nonCopiedSecondPatchsetRemovedVote.accountId().get()).isEqualTo(admin.id().get());
+ assertThat(nonCopiedSecondPatchsetRemovedVote.label()).isEqualTo(LabelId.CODE_REVIEW);
+ // The vote got removed since the latest patch-set only has one vote and it's "0".
+ assertThat(nonCopiedSecondPatchsetRemovedVote.value()).isEqualTo((short) 0);
+ assertThat(nonCopiedSecondPatchsetRemovedVote.copied()).isFalse();
+ }
+
private void assertChangeKindCacheContains(ObjectId prior, ObjectId next) {
ChangeKind kind =
changeKindCache.getIfPresent(ChangeKindCacheImpl.Key.create(prior, next, "recursive"));
diff --git a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
index dd70d4a..c42628c 100644
--- a/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/project/ProjectIT.java
@@ -842,7 +842,7 @@
String otherLink = "https://other.example.com";
input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
- info = setConfig(child, input);
+ setConfig(child, input);
expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
@@ -866,7 +866,7 @@
String otherLink = "https://other.example.com";
input = new ConfigInput();
addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
- info = setConfig(project, input);
+ setConfig(project, input);
expected = new HashMap<>();
expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
@@ -888,7 +888,7 @@
input = new ConfigInput();
addCommentLink(input, BUGZILLA, null);
- info = setConfig(project, input);
+ setConfig(project, input);
expected = new HashMap<>();
expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
index 3d2026b..d3fe83f 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -47,6 +47,7 @@
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.TestProjectInput;
+import com.google.gerrit.acceptance.UseClockStep;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
@@ -1199,6 +1200,7 @@
}
@Test
+ @UseClockStep
public void cherryPickSetsReadyChangeOnNewPatchset() throws Exception {
PushOneCommit.Result result = pushTo("refs/for/master");
CherryPickInput input = new CherryPickInput();
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java
index 85a7b29..875ce97 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RobotCommentsIT.java
@@ -156,15 +156,15 @@
@UseClockStep
@Test
public void addedRobotCommentsAreLinkedToChangeMessages() throws Exception {
- TestTimeUtil.resetWithClockStep(0, TimeUnit.SECONDS);
- createChange();
- /* Advancing the time after creating the change so that the first robot comment is not in the same timestamp as with the change creation */
+ // Advancing the time after creating the change so that the first robot comment is not in the
+ // same timestamp as with the change creation.
TestTimeUtil.incrementClock(10, TimeUnit.SECONDS);
RobotCommentInput c1 = TestCommentHelper.createRobotCommentInput(FILE_NAME);
RobotCommentInput c2 = TestCommentHelper.createRobotCommentInput(FILE_NAME);
RobotCommentInput c3 = TestCommentHelper.createRobotCommentInput(FILE_NAME);
- /* Give the robot comments identifiable names for testing */
+
+ // Give the robot comments identifiable names for testing
c1.message = "robot comment 1";
c2.message = "robot comment 2";
c3.message = "robot comment 3";
diff --git a/javatests/com/google/gerrit/acceptance/git/AbstractForcePush.java b/javatests/com/google/gerrit/acceptance/git/AbstractForcePush.java
index 88d0937..f4918b6 100644
--- a/javatests/com/google/gerrit/acceptance/git/AbstractForcePush.java
+++ b/javatests/com/google/gerrit/acceptance/git/AbstractForcePush.java
@@ -21,6 +21,7 @@
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.OK;
import static org.eclipse.jgit.transport.RemoteRefUpdate.Status.REJECTED_OTHER_REASON;
+import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
@@ -34,7 +35,7 @@
import org.junit.Test;
public abstract class AbstractForcePush extends AbstractDaemonTest {
- @Inject private ProjectOperations projectOperations;
+ @Inject protected ProjectOperations projectOperations;
@Test
public void forcePushNotAllowed() throws Exception {
@@ -116,6 +117,28 @@
assertDeleteRef(OK);
}
+ @Test
+ public void directPushSendsEmail() throws Exception {
+ // create a change
+ PushOneCommit push1 =
+ pushFactory.create(admin.newIdent(), testRepo, "change1", "a.txt", "content");
+ PushOneCommit.Result r = push1.to("refs/for/master");
+ r.assertOkStatus();
+
+ // Add reviewer to receive notifications
+ gApi.changes().id(r.getChangeId()).addReviewer(user.email());
+ sender.clear();
+
+ // direct submit the change
+ PushOneCommit.Result r1 = push1.to("refs/heads/master");
+ r1.assertOkStatus();
+
+ // email received
+ assertThat(sender.getMessages()).hasSize(1);
+ assertThat(Iterables.getOnlyElement(sender.getMessages()).body())
+ .contains("has submitted this change");
+ }
+
private void assertDeleteRef(RemoteRefUpdate.Status expectedStatus) throws Exception {
BranchInput in = new BranchInput();
in.ref = "refs/heads/test";
diff --git a/javatests/com/google/gerrit/acceptance/git/RefAdvertisementIT.java b/javatests/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
index 92770ba..194f5f9 100644
--- a/javatests/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
+++ b/javatests/com/google/gerrit/acceptance/git/RefAdvertisementIT.java
@@ -1434,7 +1434,6 @@
* Assert that refs seen by a non-admin user match the expected refs.
*
* @param expectedRefs expected refs.
- * @throws Exception
*/
private void assertUploadPackRefs(String... expectedRefs) throws Exception {
assertRefs(project, user, true, expectedRefs);
diff --git a/javatests/com/google/gerrit/acceptance/rest/CancellationIT.java b/javatests/com/google/gerrit/acceptance/rest/CancellationIT.java
index 9f294b3..ed5e559 100644
--- a/javatests/com/google/gerrit/acceptance/rest/CancellationIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/CancellationIT.java
@@ -28,7 +28,6 @@
import com.google.gerrit.server.cancellation.RequestCancelledException;
import com.google.gerrit.server.cancellation.RequestStateProvider;
import com.google.gerrit.server.events.CommitReceivedEvent;
-import com.google.gerrit.server.experiments.ExperimentFeaturesConstants;
import com.google.gerrit.server.git.validators.CommitValidationException;
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.CommitValidationMessage;
@@ -232,6 +231,32 @@
@Test
@GerritConfig(name = "deadline.default.timeout", value = "1ms")
+ @GerritConfig(
+ name = "deadline.default.excludedRequestUriPattern",
+ value = "/projects/non-matching")
+ public void abortIfServerDeadlineExceeded_excludedRequestUriPattern() throws Exception {
+ RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
+ assertThat(response.getStatusCode()).isEqualTo(SC_REQUEST_TIMEOUT);
+ assertThat(response.getEntityContent())
+ .isEqualTo("Server Deadline Exceeded\n\ndefault.timeout=1ms");
+ }
+
+ @Test
+ @GerritConfig(name = "deadline.default.timeout", value = "1ms")
+ @GerritConfig(name = "deadline.default.requestUriPattern", value = "/projects/.*")
+ @GerritConfig(
+ name = "deadline.default.excludedRequestUriPattern",
+ value = "/projects/non-matching")
+ public void abortIfServerDeadlineExceeded_requestUriPatternAndExcludedRequestUriPattern()
+ throws Exception {
+ RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
+ assertThat(response.getStatusCode()).isEqualTo(SC_REQUEST_TIMEOUT);
+ assertThat(response.getEntityContent())
+ .isEqualTo("Server Deadline Exceeded\n\ndefault.timeout=1ms");
+ }
+
+ @Test
+ @GerritConfig(name = "deadline.default.timeout", value = "1ms")
@GerritConfig(name = "deadline.default.projectPattern", value = ".*new.*")
public void abortIfServerDeadlineExceeded_projectPattern() throws Exception {
RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
@@ -268,6 +293,24 @@
@Test
@GerritConfig(name = "deadline.default.timeout", value = "1ms")
+ @GerritConfig(name = "deadline.default.excludedRequestUriPattern", value = "/projects/.*")
+ public void nonMatchingServerDeadlineIsIgnored_excludedRequestUriPattern() throws Exception {
+ RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
+ response.assertCreated();
+ }
+
+ @Test
+ @GerritConfig(name = "deadline.default.timeout", value = "1ms")
+ @GerritConfig(name = "deadline.default.requestUriPattern", value = "/projects/.*")
+ @GerritConfig(name = "deadline.default.excludedRequestUriPattern", value = "/projects/.*new")
+ public void nonMatchingServerDeadlineIsIgnored_requestUriPatternAndExcludedRequestUriPattern()
+ throws Exception {
+ RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
+ response.assertCreated();
+ }
+
+ @Test
+ @GerritConfig(name = "deadline.default.timeout", value = "1ms")
@GerritConfig(name = "deadline.default.projectPattern", value = ".*foo.*")
public void nonMatchingServerDeadlineIsIgnored_projectPattern() throws Exception {
RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
@@ -340,6 +383,14 @@
@Test
@GerritConfig(name = "deadline.default.timeout", value = "1ms")
+ @GerritConfig(name = "deadline.default.excludedRequestUriPattern", value = "][")
+ public void invalidServerDeadlineIsIgnored_invalidExcludedRequestUriPattern() throws Exception {
+ RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
+ response.assertCreated();
+ }
+
+ @Test
+ @GerritConfig(name = "deadline.default.timeout", value = "1ms")
@GerritConfig(name = "deadline.default.projectPattern", value = "][")
public void invalidServerDeadlineIsIgnored_invalidProjectPattern() throws Exception {
RestResponse response = adminRestSession.putWithHeaders("/projects/" + name("new"));
@@ -530,9 +581,6 @@
@Test
@GerritConfig(name = "receive.timeout", value = "1ms")
- @GerritConfig(
- name = "experiments.enabled",
- value = ExperimentFeaturesConstants.GERRIT_BACKEND_REQUEST_FEATURE_ENABLE_PUSH_CANCELLATION)
public void abortPushIfTimeoutExceeded() throws Exception {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/for/master");
@@ -541,18 +589,7 @@
@Test
@GerritConfig(name = "receive.timeout", value = "1ms")
- public void pushNotAbortedIfTimeoutExceededAndExperimentNotEnabled() throws Exception {
- PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
- PushOneCommit.Result r = push.to("refs/for/master");
- r.assertOkStatus();
- }
-
- @Test
- @GerritConfig(name = "receive.timeout", value = "1ms")
@GerritConfig(name = "deadline.default.timeout", value = "10s")
- @GerritConfig(
- name = "experiments.enabled",
- value = ExperimentFeaturesConstants.GERRIT_BACKEND_REQUEST_FEATURE_ENABLE_PUSH_CANCELLATION)
public void receiveTimeoutTakesPrecedence() throws Exception {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/for/master");
@@ -622,9 +659,6 @@
@Test
@GerritConfig(name = "receive.timeout", value = "1ms")
- @GerritConfig(
- name = "experiments.enabled",
- value = ExperimentFeaturesConstants.GERRIT_BACKEND_REQUEST_FEATURE_ENABLE_PUSH_CANCELLATION)
public void clientProvidedDeadlineOnPushDoesntOverrideServerTimeout() throws Exception {
List<String> pushOptions = new ArrayList<>();
pushOptions.add("deadline=10m");
diff --git a/javatests/com/google/gerrit/acceptance/rest/TraceIT.java b/javatests/com/google/gerrit/acceptance/rest/TraceIT.java
index 530f2ec..7e40b2b 100644
--- a/javatests/com/google/gerrit/acceptance/rest/TraceIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/TraceIT.java
@@ -711,6 +711,94 @@
}
@Test
+ @GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/.*")
+ public void traceExcludedRequestUriPattern() throws Exception {
+ TraceValidatingProjectCreationValidationListener projectCreationListener =
+ new TraceValidatingProjectCreationValidationListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(projectCreationListener)) {
+ RestResponse response = adminRestSession.put("/projects/xyz1");
+ assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
+ assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
+ assertThat(projectCreationListener.traceId).isNull();
+ assertThat(projectCreationListener.isLoggingForced).isFalse();
+
+ // The logging tag with the project name is also set if tracing is off.
+ assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz1");
+ }
+ }
+
+ @Test
+ @GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/no-match")
+ public void traceExcludedRequestUriPatternNoMatch() throws Exception {
+ TraceValidatingProjectCreationValidationListener projectCreationListener =
+ new TraceValidatingProjectCreationValidationListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(projectCreationListener)) {
+ RestResponse response = adminRestSession.put("/projects/xyz3");
+ assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
+ assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
+ assertThat(projectCreationListener.traceId).isEqualTo("issue123");
+ assertThat(projectCreationListener.isLoggingForced).isTrue();
+ assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz3");
+ }
+ }
+
+ @Test
+ @GerritConfig(name = "tracing.issue123.requestUriPattern", value = "/projects/.*")
+ @GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/xyz2")
+ public void traceRequestUriPatternAndExcludedRequestUriPattern() throws Exception {
+ TraceValidatingProjectCreationValidationListener projectCreationListener =
+ new TraceValidatingProjectCreationValidationListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(projectCreationListener)) {
+ RestResponse response = adminRestSession.put("/projects/xyz2");
+ assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
+ assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
+ assertThat(projectCreationListener.traceId).isNull();
+ assertThat(projectCreationListener.isLoggingForced).isFalse();
+
+ // The logging tag with the project name is also set if tracing is off.
+ assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz2");
+ }
+ }
+
+ @Test
+ @GerritConfig(name = "tracing.issue123.requestUriPattern", value = "/projects/.*")
+ @GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "/projects/no-match")
+ public void traceRequestUriPatternAndExcludedRequestUriPatternNoMatch() throws Exception {
+ TraceValidatingProjectCreationValidationListener projectCreationListener =
+ new TraceValidatingProjectCreationValidationListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(projectCreationListener)) {
+ RestResponse response = adminRestSession.put("/projects/xyz3");
+ assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
+ assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
+ assertThat(projectCreationListener.traceId).isEqualTo("issue123");
+ assertThat(projectCreationListener.isLoggingForced).isTrue();
+ assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz3");
+ }
+ }
+
+ @Test
+ @GerritConfig(name = "tracing.issue123.excludedRequestUriPattern", value = "][")
+ public void traceExcludedRequestUriInvalidRegEx() throws Exception {
+ TraceValidatingProjectCreationValidationListener projectCreationListener =
+ new TraceValidatingProjectCreationValidationListener();
+ try (Registration registration =
+ extensionRegistry.newRegistration().add(projectCreationListener)) {
+ RestResponse response = adminRestSession.put("/projects/xyz4");
+ assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
+ assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
+ assertThat(projectCreationListener.traceId).isNull();
+ assertThat(projectCreationListener.isLoggingForced).isFalse();
+
+ // The logging tag with the project name is also set if tracing is off.
+ assertThat(projectCreationListener.tags.get("project")).containsExactly("xyz4");
+ }
+ }
+
+ @Test
@GerritConfig(name = "retry.retryWithTraceOnFailure", value = "true")
public void noAutoRetryIfExceptionCausesNormalRetrying() throws Exception {
String changeId = createChange().getChangeId();
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/CreateChangeIT.java b/javatests/com/google/gerrit/acceptance/rest/change/CreateChangeIT.java
index 92a4028..b0a14cf 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/CreateChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/CreateChangeIT.java
@@ -1181,7 +1181,6 @@
* @param branchB name of second branch to create
* @param fileB name of file to commit to branchB
* @return A {@code Map} of branchName => commit result.
- * @throws Exception
*/
private Map<String, Result> changeInTwoBranches(
String branchA, String fileA, String branchB, String fileB) throws Exception {
@@ -1201,7 +1200,6 @@
* @param fileB name of file to commit to branchB
* @param contentB file content to commit to branchB
* @return A {@code Map} of branchName => commit result.
- * @throws Exception
*/
private Map<String, Result> changeInTwoBranches(
String branchA,
diff --git a/javatests/com/google/gerrit/acceptance/rest/util/RestApiCallHelper.java b/javatests/com/google/gerrit/acceptance/rest/util/RestApiCallHelper.java
index f98fb45..55735fc 100644
--- a/javatests/com/google/gerrit/acceptance/rest/util/RestApiCallHelper.java
+++ b/javatests/com/google/gerrit/acceptance/rest/util/RestApiCallHelper.java
@@ -29,13 +29,13 @@
/** Helper to execute REST API calls using the HTTP client. */
@Ignore
public class RestApiCallHelper {
- /** @see #execute(RestSession, List, BeforeRestCall, String...) */
+ /** See {@link #execute(RestSession, List, BeforeRestCall, String...)} */
public static void execute(RestSession restSession, List<RestCall> restCalls, String... args)
throws Exception {
execute(restSession, restCalls, () -> {}, args);
}
- /** @see #execute(RestSession, List, BeforeRestCall, String...) */
+ /** See {@link #execute(RestSession, RestCall, String...)} */
public static void execute(
RestSession restSession,
List<RestCall> restCalls,
diff --git a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java
index 89074b7..80cdad8 100644
--- a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java
@@ -224,12 +224,14 @@
String ps1 = result.getCommit().name();
CommentInput comment =
- CommentsUtil.newCommentWithOnlyMandatoryFields(PATCHSET_LEVEL, "comment");
+ CommentsUtil.newCommentWithOnlyMandatoryFields(
+ PATCHSET_LEVEL, "The change looks good, LGTM");
CommentsUtil.addComments(gApi, changeId, ps1, comment);
String emailBody = Iterables.getOnlyElement(email.getMessages()).body();
assertThat(emailBody).contains("Patchset");
assertThat(emailBody).doesNotContain("/PATCHSET_LEVEL");
+ assertThat(emailBody).contains("The change looks good, LGTM");
}
@Test
diff --git a/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java b/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
index 74dfa04..e778a5c 100644
--- a/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/change/GetRelatedIT.java
@@ -45,9 +45,9 @@
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.index.IndexConfig;
+import com.google.gerrit.server.change.GetRelatedChangesUtil;
import com.google.gerrit.server.query.change.ChangeData;
import com.google.gerrit.server.restapi.change.ChangesCollection;
-import com.google.gerrit.server.restapi.change.GetRelated;
import com.google.gerrit.server.update.BatchUpdate;
import com.google.gerrit.server.update.BatchUpdateOp;
import com.google.gerrit.server.update.ChangeContext;
@@ -573,7 +573,7 @@
ChangeData cd = getChange(last);
assertThat(cd.patchSets()).hasSize(n);
- assertThat(GetRelated.getAllGroups(cd.notes(), psUtil)).hasSize(n);
+ assertThat(GetRelatedChangesUtil.getAllGroups(cd.notes().getPatchSets().values())).hasSize(n);
assertRelated(cd.change().currentPatchSetId());
}
diff --git a/javatests/com/google/gerrit/acceptance/server/query/ApprovalQueryIT.java b/javatests/com/google/gerrit/acceptance/server/query/ApprovalQueryIT.java
index 9392219..b4d9558 100644
--- a/javatests/com/google/gerrit/acceptance/server/query/ApprovalQueryIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/query/ApprovalQueryIT.java
@@ -269,6 +269,7 @@
.key(PatchSetApproval.key(psId, approver, LabelId.create("Code-Review")))
.value(value)
.build();
- return ApprovalContext.create(changeNotes, approval, newPsId, changeKind);
+ return ApprovalContext.create(
+ changeNotes, approval, changeNotes.getPatchSets().get(newPsId), changeKind);
}
}
diff --git a/javatests/com/google/gerrit/acceptance/ssh/AbstractIndexTests.java b/javatests/com/google/gerrit/acceptance/ssh/AbstractIndexTests.java
index f866fff..3b38bad 100644
--- a/javatests/com/google/gerrit/acceptance/ssh/AbstractIndexTests.java
+++ b/javatests/com/google/gerrit/acceptance/ssh/AbstractIndexTests.java
@@ -38,7 +38,6 @@
public abstract class AbstractIndexTests extends AbstractDaemonTest {
@Inject private ExtensionRegistry extensionRegistry;
- /** @param injector injector */
public void configureIndex(Injector injector) {}
@Test
diff --git a/javatests/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverterTest.java b/javatests/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverterTest.java
index bf39ff8..d332f8a 100644
--- a/javatests/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverterTest.java
+++ b/javatests/com/google/gerrit/entities/converter/PatchSetApprovalProtoConverterTest.java
@@ -49,6 +49,7 @@
.tag("tag-21")
.realAccountId(Account.id(612))
.postSubmit(true)
+ .copied(true)
.build();
Entities.PatchSetApproval proto = protoConverter.toProto(patchSetApproval);
@@ -68,6 +69,7 @@
.setTag("tag-21")
.setRealAccountId(Entities.Account_Id.newBuilder().setId(612))
.setPostSubmit(true)
+ .setCopied(true)
.build();
assertThat(proto).isEqualTo(expectedProto);
}
@@ -99,6 +101,7 @@
.setGranted(987654L)
// This value can't be unset when our entity class is given.
.setPostSubmit(false)
+ .setCopied(false)
.build();
assertThat(proto).isEqualTo(expectedProto);
}
@@ -115,6 +118,7 @@
.tag("tag-21")
.realAccountId(Account.id(612))
.postSubmit(true)
+ .copied(true)
.build();
PatchSetApproval convertedPatchSetApproval =
@@ -162,6 +166,7 @@
assertThat(patchSetApproval.value()).isEqualTo(0);
assertThat(patchSetApproval.granted()).isEqualTo(new Timestamp(0));
assertThat(patchSetApproval.postSubmit()).isEqualTo(false);
+ assertThat(patchSetApproval.copied()).isEqualTo(false);
}
/** See {@link SerializedClassSubject} for background and what to do if this test fails. */
@@ -176,6 +181,7 @@
.put("tag", new TypeLiteral<Optional<String>>() {}.getType())
.put("realAccountId", Account.Id.class)
.put("postSubmit", boolean.class)
+ .put("copied", boolean.class)
.put("toBuilder", PatchSetApproval.Builder.class)
.build());
}
diff --git a/javatests/com/google/gerrit/extensions/common/ChangeInfoDifferTest.java b/javatests/com/google/gerrit/extensions/common/ChangeInfoDifferTest.java
index 4352fe8..024e35e 100644
--- a/javatests/com/google/gerrit/extensions/common/ChangeInfoDifferTest.java
+++ b/javatests/com/google/gerrit/extensions/common/ChangeInfoDifferTest.java
@@ -58,6 +58,17 @@
}
@Test
+ public void getDiff_returnsOldAndNewChangeInfos() {
+ ChangeInfo oldChangeInfo = createChangeInfoWithTopic("topic");
+ ChangeInfo newChangeInfo = createChangeInfoWithTopic(oldChangeInfo.topic);
+
+ ChangeInfoDifference diff = ChangeInfoDiffer.getDifference(oldChangeInfo, newChangeInfo);
+
+ assertThat(diff.oldChangeInfo()).isEqualTo(oldChangeInfo);
+ assertThat(diff.newChangeInfo()).isEqualTo(newChangeInfo);
+ }
+
+ @Test
public void getDiff_givenUnchangedTopic_returnsNullTopics() {
ChangeInfo oldChangeInfo = createChangeInfoWithTopic("topic");
ChangeInfo newChangeInfo = createChangeInfoWithTopic(oldChangeInfo.topic);
diff --git a/javatests/com/google/gerrit/httpd/ProjectBasicAuthFilterTest.java b/javatests/com/google/gerrit/httpd/ProjectBasicAuthFilterTest.java
index 162a171..da6092b 100644
--- a/javatests/com/google/gerrit/httpd/ProjectBasicAuthFilterTest.java
+++ b/javatests/com/google/gerrit/httpd/ProjectBasicAuthFilterTest.java
@@ -101,7 +101,7 @@
req = new FakeHttpServletRequest("gerrit.example.com", 80, "", "");
res = new FakeHttpServletResponse();
- extIdKeyFactory = new ExternalIdKeyFactory(authConfig);
+ extIdKeyFactory = new ExternalIdKeyFactory(new ExternalIdKeyFactory.ConfigImpl(authConfig));
extIdFactory = new ExternalIdFactory(extIdKeyFactory);
authRequestFactory = new AuthRequest.Factory(extIdKeyFactory);
pwdVerifier = new PasswordVerifier(extIdKeyFactory);
diff --git a/javatests/com/google/gerrit/mail/HtmlParserTest.java b/javatests/com/google/gerrit/mail/HtmlParserTest.java
index a7ff172..bb60fd8 100644
--- a/javatests/com/google/gerrit/mail/HtmlParserTest.java
+++ b/javatests/com/google/gerrit/mail/HtmlParserTest.java
@@ -176,7 +176,6 @@
/**
* Create an html message body with the specified comments.
*
- * @param changeMessage
* @param c1 Comment in reply to first comment.
* @param c2 Comment in reply to second comment.
* @param c3 Comment in reply to third comment.
diff --git a/javatests/com/google/gerrit/mail/TextParserTest.java b/javatests/com/google/gerrit/mail/TextParserTest.java
index caed5f8..d3e7447 100644
--- a/javatests/com/google/gerrit/mail/TextParserTest.java
+++ b/javatests/com/google/gerrit/mail/TextParserTest.java
@@ -181,7 +181,6 @@
/**
* Create a plaintext message body with the specified comments.
*
- * @param changeMessage
* @param c1 Comment in reply to first inline comment.
* @param c2 Comment in reply to second inline comment.
* @param c3 Comment in reply to third inline comment.
diff --git a/javatests/com/google/gerrit/server/CancellationMetricsTest.java b/javatests/com/google/gerrit/server/RequestInfoTest.java
similarity index 96%
rename from javatests/com/google/gerrit/server/CancellationMetricsTest.java
rename to javatests/com/google/gerrit/server/RequestInfoTest.java
index 2343c71..fafe856 100644
--- a/javatests/com/google/gerrit/server/CancellationMetricsTest.java
+++ b/javatests/com/google/gerrit/server/RequestInfoTest.java
@@ -18,7 +18,7 @@
import org.junit.Test;
-public class CancellationMetricsTest {
+public class RequestInfoTest {
@Test
public void redactRequestUri() throws Exception {
// test with valid request URIs
@@ -52,6 +52,6 @@
}
public static String redact(String uri) {
- return CancellationMetrics.redactRequestUri(uri);
+ return RequestInfo.redactRequestUri(uri);
}
}
diff --git a/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java b/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
index 058384e..7d9db0b 100644
--- a/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
+++ b/javatests/com/google/gerrit/server/account/externalids/AllExternalIdsTest.java
@@ -25,24 +25,27 @@
import com.google.gerrit.server.account.externalids.AllExternalIds.Serializer;
import com.google.gerrit.server.cache.proto.Cache.AllExternalIdsProto;
import com.google.gerrit.server.cache.proto.Cache.AllExternalIdsProto.ExternalIdProto;
-import com.google.gerrit.server.config.AuthConfig;
import com.google.inject.TypeLiteral;
import java.lang.reflect.Type;
import java.util.Arrays;
import org.eclipse.jgit.lib.ObjectId;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
public class AllExternalIdsTest {
- private AuthConfig authConfig;
private ExternalIdFactory externalIdFactory;
@Before
public void setUp() throws Exception {
- authConfig = Mockito.mock(AuthConfig.class);
- Mockito.when(authConfig.isUserNameCaseInsensitive()).thenReturn(false);
- externalIdFactory = new ExternalIdFactory(new ExternalIdKeyFactory(authConfig));
+ externalIdFactory =
+ new ExternalIdFactory(
+ new ExternalIdKeyFactory(
+ new ExternalIdKeyFactory.Config() {
+ @Override
+ public boolean isUserNameCaseInsensitive() {
+ return false;
+ }
+ }));
}
@Test
diff --git a/javatests/com/google/gerrit/server/account/externalids/ExternalIDCacheLoaderTest.java b/javatests/com/google/gerrit/server/account/externalids/ExternalIDCacheLoaderTest.java
index fab90d4..4f8c559 100644
--- a/javatests/com/google/gerrit/server/account/externalids/ExternalIDCacheLoaderTest.java
+++ b/javatests/com/google/gerrit/server/account/externalids/ExternalIDCacheLoaderTest.java
@@ -28,7 +28,6 @@
import com.google.gerrit.server.account.externalids.testing.ExternalIdTestUtil;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.AllUsersNameProvider;
-import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
@@ -57,14 +56,20 @@
private GitRepositoryManager repoManager = new InMemoryRepositoryManager();
private ExternalIdReader externalIdReader;
private ExternalIdReader externalIdReaderSpy;
- private AuthConfig authConfig;
+
private ExternalIdFactory externalIdFactory;
@Before
public void setUp() throws Exception {
- authConfig = Mockito.mock(AuthConfig.class);
- Mockito.when(authConfig.isUserNameCaseInsensitive()).thenReturn(false);
- externalIdFactory = new ExternalIdFactory(new ExternalIdKeyFactory(authConfig));
+ externalIdFactory =
+ new ExternalIdFactory(
+ new ExternalIdKeyFactory(
+ new ExternalIdKeyFactory.Config() {
+ @Override
+ public boolean isUserNameCaseInsensitive() {
+ return false;
+ }
+ }));
externalIdCache = CacheBuilder.newBuilder().build();
repoManager.createRepository(ALL_USERS).close();
externalIdReader =
diff --git a/javatests/com/google/gerrit/server/logging/PerformanceLogContextTest.java b/javatests/com/google/gerrit/server/logging/PerformanceLogContextTest.java
index ed4325d..fefa066 100644
--- a/javatests/com/google/gerrit/server/logging/PerformanceLogContextTest.java
+++ b/javatests/com/google/gerrit/server/logging/PerformanceLogContextTest.java
@@ -34,6 +34,7 @@
import com.google.inject.Injector;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jgit.lib.Config;
import org.junit.After;
import org.junit.Before;
@@ -110,9 +111,10 @@
@Test
public void
- traceTimersInsidePerformanceLogContextDoNotCreatePerformanceLogIfNoPerformanceLoggers() {
+ traceTimersInsidePerformanceLogContextDoNotCreatePerformanceLogIfNoPerformanceLoggers()
+ throws Exception {
// Remove test performance logger so that there are no registered performance loggers.
- performanceLoggerRegistrationHandle.remove();
+ removeAllPerformanceLoggers();
assertThat(LoggingContext.getInstance().isPerformanceLogging()).isFalse();
assertThat(LoggingContext.getInstance().getPerformanceLogRecords()).isEmpty();
@@ -277,9 +279,10 @@
@Test
public void
- timerMetricssInsidePerformanceLogContextDoNotCreatePerformanceLogIfNoPerformanceLoggers() {
- // Remove test performance logger so that there are no registered performance loggers.
- performanceLoggerRegistrationHandle.remove();
+ timerMetricssInsidePerformanceLogContextDoNotCreatePerformanceLogIfNoPerformanceLoggers()
+ throws Exception {
+ // Remove all performance loggers so that there are no registered performance loggers.
+ removeAllPerformanceLoggers();
assertThat(LoggingContext.getInstance().isPerformanceLogging()).isFalse();
assertThat(LoggingContext.getInstance().getPerformanceLogRecords()).isEmpty();
@@ -369,6 +372,12 @@
}
}
+ private void removeAllPerformanceLoggers() throws Exception {
+ java.lang.reflect.Field itemsField = DynamicSet.class.getDeclaredField("items");
+ itemsField.setAccessible(true);
+ ((CopyOnWriteArrayList<?>) itemsField.get(performanceLoggers)).clear();
+ }
+
@AutoValue
abstract static class PerformanceLogEntry {
static PerformanceLogEntry create(String operation, Metadata metadata) {
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesParserTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesParserTest.java
index 6a32fa1..dc9b9cd 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesParserTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesParserTest.java
@@ -153,6 +153,43 @@
}
@Test
+ public void parseCopiedApproval() throws Exception {
+ assertParseSucceeds(
+ "Update change\n"
+ + "\n"
+ + "Branch: refs/heads/master\n"
+ + "Change-id: I577fb248e474018276351785930358ec0450e9f7\n"
+ + "Patch-set: 1\n"
+ + "Copied-Label: Label1=+1 Account <1@gerrit>,Other Account <2@Gerrit>\n"
+ + "Copied-Label: Label2=+1 Account <1@gerrit>\n"
+ + "Copied-Label: Label3=+1 Account <1@gerrit>,Other Account <2@Gerrit> :\"tag\"\n"
+ + "Copied-Label: Label4=+1 Account <1@Gerrit> :\"tag with characters %^#@^( *::!\"\n"
+ + "Subject: This is a test change\n");
+ assertParseSucceeds(
+ "Update change\n"
+ + "\n"
+ + "Branch: refs/heads/master\n"
+ + "Change-id: I577fb248e474018276351785930358ec0450e9f7\n"
+ + "Patch-set: 1\n"
+ + "Label: -Label1\n"
+ + "Label: -Label4 Account <1@gerrit>\n"
+ + "Subject: This is a test change\n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: Label1=X\n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: Label1 = 1\n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: X+Y\n");
+ assertParseFails(
+ "Update change\n\nPatch-set: 1\nCopied-Label: Label1 Other Account <2@gerrit>\n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: -Label!1\n");
+ assertParseFails(
+ "Update change\n\nPatch-set: 1\nCopied-Label: -Label!1 Other Account <2@gerrit>\n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: -Label1\n");
+ assertParseFails(
+ "Update change\n\nPatch-set: 1\nCopied-Label: Label1 Other Account <2@gerrit>,Other "
+ + "Account <2@gerrit>,Other Account <2@gerrit> \n");
+ assertParseFails("Update change\n\nPatch-set: 1\nCopied-Label: Label1 non-user\n");
+ }
+
+ @Test
public void parseSubmitRecords() throws Exception {
assertParseSucceeds(
"Update change\n"
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
index 048e3fd..52eaf11 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesStateTest.java
@@ -375,6 +375,7 @@
PatchSetApproval.key(
PatchSet.id(ID, 1), Account.id(2001), LabelId.create(LabelId.CODE_REVIEW)))
.value(1)
+ .tag("tag")
.granted(new Timestamp(1212L))
.build();
Entities.PatchSetApproval psa1 = PatchSetApprovalProtoConverter.INSTANCE.toProto(a1);
@@ -386,11 +387,13 @@
PatchSetApproval.key(
PatchSet.id(ID, 1), Account.id(2002), LabelId.create(LabelId.VERIFIED)))
.value(-1)
+ .tag("tag")
+ .copied(true)
.granted(new Timestamp(3434L))
.build();
Entities.PatchSetApproval psa2 = PatchSetApprovalProtoConverter.INSTANCE.toProto(a2);
ByteString a2Bytes = Protos.toByteString(psa2);
- assertThat(a2Bytes.size()).isEqualTo(49);
+ assertThat(a2Bytes.size()).isEqualTo(56);
assertThat(a2Bytes).isNotEqualTo(a1Bytes);
assertRoundTrip(
@@ -980,6 +983,7 @@
.put("tag", new TypeLiteral<Optional<String>>() {}.getType())
.put("realAccountId", Account.Id.class)
.put("postSubmit", boolean.class)
+ .put("copied", boolean.class)
.put("toBuilder", PatchSetApproval.Builder.class)
.build());
}
diff --git a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
index 9c2e9a9..4e7b3f3 100644
--- a/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
+++ b/javatests/com/google/gerrit/server/notedb/ChangeNotesTest.java
@@ -76,8 +76,6 @@
import org.junit.Test;
public class ChangeNotesTest extends AbstractChangeNotesTest {
- @Inject private DraftCommentNotes.Factory draftNotesFactory;
-
@Inject private ChangeNoteJson changeNoteJson;
@Test
@@ -514,6 +512,184 @@
}
@Test
+ public void copiedApprovals() throws Exception {
+ Change c = newChange();
+ ChangeUpdate update = newUpdate(c, changeOwner);
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.CODE_REVIEW)))
+ .value(1)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .tag("tag")
+ .realAccountId(otherUserId)
+ .build());
+ update.putApprovalFor(otherUserId, LabelId.CODE_REVIEW, (short) -1);
+ update.commit();
+
+ // Only the non copied approval is reachable by getApprovals.
+ ChangeNotes notes = newNotes(c);
+ PatchSetApproval approval =
+ Iterables.getOnlyElement(notes.getApprovals().get(c.currentPatchSetId()));
+ assertThat(approval.accountId()).isEqualTo(otherUser.getAccountId());
+ assertThat(approval.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(approval.value()).isEqualTo((short) -1);
+ assertThat(approval.copied()).isFalse();
+
+ // Get approvals with copied gets all of the approvals (including copied).
+ ImmutableList<PatchSetApproval> approvals =
+ notes.getApprovalsWithCopied().get(c.currentPatchSetId()).stream()
+ .sorted(comparing(a -> a.accountId().get()))
+ .collect(toImmutableList());
+ assertThat(approvals).hasSize(2);
+
+ PatchSetApproval copied = approvals.get(0);
+ assertThat(copied.accountId()).isEqualTo(changeOwner.getAccountId());
+ assertThat(copied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(copied.value()).isEqualTo((short) 1);
+ assertThat(copied.tag()).hasValue("tag");
+ assertThat(copied.accountId()).isEqualTo(changeOwner.getAccountId());
+ assertThat(copied.realAccountId()).isEqualTo(otherUserId);
+ assertThat(copied.copied()).isTrue();
+
+ PatchSetApproval nonCopied = approvals.get(1);
+ assertThat(nonCopied.accountId()).isEqualTo(otherUserId);
+ assertThat(nonCopied.realAccountId()).isEqualTo(otherUserId);
+ assertThat(nonCopied.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(nonCopied.value()).isEqualTo((short) -1);
+ }
+
+ @Test
+ public void copiedApprovalsCanBeRemoved() throws Exception {
+ Change c = newChange();
+ ChangeUpdate update = newUpdate(c, changeOwner);
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.CODE_REVIEW)))
+ .value(1)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .build());
+ update.commit();
+
+ update.removeApproval(LabelId.CODE_REVIEW);
+ update.commit();
+
+ ChangeNotes notes = newNotes(c);
+ PatchSetApproval approval =
+ Iterables.getOnlyElement(notes.getApprovalsWithCopied().get(c.currentPatchSetId()));
+ assertThat(approval.accountId()).isEqualTo(changeOwner.getAccountId());
+ assertThat(approval.label()).isEqualTo(LabelId.CODE_REVIEW);
+ // The vote got removed since the latest patch-set only has one vote and it's "0". The copied
+ // approval will never have a "0" vote, but it can be overridden by a "0" vote of a
+ // non-copied approval.
+ assertThat(approval.value()).isEqualTo((short) 0);
+ assertThat(approval.copied()).isFalse();
+ }
+
+ @Test
+ public void copiedApprovalsWithStrangeTags() throws Exception {
+ String strangeTag = "!@#$%^\0&*):\" \n: \r\"#$@,. :";
+ Change c = newChange();
+ ChangeUpdate update = newUpdate(c, changeOwner);
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.CODE_REVIEW)))
+ .value(1)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .tag(strangeTag)
+ .build());
+ update.commit();
+
+ ChangeNotes notes = newNotes(c);
+ PatchSetApproval approval =
+ Iterables.getOnlyElement(notes.getApprovalsWithCopied().get(c.currentPatchSetId()));
+ assertThat(approval.accountId()).isEqualTo(changeOwner.getAccountId());
+ assertThat(approval.label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(approval.value()).isEqualTo((short) 1);
+ assertThat(approval.tag()).hasValue(NoteDbUtil.sanitizeFooter(strangeTag));
+ assertThat(approval.copied()).isTrue();
+ }
+
+ @Test
+ public void copiedApprovalsPostSubmit() throws Exception {
+ Change c = newChange();
+ SubmissionId submissionId = new SubmissionId(c);
+ ChangeUpdate update = newUpdate(c, changeOwner);
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.CODE_REVIEW)))
+ .value(1)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .build());
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.VERIFIED)))
+ .value(1)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .build());
+ update.commit();
+
+ update = newUpdate(c, changeOwner);
+ update.merge(
+ submissionId,
+ ImmutableList.of(
+ submitRecord(
+ "NOT_READY",
+ null,
+ submitLabel(LabelId.VERIFIED, "OK", changeOwner.getAccountId()),
+ submitLabel(LabelId.CODE_REVIEW, "NEED", null))));
+ update.commit();
+
+ update = newUpdate(c, changeOwner);
+ update.putCopiedApproval(
+ PatchSetApproval.builder()
+ .key(
+ PatchSetApproval.key(
+ c.currentPatchSetId(),
+ changeOwner.getAccountId(),
+ LabelId.create(LabelId.CODE_REVIEW)))
+ .value(2)
+ .copied(true)
+ .granted(TimeUtil.nowTs())
+ .build());
+ update.commit();
+
+ ChangeNotes notes = newNotes(c);
+ List<PatchSetApproval> approvals = Lists.newArrayList(notes.getApprovalsWithCopied().values());
+ assertThat(approvals).hasSize(2);
+ assertThat(approvals.get(0).label()).isEqualTo(LabelId.VERIFIED);
+ assertThat(approvals.get(0).value()).isEqualTo((short) 1);
+ assertThat(approvals.get(0).postSubmit()).isFalse();
+ assertThat(approvals.get(1).label()).isEqualTo(LabelId.CODE_REVIEW);
+ assertThat(approvals.get(1).value()).isEqualTo((short) 2);
+ assertThat(approvals.get(1).postSubmit()).isTrue();
+ }
+
+ @Test
public void multipleReviewers() throws Exception {
Change c = newChange();
ChangeUpdate update = newUpdate(c, changeOwner);
@@ -2802,86 +2978,6 @@
}
@Test
- public void filterOutAndFixUpZombieDraftComments() throws Exception {
- Change c = newChange();
- ObjectId commitId1 = ObjectId.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
- CommentRange range = new CommentRange(1, 1, 2, 1);
- PatchSet.Id ps1 = c.currentPatchSetId();
- short side = (short) 1;
-
- ChangeUpdate update = newUpdate(c, otherUser);
- Timestamp now = TimeUtil.nowTs();
- HumanComment comment1 =
- newComment(
- ps1,
- "file1",
- "uuid1",
- range,
- range.getEndLine(),
- otherUser,
- null,
- now,
- "comment on ps1",
- side,
- commitId1,
- false);
- HumanComment comment2 =
- newComment(
- ps1,
- "file2",
- "uuid2",
- range,
- range.getEndLine(),
- otherUser,
- null,
- now,
- "another comment",
- side,
- commitId1,
- false);
- update.putComment(HumanComment.Status.DRAFT, comment1);
- update.putComment(HumanComment.Status.DRAFT, comment2);
- update.commit();
-
- String refName = refsDraftComments(c.getId(), otherUserId);
- ObjectId oldDraftId = exactRefAllUsers(refName);
-
- update = newUpdate(c, otherUser);
- update.setPatchSetId(ps1);
- update.putComment(HumanComment.Status.PUBLISHED, comment2);
- update.commit();
- assertThat(exactRefAllUsers(refName)).isNotNull();
- assertThat(exactRefAllUsers(refName)).isNotEqualTo(oldDraftId);
-
- // Re-add draft version of comment2 back to draft ref without updating
- // change ref. Simulates the case where deleting the draft failed
- // non-atomically after adding the published comment succeeded.
- ChangeDraftUpdate draftUpdate = newUpdate(c, otherUser).createDraftUpdateIfNull();
- draftUpdate.putComment(comment2);
- try (NoteDbUpdateManager manager = updateManagerFactory.create(c.getProject())) {
- manager.add(draftUpdate);
- manager.execute();
- }
-
- // Looking at drafts directly shows the zombie comment.
- DraftCommentNotes draftNotes = draftNotesFactory.create(c.getId(), otherUserId);
- assertThat(draftNotes.load().getComments().get(commitId1)).containsExactly(comment1, comment2);
-
- // Zombie comment is filtered out of drafts via ChangeNotes.
- ChangeNotes notes = newNotes(c);
- assertThat(notes.getDraftComments(otherUserId).get(commitId1)).containsExactly(comment1);
- assertThat(notes.getHumanComments().get(commitId1)).containsExactly(comment2);
-
- update = newUpdate(c, otherUser);
- update.setPatchSetId(ps1);
- update.putComment(HumanComment.Status.PUBLISHED, comment1);
- update.commit();
-
- // Updating an unrelated comment causes the zombie comment to get fixed up.
- assertThat(exactRefAllUsers(refName)).isNull();
- }
-
- @Test
public void updateCommentsInSequentialUpdates() throws Exception {
Change c = newChange();
CommentRange range = new CommentRange(1, 1, 2, 1);
diff --git a/javatests/com/google/gerrit/server/notedb/CommitRewriterTest.java b/javatests/com/google/gerrit/server/notedb/CommitRewriterTest.java
index 26e1881..19c2bcf 100644
--- a/javatests/com/google/gerrit/server/notedb/CommitRewriterTest.java
+++ b/javatests/com/google/gerrit/server/notedb/CommitRewriterTest.java
@@ -34,6 +34,7 @@
import com.google.gerrit.entities.RefNames;
import com.google.gerrit.entities.SubmitRecord;
import com.google.gerrit.json.OutputFormat;
+import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.ReviewerStatusUpdate;
import com.google.gerrit.server.notedb.ChangeNoteUtil.AttentionStatusInNoteDb;
@@ -837,6 +838,118 @@
}
@Test
+ public void fixRemoveVoteChangeMessageWithNoFooterLabel_matchByEmail() throws Exception {
+ Change c = newChange();
+ ChangeUpdate approvalUpdate = newUpdate(c, changeOwner);
+ approvalUpdate.putApproval(VERIFIED, (short) +2);
+
+ approvalUpdate.putApprovalFor(otherUserId, VERIFIED, (short) -1);
+ approvalUpdate.commit();
+ writeUpdate(
+ RefNames.changeMetaRef(c.getId()),
+ getChangeUpdateBody(
+ c, /*changeMessage=*/ "Removed Verified+2 by Renamed Change Owner <change@owner.com>"),
+ getAuthorIdent(changeOwner.getAccount()));
+
+ RunOptions options = new RunOptions();
+ options.dryRun = false;
+ BackfillResult result = rewriter.backfillProject(project, repo, options);
+ assertThat(result.fixedRefDiff.keySet()).containsExactly(RefNames.changeMetaRef(c.getId()));
+
+ List<String> commitHistoryDiff = commitHistoryDiff(result, c.getId());
+ assertThat(commitHistoryDiff)
+ .containsExactly(
+ "@@ -6 +6 @@\n"
+ + "-Removed Verified+2 by Renamed Change Owner <change@owner.com>\n"
+ + "+Removed Verified+2 by <GERRIT_ACCOUNT_1>\n");
+ BackfillResult secondRunResult = rewriter.backfillProject(project, repo, options);
+ assertThat(secondRunResult.fixedRefDiff.keySet()).isEmpty();
+ assertThat(secondRunResult.refsFailedToFix).isEmpty();
+ }
+
+ @Test
+ public void fixRemoveVoteChangeMessageWithNoFooterLabel_matchByName() throws Exception {
+ Change c = newChange();
+ ChangeUpdate approvalUpdate = newUpdate(c, changeOwner);
+ approvalUpdate.putApproval(VERIFIED, (short) +2);
+
+ approvalUpdate.putApprovalFor(otherUserId, VERIFIED, (short) -1);
+ approvalUpdate.commit();
+ writeUpdate(
+ RefNames.changeMetaRef(c.getId()),
+ getChangeUpdateBody(c, /*changeMessage=*/ "Removed Verified+2 by Change Owner"),
+ getAuthorIdent(changeOwner.getAccount()));
+
+ RunOptions options = new RunOptions();
+ options.dryRun = false;
+ BackfillResult result = rewriter.backfillProject(project, repo, options);
+ assertThat(result.fixedRefDiff.keySet()).containsExactly(RefNames.changeMetaRef(c.getId()));
+
+ List<String> commitHistoryDiff = commitHistoryDiff(result, c.getId());
+ assertThat(commitHistoryDiff)
+ .containsExactly(
+ "@@ -6 +6 @@\n"
+ + "-Removed Verified+2 by Change Owner\n"
+ + "+Removed Verified+2 by <GERRIT_ACCOUNT_1>\n");
+ BackfillResult secondRunResult = rewriter.backfillProject(project, repo, options);
+ assertThat(secondRunResult.fixedRefDiff.keySet()).isEmpty();
+ assertThat(secondRunResult.refsFailedToFix).isEmpty();
+ }
+
+ @Test
+ public void fixRemoveVoteChangeMessageWithNoFooterLabel_matchDuplicateAccounts()
+ throws Exception {
+ Account duplicateCodeOwner =
+ Account.builder(Account.id(4), TimeUtil.nowTs())
+ .setFullName(changeOwner.getName())
+ .setPreferredEmail("other@test.com")
+ .build();
+ accountCache.put(duplicateCodeOwner);
+ Change c = newChange();
+ ChangeUpdate approvalUpdate = newUpdate(c, changeOwner);
+ approvalUpdate.putApproval(VERIFIED, (short) +2);
+
+ approvalUpdate.putApprovalFor(duplicateCodeOwner.id(), VERIFIED, (short) -1);
+ approvalUpdate.commit();
+ writeUpdate(
+ RefNames.changeMetaRef(c.getId()),
+ getChangeUpdateBody(
+ c, /*changeMessage=*/ "Removed Verified+2 by Change Owner <other@test.com>"),
+ getAuthorIdent(changeOwner.getAccount()));
+ writeUpdate(
+ RefNames.changeMetaRef(c.getId()),
+ getChangeUpdateBody(
+ c, /*changeMessage=*/ "Removed Verified+2 by Change Owner <change@owner.com>"),
+ getAuthorIdent(changeOwner.getAccount()));
+ writeUpdate(
+ RefNames.changeMetaRef(c.getId()),
+ getChangeUpdateBody(
+ c, /*changeMessage=*/ "Removed Verified-1 by Change Owner <other@test.com>"),
+ getAuthorIdent(changeOwner.getAccount()));
+
+ RunOptions options = new RunOptions();
+ options.dryRun = false;
+ BackfillResult result = rewriter.backfillProject(project, repo, options);
+ assertThat(result.fixedRefDiff.keySet()).containsExactly(RefNames.changeMetaRef(c.getId()));
+
+ List<String> commitHistoryDiff = commitHistoryDiff(result, c.getId());
+ assertThat(commitHistoryDiff)
+ .containsExactly(
+ "@@ -6 +6 @@\n"
+ + "-Removed Verified+2 by Change Owner <other@test.com>\n"
+ + "+Removed Verified+2 by <GERRIT_ACCOUNT_4>\n",
+ "@@ -6 +6 @@\n"
+ + "-Removed Verified+2 by Change Owner <change@owner.com>\n"
+ + "+Removed Verified+2 by <GERRIT_ACCOUNT_1>\n",
+ "@@ -6 +6 @@\n"
+ + "-Removed Verified-1 by Change Owner <other@test.com>\n"
+ + "+Removed Verified-1 by <GERRIT_ACCOUNT_4>\n");
+ BackfillResult secondRunResult = rewriter.backfillProject(project, repo, options);
+ assertThat(secondRunResult.fixedRefDiff.keySet()).isEmpty();
+ assertThat(secondRunResult.refsFailedToFix).isEmpty();
+ }
+
+ @Test
public void fixRemoveVotesChangeMessage() throws Exception {
Change c = newChange();
ChangeUpdate approvalUpdate = newUpdate(c, changeOwner);
@@ -1491,19 +1604,20 @@
accountCache.put(duplicateReviewer);
Change c = newChange();
ImmutableList.Builder<ObjectId> commitsToFix = new ImmutableList.Builder<>();
- ChangeUpdate addReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate addReviewerUpdate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
addReviewerUpdate.putReviewer(reviewer.id(), REVIEWER);
addReviewerUpdate.commit();
- ChangeUpdate invalidOnAddReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate invalidOnAddReviewerUpdate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
invalidOnAddReviewerUpdate.setChangeMessage(
"Reviewer User who was added as reviewer owns the following files:\n"
+ " * file1.java\n"
+ " * file2.ts\n");
commitsToFix.add(invalidOnAddReviewerUpdate.commit());
- ChangeUpdate addOtherReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate addOtherReviewerUpdate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
addOtherReviewerUpdate.putReviewer(otherUserId, REVIEWER);
addOtherReviewerUpdate.commit();
- ChangeUpdate invalidOnAddReviewerMultipleReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate invalidOnAddReviewerMultipleReviewerUpdate =
+ newCodeOwnerAddReviewerUpdate(c, changeOwner);
invalidOnAddReviewerMultipleReviewerUpdate.setChangeMessage(
"Reviewer User who was added as reviewer owns the following files:\n"
+ " * file1.java\n"
@@ -1512,17 +1626,17 @@
+ "\nMissing Reviewer who was added as reviewer owns the following files:\n"
+ " * file4.java\n");
commitsToFix.add(invalidOnAddReviewerMultipleReviewerUpdate.commit());
- ChangeUpdate addDuplicateReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate addDuplicateReviewerUpdate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
addDuplicateReviewerUpdate.putReviewer(duplicateReviewer.id(), REVIEWER);
addDuplicateReviewerUpdate.commit();
// Reviewer name resolves to multiple accounts in the same change
- ChangeUpdate onAddReviewerUpdateWithDuplicate = newUpdate(c, changeOwner);
+ ChangeUpdate onAddReviewerUpdateWithDuplicate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
onAddReviewerUpdateWithDuplicate.setChangeMessage(
"Reviewer User who was added as reviewer owns the following files:\n"
+ " * file6.java\n");
commitsToFix.add(onAddReviewerUpdateWithDuplicate.commit());
- ChangeUpdate validOnAddReviewerUpdate = newUpdate(c, changeOwner);
+ ChangeUpdate validOnAddReviewerUpdate = newCodeOwnerAddReviewerUpdate(c, changeOwner);
validOnAddReviewerUpdate.setChangeMessage(
"Gerrit Account who was added as reviewer owns the following files:\n"
+ " * file1.java\n"
@@ -2137,6 +2251,13 @@
.collect(toImmutableList());
}
+ protected ChangeUpdate newCodeOwnerAddReviewerUpdate(Change c, CurrentUser user)
+ throws Exception {
+ ChangeUpdate update = newUpdate(c, user, true);
+ update.setTag("autogenerated:gerrit:code-owners:addReviewer");
+ return update;
+ }
+
private ImmutableList<String> commitHistoryDiff(BackfillResult result, Change.Id changeId) {
return result.fixedRefDiff.get(RefNames.changeMetaRef(changeId)).stream()
.map(CommitDiff::diff)
diff --git a/javatests/com/google/gerrit/server/permissions/SectionSortCacheTest.java b/javatests/com/google/gerrit/server/permissions/SectionSortCacheTest.java
index 9ec1625..0ba3b56 100644
--- a/javatests/com/google/gerrit/server/permissions/SectionSortCacheTest.java
+++ b/javatests/com/google/gerrit/server/permissions/SectionSortCacheTest.java
@@ -78,7 +78,7 @@
// Cache preserves relative order (reference equality) for identical elements
AccessSection[] expected = {sectionBClone, sectionB, sectionA, sectionAClone, sectionA};
for (int i = 0; i < sorted.size(); i++) {
- assert (sorted.get(i) == expected[i]);
+ assertThat(sorted.get(i)).isSameInstanceAs(expected[i]);
}
}
}
diff --git a/javatests/com/google/gerrit/server/project/SubmitRequirementsAdapterTest.java b/javatests/com/google/gerrit/server/project/SubmitRequirementsAdapterTest.java
index 2212fe7..05eb6e0 100644
--- a/javatests/com/google/gerrit/server/project/SubmitRequirementsAdapterTest.java
+++ b/javatests/com/google/gerrit/server/project/SubmitRequirementsAdapterTest.java
@@ -69,7 +69,18 @@
.setFunction(LabelFunction.ANY_WITH_BLOCK)
.build();
- labelTypes = Arrays.asList(codeReview, verified, codeStyle);
+ LabelType ignoreSelfApprovalLabel =
+ LabelType.builder(
+ "ISA-Label",
+ ImmutableList.of(
+ LabelValue.create((short) 1, "Looks good to me"),
+ LabelValue.create((short) 0, "No score"),
+ LabelValue.create((short) -1, "I would prefer this is not merged as is")))
+ .setFunction(LabelFunction.MAX_WITH_BLOCK)
+ .setIgnoreSelfApproval(true)
+ .build();
+
+ labelTypes = Arrays.asList(codeReview, verified, codeStyle, ignoreSelfApprovalLabel);
}
@Test
@@ -129,6 +140,46 @@
}
@Test
+ public void defaultSubmitRule_withLabelStatusNeed_labelHasIgnoreSelfApproval() throws Exception {
+ SubmitRecord submitRecord =
+ createSubmitRecord(
+ "gerrit~DefaultSubmitRule",
+ Status.NOT_READY,
+ Arrays.asList(createLabel("ISA-Label", Label.Status.NEED)));
+
+ List<SubmitRequirementResult> requirements =
+ SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId);
+
+ assertThat(requirements).hasSize(1);
+ assertResult(
+ requirements.get(0),
+ /* reqName= */ "ISA-Label",
+ /* submitExpression= */ "label:ISA-Label=MAX,user=non_uploader -label:ISA-Label=MIN",
+ SubmitRequirementResult.Status.UNSATISFIED,
+ SubmitRequirementExpressionResult.Status.FAIL);
+ }
+
+ @Test
+ public void defaultSubmitRule_withLabelStatusOk_labelHasIgnoreSelfApproval() throws Exception {
+ SubmitRecord submitRecord =
+ createSubmitRecord(
+ "gerrit~DefaultSubmitRule",
+ Status.OK,
+ Arrays.asList(createLabel("ISA-Label", Label.Status.OK)));
+
+ List<SubmitRequirementResult> requirements =
+ SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId);
+
+ assertThat(requirements).hasSize(1);
+ assertResult(
+ requirements.get(0),
+ /* reqName= */ "ISA-Label",
+ /* submitExpression= */ "label:ISA-Label=MAX,user=non_uploader -label:ISA-Label=MIN",
+ SubmitRequirementResult.Status.SATISFIED,
+ SubmitRequirementExpressionResult.Status.PASS);
+ }
+
+ @Test
public void customSubmitRule_noLabels_withStatusOk() {
SubmitRecord submitRecord =
createSubmitRecord("gerrit~IgnoreSelfApprovalRule", Status.OK, Arrays.asList());
@@ -207,6 +258,34 @@
SubmitRequirementExpressionResult.Status.FAIL);
}
+ @Test
+ public void customSubmitRule_withMixOfPassingAndFailingLabels() {
+ SubmitRecord submitRecord =
+ createSubmitRecord(
+ "gerrit~PrologRule",
+ Status.NOT_READY,
+ Arrays.asList(
+ createLabel("custom-label-1", Label.Status.OK),
+ createLabel("custom-label-2", Label.Status.REJECT)));
+
+ List<SubmitRequirementResult> requirements =
+ SubmitRequirementsAdapter.createResult(submitRecord, labelTypes, psCommitId);
+
+ assertThat(requirements).hasSize(2);
+ assertResult(
+ requirements.get(0),
+ /* reqName= */ "custom-label-1",
+ /* submitExpression= */ "label:custom-label-1=gerrit~PrologRule",
+ SubmitRequirementResult.Status.SATISFIED,
+ SubmitRequirementExpressionResult.Status.PASS);
+ assertResult(
+ requirements.get(1),
+ /* reqName= */ "custom-label-2",
+ /* submitExpression= */ "label:custom-label-2=gerrit~PrologRule",
+ SubmitRequirementResult.Status.UNSATISFIED,
+ SubmitRequirementExpressionResult.Status.FAIL);
+ }
+
private void assertResult(
SubmitRequirementResult r,
String reqName,
diff --git a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
index 92cbc41..2663853 100644
--- a/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
+++ b/javatests/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java
@@ -69,7 +69,6 @@
import com.google.gerrit.extensions.api.changes.DraftInput;
import com.google.gerrit.extensions.api.changes.HashtagsInput;
import com.google.gerrit.extensions.api.changes.ReviewInput;
-import com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling;
import com.google.gerrit.extensions.api.changes.ReviewerInput;
import com.google.gerrit.extensions.api.groups.GroupInput;
import com.google.gerrit.extensions.api.projects.ConfigInput;
@@ -2334,44 +2333,6 @@
}
@Test
- public void byHasDraftExcludesZombieDrafts() throws Exception {
- Project.NameKey project = Project.nameKey("repo");
- TestRepository<Repo> repo = createProject(project.get());
- Change change = insert(repo, newChange(repo));
- Change.Id id = change.getId();
-
- DraftInput in = new DraftInput();
- in.line = 1;
- in.message = "nit: trailing whitespace";
- in.path = Patch.COMMIT_MSG;
- gApi.changes().id(id.get()).current().createDraft(in);
-
- assertQuery("has:draft", change);
- assertQuery("commentby:" + userId);
-
- try (TestRepository<Repo> allUsers =
- new TestRepository<>(repoManager.openRepository(allUsersName))) {
- Ref draftsRef = allUsers.getRepository().exactRef(RefNames.refsDraftComments(id, userId));
- assertThat(draftsRef).isNotNull();
-
- ReviewInput rin = ReviewInput.dislike();
- rin.drafts = DraftHandling.PUBLISH_ALL_REVISIONS;
- gApi.changes().id(id.get()).current().review(rin);
-
- assertQuery("has:draft");
- assertQuery("commentby:" + userId, change);
- assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNull();
-
- // Re-add drafts ref and ensure it gets filtered out during indexing.
- allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
- assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
- }
-
- indexer.index(project, id);
- assertQuery("has:draft");
- }
-
- @Test
public void byStarredBy() throws Exception {
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
@@ -3432,6 +3393,7 @@
@Test
public void attentionSetIndexed() throws Exception {
assume().that(getSchema().hasField(ChangeField.ATTENTION_SET_USERS)).isTrue();
+ assume().that(getSchema().hasField(ChangeField.ATTENTION_SET_USERS_COUNT)).isTrue();
TestRepository<Repo> repo = createProject("repo");
Change change1 = insert(repo, newChange(repo));
Change change2 = insert(repo, newChange(repo));
@@ -3439,8 +3401,18 @@
AttentionSetInput input = new AttentionSetInput(userId.toString(), "some reason");
gApi.changes().id(change1.getChangeId()).addToAttentionSet(input);
+ assertQuery("is:attention", change1);
+ assertQuery("-is:attention", change2);
+ assertQuery("has:attention", change1);
+ assertQuery("-has:attention", change2);
assertQuery("attention:" + user.getUserName().get(), change1);
assertQuery("-attention:" + userId.toString(), change2);
+
+ gApi.changes()
+ .id(change1.getChangeId())
+ .attention(userId.toString())
+ .remove(new AttentionSetInput("removed again"));
+ assertQuery("-is:attention", change1, change2);
}
@Test
@@ -3687,18 +3659,16 @@
TestRepository<Repo> repo = createProject("repo");
Change change = insert(repo, newChange(repo));
- AssigneeInput ain = new AssigneeInput();
- ain.assignee = user2.toString();
- gApi.changes().id(change.getId().get()).setAssignee(ain);
+ gApi.changes().id(change.getId().get()).addReviewer(user2.toString());
RequestContext adminContext = requestContext.setContext(newRequestContext(user2));
- assertQuery("assignee:self", change);
+ assertQuery("reviewer:self", change);
requestContext.setContext(adminContext);
gApi.accounts().id(user2.get()).setActive(false);
requestContext.setContext(newRequestContext(user2));
- assertQuery("assignee:self", change);
+ assertQuery("reviewer:self", change);
}
@Test
diff --git a/package.json b/package.json
index 6ad3ab4..a492055 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"@bazel/rollup": "^3.5.0",
"@bazel/terser": "^3.5.0",
"@bazel/typescript": "^3.5.0",
- "twinkie": "^1.1.2"
+ "twinkie": "^1.1.3"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.29.0",
@@ -15,12 +15,16 @@
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^32.3.0",
+ "eslint-plugin-lit": "^1.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
+ "eslint-plugin-regex": "^1.8.0",
"gts": "^3.1.0",
+ "lit-analyzer": "^1.2.1",
"prettier": "2.3.1",
"rollup": "^2.45.2",
"terser": "^5.6.1",
+ "ts-lit-plugin": "^1.2.1",
"typescript": "4.3.2"
},
"scripts": {
@@ -32,19 +36,19 @@
"safe_bazelisk": "if which bazelisk >/dev/null; then bazel_bin=bazelisk; else bazel_bin=bazel; fi && $bazel_bin",
"eslint": "npm run safe_bazelisk test polygerrit-ui/app:lint_test",
"eslintfix": "npm run safe_bazelisk run polygerrit-ui/app:lint_bin -- -- --fix $(pwd)/polygerrit-ui/app",
- "polylint": "npm run safe_bazelisk test polygerrit-ui/app:polylint_test",
- "test:debug": "npm run compile:local && npm run safe_bazelisk run //polygerrit-ui:karma_bin -- -- start $(pwd)/polygerrit-ui/karma.conf.js --browsers ChromeDev --no-single-run --testFiles",
- "test:single": "npm run compile:local && npm run safe_bazelisk run //polygerrit-ui:karma_bin -- -- start $(pwd)/polygerrit-ui/karma.conf.js --testFiles",
- "postinstall": "(git apply --reverse --ignore-whitespace twinkie.patch || true) && git apply --ignore-whitespace twinkie.patch",
- "polytest": "npm run safe_bazelisk test //polygerrit-ui/app:validate_polymer_templates",
- "polytest:dev": "rm -rf ./polygerrit-ui/app/tmpl_out && npm run safe_bazelisk build //polygerrit-ui/app:template_test_tar && mkdir ./polygerrit-ui/app/tmpl_out && tar -xf bazel-bin/polygerrit-ui/app/template_test_tar.tar -C ./polygerrit-ui/app/tmpl_out"
+ "litlint": "npm run safe_bazelisk run polygerrit-ui/app:lit_analysis",
+ "test:debug": "npm run compile:local && npm run safe_bazelisk run //polygerrit-ui:karma_bin -- -- start $(pwd)/polygerrit-ui/karma.conf.js --root '.ts-out/polygerrit-ui/app/' --browsers ChromeDev --no-single-run --test-files",
+ "test:single": "npm run compile:local && npm run safe_bazelisk run //polygerrit-ui:karma_bin -- -- start $(pwd)/polygerrit-ui/karma.conf.js --root '.ts-out/polygerrit-ui/app/' --test-files",
+ "polylint": "npm run safe_bazelisk test //polygerrit-ui/app:polylint_test",
+ "polylint:dev": "rm -rf ./polygerrit-ui/app/tmpl_out && npm run safe_bazelisk build //polygerrit-ui/app:template_test_tar && mkdir ./polygerrit-ui/app/tmpl_out && tar -xf bazel-bin/polygerrit-ui/app/template_test_tar.tar -C ./polygerrit-ui/app/tmpl_out"
},
"repository": {
"type": "git",
"url": "https://gerrit.googlesource.com/gerrit"
},
"resolutions": {
- "lodash": "4.17.21"
+ "lodash": "4.17.21",
+ "twinkie/typescript": "4.3.2"
},
"author": "",
"license": "Apache-2.0"
diff --git a/plugins/BUILD b/plugins/BUILD
index 01ede06..0e5df2c 100644
--- a/plugins/BUILD
+++ b/plugins/BUILD
@@ -73,6 +73,7 @@
"//lib/commons:compress",
"//lib/commons:dbcp",
"//lib/commons:lang",
+ "//lib/commons:lang3",
"//lib/dropwizard:dropwizard-core",
"//lib/flogger:api",
"//lib/guice:guice",
diff --git a/plugins/delete-project b/plugins/delete-project
index 7dce6f7..8fe544a 160000
--- a/plugins/delete-project
+++ b/plugins/delete-project
@@ -1 +1 @@
-Subproject commit 7dce6f70611cd8dbf1d38628698155258ee8ef82
+Subproject commit 8fe544ac569efa357ee054257143d8e1d4aa6afd
diff --git a/plugins/plugin-manager b/plugins/plugin-manager
index 5b87f63..44808dc 160000
--- a/plugins/plugin-manager
+++ b/plugins/plugin-manager
@@ -1 +1 @@
-Subproject commit 5b87f63f3e9c5817bcddf008c0b4005494059368
+Subproject commit 44808dcad3c978ed12bb2cb454c6ad320912aa8a
diff --git a/plugins/replication b/plugins/replication
index 46cfb7d..cd17fe7 160000
--- a/plugins/replication
+++ b/plugins/replication
@@ -1 +1 @@
-Subproject commit 46cfb7dd5b6891f991cfe66e72c08953487c1c81
+Subproject commit cd17fe7f90e5a36ab84b9b7ce0aab22e60e48a70
diff --git a/plugins/tsconfig-plugins-base.json b/plugins/tsconfig-plugins-base.json
index b580549..b7e9d52 100644
--- a/plugins/tsconfig-plugins-base.json
+++ b/plugins/tsconfig-plugins-base.json
@@ -20,6 +20,7 @@
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
+ "noImplicitOverride": true,
"noFallthroughCasesInSwitch": true,/* Report errors for fallthrough cases in switch statement. */
"skipLibCheck": true, /* Do not check node_modules */
@@ -34,6 +35,15 @@
"incremental": true,
"experimentalDecorators": true,
- "allowUmdGlobalAccess": true
+ "allowUmdGlobalAccess": true,
+
+ "typeRoots": [
+ /* typeRoots for Bazel */
+ "../external/ui_dev_npm/node_modules/@types",
+ "../external/plugins_npm/node_modules/@types",
+ /* typeRoots for IDE */
+ "../polygerrit-ui/node_modules/@types",
+ "../plugins/node_modules/@types"
+ ]
},
}
diff --git a/polygerrit-ui/BUILD b/polygerrit-ui/BUILD
index 7bca96d..62d1d92 100644
--- a/polygerrit-ui/BUILD
+++ b/polygerrit-ui/BUILD
@@ -1,5 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("//tools/bzl:genrule2.bzl", "genrule2")
+load("//tools/bzl:js.bzl", "karma_test")
package(default_visibility = ["//visibility:public"])
@@ -33,8 +34,6 @@
],
)
-# Define a karma+plugins binary to run karma-mocha tests.
-# Can be reused multiple time, if there are multiple karma test rules
sh_binary(
name = "karma_bin",
srcs = ["@ui_dev_npm//:node_modules/karma/bin/karma"],
@@ -49,26 +48,8 @@
],
)
-# Run all tests in one.
-# TODO(dmfilippov): allow parallel tests for karma - either on the bazel level
-# or on the karma level. For now single sh_test is enough.
-sh_test(
+karma_test(
name = "karma_test",
- size = "enormous",
srcs = ["karma_test.sh"],
- args = [
- "$(location :karma_bin)",
- "$(location karma.conf.js)",
- ],
- data = [
- "karma.conf.js",
- ":karma_bin",
- "//polygerrit-ui/app:test-srcs-fg",
- ],
- # Should not run sandboxed.
- tags = [
- "karma",
- "local",
- "manual",
- ],
+ data = ["//polygerrit-ui/app:test-srcs-fg"],
)
diff --git a/polygerrit-ui/app/.eslintrc.js b/polygerrit-ui/app/.eslintrc.js
index faf126c..14f9e8c 100644
--- a/polygerrit-ui/app/.eslintrc.js
+++ b/polygerrit-ui/app/.eslintrc.js
@@ -277,6 +277,18 @@
},
},
{
+ files: ['**/api/*.ts'],
+ rules: {
+ 'regex/invalid': [
+ 'error', [{
+ regex: 'export interface',
+ message: 'All interfaces in the api/ dir must have "declare"',
+ replacement: 'export declare interface',
+ }],
+ ],
+ },
+ },
+ {
files: ['**/*.ts'],
extends: [require.resolve('gts/.eslintrc.json')],
rules: {
@@ -400,12 +412,32 @@
}],
},
},
+ {
+ files: ['*.ts'],
+ excludedFiles: '*_html.ts',
+ rules: {
+ 'lit/attribute-value-entities': 'error',
+ 'lit/binding-positions': 'error',
+ 'lit/no-duplicate-template-bindings': 'error',
+ 'lit/no-invalid-html': 'error',
+ 'lit/no-legacy-template-syntax': 'error',
+ 'lit/no-property-change-update': 'error',
+ 'lit/no-invalid-escape-sequences': 'error',
+ 'lit/no-legacy-imports': 'error',
+ 'lit/no-private-properties': 'error',
+ 'lit/no-useless-template-literals': 'error',
+ 'lit/no-value-attribute': 'error',
+ 'lit/prefer-static-styles': 'error',
+ },
+ },
],
plugins: [
'html',
'jsdoc',
'import',
+ 'lit',
'prettier',
+ 'regex',
],
settings: {
'html/report-bad-indent': 'error',
diff --git a/polygerrit-ui/app/BUILD b/polygerrit-ui/app/BUILD
index 4a186c1..3a647d4 100644
--- a/polygerrit-ui/app/BUILD
+++ b/polygerrit-ui/app/BUILD
@@ -45,8 +45,6 @@
),
allow_js = True,
incremental = True,
- # The same outdir also appears in the following files:
- # polylint_test.sh
out_dir = "_pg_ts_out",
tsc = "//tools/node_tools:tsc-bin",
tsconfig = ":ts_config_bazel",
@@ -70,7 +68,6 @@
[
"**/*.js",
"**/*.ts",
- "test/@types/*.d.ts",
],
exclude = [
"node_modules/**",
@@ -97,9 +94,7 @@
# so template tests pass.
# TODO: fix problems reported by template checker in these files.
ignore_templates_list = [
- "elements/admin/gr-access-section/gr-access-section_html.ts",
"elements/admin/gr-admin-view/gr-admin-view_html.ts",
- "elements/admin/gr-create-change-dialog/gr-create-change-dialog_html.ts",
"elements/admin/gr-create-repo-dialog/gr-create-repo-dialog_html.ts",
"elements/admin/gr-group-members/gr-group-members_html.ts",
"elements/admin/gr-group/gr-group_html.ts",
@@ -110,7 +105,6 @@
"elements/admin/gr-repo-plugin-config/gr-repo-plugin-config_html.ts",
"elements/admin/gr-repo/gr-repo_html.ts",
"elements/admin/gr-rule-editor/gr-rule-editor_html.ts",
- "elements/change-list/gr-change-list-item/gr-change-list-item_html.ts",
"elements/change-list/gr-change-list-view/gr-change-list-view_html.ts",
"elements/change-list/gr-change-list/gr-change-list_html.ts",
"elements/change-list/gr-dashboard-view/gr-dashboard-view_html.ts",
@@ -118,9 +112,6 @@
"elements/change/gr-change-metadata/gr-change-metadata_html.ts",
"elements/change/gr-change-requirements/gr-change-requirements_html.ts",
"elements/change/gr-change-view/gr-change-view_html.ts",
- "elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_html.ts",
- "elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_html.ts",
- "elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_html.ts",
"elements/change/gr-file-list-header/gr-file-list-header_html.ts",
"elements/change/gr-file-list/gr-file-list_html.ts",
"elements/change/gr-label-score-row/gr-label-score-row_html.ts",
@@ -138,25 +129,21 @@
"elements/gr-app-element_html.ts",
"elements/settings/gr-watched-projects-editor/gr-watched-projects-editor_html.ts",
"elements/shared/gr-account-list/gr-account-list_html.ts",
- "elements/shared/gr-comment-thread/gr-comment-thread_html.ts",
- "elements/shared/gr-comment/gr-comment_html.ts",
- "elements/shared/gr-dropdown-list/gr-dropdown-list_html.ts",
- "elements/shared/gr-hovercard-account/gr-hovercard-account_html.ts",
- "elements/shared/gr-label-info/gr-label-info_html.ts",
- "elements/shared/gr-list-view/gr-list-view_html.ts",
]
+sources_for_template_checking = glob(
+ [src_dir + "/**/*" + ext for src_dir in src_dirs for ext in [
+ ".ts",
+ ]],
+ exclude = [
+ "**/*_test.ts",
+ ] + ignore_templates_list,
+)
+
# Transform templates into a .ts files.
templates_srcs = transform_polymer_templates(
name = "template_test",
- srcs = glob(
- [src_dir + "/**/*" + ext for src_dir in src_dirs for ext in [
- ".ts",
- ]],
- exclude = [
- "**/*_test.ts",
- ] + ignore_templates_list,
- ),
+ srcs = sources_for_template_checking,
out_tsconfig = "tsconfig_template_test.json",
tsconfig = "tsconfig_bazel.json",
deps = [
@@ -166,50 +153,34 @@
],
)
-# Compile transformed templates together with the polygerrit source. If
-# templates don't have problem, then the compilation ends without error.
-# Otherwise, the typescript compiler reports the error.
-# Note, that the compile_ts macro creates build rules. If the build succeed,
-# the macro creates the file compile_template_test.success. The
-# 'validate_polymer_templates' rule tests existence of the file.
-#
-# TODO: Re-instantiate this rule. It broke when switching to ts_project with
-# ERROR: //polygerrit-ui/app:compile_template_test srcs cannot be a mix of
-# generated files and source files since this would prevent giving a
-# single rootDir to the TypeScript compiler
-# Also, the emitJS feature of compile_ts has to be re-created in some form.
-#ts_project(
-# name = "compile_template_test",
-# srcs = templates_srcs + glob(
-# [src_dir + "/**/*" + ext for src_dir in src_dirs for ext in [
-# ".ts",
-# ]],
-# exclude = [
-# "**/*_test.ts",
-# ] + ignore_templates_list,
-# ),
-# allow_js = True,
-# out_dir = "_pg_template_test_out",
-# # Should not run sandboxed.
-# tags = [
-# "local",
-# "manual",
-# ],
-# tsc = "//tools/node_tools:tsc-bin",
-# tsconfig = "tsconfig_template_test.json",
-#)
-#
-# This rule allows to run polymer template checker with bazel test command.
-# For details - see compile_template_test rule.
-#
-# TODO: Re-instantiate this test. It broke when switching
-# 'compile_template_test'to ts_project, see above. ts_project does not
-# create '.success' files.
-#sh_test(
-# name = "validate_polymer_templates",
-# srcs = [":empty_test.sh"],
-# data = ["compile_template_test.success"],
-#)
+# After templates are converted into a typescript code, the TS compiler should check that the
+# converted code doesn't have the error (i.e. templates don't have problems).
+# The input to the compiler is: the converted (i.e. autogenerated) code + original polygerrit code;
+# the output (i.e. js code) is not needed (we only care wheather the code has error or not).
+# The existing ts_project rule can't compile a mix of a generated and a non-generated code, so it
+# can't be used for the purpose of template checking.
+# Because the output of TS compiler is not needed, the simplest workaround is to run typescript
+# compiler from command line using the sh_test rule. The compiler exits with non-zero return code if
+# errors found and sh_test fails.
+sh_test(
+ name = "polylint_test",
+ srcs = [":compile_generated_templates.sh"],
+ args = [
+ "$(location //tools/node_tools:tsc-bin)",
+ "$(location tsconfig_template_test.json)",
+ ],
+ data = [
+ "tsconfig_template_test.json",
+ "tsconfig_bazel.json",
+ "tsconfig.json",
+ "//tools/node_tools:tsc-bin",
+ "@ui_npm//:node_modules",
+ ] + templates_srcs + sources_for_template_checking,
+ tags = [
+ "local",
+ "manual",
+ ],
+)
polygerrit_bundle(
name = "polygerrit_ui",
@@ -293,31 +264,30 @@
)
filegroup(
- name = "polylint-fg",
- srcs = [
- # Workaround for https://github.com/bazelbuild/bazel/issues/1305
+ name = "lit_analysis_src_code",
+ srcs = glob(
+ ["**/*.ts"],
+ exclude = [
+ "**/*_html.ts",
+ "**/*_test.ts",
+ ],
+ ) + [
+ "@ui_dev_npm//:node_modules",
"@ui_npm//:node_modules",
- # Polylinter can't check .ts files, run it on compiled srcs
- ":compile_pg",
],
)
-sh_test(
- name = "polylint_test",
- size = "large",
- srcs = ["polylint_test.sh"],
- args = [
- "$(location @tools_npm//polymer-cli/bin:polymer)",
- "$(location polymer.json)",
- ],
+nodejs_binary(
+ name = "lit_analysis",
data = [
- "polymer.json",
- ":polylint-fg",
- "@tools_npm//polymer-cli/bin:polymer",
+ ":lit_analysis_src_code",
+ "@npm//lit-analyzer",
],
- # Should not run sandboxed.
- tags = [
- "local",
- "manual",
+ entry_point = "@npm//:node_modules/lit-analyzer/cli.js",
+ templated_args = [
+ "**/elements/**/*.ts",
+ "--strict",
+ "--rules.no-property-visibility-mismatch off",
+ "--rules.no-incompatible-property-type off",
],
)
diff --git a/polygerrit-ui/app/api/checks.ts b/polygerrit-ui/app/api/checks.ts
index 6c11e57..d52a555 100644
--- a/polygerrit-ui/app/api/checks.ts
+++ b/polygerrit-ui/app/api/checks.ts
@@ -144,8 +144,8 @@
* attempt. Every run has its own attempt numbering, so attempt 3 of run A is
* not directly related to attempt 3 of run B.
*
- * RUNNABLE runs must use `undefined` as attempt.
- * COMPLETED and RUNNING runs must use an attempt number >=0.
+ * The attempt number must be >=0. Only if you have just one RUNNABLE attempt,
+ * then you can leave it undefined.
*
* TBD: Optionally providing aggregate information about former attempts will
* probably be a useful feature, but we are deferring the exact data modeling
@@ -184,7 +184,8 @@
/**
* RUNNABLE: Not run (yet). Mostly useful for runs that the user can trigger
- * (see actions). Cannot contain results.
+ * (see actions) and for indicating that a check was not run at a
+ * later attempt. Cannot contain results.
* RUNNING: Subsumes "scheduled".
* COMPLETED: The attempt of the run has finished. Does not indicate at all
* whether the run was successful or not. Outcomes can and should
diff --git a/polygerrit-ui/app/api/diff.ts b/polygerrit-ui/app/api/diff.ts
index 26701e8..ee579ff 100644
--- a/polygerrit-ui/app/api/diff.ts
+++ b/polygerrit-ui/app/api/diff.ts
@@ -53,30 +53,30 @@
}
/**
+ * Represents a "generic" text range in the code (e.g. text selection)
+ */
+interface TextRange {
+ /** first line of the range (1-based inclusive). */
+ start_line: number;
+ /** first column of the range (in the first line) (1-based inclusive). */
+ start_column: number;
+ /** last line of the range (1-based inclusive). */
+ end_line: number;
+ /** last column of the range (in the end line) (1-based inclusive). */
+ end_column: number;
+}
+
+/**
* Represents a syntax block in a code (e.g. method, function, class, if-else).
*/
export declare interface SyntaxBlock {
/** Name of the block (e.g. name of the method/class)*/
name: string;
- /** Where does this block syntatically starts and ends (line number and column).*/
- range: {
- /** first line of the block (1-based inclusive). */
- start_line: number;
- /**
- * column of the range start inside the first line (e.g. "{" character ending a function/method)
- * (1-based inclusive).
- */
- start_column: number;
- /**
- * last line of the block (1-based inclusive).
- */
- end_line: number;
- /**
- * column of the block end inside the end line (e.g. "}" character ending a function/method)
- * (1-based inclusive).
- */
- end_column: number;
- };
+ /**
+ * Where does this block syntatically starts and ends (line number and
+ * column).
+ */
+ range: TextRange;
/** Sub-blocks of the current syntax block (e.g. methods of a class) */
children: SyntaxBlock[];
}
@@ -209,6 +209,25 @@
line_wrapping?: boolean;
}
+/**
+ * Event details when a token is highlighted.
+ */
+export declare interface TokenHighlightEventDetails {
+ token: string;
+ element: Element;
+ side: Side;
+ range: TextRange;
+}
+
+/**
+ * Listens to changes in token highlighting - when a new token starts or stopped
+ * being highlighted. undefined is sent if the event is about a clear in
+ * highlighting.
+ */
+export type TokenHighlightListener = (
+ tokenHighlightEvent?: TokenHighlightEventDetails
+) => void;
+
export declare interface ImageDiffPreferences {
automatic_blink?: boolean;
}
diff --git a/polygerrit-ui/app/api/embed.ts b/polygerrit-ui/app/api/embed.ts
index ba378e2..520aeec 100644
--- a/polygerrit-ui/app/api/embed.ts
+++ b/polygerrit-ui/app/api/embed.ts
@@ -20,14 +20,24 @@
* limitations under the License.
*/
-import {DiffLayer, GrAnnotation, GrDiffCursor} from './diff';
+import {
+ DiffLayer,
+ GrAnnotation,
+ GrDiffCursor,
+ TokenHighlightListener,
+} from './diff';
declare global {
interface Window {
grdiff: {
GrAnnotation: GrAnnotation;
GrDiffCursor: {new (): GrDiffCursor};
- TokenHighlightLayer: {new (container?: HTMLElement): DiffLayer};
+ TokenHighlightLayer: {
+ new (
+ container?: HTMLElement,
+ listener?: TokenHighlightListener
+ ): DiffLayer;
+ };
};
}
}
diff --git a/polygerrit-ui/app/api/gerrit.ts b/polygerrit-ui/app/api/gerrit.ts
index 8488961..2091eea 100644
--- a/polygerrit-ui/app/api/gerrit.ts
+++ b/polygerrit-ui/app/api/gerrit.ts
@@ -25,7 +25,7 @@
}
}
-export interface Gerrit {
+export declare interface Gerrit {
install(
callback: (plugin: PluginApi) => void,
opt_version?: string,
diff --git a/polygerrit-ui/app/api/hook.ts b/polygerrit-ui/app/api/hook.ts
index f8a6cc1..8cbb9d0 100644
--- a/polygerrit-ui/app/api/hook.ts
+++ b/polygerrit-ui/app/api/hook.ts
@@ -16,7 +16,7 @@
*/
import {ChangeInfo, ConfigInfo, RevisionInfo} from './rest-api';
-export interface GerritElementExtensions {
+export declare interface GerritElementExtensions {
content?: HTMLElement & {hidden?: boolean};
change?: ChangeInfo;
revision?: RevisionInfo;
diff --git a/polygerrit-ui/app/api/popup.ts b/polygerrit-ui/app/api/popup.ts
index 8d81831..d265ee6 100644
--- a/polygerrit-ui/app/api/popup.ts
+++ b/polygerrit-ui/app/api/popup.ts
@@ -17,9 +17,10 @@
export declare interface PopupPluginApi {
/**
- * Opens the popup, inserts it into DOM over current UI.
- * Creates the popup if not previously created. Creates popup content element,
- * if it was provided with constructor.
+ * Opens the popup, inserts it into the DOM over current UI.
+ * Creates the popup if not previously created. Creates and inserts the popup
+ * content element, if a `moduleName` was provided in the constructor.
+ * Otherwise you have to call `appendContent()` when the promise resolves.
*/
open(): Promise<PopupPluginApi>;
@@ -27,4 +28,10 @@
* Hides the popup.
*/
close(): void;
+
+ /**
+ * Appends the given element as a child to the popup. Only call this method
+ * when you have called `popup()` without a `moduleName`.
+ */
+ appendContent(el: HTMLElement): void;
}
diff --git a/polygerrit-ui/app/api/rest-api.ts b/polygerrit-ui/app/api/rest-api.ts
index 4a4b79d..f86e825 100644
--- a/polygerrit-ui/app/api/rest-api.ts
+++ b/polygerrit-ui/app/api/rest-api.ts
@@ -240,7 +240,7 @@
* The AccountDetailInfo entity contains detailed information about an account.
* https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#account-detail-info
*/
-export interface AccountDetailInfo extends AccountInfo {
+export declare interface AccountDetailInfo extends AccountInfo {
registered_on: Timestamp;
}
@@ -249,7 +249,7 @@
* from the accounts section.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#accounts-config-info
*/
-export interface AccountsConfigInfo {
+export declare interface AccountsConfigInfo {
visibility: string;
default_display_name: DefaultDisplayNameConfig;
}
@@ -320,7 +320,7 @@
* configuration of the Gerrit server.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#auth-info
*/
-export interface AuthInfo {
+export declare interface AuthInfo {
auth_type: AuthType; // docs incorrectly names it 'type'
use_contributor_agreements?: boolean;
contributor_agreements?: ContributorAgreementInfo[];
@@ -356,7 +356,7 @@
* from the change section.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#change-config-info
*/
-export interface ChangeConfigInfo {
+export declare interface ChangeConfigInfo {
allow_blame?: boolean;
large_change: number;
update_delay: number;
@@ -464,14 +464,14 @@
* The CommentLinkInfo entity describes acommentlink.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#commentlink-info
*/
-export interface CommentLinkInfo {
+export declare interface CommentLinkInfo {
match: string;
link?: string;
enabled?: boolean;
html?: string;
}
-export interface CommentLinks {
+export declare interface CommentLinks {
[name: string]: CommentLinkInfo;
}
@@ -492,7 +492,8 @@
resolve_conflicts_web_links?: WebLinkInfo[];
}
-export interface ConfigArrayParameterInfo extends ConfigParameterInfoBase {
+export declare interface ConfigArrayParameterInfo
+ extends ConfigParameterInfoBase {
type: ConfigParameterInfoType.ARRAY;
values: string[];
}
@@ -502,7 +503,7 @@
* project configuration.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#config-info
*/
-export interface ConfigInfo {
+export declare interface ConfigInfo {
description?: string;
use_contributor_agreements?: InheritedBooleanInfo;
use_content_merge?: InheritedBooleanInfo;
@@ -525,7 +526,8 @@
reject_empty_commit?: InheritedBooleanInfo;
}
-export interface ConfigListParameterInfo extends ConfigParameterInfoBase {
+export declare interface ConfigListParameterInfo
+ extends ConfigParameterInfoBase {
type: ConfigParameterInfoType.LIST;
permitted_values?: string[];
}
@@ -539,7 +541,7 @@
* The ConfigParameterInfo entity describes a project configurationparameter.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#config-parameter-info
*/
-export interface ConfigParameterInfoBase {
+export declare interface ConfigParameterInfoBase {
display_name?: string;
description?: string;
warning?: string;
@@ -554,7 +556,7 @@
}
// https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#contributor-agreement-info
-export interface ContributorAgreementInfo {
+export declare interface ContributorAgreementInfo {
name: string;
description: string;
url: string;
@@ -584,7 +586,7 @@
* options.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#download-info
*/
-export interface DownloadInfo {
+export declare interface DownloadInfo {
schemes: SchemesInfoMap;
archives: string[];
}
@@ -594,7 +596,7 @@
* scheme and its commands.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html
*/
-export interface DownloadSchemeInfo {
+export declare interface DownloadSchemeInfo {
url: string;
is_auth_required: boolean;
is_auth_supported: boolean;
@@ -634,7 +636,7 @@
* the gerrit section.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#gerrit-info
*/
-export interface GerritInfo {
+export declare interface GerritInfo {
all_projects: string; // Doc contains incorrect name
all_users: string; // Doc contains incorrect name
doc_search: boolean;
@@ -685,7 +687,7 @@
* Gerrit internal group, or an external group that is known to Gerrit.
* https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html#group-info
*/
-export interface GroupInfo {
+export declare interface GroupInfo {
id: GroupId;
name?: GroupName;
url?: string;
@@ -706,7 +708,7 @@
* Options of the group.
* https://gerrit-review.googlesource.com/Documentation/rest-api-groups.html
*/
-export interface GroupOptionsInfo {
+export declare interface GroupOptionsInfo {
visible_to_all: boolean;
}
@@ -718,7 +720,7 @@
* A boolean value that can also be inherited.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#inherited-boolean-info
*/
-export interface InheritedBooleanInfo {
+export declare interface InheritedBooleanInfo {
value: boolean;
configured_value: InheritedBooleanInfoConfiguredValue;
inherited_value?: boolean;
@@ -750,7 +752,7 @@
* has.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#label-type-info
*/
-export interface LabelTypeInfo {
+export declare interface LabelTypeInfo {
values: LabelTypeInfoValues;
default_value: number;
}
@@ -765,7 +767,7 @@
* size limit of a project.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#max-object-size-limit-info
*/
-export interface MaxObjectSizeLimitInfo {
+export declare interface MaxObjectSizeLimitInfo {
value?: string;
configured_value?: string;
summary?: string;
@@ -793,7 +795,7 @@
* plugins.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#plugin-config-info
*/
-export interface PluginConfigInfo {
+export declare interface PluginConfigInfo {
has_avatars: boolean;
// Exists in Java class, but not mentioned in docs.
js_resource_paths: string[];
@@ -828,7 +830,7 @@
* The ProjectInfo entity contains information about a project
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-info
*/
-export interface ProjectInfo {
+export declare interface ProjectInfo {
id: UrlEncodedRepoName;
// name is not set if returned in a map where the project name is used as
// map key
@@ -845,7 +847,7 @@
web_links?: WebLinkInfo[];
}
-export interface ProjectInfoWithName extends ProjectInfo {
+export declare interface ProjectInfoWithName extends ProjectInfo {
name: RepoName;
}
@@ -891,7 +893,7 @@
* git-receive-pack behavior on the server.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#receive-info
*/
-export interface ReceiveInfo {
+export declare interface ReceiveInfo {
enable_signed_push?: string;
}
@@ -964,7 +966,7 @@
* Gerrit server.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#server-info
*/
-export interface ServerInfo {
+export declare interface ServerInfo {
accounts: AccountsConfigInfo;
auth: AuthInfo;
change: ChangeConfigInfo;
@@ -999,7 +1001,7 @@
* project inheritance.
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#submit-type-info
*/
-export interface SubmitTypeInfo {
+export declare interface SubmitTypeInfo {
value: Exclude<SubmitType, SubmitType.INHERIT>;
configured_value: SubmitType;
inherited_value: Exclude<SubmitType, SubmitType.INHERIT>;
@@ -1010,7 +1012,7 @@
* the suggest section.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#suggest-info
*/
-export interface SuggestInfo {
+export declare interface SuggestInfo {
from: number;
}
@@ -1038,7 +1040,7 @@
* from the user section.
* https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#user-config-info
*/
-export interface UserConfigInfo {
+export declare interface UserConfigInfo {
anonymous_coward_name: string;
}
diff --git a/polygerrit-ui/app/api/styles.ts b/polygerrit-ui/app/api/styles.ts
index ded3beb..55ac2cc 100644
--- a/polygerrit-ui/app/api/styles.ts
+++ b/polygerrit-ui/app/api/styles.ts
@@ -29,14 +29,15 @@
*/
/** Lit plugins can cast Style to CSSResult. */
-export interface Style {
+export declare interface Style {
toString(): string;
}
-export interface Styles {
+export declare interface Styles {
font: Style;
form: Style;
menuPage: Style;
+ spinner: Style;
subPage: Style;
table: Style;
}
diff --git a/polygerrit-ui/app/compile_generated_templates.sh b/polygerrit-ui/app/compile_generated_templates.sh
new file mode 100755
index 0000000..68bf485
--- /dev/null
+++ b/polygerrit-ui/app/compile_generated_templates.sh
@@ -0,0 +1 @@
+$1 --project $2 --baseUrl ./external/ui_npm/node_modules/ --rootDir null
diff --git a/polygerrit-ui/app/constants/constants.ts b/polygerrit-ui/app/constants/constants.ts
index 2acad49..645e770 100644
--- a/polygerrit-ui/app/constants/constants.ts
+++ b/polygerrit-ui/app/constants/constants.ts
@@ -304,3 +304,7 @@
theme: 'DEFAULT',
};
}
+
+export const RELOAD_DASHBOARD_INTERVAL_MS = 10 * 1000;
+
+export const SHOWN_ITEMS_COUNT = 25;
diff --git a/polygerrit-ui/app/constants/reporting.ts b/polygerrit-ui/app/constants/reporting.ts
index a09c1c3..a10bdda 100644
--- a/polygerrit-ui/app/constants/reporting.ts
+++ b/polygerrit-ui/app/constants/reporting.ts
@@ -23,6 +23,7 @@
VISIBILILITY_VISIBLE = 'Visibility changed to visible',
EXTENSION_DETECTED = 'Extension detected',
PLUGINS_INSTALLED = 'Plugins installed',
+ PLUGINS_FAILED = 'Some plugins failed to load',
USER_REFERRED_FROM = 'User referred from',
}
diff --git a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
index 6efaf0c..2328a05 100644
--- a/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
+++ b/polygerrit-ui/app/elements/admin/gr-access-section/gr-access-section.ts
@@ -115,7 +115,7 @@
_updateSection(section: PermissionAccessSection) {
this._permissions = toSortedPermissionsArray(section.value.permissions);
- this._originalId = section.id as GitRef;
+ this._originalId = section.id;
}
_handleAccessSaved() {
@@ -170,7 +170,9 @@
_computePermissions(
name: string,
capabilities?: CapabilityInfoMap,
- labels?: LabelNameToLabelTypeInfoMap
+ labels?: LabelNameToLabelTypeInfoMap,
+ // This is just for triggering re-computation. We don't use the value.
+ _?: unknown
) {
let allPermissions;
const section = this.section;
@@ -227,10 +229,10 @@
_computePermissionName(
name: string,
permission: PermissionArrayItem<EditablePermissionInfo>,
- capabilities: CapabilityInfoMap
- ) {
+ capabilities?: CapabilityInfoMap
+ ): string | undefined {
if (name === GLOBAL_NAME) {
- return capabilities[permission.id].name;
+ return capabilities?.[permission.id].name;
} else if (AccessPermissions[permission.id]) {
return AccessPermissions[permission.id].name;
} else if (permission.value.label) {
@@ -313,7 +315,7 @@
if (
editing &&
this.section &&
- this._isEditEnabled(canUpload, ownerOf, this.section.id as GitRef)
+ this._isEditEnabled(canUpload, ownerOf, this.section.id)
) {
classList.push('editing');
}
@@ -331,7 +333,7 @@
}
_handleAddPermission() {
- const value = this.$.permissionSelect.value;
+ const value = this.$.permissionSelect.value as GitRef;
const permission: PermissionArrayItem<EditablePermissionInfo> = {
id: value,
value: {rules: {}, added: true},
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
index cdd2913..ea70d7e 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-group-list/gr-admin-group-list.ts
@@ -23,7 +23,6 @@
import '../gr-create-group-dialog/gr-create-group-dialog';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-admin-group-list_html';
-import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {customElement, property, observe, computed} from '@polymer/decorators';
import {AppElementAdminParams} from '../../gr-app-types';
@@ -32,6 +31,7 @@
import {GrCreateGroupDialog} from '../gr-create-group-dialog/gr-create-group-dialog';
import {fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
+import {SHOWN_ITEMS_COUNT} from '../../../constants/constants';
declare global {
interface HTMLElementTagNameMap {
@@ -46,11 +46,8 @@
};
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
@customElement('gr-admin-group-list')
-export class GrAdminGroupList extends base {
+export class GrAdminGroupList extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -62,7 +59,7 @@
* Offset of currently visible query results.
*/
@property({type: Number})
- _offset?: number;
+ _offset = 0;
@property({type: String})
readonly _path = '/admin/groups';
@@ -82,7 +79,7 @@
* */
@computed('_groups')
get _shownGroups() {
- return this.computeShownItems(this._groups);
+ return this._groups.slice(0, SHOWN_ITEMS_COUNT);
}
@property({type: Number})
@@ -106,8 +103,8 @@
@observe('params')
_paramsChanged(params: AppElementAdminParams) {
this._loading = true;
- this._filter = this.getFilterValue(params);
- this._offset = this.getOffsetValue(params);
+ this._filter = params?.filter ?? '';
+ this._offset = Number(params?.offset ?? 0);
return this._getGroups(this._filter, this._groupsPerPage, this._offset);
}
@@ -184,4 +181,8 @@
_visibleToAll(item: GroupInfo) {
return item.options?.visible_to_all === true ? 'Y' : 'N';
}
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
}
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_html.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_html.ts
index 70e146f..a3afc5c 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_html.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_html.ts
@@ -24,11 +24,6 @@
/* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
</style>
<style include="gr-page-nav-styles">
- gr-dropdown-list {
- --trigger-style: {
- text-transform: none;
- }
- }
.breadcrumbText {
/* Same as dropdown trigger so chevron spacing is consistent. */
padding: 5px 4px;
diff --git a/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts b/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
index 5a48399..04d3198 100644
--- a/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-confirm-delete-item-dialog/gr-confirm-delete-item-dialog.ts
@@ -45,7 +45,7 @@
@property({type: String})
itemTypeName?: string;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -57,7 +57,7 @@
];
}
- render() {
+ override render() {
const item = this.item ?? 'UNKNOWN ITEM';
const itemTypeName = this.itemTypeName ?? 'UNKNOWN ITEM TYPE';
return html` <gr-dialog
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
index 63b10ec..15f6f4b 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog.ts
@@ -32,7 +32,7 @@
InheritedBooleanInfo,
} from '../../../types/common';
import {InheritedBooleanInfoConfiguredValue} from '../../../constants/constants';
-import {GrAutocomplete} from '../../shared/gr-autocomplete/gr-autocomplete';
+import {GrTypedAutocomplete} from '../../shared/gr-autocomplete/gr-autocomplete';
import {IronAutogrowTextareaElement} from '@polymer/iron-autogrow-textarea/iron-autogrow-textarea';
import {appContext} from '../../../services/app-context';
import {Subject} from 'rxjs';
@@ -41,6 +41,7 @@
serverConfig$,
} from '../../../services/config/config-model';
import {takeUntil} from 'rxjs/operators';
+import {IronInputElement} from '@polymer/iron-input/iron-input';
const SUGGESTIONS_LIMIT = 15;
const REF_PREFIX = 'refs/heads/';
@@ -48,8 +49,8 @@
export interface GrCreateChangeDialog {
$: {
privateChangeCheckBox: HTMLInputElement;
- branchInput: GrAutocomplete;
- tagNameInput: HTMLInputElement;
+ branchInput: GrTypedAutocomplete<BranchName>;
+ tagNameInput: IronInputElement;
messageInput: IronAutogrowTextareaElement;
};
}
@@ -63,19 +64,19 @@
repoName?: RepoName;
@property({type: String})
- branch?: BranchName;
+ branch = '' as BranchName;
@property({type: Object})
_repoConfig?: ConfigInfo;
@property({type: String})
- subject?: string;
+ subject = '';
@property({type: String})
topic?: string;
@property({type: Object})
- _query?: (input: string) => Promise<{name: string}[]>;
+ _query?: (input: string) => Promise<{name: BranchName}[]>;
@property({type: String})
baseChange?: ChangeId;
@@ -90,7 +91,7 @@
canCreate = false;
@property({type: Boolean})
- _privateChangesEnabled?: boolean;
+ _privateChangesEnabled = false;
restApiService = appContext.restApiService;
@@ -120,7 +121,7 @@
super.disconnectedCallback();
}
- _computeBranchClass(baseChange: boolean) {
+ _computeBranchClass(baseChange?: ChangeId) {
return baseChange ? 'hide' : '';
}
@@ -165,19 +166,19 @@
.getRepoBranches(input, this.repoName, SUGGESTIONS_LIMIT)
.then(response => {
if (!response) return [];
- const branches = [];
+ const branches: Array<{name: BranchName}> = [];
for (const branchInfo of response) {
let name: string = branchInfo.ref;
if (name.startsWith('refs/heads/')) {
name = name.substring('refs/heads/'.length);
}
- branches.push({name});
+ branches.push({name: name as BranchName});
}
return branches;
});
}
- _formatBooleanString(config: InheritedBooleanInfo) {
+ _formatBooleanString(config?: InheritedBooleanInfo) {
if (
config &&
config.configured_value === InheritedBooleanInfoConfiguredValue.TRUE
diff --git a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
index a9de24a..9ed5d81 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-change-dialog/gr-create-change-dialog_test.ts
@@ -20,7 +20,11 @@
import {GrCreateChangeDialog} from './gr-create-change-dialog';
import {BranchName, GitRef, RepoName} from '../../../types/common';
import {InheritedBooleanInfoConfiguredValue} from '../../../constants/constants';
-import {createChange, createConfig} from '../../../test/test-data-generators';
+import {
+ createChange,
+ createConfig,
+ TEST_CHANGE_ID,
+} from '../../../test/test-data-generators';
import {stubRestApi} from '../../../test/test-utils';
const basicFixture = fixtureFromElement('gr-create-change-dialog');
@@ -130,8 +134,8 @@
});
test('_computeBranchClass', () => {
- assert.equal(element._computeBranchClass(true), 'hide');
- assert.equal(element._computeBranchClass(false), '');
+ assert.equal(element._computeBranchClass(TEST_CHANGE_ID), 'hide');
+ assert.equal(element._computeBranchClass(undefined), '');
});
test('_computePrivateSectionClass', () => {
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
index d40b810..6605350 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.ts
@@ -17,11 +17,9 @@
import '../../../styles/gr-table-styles';
import '../../../styles/shared-styles';
-import '../../shared/gr-date-formatter/gr-date-formatter';
import '../../shared/gr-account-link/gr-account-link';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-group-audit-log_html';
-import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {customElement, property} from '@polymer/decorators';
import {
@@ -36,11 +34,8 @@
import {appContext} from '../../../services/app-context';
import {ErrorCallback} from '../../../api/rest';
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
@customElement('gr-group-audit-log')
-export class GrGroupAuditLog extends base {
+export class GrGroupAuditLog extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -130,6 +125,10 @@
return '';
}
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_html.ts b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_html.ts
index 40c2f30..828aa55 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_html.ts
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_html.ts
@@ -43,7 +43,7 @@
<template is="dom-repeat" items="[[_auditLog]]">
<tr class="table">
<td class="date">
- <gr-date-formatter has-tooltip="" date-str="[[item.date]]">
+ <gr-date-formatter withTooltip date-str="[[item.date]]">
</gr-date-formatter>
</td>
<td class="type">[[itemType(item.type)]]</td>
diff --git a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.js b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.js
index d26d14c..b91b04b 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-group-members/gr-group-members_test.js
@@ -140,7 +140,7 @@
'https://test/site/group/url');
});
- test('save members correctly', () => {
+ test('save members correctly', async () => {
element._groupOwner = true;
const memberName = 'test-admin';
@@ -155,6 +155,7 @@
element.$.groupMemberSearchInput.text = memberName;
element.$.groupMemberSearchInput.value = 1234;
+ await flush();
assert.isFalse(button.hasAttribute('disabled'));
return element._handleSavingGroupMember().then(() => {
@@ -165,7 +166,7 @@
});
});
- test('save included groups correctly', () => {
+ test('save included groups correctly', async () => {
element._groupOwner = true;
const includedGroupName = 'testName';
@@ -179,7 +180,7 @@
element.$.includedGroupSearchInput.text = includedGroupName;
element.$.includedGroupSearchInput.value = 'testId';
-
+ await flush();
assert.isFalse(button.hasAttribute('disabled'));
return element._handleSavingIncludedGroups().then(() => {
diff --git a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
index e492a15..e390ac5 100644
--- a/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
+++ b/polygerrit-ui/app/elements/admin/gr-group/gr-group_test.js
@@ -94,6 +94,7 @@
element.$.groupNameInput.text = groupName2;
+ await flush();
assert.isFalse(button.hasAttribute('disabled'));
assert.isTrue(element.$.groupName.classList.contains('edited'));
@@ -122,6 +123,7 @@
element.$.groupOwnerInput.text = 'testId2';
+ await flush();
assert.isFalse(button.hasAttribute('disabled'));
assert.isTrue(element.$.groupOwner.classList.contains('edited'));
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
index 9eb9b07..2d3b5c3 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-config-array-editor/gr-plugin-config-array-editor.ts
@@ -28,7 +28,6 @@
PluginConfigOptionsChangedEventDetail,
ArrayPluginOption,
} from '../gr-repo-plugin-config/gr-repo-plugin-config-types';
-import {KeydownEvent} from '../../../types/events';
declare global {
interface HTMLElementTagNameMap {
@@ -75,7 +74,7 @@
this._handleAdd();
}
- _handleInputKeydown(e: KeydownEvent) {
+ _handleInputKeydown(e: KeyboardEvent) {
// Enter.
if (e.keyCode === 13) {
e.preventDefault();
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
index 13bd79d..9f51688 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
@@ -19,25 +19,21 @@
import '../../shared/gr-list-view/gr-list-view';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-plugin-list_html';
-import {
- ListViewMixin,
- ListViewParams,
-} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {customElement, property} from '@polymer/decorators';
import {PluginInfo} from '../../../types/common';
import {firePageError, fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
import {ErrorCallback} from '../../../api/rest';
+import {encodeURL, getBaseUrl} from '../../../utils/url-util';
+import {SHOWN_ITEMS_COUNT} from '../../../constants/constants';
+import {ListViewParams} from '../../gr-app-types';
interface PluginInfoWithName extends PluginInfo {
name: string;
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
@customElement('gr-plugin-list')
-export class GrPluginList extends base {
+export class GrPluginList extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -85,8 +81,8 @@
_paramsChanged(params: ListViewParams) {
this._loading = true;
- this._filter = this.getFilterValue(params);
- this._offset = this.getOffsetValue(params);
+ this._filter = params?.filter ?? '';
+ this._offset = Number(params?.offset ?? 0);
return this._getPlugins(this._filter, this._pluginsPerPage, this._offset);
}
@@ -114,7 +110,15 @@
}
_computePluginUrl(id: string) {
- return this.getUrl('/', id);
+ return getBaseUrl() + '/' + encodeURL(id, true);
+ }
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
+
+ computeShownItems(plugins: PluginInfoWithName[]) {
+ return plugins.slice(0, SHOWN_ITEMS_COUNT);
}
}
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
index fc7ef4b..7800653 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-dashboards/gr-repo-dashboards.ts
@@ -43,7 +43,7 @@
private readonly restApiService = appContext.restApiService;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
tableStyles,
@@ -63,7 +63,7 @@
];
}
- render() {
+ override render() {
return html` <table
id="list"
class="genericList ${this._computeLoadingClass(this._loading)}"
@@ -114,7 +114,7 @@
</table>`;
}
- updated(changedProperties: PropertyValues) {
+ override updated(changedProperties: PropertyValues) {
if (changedProperties.has('repo')) {
this.repoChanged();
}
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
index 3693845..052e07a 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
@@ -30,7 +30,6 @@
import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-repo-detail-list_html';
-import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {encodeURL} from '../../../utils/url-util';
import {customElement, property} from '@polymer/decorators';
import {GrOverlay} from '../../shared/gr-overlay/gr-overlay';
@@ -49,6 +48,7 @@
import {firePageError} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
import {ErrorCallback} from '../../../api/rest';
+import {SHOWN_ITEMS_COUNT} from '../../../constants/constants';
const PGP_START = '-----BEGIN PGP SIGNATURE-----';
@@ -60,11 +60,8 @@
};
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
@customElement('gr-repo-detail-list')
-export class GrRepoDetailList extends base {
+export class GrRepoDetailList extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -85,7 +82,7 @@
_loggedIn = false;
@property({type: Number})
- _offset?: number;
+ _offset = 0;
@property({type: String})
_repo?: RepoName;
@@ -155,8 +152,8 @@
this.detailType = params.detail;
- this._filter = this.getFilterValue(params);
- this._offset = this.getOffsetValue(params);
+ this._filter = params?.filter ?? '';
+ this._offset = Number(params?.offset ?? 0);
if (!this.detailType)
return Promise.reject(new Error('undefined detailType'));
@@ -395,6 +392,14 @@
_computeHideTagger(tagger?: GitPersonInfo) {
return tagger ? '' : 'hide';
}
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
+
+ computeShownItems(items: BranchInfo[] | TagInfo[]) {
+ return items.slice(0, SHOWN_ITEMS_COUNT);
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_html.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_html.ts
index 4f66f0d..429a6d6 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_html.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_html.ts
@@ -145,10 +145,7 @@
<td class$="tagger [[_hideIfBranch(detailType)]]">
<div class$="tagger [[_computeHideTagger(item.tagger)]]">
<gr-account-link account="[[item.tagger]]"> </gr-account-link>
- (<gr-date-formatter
- has-tooltip=""
- date-str="[[item.tagger.date]]"
- >
+ (<gr-date-formatter withTooltip date-str="[[item.tagger.date]]">
</gr-date-formatter
>)
</div>
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
index e87bb0d..adcfb64 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-list/gr-repo-list.ts
@@ -22,16 +22,16 @@
import '../gr-create-repo-dialog/gr-create-repo-dialog';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-repo-list_html';
-import {ListViewMixin} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {customElement, property, observe, computed} from '@polymer/decorators';
import {AppElementAdminParams} from '../../gr-app-types';
import {GrOverlay} from '../../shared/gr-overlay/gr-overlay';
import {RepoName, ProjectInfoWithName} from '../../../types/common';
import {GrCreateRepoDialog} from '../gr-create-repo-dialog/gr-create-repo-dialog';
-import {ProjectState} from '../../../constants/constants';
+import {ProjectState, SHOWN_ITEMS_COUNT} from '../../../constants/constants';
import {fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
+import {encodeURL, getBaseUrl} from '../../../utils/url-util';
declare global {
interface HTMLElementTagNameMap {
@@ -46,11 +46,8 @@
};
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
@customElement('gr-repo-list')
-export class GrRepoList extends base {
+export class GrRepoList extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -59,7 +56,7 @@
params?: AppElementAdminParams;
@property({type: Number})
- _offset?: number;
+ _offset = 0;
@property({type: String})
readonly _path = '/admin/repos';
@@ -84,7 +81,7 @@
@computed('_repos')
get _shownRepos() {
- return this.computeShownItems(this._repos);
+ return this._repos.slice(0, SHOWN_ITEMS_COUNT);
}
private readonly restApiService = appContext.restApiService;
@@ -99,8 +96,8 @@
@observe('params')
_paramsChanged(params: AppElementAdminParams) {
this._loading = true;
- this._filter = this.getFilterValue(params);
- this._offset = this.getOffsetValue(params);
+ this._filter = params?.filter ?? '';
+ this._offset = Number(params?.offset ?? 0);
return this._getRepos(this._filter, this._reposPerPage, this._offset);
}
@@ -115,7 +112,7 @@
}
_computeRepoUrl(name: string) {
- return this.getUrl(this._path + '/', name);
+ return getBaseUrl() + this._path + '/' + encodeURL(name, true);
}
_computeChangesLink(name: string) {
@@ -185,4 +182,8 @@
const webLinks = repo.web_links;
return webLinks.length ? webLinks : null;
}
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
}
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
index 02339cf..32812dd 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-plugin-config/gr-repo-plugin-config.ts
@@ -119,15 +119,7 @@
private renderOption(option: PluginOption) {
return html`
<section class="section ${option.info.type}">
- <span class="title">
- <gr-tooltip-content
- has-tooltip="${option.info.description}"
- show-icon="${option.info.description}"
- title="${option.info.description}"
- >
- <span>${option.info.display_name}</span>
- </gr-tooltip-content>
- </span>
+ <span class="title"> ${this.renderOptionTitle(option)} </span>
<span class="value">
${this.renderOptionDetail(option)} ${this.renderInherited(option)}
</span>
@@ -135,12 +127,24 @@
`;
}
+ private renderOptionTitle(option: PluginOption) {
+ const titleName = html`<span>${option.info.display_name}</span>`;
+ if (!option.info.description) return titleName;
+ return html` <gr-tooltip-content
+ has-tooltip
+ show-icon
+ title="${option.info.description}"
+ >
+ ${titleName}
+ </gr-tooltip-content>`;
+ }
+
private renderOptionDetail(option: PluginOption) {
if (option.info.type === ConfigParameterInfoType.ARRAY) {
return html`
<gr-plugin-config-array-editor
@plugin-config-option-changed=${this._handleArrayChange}
- plugin-option="${option}"
+ .pluginOption="${option}"
></gr-plugin-config-array-editor>
`;
} else if (option.info.type === ConfigParameterInfoType.BOOLEAN) {
@@ -155,7 +159,10 @@
`;
} else if (option.info.type === ConfigParameterInfoType.LIST) {
return html`
- <gr-select value=${option.info.value} @change=${this._handleListChange}>
+ <gr-select
+ .bindValue=${option.info.value}
+ @change=${this._handleListChange}
+ >
<select
data-option-key=${option._key}
?disabled=${!option.info.editable}
@@ -173,14 +180,12 @@
) {
return html`
<iron-input
- value=${option.info.value}
@input=${this._handleStringChange}
data-option-key="${option._key}"
- ?disabled=${!option.info.editable}
>
<input
is="iron-input"
- value="${option.info.value}"
+ .value="${option.info.value ?? ''}"
@input=${this._handleStringChange}
data-option-key="${option._key}"
?disabled=${!option.info.editable}
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
index 313b91f..c476d2d 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item.ts
@@ -28,7 +28,6 @@
import '../../plugins/gr-endpoint-param/gr-endpoint-param';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-change-list-item_html';
-import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {getDisplayName} from '../../../utils/display-name-util';
import {getPluginEndpoints} from '../../shared/gr-js-api-interface/gr-plugin-endpoints';
@@ -76,11 +75,8 @@
// How many reviewers should be shown with an account-label?
const PRIMARY_REVIEWERS_COUNT = 2;
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ChangeTableMixin(PolymerElement);
-
@customElement('gr-change-list-item')
-export class GrChangeListItem extends base {
+export class GrChangeListItem extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -288,7 +284,7 @@
* @param truncate whether or not the project name should be
* truncated. If this value is truthy, the name will be truncated.
*/
- _computeRepoDisplay(change: ChangeInfo | undefined, truncate: boolean) {
+ _computeRepoDisplay(change?: ChangeInfo) {
if (!change?.project) {
return '';
}
@@ -296,7 +292,19 @@
if (change.internalHost) {
str += change.internalHost + '/';
}
- str += truncate ? truncatePath(change.project, 2) : change.project;
+ str += change.project;
+ return str;
+ }
+
+ _computeTruncatedRepoDisplay(change?: ChangeInfo) {
+ if (!change?.project) {
+ return '';
+ }
+ let str = '';
+ if (change.internalHost) {
+ str += change.internalHost + '/';
+ }
+ str += truncatePath(change.project, 2);
return str;
}
@@ -354,10 +362,7 @@
return this._computeAdditionalReviewers(change).length;
}
- _computeAdditionalReviewersTitle(
- change: ChangeInfo | undefined,
- config: ServerInfo
- ) {
+ _computeAdditionalReviewersTitle(change?: ChangeInfo, config?: ServerInfo) {
if (!change || !config) return '';
return this._computeAdditionalReviewers(change)
.map(user => getDisplayName(config, user, true))
@@ -393,13 +398,20 @@
}
_computeWaiting(
- account?: AccountInfo,
- change?: ChangeInfo
+ account?: AccountInfo | null,
+ change?: ChangeInfo | null
): Timestamp | undefined {
if (!account?._account_id || !change?.attention_set) return undefined;
return change?.attention_set[account._account_id]?.last_update;
}
+ _computeIsColumnHidden(columnToCheck?: string, columnsToDisplay?: string[]) {
+ if (!columnsToDisplay || !columnToCheck) {
+ return false;
+ }
+ return !columnsToDisplay.includes(columnToCheck);
+ }
+
toggleReviewed() {
if (!this.change) return;
const newVal = !this.change?.reviewed;
@@ -417,6 +429,11 @@
);
}
+ _formatDate(date: Timestamp | undefined): string | undefined {
+ if (!date) return undefined;
+ return date.toString();
+ }
+
_handleChangeClick() {
// Don't prevent the default and neither stop bubbling. We just want to
// report the click, but then let the browser handle the click on the link.
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_html.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_html.ts
index 8ee6a3f..a0aa962 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_html.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_html.ts
@@ -127,7 +127,7 @@
</td>
<td
class="cell subject"
- hidden$="[[isColumnHidden('Subject', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Subject', visibleChangeTableColumns)]]"
>
<a
title$="[[change.subject]]"
@@ -143,7 +143,7 @@
</td>
<td
class="cell status"
- hidden$="[[isColumnHidden('Status', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Status', visibleChangeTableColumns)]]"
>
<template is="dom-repeat" items="[[statuses]]" as="status">
<div class="comma">,</div>
@@ -155,7 +155,7 @@
</td>
<td
class="cell owner"
- hidden$="[[isColumnHidden('Owner', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Owner', visibleChangeTableColumns)]]"
>
<gr-account-link
highlightAttention
@@ -165,7 +165,7 @@
</td>
<td
class="cell assignee"
- hidden$="[[isColumnHidden('Assignee', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Assignee', visibleChangeTableColumns)]]"
>
<template is="dom-if" if="[[change.assignee]]">
<gr-account-link
@@ -179,7 +179,7 @@
</td>
<td
class="cell reviewers"
- hidden$="[[isColumnHidden('Reviewers', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Reviewers', visibleChangeTableColumns)]]"
>
<div>
<template
@@ -204,14 +204,14 @@
</template>
<template is="dom-if" if="[[_computeAdditionalReviewersCount(change)]]">
<span title="[[_computeAdditionalReviewersTitle(change, config)]]">
- +[[_computeAdditionalReviewersCount(change, config)]]
+ +[[_computeAdditionalReviewersCount(change)]]
</span>
</template>
</div>
</td>
<td
class="cell comments"
- hidden$="[[isColumnHidden('Comments', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Comments', visibleChangeTableColumns)]]"
>
<iron-icon
hidden$="[[!change.unresolved_comment_count]]"
@@ -221,7 +221,7 @@
</td>
<td
class="cell repo"
- hidden$="[[isColumnHidden('Repo', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Repo', visibleChangeTableColumns)]]"
>
<a class="fullRepo" href$="[[_computeRepoUrl(change)]]">
[[_computeRepoDisplay(change)]]
@@ -231,12 +231,12 @@
href$="[[_computeRepoUrl(change)]]"
title$="[[_computeRepoDisplay(change)]]"
>
- [[_computeRepoDisplay(change, 'true')]]
+ [[_computeTruncatedRepoDisplay(change)]]
</a>
</td>
<td
class="cell branch"
- hidden$="[[isColumnHidden('Branch', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Branch', visibleChangeTableColumns)]]"
>
<a href$="[[_computeRepoBranchURL(change)]]"> [[change.branch]] </a>
<template is="dom-if" if="[[change.topic]]">
@@ -250,38 +250,38 @@
</td>
<td
class="cell updated"
- hidden$="[[isColumnHidden('Updated', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Updated', visibleChangeTableColumns)]]"
>
<gr-date-formatter
- has-tooltip=""
- date-str="[[change.updated]]"
+ withTooltip
+ date-str="[[_formatDate(change.updated)]]"
></gr-date-formatter>
</td>
<td
class="cell submitted"
- hidden$="[[isColumnHidden('Submitted', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Submitted', visibleChangeTableColumns)]]"
>
<gr-date-formatter
- has-tooltip=""
- date-str="[[change.submitted]]"
+ withTooltip
+ date-str="[[_formatDate(change.submitted)]]"
></gr-date-formatter>
</td>
<td
class="cell waiting"
- hidden$="[[isColumnHidden('Waiting', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Waiting', visibleChangeTableColumns)]]"
>
<gr-date-formatter
- has-tooltip=""
- force-relative=""
- relative-option-no-ago=""
+ withTooltip
+ forceRelative
+ relativeOptionNoAgo
date-str="[[_computeWaiting(account, change)]]"
></gr-date-formatter>
</td>
<td
class="cell size"
- hidden$="[[isColumnHidden('Size', visibleChangeTableColumns)]]"
+ hidden$="[[_computeIsColumnHidden('Size', visibleChangeTableColumns)]]"
>
- <gr-tooltip-content has-tooltip="" title="[[_computeSizeTooltip(change)]]">
+ <gr-tooltip-content has-tooltip title="[[_computeSizeTooltip(change)]]">
<template is="dom-if" if="[[_changeSize]]">
<span>[[_changeSize]]</span>
</template>
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts
index ac0b929..34cb6eb 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-item/gr-change-list-item_test.ts
@@ -29,6 +29,7 @@
TopicName,
} from '../../../types/common';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
+import {columnNames} from '../gr-change-list/gr-change-list';
import './gr-change-list-item';
import {GrChangeListItem, LabelCategory} from './gr-change-list-item';
@@ -372,7 +373,7 @@
await flush();
- for (const column of element.columnNames) {
+ for (const column of columnNames) {
const elementClass = '.' + column.toLowerCase();
assert.isFalse(
queryAndAssert(element, elementClass).hasAttribute('hidden')
@@ -395,7 +396,7 @@
await flush();
- for (const column of element.columnNames) {
+ for (const column of columnNames) {
const elementClass = '.' + column.toLowerCase();
if (column === 'Repo') {
assert.isTrue(
@@ -565,13 +566,13 @@
});
test('_computeRepoDisplay', () => {
+ assert.equal(element._computeRepoDisplay(change), 'host/a/test/repo');
assert.equal(
- element._computeRepoDisplay(change, false),
- 'host/a/test/repo'
+ element._computeTruncatedRepoDisplay(change),
+ 'host/…/test/repo'
);
- assert.equal(element._computeRepoDisplay(change, true), 'host/…/test/repo');
delete change.internalHost;
- assert.equal(element._computeRepoDisplay(change, false), 'a/test/repo');
- assert.equal(element._computeRepoDisplay(change, true), '…/test/repo');
+ assert.equal(element._computeRepoDisplay(change), 'a/test/repo');
+ assert.equal(element._computeTruncatedRepoDisplay(change), '…/test/repo');
});
});
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
index 9970dd5..2360312 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list-view/gr-change-list-view.ts
@@ -39,6 +39,7 @@
import {fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
import {GerritView} from '../../../services/router/router-model';
+import {RELOAD_DASHBOARD_INTERVAL_MS} from '../../../constants/constants';
const LOOKUP_QUERY_PATTERNS: RegExp[] = [
/^\s*i?[0-9a-f]{7,40}\s*$/i, // CHANGE_ID
@@ -112,10 +113,26 @@
private reporting = appContext.reportingService;
+ private lastVisibleTimestampMs = 0;
+
constructor() {
super();
this.addEventListener('next-page', () => this._handleNextPage());
this.addEventListener('previous-page', () => this._handlePreviousPage());
+ this.addEventListener('reload', () => this.reload());
+ // We are not currently verifying if the view is actually visible. We rely
+ // on gr-app-element to restamp the component if view changes
+ document.addEventListener('visibilitychange', () => {
+ if (document.visibilityState === 'visible') {
+ if (
+ Date.now() - this.lastVisibleTimestampMs >
+ RELOAD_DASHBOARD_INTERVAL_MS
+ )
+ this.reload();
+ } else {
+ this.lastVisibleTimestampMs = Date.now();
+ }
+ });
}
override connectedCallback() {
@@ -123,6 +140,15 @@
this._loadPreferences();
}
+ reload() {
+ if (this._loading) return;
+ this._loading = true;
+ this._getChanges().then(changes => {
+ this._changes = changes || [];
+ this._loading = false;
+ });
+ }
+
_paramsChanged(value: AppElementParams) {
if (value.view !== GerritView.SEARCH) return;
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
index 40674d4..ac44908 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list.ts
@@ -24,7 +24,6 @@
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-change-list_html';
import {appContext} from '../../../services/app-context';
-import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
import {
KeyboardShortcutMixin,
Shortcut,
@@ -47,9 +46,9 @@
PreferencesInput,
} from '../../../types/common';
import {hasAttention} from '../../../utils/attention-set-util';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {fireEvent, fireReload} from '../../../utils/event-util';
-import {isShiftPressed} from '../../../utils/dom-util';
+import {isShiftPressed, modifierPressed} from '../../../utils/dom-util';
import {ScrollMode} from '../../../constants/constants';
const NUMBER_FIXED_COLUMNS = 3;
@@ -57,6 +56,19 @@
const LABEL_PREFIX_INVALID_PROLOG = 'Invalid-Prolog-Rules-Label-Name--';
const MAX_SHORTCUT_CHARS = 5;
+export const columnNames = [
+ 'Subject',
+ 'Status',
+ 'Owner',
+ 'Assignee',
+ 'Reviewers',
+ 'Comments',
+ 'Repo',
+ 'Branch',
+ 'Updated',
+ 'Size',
+];
+
export interface ChangeListSection {
name?: string;
query?: string;
@@ -68,7 +80,7 @@
}
// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ChangeTableMixin(KeyboardShortcutMixin(PolymerElement));
+const base = KeyboardShortcutMixin(PolymerElement);
@customElement('gr-change-list')
export class GrChangeList extends base {
@@ -145,6 +157,8 @@
private readonly restApiService = appContext.restApiService;
+ private readonly shortcuts = appContext.shortcutsService;
+
override keyboardShortcuts() {
return {
[Shortcut.CURSOR_NEXT_CHANGE]: '_nextChange',
@@ -164,9 +178,7 @@
super();
this.cursor.scrollMode = ScrollMode.KEEP_VISIBLE;
this.cursor.focusOnMove = true;
- this.addEventListener('keydown', e =>
- this._scopedKeydownHandler(e as unknown as CustomKeyboardEvent)
- );
+ this.addEventListener('keydown', e => this._scopedKeydownHandler(e));
}
override ready() {
@@ -198,10 +210,10 @@
*
* Context: Issue 7294
*/
- _scopedKeydownHandler(e: CustomKeyboardEvent) {
+ _scopedKeydownHandler(e: KeyboardEvent) {
if (e.keyCode === 13) {
// Enter.
- this._openChange(e);
+ this.openChange(e);
}
}
@@ -219,32 +231,44 @@
return;
}
- this.changeTableColumns = this.columnNames;
+ this.changeTableColumns = columnNames;
this.showNumber = false;
- this.visibleChangeTableColumns = this.getEnabledColumns(
- this.columnNames,
- config,
- this.flagsService.enabledExperiments
+ this.visibleChangeTableColumns = this.changeTableColumns.filter(col =>
+ this._isColumnEnabled(col, config, this.flagsService.enabledExperiments)
);
-
if (account && preferences) {
this.showNumber = !!(
preferences && preferences.legacycid_in_change_table
);
if (preferences.change_table && preferences.change_table.length > 0) {
- const prefColumns = this.renameProjectToRepoColumn(
- preferences.change_table
+ const prefColumns = preferences.change_table.map(column =>
+ column === 'Project' ? 'Repo' : column
);
- this.visibleChangeTableColumns = this.getEnabledColumns(
- prefColumns,
- config,
- this.flagsService.enabledExperiments
+ this.visibleChangeTableColumns = prefColumns.filter(col =>
+ this._isColumnEnabled(
+ col,
+ config,
+ this.flagsService.enabledExperiments
+ )
);
}
}
}
/**
+ * Is the column disabled by a server config or experiment? For example the
+ * assignee feature might be disabled and thus the corresponding column is
+ * also disabled.
+ *
+ */
+ _isColumnEnabled(column: string, config: ServerInfo, experiments: string[]) {
+ if (!config || !config.change) return true;
+ if (column === 'Assignee') return !!config.change.enable_assignee;
+ if (column === 'Comments') return experiments.includes('comments-column');
+ return true;
+ }
+
+ /**
* This methods allows us to customize the columns per section.
*
* @param visibleColumns are the columns according to configs and user prefs
@@ -382,8 +406,8 @@
);
}
- _nextChange(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _nextChange(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -394,8 +418,8 @@
this.selectedIndex = this.cursor.index;
}
- _prevChange(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _prevChange(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -406,19 +430,21 @@
this.selectedIndex = this.cursor.index;
}
- _openChange(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
- return;
- }
+ _openChange(e: IronKeyboardEvent) {
+ if (this.modifierPressed(e)) return;
+ this.openChange(e.detail.keyboardEvent);
+ }
+ openChange(e: KeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || modifierPressed(e)) return;
e.preventDefault();
const change = this._changeForIndex(this.selectedIndex);
if (change) GerritNav.navigateToChange(change);
}
- _nextPage(e: CustomKeyboardEvent) {
+ _nextPage(e: IronKeyboardEvent) {
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
(this.modifierPressed(e) && !isShiftPressed(e))
) {
return;
@@ -428,9 +454,9 @@
fireEvent(this, 'next-page');
}
- _prevPage(e: CustomKeyboardEvent) {
+ _prevPage(e: IronKeyboardEvent) {
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
(this.modifierPressed(e) && !isShiftPressed(e))
) {
return;
@@ -445,8 +471,8 @@
);
}
- _toggleChangeReviewed(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _toggleChangeReviewed(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -464,8 +490,8 @@
changeEl.toggleReviewed();
}
- _refreshChangeList(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _refreshChangeList(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
@@ -473,8 +499,8 @@
fireReload(this);
}
- _toggleChangeStar(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _toggleChangeStar(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
diff --git a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.js b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.js
index 0d2056a..4956380 100644
--- a/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.js
+++ b/polygerrit-ui/app/elements/change-list/gr-change-list/gr-change-list_test.js
@@ -19,8 +19,7 @@
import './gr-change-list.js';
import {afterNextRender} from '@polymer/polymer/lib/utils/render-status.js';
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
-import {mockPromise, TestKeyboardShortcutBinder} from '../../../test/test-utils.js';
-import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
+import {mockPromise} from '../../../test/test-utils.js';
import {YOUR_TURN} from '../../core/gr-navigation/gr-navigation.js';
const basicFixture = fixtureFromElement('gr-change-list');
@@ -28,22 +27,6 @@
suite('gr-change-list basic tests', () => {
let element;
- suiteSetup(() => {
- const kb = TestKeyboardShortcutBinder.push();
- kb.bindShortcut(Shortcut.CURSOR_NEXT_CHANGE, 'j');
- kb.bindShortcut(Shortcut.CURSOR_PREV_CHANGE, 'k');
- kb.bindShortcut(Shortcut.OPEN_CHANGE, 'o');
- kb.bindShortcut(Shortcut.REFRESH_CHANGE_LIST, 'shift+r');
- kb.bindShortcut(Shortcut.TOGGLE_CHANGE_REVIEWED, 'r');
- kb.bindShortcut(Shortcut.TOGGLE_CHANGE_STAR, 's');
- kb.bindShortcut(Shortcut.NEXT_PAGE, 'n');
- kb.bindShortcut(Shortcut.NEXT_PAGE, 'p');
- });
-
- suiteTeardown(() => {
- TestKeyboardShortcutBinder.pop();
- });
-
setup(() => {
element = basicFixture.instantiate();
});
@@ -269,7 +252,7 @@
});
test('all columns visible', () => {
- for (const column of element.columnNames) {
+ for (const column of element.changeTableColumns) {
const elementClass = '.' + element._lowerCase(column);
assert.isFalse(element.shadowRoot
.querySelector(elementClass).hidden);
@@ -495,11 +478,11 @@
assert.deepEqual(navStub.lastCall.args[0], {_number: 4},
'Should navigate to /c/4/');
- MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
+ MockInteractions.keyUpOn(element, 82); // 'r'
const change = element._changeForIndex(element.selectedIndex);
assert.equal(change.reviewed, true,
'Should mark change as reviewed');
- MockInteractions.pressAndReleaseKeyOn(element, 82); // 'r'
+ MockInteractions.keyUpOn(element, 82); // 'r'
assert.equal(change.reviewed, false,
'Should mark change as unreviewed');
promise.resolve();
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
index c341dea..9eca3bc 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view.ts
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../gr-change-list/gr-change-list';
import '../../shared/gr-button/gr-button';
@@ -54,9 +55,9 @@
import {DashboardViewState} from '../../../types/types';
import {firePageError, fireTitleChange} from '../../../utils/event-util';
import {GerritView} from '../../../services/router/router-model';
+import {RELOAD_DASHBOARD_INTERVAL_MS} from '../../../constants/constants';
const PROJECT_PLACEHOLDER_PATTERN = /\${project}/g;
-const RELOAD_DASHBOARD_INTERVAL_MS = 10 * 1000;
export interface GrDashboardView {
$: {
@@ -122,12 +123,9 @@
constructor() {
super();
- }
-
- override connectedCallback() {
- super.connectedCallback();
- this._loadPreferences();
this.addEventListener('reload', () => this._reload(this.params));
+ // We are not currently verifying if the view is actually visible. We rely
+ // on gr-app-element to restamp the component if view changes
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
if (
@@ -141,6 +139,11 @@
});
}
+ override connectedCallback() {
+ super.connectedCallback();
+ this._loadPreferences();
+ }
+
_loadPreferences() {
return this.restApiService.getLoggedIn().then(loggedIn => {
if (loggedIn) {
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_html.ts b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_html.ts
index 484a952..a55befb 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_html.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
display: block;
@@ -39,11 +42,6 @@
justify-content: space-between;
padding: var(--spacing-xs) var(--spacing-l);
}
- .banner gr-button {
- --gr-button: {
- color: var(--primary-text-color);
- }
- }
.hide {
display: none;
}
diff --git a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
index 96a19e0..aa76347 100644
--- a/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
+++ b/polygerrit-ui/app/elements/change-list/gr-dashboard-view/gr-dashboard-view_test.js
@@ -128,7 +128,7 @@
// Open confirmation dialog and tap confirm button.
await element.$.confirmDeleteOverlay.open();
- MockInteractions.tap(element.$.confirmDeleteDialog.$.confirm);
+ MockInteractions.tap(element.$.confirmDeleteDialog.confirmButton);
flush();
assert.isTrue(deleteStub.calledWithExactly('-is:open'));
assert.isTrue(element.$.confirmDeleteDialog.disabled);
diff --git a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
index beadea3..d8949ed 100644
--- a/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-repo-header/gr-repo-header.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import '../../shared/gr-date-formatter/gr-date-formatter';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {RepoName} from '../../../types/common';
import {WebLinkInfo} from '../../../types/diff';
@@ -73,7 +72,7 @@
<h1 class="heading-1">${this.repo}</h1>
<hr />
<div>
- <span>Detail:</span> <a href="${this._repoUrl}">Repo settings</a>
+ <span>Detail:</span> <a href="${this._repoUrl!}">Repo settings</a>
</div>
${this._renderLinks(this._webLinks)}
</div>`;
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
index bc21dc0..50de7b9 100644
--- a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.ts
@@ -48,7 +48,7 @@
private readonly restApiService = appContext.restApiService;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
dashboardHeaderStyles,
@@ -63,8 +63,8 @@
];
}
- render() {
- return html` <gr-avatar
+ override render() {
+ return html`<gr-avatar
.account="${this._accountDetails}"
.imageSize=${100}
aria-label="Account avatar"
@@ -85,7 +85,7 @@
<div>
<span>Joined:</span>
<gr-date-formatter
- date-str="${this._computeDetail(
+ dateStr="${this._computeDetail(
this._accountDetails,
'registered_on'
)}"
@@ -95,10 +95,10 @@
<gr-endpoint-decorator name="user-header">
<gr-endpoint-param
name="accountDetails"
- value="${this._accountDetails}"
+ .value="${this._accountDetails}"
>
</gr-endpoint-param>
- <gr-endpoint-param name="loggedIn" value="${this.loggedIn}">
+ <gr-endpoint-param name="loggedIn" .value="${this.loggedIn}">
</gr-endpoint-param>
</gr-endpoint-decorator>
</div>
@@ -116,7 +116,7 @@
</div>`;
}
- updated(changedProperties: PropertyValues) {
+ override updated(changedProperties: PropertyValues) {
if (changedProperties.has('userId')) {
this._accountChanged(this.userId);
}
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_html.ts b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_html.ts
index 614339a..d21c29f 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_html.ts
@@ -33,6 +33,9 @@
/* px because don't have the same font size */
margin-left: 8px;
}
+ gr-button {
+ display: block;
+ }
#actionLoadingMessage {
align-items: center;
color: var(--deemphasized-text-color);
@@ -57,10 +60,8 @@
flex-wrap: wrap;
}
gr-button {
- --gr-button: {
- padding: var(--spacing-m);
- white-space: nowrap;
- }
+ --gr-button-padding: var(--spacing-m);
+ white-space: nowrap;
}
gr-button,
gr-dropdown {
@@ -84,24 +85,27 @@
hidden$="[[_shouldHideActions(_topLevelActions.*, _loading)]]"
>
<template is="dom-repeat" items="[[_topLevelPrimaryActions]]" as="action">
- <gr-button
- link=""
+ <gr-tooltip-content
title$="[[action.title]]"
has-tooltip="[[_computeHasTooltip(action.title)]]"
position-below="true"
- data-action-key$="[[action.__key]]"
- class$="[[action.__key]]"
- data-action-type$="[[action.__type]]"
- data-label$="[[action.label]]"
- disabled$="[[_calculateDisabled(action, _hasKnownChainState)]]"
- on-click="_handleActionTap"
>
- <iron-icon
- class$="[[_computeHasIcon(action)]]"
- icon$="gr-icons:[[action.icon]]"
- ></iron-icon>
- [[action.label]]
- </gr-button>
+ <gr-button
+ link=""
+ data-action-key$="[[action.__key]]"
+ class$="[[action.__key]]"
+ data-action-type$="[[action.__type]]"
+ data-label$="[[action.label]]"
+ disabled$="[[_calculateDisabled(action, _hasKnownChainState)]]"
+ on-click="_handleActionTap"
+ >
+ <iron-icon
+ class$="[[_computeHasIcon(action)]]"
+ icon$="gr-icons:[[action.icon]]"
+ ></iron-icon>
+ [[action.label]]
+ </gr-button>
+ </gr-tooltip-content>
</template>
</section>
<section
@@ -113,24 +117,27 @@
items="[[_topLevelSecondaryActions]]"
as="action"
>
- <gr-button
- link=""
+ <gr-tooltip-content
title$="[[action.title]]"
has-tooltip="[[_computeHasTooltip(action.title)]]"
position-below="true"
- data-action-key$="[[action.__key]]"
- class$="[[action.__key]]"
- data-action-type$="[[action.__type]]"
- data-label$="[[action.label]]"
- disabled$="[[_calculateDisabled(action, _hasKnownChainState)]]"
- on-click="_handleActionTap"
>
- <iron-icon
- class$="[[_computeHasIcon(action)]]"
- icon$="gr-icons:[[action.icon]]"
- ></iron-icon>
- [[action.label]]
- </gr-button>
+ <gr-button
+ link=""
+ data-action-key$="[[action.__key]]"
+ class$="[[action.__key]]"
+ data-action-type$="[[action.__type]]"
+ data-label$="[[action.label]]"
+ disabled$="[[_calculateDisabled(action, _hasKnownChainState)]]"
+ on-click="_handleActionTap"
+ >
+ <iron-icon
+ class$="[[_computeHasIcon(action)]]"
+ icon$="gr-icons:[[action.icon]]"
+ ></iron-icon>
+ [[action.label]]
+ </gr-button>
+ </gr-tooltip-content>
</template>
</section>
<gr-button hidden$="[[!_loading]]" disabled=""
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.ts b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.ts
index 906300f..26e2fb4 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.ts
@@ -54,7 +54,7 @@
} from '../../../types/common';
import {ActionType} from '../../../api/change-actions';
import {tap} from '@polymer/iron-test-helpers/mock-interactions';
-import {SinonFakeTimers} from 'sinon/pkg/sinon-esm';
+import {SinonFakeTimers} from 'sinon';
import {IronAutogrowTextareaElement} from '@polymer/iron-autogrow-textarea';
import {GrButton} from '../../shared/gr-button/gr-button';
import {GrDialog} from '../../shared/gr-dialog/gr-dialog';
@@ -1094,7 +1094,7 @@
);
tap(abandonButton);
- assert.isUndefined(element.$.confirmAbandonDialog.message);
+ assert.equal(element.$.confirmAbandonDialog.message, '');
});
test('works', () => {
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
index 08ad2bd..ba62ec3 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import '../../../styles/shared-styles';
+import '../../../styles/gr-font-styles';
import '../../../styles/gr-change-metadata-shared-styles';
import '../../../styles/gr-change-view-integration-shared-styles';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
index c080345..26d1277 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_html.ts
@@ -20,6 +20,9 @@
<style include="gr-change-metadata-shared-styles">
/* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
</style>
+ <style include="gr-font-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
display: table;
@@ -94,7 +97,6 @@
max-width: 285px;
}
.metadata-title {
- font-weight: var(--font-weight-bold);
color: var(--deemphasized-text-color);
padding-left: var(--metadata-horizontal-padding);
}
@@ -114,7 +116,7 @@
</style>
<gr-external-style id="externalStyle" name="change-metadata">
<div class="metadata-header">
- <h3 class="metadata-title">Change Info</h3>
+ <h3 class="metadata-title heading-3">Change Info</h3>
<gr-button link="" class="show-all-button" on-click="_onShowAllClick"
>[[_computeShowAllLabelText(_showAllSections)]]
<iron-icon
@@ -134,9 +136,9 @@
<span class="title">Submitted</span>
<span class="value">
<gr-date-formatter
- has-tooltip=""
+ withTooltip
date-str="[[change.submitted]]"
- show-yesterday=""
+ showYesterday=""
></gr-date-formatter>
</span>
</section>
@@ -154,9 +156,9 @@
</span>
<span class="value">
<gr-date-formatter
- has-tooltip=""
+ withTooltip
date-str="[[change.updated]]"
- show-yesterday=""
+ showYesterday
></gr-date-formatter>
</span>
</section>
@@ -354,8 +356,8 @@
></gr-commit-info>
<gr-tooltip-content
id="parentNotCurrentMessage"
- has-tooltip=""
- show-icon=""
+ has-tooltip
+ show-icon
title$="[[_notCurrentMessage]]"
></gr-tooltip-content>
</li>
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
index cb4c9a4..422c91b 100644
--- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.ts
@@ -57,7 +57,7 @@
LabelValueToDescriptionMap,
Hashtag,
} from '../../../types/common';
-import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonStubbedMember} from 'sinon';
import {RestApiService} from '../../../services/gr-rest-api/gr-rest-api';
import {tap} from '@polymer/iron-test-helpers/mock-interactions';
import {GrEditableLabel} from '../../shared/gr-editable-label/gr-editable-label';
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
index 6a31c0a..725bb24 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements.ts
@@ -15,9 +15,9 @@
* limitations under the License.
*/
import '../../../styles/shared-styles';
+import '../../../styles/gr-font-styles';
import '../../shared/gr-button/gr-button';
import '../../shared/gr-icons/gr-icons';
-import '../../shared/gr-label/gr-label';
import '../../shared/gr-label-info/gr-label-info';
import '../../shared/gr-limited-text/gr-limited-text';
import {PolymerElement} from '@polymer/polymer/polymer-element';
diff --git a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
index d824d94..8161592 100644
--- a/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-requirements/gr-change-requirements_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-font-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
display: table;
@@ -104,7 +107,7 @@
padding-left: 0;
}
</style>
- <h3 class="metadata-title">Submit requirements</h3>
+ <h3 class="metadata-title heading-3">Submit requirements</h3>
<template is="dom-repeat" items="[[_requirements]]">
<gr-endpoint-decorator
class="submit-requirement-endpoints"
diff --git a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
index 90b9a2d..ad8f72f 100644
--- a/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-summary/gr-change-summary.ts
@@ -30,9 +30,10 @@
someProvidersAreLoadingFirstTime$,
topLevelActionsLatest$,
} from '../../../services/checks/checks-model';
-import {Action, Category, RunStatus} from '../../../api/checks';
+import {Action, Category, Link, RunStatus} from '../../../api/checks';
import {fireShowPrimaryTab} from '../../../utils/event-util';
import '../../shared/gr-avatar/gr-avatar';
+import '../../checks/gr-checks-action';
import {
firstPrimaryLink,
getResultsOf,
@@ -180,6 +181,9 @@
@property()
text = '';
+ @property()
+ links: Link[] = [];
+
static override get styles() {
return [
fontStyles,
@@ -187,6 +191,8 @@
css`
:host {
display: inline-block;
+ position: relative;
+ white-space: nowrap;
}
.checksChip {
color: var(--chip-color);
@@ -202,8 +208,16 @@
position: relative;
top: 2px;
}
- .checksChip:hover .text {
- max-width: 240px;
+ .checksChip.hoverFullLength {
+ position: absolute;
+ z-index: 1;
+ display: none;
+ }
+ .checksChip.hoverFullLength .text {
+ max-width: 400px;
+ }
+ :host(:hover) .checksChip.hoverFullLength {
+ display: inline-block;
}
.checksChip .text {
display: inline-block;
@@ -276,8 +290,6 @@
color: var(--success-foreground);
}
.checksChip.timelapse {
- }
- .checksChip.timelapse {
border-color: var(--gray-foreground);
background: var(--gray-background);
}
@@ -308,20 +320,51 @@
ariaLabel = `${this.text} ${label} ${type}${plural}`;
}
const chipClass = `checksChip font-small ${icon}`;
+ const chipClassFullLength = `${chipClass} hoverFullLength`;
const grIcon = `gr-icons:${icon}`;
+ // 15 is roughly the number of chars for the chip exceeding its 120px width.
return html`
- <div
- class="${chipClass}"
- role="link"
- tabindex="0"
- aria-label="${ariaLabel}"
- >
- <iron-icon icon="${grIcon}"></iron-icon>
+ ${this.text.length > 15
+ ? html` ${this.renderChip(chipClassFullLength, ariaLabel, grIcon)}`
+ : ''}
+ ${this.renderChip(chipClass, ariaLabel, grIcon)}
+ `;
+ }
+
+ private renderChip(clazz: string, ariaLabel: string, icon: string) {
+ return html`
+ <div class="${clazz}" role="link" tabindex="0" aria-label="${ariaLabel}">
+ <iron-icon icon="${icon}"></iron-icon>
<div class="text">${this.text}</div>
- <slot></slot>
+ ${this.renderLinks()}
</div>
`;
}
+
+ private renderLinks() {
+ return this.links.map(
+ link => html`
+ <a
+ href="${link.url}"
+ target="_blank"
+ @click="${this.onLinkClick}"
+ @keydown="${this.onLinkKeyDown}"
+ aria-label="Link to check details"
+ ><iron-icon class="launch" icon="gr-icons:launch"></iron-icon
+ ></a>
+ `
+ );
+ }
+
+ private onLinkKeyDown(e: KeyboardEvent) {
+ // Prevents onChipKeyDown() from reacting to <a> link keyboard events.
+ e.stopPropagation();
+ }
+
+ private onLinkClick(e: MouseEvent) {
+ // Prevents onChipClick() from reacting to <a> link clicks.
+ e.stopPropagation();
+ }
}
/** What is the maximum number of detailed checks chips? */
@@ -470,7 +513,7 @@
.actions gr-checks-action,
.actions gr-dropdown {
vertical-align: top;
- --padding: 0 var(--spacing-m);
+ --gr-button-padding: 0 var(--spacing-m);
}
.actions #moreMessage {
display: none;
@@ -618,7 +661,7 @@
const handler = () => this.onChipClick({statusOrCategory});
return html`<gr-checks-chip
.statusOrCategory="${statusOrCategory}"
- .text="${count}"
+ .text="${`${count}`}"
@click="${handler}"
@keydown="${(e: KeyboardEvent) => handleSpaceOrEnter(e, handler)}"
></gr-checks-chip>`;
@@ -660,21 +703,10 @@
return html`<gr-checks-chip
.statusOrCategory="${statusOrCategory}"
.text="${text}"
+ .links="${links}"
@click="${handler}"
@keydown="${(e: KeyboardEvent) => handleSpaceOrEnter(e, handler)}"
- >${links.map(
- link => html`
- <a
- href="${link.url}"
- target="_blank"
- @click="${this.onLinkClick}"
- @keydown="${this.onLinkKeyDown}"
- aria-label="Link to check details"
- ><iron-icon class="launch" icon="gr-icons:launch"></iron-icon
- ></a>
- `
- )}
- </gr-checks-chip>`;
+ ></gr-checks-chip>`;
}
private onChipClick(state: ChecksTabState) {
@@ -683,16 +715,6 @@
});
}
- private onLinkKeyDown(e: KeyboardEvent) {
- // Prevents onConChipKeyDown() from reacting to <a> link keyboard events.
- e.stopPropagation();
- }
-
- private onLinkClick(e: MouseEvent) {
- // Prevents onChipClick() from reacting to <a> link clicks.
- e.stopPropagation();
- }
-
override render() {
const commentThreads =
this.commentThreads?.filter(t => !isRobotThread(t) || hasHumanReply(t)) ??
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
index 58a00f4..fd7b5d1 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import '@polymer/paper-tabs/paper-tabs';
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../../diff/gr-comment-api/gr-comment-api';
import '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
@@ -23,7 +24,6 @@
import '../../shared/gr-button/gr-button';
import '../../shared/gr-change-star/gr-change-star';
import '../../shared/gr-change-status/gr-change-status';
-import '../../shared/gr-date-formatter/gr-date-formatter';
import '../../shared/gr-editable-content/gr-editable-content';
import '../../shared/gr-linked-text/gr-linked-text';
import '../../shared/gr-overlay/gr-overlay';
@@ -48,10 +48,11 @@
import {
KeyboardShortcutMixin,
Shortcut,
+ ShortcutSection,
} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {GrEditConstants} from '../../edit/gr-edit-constants';
import {pluralize} from '../../../utils/string-util';
-import {windowLocationReload} from '../../../utils/dom-util';
+import {windowLocationReload, querySelectorAll} from '../../../utils/dom-util';
import {
GeneratedWebLink,
GerritNav,
@@ -84,6 +85,7 @@
isCc,
isOwner,
isReviewer,
+ isInvolved,
} from '../../../utils/change-util';
import {EventType as PluginEventType} from '../../../api/plugin';
import {customElement, observe, property} from '@polymer/decorators';
@@ -156,8 +158,9 @@
ParsedChangeInfo,
} from '../../../types/types';
import {
+ IronKeyboardEventListener,
CloseFixPreviewEvent,
- CustomKeyboardEvent,
+ IronKeyboardEvent,
EditableContentSaveEvent,
EventType,
OpenFixPreviewEvent,
@@ -188,6 +191,11 @@
changeComments$,
drafts$,
} from '../../../services/comments/comments-model';
+import {
+ hasAttention,
+ getAddedByReason,
+ getRemovedByReason,
+} from '../../../utils/attention-set-util';
const MIN_LINES_FOR_COMMIT_COLLAPSE = 18;
@@ -530,7 +538,7 @@
@property({type: Boolean})
_showRobotCommentsButton = false;
- _throttledToggleChangeStar?: EventListener;
+ _throttledToggleChangeStar?: IronKeyboardEventListener;
@property({type: Boolean})
_showChecksTab = false;
@@ -557,6 +565,8 @@
private readonly commentsService = appContext.commentsService;
+ private readonly shortcuts = appContext.shortcutsService;
+
private replyDialogResizeObserver?: ResizeObserver;
override keyboardShortcuts() {
@@ -579,6 +589,7 @@
[Shortcut.DIFF_RIGHT_AGAINST_LATEST]: '_handleDiffRightAgainstLatest',
[Shortcut.DIFF_BASE_AGAINST_LATEST]: '_handleDiffBaseAgainstLatest',
[Shortcut.OPEN_SUBMIT_DIALOG]: '_handleOpenSubmitDialog',
+ [Shortcut.TOGGLE_ATTENTION_SET]: '_handleToggleAttentionSet',
};
}
@@ -630,8 +641,8 @@
override connectedCallback() {
super.connectedCallback();
- this._throttledToggleChangeStar = throttleWrap(e =>
- this._handleToggleChangeStar(e as CustomKeyboardEvent)
+ this._throttledToggleChangeStar = throttleWrap<IronKeyboardEvent>(e =>
+ this._handleToggleChangeStar(e)
);
this._getServerConfig().then(config => {
this._serverConfig = config;
@@ -740,8 +751,8 @@
if (e.detail.fixApplied) fireReload(this);
}
- _handleToggleDiffMode(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleToggleDiffMode(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1172,6 +1183,9 @@
_paramsChanged(value: AppElementChangeViewParams) {
if (value.view !== GerritView.CHANGE) {
this._initialLoadComplete = false;
+ querySelectorAll(this, 'gr-overlay').forEach(overlay =>
+ (overlay as GrOverlay).close()
+ );
return;
}
@@ -1481,8 +1495,8 @@
return label;
}
- _handleOpenReplyDialog(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleOpenReplyDialog(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
this._getLoggedIn().then(isLoggedIn => {
@@ -1496,8 +1510,8 @@
});
}
- _handleOpenDownloadDialogShortcut(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleOpenDownloadDialogShortcut(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1505,8 +1519,8 @@
this._handleOpenDownloadDialog();
}
- _handleEditTopic(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleEditTopic(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1514,8 +1528,8 @@
this.$.metadata.editTopic();
}
- _handleOpenSubmitDialog(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || !this._submitEnabled) {
+ _handleOpenSubmitDialog(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || !this._submitEnabled) {
return;
}
@@ -1523,8 +1537,50 @@
this.$.actions.showSubmitDialog();
}
- _handleDiffAgainstBase(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleToggleAttentionSet(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
+ return;
+ }
+ if (!this._change || !this._account?._account_id) return;
+ if (!this._loggedIn || !isInvolved(this._change, this._account)) return;
+ if (!this._change.attention_set) this._change.attention_set = {};
+ if (hasAttention(this._account, this._change)) {
+ const reason = getRemovedByReason(this._account, this._serverConfig);
+ if (this._change.attention_set)
+ delete this._change.attention_set[this._account._account_id];
+ fireAlert(this, 'Removing you from the attention set ...');
+ this.restApiService
+ .removeFromAttentionSet(
+ this._change._number,
+ this._account._account_id,
+ reason
+ )
+ .then(() => {
+ fireEvent(this, 'hide-alert');
+ });
+ } else {
+ const reason = getAddedByReason(this._account, this._serverConfig);
+ fireAlert(this, 'Adding you to the attention set ...');
+ this._change.attention_set[this._account._account_id!] = {
+ account: this._account,
+ reason,
+ reason_account: this._account,
+ };
+ this.restApiService
+ .addToAttentionSet(
+ this._change._number,
+ this._account._account_id,
+ reason
+ )
+ .then(() => {
+ fireEvent(this, 'hide-alert');
+ });
+ }
+ this._change = {...this._change};
+ }
+
+ _handleDiffAgainstBase(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
assertIsDefined(this._change, '_change');
@@ -1537,8 +1593,8 @@
GerritNav.navigateToChange(this._change, this._patchRange.patchNum);
}
- _handleDiffBaseAgainstLeft(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleDiffBaseAgainstLeft(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
assertIsDefined(this._change, '_change');
@@ -1551,8 +1607,8 @@
GerritNav.navigateToChange(this._change, this._patchRange.basePatchNum);
}
- _handleDiffAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleDiffAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
assertIsDefined(this._change, '_change');
@@ -1570,8 +1626,8 @@
);
}
- _handleDiffRightAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleDiffRightAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
assertIsDefined(this._change, '_change');
@@ -1589,8 +1645,8 @@
);
}
- _handleDiffBaseAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleDiffBaseAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
assertIsDefined(this._change, '_change');
@@ -1607,24 +1663,24 @@
GerritNav.navigateToChange(this._change, latestPatchNum);
}
- _handleRefreshChange(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleRefreshChange(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
e.preventDefault();
fireReload(this, true);
}
- _handleToggleChangeStar(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleToggleChangeStar(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
e.preventDefault();
this.$.changeStar.toggleStar();
}
- _handleUpToDashboard(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleUpToDashboard(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1632,8 +1688,8 @@
this._determinePageBack();
}
- _handleExpandAllMessages(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleExpandAllMessages(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1643,8 +1699,8 @@
}
}
- _handleCollapseAllMessages(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleCollapseAllMessages(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1654,8 +1710,8 @@
}
}
- _handleOpenDiffPrefsShortcut(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleOpenDiffPrefsShortcut(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -2592,6 +2648,10 @@
'#relatedChanges'
);
}
+
+ createTitle(shortcutName: Shortcut, section: ShortcutSection) {
+ return this.shortcuts.createTitle(shortcutName, section);
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
index fb80822..d57aca8 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
.container:not(.loading) {
background-color: var(--background-color-tertiary);
@@ -476,7 +479,7 @@
class="commentThreads"
>
<gr-tooltip-content
- has-tooltip=""
+ has-tooltip
title$="[[_computeTotalCommentCounts(_change.unresolved_comment_count, _changeComments)]]"
>
<span>Comments</span></gr-tooltip-content
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
index 6b63000..a82fceb 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view_test.ts
@@ -35,12 +35,7 @@
import {EventType, PluginApi} from '../../../api/plugin';
import 'lodash/lodash';
-import {
- mockPromise,
- stubRestApi,
- TestKeyboardShortcutBinder,
-} from '../../../test/test-utils';
-import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
+import {mockPromise, stubRestApi} from '../../../test/test-utils';
import {
createAppElementChangeViewParams,
createApproval,
@@ -59,6 +54,7 @@
createAccountWithIdNameAndEmail,
createChangeViewChange,
createRelatedChangeAndCommitInfo,
+ createAccountDetailWithId,
} from '../../../test/test-data-generators';
import {ChangeViewPatchRange, GrChangeView} from './gr-change-view';
import {
@@ -86,13 +82,17 @@
} from '../../../types/common';
import {
pressAndReleaseKeyOn,
+ keyUpOn,
tap,
} from '@polymer/iron-test-helpers/mock-interactions';
import {GrEditControls} from '../../edit/gr-edit-controls/gr-edit-controls';
import {AppElementChangeViewParams} from '../../gr-app-types';
-import {SinonFakeTimers, SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonFakeTimers, SinonStubbedMember} from 'sinon';
import {RestApiService} from '../../../services/gr-rest-api/gr-rest-api';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {
+ IronKeyboardEvent,
+ IronKeyboardEventDetail,
+} from '../../../types/events';
import {CommentThread, UIRobot} from '../../../utils/comment-util';
import {GerritView} from '../../../services/router/router-model';
import {ParsedChangeInfo} from '../../../types/types';
@@ -110,25 +110,6 @@
typeof GerritNav.navigateToChange
>;
- suiteSetup(() => {
- const kb = TestKeyboardShortcutBinder.push();
- kb.bindShortcut(Shortcut.SEND_REPLY, 'ctrl+enter');
- kb.bindShortcut(Shortcut.REFRESH_CHANGE, 'shift+r');
- kb.bindShortcut(Shortcut.OPEN_REPLY_DIALOG, 'a');
- kb.bindShortcut(Shortcut.OPEN_DOWNLOAD_DIALOG, 'd');
- kb.bindShortcut(Shortcut.TOGGLE_DIFF_MODE, 'm');
- kb.bindShortcut(Shortcut.TOGGLE_CHANGE_STAR, 's');
- kb.bindShortcut(Shortcut.UP_TO_DASHBOARD, 'u');
- kb.bindShortcut(Shortcut.EXPAND_ALL_MESSAGES, 'x');
- kb.bindShortcut(Shortcut.COLLAPSE_ALL_MESSAGES, 'z');
- kb.bindShortcut(Shortcut.OPEN_DIFF_PREFS, ',');
- kb.bindShortcut(Shortcut.EDIT_TOPIC, 't');
- });
-
- suiteTeardown(() => {
- TestKeyboardShortcutBinder.pop();
- });
-
const ROBOT_COMMENTS_LIMIT = 10;
// TODO: should have a mock service to generate VALID fake data
@@ -366,7 +347,9 @@
},
})
);
- stubRestApi('getAccount').returns(Promise.resolve(undefined));
+ stubRestApi('getAccount').returns(
+ Promise.resolve(createAccountDetailWithId(5))
+ );
stubRestApi('getDiffComments').returns(Promise.resolve({}));
stubRestApi('getDiffRobotComments').returns(Promise.resolve({}));
stubRestApi('getDiffDrafts').returns(Promise.resolve({}));
@@ -420,8 +403,7 @@
patchNum: 3 as RevisionPatchSetNum,
basePatchNum: 1 as BasePatchSetNum,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._handleDiffAgainstBase(new CustomEvent('') as CustomKeyboardEvent);
+ element._handleDiffAgainstBase(new CustomEvent('') as IronKeyboardEvent);
assert(navigateToChangeStub.called);
const args = navigateToChangeStub.getCall(0).args;
assert.equal(args[0], element._change);
@@ -437,15 +419,12 @@
basePatchNum: 1 as BasePatchSetNum,
patchNum: 3 as RevisionPatchSetNum,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._handleDiffAgainstLatest(
- new CustomEvent('') as CustomKeyboardEvent
- );
+ element._handleDiffAgainstLatest(new CustomEvent('') as IronKeyboardEvent);
assert(navigateToChangeStub.called);
const args = navigateToChangeStub.getCall(0).args;
assert.equal(args[0], element._change);
assert.equal(args[1], 10 as PatchSetNum);
- assert.equal(args[2], 1 as PatchSetNum);
+ assert.equal(args[2], 1 as BasePatchSetNum);
});
test('_handleDiffBaseAgainstLeft', () => {
@@ -457,9 +436,8 @@
patchNum: 3 as RevisionPatchSetNum,
basePatchNum: 1 as BasePatchSetNum,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
element._handleDiffBaseAgainstLeft(
- new CustomEvent('') as CustomKeyboardEvent
+ new CustomEvent('') as IronKeyboardEvent
);
assert(navigateToChangeStub.called);
const args = navigateToChangeStub.getCall(0).args;
@@ -476,14 +454,13 @@
basePatchNum: 1 as BasePatchSetNum,
patchNum: 3 as RevisionPatchSetNum,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
element._handleDiffRightAgainstLatest(
- new CustomEvent('') as CustomKeyboardEvent
+ new CustomEvent('') as IronKeyboardEvent
);
assert(navigateToChangeStub.called);
const args = navigateToChangeStub.getCall(0).args;
assert.equal(args[1], 10 as PatchSetNum);
- assert.equal(args[2], 3 as PatchSetNum);
+ assert.equal(args[2], 3 as BasePatchSetNum);
});
test('_handleDiffBaseAgainstLatest', () => {
@@ -495,9 +472,8 @@
basePatchNum: 1 as BasePatchSetNum,
patchNum: 3 as RevisionPatchSetNum,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
element._handleDiffBaseAgainstLatest(
- new CustomEvent('') as CustomKeyboardEvent
+ new CustomEvent('') as IronKeyboardEvent
);
assert(navigateToChangeStub.called);
const args = navigateToChangeStub.getCall(0).args;
@@ -505,6 +481,34 @@
assert.isNotOk(args[2]);
});
+ test('toggle attention set status', async () => {
+ element._change = {
+ ...createChangeViewChange(),
+ revisions: createRevisions(10),
+ };
+ const addToAttentionSetStub = stubRestApi('addToAttentionSet').returns(
+ Promise.resolve(new Response())
+ );
+
+ const removeFromAttentionSetStub = stubRestApi(
+ 'removeFromAttentionSet'
+ ).returns(Promise.resolve(new Response()));
+ element._patchRange = {
+ basePatchNum: 1 as BasePatchSetNum,
+ patchNum: 3 as RevisionPatchSetNum,
+ };
+
+ assert.isNotOk(element._change.attention_set);
+ await element._getLoggedIn();
+ await element.restApiService.getAccount();
+ element._handleToggleAttentionSet(new CustomEvent('') as IronKeyboardEvent);
+ assert.isTrue(addToAttentionSetStub.called);
+ assert.isFalse(removeFromAttentionSetStub.called);
+
+ element._handleToggleAttentionSet(new CustomEvent('') as IronKeyboardEvent);
+ assert.isTrue(removeFromAttentionSetStub.called);
+ });
+
suite('plugins adding to file tab', () => {
setup(async () => {
element._changeNum = TEST_NUMERIC_CHANGE_ID;
@@ -646,7 +650,7 @@
sinon.stub(element, '_getLoggedIn').returns(Promise.resolve(false));
const loggedInErrorSpy = sinon.spy();
element.addEventListener('show-auth-required', loggedInErrorSpy);
- pressAndReleaseKeyOn(element, 65, null, 'a');
+ keyUpOn(element, 65, null, 'a');
await flush();
assert.isFalse(element.$.replyOverlay.opened);
assert.isTrue(loggedInErrorSpy.called);
@@ -679,7 +683,7 @@
const openSpy = sinon.spy(element, '_openReplyDialog');
- pressAndReleaseKeyOn(element, 65, null, 'a');
+ keyUpOn(element, 65, null, 'a');
await flush();
assert.isTrue(element.$.replyOverlay.opened);
element.$.replyOverlay.close();
@@ -792,7 +796,7 @@
const stub = sinon
.stub(element.$.downloadOverlay, 'open')
.returns(Promise.resolve());
- pressAndReleaseKeyOn(element, 68, null, 'd');
+ keyUpOn(element, 68, null, 'd');
assert.isTrue(stub.called);
});
@@ -816,12 +820,13 @@
});
test('m should toggle diff mode', () => {
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const setModeStub = sinon.stub(
element.$.fileListHeader,
'setDiffViewMode'
);
- const e = {preventDefault: () => {}} as CustomKeyboardEvent;
+ const e = new CustomEvent<IronKeyboardEventDetail>('keydown', {
+ detail: {keyboardEvent: new KeyboardEvent('keydown'), key: 'x'},
+ });
flush();
element.viewState.diffMode = DiffViewMode.SIDE_BY_SIDE;
diff --git a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
index 1052c91..0ce3b07 100644
--- a/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
+++ b/polygerrit-ui/app/elements/change/gr-commit-info/gr-commit-info.ts
@@ -43,7 +43,7 @@
@property({type: Object})
serverConfig: ServerInfo | undefined;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -55,7 +55,7 @@
];
}
- render() {
+ override render() {
return html` <div class="container">
<a
target="_blank"
@@ -73,9 +73,9 @@
)}</a
>
<gr-copy-clipboard
- hasTooltip=""
- .buttonTitle="Copy full SHA to clipboard"
- hideInput=""
+ hastooltip
+ .buttonTitle="${'Copy full SHA to clipboard'}"
+ hideinput
.text="${this.commitInfo?.commit}"
>
</gr-copy-clipboard>
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
index 4fd42b0..07da53f 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog.ts
@@ -57,7 +57,7 @@
*/
@property({type: String})
- message?: string;
+ message = '';
get keyBindings() {
return {
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.js b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.js
deleted file mode 100644
index 14d16f5..0000000
--- a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.js
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../../test/common-test-setup-karma.js';
-import './gr-confirm-abandon-dialog.js';
-
-const basicFixture = fixtureFromElement('gr-confirm-abandon-dialog');
-
-suite('gr-confirm-abandon-dialog tests', () => {
- let element;
-
- setup(() => {
- element = basicFixture.instantiate();
- });
-
- test('_handleConfirmTap', () => {
- const confirmHandler = sinon.stub();
- element.addEventListener('confirm', confirmHandler);
- sinon.spy(element, '_handleConfirmTap');
- sinon.spy(element, '_confirm');
- element.shadowRoot
- .querySelector('gr-dialog').dispatchEvent(
- new CustomEvent('confirm', {
- composed: true, bubbles: true,
- }));
- assert.isTrue(confirmHandler.called);
- assert.isTrue(confirmHandler.calledOnce);
- assert.isTrue(element._handleConfirmTap.called);
- assert.isTrue(element._confirm.called);
- assert.isTrue(element._confirm.calledOnce);
- });
-
- test('_handleCancelTap', () => {
- const cancelHandler = sinon.stub();
- element.addEventListener('cancel', cancelHandler);
- sinon.spy(element, '_handleCancelTap');
- element.shadowRoot
- .querySelector('gr-dialog').dispatchEvent(
- new CustomEvent('cancel', {
- composed: true, bubbles: true,
- }));
- assert.isTrue(cancelHandler.called);
- assert.isTrue(cancelHandler.calledOnce);
- assert.isTrue(element._handleCancelTap.called);
- assert.isTrue(element._handleCancelTap.calledOnce);
- });
-});
-
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.ts b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.ts
new file mode 100644
index 0000000..08dda14
--- /dev/null
+++ b/polygerrit-ui/app/elements/change/gr-confirm-abandon-dialog/gr-confirm-abandon-dialog_test.ts
@@ -0,0 +1,66 @@
+/**
+ * @license
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import '../../../test/common-test-setup-karma';
+import './gr-confirm-abandon-dialog';
+import {GrConfirmAbandonDialog} from './gr-confirm-abandon-dialog';
+import {queryAndAssert} from '../../../test/test-utils';
+import {GrDialog} from '../../shared/gr-dialog/gr-dialog';
+
+const basicFixture = fixtureFromElement('gr-confirm-abandon-dialog');
+
+suite('gr-confirm-abandon-dialog tests', () => {
+ let element: GrConfirmAbandonDialog;
+
+ setup(() => {
+ element = basicFixture.instantiate();
+ });
+
+ test('_handleConfirmTap', () => {
+ const confirmHandler = sinon.stub();
+ element.addEventListener('confirm', confirmHandler);
+ const confirmTapSpy = sinon.spy(element, '_handleConfirmTap');
+ const confirmSpy = sinon.spy(element, '_confirm');
+ queryAndAssert<GrDialog>(element, 'gr-dialog').dispatchEvent(
+ new CustomEvent('confirm', {
+ composed: true,
+ bubbles: true,
+ })
+ );
+ assert.isTrue(confirmHandler.called);
+ assert.isTrue(confirmHandler.calledOnce);
+ assert.isTrue(confirmTapSpy.called);
+ assert.isTrue(confirmSpy.called);
+ assert.isTrue(confirmSpy.calledOnce);
+ });
+
+ test('_handleCancelTap', () => {
+ const cancelHandler = sinon.stub();
+ element.addEventListener('cancel', cancelHandler);
+ const cancelTapSpy = sinon.spy(element, '_handleCancelTap');
+ queryAndAssert<GrDialog>(element, 'gr-dialog').dispatchEvent(
+ new CustomEvent('cancel', {
+ composed: true,
+ bubbles: true,
+ })
+ );
+ assert.isTrue(cancelHandler.called);
+ assert.isTrue(cancelHandler.calledOnce);
+ assert.isTrue(cancelTapSpy.called);
+ assert.isTrue(cancelTapSpy.calledOnce);
+ });
+});
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
index a090aee..b061043 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.ts
@@ -25,15 +25,14 @@
import {appContext} from '../../../services/app-context';
import {
ChangeInfo,
- BranchInfo,
- RepoName,
BranchName,
+ RepoName,
CommitId,
ChangeInfoId,
} from '../../../types/common';
import {ReportingService} from '../../../services/gr-reporting/gr-reporting';
import {customElement, property, observe} from '@polymer/decorators';
-import {AutocompleteSuggestion} from '../../shared/gr-autocomplete/gr-autocomplete';
+import {GrTypedAutocomplete} from '../../shared/gr-autocomplete/gr-autocomplete';
import {HttpMethod, ChangeStatus} from '../../../constants/constants';
import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {fireEvent} from '../../../utils/event-util';
@@ -68,7 +67,7 @@
export interface GrConfirmCherrypickDialog {
$: {
- branchInput: HTMLElement;
+ branchInput: GrTypedAutocomplete<BranchName>;
};
}
@@ -91,7 +90,7 @@
*/
@property({type: String})
- branch?: BranchName;
+ branch = '' as BranchName;
@property({type: String})
baseCommit?: string;
@@ -106,7 +105,7 @@
commitNum?: CommitId;
@property({type: String})
- message?: string;
+ message = '';
@property({type: String})
project?: RepoName;
@@ -115,7 +114,7 @@
changes: ChangeInfo[] = [];
@property({type: Object})
- _query: (input: string) => Promise<AutocompleteSuggestion[]>;
+ _query?: (input: string) => Promise<{name: BranchName}[]>;
@property({type: Boolean})
_showCherryPickTopic = false;
@@ -249,7 +248,7 @@
cherryPickType: CherryPickType,
duplicateProjectChanges: boolean,
statuses: Statuses,
- branch?: BranchName
+ branch: BranchName
) {
if (!branch) return true;
const duplicateProject =
@@ -298,6 +297,9 @@
let newMessage = commitMessage;
if (changeStatus === 'MERGED') {
+ if (!newMessage.endsWith('\n')) {
+ newMessage += '\n';
+ }
newMessage += '(cherry picked from commit ' + commitNum.toString() + ')';
}
this.message = newMessage;
@@ -395,29 +397,22 @@
this.$.branchInput.focus();
}
- _getProjectBranchesSuggestions(
- input: string
- ): Promise<AutocompleteSuggestion[]> {
- if (!this.project) {
- this.reporting.error(new Error('no project specified'));
- return Promise.resolve([]);
- }
+ _getProjectBranchesSuggestions(input: string) {
+ if (!this.project) return Promise.reject(new Error('Missing project'));
if (input.startsWith('refs/heads/')) {
input = input.substring('refs/heads/'.length);
}
return this.restApiService
.getRepoBranches(input, this.project, SUGGESTIONS_LIMIT)
- .then((response: BranchInfo[] | undefined) => {
+ .then(response => {
if (!response) return [];
- const branches = [];
+ const branches: Array<{name: BranchName}> = [];
for (const branchInfo of response) {
- let branch;
- if (branchInfo.ref.startsWith('refs/heads/')) {
- branch = branchInfo.ref.substring('refs/heads/'.length);
- } else {
- branch = branchInfo.ref;
+ let name: string = branchInfo.ref;
+ if (name.startsWith('refs/heads/')) {
+ name = name.substring('refs/heads/'.length);
}
- branches.push({name: branch});
+ branches.push({name: name as BranchName});
}
return branches;
});
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.js
index 90fddaa..3df997f8 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.js
@@ -46,6 +46,16 @@
element.project = 'test-project';
});
+ test('with message missing newline', () => {
+ element.changeStatus = 'MERGED';
+ element.commitMessage = 'message';
+ element.commitNum = '123';
+ element.branch = 'master';
+ flush();
+ const expectedMessage = 'message\n(cherry picked from commit 123)';
+ assert.equal(element.message, expectedMessage);
+ });
+
test('with merged change', () => {
element.changeStatus = 'MERGED';
element.commitMessage = 'message\n';
@@ -105,18 +115,19 @@
current_revision: 'a',
},
];
- setup(() => {
+ setup(async () => {
element.updateChanges(changes);
element._cherryPickType = CHERRY_PICK_TYPES.TOPIC;
- flush();
+ await flush();
});
test('cherry pick topic submit', async () => {
element.branch = 'master';
+ await flush();
const executeChangeActionStub = stubRestApi(
'executeChangeAction').returns(Promise.resolve([]));
MockInteractions.tap(element.shadowRoot.
- querySelector('gr-dialog').$.confirm);
+ querySelector('gr-dialog').confirmButton);
await flush();
const args = executeChangeActionStub.args[0];
assert.equal(args[0], 1);
@@ -127,26 +138,29 @@
assert.isTrue(args[4].allow_empty);
});
- test('deselecting a change removes it from being cherry picked', () => {
- const duplicateChangesStub = sinon.stub(element,
- 'containsDuplicateProject');
- element.branch = 'master';
- const executeChangeActionStub = stubRestApi(
- 'executeChangeAction').returns(Promise.resolve([]));
- const checkboxes = element.shadowRoot.querySelectorAll(
- 'input[type="checkbox"]');
- assert.equal(checkboxes.length, 2);
- assert.isTrue(checkboxes[0].checked);
- MockInteractions.tap(checkboxes[0]);
- MockInteractions.tap(element.shadowRoot.
- querySelector('gr-dialog').$.confirm);
- flush();
- assert.equal(executeChangeActionStub.callCount, 1);
- assert.isTrue(duplicateChangesStub.called);
- });
+ test('deselecting a change removes it from being cherry picked',
+ async () => {
+ const duplicateChangesStub = sinon.stub(element,
+ 'containsDuplicateProject');
+ element.branch = 'master';
+ await flush();
+ const executeChangeActionStub = stubRestApi(
+ 'executeChangeAction').returns(Promise.resolve([]));
+ const checkboxes = element.shadowRoot.querySelectorAll(
+ 'input[type="checkbox"]');
+ assert.equal(checkboxes.length, 2);
+ assert.isTrue(checkboxes[0].checked);
+ MockInteractions.tap(checkboxes[0]);
+ MockInteractions.tap(element.shadowRoot.
+ querySelector('gr-dialog').confirmButton);
+ await flush();
+ assert.equal(executeChangeActionStub.callCount, 1);
+ assert.isTrue(duplicateChangesStub.called);
+ });
- test('deselecting all change shows error message', () => {
+ test('deselecting all change shows error message', async () => {
element.branch = 'master';
+ await flush();
const executeChangeActionStub = stubRestApi(
'executeChangeAction').returns(Promise.resolve([]));
const checkboxes = element.shadowRoot.querySelectorAll(
@@ -155,8 +169,8 @@
MockInteractions.tap(checkboxes[0]);
MockInteractions.tap(checkboxes[1]);
MockInteractions.tap(element.shadowRoot.
- querySelector('gr-dialog').$.confirm);
- flush();
+ querySelector('gr-dialog').confirmButton);
+ await flush();
assert.equal(executeChangeActionStub.callCount, 0);
assert.equal(element.shadowRoot.querySelector('.error-message').innerText
, 'No change selected');
@@ -170,8 +184,8 @@
});
test('submit button is blocked while cherry picks is running', async () => {
- const confirmButton = element.shadowRoot.querySelector('gr-dialog').$
- .confirm;
+ const confirmButton = element.shadowRoot.querySelector('gr-dialog')
+ .confirmButton;
assert.isTrue(confirmButton.hasAttribute('disabled'));
element.branch = 'b';
await flush();
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
index c196706..8e6521d 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog.ts
@@ -21,15 +21,23 @@
import {htmlTemplate} from './gr-confirm-move-dialog_html';
import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {customElement, property} from '@polymer/decorators';
-import {RepoName, BranchName} from '../../../types/common';
-import {AutocompleteSuggestion} from '../../shared/gr-autocomplete/gr-autocomplete';
+import {BranchName, RepoName} from '../../../types/common';
import {appContext} from '../../../services/app-context';
+import {GrTypedAutocomplete} from '../../shared/gr-autocomplete/gr-autocomplete';
const SUGGESTIONS_LIMIT = 15;
// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
const base = KeyboardShortcutMixin(PolymerElement);
+// This is used to make sure 'branch'
+// can be typed as BranchName.
+export interface GrConfirmMoveDialog {
+ $: {
+ branchInput: GrTypedAutocomplete<BranchName>;
+ };
+}
+
@customElement('gr-confirm-move-dialog')
export class GrConfirmMoveDialog extends base {
static get template() {
@@ -49,16 +57,16 @@
*/
@property({type: String})
- branch?: BranchName;
+ branch = '' as BranchName;
@property({type: String})
- message?: string;
+ message = '';
@property({type: String})
project?: RepoName;
@property({type: Object})
- _query: (input: string) => Promise<AutocompleteSuggestion[]>;
+ _query?: (input: string) => Promise<{name: BranchName}[]>;
get keyBindings() {
return {
@@ -95,9 +103,7 @@
);
}
- _getProjectBranchesSuggestions(
- input: string
- ): Promise<AutocompleteSuggestion[]> {
+ _getProjectBranchesSuggestions(input: string) {
if (!this.project) return Promise.reject(new Error('Missing project'));
if (input.startsWith('refs/heads/')) {
input = input.substring('refs/heads/'.length);
@@ -105,21 +111,15 @@
return this.restApiService
.getRepoBranches(input, this.project, SUGGESTIONS_LIMIT)
.then(response => {
- const branches: AutocompleteSuggestion[] = [];
- let branch;
- if (response) {
- response.forEach(value => {
- if (value.ref.startsWith('refs/heads/')) {
- branch = value.ref.substring('refs/heads/'.length);
- } else {
- branch = value.ref;
- }
- branches.push({
- name: branch,
- });
- });
+ if (!response) return [];
+ const branches: Array<{name: BranchName}> = [];
+ for (const branchInfo of response) {
+ let name: string = branchInfo.ref;
+ if (name.startsWith('refs/heads/')) {
+ name = name.substring('refs/heads/'.length);
+ }
+ branches.push({name: name as BranchName});
}
-
return branches;
});
}
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.ts
similarity index 75%
rename from polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js
rename to polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.ts
index 10844f5..ea5d320 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-move-dialog/gr-confirm-move-dialog_test.ts
@@ -15,35 +15,37 @@
* limitations under the License.
*/
-import '../../../test/common-test-setup-karma.js';
-import './gr-confirm-move-dialog.js';
-import {stubRestApi} from '../../../test/test-utils.js';
+import '../../../test/common-test-setup-karma';
+import './gr-confirm-move-dialog';
+import {GrConfirmMoveDialog} from './gr-confirm-move-dialog';
+import {stubRestApi} from '../../../test/test-utils';
+import {BranchName, GitRef, RepoName} from '../../../types/common';
const basicFixture = fixtureFromElement('gr-confirm-move-dialog');
suite('gr-confirm-move-dialog tests', () => {
- let element;
+ let element: GrConfirmMoveDialog;
setup(() => {
- stubRestApi('getRepoBranches').callsFake(input => {
+ stubRestApi('getRepoBranches').callsFake((input: string) => {
if (input.startsWith('test')) {
return Promise.resolve([
{
- ref: 'refs/heads/test-branch',
+ ref: 'refs/heads/test-branch' as GitRef,
revision: '67ebf73496383c6777035e374d2d664009e2aa5c',
can_delete: true,
},
]);
} else {
- return Promise.resolve(undefined);
+ return Promise.resolve([]);
}
});
element = basicFixture.instantiate();
- element.project = 'test-project';
+ element.project = 'test-repo' as RepoName;
});
test('with updated commit message', () => {
- element.branch = 'master';
+ element.branch = 'master' as BranchName;
const myNewMessage = 'updated commit message';
element.message = myNewMessage;
flush();
@@ -52,13 +54,15 @@
test('_getProjectBranchesSuggestions empty', async () => {
const branches = await element._getProjectBranchesSuggestions(
- 'nonexistent');
+ 'nonexistent'
+ );
assert.equal(branches.length, 0);
});
test('_getProjectBranchesSuggestions non-empty', async () => {
const branches = await element._getProjectBranchesSuggestions(
- 'test-branch');
+ 'test-branch'
+ );
assert.equal(branches.length, 1);
assert.equal(branches[0].name, 'test-branch');
});
@@ -68,4 +72,3 @@
assert.equal(branches.length, 0);
});
});
-
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
index c705319..9d371d3 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-confirm-submit-dialog/gr-confirm-submit-dialog.ts
@@ -58,7 +58,7 @@
@property({type: Boolean})
_initialised = false;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
fontStyles,
@@ -112,8 +112,8 @@
id="commentList"
.threads="${this._computeUnresolvedThreads(this.commentThreads)}"
.change="${this.change}"
- .change-num="${this.change?._number}"
- logged-in="true"
+ .changeNum="${this.change?._number}"
+ logged-in
hide-dropdown
>
</gr-thread-list>
@@ -154,7 +154,7 @@
`;
}
- render() {
+ override render() {
return html` <gr-dialog
id="dialog"
confirm-label="Continue"
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
index bdc6a43..8aef3c0 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.ts
@@ -44,7 +44,12 @@
import {DiffViewMode} from '../../../constants/constants';
import {GrButton} from '../../shared/gr-button/gr-button';
import {fireEvent} from '../../../utils/event-util';
-import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
+import {
+ KeyboardShortcutMixin,
+ Shortcut,
+ ShortcutSection,
+} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
+import {appContext} from '../../../services/app-context';
declare global {
interface HTMLElementTagNameMap {
@@ -144,6 +149,8 @@
@property({type: Object})
revisionInfo?: RevisionInfo;
+ private readonly shortcuts = appContext.shortcutsService;
+
setDiffViewMode(mode: DiffViewMode) {
this.$.modeSelect.setMode(mode);
}
@@ -217,4 +224,8 @@
}
return 'patchInfoOldPatchSet';
}
+
+ createTitle(shortcutName: Shortcut, section: ShortcutSection) {
+ return this.shortcuts.createTitle(shortcutName, section);
+ }
}
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_html.ts b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_html.ts
index bceee27..5972393 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_html.ts
@@ -93,9 +93,7 @@
}
.fileViewActions gr-button {
margin: 0;
- --gr-button: {
- padding: 2px 4px;
- }
+ --gr-button-padding: 2px 4px;
}
.editMode .hideOnEdit {
display: none;
@@ -180,50 +178,50 @@
hidden$="[[_computePrefsButtonHidden(diffPrefs, diffPrefsDisabled)]]"
hidden=""
>
- <gr-button
- link=""
- has-tooltip=""
- title="Diff preferences"
- class="prefsButton desktop"
- on-click="_handlePrefsTap"
- ><iron-icon icon="gr-icons:settings"></iron-icon
- ></gr-button>
+ <gr-tooltip-content has-tooltip title="Diff preferences">
+ <gr-button
+ link=""
+ class="prefsButton desktop"
+ on-click="_handlePrefsTap"
+ ><iron-icon icon="gr-icons:settings"></iron-icon
+ ></gr-button>
+ </gr-tooltip-content>
</span>
<span class="separator"></span>
</div>
<span class="downloadContainer desktop">
- <gr-button
- link=""
- class="download"
+ <gr-tooltip-content
+ has-tooltip
title="[[createTitle(Shortcut.OPEN_DOWNLOAD_DIALOG,
- ShortcutSection.ACTIONS)]]"
- has-tooltip=""
- on-click="_handleDownloadTap"
- >Download</gr-button
+ ShortcutSection.ACTIONS)]]"
>
+ <gr-button link="" class="download" on-click="_handleDownloadTap"
+ >Download</gr-button
+ >
+ </gr-tooltip-content>
</span>
<template
is="dom-if"
if="[[_fileListActionsVisible(shownFileCount, _maxFilesForBulkActions)]]"
>
- <gr-button
- id="expandBtn"
- link=""
+ <gr-tooltip-content
+ has-tooltip
title="[[createTitle(Shortcut.TOGGLE_ALL_INLINE_DIFFS,
- ShortcutSection.FILE_LIST)]]"
- has-tooltip=""
- on-click="_expandAllDiffs"
- >Expand All</gr-button
+ ShortcutSection.FILE_LIST)]]"
>
- <gr-button
- id="collapseBtn"
- link=""
- on-click="_collapseAllDiffs"
+ <gr-button id="expandBtn" link="" on-click="_expandAllDiffs"
+ >Expand All</gr-button
+ >
+ </gr-tooltip-content>
+ <gr-tooltip-content
+ has-tooltip
title="[[createTitle(Shortcut.TOGGLE_ALL_INLINE_DIFFS,
- ShortcutSection.FILE_LIST)]]"
- has-tooltip=""
- >Collapse All</gr-button
+ ShortcutSection.FILE_LIST)]]"
>
+ <gr-button id="collapseBtn" link="" on-click="_collapseAllDiffs"
+ >Collapse All</gr-button
+ >
+ </gr-tooltip-content>
</template>
<template
is="dom-if"
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.js b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.js
index 08e5e3b..c90cfcc 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header_test.js
@@ -90,26 +90,26 @@
assert.isFalse(computeSpy.lastCall.returnValue);
});
- test('fileViewActions are properly hidden', () => {
+ test('fileViewActions are properly hidden', async () => {
const actions = element.shadowRoot
.querySelector('.fileViewActions');
assert.equal(getComputedStyle(actions).display, 'none');
element.filesExpanded = FilesExpandedState.SOME;
- flush();
+ await flush();
assert.notEqual(getComputedStyle(actions).display, 'none');
element.filesExpanded = FilesExpandedState.ALL;
- flush();
+ await flush();
assert.notEqual(getComputedStyle(actions).display, 'none');
element.filesExpanded = FilesExpandedState.NONE;
- flush();
+ await flush();
assert.equal(getComputedStyle(actions).display, 'none');
});
- test('expand/collapse buttons are toggled correctly', () => {
+ test('expand/collapse buttons are toggled correctly', async () => {
// Only the expand button should be visible in the initial state when
// NO files are expanded.
element.shownFileCount = 10;
- flush();
+ await flush();
const expandBtn = element.shadowRoot.querySelector('#expandBtn');
const collapseBtn = element.shadowRoot.querySelector('#collapseBtn');
assert.notEqual(getComputedStyle(expandBtn).display, 'none');
@@ -118,19 +118,19 @@
// Both expand and collapse buttons should be visible when SOME files are
// expanded.
element.filesExpanded = FilesExpandedState.SOME;
- flush();
+ await flush();
assert.notEqual(getComputedStyle(expandBtn).display, 'none');
assert.notEqual(getComputedStyle(collapseBtn).display, 'none');
// Only the collapse button should be visible when ALL files are expanded.
element.filesExpanded = FilesExpandedState.ALL;
- flush();
+ await flush();
assert.equal(getComputedStyle(expandBtn).display, 'none');
assert.notEqual(getComputedStyle(collapseBtn).display, 'none');
// Only the expand button should be visible when NO files are expanded.
element.filesExpanded = FilesExpandedState.NONE;
- flush();
+ await flush();
assert.notEqual(getComputedStyle(expandBtn).display, 'none');
assert.equal(getComputedStyle(collapseBtn).display, 'none');
});
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
index 8d0c203..b78c78f 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.ts
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../../diff/gr-diff-cursor/gr-diff-cursor';
import '../../diff/gr-diff-host/gr-diff-host';
@@ -49,8 +50,8 @@
} from '../../../constants/constants';
import {
descendedFromClass,
- getKeyboardEvent,
isShiftPressed,
+ modifierPressed,
toggleClass,
} from '../../../utils/dom-util';
import {
@@ -77,7 +78,7 @@
import {GrCursorManager} from '../../shared/gr-cursor-manager/gr-cursor-manager';
import {PolymerSpliceChange} from '@polymer/polymer/interfaces';
import {ChangeComments} from '../../diff/gr-comment-api/gr-comment-api';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {ParsedChangeInfo, PatchSetFile} from '../../../types/types';
import {Timing} from '../../../constants/reporting';
import {RevisionInfo} from '../../shared/revision-info/revision-info';
@@ -226,9 +227,6 @@
@property({type: Object, notify: true, observer: '_updateDiffPreferences'})
diffPrefs?: DiffPreferencesInfo;
- @property({type: Boolean})
- _showInlineDiffs?: boolean;
-
@property({type: Number, notify: true})
numFilesShown: number = DEFAULT_NUM_FILES_SHOWN;
@@ -358,14 +356,14 @@
private diffCursor = new GrDiffCursor();
+ private readonly shortcuts = appContext.shortcutsService;
+
constructor() {
super();
this.fileCursor.scrollMode = ScrollMode.KEEP_VISIBLE;
this.fileCursor.cursorTargetClass = 'selected';
this.fileCursor.focusOnMove = true;
- this.addEventListener('keydown', e =>
- this._scopedKeydownHandler(e as unknown as CustomKeyboardEvent)
- );
+ this.addEventListener('keydown', e => this._scopedKeydownHandler(e));
}
override connectedCallback() {
@@ -435,13 +433,8 @@
*
* Context: Issue 7277
*/
- _scopedKeydownHandler(e: CustomKeyboardEvent) {
- if (e.keyCode === 13) {
- // TODO(TS): e is not an instance of CustomKeyboardEvent.
- // However, to fix it we should fix keyboard-shortcut-mixin first
- // The keyboard-shortcut-mixin will be updated in a separate change
- this._handleOpenFile(e as unknown as CustomKeyboardEvent);
- }
+ _scopedKeydownHandler(e: KeyboardEvent) {
+ if (e.keyCode === 13) this.handleOpenFile(e);
}
reload() {
@@ -628,8 +621,6 @@
}
expandAllDiffs() {
- this._showInlineDiffs = true;
-
// Find the list of paths that are in the file list, but not in the
// expanded list.
const newFiles: PatchSetFile[] = [];
@@ -645,7 +636,6 @@
}
collapseAllDiffs() {
- this._showInlineDiffs = false;
this._expandedFiles = [];
this.filesExpanded = this._computeExpandedFiles(
this._expandedFiles.length,
@@ -891,8 +881,8 @@
return fileData;
}
- _handleLeftPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this._noDiffsExpanded()) {
+ _handleLeftPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this._noDiffsExpanded()) {
return;
}
@@ -900,8 +890,8 @@
this.diffCursor.moveLeft();
}
- _handleRightPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this._noDiffsExpanded()) {
+ _handleRightPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this._noDiffsExpanded()) {
return;
}
@@ -909,9 +899,9 @@
this.diffCursor.moveRight();
}
- _handleToggleInlineDiff(e: CustomKeyboardEvent) {
+ _handleToggleInlineDiff(e: IronKeyboardEvent) {
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
this.modifierPressed(e) ||
e.detail?.keyboardEvent?.repeat ||
this.fileCursor.index === -1
@@ -923,11 +913,8 @@
this._toggleFileExpandedByIndex(this.fileCursor.index);
}
- _handleToggleAllInlineDiffs(e: CustomKeyboardEvent) {
- if (
- this.shouldSuppressKeyboardShortcut(e) ||
- e.detail?.keyboardEvent?.repeat
- ) {
+ _handleToggleAllInlineDiffs(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || e.detail?.keyboardEvent?.repeat) {
return;
}
@@ -935,8 +922,8 @@
this._toggleInlineDiffs();
}
- _handleToggleHideAllCommentThreads(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleToggleHideAllCommentThreads(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -944,18 +931,18 @@
toggleClass(this, 'hideComments');
}
- _handleCursorNext(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleCursorNext(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
e.preventDefault();
this.diffCursor.moveDown();
this._displayLine = true;
} else {
// Down key
- if (getKeyboardEvent(e).keyCode === 40) {
+ if (e.detail.keyboardEvent.keyCode === 40) {
return;
}
e.preventDefault();
@@ -964,18 +951,18 @@
}
}
- _handleCursorPrev(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleCursorPrev(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
e.preventDefault();
this.diffCursor.moveUp();
this._displayLine = true;
} else {
// Up key
- if (getKeyboardEvent(e).keyCode === 38) {
+ if (e.detail.keyboardEvent.keyCode === 38) {
return;
}
e.preventDefault();
@@ -984,8 +971,8 @@
}
}
- _handleNewComment(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleNewComment(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
e.preventDefault();
@@ -993,9 +980,9 @@
this.diffCursor.createCommentInPlace();
}
- _handleOpenLastFile(e: CustomKeyboardEvent) {
+ _handleOpenLastFile(e: IronKeyboardEvent) {
// Check for meta key to avoid overriding native chrome shortcut.
- if (this.shouldSuppressKeyboardShortcut(e) || getKeyboardEvent(e).metaKey) {
+ if (this.shortcuts.shouldSuppress(e) || e.detail.keyboardEvent.metaKey) {
return;
}
@@ -1003,9 +990,9 @@
this._openSelectedFile(this._files.length - 1);
}
- _handleOpenFirstFile(e: CustomKeyboardEvent) {
+ _handleOpenFirstFile(e: IronKeyboardEvent) {
// Check for meta key to avoid overriding native chrome shortcut.
- if (this.shouldSuppressKeyboardShortcut(e) || getKeyboardEvent(e).metaKey) {
+ if (this.shortcuts.shouldSuppress(e) || e.detail.keyboardEvent.metaKey) {
return;
}
@@ -1013,13 +1000,18 @@
this._openSelectedFile(0);
}
- _handleOpenFile(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleOpenFile(e: IronKeyboardEvent) {
+ if (this.modifierPressed(e)) return;
+ this.handleOpenFile(e.detail.keyboardEvent);
+ }
+
+ handleOpenFile(e: KeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || modifierPressed(e)) {
return;
}
e.preventDefault();
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
this._openCursorFile();
return;
}
@@ -1027,9 +1019,9 @@
this._openSelectedFile();
}
- _handleNextChunk(e: CustomKeyboardEvent) {
+ _handleNextChunk(e: IronKeyboardEvent) {
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
(this.modifierPressed(e) && !isShiftPressed(e)) ||
this._noDiffsExpanded()
) {
@@ -1044,9 +1036,9 @@
}
}
- _handlePrevChunk(e: CustomKeyboardEvent) {
+ _handlePrevChunk(e: IronKeyboardEvent) {
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
(this.modifierPressed(e) && !isShiftPressed(e)) ||
this._noDiffsExpanded()
) {
@@ -1061,8 +1053,8 @@
}
}
- _handleToggleFileReviewed(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleToggleFileReviewed(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
@@ -1073,8 +1065,8 @@
this._reviewFile(this._files[this.fileCursor.index].__path);
}
- _handleToggleLeftPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleToggleLeftPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
@@ -1085,7 +1077,7 @@
}
_toggleInlineDiffs() {
- if (this._showInlineDiffs) {
+ if (this.filesExpanded === FilesExpandedState.ALL) {
this.collapseAllDiffs();
} else {
this.expandAllDiffs();
@@ -1550,8 +1542,8 @@
return undefined;
}
- _handleEscKey(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e) || this.modifierPressed(e)) {
+ _handleEscKey(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e) || this.modifierPressed(e)) {
return;
}
e.preventDefault();
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
index 4d04744..f7be36b 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
display: block;
@@ -253,9 +256,7 @@
display: inline-block;
visibility: hidden;
vertical-align: bottom;
- --gr-button: {
- padding: 0px;
- }
+ --gr-button-padding: 0px;
}
.row:focus-within gr-copy-clipboard,
.row:hover gr-copy-clipboard {
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
index e11d3a3..f4064da 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list_test.js
@@ -17,6 +17,7 @@
import '../../../test/common-test-setup-karma.js';
import '../../diff/gr-comment-api/gr-comment-api.js';
+import '../../shared/gr-date-formatter/gr-date-formatter.js';
import {getMockDiffResponse} from '../../../test/mocks/diff-response.js';
import './gr-file-list.js';
import {createCommentApiMockWithTemplateElement} from '../../../test/mocks/comment-api.js';
@@ -26,7 +27,6 @@
import {runA11yAudit} from '../../../test/a11y-test-utils.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import {
- TestKeyboardShortcutBinder,
stubRestApi,
spyRestApi,
listenOnce,
@@ -34,7 +34,6 @@
query,
} from '../../../test/test-utils.js';
import {EditPatchSetNum} from '../../../types/common.js';
-import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
import {createCommentThreads} from '../../../utils/comment-util.js';
import {
createChange,
@@ -43,7 +42,6 @@
createParsedChange,
createRevision,
} from '../../../test/test-data-generators.js';
-import sinon from 'sinon/pkg/sinon-esm';
import {createDefaultDiffPrefs} from '../../../constants/constants.js';
import {queryAndAssert} from '../../../utils/common-util.js';
@@ -68,30 +66,6 @@
let saveStub;
- suiteSetup(() => {
- const kb = TestKeyboardShortcutBinder.push();
- kb.bindShortcut(Shortcut.LEFT_PANE, 'shift+left');
- kb.bindShortcut(Shortcut.RIGHT_PANE, 'shift+right');
- kb.bindShortcut(Shortcut.TOGGLE_INLINE_DIFF, 'i:keyup');
- kb.bindShortcut(Shortcut.TOGGLE_ALL_INLINE_DIFFS, 'shift+i:keyup');
- kb.bindShortcut(Shortcut.CURSOR_NEXT_FILE, 'j', 'down');
- kb.bindShortcut(Shortcut.CURSOR_PREV_FILE, 'k', 'up');
- kb.bindShortcut(Shortcut.NEXT_LINE, 'j', 'down');
- kb.bindShortcut(Shortcut.PREV_LINE, 'k', 'up');
- kb.bindShortcut(Shortcut.NEW_COMMENT, 'c');
- kb.bindShortcut(Shortcut.OPEN_LAST_FILE, '[');
- kb.bindShortcut(Shortcut.OPEN_FIRST_FILE, ']');
- kb.bindShortcut(Shortcut.OPEN_FILE, 'o');
- kb.bindShortcut(Shortcut.NEXT_CHUNK, 'n');
- kb.bindShortcut(Shortcut.PREV_CHUNK, 'p');
- kb.bindShortcut(Shortcut.TOGGLE_FILE_REVIEWED, 'r');
- kb.bindShortcut(Shortcut.TOGGLE_LEFT_PANE, 'shift+a');
- });
-
- suiteTeardown(() => {
- TestKeyboardShortcutBinder.pop();
- });
-
suite('basic tests', () => {
setup(async () => {
stubRestApi('getDiffComments').returns(Promise.resolve({}));
@@ -566,35 +540,36 @@
assert.equal(element.diffs.length, 0);
assert.equal(element._expandedFiles.length, 0);
- MockInteractions.keyUpOn(element, 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, null, 'i');
flush();
assert.equal(element.diffs.length, 1);
assert.equal(element.diffs[0].path, paths[0]);
assert.equal(element._expandedFiles.length, 1);
assert.equal(element._expandedFiles[0].path, paths[0]);
- MockInteractions.keyUpOn(element, 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, null, 'i');
flush();
assert.equal(element.diffs.length, 0);
assert.equal(element._expandedFiles.length, 0);
element.fileCursor.setCursorAtIndex(1);
- MockInteractions.keyUpOn(element, 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, null, 'i');
flush();
assert.equal(element.diffs.length, 1);
assert.equal(element.diffs[0].path, paths[1]);
assert.equal(element._expandedFiles.length, 1);
assert.equal(element._expandedFiles[0].path, paths[1]);
- MockInteractions.keyUpOn(element, 73, 'shift', 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, 'shift', 'i');
flush();
assert.equal(element.diffs.length, paths.length);
assert.equal(element._expandedFiles.length, paths.length);
for (const diff of element.diffs) {
assert.isTrue(element._expandedFiles.some(f => f.path === diff.path));
}
-
- MockInteractions.keyUpOn(element, 73, 'shift', 'i');
+ // since _expandedFilesChanged is stubbed
+ element.filesExpanded = FilesExpandedState.ALL;
+ MockInteractions.pressAndReleaseKeyOn(element, 73, 'shift', 'i');
flush();
assert.equal(element.diffs.length, 0);
assert.equal(element._expandedFiles.length, 0);
@@ -609,12 +584,12 @@
assert.equal(getNumReviewed(), 0);
// Press the review key to toggle it (set the flag).
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
flush();
assert.equal(getNumReviewed(), 1);
// Press the review key to toggle it (clear the flag).
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
assert.equal(getNumReviewed(), 0);
});
@@ -622,22 +597,23 @@
let interact;
setup(() => {
- sinon.stub(element, 'shouldSuppressKeyboardShortcut')
- .returns(false);
sinon.stub(element, 'modifierPressed').returns(false);
const openCursorStub = sinon.stub(element, '_openCursorFile');
const openSelectedStub = sinon.stub(element, '_openSelectedFile');
const expandStub = sinon.stub(element, '_toggleFileExpanded');
- interact = function(opt_payload) {
+ interact = function() {
openCursorStub.reset();
openSelectedStub.reset();
expandStub.reset();
- const e = new CustomEvent('fake-keyboard-event', opt_payload);
- sinon.stub(e, 'preventDefault');
+ const keyboardEvent = new KeyboardEvent('keydown');
+ const e = new CustomEvent('keydown', {
+ detail: {keyboardEvent, key: 'x'},
+ });
+ sinon.stub(keyboardEvent, 'preventDefault');
element._handleOpenFile(e);
- assert.isTrue(e.preventDefault.called);
+ assert.isTrue(keyboardEvent.preventDefault.called);
const result = {};
if (openCursorStub.called) {
result.opened_cursor = true;
@@ -653,17 +629,17 @@
});
test('open from selected file', () => {
- element._showInlineDiffs = false;
+ element.filesExpanded = FilesExpandedState.NONE;
assert.deepEqual(interact(), {opened_selected: true});
});
test('open from diff cursor', () => {
- element._showInlineDiffs = true;
+ element.filesExpanded = FilesExpandedState.ALL;
assert.deepEqual(interact(), {opened_cursor: true});
});
test('expand when user prefers', () => {
- element._showInlineDiffs = false;
+ element.filesExpanded = FilesExpandedState.NONE;
assert.deepEqual(interact(), {opened_selected: true});
element._userPrefs = {};
assert.deepEqual(interact(), {opened_selected: true});
@@ -929,14 +905,14 @@
element._filesByPath = {[path]: {}};
element.expandAllDiffs();
flush();
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
assert.isTrue(reInitStub.calledOnce);
assert.equal(collapseStub.lastCall.args[0].length, 0);
element.collapseAllDiffs();
flush();
assert.equal(element._expandedFiles.length, 0);
- assert.isFalse(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.NONE);
assert.isTrue(cursorUpdateStub.calledOnce);
assert.equal(collapseStub.lastCall.args[0].length, 1);
});
@@ -1573,7 +1549,7 @@
});
test('cursor with individually opened files', async () => {
- MockInteractions.keyUpOn(element, 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, null, 'i');
await flush();
let diffs = await renderAndGetNewDiffs(0);
const diffStops = diffs[0].getCursorStops();
@@ -1600,7 +1576,7 @@
// The file cursor is now at 1.
assert.equal(element.fileCursor.index, 1);
- MockInteractions.keyUpOn(element, 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, null, 'i');
await flush();
diffs = await renderAndGetNewDiffs(1);
@@ -1615,7 +1591,7 @@
});
test('cursor with toggle all files', async () => {
- MockInteractions.keyUpOn(element, 73, 'shift', 'i');
+ MockInteractions.pressAndReleaseKeyOn(element, 73, 'shift', 'i');
await flush();
const diffs = await renderAndGetNewDiffs(0);
@@ -1662,7 +1638,7 @@
});
test('n key with some files expanded and no shift key', async () => {
- MockInteractions.keyUpOn(fileRows[0], 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(fileRows[0], 73, null, 'i');
await flush();
// Handle N key should return before calling diff cursor functions.
@@ -1676,7 +1652,7 @@
});
test('n key with some files expanded and shift key', async () => {
- MockInteractions.keyUpOn(fileRows[0], 73, null, 'i');
+ MockInteractions.pressAndReleaseKeyOn(fileRows[0], 73, null, 'i');
await flush();
assert.equal(nextChunkStub.callCount, 0);
@@ -1690,7 +1666,7 @@
});
test('n key without all files expanded and shift key', async () => {
- MockInteractions.keyUpOn(fileRows[0], 73, 'shift', 'i');
+ MockInteractions.pressAndReleaseKeyOn(fileRows[0], 73, 'shift', 'i');
await flush();
MockInteractions.pressAndReleaseKeyOn(element, 78, null, 'n');
@@ -1699,11 +1675,11 @@
// This is also called in diffCursor.moveToFirstChunk.
assert.equal(nextChunkStub.callCount, 1);
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
});
test('n key without all files expanded and no shift key', async () => {
- MockInteractions.keyUpOn(fileRows[0], 73, 'shift', 'i');
+ MockInteractions.pressAndReleaseKeyOn(fileRows[0], 73, 'shift', 'i');
await flush();
MockInteractions.pressAndReleaseKeyOn(element, 78, 'shift', 'n');
@@ -1712,7 +1688,7 @@
// This is also called in diffCursor.moveToFirstChunk.
assert.equal(nextChunkStub.callCount, 0);
- assert.isTrue(element._showInlineDiffs);
+ assert.equal(element.filesExpanded, FilesExpandedState.ALL);
});
});
@@ -1732,12 +1708,13 @@
});
test('_displayLine', () => {
- sinon.stub(element, 'shouldSuppressKeyboardShortcut')
- .callsFake(() => false);
sinon.stub(element, 'modifierPressed')
.callsFake(() => false);
- element._showInlineDiffs = true;
- const mockEvent = {preventDefault() {}};
+ element.filesExpanded = FilesExpandedState.ALL;
+ const mockEvent = {
+ preventDefault() {},
+ composedPath() { return []; },
+ };
element._displayLine = false;
element._handleCursorNext(mockEvent);
@@ -1758,13 +1735,13 @@
const saveReviewStub = sinon.stub(element, '_saveReviewedState');
element.editMode = false;
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
assert.isTrue(saveReviewStub.calledOnce);
element.editMode = true;
await flush();
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
assert.isTrue(saveReviewStub.calledOnce);
});
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_html.ts b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_html.ts
index f9d21d9..0af2f36 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_html.ts
@@ -53,25 +53,27 @@
);
padding: 0 var(--spacing-m);
}
- gr-button.iron-selected[vote='max'] {
+ gr-tooltip-content.iron-selected > gr-button[vote='max'] {
--button-background-color: var(--vote-color-approved);
}
- gr-button.iron-selected[vote='positive'] {
+ gr-tooltip-content.iron-selected > gr-buttonvote='positive'] {
--button-background-color: var(--vote-color-recommended);
}
- gr-button.iron-selected[vote='min'] {
+ gr-tooltip-content.iron-selected > gr-button[vote='min'] {
--button-background-color: var(--vote-color-rejected);
}
- gr-button.iron-selected[vote='negative'] {
+ gr-tooltip-content.iron-selected > gr-button[vote='negative'] {
--button-background-color: var(--vote-color-disliked);
}
- gr-button.iron-selected[vote='neutral'] {
+ gr-tooltip-content.iron-selected > gr-button[vote='neutral'] {
--button-background-color: var(--vote-color-neutral);
}
- gr-button.iron-selected[vote='positive']::part(paper-button) {
+ gr-tooltip-content.iron-selected
+ > gr-button[vote='positive']::part(paper-button) {
border-color: var(--vote-outline-recommended);
}
- gr-button.iron-selected[vote='negative']::part(paper-button) {
+ gr-tooltip-content.iron-selected
+ > gr-button[vote='negative']::part(paper-button) {
border-color: var(--vote-outline-disliked);
}
.placeholder {
@@ -116,17 +118,20 @@
aria-labelledby="labelName"
>
<template is="dom-repeat" items="[[_items]]" as="value">
- <gr-button
- role="radio"
- vote$="[[_computeVoteAttribute(value, index, _items.length)]]"
- vote-chip
- has-tooltip=""
+ <gr-tooltip-content
+ has-tooltip
+ title$="[[_computeLabelValueTitle(labels, label.name, value)]]"
data-name$="[[label.name]]"
data-value$="[[value]]"
- title$="[[_computeLabelValueTitle(labels, label.name, value)]]"
>
- [[value]]</gr-button
- >
+ <gr-button
+ role="radio"
+ vote$="[[_computeVoteAttribute(value, index, _items.length)]]"
+ voteChip
+ >
+ [[value]]
+ </gr-button>
+ </gr-tooltip-content>
</template>
</iron-selector>
<template
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.js b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.js
index e7ff236..34e959b 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.js
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row_test.js
@@ -97,14 +97,14 @@
}
}
- test('label picker', () => {
+ test('label picker', async () => {
const labelsChangedHandler = sinon.stub();
element.addEventListener('labels-changed', labelsChangedHandler);
assert.ok(element.$.labelSelector);
MockInteractions.tap(element.shadowRoot
.querySelector(
- 'gr-button[data-value="-1"]'));
- flush();
+ 'gr-tooltip-content[data-value="-1"] > gr-button'));
+ await flush();
assert.strictEqual(element.selectedValue, '-1');
assert.strictEqual(element.selectedItem
.textContent.trim(), '-1');
@@ -160,26 +160,6 @@
checkAriaCheckedValid();
});
- test('do not display tooltips on touch devices', () => {
- const verifiedBtn = element.shadowRoot
- .querySelector(
- 'iron-selector > gr-button[data-value="-1"]');
-
- // On touch devices, tooltips should not be shown.
- verifiedBtn._isTouchDevice = true;
- verifiedBtn._handleShowTooltip();
- assert.isNotOk(verifiedBtn._tooltip);
- verifiedBtn._handleHideTooltip();
- assert.isNotOk(verifiedBtn._tooltip);
-
- // On other devices, tooltips should be shown.
- verifiedBtn._isTouchDevice = false;
- verifiedBtn._handleShowTooltip();
- assert.isOk(verifiedBtn._tooltip);
- verifiedBtn._handleHideTooltip();
- assert.isNotOk(verifiedBtn._tooltip);
- });
-
test('_computeLabelValue', () => {
assert.strictEqual(element._computeLabelValue(element.labels,
element.permittedLabels,
@@ -209,7 +189,7 @@
'Code-Review'), []);
});
- test('changes in label score are reflected in the DOM', () => {
+ test('changes in label score are reflected in the DOM', async () => {
element.labels = {
'Code-Review': {
values: {
@@ -232,9 +212,10 @@
default_value: 0,
},
};
+ await flush();
const selector = element.$.labelSelector;
element.set('label', {name: 'Verified', value: ' 0'});
- flush();
+ await flush();
assert.strictEqual(selector.selected, ' 0');
assert.strictEqual(
element.$.selectedValueLabel.textContent.trim(), 'No score');
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
index 4147cc0..a496be5 100644
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores.ts
@@ -16,9 +16,8 @@
*/
import '../gr-label-score-row/gr-label-score-row';
import '../../../styles/shared-styles';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-label-scores_html';
-import {customElement, property} from '@polymer/decorators';
+import {LitElement, css, html} from 'lit';
+import {customElement, property} from 'lit/decorators';
import {hasOwnProperty} from '../../../utils/common-util';
import {
LabelNameToValueMap,
@@ -33,21 +32,14 @@
Label,
LabelValuesMap,
} from '../gr-label-score-row/gr-label-score-row';
-import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
import {appContext} from '../../../services/app-context';
import {labelCompare} from '../../../utils/label-util';
import {Execution} from '../../../constants/reporting';
+import {ChangeStatus} from '../../../constants/constants';
@customElement('gr-label-scores')
-export class GrLabelScores extends PolymerElement {
- static get template() {
- return htmlTemplate;
- }
-
- @property({type: Array, computed: '_computeLabels(change.labels.*, account)'})
- _labels: Label[] = [];
-
- @property({type: Object, observer: '_computeColumns'})
+export class GrLabelScores extends LitElement {
+ @property({type: Object})
permittedLabels?: LabelNameToValueMap;
@property({type: Object})
@@ -56,11 +48,63 @@
@property({type: Object})
account?: AccountInfo;
- @property({type: Object})
- _labelValues?: LabelValuesMap;
-
private readonly reporting = appContext.reportingService;
+ static override get styles() {
+ return [
+ css`
+ .scoresTable {
+ display: table;
+ width: 100%;
+ }
+ .mergedMessage,
+ .abandonedMessage {
+ font-style: italic;
+ text-align: center;
+ width: 100%;
+ }
+ gr-label-score-row:hover {
+ background-color: var(--hover-background-color);
+ }
+ gr-label-score-row {
+ display: table-row;
+ }
+ gr-label-score-row.no-access {
+ display: none;
+ }
+ `,
+ ];
+ }
+
+ override render() {
+ const labels = this._computeLabels();
+ const labelValues = this._computeColumns();
+ return html`<div class="scoresTable">
+ ${labels.map(
+ label => html`<gr-label-score-row
+ class="${this.computeLabelAccessClass(label.name)}"
+ .label="${label}"
+ .name="${label.name}"
+ .labels="${this.change?.labels}"
+ .permittedLabels="${this.permittedLabels}"
+ .labelValues="${labelValues}"
+ ></gr-label-score-row>`
+ )}
+ </div>
+ <div
+ class="mergedMessage"
+ ?hidden=${this.change?.status !== ChangeStatus.MERGED}
+ >
+ Because this change has been merged, votes may not be decreased.
+ </div>
+ <div
+ class="abandonedMessage"
+ ?hidden=${this.change?.status !== ChangeStatus.ABANDONED}
+ >
+ Because this change has been abandoned, you cannot vote.
+ </div>`;
+ }
+
getLabelValues(includeDefaults = true): LabelNameToValuesMap {
const labels: LabelNameToValuesMap = {};
if (this.shadowRoot === null || !this.change) {
@@ -79,7 +123,7 @@
if (selectedVal === undefined) continue;
- const defValNum = this._getDefaultValue(this.change.labels, label);
+ const defValNum = this.getDefaultValue(label);
if (includeDefaults || selectedVal !== defValNum) {
labels[label] = selectedVal;
}
@@ -87,7 +131,7 @@
return labels;
}
- _getStringLabelValue(
+ private getStringLabelValue(
labels: LabelNameToInfoMap,
labelName: string,
numberValue?: number
@@ -108,25 +152,26 @@
return stringVal;
}
- _getDefaultValue(labels?: LabelNameToInfoMap, labelName?: string) {
+ private getDefaultValue(labelName?: string) {
+ const labels = this.change?.labels;
if (!labelName || !labels?.[labelName]) return undefined;
const labelInfo = labels[labelName] as DetailedLabelInfo;
return labelInfo.default_value;
}
- _getVoteForAccount(
- labels: LabelNameToInfoMap | undefined,
- labelName: string,
- account?: AccountInfo
- ): string | null {
+ _getVoteForAccount(labelName: string): string | null {
+ const labels = this.change?.labels;
if (!labels) return null;
const votes = labels[labelName] as DetailedLabelInfo;
if (votes.all && votes.all.length > 0) {
for (let i = 0; i < votes.all.length; i++) {
- // TODO(TS): Replace == with === and check code can assign string to _account_id instead of number
- // eslint-disable-next-line eqeqeq
- if (account && votes.all[i]._account_id == account._account_id) {
- return this._getStringLabelValue(
+ if (
+ this.account &&
+ // TODO(TS): Replace == with === and check code can assign string to _account_id instead of number
+ // eslint-disable-next-line eqeqeq
+ votes.all[i]._account_id == this.account._account_id
+ ) {
+ return this.getStringLabelValue(
labels,
labelName,
votes.all[i].value
@@ -137,32 +182,26 @@
return null;
}
- _computeLabels(
- labelRecord: PolymerDeepPropertyChange<
- LabelNameToInfoMap,
- LabelNameToInfoMap
- >,
- account?: AccountInfo
- ): Label[] {
- if (!account) return [];
- if (!labelRecord?.base) return [];
- const labelsObj = labelRecord.base;
+ _computeLabels(): Label[] {
+ if (!this.account) return [];
+ const labelsObj = this.change?.labels;
+ if (!labelsObj) return [];
return Object.keys(labelsObj)
.sort(labelCompare)
.map(key => {
return {
name: key,
- value: this._getVoteForAccount(labelsObj, key, this.account),
+ value: this._getVoteForAccount(key),
};
});
}
- _computeColumns(permittedLabels?: LabelNameToValueMap) {
- if (!permittedLabels) return;
- const labels = Object.keys(permittedLabels);
+ _computeColumns() {
+ if (!this.permittedLabels) return;
+ const labels = Object.keys(this.permittedLabels);
const values: Set<number> = new Set();
for (const label of labels) {
- for (const value of permittedLabels[label]) {
+ for (const value of this.permittedLabels[label]) {
values.add(Number(value));
}
}
@@ -173,23 +212,14 @@
for (let i = 0; i < orderedValues.length; i++) {
labelValues[orderedValues[i]] = i;
}
- this._labelValues = labelValues;
+ return labelValues;
}
- _changeIsMerged(changeStatus: string) {
- return changeStatus === 'MERGED';
- }
+ private computeLabelAccessClass(label?: string) {
+ if (!this.permittedLabels || !label) return '';
- _computeLabelAccessClass(
- label?: string,
- permittedLabels?: LabelNameToValueMap
- ) {
- if (!permittedLabels || !label) {
- return '';
- }
-
- return hasOwnProperty(permittedLabels, label) &&
- permittedLabels[label].length
+ return hasOwnProperty(this.permittedLabels, label) &&
+ this.permittedLabels[label].length
? 'access'
: 'no-access';
}
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_html.ts b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_html.ts
deleted file mode 100644
index 7b1fb7f..0000000
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_html.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style include="shared-styles">
- .scoresTable {
- display: table;
- width: 100%;
- }
- .mergedMessage {
- font-style: italic;
- text-align: center;
- width: 100%;
- }
- gr-label-score-row:hover {
- background-color: var(--hover-background-color);
- }
- gr-label-score-row {
- display: table-row;
- }
- gr-label-score-row.no-access {
- display: none;
- }
- </style>
- <div class="scoresTable">
- <template is="dom-repeat" items="[[_labels]]" as="label">
- <gr-label-score-row
- class$="[[_computeLabelAccessClass(label.name, permittedLabels)]]"
- label="[[label]]"
- name="[[label.name]]"
- labels="[[change.labels]]"
- permitted-labels="[[permittedLabels]]"
- label-values="[[_labelValues]]"
- ></gr-label-score-row>
- </template>
- </div>
- <div class="mergedMessage" hidden$="[[!_changeIsMerged(change.status)]]">
- Because this change has been merged, votes may not be decreased.
- </div>
-`;
diff --git a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_test.ts b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_test.ts
index 58fe189..f529464 100644
--- a/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-label-scores/gr-label-scores_test.ts
@@ -17,7 +17,7 @@
import '../../../test/common-test-setup-karma';
import './gr-label-scores';
-import {queryAndAssert, stubRestApi} from '../../../test/test-utils';
+import {isHidden, queryAndAssert, stubRestApi} from '../../../test/test-utils';
import {GrLabelScores} from './gr-label-scores';
import {AccountId} from '../../../types/common';
import {GrLabelScoreRow} from '../gr-label-score-row/gr-label-score-row';
@@ -25,6 +25,7 @@
createAccountWithId,
createChange,
} from '../../../test/test-data-generators';
+import {ChangeStatus} from '../../../constants/constants';
const basicFixture = fixtureFromElement('gr-label-scores');
@@ -84,7 +85,7 @@
await flush();
});
- test('get and set label scores', () => {
+ test('get and set label scores', async () => {
for (const label of Object.keys(element.permittedLabels!)) {
const row = queryAndAssert<GrLabelScoreRow>(
element,
@@ -92,6 +93,7 @@
);
row.setSelectedValue('-1');
}
+ await flush();
assert.deepEqual(element.getLabelValues(), {
'Code-Review': -1,
Verified: -1,
@@ -116,19 +118,12 @@
test('_getVoteForAccount', () => {
const labelName = 'Code-Review';
- assert.strictEqual(
- element._getVoteForAccount(
- element.change!.labels,
- labelName,
- element.account
- ),
- '+1'
- );
+ assert.strictEqual(element._getVoteForAccount(labelName), '+1');
});
test('_computeColumns', () => {
- element._computeColumns(element.permittedLabels);
- assert.deepEqual(element._labelValues, {
+ const labelValues = element._computeColumns();
+ assert.deepEqual(labelValues, {
'-2': 0,
'-1': 1,
'0': 2,
@@ -137,31 +132,8 @@
});
});
- test('_computeLabelAccessClass undefined case', () => {
- assert.strictEqual(
- element._computeLabelAccessClass(undefined, undefined),
- ''
- );
- assert.strictEqual(element._computeLabelAccessClass('', undefined), '');
- assert.strictEqual(element._computeLabelAccessClass(undefined, {}), '');
- });
-
- test('_computeLabelAccessClass has access', () => {
- assert.strictEqual(
- element._computeLabelAccessClass('foo', {foo: ['']}),
- 'access'
- );
- });
-
- test('_computeLabelAccessClass no access', () => {
- assert.strictEqual(
- element._computeLabelAccessClass('zap', {foo: ['']}),
- 'no-access'
- );
- });
-
- test('changes in label score are reflected in _labels', () => {
- element.change = {
+ test('changes in label score are reflected in _labels', async () => {
+ const change = {
...createChange(),
labels: {
'Code-Review': {
@@ -186,17 +158,62 @@
},
},
};
- assert.deepEqual(element._labels, [
+ element.change = change;
+ await flush();
+ let labels = element._computeLabels();
+ assert.deepEqual(labels, [
{name: 'Code-Review', value: null},
{name: 'Verified', value: null},
]);
- element.set(
- ['change', 'labels', 'Verified', 'all'],
- [{_account_id: accountId, value: 1}]
- );
- assert.deepEqual(element._labels, [
+ element.change = {
+ ...change,
+ labels: {
+ ...change.labels,
+ Verified: {
+ ...change.labels.Verified,
+ all: [
+ {
+ _account_id: accountId,
+ value: 1,
+ },
+ ],
+ },
+ },
+ };
+ await flush();
+ labels = element._computeLabels();
+ assert.deepEqual(labels, [
{name: 'Code-Review', value: null},
{name: 'Verified', value: '+1'},
]);
});
+ suite('message', () => {
+ test('shown when change is abandoned', async () => {
+ element.change = {
+ ...createChange(),
+ status: ChangeStatus.ABANDONED,
+ };
+ await flush();
+ assert.isFalse(isHidden(queryAndAssert(element, '.abandonedMessage')));
+ assert.isTrue(isHidden(queryAndAssert(element, '.mergedMessage')));
+ });
+ test('shown when change is merged', async () => {
+ element.change = {
+ ...createChange(),
+ status: ChangeStatus.MERGED,
+ };
+ await flush();
+ assert.isFalse(isHidden(queryAndAssert(element, '.mergedMessage')));
+ assert.isTrue(isHidden(queryAndAssert(element, '.abandonedMessage')));
+ });
+ test('do not show for new', async () => {
+ element.change = {
+ ...createChange(),
+ status: ChangeStatus.NEW,
+ };
+ await flush();
+ assert.isTrue(isHidden(queryAndAssert(element, '.mergedMessage')));
+ assert.isTrue(isHidden(queryAndAssert(element, '.abandonedMessage')));
+ });
+ });
});
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
index b4e85a9..95e4301 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message.ts
@@ -209,7 +209,7 @@
this.addEventListener('click', e => this._handleClick(e));
}
- connectedCallback() {
+ override connectedCallback() {
super.connectedCallback();
this.restApiService.getConfig().then(config => {
this.config = config;
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message_html.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message_html.ts
index ddbd22e..7f3e9de 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message_html.ts
@@ -132,7 +132,7 @@
}
.dateContainer .patchsetDiffButton {
margin-right: var(--spacing-m);
- --padding: 0 var(--spacing-m);
+ --gr-button-padding: 0 var(--spacing-m);
}
span.date {
color: var(--deemphasized-text-color);
@@ -325,8 +325,8 @@
<template is="dom-if" if="[[!message.id]]">
<span class="date">
<gr-date-formatter
- has-tooltip=""
- show-date-and-time=""
+ withTooltip
+ showDateAndTime
date-str="[[message.date]]"
></gr-date-formatter>
</span>
@@ -334,8 +334,8 @@
<template is="dom-if" if="[[message.id]]">
<span class="date" on-click="_handleAnchorClick">
<gr-date-formatter
- has-tooltip=""
- show-date-and-time=""
+ withTooltip
+ showDateAndTime
date-str="[[message.date]]"
></gr-date-formatter>
</span>
diff --git a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts
index 90d2049..f87c4c3 100644
--- a/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-message/gr-message_test.ts
@@ -51,7 +51,7 @@
} from '../../../types/events';
import {GrButton} from '../../shared/gr-button/gr-button';
import {CommentSide} from '../../../constants/constants';
-import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonStubbedMember} from 'sinon';
const basicFixture = fixtureFromElement('gr-message');
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
index e458611..cd79bba 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.ts
@@ -90,27 +90,19 @@
*/
function computeThreads(
message: CombinedMessage,
- changeComments?: ChangeComments
+ allThreadsForChange: CommentThread[]
): CommentThread[] {
- if (message._index === undefined || changeComments === undefined) {
+ if (message._index === undefined) {
return [];
}
const messageId = getMessageId(message);
- return changeComments.getAllThreadsForChange().filter(thread =>
- thread.comments
- .map(comment => {
- // collapse all by default
- comment.collapsed = true;
- return comment;
- })
- .some(comment => {
- const condition = comment.change_message_id === messageId;
- // Since getAllThreadsForChange() always returns a new copy of
- // all comments we can modify them here without worrying about
- // polluting other threads.
- comment.collapsed = !condition;
- return condition;
- })
+ return allThreadsForChange.filter(thread =>
+ thread.comments.some(comment => {
+ const matchesMessage = comment.change_message_id === messageId;
+ if (!matchesMessage) return false;
+ comment.collapsed = !matchesMessage;
+ return matchesMessage;
+ })
);
}
@@ -198,7 +190,6 @@
}
export const TEST_ONLY = {
- computeThreads,
computeTag,
computeRevision,
computeIsImportant,
@@ -266,6 +257,8 @@
private readonly reporting = appContext.reportingService;
+ private readonly shortcuts = appContext.shortcutsService;
+
scrollToMessage(messageID: string) {
const selector = `[data-message-id="${messageID}"]`;
const el = this.shadowRoot!.querySelector(selector) as
@@ -355,14 +348,24 @@
mDate = null;
}
}
- combinedMessages.forEach(m => {
- if (m.expanded === undefined) {
- m.expanded = false;
+
+ const allThreadsForChange = changeComments.getAllThreadsForChange();
+ // collapse all by default
+ for (const thread of allThreadsForChange) {
+ for (const comment of thread.comments) {
+ comment.collapsed = true;
}
- m.commentThreads = computeThreads(m, changeComments);
- m._revision_number = computeRevision(m, combinedMessages);
- m.tag = computeTag(m);
- });
+ }
+
+ for (let i = 0; i < combinedMessages.length; i++) {
+ const message = combinedMessages[i];
+ if (message.expanded === undefined) {
+ message.expanded = false;
+ }
+ message.commentThreads = computeThreads(message, allThreadsForChange);
+ message._revision_number = computeRevision(message, combinedMessages);
+ message.tag = computeTag(message);
+ }
// computeIsImportant() depends on tags and revision numbers already being
// updated for all messages, so we have to compute this in its own forEach
// loop.
@@ -372,10 +375,6 @@
return combinedMessages;
}
- getCommentThreads(message: CombinedMessage, changeComments?: ChangeComments) {
- return computeThreads(message, changeComments);
- }
-
_updateExpandedStateOfAllMessages(exp: boolean) {
if (this._combinedMessages) {
for (let i = 0; i < this._combinedMessages.length; i++) {
@@ -387,13 +386,13 @@
_computeExpandAllTitle(_expandAllState?: string) {
if (_expandAllState === ExpandAllState.COLLAPSE_ALL) {
- return this.createTitle(
+ return this.shortcuts.createTitle(
Shortcut.COLLAPSE_ALL_MESSAGES,
ShortcutSection.ACTIONS
);
}
if (_expandAllState === ExpandAllState.EXPAND_ALL) {
- return this.createTitle(
+ return this.shortcuts.createTitle(
Shortcut.EXPAND_ALL_MESSAGES,
ShortcutSection.ACTIONS
);
@@ -441,24 +440,26 @@
}
/**
- * This method is for reporting stats only.
+ * Called when this._combinedMessages has changed.
*/
_combinedMessagesChanged(combinedMessages?: CombinedMessage[]) {
- if (combinedMessages) {
- if (combinedMessages.length === 0) return;
- const tags = combinedMessages.map(
- message =>
- message.tag || (message as FormattedReviewerUpdateInfo).type || 'none'
- );
- const tagsCounted = tags.reduce(
- (acc, val) => {
- acc[val] = (acc[val] || 0) + 1;
- return acc;
- },
- {all: combinedMessages.length} as TagsCountReportInfo
- );
- this.reporting.reportInteraction('messages-count', tagsCounted);
+ if (!combinedMessages) return;
+ if (combinedMessages.length === 0) return;
+ for (let i = 0; i < combinedMessages.length; i++) {
+ this.notifyPath(`_combinedMessages.${i}.commentThreads`);
}
+ const tags = combinedMessages.map(
+ message =>
+ message.tag || (message as FormattedReviewerUpdateInfo).type || 'none'
+ );
+ const tagsCounted = tags.reduce(
+ (acc, val) => {
+ acc[val] = (acc[val] || 0) + 1;
+ return acc;
+ },
+ {all: combinedMessages.length} as TagsCountReportInfo
+ );
+ this.reporting.reportInteraction('messages-count', tagsCounted);
}
/**
diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
index 93df77e..56fae87 100644
--- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list_html.ts
@@ -93,7 +93,7 @@
change="[[change]]"
change-num="[[changeNum]]"
message="[[message]]"
- comment-threads="[[getCommentThreads(message, changeComments)]]"
+ comment-threads="[[message.commentThreads]]"
project-name="[[projectName]]"
show-reply-button="[[showReplyButtons]]"
on-message-anchor-tap="_handleAnchorClick"
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-change.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-change.ts
index d34600e..e4703df 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-change.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-change.ts
@@ -24,6 +24,7 @@
} from '../../../types/common';
import {ChangeStatus} from '../../../constants/constants';
import {isChangeInfo} from '../../../utils/change-util';
+import {ifDefined} from 'lit/directives/if-defined';
@customElement('gr-related-change')
export class GrRelatedChange extends LitElement {
@@ -109,7 +110,7 @@
const linkClass = this._computeLinkClass(change);
return html`
<div class="changeContainer">
- <a href="${this.href}" class="${linkClass}"><slot></slot></a>
+ <a href="${ifDefined(this.href)}" class="${linkClass}"><slot></slot></a>
${this.showSubmittableCheck
? html`<span
tabindex="-1"
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
index 74f20f2..bce4024 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
@@ -40,6 +40,7 @@
isChangeInfo,
} from '../../../utils/change-util';
import {Interaction} from '../../../constants/reporting';
+import {fontStyles} from '../../../styles/gr-font-styles';
/** What is the maximum number of shown changes in collapsed list? */
const DEFALT_NUM_CHANGES_WHEN_COLLAPSED = 3;
@@ -686,9 +687,9 @@
static override get styles() {
return [
sharedStyles,
+ fontStyles,
css`
.title {
- font-weight: var(--font-weight-bold);
color: var(--deemphasized-text-color);
padding-left: var(--metadata-horizontal-padding);
}
@@ -720,7 +721,7 @@
}
override render() {
- const title = html`<h4 class="title">${this.title}</h4>`;
+ const title = html`<h3 class="title heading-3">${this.title}</h3>`;
const collapsible = this.length > this.numChangesWhenCollapsed;
this.collapsed = !this.showAll && collapsible;
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
index e38e0ae..a6dc338f 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_test.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonStubbedMember} from 'sinon';
import {PluginApi} from '../../../api/plugin';
import {ChangeStatus} from '../../../constants/constants';
import {RestApiService} from '../../../services/gr-rest-api/gr-rest-api';
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
index 933cb821..b8c9319 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog-it_test.js
@@ -127,7 +127,7 @@
const labelScoreRows = element.getLabelScores().shadowRoot
.querySelector('gr-label-score-row[name="Code-Review"]');
const selectedBtn = labelScoreRows.shadowRoot
- .querySelector('gr-button[data-value="+1"].iron-selected');
+ .querySelector('gr-tooltip-content[data-value="+1"] > gr-button');
assert.isOk(selectedBtn);
});
});
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts
index b571985..0beb91c 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_html.ts
@@ -177,7 +177,7 @@
}
.attention .edit-attention-button {
vertical-align: top;
- --padding: 0px 4px;
+ --gr-button-padding: 0px 4px;
}
.attention .edit-attention-button iron-icon {
color: inherit;
@@ -441,23 +441,26 @@
></gr-account-label>
</template>
</template>
- <gr-button
- class="edit-attention-button"
- on-click="_handleAttentionModify"
- disabled="[[_sendDisabled]]"
- link=""
- position-below=""
- data-label="Edit"
- data-action-type="change"
- data-action-key="edit"
- has-tooltip=""
+ <gr-tooltip-content
+ has-tooltip
title="[[_computeAttentionButtonTitle(_sendDisabled)]]"
- role="button"
- tabindex="0"
>
- <iron-icon icon="gr-icons:edit"></iron-icon>
- Modify
- </gr-button>
+ <gr-button
+ class="edit-attention-button"
+ on-click="_handleAttentionModify"
+ disabled="[[_sendDisabled]]"
+ link=""
+ position-below=""
+ data-label="Edit"
+ data-action-type="change"
+ data-action-key="edit"
+ role="button"
+ tabindex="0"
+ >
+ <iron-icon icon="gr-icons:edit"></iron-icon>
+ Modify
+ </gr-button>
+ </gr-tooltip-content>
</div>
<div>
<a
@@ -612,26 +615,32 @@
<!-- Use 'Send' here as the change may only about reviewers / ccs
and when this button is visible, the next button will always
be 'Start review' -->
- <gr-button
- link=""
- disabled="[[_isState(knownLatestState, 'not-latest')]]"
- class="action save"
+ <gr-tooltip-content
has-tooltip=""
- title="[[_saveTooltip]]"
- on-click="_saveClickHandler"
- >Send As WIP</gr-button
+ title$="[[_saveTooltip]]"
>
+ <gr-button
+ link=""
+ disabled="[[_isState(knownLatestState, 'not-latest')]]"
+ class="action save"
+ on-click="_saveClickHandler"
+ >Send As WIP</gr-button
+ >
+ </gr-tooltip-content>
</template>
- <gr-button
- id="sendButton"
- primary=""
- disabled="[[_sendDisabled]]"
- class="action send"
+ <gr-tooltip-content
has-tooltip=""
title$="[[_computeSendButtonTooltip(canBeStarted, _commentEditing)]]"
- on-click="_sendTapHandler"
- >[[_sendButtonLabel]]</gr-button
>
+ <gr-button
+ id="sendButton"
+ primary=""
+ disabled="[[_sendDisabled]]"
+ class="action send"
+ on-click="_sendTapHandler"
+ >[[_sendButtonLabel]]
+ </gr-button>
+ </gr-tooltip-content>
</div>
</section>
</div>
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
index e3bbd9e..e57ffc7 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog_test.ts
@@ -116,7 +116,7 @@
return {id: `${lastId++}` as GroupId};
};
- setup(() => {
+ setup(async () => {
changeNum = 42 as NumericChangeId;
patchNum = 1 as PatchSetNum;
@@ -168,7 +168,7 @@
// .returns(Promise.resolve({isLatest: true}));
// Allow the elements created by dom-repeat to be stamped.
- flush();
+ await flush();
});
function stubSaveReview(
@@ -216,6 +216,7 @@
// which the dom-repeat elements are stamped.
await flush();
tap(queryAndAssert(element, '.send'));
+ await flush();
const review = await saveReviewPromise;
assert.deepEqual(review, {
@@ -1063,6 +1064,7 @@
const label = 'Verified';
const value = '+1';
element.setLabelValue(label, value);
+ await flush();
const labels = (
queryAndAssert(element, '#labelScores') as GrLabelScores
diff --git a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_html.ts b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_html.ts
index 058007b..dec65e2 100644
--- a/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-reviewer-list/gr-reviewer-list_html.ts
@@ -42,15 +42,13 @@
display: inline-block;
}
gr-button.addReviewer {
- --padding: 1px 4px;
+ --gr-button-padding: 1px 0px;
vertical-align: top;
top: 1px;
}
gr-button {
line-height: var(--line-height-normal);
- --gr-button: {
- padding: 0px 0px;
- }
+ --gr-button-padding: 0px;
}
gr-account-chip {
line-height: var(--line-height-normal);
@@ -58,8 +56,9 @@
display: inline-block;
}
gr-vote-chip {
- --gr-vote-chip-width: 16px;
- --gr-vote-chip-height: 16px;
+ --gr-vote-chip-width: 14px;
+ --gr-vote-chip-height: 14px;
+ margin-right: var(--spacing-s);
}
</style>
<div class="container">
diff --git a/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard.ts b/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard.ts
index 7ca7226..2e00034 100644
--- a/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard.ts
+++ b/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard.ts
@@ -16,12 +16,14 @@
*/
import '../../../styles/gr-font-styles';
import '../../shared/gr-hovercard/gr-hovercard-shared-style';
+import '../../shared/gr-button/gr-button';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {customElement, property} from '@polymer/decorators';
import {HovercardBehaviorMixin} from '../../shared/gr-hovercard/gr-hovercard-behavior';
import {htmlTemplate} from './gr-submit-requirement-hovercard_html';
import {
AccountInfo,
+ SubmitRequirementExpressionInfo,
SubmitRequirementResultInfo,
SubmitRequirementStatus,
} from '../../../api/rest-api';
@@ -51,7 +53,10 @@
account?: AccountInfo;
@property({type: Boolean})
- mutable?: boolean;
+ mutable = false;
+
+ @property({type: Boolean})
+ expanded = false;
@property({type: Array, computed: 'computeLabels(change, requirement)'})
_labels: Label[] = [];
@@ -82,6 +87,16 @@
computeIcon(status: SubmitRequirementStatus) {
return iconForStatus(status);
}
+
+ renderCondition(expression?: SubmitRequirementExpressionInfo) {
+ if (!expression) return '';
+
+ return expression.expression;
+ }
+
+ _handleShowConditions() {
+ this.expanded = true;
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard_html.ts b/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard_html.ts
index 6adb29e..b7b4d9c 100644
--- a/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-submit-requirement-hovercard/gr-submit-requirement-hovercard_html.ts
@@ -43,7 +43,6 @@
}
.row {
display: flex;
- margin-top: var(--spacing-s);
}
.title {
color: var(--deemphasized-text-color);
@@ -52,19 +51,38 @@
div.section {
margin: 0 var(--spacing-xl) var(--spacing-m) var(--spacing-xl);
display: flex;
+ align-items: center;
+ }
+ div.sectionIcon {
+ flex: 0 0 30px;
}
div.sectionIcon iron-icon {
position: relative;
- top: 2px;
width: 20px;
height: 20px;
}
+ .condition {
+ background-color: var(--gray-background);
+ padding: var(--spacing-m);
+ flex-grow: 1;
+ }
+ .expression {
+ color: var(--gray-foreground);
+ }
iron-icon.check {
color: var(--success-foreground);
}
iron-icon.close {
color: var(--warning-foreground);
}
+ .showConditions iron-icon {
+ color: inherit;
+ }
+ div.showConditions {
+ border-top: 1px solid var(--border-color);
+ margin-top: var(--spacing-m);
+ padding: var(--spacing-m) var(--spacing-xl) 0;
+ }
</style>
<div id="container" role="tooltip" tabindex="-1">
<div class="section">
@@ -113,5 +131,59 @@
</section>
</template>
</div>
+ <template is="dom-if" if="[[!expanded]]">
+ <div class="showConditions">
+ <gr-button
+ link=""
+ class="showConditions"
+ on-click="_handleShowConditions"
+ >
+ View condition
+ <iron-icon icon="gr-icons:expand-more"></iron-icon
+ ></gr-button>
+ </div>
+ </template>
+ <template is="dom-if" if="[[expanded]]">
+ <div class="section">
+ <div class="sectionIcon">
+ <iron-icon icon="gr-icons:description"></iron-icon>
+ </div>
+ <div class="sectionContent">[[requirement.description]]</div>
+ </div>
+ <div class="section">
+ <div class="sectionIcon"></div>
+ <div class="sectionContent condition">
+ Blocking condition:<br />
+ <span class="expression">
+ [[renderCondition(requirement.submittability_expression_result)]]
+ </span>
+ </div>
+ </div>
+ <template
+ is="dom-if"
+ if="[[requirement.applicability_expression_result]]"
+ >
+ <div class="section">
+ <div class="sectionIcon"></div>
+ <div class="sectionContent condition">
+ Application condition:<br />
+ <span class="expression">
+ [[renderCondition(requirement.applicability_expression_result)]]
+ </span>
+ </div>
+ </div>
+ </template>
+ <template is="dom-if" if="[[requirement.override_expression_result]]">
+ <div class="section">
+ <div class="sectionIcon"></div>
+ <div class="sectionContent condition">
+ Override condition:<br />
+ <span class="expression">
+ [[renderCondition(requirement.override_expression_result)]]
+ </span>
+ </div>
+ </div>
+ </template>
+ </template>
</div>
`;
diff --git a/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts b/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts
index 286f24a..21e8093 100644
--- a/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts
+++ b/polygerrit-ui/app/elements/change/gr-submit-requirements/gr-submit-requirements.ts
@@ -16,11 +16,12 @@
*/
import '../gr-submit-requirement-hovercard/gr-submit-requirement-hovercard';
import {LitElement, css, html} from 'lit';
-import {customElement, property} from 'lit/decorators';
+import {customElement, property, state} from 'lit/decorators';
import {ParsedChangeInfo} from '../../../types/types';
import {
AccountInfo,
isDetailedLabelInfo,
+ LabelInfo,
LabelNameToInfoMap,
SubmitRequirementResultInfo,
SubmitRequirementStatus,
@@ -28,8 +29,20 @@
import {unique} from '../../../utils/common-util';
import {
extractAssociatedLabels,
+ getAllUniqueApprovals,
+ hasVotes,
iconForStatus,
} from '../../../utils/label-util';
+import {fontStyles} from '../../../styles/gr-font-styles';
+import {charsOnly, pluralize} from '../../../utils/string-util';
+import {subscribe} from '../../lit/subscription-controller';
+import {
+ allRunsLatestPatchsetLatestAttempt$,
+ CheckRun,
+} from '../../../services/checks/checks-model';
+import {getResultsOf, hasResultsOf} from '../../../services/checks/checks-util';
+import {Category} from '../../../api/checks';
+import '../../shared/gr-vote-chip/gr-vote-chip';
@customElement('gr-submit-requirements')
export class GrSubmitRequirements extends LitElement {
@@ -42,45 +55,23 @@
@property({type: Boolean})
mutable?: boolean;
+ @state()
+ runs: CheckRun[] = [];
+
static override get styles() {
return [
+ fontStyles,
css`
- :host {
- display: table;
- width: 100%;
- }
.metadata-title {
- font-size: 100%;
- font-weight: var(--font-weight-bold);
color: var(--deemphasized-text-color);
padding-left: var(--metadata-horizontal-padding);
- }
- section {
- display: table-row;
- }
- .title {
- min-width: 10em;
- padding: var(--spacing-s) 0 0 0;
- }
- .value {
- padding: var(--spacing-s) 0 0 0;
- }
- .title,
- .status {
- display: table-cell;
- vertical-align: top;
- }
- .value {
- display: inline-flex;
- }
- .status {
- width: var(--line-height-small);
- padding: var(--spacing-s) var(--spacing-m) 0
- var(--requirements-horizontal-padding);
+ margin: 0 0 var(--spacing-s);
+ border-top: 1px solid var(--border-color);
+ padding-top: var(--spacing-s);
}
iron-icon {
- width: var(--line-height-small);
- height: var(--line-height-small);
+ width: var(--line-height-normal, 20px);
+ height: var(--line-height-normal, 20px);
}
iron-icon.check {
color: var(--success-foreground);
@@ -102,33 +93,103 @@
.testing:hover * {
visibility: visible;
}
+ .requirements,
+ section.trigger-votes {
+ margin-left: var(--spacing-l);
+ }
+ .trigger-votes {
+ padding-top: var(--spacing-s);
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--spacing-s);
+ /* Setting max-width as defined in Submit Requirements design,
+ * to wrap overflowed items to next row.
+ */
+ max-width: 390px;
+ }
+ gr-limited-text.name {
+ font-weight: var(--font-weight-bold);
+ }
+ table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ }
+ td {
+ padding: var(--spacing-s);
+ }
+ .votes-cell {
+ display: flex;
+ }
+ .check-error {
+ margin-right: var(--spacing-l);
+ }
+ .check-error iron-icon {
+ color: var(--error-foreground);
+ vertical-align: top;
+ }
+ gr-vote-chip {
+ margin-right: var(--spacing-s);
+ }
`,
];
}
+ constructor() {
+ super();
+ subscribe(this, allRunsLatestPatchsetLatestAttempt$, x => (this.runs = x));
+ }
+
override render() {
const submit_requirements = (this.change?.submit_requirements ?? []).filter(
req => req.status !== SubmitRequirementStatus.NOT_APPLICABLE
);
- return html`<h3 class="metadata-title">Submit Requirements</h3>
+ return html` <h3
+ class="metadata-title heading-3"
+ id="submit-requirements-caption"
+ >
+ Submit Requirements
+ </h3>
+ <table class="requirements" aria-labelledby="submit-requirements-caption">
+ <thead hidden>
+ <tr>
+ <th>Status</th>
+ <th>Name</th>
+ <th>Votes</th>
+ </tr>
+ </thead>
+ <tbody>
+ ${submit_requirements.map(
+ requirement => html`<tr
+ id="requirement-${charsOnly(requirement.name)}"
+ >
+ <td>${this.renderStatus(requirement.status)}</td>
+ <td class="name">
+ <gr-limited-text
+ class="name"
+ limit="25"
+ .text="${requirement.name}"
+ ></gr-limited-text>
+ </td>
+ <td>
+ <div class="votes-cell">
+ ${this.renderVotes(requirement)}
+ ${this.renderChecks(requirement)}
+ </div>
+ </td>
+ </tr>`
+ )}
+ </tbody>
+ </table>
${submit_requirements.map(
- requirement => html`<section>
+ requirement => html`
<gr-submit-requirement-hovercard
+ for="requirement-${charsOnly(requirement.name)}"
.requirement="${requirement}"
.change="${this.change}"
.account="${this.account}"
- .mutable="${this.mutable}"
+ .mutable="${this.mutable ?? false}"
></gr-submit-requirement-hovercard>
- <div class="status">${this.renderStatus(requirement.status)}</div>
- <div class="title">
- <gr-limited-text
- class="name"
- limit="25"
- text="${requirement.name}"
- ></gr-limited-text>
- </div>
- <div class="value">${this.renderVotes(requirement)}</div>
- </section>`
+ `
)}
${this.renderTriggerVotes(
submit_requirements
@@ -140,27 +201,32 @@
return html`<iron-icon
class="${icon}"
icon="gr-icons:${icon}"
+ role="img"
+ aria-label="${status.toLowerCase()}"
></iron-icon>`;
}
renderVotes(requirement: SubmitRequirementResultInfo) {
const requirementLabels = extractAssociatedLabels(requirement);
- const labels = this.change?.labels ?? {};
+ const allLabels = this.change?.labels ?? {};
+ const associatedLabels = Object.keys(allLabels).filter(label =>
+ requirementLabels.includes(label)
+ );
- return Object.keys(labels)
- .filter(label => requirementLabels.includes(label))
- .map(label => this.renderLabelVote(label, labels));
+ const everyAssociatedLabelsIsWithoutVotes = associatedLabels.every(
+ label => !hasVotes(allLabels[label])
+ );
+ if (everyAssociatedLabelsIsWithoutVotes) return html`No votes`;
+
+ return associatedLabels.map(label =>
+ this.renderLabelVote(label, allLabels)
+ );
}
renderLabelVote(label: string, labels: LabelNameToInfoMap) {
const labelInfo = labels[label];
if (!isDetailedLabelInfo(labelInfo)) return;
- const uniqueApprovals = (labelInfo.all ?? [])
- .filter(
- (approvalInfo, index, array) =>
- index === array.findIndex(other => other.value === approvalInfo.value)
- )
- .sort((a, b) => -(a.value ?? 0) + (b.value ?? 0));
+ const uniqueApprovals = getAllUniqueApprovals(labelInfo);
return uniqueApprovals.map(
approvalInfo =>
html`<gr-vote-chip
@@ -173,27 +239,48 @@
);
}
+ renderChecks(requirement: SubmitRequirementResultInfo) {
+ const requirementLabels = extractAssociatedLabels(requirement);
+ const requirementRuns = this.runs
+ .filter(run => hasResultsOf(run, Category.ERROR))
+ .filter(
+ run => run.labelName && requirementLabels.includes(run.labelName)
+ );
+ const runsCount = requirementRuns.reduce(
+ (sum, run) => sum + getResultsOf(run, Category.ERROR).length,
+ 0
+ );
+ if (runsCount > 0) {
+ return html`<span class="check-error"
+ ><iron-icon icon="gr-icons:error"></iron-icon>${pluralize(
+ runsCount,
+ 'error'
+ )}</span
+ >`;
+ }
+ return;
+ }
+
renderTriggerVotes(submitReqs: SubmitRequirementResultInfo[]) {
const labels = this.change?.labels ?? {};
const allLabels = Object.keys(labels);
const labelAssociatedWithSubmitReqs = submitReqs
.flatMap(req => extractAssociatedLabels(req))
.filter(unique);
- const triggerVotes = allLabels.filter(
- label => !labelAssociatedWithSubmitReqs.includes(label)
- );
+ const triggerVotes = allLabels
+ .filter(label => !labelAssociatedWithSubmitReqs.includes(label))
+ .filter(label => hasVotes(labels[label]));
if (!triggerVotes.length) return;
- return html`<h3 class="metadata-title">Trigger Votes</h3>
- ${triggerVotes.map(
- label => html`${label}:
- <gr-label-info
- .change="${this.change}"
- .account="${this.account}"
- .mutable="${this.mutable}"
- label="${label}"
- .labelInfo="${labels[label]}"
- ></gr-label-info>`
- )}`;
+ return html`<h3 class="metadata-title heading-3">Trigger Votes</h3>
+ <section class="trigger-votes">
+ ${triggerVotes.map(
+ label =>
+ html`<gr-trigger-vote
+ .label="${label}"
+ .labelInfo="${labels[label]}"
+ ></gr-trigger-vote>`
+ )}
+ </section>`;
}
renderFakeControls() {
@@ -240,8 +327,61 @@
}
}
+@customElement('gr-trigger-vote')
+export class GrTriggerVote extends LitElement {
+ @property()
+ label?: string;
+
+ @property({type: Object})
+ labelInfo?: LabelInfo;
+
+ static override get styles() {
+ return css`
+ :host {
+ display: block;
+ }
+ .container {
+ box-sizing: border-box;
+ border: 1px solid var(--border-color);
+ border-radius: calc(var(--border-radius) + 2px);
+ background-color: var(--background-color-primary);
+ display: flex;
+ padding: 0;
+ padding-left: var(--spacing-s);
+ padding-right: var(--spacing-xxs);
+ align-items: center;
+ }
+ .label {
+ padding-right: var(--spacing-s);
+ font-weight: var(--font-weight-bold);
+ }
+ gr-vote-chip {
+ --gr-vote-chip-width: 14px;
+ --gr-vote-chip-height: 14px;
+ margin-right: 0px;
+ }
+ `;
+ }
+
+ override render() {
+ const uniqueApprovals = getAllUniqueApprovals(this.labelInfo);
+ return html`
+ <div class="container">
+ <span class="label">${this.label}</span>
+ ${uniqueApprovals.map(
+ approvalInfo => html`<gr-vote-chip
+ .vote="${approvalInfo}"
+ .label="${this.labelInfo}"
+ ></gr-vote-chip>`
+ )}
+ </div>
+ `;
+ }
+}
+
declare global {
interface HTMLElementTagNameMap {
'gr-submit-requirements': GrSubmitRequirements;
+ 'gr-trigger-vote': GrTriggerVote;
}
}
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
index 4d97fec..3eb28c9 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_html.ts
@@ -51,11 +51,8 @@
margin-right: var(--spacing-s);
}
gr-dropdown-list {
- --trigger-style: {
- color: var(--primary-text-color);
- text-transform: none;
- font-family: var(--font-family);
- }
+ --trigger-style-text-color: var(--primary-text-color);
+ --trigger-style-font-family: var(--font-family);
}
.filter-text, .sort-text, .author-text {
margin-right: var(--spacing-s);
@@ -102,9 +99,9 @@
items="[[getCommentsDropdownEntires(threads, loggedIn)]]"
>
</gr-dropdown-list>
- <template is="dom-if" if="[[threads.length]]">
+ <template is="dom-if" if="[[_displayedThreads.length]]">
<span class="author-text">From:</span>
- <template is="dom-repeat" items="[[getCommentAuthors(threads, account)]]">
+ <template is="dom-repeat" items="[[getCommentAuthors(_displayedThreads, account)]]">
<gr-account-label
account="[[item]]"
on-click="handleAccountClicked"
diff --git a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
index b478ef5..aab5cee 100644
--- a/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
+++ b/polygerrit-ui/app/elements/change/gr-thread-list/gr-thread-list_test.js
@@ -495,15 +495,18 @@
test('tapping single author chips', () => {
element.account = createAccountDetailWithId(1);
flush();
- const chips = queryAll(element, 'gr-account-label');
- const authors = Array.from(chips).map(
+ const chips = Array.from(queryAll(element, 'gr-account-label'));
+ const authors = chips.map(
chip => accountOrGroupKey(chip.account))
.sort();
assert.deepEqual(authors, [1, 1000000, 1000001, 1000002, 1000003]);
assert.equal(element.threads.length, 9);
assert.equal(element._displayedThreads.length, 9);
- tap(chips[0]); // accountId 1000001
+ // accountId 1000001
+ const chip = chips.find(chip => chip.account._account_id === 1000001);
+
+ tap(chip);
flush();
assert.equal(element.threads.length, 9);
@@ -511,7 +514,7 @@
assert.equal(element._displayedThreads[0].comments[0].author._account_id,
1000001);
- tap(chips[0]); // tapping again resets
+ tap(chip); // tapping again resets
flush();
assert.equal(element.threads.length, 9);
assert.equal(element._displayedThreads.length, 9);
@@ -520,10 +523,10 @@
test('tapping multiple author chips', () => {
element.account = createAccountDetailWithId(1);
flush();
- const chips = queryAll(element, 'gr-account-label');
+ const chips = Array.from(queryAll(element, 'gr-account-label'));
- tap(chips[0]); // accountId 1000001
- tap(chips[2]); // accountId 1000002
+ tap(chips.find(chip => chip.account._account_id === 1000001));
+ tap(chips.find(chip => chip.account._account_id === 1000002));
flush();
assert.equal(element.threads.length, 9);
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-action.ts b/polygerrit-ui/app/elements/checks/gr-checks-action.ts
index 87cab46..859fd33 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-action.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-action.ts
@@ -22,11 +22,11 @@
@customElement('gr-checks-action')
export class GrChecksAction extends LitElement {
- @property()
+ @property({type: Object})
action!: Action;
- @property()
- eventTarget?: EventTarget;
+ @property({type: Object})
+ eventTarget: HTMLElement | null = null;
private checksService = appContext.checksService;
@@ -43,7 +43,7 @@
white-space: nowrap;
}
gr-button {
- --padding: var(--spacing-s) var(--spacing-m);
+ --gr-button-padding: var(--spacing-s) var(--spacing-m);
}
paper-tooltip {
text-transform: none;
@@ -72,7 +72,7 @@
private renderTooltip() {
if (!this.action.tooltip) return;
return html`
- <paper-tooltip offset="5" fit-to-visible-bounds="true">
+ <paper-tooltip offset="5" fit-to-visible-bounds>
${this.action.tooltip}
</paper-tooltip>
`;
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-attempt.ts b/polygerrit-ui/app/elements/checks/gr-checks-attempt.ts
index b4d87ae..69152b2 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-attempt.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-attempt.ts
@@ -21,7 +21,7 @@
@customElement('gr-checks-attempt')
class GrChecksAttempt extends LitElement {
- @property()
+ @property({attribute: false})
run?: CheckRun;
static override get styles() {
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-results.ts b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
index de334be..48ccf2c 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-results.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-results.ts
@@ -20,7 +20,9 @@
import {LitElement, css, html, PropertyValues, TemplateResult} from 'lit';
import {customElement, property, query, state} from 'lit/decorators';
import './gr-checks-action';
+import './gr-hovercard-run';
import '@polymer/paper-tooltip/paper-tooltip';
+import '@polymer/iron-icon/iron-icon';
import {
Action,
Category,
@@ -46,7 +48,6 @@
iconForLink,
isCategory,
otherPrimaryLinks,
- primaryRunAction,
secondaryLinks,
tooltipForLink,
} from '../../services/checks/checks-util';
@@ -54,7 +55,7 @@
import {modifierPressed, toggleClass, whenVisible} from '../../utils/dom-util';
import {durationString} from '../../utils/date-util';
import {charsOnly} from '../../utils/string-util';
-import {isAttemptSelected} from './gr-checks-util';
+import {isAttemptSelected, matches} from './gr-checks-util';
import {ChecksTabState} from '../../types/events';
import {
ConfigInfo,
@@ -80,19 +81,19 @@
@query('td.nameCol div.name')
nameEl?: HTMLElement;
- @property()
+ @property({attribute: false})
result?: RunResult;
- @property()
+ @state()
isExpanded = false;
@property({type: Boolean, reflect: true})
isExpandable = false;
- @property()
+ @state()
shouldRender = false;
- @property()
+ @state()
labels?: LabelNameToInfoMap;
private checksService = appContext.checksService;
@@ -279,11 +280,10 @@
];
}
- override update(changedProperties: PropertyValues) {
+ override updated(changedProperties: PropertyValues) {
if (changedProperties.has('result')) {
this.isExpandable = !!this.result?.summary && !!this.result?.message;
}
- super.update(changedProperties);
}
override focus() {
@@ -324,7 +324,6 @@
${this.result.checkName}
</div>
<div class="space"></div>
- ${this.renderPrimaryRunAction()}
</div>
</td>
<td class="summaryCol">
@@ -347,7 +346,7 @@
role="switch"
tabindex="0"
?hidden="${!this.isExpandable}"
- ?aria-checked="${this.isExpanded}"
+ aria-checked="${this.isExpanded ? 'true' : 'false'}"
aria-label="${this.isExpanded
? 'Collapse result row'
: 'Expand result row'}"
@@ -367,13 +366,6 @@
`;
}
- private renderPrimaryRunAction() {
- if (!this.result) return;
- const action = primaryRunAction(this.result);
- if (!action) return;
- return html`<gr-checks-action .action="${action}"></gr-checks-action>`;
- }
-
private renderExpanded() {
if (!this.isExpanded) return;
return html`<gr-result-expanded
@@ -428,7 +420,7 @@
return html`
<div class="label ${status}">
<span>${label} ${valueStr}</span>
- <paper-tooltip offset="5" fit-to-visible-bounds="true">
+ <paper-tooltip offset="5" ?fitToVisibleBounds="${true}">
The check result has (probably) influenced this label vote.
</paper-tooltip>
</div>
@@ -525,7 +517,7 @@
renderTag(tag: Tag) {
return html`<div class="tag ${tag.color}">
<span>${tag.name}</span>
- <paper-tooltip offset="5" fit-to-visible-bounds="true">
+ <paper-tooltip offset="5" ?fitToVisibleBounds="${true}">
${tag.tooltip ?? 'A category tag for this check result'}
</paper-tooltip>
</div>`;
@@ -534,10 +526,10 @@
@customElement('gr-result-expanded')
class GrResultExpanded extends LitElement {
- @property()
+ @property({attribute: false})
result?: RunResult;
- @property()
+ @state()
repoConfig?: ConfigInfo;
private changeService = appContext.changeService;
@@ -681,36 +673,36 @@
filterRegExp = new RegExp('');
/** All runs. Shown should only the selected/filtered ones. */
- @property()
+ @property({attribute: false})
runs: CheckRun[] = [];
/**
* Check names of runs that are selected in the runs panel. When this array
* is empty, then no run is selected and all runs should be shown.
*/
- @property()
+ @property({attribute: false})
selectedRuns: string[] = [];
- @property()
+ @state()
actions: Action[] = [];
- @property()
+ @state()
links: Link[] = [];
- @property()
+ @property({attribute: false})
tabState?: ChecksTabState;
- @property()
+ @state()
someProvidersAreLoading = false;
- @property()
+ @state()
checksPatchsetNumber: PatchSetNumber | undefined = undefined;
- @property()
+ @state()
latestPatchsetNumber: PatchSetNumber | undefined = undefined;
/** Maps checkName to selected attempt number. `undefined` means `latest`. */
- @property()
+ @property({attribute: false})
selectedAttempts: Map<string, number | undefined> = new Map<
string,
number | undefined
@@ -817,6 +809,7 @@
}
.headerTopRow .right .goToLatest gr-button {
margin-right: var(--spacing-m);
+ --gr-button-padding: var(--spacing-s) var(--spacing-m);
}
.headerBottomRow iron-icon {
color: var(--link-color);
@@ -976,22 +969,12 @@
}
override render() {
- // To pass CSS mixins for @apply to Polymer components, they need to appear
- // in <style> inside the template.
- const style = html`<style>
- .headerTopRow .right .goToLatest gr-button {
- --gr-button: {
- padding: var(--spacing-s) var(--spacing-m);
- text-transform: none;
- }
- }
- </style>`;
- const headerClasses = classMap({
+ const headerClasses = {
header: true,
notLatest: !!this.checksPatchsetNumber,
- });
- return html`${style}
- <div class="${headerClasses}">
+ };
+ return html`
+ <div class="${classMap(headerClasses)}">
<div class="headerTopRow">
<div class="left">
<h2 class="heading-2">Results</h2>
@@ -1007,7 +990,9 @@
>
</div>
<gr-dropdown-list
- value="${this.checksPatchsetNumber ?? this.latestPatchsetNumber}"
+ value="${this.checksPatchsetNumber ??
+ this.latestPatchsetNumber ??
+ 0}"
.items="${this.createPatchsetDropdownItems()}"
@value-change="${this.onPatchsetSelected}"
></gr-dropdown-list>
@@ -1023,7 +1008,8 @@
${this.renderSection(Category.WARNING)}
${this.renderSection(Category.INFO)}
${this.renderSection(Category.SUCCESS)}
- </div>`;
+ </div>
+ `;
}
private renderLinksAndActions() {
@@ -1185,11 +1171,8 @@
);
const isSelection = this.selectedRuns.length > 0;
const selected = all.filter(result => this.isRunSelected(result));
- const filtered = selected.filter(
- result =>
- this.filterRegExp.test(result.checkName) ||
- this.filterRegExp.test(result.summary) ||
- this.filterRegExp.test(result.message ?? '')
+ const filtered = selected.filter(result =>
+ matches(result, this.filterRegExp)
);
let expanded = this.isSectionExpanded.get(category);
const expandedByUser = this.isSectionExpandedByUser.get(category) ?? false;
@@ -1298,9 +1281,9 @@
${repeat(
filtered,
result => result.internalResultId,
- result => html`
+ (result?: RunResult) => html`
<gr-result-row
- class="${charsOnly(result.checkName)}"
+ class="${charsOnly(result!.checkName)}"
.result="${result}"
></gr-result-row>
`
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-runs.ts b/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
index d296a46..a643c18 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-runs.ts
@@ -14,9 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import '@polymer/iron-icon/iron-icon';
import {classMap} from 'lit/directives/class-map';
import './gr-hovercard-run';
-import {LitElement, css, html, nothing, PropertyValues} from 'lit';
+import {css, html, LitElement, nothing, PropertyValues} from 'lit';
import {customElement, property, query, state} from 'lit/decorators';
import './gr-checks-attempt';
import {Action, Link, RunStatus} from '../../api/checks';
@@ -24,6 +25,7 @@
import {
AttemptDetail,
compareByWorstCategory,
+ headerForStatus,
iconFor,
iconForRun,
PRIMARY_STATUS_ACTIONS,
@@ -181,28 +183,24 @@
@query('.chip')
chipElement?: HTMLElement;
- @property()
+ @property({attribute: false})
run!: CheckRun;
- @property()
+ @property({attribute: false})
selected = false;
- @property()
+ @property({attribute: false})
selectedAttempt?: number;
- @property()
+ @property({attribute: false})
deselected = false;
- @property()
+ @state()
shouldRender = false;
override firstUpdated() {
assertIsDefined(this.chipElement, 'chip element');
- whenVisible(
- this.chipElement,
- () => this.setAttribute('shouldRender', 'true'),
- 200
- );
+ whenVisible(this.chipElement, () => (this.shouldRender = true), 200);
}
protected override updated(changedProperties: PropertyValues) {
@@ -276,16 +274,20 @@
const checkNameId = charsOnly(this.run.checkName).toLowerCase();
const id = `attempt-${detail.attempt}`;
const icon = detail.icon;
+ const wasNotRun = icon === iconFor(RunStatus.RUNNABLE);
return html`<div class="attemptDetail">
<input
type="radio"
id="${id}"
name="${`${checkNameId}-attempt-choice`}"
?checked="${this.isSelected(detail)}"
+ ?disabled="${!this.isSelected(detail) && wasNotRun}"
@change="${() => this.handleAttemptChange(detail)}"
/>
<iron-icon class="${icon}" icon="gr-icons:${icon}"></iron-icon>
- <label for="${id}">Attempt ${detail.attempt}</label>
+ <label for="${id}">
+ Attempt ${detail.attempt}${wasNotRun ? ' (not run)' : ''}
+ </label>
</div>`;
}
@@ -298,9 +300,6 @@
renderStatusLink() {
const link = this.run.statusLink;
if (!link) return;
- // For COMPLETED we think that the status link are too much clutter.
- // That could be re-considered.
- if (this.run.status !== RunStatus.RUNNING) return;
return html`
<a href="${link}" target="_blank" @click="${this.onLinkClick}"
><iron-icon
@@ -363,29 +362,29 @@
@state()
filterRegExp = new RegExp('');
- @property()
+ @property({attribute: false})
runs: CheckRun[] = [];
@property({type: Boolean, reflect: true})
collapsed = false;
- @property()
+ @property({attribute: false})
selectedRuns: string[] = [];
/** Maps checkName to selected attempt number. `undefined` means `latest`. */
- @property()
+ @property({attribute: false})
selectedAttempts: Map<string, number | undefined> = new Map<
string,
number | undefined
>();
- @property()
+ @property({attribute: false})
tabState?: ChecksTabState;
- @property()
+ @state()
errorMessages: ErrorMessages = {};
- @property()
+ @state()
loginCallback?: () => void;
private isSectionExpanded = new Map<RunStatus, boolean>();
@@ -424,11 +423,11 @@
flex-grow: 1;
}
.title gr-button {
- --padding: var(--spacing-s) var(--spacing-m);
+ --gr-button-padding: var(--spacing-s) var(--spacing-m);
white-space: nowrap;
}
.title gr-button.expandButton {
- --padding: var(--spacing-xs) var(--spacing-s);
+ --gr-button-padding: var(--spacing-xs) var(--spacing-s);
}
:host(:not([collapsed])) .expandButton {
margin-right: calc(0px - var(--spacing-m));
@@ -470,6 +469,11 @@
.testing:hover * {
visibility: visible;
}
+ .zero {
+ padding: var(--spacing-m) 0;
+ color: var(--primary-text-color);
+ margin-top: var(--spacing-m);
+ }
.login,
.error {
padding: var(--spacing-m);
@@ -529,7 +533,7 @@
<div class="flex-space"></div>
${this.renderTitleButtons()} ${this.renderCollapseButton()}
</h2>
- ${this.renderErrors()} ${this.renderSignIn()}
+ ${this.renderErrors()} ${this.renderSignIn()} ${this.renderZeroState()}
<input
id="filterInput"
type="text"
@@ -543,6 +547,11 @@
`;
}
+ private renderZeroState() {
+ if (this.runs.length > 0) return;
+ return html`<div class="zero">No Check Run to show</div>`;
+ }
+
private renderErrors() {
return Object.entries(this.errorMessages).map(
([plugin, message]) =>
@@ -599,42 +608,48 @@
@click="${() => fireRunSelectionReset(this)}"
>Unselect All</gr-button
>
- <gr-button
- class="font-normal"
- link
+ <gr-tooltip-content
title="${runButtonDisabled
? 'Disabled. Unselect checks without a "Run" action to enable the button.'
: ''}"
- has-tooltip="${runButtonDisabled}"
- ?disabled="${runButtonDisabled}"
- @click="${() => {
- actions.forEach(action => this.checksService.triggerAction(action));
- }}"
- >Run Selected</gr-button
+ ?has-tooltip=${runButtonDisabled}
>
+ <gr-button
+ class="font-normal"
+ link
+ ?disabled=${runButtonDisabled}
+ @click="${() => {
+ actions.forEach(action => this.checksService.triggerAction(action));
+ }}"
+ >Run Selected</gr-button
+ >
+ </gr-tooltip-content>
`;
}
private renderCollapseButton() {
return html`
- <gr-button
- link
- class="expandButton"
- role="switch"
- ?aria-checked="${this.collapsed}"
- aria-label="${this.collapsed
- ? 'Expand runs panel'
- : 'Collapse runs panel'}"
- has-tooltip="true"
+ <gr-tooltip-content
+ has-tooltip
title="${this.collapsed ? 'Expand runs panel' : 'Collapse runs panel'}"
- @click="${() => (this.collapsed = !this.collapsed)}"
- ><iron-icon
- class="expandIcon"
- icon="${this.collapsed
- ? 'gr-icons:chevron-right'
- : 'gr-icons:chevron-left'}"
- ></iron-icon>
- </gr-button>
+ >
+ <gr-button
+ link
+ class="expandButton"
+ role="switch"
+ aria-checked="${this.collapsed ? 'true' : 'false'}"
+ aria-label="${this.collapsed
+ ? 'Expand runs panel'
+ : 'Collapse runs panel'}"
+ @click="${() => (this.collapsed = !this.collapsed)}"
+ ><iron-icon
+ class="expandIcon"
+ icon="${this.collapsed
+ ? 'gr-icons:chevron-right'
+ : 'gr-icons:chevron-left'}"
+ ></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>
`;
}
@@ -698,7 +713,7 @@
@click="${() => this.toggleExpanded(status)}"
>
<iron-icon class="expandIcon" icon="${icon}"></iron-icon>
- <h3 class="heading-3">${status.toLowerCase()}</h3>
+ <h3 class="heading-3">${headerForStatus(status)}</h3>
</div>
<div class="sectionRuns">${runs.map(run => this.renderRun(run))}</div>
</div>
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
index 688667a..ed6117a 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-tab.ts
@@ -40,22 +40,22 @@
*/
@customElement('gr-checks-tab')
export class GrChecksTab extends LitElement {
- @property()
+ @state()
runs: CheckRun[] = [];
- @property()
+ @state()
results: CheckResult[] = [];
- @property()
+ @property({type: Object})
tabState?: ChecksTabState;
- @property()
+ @state()
checksPatchsetNumber: PatchSetNumber | undefined = undefined;
- @property()
+ @state()
latestPatchsetNumber: PatchSetNumber | undefined = undefined;
- @property()
+ @state()
changeNum: NumericChangeId | undefined = undefined;
@state()
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-util.ts b/polygerrit-ui/app/elements/checks/gr-checks-util.ts
index 05a87a4..e9bbb22 100644
--- a/polygerrit-ui/app/elements/checks/gr-checks-util.ts
+++ b/polygerrit-ui/app/elements/checks/gr-checks-util.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {CheckRun} from '../../services/checks/checks-model';
+import {CheckRun, RunResult} from '../../services/checks/checks-model';
export interface AttemptSelectedEventDetail {
checkName: string;
@@ -85,3 +85,12 @@
(selected === undefined && run.isLatestAttempt) || selected === run.attempt
);
}
+
+export function matches(result: RunResult, regExp: RegExp) {
+ return (
+ regExp.test(result.checkName) ||
+ regExp.test(result.summary) ||
+ (result.tags ?? []).some(tag => regExp.test(tag.name)) ||
+ regExp.test(result.message ?? '')
+ );
+}
diff --git a/polygerrit-ui/app/elements/checks/gr-checks-util_test.ts b/polygerrit-ui/app/elements/checks/gr-checks-util_test.ts
new file mode 100644
index 0000000..698a4a1
--- /dev/null
+++ b/polygerrit-ui/app/elements/checks/gr-checks-util_test.ts
@@ -0,0 +1,34 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import '../../test/common-test-setup-karma';
+import {createRunResult} from '../../test/test-data-generators';
+import {matches} from './gr-checks-util';
+import {RunResult} from '../../services/checks/checks-model';
+
+suite('gr-checks-util test', () => {
+ test('regexp filter matching results', () => {
+ const result: RunResult = {
+ ...createRunResult(),
+ tags: [{name: 'tag'}],
+ };
+ assert.isTrue(matches(result, new RegExp('message')));
+ assert.isTrue(matches(result, new RegExp('summary')));
+ assert.isTrue(matches(result, new RegExp('name')));
+ assert.isTrue(matches(result, new RegExp('tag')));
+ assert.isFalse(matches(result, new RegExp('qwertyui')));
+ });
+});
diff --git a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
index 0dbe823a..eb55177 100644
--- a/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
+++ b/polygerrit-ui/app/elements/core/gr-account-dropdown/gr-account-dropdown.ts
@@ -76,12 +76,13 @@
super.disconnectedCallback();
}
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
gr-dropdown {
padding: 0 var(--spacing-m);
+ --gr-button-text-color: var(--header-text-color);
}
gr-avatar {
height: 2em;
@@ -92,15 +93,13 @@
];
}
- render() {
+ override render() {
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
gr-dropdown {
- --gr-button: {
- color: var(--header-text-color);
- }
--gr-dropdown-item: {
color: var(--primary-text-color);
}
diff --git a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
index 2dec8d2..c51988e 100644
--- a/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-error-dialog/gr-error-dialog_test.ts
@@ -26,15 +26,16 @@
suite('gr-error-dialog tests', () => {
let element: GrErrorDialog;
- setup(() => {
+ setup(async () => {
element = basicFixture.instantiate();
+ await flush();
});
test('dismiss tap fires event', async () => {
const dismissCalled = mockPromise();
element.addEventListener('dismiss', () => dismissCalled.resolve());
MockInteractions.tap(
- (queryAndAssert(element, '#dialog') as GrDialog).$.confirm
+ (queryAndAssert(element, '#dialog') as GrDialog).confirmButton!
);
await dismissCalled;
});
diff --git a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
index 0b191f1..541d877 100644
--- a/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
+++ b/polygerrit-ui/app/elements/core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.ts
@@ -27,6 +27,7 @@
SectionView,
} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {property, customElement} from '@polymer/decorators';
+import {appContext} from '../../../services/app-context';
declare global {
interface HTMLElementTagNameMap {
@@ -60,13 +61,14 @@
@property({type: Array})
_right?: SectionShortcut[];
- private keyboardShortcutDirectoryListener: ShortcutListener;
+ private readonly shortcutListener: ShortcutListener;
+
+ private readonly shortcuts = appContext.shortcutsService;
constructor() {
super();
- this.keyboardShortcutDirectoryListener = (
- d?: Map<ShortcutSection, SectionView>
- ) => this._onDirectoryUpdated(d);
+ this.shortcutListener = (d?: Map<ShortcutSection, SectionView>) =>
+ this._onDirectoryUpdated(d);
}
override ready() {
@@ -76,15 +78,11 @@
override connectedCallback() {
super.connectedCallback();
- this.addKeyboardShortcutDirectoryListener(
- this.keyboardShortcutDirectoryListener
- );
+ this.shortcuts.addListener(this.shortcutListener);
}
override disconnectedCallback() {
- this.removeKeyboardShortcutDirectoryListener(
- this.keyboardShortcutDirectoryListener
- );
+ this.shortcuts.removeListener(this.shortcutListener);
super.disconnectedCallback();
}
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 4a6f009..f0cff85 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -177,8 +177,8 @@
CHANGE_ID_QUERY: /^\/id\/(I[0-9a-f]{40})$/,
- // Matches /c/<changeNum>/[<basePatchNum>..][<patchNum>][/].
- CHANGE_LEGACY: /^\/c\/(\d+)\/?(((-?\d+|edit)(\.\.(\d+|edit))?))?\/?$/,
+ // Matches /c/<changeNum>/[*][/].
+ CHANGE_LEGACY: /^\/c\/(\d+)\/?(.*)$/,
CHANGE_NUMBER_LEGACY: /^\/(\d+)\/?/,
// Matches
@@ -210,10 +210,6 @@
// Matches /c/<project>/+/<changeNum>/[<patchNum|edit>]/<path>,edit[#lineNum]
DIFF_EDIT: /^\/c\/(.+)\/\+\/(\d+)\/(\d+|edit)\/(.+),edit(#\d+)?$/,
- // Matches non-project-relative
- // /c/<changeNum>/[<basePatchNum>..]<patchNum>/<path>.
- DIFF_LEGACY: /^\/c\/(\d+)\/((-?\d+|edit)(\.\.(\d+|edit))?)\/(.+)/,
-
// Matches diff routes using @\d+ to specify a file name (whether or not
// the project name is included).
// eslint-disable-next-line max-len
@@ -287,15 +283,6 @@
type QueryStringItem = [string, string]; // [key, value]
-type GenerateUrlLegacyChangeViewParameters = Omit<
- GenerateUrlChangeViewParameters,
- 'project'
->;
-type GenerateUrlLegacyDiffViewParameters = Omit<
- GenerateUrlDiffViewParameters,
- 'project'
->;
-
interface PatchRangeParams {
patchNum?: PatchSetNum;
basePatchNum?: BasePatchSetNum;
@@ -679,37 +666,6 @@
}
/**
- * Given a set of params without a project, gets the project from the rest
- * API project lookup and then sets the app params.
- */
- _normalizeLegacyRouteParams(
- params: Readonly<
- | GenerateUrlLegacyChangeViewParameters
- | GenerateUrlLegacyDiffViewParameters
- >
- ) {
- if (!params.changeNum) {
- return Promise.resolve();
- }
-
- return this.restApiService
- .getFromProjectLookup(params.changeNum)
- .then(project => {
- // Show a 404 and terminate if the lookup request failed. Attempting
- // to redirect after failing to get the project loops infinitely.
- if (!project) {
- this._show404();
- return;
- }
- const updatedParams:
- | GenerateUrlChangeViewParameters
- | GenerateUrlDiffViewParameters = {...params, project};
- this._normalizePatchRangeParams(updatedParams);
- this._redirect(this._generateUrl(updatedParams));
- });
- }
-
- /**
* Normalizes the params object, and determines if the URL needs to be
* modified to fit the proper schema.
*
@@ -1100,8 +1056,6 @@
this._mapRoute(RoutePattern.CHANGE_LEGACY, '_handleChangeLegacyRoute');
- this._mapRoute(RoutePattern.DIFF_LEGACY, '_handleDiffLegacyRoute');
-
this._mapRoute(RoutePattern.AGREEMENTS, '_handleAgreementsRoute', true);
this._mapRoute(
@@ -1666,41 +1620,26 @@
}
_handleChangeLegacyRoute(ctx: PageContextWithQueryMap) {
- // Parameter order is based on the regex group number matched.
- const params: GenerateUrlLegacyChangeViewParameters = {
- changeNum: Number(ctx.params[0]) as NumericChangeId,
- basePatchNum: convertToPatchSetNum(ctx.params[3]) as BasePatchSetNum,
- patchNum: convertToPatchSetNum(ctx.params[5]),
- view: GerritView.CHANGE,
- querystring: ctx.querystring,
- };
-
- this._normalizeLegacyRouteParams(params);
+ const changeNum = Number(ctx.params[0]) as NumericChangeId;
+ if (!changeNum) {
+ this._show404();
+ return;
+ }
+ this.restApiService.getFromProjectLookup(changeNum).then(project => {
+ // Show a 404 and terminate if the lookup request failed. Attempting
+ // to redirect after failing to get the project loops infinitely.
+ if (!project) {
+ this._show404();
+ return;
+ }
+ this._redirect(`/c/${project}/+/${changeNum}/${ctx.params[1]}`);
+ });
}
_handleLegacyLinenum(ctx: PageContextWithQueryMap) {
this._redirect(ctx.path.replace(LEGACY_LINENUM_PATTERN, '#$1'));
}
- _handleDiffLegacyRoute(ctx: PageContextWithQueryMap) {
- // Parameter order is based on the regex group number matched.
- const params: GenerateUrlLegacyDiffViewParameters = {
- changeNum: Number(ctx.params[0]) as NumericChangeId,
- basePatchNum: convertToPatchSetNum(ctx.params[2]) as BasePatchSetNum,
- patchNum: convertToPatchSetNum(ctx.params[4]),
- path: ctx.params[5],
- view: GerritView.DIFF,
- };
-
- const address = this._parseLineAddress(ctx.hash);
- if (address) {
- params.leftSide = address.leftSide;
- params.lineNum = address.lineNum;
- }
-
- this._normalizeLegacyRouteParams(params);
- }
-
_handleDiffEditRoute(ctx: PageContextWithQueryMap) {
// Parameter order is based on the regex group number matched.
const project = ctx.params[0] as RepoName;
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
index 4c7855b..b91bf0c 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.js
@@ -192,7 +192,6 @@
'_handleDiffRoute',
'_handleDefaultRoute',
'_handleChangeLegacyRoute',
- '_handleDiffLegacyRoute',
'_handleDocumentationRedirectRoute',
'_handleDocumentationSearchRoute',
'_handleDocumentationSearchRedirectRoute',
@@ -536,66 +535,6 @@
});
suite('param normalization', () => {
- let projectLookupStub;
- let generateUrlStub;
-
- setup(() => {
- projectLookupStub = stubRestApi('getFromProjectLookup');
- generateUrlStub = sinon.stub(element, '_generateUrl');
- });
-
- suite('_normalizeLegacyRouteParams', () => {
- let rangeStub;
- let redirectStub;
- let show404Stub;
-
- setup(() => {
- rangeStub = sinon.stub(element, '_normalizePatchRangeParams')
- .returns(Promise.resolve());
- redirectStub = sinon.stub(element, '_redirect');
- show404Stub = sinon.stub(element, '_show404');
- });
-
- test('w/o changeNum', () => {
- projectLookupStub.returns(Promise.resolve('foo/bar'));
- const params = {};
- return element._normalizeLegacyRouteParams(params).then(() => {
- assert.isFalse(generateUrlStub.calledOnce);
- assert.isFalse(projectLookupStub.called);
- assert.isFalse(rangeStub.called);
- assert.isFalse(redirectStub.called);
- assert.isFalse(show404Stub.called);
- });
- });
-
- test('w/ changeNum', () => {
- projectLookupStub.returns(Promise.resolve('foo/bar'));
- const params = {changeNum: 1234};
-
- return element._normalizeLegacyRouteParams(params).then(() => {
- assert.isTrue(generateUrlStub.calledOnce);
- const updatedParams = generateUrlStub.lastCall.args[0];
- assert.isTrue(projectLookupStub.called);
- assert.isTrue(rangeStub.called);
- assert.equal(updatedParams.project, 'foo/bar');
- assert.isTrue(redirectStub.calledOnce);
- assert.isFalse(show404Stub.called);
- });
- });
-
- test('halts on project lookup failure', () => {
- projectLookupStub.returns(Promise.resolve(undefined));
- const params = {changeNum: 1234};
- return element._normalizeLegacyRouteParams(params).then(() => {
- assert.isFalse(generateUrlStub.calledOnce);
- assert.isTrue(projectLookupStub.called);
- assert.isFalse(rangeStub.called);
- assert.isFalse(redirectStub.called);
- assert.isTrue(show404Stub.calledOnce);
- });
- });
- });
-
suite('_normalizePatchRangeParams', () => {
test('range n..n normalizes to n', () => {
const params = {basePatchNum: 4, patchNum: 4};
@@ -1367,58 +1306,19 @@
assert.isTrue(redirectStub.calledWithExactly('/c/12345'));
});
- test('_handleChangeLegacyRoute', () => {
- const normalizeRouteStub = sinon.stub(element,
- '_normalizeLegacyRouteParams');
+ test('_handleChangeLegacyRoute', async () => {
+ stubRestApi('getFromProjectLookup').returns(Promise.resolve('project'));
const ctx = {
params: [
1234, // 0 Change number
- null, // 1 Unused
- null, // 2 Unused
- 6, // 3 Base patch number
- null, // 4 Unused
- 9, // 5 Patch number
+ 'comment/6789',
],
querystring: '',
};
element._handleChangeLegacyRoute(ctx);
- assert.isTrue(normalizeRouteStub.calledOnce);
- assert.deepEqual(normalizeRouteStub.lastCall.args[0], {
- changeNum: 1234,
- basePatchNum: 6,
- patchNum: 9,
- view: GerritView.CHANGE,
- querystring: '',
- });
- });
-
- test('_handleDiffLegacyRoute', () => {
- const normalizeRouteStub = sinon.stub(element,
- '_normalizeLegacyRouteParams');
- const ctx = {
- params: [
- 1234, // 0 Change number
- null, // 1 Unused
- 3, // 2 Base patch number
- null, // 3 Unused
- 8, // 4 Patch number
- 'foo/bar', // 5 Diff path
- ],
- path: '/c/1234/3..8/foo/bar',
- hash: 'b123',
- };
- element._handleDiffLegacyRoute(ctx);
- assert.isFalse(redirectStub.called);
- assert.isTrue(normalizeRouteStub.calledOnce);
- assert.deepEqual(normalizeRouteStub.lastCall.args[0], {
- changeNum: 1234,
- basePatchNum: 3,
- patchNum: 8,
- view: GerritView.DIFF,
- path: 'foo/bar',
- lineNum: 123,
- leftSide: true,
- });
+ await flush();
+ assert.isTrue(redirectStub.calledWithExactly('/c/project/+/1234' +
+ '/comment/6789'));
});
test('_handleLegacyLinenum w/ @321', () => {
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
index 2dc737e..78c1ebd 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar.ts
@@ -31,10 +31,9 @@
GrAutocomplete,
} from '../../shared/gr-autocomplete/gr-autocomplete';
import {getDocsBaseUrl} from '../../../utils/url-util';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {MergeabilityComputationBehavior} from '../../../constants/constants';
import {appContext} from '../../../services/app-context';
-import {getKeyboardEvent} from '../../../utils/dom-util';
// Possible static search options for auto complete, without negations.
const SEARCH_OPERATORS: ReadonlyArray<string> = [
@@ -67,6 +66,7 @@
'footer:',
'from:',
'has:',
+ 'has:attention',
'has:draft',
'has:edit',
'has:star',
@@ -77,6 +77,7 @@
'is:',
'is:abandoned',
'is:assigned',
+ 'is:attention',
'is:cherrypick',
'is:closed',
'is:ignored',
@@ -197,12 +198,14 @@
private readonly restApiService = appContext.restApiService;
+ private readonly shortcuts = appContext.shortcutsService;
+
constructor() {
super();
this.query = (input: string) => this._getSearchSuggestions(input);
}
- connectedCallback() {
+ override connectedCallback() {
super.connectedCallback();
this.restApiService.getConfig().then((serverConfig?: ServerInfo) => {
const mergeability =
@@ -394,10 +397,10 @@
});
}
- _handleSearch(e: CustomKeyboardEvent) {
- const keyboardEvent = getKeyboardEvent(e);
+ _handleSearch(e: IronKeyboardEvent) {
+ const keyboardEvent = e.detail.keyboardEvent;
if (
- this.shouldSuppressKeyboardShortcut(e) ||
+ this.shortcuts.shouldSuppress(e) ||
(this.modifierPressed(e) && !keyboardEvent.shiftKey)
) {
return;
diff --git a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.ts b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.ts
index b5b0124..b6d0579 100644
--- a/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-search-bar/gr-search-bar_test.ts
@@ -19,12 +19,7 @@
import './gr-search-bar';
import '../../../scripts/util';
import {GrSearchBar} from './gr-search-bar';
-import {
- TestKeyboardShortcutBinder,
- stubRestApi,
- mockPromise,
-} from '../../../test/test-utils';
-import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
+import {stubRestApi, mockPromise} from '../../../test/test-utils';
import {_testOnly_clearDocsBaseUrlCache} from '../../../utils/url-util';
import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
import {
@@ -39,15 +34,6 @@
suite('gr-search-bar tests', () => {
let element: GrSearchBar;
- suiteSetup(() => {
- const kb = TestKeyboardShortcutBinder.push();
- kb.bindShortcut(Shortcut.SEARCH, '/');
- });
-
- suiteTeardown(() => {
- TestKeyboardShortcutBinder.pop();
- });
-
setup(async () => {
element = basicFixture.instantiate();
await flush();
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
index 1908df0..f5072b9 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts
@@ -38,9 +38,10 @@
import {OpenFixPreviewEvent} from '../../../types/events';
import {appContext} from '../../../services/app-context';
import {fireCloseFixPreview, fireEvent} from '../../../utils/event-util';
-import {ParsedChangeInfo} from '../../../types/types';
+import {DiffLayer, ParsedChangeInfo} from '../../../types/types';
import {GrButton} from '../../shared/gr-button/gr-button';
import {TokenHighlightLayer} from '../gr-diff-builder/token-highlight-layer';
+import {KnownExperimentId} from '../../../services/flags/flags';
export interface GrApplyFixDialog {
$: {
@@ -98,12 +99,25 @@
})
_disableApplyFixButton = false;
- layers = [new TokenHighlightLayer(this)];
+ @property({type: Array})
+ layers: DiffLayer[] = [];
private refitOverlay?: () => void;
private readonly restApiService = appContext.restApiService;
+ constructor() {
+ super();
+ this.restApiService.getPreferences().then(prefs => {
+ if (
+ !prefs?.disable_token_highlighting &&
+ appContext.flagsService.isEnabled(KnownExperimentId.TOKEN_HIGHLIGHTING)
+ ) {
+ this.layers = [new TokenHighlightLayer(this)];
+ }
+ });
+ }
+
/**
* Given robot comment CustomEvent object, fetch diffs associated
* with first robot comment suggested fix and open dialog.
@@ -136,7 +150,7 @@
});
}
- connectedCallback() {
+ override connectedCallback() {
super.connectedCallback();
this.refitOverlay = () => {
// re-center the dialog as content changed
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts
index d3d7615..94d37f5 100644
--- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts
+++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts
@@ -186,6 +186,7 @@
})
);
element._isApplyFixLoading = true;
+ await flush();
const button = getConfirmButton();
assert.isTrue(button.hasAttribute('disabled'));
assert.equal(button.getAttribute('title'), '');
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
index 294a78e..663ee7e 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/gr-diff-builder.ts
@@ -572,6 +572,7 @@
lineLimit: number
): HTMLElement {
const contentText = this._createElement('div', 'contentText');
+ contentText.ariaLabel = text;
const responsive = isResponsive(responsiveMode);
let columnPos = 0;
let textOffset = 0;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer.ts
index 4cc98d0a..de7d007 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer.ts
@@ -15,9 +15,17 @@
* limitations under the License.
*/
import {DiffLayer, DiffLayerListener} from '../../../types/types';
-import {GrDiffLine, Side} from '../../../api/diff';
+import {GrDiffLine, Side, TokenHighlightListener} from '../../../api/diff';
+import {assertIsDefined} from '../../../utils/common-util';
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation';
import {debounce, DelayedTask} from '../../../utils/async-util';
+
+import {
+ getLineElByChild,
+ getSideByLineEl,
+ getPreviousContentNodes,
+} from '../gr-diff/gr-diff-utils';
+
import {
getLineNumberByChild,
lineNumberToNumber,
@@ -65,6 +73,9 @@
/** The currently highlighted token. */
private currentHighlight?: string;
+ /** Trigger when a new token starts or stoped being highlighted.*/
+ private readonly tokenHighlightListener?: TokenHighlightListener;
+
/**
* The line of the currently highlighted token. We store this in order to
* re-render only relevant lines of the diff. Only lines visible on the screen
@@ -95,7 +106,11 @@
private updateTokenTask?: DelayedTask;
- constructor(container: HTMLElement = document.documentElement) {
+ constructor(
+ container: HTMLElement = document.documentElement,
+ tokenHighlightListener?: TokenHighlightListener
+ ) {
+ this.tokenHighlightListener = tokenHighlightListener;
container.addEventListener('click', e => {
this.handleContainerClick(e);
});
@@ -188,7 +203,7 @@
this.updateTokenTask = debounce(
this.updateTokenTask,
() => {
- this.updateTokenHighlight(newHighlight, line);
+ this.updateTokenHighlight(newHighlight, line, element);
},
HOVER_DELAY_MS
);
@@ -203,11 +218,11 @@
if (element) return;
this.hoveredElement = undefined;
this.updateTokenTask?.cancel();
- this.updateTokenHighlight(undefined, 0);
+ this.updateTokenHighlight(undefined, 0, undefined);
}
private interferesWithSelection() {
- return window.getSelection()?.type === 'Range';
+ return document.getSelection()?.type === 'Range';
}
findTokenAncestor(el?: EventTarget | Element | null): {
@@ -241,7 +256,8 @@
private updateTokenHighlight(
newHighlight: string | undefined,
- newLineNumber: number
+ newLineNumber: number,
+ newHoveredElement: Element | undefined
) {
if (
this.currentHighlight === newHighlight &&
@@ -252,11 +268,42 @@
const oldLineNumber = this.currentHighlightLineNumber;
this.currentHighlight = newHighlight;
this.currentHighlightLineNumber = newLineNumber;
-
+ this.triggerTokenHighlightEvent(
+ newHighlight,
+ newLineNumber,
+ newHoveredElement
+ );
this.notifyForToken(oldHighlight, oldLineNumber);
this.notifyForToken(newHighlight, newLineNumber);
}
+ triggerTokenHighlightEvent(
+ token: string | undefined,
+ line: number,
+ element: Element | undefined
+ ) {
+ if (!this.tokenHighlightListener) {
+ return;
+ }
+ if (!token || !element) {
+ this.tokenHighlightListener(undefined);
+ return;
+ }
+ const previousTextLength = getPreviousContentNodes(element)
+ .map(sib => sib.textContent!.length)
+ .reduce((partial_sum, a) => partial_sum + a, 0);
+ const lineEl = getLineElByChild(element);
+ assertIsDefined(lineEl, 'Line element should be found!');
+ const side = getSideByLineEl(lineEl);
+ const range = {
+ start_line: line,
+ start_column: previousTextLength + 1, // 1-based inclusive
+ end_line: line,
+ end_column: previousTextLength + token.length, // 1-based inclusive
+ };
+ this.tokenHighlightListener({token, element, side, range});
+ }
+
getSortedLinesForSide(
lineMapping: Map<string, Set<number>>,
token: string | undefined,
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer_test.ts b/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer_test.ts
index d606e01..2993d35 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer_test.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-builder/token-highlight-layer_test.ts
@@ -17,12 +17,11 @@
import '../../../test/common-test-setup-karma';
import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
-import {Side} from '../../../api/diff';
+import {Side, TokenHighlightEventDetails} from '../../../api/diff';
import {GrDiffLine, GrDiffLineType} from '../gr-diff/gr-diff-line.js';
import {HOVER_DELAY_MS, TokenHighlightLayer} from './token-highlight-layer';
import {GrAnnotation} from '../gr-diff-highlight/gr-annotation';
-import sinon from 'sinon/pkg/sinon-esm';
-import {html, render} from 'lit-html';
+import {html, render} from 'lit';
import {_testOnly_allTasks} from '../../../utils/async-util';
import {queryAndAssert} from '../../../test/test-utils';
@@ -67,12 +66,20 @@
let container: HTMLElement;
let listener: MockListener;
let highlighter: TokenHighlightLayer;
+ let tokenHighlightingCalls: {details?: TokenHighlightEventDetails}[] = [];
+
+ function tokenHighlightListener(
+ highlightDetails?: TokenHighlightEventDetails
+ ) {
+ tokenHighlightingCalls.push({details: highlightDetails});
+ }
setup(async () => {
listener = new MockListener();
+ tokenHighlightingCalls = [];
container = document.createElement('div');
document.body.appendChild(container);
- highlighter = new TokenHighlightLayer(container);
+ highlighter = new TokenHighlightLayer(container, tokenHighlightListener);
highlighter.addListener((...args) => listener.notify(...args));
});
@@ -98,10 +105,13 @@
const lineId = createLineId();
const template = html`
<div class="line">
- <div data-value=${line} class="lineNum"></div>
- <div id=${lineId} class="line-content">${text}</div>
+ <div data-value=${line} class="lineNum right"></div>
+ <div class="content">
+ <div id=${lineId} class="contentText">${text}</div>
+ </div>
</div>
`;
+
const div = document.createElement('div');
render(template, div);
container.appendChild(div);
@@ -252,6 +262,34 @@
assert.equal(_testOnly_allTasks.size, 0);
});
+ test('triggers listener for applying and clearing highlighting', async () => {
+ const clock = sinon.useFakeTimers();
+ const line1 = createLine('two words');
+ annotate(line1);
+ const line2 = createLine('three words', 2);
+ annotate(line2, Side.RIGHT, 2);
+ const words1 = queryAndAssert(line1, '.tk-words');
+ assert.isTrue(words1.classList.contains('token'));
+ dispatchMouseEvent(
+ 'mouseover',
+ MockInteractions.middleOfNode(words1),
+ words1
+ );
+ assert.equal(tokenHighlightingCalls.length, 0);
+ clock.tick(HOVER_DELAY_MS);
+ assert.equal(tokenHighlightingCalls.length, 1);
+ assert.deepEqual(tokenHighlightingCalls[0].details, {
+ token: 'words',
+ side: Side.RIGHT,
+ element: words1,
+ range: {start_line: 1, start_column: 5, end_line: 1, end_column: 9},
+ });
+
+ MockInteractions.click(container);
+ assert.equal(tokenHighlightingCalls.length, 2);
+ assert.deepEqual(tokenHighlightingCalls[1].details, undefined);
+ });
+
test('clicking clears highlight', async () => {
const clock = sinon.useFakeTimers();
const line1 = createLine('two words');
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-annotation.ts b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-annotation.ts
index 5e81871..79e7dbc 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-annotation.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-annotation.ts
@@ -134,7 +134,7 @@
if (node instanceof Text) {
this._annotateText(node, offset, subLength, cssClass);
- } else if (node instanceof HTMLElement) {
+ } else if (node instanceof Element) {
this.annotateElement(node, offset, subLength, cssClass);
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
index 18fbe9a..4c1295f 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight_test.js
@@ -251,7 +251,7 @@
};
const emulateSelection = (startNode, startOffset, endNode, endOffset) => {
- const selection = window.getSelection();
+ const selection = document.getSelection();
const range = document.createRange();
range.setStart(startNode, startOffset);
range.setEnd(endNode, endOffset);
@@ -281,7 +281,7 @@
teardown(() => {
contentStubs = null;
- window.getSelection().removeAllRanges();
+ document.getSelection().removeAllRanges();
});
test('single first line', () => {
@@ -389,7 +389,7 @@
test('collapsed', () => {
const content = stubContent(138, 'left');
emulateSelection(content.firstChild, 5, content.firstChild, 5);
- assert.isOk(window.getSelection().getRangeAt(0).startContainer);
+ assert.isOk(document.getSelection().getRangeAt(0).startContainer);
assert.isFalse(!!element.selectedRange);
});
@@ -556,7 +556,7 @@
content.querySelectorAll('hl')[3], 0,
content.querySelectorAll('span')[1], 0);
const spyCall = spy.getCall(0);
- const range = window.getSelection().getRangeAt(0);
+ const range = document.getSelection().getRangeAt(0);
assert.notDeepEqual(spyCall.returnValue, range);
});
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
index fa3ddf4..4641897 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts
@@ -327,18 +327,21 @@
super.disconnectedCallback();
}
- initLayers() {
- return getPluginLoader()
- .awaitPluginsLoaded()
- .then(() => {
- assertIsDefined(this.path, 'path');
- this._layers = this._getLayers(this.path);
- this._coverageRanges = [];
- // We kick off fetching the data here, but we don't return the promise,
- // so awaiting initLayers() will not wait for coverage data to be
- // completely loaded.
- this._getCoverageData();
- });
+ async initLayers() {
+ const preferencesPromise = appContext.restApiService.getPreferences();
+ await getPluginLoader().awaitPluginsLoaded();
+ const prefs = await preferencesPromise;
+ const enableTokenHighlight =
+ appContext.flagsService.isEnabled(KnownExperimentId.TOKEN_HIGHLIGHTING) &&
+ !prefs?.disable_token_highlighting;
+
+ assertIsDefined(this.path, 'path');
+ this._layers = this.getLayers(this.path, enableTokenHighlight);
+ this._coverageRanges = [];
+ // We kick off fetching the data here, but we don't return the promise,
+ // so awaiting initLayers() will not wait for coverage data to be
+ // completely loaded.
+ this._getCoverageData();
}
diffChanged(diff?: DiffInfo) {
@@ -410,9 +413,11 @@
}
}
- private _getLayers(path: string): DiffLayer[] {
+ private getLayers(path: string, enableTokenHighlight: boolean): DiffLayer[] {
const layers = [];
- layers.push(new TokenHighlightLayer(this));
+ if (enableTokenHighlight) {
+ layers.push(new TokenHighlightLayer(this));
+ }
layers.push(this.syntaxLayer);
// Get layers from plugins (if any).
layers.push(...this.jsAPI.getDiffLayers(path));
@@ -727,7 +732,9 @@
_threadsChanged(threads: CommentThread[]) {
const threadEls = new Set<Object>();
for (const thread of threads) {
- threadEls.add(this._getOrCreateThread(thread));
+ const threadEl = this._createThreadElement(thread);
+ this._attachThreadElement(threadEl);
+ threadEls.add(threadEl);
}
// Remove all threads that are no longer existing.
for (const threadEl of this.getThreadEls()) {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
index b24b3ba..ed3ffe0 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host_test.js
@@ -17,19 +17,16 @@
import '../../../test/common-test-setup-karma.js';
import './gr-diff-host.js';
-import {GrDiffBuilderImage} from '../gr-diff-builder/gr-diff-builder-image.js';
-import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+
import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
-import {Side, createDefaultDiffPrefs} from '../../../constants/constants.js';
-import {createChange} from '../../../test/test-data-generators.js';
-import {CoverageType} from '../../../types/types.js';
-import {
- addListenerForTest,
- mockPromise,
- stubRestApi,
-} from '../../../test/test-utils.js';
-import {EditPatchSetNum, ParentPatchSetNum} from '../../../types/common.js';
+import {createDefaultDiffPrefs, Side} from '../../../constants/constants.js';
import {_testOnly_resetState} from '../../../services/comments/comments-model.js';
+import {createChange, createComment, createCommentThread} from '../../../test/test-data-generators.js';
+import {addListenerForTest, mockPromise, stubRestApi} from '../../../test/test-utils.js';
+import {EditPatchSetNum, ParentPatchSetNum} from '../../../types/common.js';
+import {CoverageType} from '../../../types/types.js';
+import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
+import {GrDiffBuilderImage} from '../gr-diff-builder/gr-diff-builder-image.js';
const basicFixture = fixtureFromElement('gr-diff-host');
@@ -1127,6 +1124,35 @@
assert.equal(threads[0].path, element.file.path);
});
+ test('multiple threads created on the same range', () => {
+ element.patchRange = {
+ basePatchNum: 2,
+ patchNum: 3,
+ };
+ element.file = {basePath: 'file_renamed.txt', path: element.path};
+
+ const comment = createComment();
+ comment.range = {
+ start_line: 1,
+ start_character: 1,
+ end_line: 2,
+ end_character: 2,
+ };
+ const thread = createCommentThread([comment]);
+ element.threads = [thread];
+
+ let threads = dom(element.$.diff)
+ .queryDistributedElements('gr-comment-thread');
+
+ assert.equal(threads.length, 1);
+
+ element.threads= [...element.threads, thread];
+
+ threads = dom(element.$.diff)
+ .queryDistributedElements('gr-comment-thread');
+ assert.equal(threads.length, 2);
+ });
+
test('thread should use new file path if first created' +
'on patch set (left) but is base', () => {
const diffSide = Side.LEFT;
@@ -1143,8 +1169,8 @@
},
}));
- const threads = dom(element.$.diff)
- .queryDistributedElements('gr-comment-thread');
+ const threads =
+ dom(element.$.diff).queryDistributedElements('gr-comment-thread');
assert.equal(threads.length, 1);
assert.equal(threads[0].diffSide, diffSide);
@@ -1167,8 +1193,8 @@
},
}));
- const threads = dom(element.$.diff)
- .queryDistributedElements('gr-comment-thread');
+ const threads =
+ dom(element.$.diff).queryDistributedElements('gr-comment-thread');
assert.equal(threads.length, 0);
assert.isTrue(alertSpy.called);
});
@@ -1270,7 +1296,7 @@
test('gr-diff-host provides syntax highlighting layer', async () => {
stubRestApi('getDiff').returns(Promise.resolve({content: []}));
await element.reload();
- assert.equal(element.$.diff.layers[1], element.syntaxLayer);
+ assert.equal(element.$.diff.layers[0], element.syntaxLayer);
});
test('rendering normal-sized diff does not disable syntax', () => {
@@ -1324,7 +1350,7 @@
test('gr-diff-host provides syntax highlighting layer', async () => {
stubRestApi('getDiff').returns(Promise.resolve({content: []}));
await element.reload();
- assert.equal(element.$.diff.layers[1], element.syntaxLayer);
+ assert.equal(element.$.diff.layers[0], element.syntaxLayer);
});
test('syntax layer should be disabled', () => {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-image-viewer.ts b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-image-viewer.ts
index fbdcb69..3a05e7d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-image-viewer.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-image-viewer/gr-image-viewer.ts
@@ -267,11 +267,11 @@
outline: 1px solid transparent;
border: 1px solid var(--primary-button-background-color);
}
- paper-button[unelevated] {
+ paper-button.unelevated {
color: var(--primary-button-text-color);
background-color: var(--primary-button-background-color);
}
- paper-button[outlined] {
+ paper-button.outlined {
color: var(--primary-button-background-color);
}
#version-switcher {
@@ -422,18 +422,25 @@
/>
`;
- const sourceImageWithHighlight = html`
- <div id="source-plus-highlight-container">
- ${sourceImage}
- <img
- id="highlight-image"
- style="${styleMap({
- opacity: this.showHighlight ? '1' : '0',
- })}"
- src="${this.diffHighlightSrc}"
- />
- </div>
- `;
+ const sourceImageWithHighlight = this.diffHighlightSrc
+ ? html`
+ <div id="source-plus-highlight-container">
+ ${sourceImage}
+ <img
+ id="highlight-image"
+ style="${styleMap({
+ opacity: this.showHighlight ? '1' : '0',
+ // When the highlight layer is not being shown, saving the image or
+ // opening it in a new tab from the context menu, e.g. for external
+ // comparison, should give back the source image, not the highlight
+ // layer.
+ 'pointer-events': this.showHighlight ? 'auto' : 'none',
+ })}"
+ src="${this.diffHighlightSrc}"
+ />
+ </div>
+ `
+ : '';
const versionExplanation = html`
<div id="version-explanation">
@@ -443,12 +450,20 @@
// This uses the unelevated and outlined attributes from mwc-button with
// manual styling, for a more seamless transition later.
+ const leftClasses = {
+ left: true,
+ unelevated: this.baseSelected,
+ outlined: !this.baseSelected,
+ };
+ const rightClasses = {
+ right: true,
+ unelevated: !this.baseSelected,
+ outlined: this.baseSelected,
+ };
const versionToggle = html`
<div id="version-switcher">
<paper-button
- class="left"
- ?unelevated=${this.baseSelected}
- ?outlined=${!this.baseSelected}
+ class="${classMap(leftClasses)}"
@click="${this.selectBase}"
>
Base
@@ -456,9 +471,7 @@
<paper-fab mini icon="gr-icons:swapHoriz" @click="${this.manualBlink}">
</paper-fab>
<paper-button
- class="right"
- ?unelevated=${!this.baseSelected}
- ?outlined=${this.baseSelected}
+ class="${classMap(rightClasses)}"
@click="${this.selectRevision}"
>
Revision
@@ -504,7 +517,7 @@
<paper-listbox
slot="dropdown-content"
selected="fit"
- attr-for-selected="value"
+ .attrForSelected="${'value'}"
@selected-changed="${this.zoomControlChanged}"
>
${this.zoomLevels.map(
@@ -574,6 +587,7 @@
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
paper-item {
@@ -643,7 +657,9 @@
// We don't want property changes in updateSizes() to trigger infinite update
// loops, so we perform this in update() instead of updated().
override update(changedProperties: PropertyValues) {
+ // eslint-disable-next-line lit/no-property-change-update
if (!this.baseUrl) this.baseSelected = false;
+ // eslint-disable-next-line lit/no-property-change-update
if (!this.revisionUrl) this.baseSelected = true;
this.updateSizes();
super.update(changedProperties);
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector_html.ts b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector_html.ts
index 4e2b6a1..8a6d95d 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-mode-selector/gr-diff-mode-selector_html.ts
@@ -30,28 +30,34 @@
width: 1.3rem;
}
</style>
- <gr-button
- id="sideBySideBtn"
- link=""
+ <gr-tooltip-content
has-tooltip=""
- position-below="[[showTooltipBelow]]"
- class$="[[_computeSideBySideSelected(mode)]]"
title="Side-by-side diff"
- aria-pressed$="[[isSideBySideSelected(mode)]]"
- on-click="_handleSideBySideTap"
+ position-below="[[showTooltipBelow]]"
>
- <iron-icon icon="gr-icons:side-by-side"></iron-icon>
- </gr-button>
- <gr-button
- id="unifiedBtn"
- link=""
+ <gr-button
+ id="sideBySideBtn"
+ link=""
+ class$="[[_computeSideBySideSelected(mode)]]"
+ aria-pressed$="[[isSideBySideSelected(mode)]]"
+ on-click="_handleSideBySideTap"
+ >
+ <iron-icon icon="gr-icons:side-by-side"></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>
+ <gr-tooltip-content
has-tooltip=""
position-below="[[showTooltipBelow]]"
title="Unified diff"
- class$="[[_computeUnifiedSelected(mode)]]"
- aria-pressed$="[[isUnifiedSelected(mode)]]"
- on-click="_handleUnifiedTap"
>
- <iron-icon icon="gr-icons:unified"></iron-icon>
- </gr-button>
+ <gr-button
+ id="unifiedBtn"
+ link=""
+ class$="[[_computeUnifiedSelected(mode)]]"
+ aria-pressed$="[[isUnifiedSelected(mode)]]"
+ on-click="_handleUnifiedTap"
+ >
+ <iron-icon icon="gr-icons:unified"></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>
`;
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
index 0051b8b..2665ef0 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection.ts
@@ -195,7 +195,7 @@
_getSelection() {
const diffHosts = querySelectorAll(document.body, 'gr-diff');
- if (!diffHosts.length) return window.getSelection();
+ if (!diffHosts.length) return document.getSelection();
const curDiffHost = diffHosts.find(diffHost => {
if (!diffHost?.shadowRoot?.getSelection) return false;
@@ -205,9 +205,9 @@
return selection && selection.type !== 'None';
});
- return curDiffHost
- ? curDiffHost.shadowRoot!.getSelection()
- : window.getSelection();
+ return curDiffHost?.shadowRoot?.getSelection
+ ? curDiffHost.shadowRoot.getSelection()
+ : document.getSelection();
}
/**
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.js b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.js
index 8d7264c..15454f9 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-selection/gr-diff-selection_test.js
@@ -247,7 +247,7 @@
element.classList.add('selected-left');
element.classList.remove('selected-right');
- const selection = window.getSelection();
+ const selection = document.getSelection();
selection.removeAllRanges();
const range = document.createRange();
range.setStart(element.querySelector('div.contentText').firstChild, 3);
@@ -261,7 +261,7 @@
element.classList.add('selected-left');
element.classList.add('selected-comment');
element.classList.remove('selected-right');
- const selection = window.getSelection();
+ const selection = document.getSelection();
selection.removeAllRanges();
const range = document.createRange();
range.setStart(
@@ -277,7 +277,7 @@
element.classList.add('selected-left');
element.classList.add('selected-comment');
element.classList.remove('selected-right');
- const selection = window.getSelection();
+ const selection = document.getSelection();
selection.removeAllRanges();
const range = document.createRange();
const nodes = element.querySelectorAll('.gr-formatted-text *');
@@ -307,7 +307,7 @@
element.classList.add('selected-right');
element.classList.remove('selected-left');
- const selection = window.getSelection();
+ const selection = document.getSelection();
selection.removeAllRanges();
const range = document.createRange();
range.setStart(
@@ -329,7 +329,7 @@
};
element.classList.add('selected-left');
element.classList.remove('selected-right');
- const selection = window.getSelection();
+ const selection = document.getSelection();
selection.removeAllRanges();
const range = document.createRange();
range.setStart(element.querySelector('div.contentText').firstChild, 3);
@@ -348,7 +348,7 @@
element.classList.add('selected-left');
element.classList.add('selected-comment');
element.classList.remove('selected-right');
- selection = window.getSelection();
+ selection = document.getSelection();
selection.removeAllRanges();
range = document.createRange();
nodes = element.querySelectorAll('.gr-formatted-text *');
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
index b1d71cc..e2baec9 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.ts
@@ -16,6 +16,7 @@
*/
import '@polymer/iron-dropdown/iron-dropdown';
import '@polymer/iron-input/iron-input';
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../../shared/gr-button/gr-button';
import '../../shared/gr-dropdown/gr-dropdown';
@@ -36,6 +37,7 @@
import {
KeyboardShortcutMixin,
Shortcut,
+ ShortcutSection,
} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {
GeneratedWebLink,
@@ -97,14 +99,15 @@
} from '../../../utils/comment-util';
import {AppElementParams} from '../../gr-app-types';
import {
- CustomKeyboardEvent,
+ IronKeyboardEventListener,
+ IronKeyboardEvent,
EventType,
OpenFixPreviewEvent,
} from '../../../types/events';
import {fireAlert, fireEvent, fireTitleChange} from '../../../utils/event-util';
import {GerritView} from '../../../services/router/router-model';
import {assertIsDefined} from '../../../utils/common-util';
-import {toggleClass, getKeyboardEvent} from '../../../utils/dom-util';
+import {toggleClass} from '../../../utils/dom-util';
import {CursorMoveResult} from '../../../api/core';
import {throttleWrap} from '../../../utils/async-util';
import {changeComments$} from '../../../services/comments/comments-model';
@@ -340,7 +343,9 @@
private readonly commentsService = appContext.commentsService;
- _throttledToggleFileReviewed?: EventListener;
+ private readonly shortcuts = appContext.shortcutsService;
+
+ _throttledToggleFileReviewed?: IronKeyboardEventListener;
_onRenderHandler?: EventListener;
@@ -351,7 +356,7 @@
override connectedCallback() {
super.connectedCallback();
this._throttledToggleFileReviewed = throttleWrap(e =>
- this._handleToggleFileReviewed(e as CustomKeyboardEvent)
+ this._handleToggleFileReviewed(e)
);
this._getLoggedIn().then(loggedIn => {
this._loggedIn = loggedIn;
@@ -517,38 +522,38 @@
);
}
- _handleToggleFileReviewed(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleFileReviewed(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
e.preventDefault();
this._setReviewed(!this.$.reviewed.checked);
}
- _handleEscKey(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleEscKey(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
e.preventDefault();
this.$.diffHost.displayLine = false;
}
- _handleLeftPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleLeftPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
e.preventDefault();
this.cursor.moveLeft();
}
- _handleRightPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleRightPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
e.preventDefault();
this.cursor.moveRight();
}
- _handlePrevLineOrFileWithComments(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handlePrevLineOrFileWithComments(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (
e.detail.keyboardEvent?.shiftKey &&
@@ -567,8 +572,8 @@
this.cursor.moveUp();
}
- _handleVisibleLine(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleVisibleLine(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
e.preventDefault();
this.cursor.moveToVisibleArea();
@@ -578,8 +583,8 @@
this.$.applyFixDialog.open(e);
}
- _handleNextLineOrFileWithComments(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleNextLineOrFileWithComments(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (
e.detail.keyboardEvent?.shiftKey &&
@@ -637,39 +642,41 @@
);
}
- _handleNewComment(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
- if (this.modifierPressed(e)) return;
+ _handleNewComment(ike: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(ike)) return;
+ if (this.modifierPressed(ike)) return;
- e.preventDefault();
+ ike.preventDefault();
this.classList.remove('hideComments');
this.cursor.createCommentInPlace();
}
- _handlePrevFile(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handlePrevFile(ike: IronKeyboardEvent) {
+ const ke = ike.detail.keyboardEvent;
+ if (this.shortcuts.shouldSuppress(ike)) return;
// Check for meta key to avoid overriding native chrome shortcut.
- if (getKeyboardEvent(e).metaKey) return;
+ if (ke.metaKey) return;
if (!this._path) return;
if (!this._fileList) return;
- e.preventDefault();
+ ike.preventDefault();
this._navToFile(this._path, this._fileList, -1);
}
- _handleNextFile(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleNextFile(ike: IronKeyboardEvent) {
+ const ke = ike.detail.keyboardEvent;
+ if (this.shortcuts.shouldSuppress(ike)) return;
// Check for meta key to avoid overriding native chrome shortcut.
- if (getKeyboardEvent(e).metaKey) return;
+ if (ke.metaKey) return;
if (!this._path) return;
if (!this._fileList) return;
- e.preventDefault();
+ ike.preventDefault();
this._navToFile(this._path, this._fileList, 1);
}
- _handleNextChunkOrCommentThread(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleNextChunkOrCommentThread(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
e.preventDefault();
if (e.detail.keyboardEvent?.shiftKey) {
@@ -729,8 +736,8 @@
this._navToFile(this._path, unreviewedFiles, direction === 'next' ? 1 : -1);
}
- _handlePrevChunkOrCommentThread(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handlePrevChunkOrCommentThread(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
e.preventDefault();
if (e.detail.keyboardEvent?.shiftKey) {
@@ -745,8 +752,8 @@
}
// Similar to gr-change-view._handleOpenReplyDialog
- _handleOpenReplyDialog(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleOpenReplyDialog(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
this._getLoggedIn().then(isLoggedIn => {
if (!isLoggedIn) {
@@ -760,16 +767,16 @@
});
}
- _handleToggleLeftPane(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleLeftPane(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!e.detail.keyboardEvent?.shiftKey) return;
e.preventDefault();
this.$.diffHost.toggleLeftDiff();
}
- _handleOpenDownloadDialog(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleOpenDownloadDialog(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
this.set('changeViewState.showDownloadDialog', true);
@@ -777,16 +784,16 @@
this._navToChangeView();
}
- _handleUpToChange(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleUpToChange(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
e.preventDefault();
this._navToChangeView();
}
- _handleCommaKey(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleCommaKey(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
if (this._diffPrefsDisabled) return;
@@ -794,8 +801,8 @@
this.$.diffPreferencesDialog.open();
}
- _handleToggleDiffMode(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleDiffMode(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
e.preventDefault();
@@ -1691,28 +1698,28 @@
this._loadBlame();
}
- _handleToggleBlame(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleBlame(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
this._toggleBlame();
}
- _handleToggleHideAllCommentThreads(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleHideAllCommentThreads(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
toggleClass(this, 'hideComments');
}
- _handleOpenFileList(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleOpenFileList(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (this.modifierPressed(e)) return;
this.$.dropdown.open();
}
- _handleDiffAgainstBase(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleDiffAgainstBase(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!this._change) return;
if (!this._path) return;
if (!this._patchRange) return;
@@ -1728,8 +1735,8 @@
);
}
- _handleDiffBaseAgainstLeft(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleDiffBaseAgainstLeft(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!this._change) return;
if (!this._path) return;
if (!this._patchRange) return;
@@ -1749,8 +1756,8 @@
);
}
- _handleDiffAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleDiffAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!this._change) return;
if (!this._path) return;
if (!this._patchRange) return;
@@ -1769,8 +1776,8 @@
);
}
- _handleDiffRightAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleDiffRightAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!this._change) return;
if (!this._path) return;
if (!this._patchRange) return;
@@ -1788,8 +1795,8 @@
);
}
- _handleDiffBaseAgainstLatest(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleDiffBaseAgainstLatest(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
if (!this._change) return;
if (!this._path) return;
if (!this._patchRange) return;
@@ -1826,8 +1833,8 @@
return '';
}
- _handleToggleAllDiffContext(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleToggleAllDiffContext(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
this.$.diffHost.toggleAllContext();
}
@@ -1836,8 +1843,8 @@
return disableDiffPrefs || !loggedIn;
}
- _handleNextUnreviewedFile(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleNextUnreviewedFile(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
this._setReviewed(true);
this.navigateToUnreviewedFile('next');
}
@@ -1897,6 +1904,10 @@
_computeTruncatedPath(path?: string) {
return path ? computeTruncatedPath(path) : '';
}
+
+ createTitle(shortcutName: Shortcut, section: ShortcutSection) {
+ return this.shortcuts.createTitle(shortcutName, section);
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_html.ts b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_html.ts
index 7e0ca10..b25be5a8 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
display: block;
@@ -138,11 +141,6 @@
.separator.hide {
display: none;
}
- gr-dropdown-list {
- --trigger-style: {
- text-transform: none;
- }
- }
.editButtona a {
text-decoration: none;
}
@@ -351,15 +349,15 @@
hidden=""
>
<span class="preferences desktop">
- <gr-button
- link=""
- class="prefsButton"
+ <gr-tooltip-content
has-tooltip=""
position-below=""
title="Diff preferences"
- on-click="_handlePrefsTap"
- ><iron-icon icon="gr-icons:settings"></iron-icon
- ></gr-button>
+ >
+ <gr-button link="" class="prefsButton" on-click="_handlePrefsTap"
+ ><iron-icon icon="gr-icons:settings"></iron-icon
+ ></gr-button>
+ </gr-tooltip-content>
</span>
</span>
<gr-endpoint-decorator name="annotation-toggler">
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
index d9c4ba2..735624a 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.js
@@ -19,8 +19,7 @@
import './gr-diff-view.js';
import {GerritNav} from '../../core/gr-navigation/gr-navigation.js';
import {ChangeStatus} from '../../../constants/constants.js';
-import {TestKeyboardShortcutBinder, stubRestApi} from '../../../test/test-utils.js';
-import {Shortcut} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.js';
+import {stubRestApi} from '../../../test/test-utils.js';
import {ChangeComments} from '../gr-comment-api/gr-comment-api.js';
import {GerritView} from '../../../services/router/router-model.js';
import {
@@ -29,7 +28,6 @@
createComment,
} from '../../../test/test-data-generators.js';
import {EditPatchSetNum} from '../../../types/common.js';
-import sinon from 'sinon/pkg/sinon-esm';
import {CursorMoveResult} from '../../../api/core.js';
const basicFixture = fixtureFromElement('gr-diff-view');
@@ -42,42 +40,6 @@
let clock;
let diffCommentsStub;
- suiteSetup(() => {
- const kb = TestKeyboardShortcutBinder.push();
- kb.bindShortcut(Shortcut.LEFT_PANE, 'shift+left');
- kb.bindShortcut(Shortcut.RIGHT_PANE, 'shift+right');
- kb.bindShortcut(Shortcut.NEXT_LINE, 'j', 'down');
- kb.bindShortcut(Shortcut.PREV_LINE, 'k', 'up');
- kb.bindShortcut(Shortcut.NEXT_FILE_WITH_COMMENTS, 'shift+j');
- kb.bindShortcut(Shortcut.PREV_FILE_WITH_COMMENTS, 'shift+k');
- kb.bindShortcut(Shortcut.NEW_COMMENT, 'c');
- kb.bindShortcut(Shortcut.SAVE_COMMENT, 'ctrl+s');
- kb.bindShortcut(Shortcut.NEXT_FILE, ']');
- kb.bindShortcut(Shortcut.PREV_FILE, '[');
- kb.bindShortcut(Shortcut.NEXT_CHUNK, 'n');
- kb.bindShortcut(Shortcut.NEXT_COMMENT_THREAD, 'shift+n');
- kb.bindShortcut(Shortcut.PREV_CHUNK, 'p');
- kb.bindShortcut(Shortcut.PREV_COMMENT_THREAD, 'shift+p');
- kb.bindShortcut(Shortcut.OPEN_REPLY_DIALOG, 'a');
- kb.bindShortcut(Shortcut.OPEN_DOWNLOAD_DIALOG, 'd');
- kb.bindShortcut(Shortcut.TOGGLE_LEFT_PANE, 'shift+a');
- kb.bindShortcut(Shortcut.UP_TO_CHANGE, 'u');
- kb.bindShortcut(Shortcut.OPEN_DIFF_PREFS, ',');
- kb.bindShortcut(Shortcut.TOGGLE_DIFF_MODE, 'm');
- kb.bindShortcut(Shortcut.TOGGLE_FILE_REVIEWED, 'r');
- kb.bindShortcut(Shortcut.TOGGLE_ALL_DIFF_CONTEXT, 'shift+x');
- kb.bindShortcut(Shortcut.EXPAND_ALL_COMMENT_THREADS, 'e');
- kb.bindShortcut(Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, 'h');
- kb.bindShortcut(Shortcut.COLLAPSE_ALL_COMMENT_THREADS, 'shift+e');
- kb.bindShortcut(Shortcut.NEXT_UNREVIEWED_FILE, 'shift+m');
- kb.bindShortcut(Shortcut.TOGGLE_BLAME, 'b');
- kb.bindShortcut(Shortcut.OPEN_FILE_LIST, 'f');
- });
-
- suiteTeardown(() => {
- TestKeyboardShortcutBinder.pop();
- });
-
const PARENT = 'PARENT';
function getFilesFromFileList(fileList) {
@@ -505,16 +467,16 @@
sinon.stub(element, '_setReviewed');
sinon.spy(element, '_handleToggleFileReviewed');
element.$.reviewed.checked = false;
- MockInteractions.pressAndReleaseKeyOn(element, 82, 'shift', 'r');
+ MockInteractions.keyUpOn(element, 82, 'shift', 'r');
assert.isFalse(element._setReviewed.called);
assert.isTrue(element._handleToggleFileReviewed.calledOnce);
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
assert.isTrue(element._handleToggleFileReviewed.calledOnce);
clock.tick(1000);
- MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
+ MockInteractions.keyUpOn(element, 82, null, 'r');
assert.isTrue(element._handleToggleFileReviewed.calledTwice);
assert.isTrue(element._setReviewed.called);
assert.equal(element._setReviewed.lastCall.args[0], true);
@@ -574,7 +536,6 @@
basePatchNum: 5,
patchNum: 10,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffAgainstBase(new CustomEvent(''));
const args = diffNavStub.getCall(0).args;
@@ -591,7 +552,6 @@
basePatchNum: 5,
patchNum: 10,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffAgainstLatest(new CustomEvent(''));
const args = diffNavStub.getCall(0).args;
@@ -609,7 +569,6 @@
basePatchNum: 1,
};
element.params = {};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffBaseAgainstLeft(new CustomEvent(''));
assert(diffNavStub.called);
@@ -632,7 +591,6 @@
sinon.stub(element, '_paramsChanged');
element.params = {commentLink: true, view: GerritView.DIFF};
element._focusLineNum = 10;
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffBaseAgainstLeft(new CustomEvent(''));
assert(diffNavStub.called);
@@ -651,7 +609,6 @@
basePatchNum: 1,
patchNum: 3,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffRightAgainstLatest(new CustomEvent(''));
assert(diffNavStub.called);
@@ -669,7 +626,6 @@
basePatchNum: 1,
patchNum: 3,
};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
const diffNavStub = sinon.stub(GerritNav, 'navigateToDiff');
element._handleDiffBaseAgainstLatest(new CustomEvent(''));
assert(diffNavStub.called);
@@ -683,7 +639,7 @@
sinon.stub(element, '_getLoggedIn').returns(Promise.resolve(false));
const loggedInErrorSpy = sinon.spy();
element.addEventListener('show-auth-required', loggedInErrorSpy);
- MockInteractions.pressAndReleaseKeyOn(element, 65, null, 'a');
+ MockInteractions.keyUpOn(element, 65, null, 'a');
await flush();
assert.isTrue(changeNavStub.notCalled, 'The `a` keyboard shortcut ' +
'should only work when the user is logged in.');
@@ -709,7 +665,7 @@
sinon.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
const loggedInErrorSpy = sinon.spy();
element.addEventListener('show-auth-required', loggedInErrorSpy);
- MockInteractions.pressAndReleaseKeyOn(element, 65, null, 'a');
+ MockInteractions.keyUpOn(element, 65, null, 'a');
await flush();
assert.isTrue(element.changeViewState.showReplyDialog);
assert(changeNavStub.lastCall.calledWithExactly(element._change, 10,
@@ -735,7 +691,7 @@
sinon.stub(element, '_getLoggedIn').returns(Promise.resolve(true));
const loggedInErrorSpy = sinon.spy();
element.addEventListener('show-auth-required', loggedInErrorSpy);
- MockInteractions.pressAndReleaseKeyOn(element, 65, null, 'a');
+ MockInteractions.keyUpOn(element, 65, null, 'a');
await flush();
assert.isTrue(element.changeViewState.showReplyDialog);
assert(changeNavStub.lastCall.calledWithExactly(element._change, 1,
@@ -799,7 +755,7 @@
'Should navigate to /c/42/5..10');
assert.isUndefined(element.changeViewState.showDownloadDialog);
- MockInteractions.pressAndReleaseKeyOn(element, 68, null, 'd');
+ MockInteractions.keyUpOn(element, 68, null, 'd');
assert.isTrue(element.changeViewState.showDownloadDialog);
});
@@ -1521,8 +1477,9 @@
});
test('_handleToggleDiffMode', () => {
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- const e = {preventDefault: () => {}};
+ const e = new CustomEvent('keydown', {
+ detail: {keyboardEvent: new KeyboardEvent('keydown'), key: 'x'},
+ });
// Initial state.
assert.equal(element._getDiffViewMode(), 'SIDE_BY_SIDE');
@@ -1733,7 +1690,7 @@
test('toggle blame with shortcut', () => {
const toggleBlame = sinon.stub(
element.$.diffHost, 'loadBlame').callsFake(() => Promise.resolve());
- MockInteractions.pressAndReleaseKeyOn(element, 66, null, 'b');
+ MockInteractions.keyUpOn(element, 66, null, 'b');
assert.isTrue(toggleBlame.calledOnce);
});
});
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
index fada9cb..7393606 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
@@ -129,6 +129,29 @@
rootId: string;
}
+const VISIBLE_TEXT_NODE_TYPES = [Node.TEXT_NODE, Node.ELEMENT_NODE];
+
+export function getPreviousContentNodes(node?: Node | null) {
+ const sibs = [];
+ while (node) {
+ const {parentNode, previousSibling} = node;
+ const topContentLevel =
+ parentNode &&
+ (parentNode as HTMLElement).classList.contains('contentText');
+ let previousEl: Node | undefined | null;
+ if (previousSibling) {
+ previousEl = previousSibling;
+ } else if (!topContentLevel) {
+ previousEl = parentNode?.previousSibling;
+ }
+ if (previousEl && VISIBLE_TEXT_NODE_TYPES.includes(previousEl.nodeType)) {
+ sibs.push(previousEl);
+ }
+ node = previousEl;
+ }
+ return sibs;
+}
+
export function isThreadEl(node: Node): node is GrDiffThreadElement {
return (
node.nodeType === Node.ELEMENT_NODE &&
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
index 3544834..0d6cadc 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select.ts
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../../shared/gr-dropdown-list/gr-dropdown-list';
import '../../shared/gr-select/gr-select';
diff --git a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
index 5ab8449..26944a4 100644
--- a/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
+++ b/polygerrit-ui/app/elements/diff/gr-patch-range-select/gr-patch-range-select_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
align-items: center;
@@ -30,11 +33,8 @@
margin: 0 var(--spacing-m);
}
gr-dropdown-list {
- --trigger-style: {
- color: var(--deemphasized-text-color);
- text-transform: none;
- font-family: var(--font-family);
- }
+ --trigger-style-text-color: var(--deemphasized-text-color);
+ --trigger-style-font-family: var(--font-family);
}
@media screen and (max-width: 50em) {
.filesWeblinks {
diff --git a/polygerrit-ui/app/elements/diff/gr-range-header/gr-range-header.ts b/polygerrit-ui/app/elements/diff/gr-range-header/gr-range-header.ts
index 1c2c074..dcf7236 100644
--- a/polygerrit-ui/app/elements/diff/gr-range-header/gr-range-header.ts
+++ b/polygerrit-ui/app/elements/diff/gr-range-header/gr-range-header.ts
@@ -16,6 +16,7 @@
*/
import {LitElement, css, html} from 'lit';
import {customElement, property} from 'lit/decorators';
+import '@polymer/iron-icon/iron-icon';
/**
* Represents a header (label) for a code chunk whenever showing
diff --git a/polygerrit-ui/app/elements/diff/gr-ranged-comment-hint/gr-ranged-comment-hint.ts b/polygerrit-ui/app/elements/diff/gr-ranged-comment-hint/gr-ranged-comment-hint.ts
index bc3c054..3f2258d 100644
--- a/polygerrit-ui/app/elements/diff/gr-ranged-comment-hint/gr-ranged-comment-hint.ts
+++ b/polygerrit-ui/app/elements/diff/gr-ranged-comment-hint/gr-ranged-comment-hint.ts
@@ -45,6 +45,7 @@
override render() {
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
.row {
diff --git a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
index 3b026b3..8821725 100644
--- a/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
+++ b/polygerrit-ui/app/elements/diff/gr-selection-action-box/gr-selection-action-box.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import '../../../styles/shared-styles';
+import '../../shared/gr-tooltip/gr-tooltip';
import {GrTooltip} from '../../shared/gr-tooltip/gr-tooltip';
import {customElement, property} from '@polymer/decorators';
import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
diff --git a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
index 91882ab..3adb0f3 100644
--- a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
+++ b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search.ts
@@ -19,21 +19,15 @@
import '../../shared/gr-list-view/gr-list-view';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-documentation-search_html';
-import {
- ListViewMixin,
- ListViewParams,
-} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {getBaseUrl} from '../../../utils/url-util';
import {customElement, property} from '@polymer/decorators';
import {DocResult} from '../../../types/common';
import {fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
-
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
+import {ListViewParams} from '../../gr-app-types';
@customElement('gr-documentation-search')
-export class GrDocumentationSearch extends base {
+export class GrDocumentationSearch extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -62,7 +56,7 @@
_paramsChanged(params: ListViewParams) {
this._loading = true;
- this._filter = this.getFilterValue(params);
+ this._filter = params?.filter ?? '';
return this._getDocumentationSearches(this._filter);
}
@@ -87,6 +81,10 @@
}
return `${getBaseUrl()}/${url}`;
}
+
+ computeLoadingClass(loading: boolean) {
+ return loading ? 'loading' : '';
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.ts b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.ts
index 5267b2d..bf6a0d5 100644
--- a/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.ts
+++ b/polygerrit-ui/app/elements/documentation/gr-documentation-search/gr-documentation-search_test.ts
@@ -21,8 +21,8 @@
import {page} from '../../../utils/page-wrapper-utils';
import 'lodash/lodash';
import {stubRestApi} from '../../../test/test-utils';
-import {ListViewParams} from '../../../mixins/gr-list-view-mixin/gr-list-view-mixin';
import {DocResult} from '../../../types/common';
+import {ListViewParams} from '../../gr-app-types';
const basicFixture = fixtureFromElement('gr-documentation-search');
diff --git a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
index 480b8fe..5312be2 100644
--- a/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
+++ b/polygerrit-ui/app/elements/edit/gr-default-editor/gr-default-editor.ts
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
import {sharedStyles} from '../../../styles/shared-styles';
import {LitElement, css, html} from 'lit';
import {customElement, property} from 'lit/decorators';
@@ -62,7 +61,7 @@
override render() {
return html` <textarea
id="textarea"
- value="${this.fileContent}"
+ .value="${this.fileContent}"
@input=${this._handleTextareaInput}
></textarea>`;
}
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
index f0a3ca1..d87b573 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls.ts
@@ -351,7 +351,7 @@
}
}
- _handleKeyPress(event: InputEvent) {
+ _handleKeyPress(event: KeyboardEvent) {
event.preventDefault();
event.stopImmediatePropagation();
}
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.ts b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.ts
index 2e1fc21..0ba68e2 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-controls/gr-edit-controls_test.ts
@@ -76,33 +76,33 @@
assert.isTrue(element._isValidPath('test.js'));
});
- test('open', () => {
+ test('open', async () => {
assert.isFalse(hideDialogStub.called);
MockInteractions.tap(queryAndAssert(element, '#open'));
element.patchNum = 1 as PatchSetNum;
- return showDialogSpy.lastCall.returnValue.then(() => {
- assert.isTrue(hideDialogStub.called);
- assert.isTrue(element.$.openDialog.disabled);
- assert.isFalse(queryStub.called);
- // Setup _focused manually - in headless mode Chrome sometimes don't
- // setup focus. flush and/or flushAsynchronousOperations don't help
- openAutoComplete._focused = true;
- openAutoComplete.noDebounce = true;
- openAutoComplete.text = 'src/test.cpp';
- assert.isTrue(queryStub.called);
- assert.isFalse(element.$.openDialog.disabled);
- MockInteractions.tap(
- queryAndAssert(element.$.openDialog, 'gr-button[primary]')
- );
- assert.isTrue(editDiffStub.called);
- assert.isTrue(navStub.called);
- assert.deepEqual(editDiffStub.lastCall.args, [
- element.change,
- 'src/test.cpp',
- element.patchNum,
- ]);
- assert.isTrue(closeDialogSpy.called);
- });
+ await showDialogSpy.lastCall.returnValue;
+ assert.isTrue(hideDialogStub.called);
+ assert.isTrue(element.$.openDialog.disabled);
+ assert.isFalse(queryStub.called);
+ // Setup _focused manually - in headless mode Chrome sometimes don't
+ // setup focus. flush and/or flushAsynchronousOperations don't help
+ openAutoComplete._focused = true;
+ openAutoComplete.noDebounce = true;
+ openAutoComplete.text = 'src/test.cpp';
+ await flush();
+ assert.isTrue(queryStub.called);
+ assert.isFalse(element.$.openDialog.disabled);
+ MockInteractions.tap(
+ queryAndAssert(element.$.openDialog, 'gr-button[primary]')
+ );
+ assert.isTrue(editDiffStub.called);
+ assert.isTrue(navStub.called);
+ assert.deepEqual(editDiffStub.lastCall.args, [
+ element.change,
+ 'src/test.cpp',
+ element.patchNum,
+ ]);
+ assert.isTrue(closeDialogSpy.called);
});
test('cancel', () => {
@@ -133,59 +133,56 @@
element.$.deleteDialog!.querySelector('gr-autocomplete')!;
});
- test('delete', () => {
+ test('delete', async () => {
deleteStub.returns(Promise.resolve({ok: true}));
MockInteractions.tap(queryAndAssert(element, '#delete'));
- return showDialogSpy.lastCall.returnValue.then(() => {
- assert.isTrue(element.$.deleteDialog.disabled);
- assert.isFalse(queryStub.called);
- // Setup _focused manually - in headless mode Chrome sometimes don't
- // setup focus. flush and/or flushAsynchronousOperations don't help
- deleteAutocomplete._focused = true;
- deleteAutocomplete.noDebounce = true;
- deleteAutocomplete.text = 'src/test.cpp';
- assert.isTrue(queryStub.called);
- assert.isFalse(element.$.deleteDialog.disabled);
- MockInteractions.tap(
- queryAndAssert(element.$.deleteDialog, 'gr-button[primary]')
- );
- flush();
+ await showDialogSpy.lastCall.returnValue;
+ assert.isTrue(element.$.deleteDialog.disabled);
+ assert.isFalse(queryStub.called);
+ // Setup _focused manually - in headless mode Chrome sometimes don't
+ // setup focus. flush and/or flushAsynchronousOperations don't help
+ deleteAutocomplete._focused = true;
+ deleteAutocomplete.noDebounce = true;
+ deleteAutocomplete.text = 'src/test.cpp';
+ await flush();
+ assert.isTrue(queryStub.called);
+ assert.isFalse(element.$.deleteDialog.disabled);
+ MockInteractions.tap(
+ queryAndAssert(element.$.deleteDialog, 'gr-button[primary]')
+ );
+ await flush();
- assert.isTrue(deleteStub.called);
-
- return deleteStub.lastCall.returnValue.then(() => {
- assert.equal(element._path, '');
- assert.isTrue(navStub.called);
- assert.isTrue(closeDialogSpy.called);
- });
- });
+ assert.isTrue(deleteStub.called);
+ await deleteStub.lastCall.returnValue;
+ assert.equal(element._path, '');
+ assert.isTrue(navStub.called);
+ assert.isTrue(closeDialogSpy.called);
});
- test('delete fails', () => {
+ test('delete fails', async () => {
deleteStub.returns(Promise.resolve({ok: false}));
MockInteractions.tap(queryAndAssert(element, '#delete'));
- return showDialogSpy.lastCall.returnValue.then(() => {
- assert.isTrue(element.$.deleteDialog.disabled);
- assert.isFalse(queryStub.called);
- // Setup _focused manually - in headless mode Chrome sometimes don't
- // setup focus. flush and/or flushAsynchronousOperations don't help
- deleteAutocomplete._focused = true;
- deleteAutocomplete.noDebounce = true;
- deleteAutocomplete.text = 'src/test.cpp';
- assert.isTrue(queryStub.called);
- assert.isFalse(element.$.deleteDialog.disabled);
- MockInteractions.tap(
- queryAndAssert(element.$.deleteDialog, 'gr-button[primary]')
- );
- flush();
+ await showDialogSpy.lastCall.returnValue;
+ assert.isTrue(element.$.deleteDialog.disabled);
+ assert.isFalse(queryStub.called);
+ // Setup _focused manually - in headless mode Chrome sometimes don't
+ // setup focus. flush and/or flushAsynchronousOperations don't help
+ deleteAutocomplete._focused = true;
+ deleteAutocomplete.noDebounce = true;
+ deleteAutocomplete.text = 'src/test.cpp';
+ await flush();
+ assert.isTrue(queryStub.called);
+ assert.isFalse(element.$.deleteDialog.disabled);
+ MockInteractions.tap(
+ queryAndAssert(element.$.deleteDialog, 'gr-button[primary]')
+ );
+ await flush();
- assert.isTrue(deleteStub.called);
+ assert.isTrue(deleteStub.called);
- return deleteStub.lastCall.returnValue.then(() => {
- assert.isFalse(navStub.called);
- assert.isFalse(closeDialogSpy.called);
- });
- });
+ await deleteStub.lastCall.returnValue;
+ assert.isFalse(navStub.called);
+ assert.isFalse(closeDialogSpy.called);
});
test('cancel', () => {
@@ -217,67 +214,66 @@
element.$.renameDialog!.querySelector('gr-autocomplete')!;
});
- test('rename', () => {
+ test('rename', async () => {
renameStub.returns(Promise.resolve({ok: true}));
MockInteractions.tap(queryAndAssert(element, '#rename'));
- return showDialogSpy.lastCall.returnValue.then(() => {
- assert.isTrue(element.$.renameDialog.disabled);
- assert.isFalse(queryStub.called);
- // Setup _focused manually - in headless mode Chrome sometimes don't
- // setup focus. flush and/or flushAsynchronousOperations don't help
- renameAutocomplete._focused = true;
- renameAutocomplete.noDebounce = true;
- renameAutocomplete.text = 'src/test.cpp';
- assert.isTrue(queryStub.called);
- assert.isTrue(element.$.renameDialog.disabled);
+ await showDialogSpy.lastCall.returnValue;
+ assert.isTrue(element.$.renameDialog.disabled);
+ assert.isFalse(queryStub.called);
+ // Setup _focused manually - in headless mode Chrome sometimes don't
+ // setup focus. flush and/or flushAsynchronousOperations don't help
+ renameAutocomplete._focused = true;
+ renameAutocomplete.noDebounce = true;
+ renameAutocomplete.text = 'src/test.cpp';
+ await flush();
+ assert.isTrue(queryStub.called);
+ assert.isTrue(element.$.renameDialog.disabled);
- element.$.newPathIronInput.bindValue = 'src/test.newPath';
+ element.$.newPathIronInput.bindValue = 'src/test.newPath';
+ await flush();
- assert.isFalse(element.$.renameDialog.disabled);
- MockInteractions.tap(
- queryAndAssert(element.$.renameDialog, 'gr-button[primary]')
- );
- flush();
+ assert.isFalse(element.$.renameDialog.disabled);
+ MockInteractions.tap(
+ queryAndAssert(element.$.renameDialog, 'gr-button[primary]')
+ );
+ await flush();
+ assert.isTrue(renameStub.called);
- assert.isTrue(renameStub.called);
-
- return renameStub.lastCall.returnValue.then(() => {
- assert.equal(element._path, '');
- assert.isTrue(navStub.called);
- assert.isTrue(closeDialogSpy.called);
- });
- });
+ await renameStub.lastCall.returnValue;
+ assert.equal(element._path, '');
+ assert.isTrue(navStub.called);
+ assert.isTrue(closeDialogSpy.called);
});
- test('rename fails', () => {
+ test('rename fails', async () => {
renameStub.returns(Promise.resolve({ok: false}));
MockInteractions.tap(queryAndAssert(element, '#rename'));
- return showDialogSpy.lastCall.returnValue.then(() => {
- assert.isTrue(element.$.renameDialog.disabled);
- assert.isFalse(queryStub.called);
- // Setup _focused manually - in headless mode Chrome sometimes don't
- // setup focus. flush and/or flushAsynchronousOperations don't help
- renameAutocomplete._focused = true;
- renameAutocomplete.noDebounce = true;
- renameAutocomplete.text = 'src/test.cpp';
- assert.isTrue(queryStub.called);
- assert.isTrue(element.$.renameDialog.disabled);
+ await showDialogSpy.lastCall.returnValue;
+ assert.isTrue(element.$.renameDialog.disabled);
+ assert.isFalse(queryStub.called);
+ // Setup _focused manually - in headless mode Chrome sometimes don't
+ // setup focus. flush and/or flushAsynchronousOperations don't help
+ renameAutocomplete._focused = true;
+ renameAutocomplete.noDebounce = true;
+ renameAutocomplete.text = 'src/test.cpp';
+ await flush();
+ assert.isTrue(queryStub.called);
+ assert.isTrue(element.$.renameDialog.disabled);
- element.$.newPathIronInput.bindValue = 'src/test.newPath';
+ element.$.newPathIronInput.bindValue = 'src/test.newPath';
+ await flush();
- assert.isFalse(element.$.renameDialog.disabled);
- MockInteractions.tap(
- queryAndAssert(element.$.renameDialog, 'gr-button[primary]')
- );
- flush();
+ assert.isFalse(element.$.renameDialog.disabled);
+ MockInteractions.tap(
+ queryAndAssert(element.$.renameDialog, 'gr-button[primary]')
+ );
+ await flush();
- assert.isTrue(renameStub.called);
+ assert.isTrue(renameStub.called);
- return renameStub.lastCall.returnValue.then(() => {
- assert.isFalse(navStub.called);
- assert.isFalse(closeDialogSpy.called);
- });
- });
+ await renameStub.lastCall.returnValue;
+ assert.isFalse(navStub.called);
+ assert.isFalse(closeDialogSpy.called);
});
test('cancel', () => {
diff --git a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
index 1255256..418c368 100644
--- a/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
+++ b/polygerrit-ui/app/elements/edit/gr-edit-file-controls/gr-edit-file-controls.ts
@@ -49,6 +49,9 @@
display: flex;
justify-content: flex-end;
}
+ gr-dropdown {
+ --gr-button-padding: var(--spacing-xs) var(--spacing-s);
+ }
#actions {
margin-right: var(--spacing-l);
}
@@ -59,14 +62,9 @@
override render() {
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
- gr-button,
- gr-dropdown {
- --gr-button: {
- height: 1.8em;
- }
- }
gr-dropdown {
--gr-dropdown-item: {
background-color: transparent;
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
index 6f2d27e..ad7e015 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.ts
@@ -47,6 +47,7 @@
import {GrButton} from '../../shared/gr-button/gr-button';
import {GrDefaultEditor} from '../gr-default-editor/gr-default-editor';
import {GrEndpointDecorator} from '../../plugins/gr-endpoint-decorator/gr-endpoint-decorator';
+import {IronKeyboardEvent} from '../../../types/events';
const RESTORED_MESSAGE = 'Content restored from a previous edit.';
const SAVING_MESSAGE = 'Saving changes...';
@@ -393,7 +394,7 @@
);
}
- _handleSaveShortcut(e: KeyboardEvent) {
+ _handleSaveShortcut(e: IronKeyboardEvent) {
e.preventDefault();
if (!this._saveDisabled) {
this._saveEdit();
diff --git a/polygerrit-ui/app/elements/gr-app-element.ts b/polygerrit-ui/app/elements/gr-app-element.ts
index 46a3e84..3b93bea 100644
--- a/polygerrit-ui/app/elements/gr-app-element.ts
+++ b/polygerrit-ui/app/elements/gr-app-element.ts
@@ -43,7 +43,6 @@
import {
KeyboardShortcutMixin,
Shortcut,
- SPECIAL_SHORTCUT,
} from '../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {GerritNav} from './core/gr-navigation/gr-navigation';
import {appContext} from '../services/app-context';
@@ -69,7 +68,7 @@
import {GrMainHeader} from './core/gr-main-header/gr-main-header';
import {GrSettingsView} from './settings/gr-settings-view/gr-settings-view';
import {
- CustomKeyboardEvent,
+ IronKeyboardEvent,
DialogChangeEventDetail,
EventType,
LocationChangeEvent,
@@ -215,6 +214,8 @@
private readonly restApiService = appContext.restApiService;
+ private readonly shortcuts = appContext.shortcutsService;
+
override keyboardShortcuts() {
return {
[Shortcut.OPEN_SHORTCUT_HELP_DIALOG]: '_showKeyboardShortcuts',
@@ -232,7 +233,6 @@
// model changes and updates the config model, but at the moment the service
// is not called from anywhere.
appContext.configService;
- this._bindKeyboardShortcuts();
document.addEventListener(EventType.PAGE_ERROR, e => {
this._handlePageError(e);
});
@@ -307,158 +307,6 @@
};
}
- _bindKeyboardShortcuts() {
- this.bindShortcut(
- Shortcut.SEND_REPLY,
- SPECIAL_SHORTCUT.DOC_ONLY,
- 'ctrl+enter',
- 'meta+enter'
- );
- this.bindShortcut(Shortcut.EMOJI_DROPDOWN, SPECIAL_SHORTCUT.DOC_ONLY, ':');
-
- this.bindShortcut(Shortcut.OPEN_SHORTCUT_HELP_DIALOG, '?');
- this.bindShortcut(
- Shortcut.GO_TO_USER_DASHBOARD,
- SPECIAL_SHORTCUT.GO_KEY,
- 'i'
- );
- this.bindShortcut(
- Shortcut.GO_TO_OPENED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY,
- 'o'
- );
- this.bindShortcut(
- Shortcut.GO_TO_MERGED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY,
- 'm'
- );
- this.bindShortcut(
- Shortcut.GO_TO_ABANDONED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY,
- 'a'
- );
- this.bindShortcut(
- Shortcut.GO_TO_WATCHED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY,
- 'w'
- );
-
- this.bindShortcut(Shortcut.CURSOR_NEXT_CHANGE, 'j');
- this.bindShortcut(Shortcut.CURSOR_PREV_CHANGE, 'k');
- this.bindShortcut(Shortcut.OPEN_CHANGE, 'o');
- this.bindShortcut(Shortcut.NEXT_PAGE, 'n', ']');
- this.bindShortcut(Shortcut.PREV_PAGE, 'p', '[');
- this.bindShortcut(Shortcut.TOGGLE_CHANGE_REVIEWED, 'r:keyup');
- this.bindShortcut(Shortcut.TOGGLE_CHANGE_STAR, 's:keydown');
- this.bindShortcut(Shortcut.REFRESH_CHANGE_LIST, 'shift+r:keyup');
- this.bindShortcut(Shortcut.EDIT_TOPIC, 't');
- this.bindShortcut(Shortcut.OPEN_SUBMIT_DIALOG, 'shift+s');
-
- this.bindShortcut(Shortcut.OPEN_REPLY_DIALOG, 'a:keyup');
- this.bindShortcut(Shortcut.OPEN_DOWNLOAD_DIALOG, 'd:keyup');
- this.bindShortcut(Shortcut.EXPAND_ALL_MESSAGES, 'x');
- this.bindShortcut(Shortcut.COLLAPSE_ALL_MESSAGES, 'z');
- this.bindShortcut(Shortcut.REFRESH_CHANGE, 'shift+r:keyup');
- this.bindShortcut(Shortcut.UP_TO_DASHBOARD, 'u');
- this.bindShortcut(Shortcut.UP_TO_CHANGE, 'u');
- this.bindShortcut(Shortcut.TOGGLE_DIFF_MODE, 'm:keyup');
- this.bindShortcut(
- Shortcut.DIFF_AGAINST_BASE,
- SPECIAL_SHORTCUT.V_KEY,
- 'down',
- 's'
- );
- // this keyboard shortcut is used in toast _displayDiffAgainstLatestToast
- // in gr-diff-view. Any updates here should be reflected there
- this.bindShortcut(
- Shortcut.DIFF_AGAINST_LATEST,
- SPECIAL_SHORTCUT.V_KEY,
- 'up',
- 'w'
- );
- // this keyboard shortcut is used in toast _displayDiffBaseAgainstLeftToast
- // in gr-diff-view. Any updates here should be reflected there
- this.bindShortcut(
- Shortcut.DIFF_BASE_AGAINST_LEFT,
- SPECIAL_SHORTCUT.V_KEY,
- 'left',
- 'a'
- );
- this.bindShortcut(
- Shortcut.DIFF_RIGHT_AGAINST_LATEST,
- SPECIAL_SHORTCUT.V_KEY,
- 'right',
- 'd'
- );
- this.bindShortcut(
- Shortcut.DIFF_BASE_AGAINST_LATEST,
- SPECIAL_SHORTCUT.V_KEY,
- 'b'
- );
-
- this.bindShortcut(Shortcut.NEXT_LINE, 'j', 'down');
- this.bindShortcut(Shortcut.PREV_LINE, 'k', 'up');
- if (this._isCursorManagerSupportMoveToVisibleLine()) {
- this.bindShortcut(Shortcut.VISIBLE_LINE, '.');
- }
- this.bindShortcut(Shortcut.NEXT_CHUNK, 'n');
- this.bindShortcut(Shortcut.PREV_CHUNK, 'p');
- this.bindShortcut(Shortcut.TOGGLE_ALL_DIFF_CONTEXT, 'shift+x');
- this.bindShortcut(Shortcut.NEXT_COMMENT_THREAD, 'shift+n');
- this.bindShortcut(Shortcut.PREV_COMMENT_THREAD, 'shift+p');
- this.bindShortcut(
- Shortcut.EXPAND_ALL_COMMENT_THREADS,
- SPECIAL_SHORTCUT.DOC_ONLY,
- 'e'
- );
- this.bindShortcut(
- Shortcut.COLLAPSE_ALL_COMMENT_THREADS,
- SPECIAL_SHORTCUT.DOC_ONLY,
- 'shift+e'
- );
- this.bindShortcut(Shortcut.LEFT_PANE, 'shift+left');
- this.bindShortcut(Shortcut.RIGHT_PANE, 'shift+right');
- this.bindShortcut(Shortcut.TOGGLE_LEFT_PANE, 'shift+a');
- this.bindShortcut(Shortcut.NEW_COMMENT, 'c');
- this.bindShortcut(
- Shortcut.SAVE_COMMENT,
- 'ctrl+enter',
- 'meta+enter',
- 'ctrl+s',
- 'meta+s'
- );
- this.bindShortcut(Shortcut.OPEN_DIFF_PREFS, ',');
- this.bindShortcut(Shortcut.TOGGLE_DIFF_REVIEWED, 'r:keyup');
-
- this.bindShortcut(Shortcut.NEXT_FILE, ']');
- this.bindShortcut(Shortcut.PREV_FILE, '[');
- this.bindShortcut(Shortcut.NEXT_FILE_WITH_COMMENTS, 'shift+j');
- this.bindShortcut(Shortcut.PREV_FILE_WITH_COMMENTS, 'shift+k');
- this.bindShortcut(Shortcut.CURSOR_NEXT_FILE, 'j', 'down');
- this.bindShortcut(Shortcut.CURSOR_PREV_FILE, 'k', 'up');
- this.bindShortcut(Shortcut.OPEN_FILE, 'o', 'enter');
- this.bindShortcut(Shortcut.TOGGLE_FILE_REVIEWED, 'r:keyup');
- this.bindShortcut(Shortcut.NEXT_UNREVIEWED_FILE, 'shift+m');
- this.bindShortcut(Shortcut.TOGGLE_ALL_INLINE_DIFFS, 'shift+i');
- this.bindShortcut(Shortcut.TOGGLE_INLINE_DIFF, 'i');
- this.bindShortcut(Shortcut.TOGGLE_BLAME, 'b:keyup');
- this.bindShortcut(Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS, 'h');
- this.bindShortcut(Shortcut.OPEN_FILE_LIST, 'f');
-
- this.bindShortcut(Shortcut.OPEN_FIRST_FILE, ']');
- this.bindShortcut(Shortcut.OPEN_LAST_FILE, '[');
-
- this.bindShortcut(Shortcut.SEARCH, '/');
- }
-
- _isCursorManagerSupportMoveToVisibleLine() {
- // This method is a copy-paste from the
- // method _isIntersectionObserverSupported of gr-cursor-manager.js
- // It is better share this method with gr-cursor-manager,
- // but doing it require a lot if changes instead of 1-line copied code
- return 'IntersectionObserver' in window;
- }
-
_accountChanged(account?: AccountDetailInfo) {
if (!account) return;
@@ -654,7 +502,8 @@
(this.shadowRoot!.querySelector('#keyboardShortcuts') as GrOverlay).open();
}
- _showKeyboardShortcuts(e: CustomKeyboardEvent) {
+ _showKeyboardShortcuts(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
// same shortcut should close the dialog if pressed again
// when dialog is open
this.loadKeyboardShortcutsDialog = true;
@@ -667,9 +516,6 @@
keyboardShortcuts.cancel();
return;
}
- if (this.shouldSuppressKeyboardShortcut(e)) {
- return;
- }
keyboardShortcuts.open();
this._footerHeaderAriaHidden = true;
this._mainAriaHidden = true;
diff --git a/polygerrit-ui/app/elements/gr-app-types.ts b/polygerrit-ui/app/elements/gr-app-types.ts
index e5096c0..6c8bdb9 100644
--- a/polygerrit-ui/app/elements/gr-app-types.ts
+++ b/polygerrit-ui/app/elements/gr-app-types.ts
@@ -52,20 +52,21 @@
groupId: GroupId;
}
-export interface AppElementAdminParams {
+export interface ListViewParams {
+ filter?: string | null;
+ offset?: number | string;
+}
+
+export interface AppElementAdminParams extends ListViewParams {
view: GerritView.ADMIN;
adminView: string;
- offset?: string | number;
- filter?: string | null;
openCreateModal?: boolean;
}
-export interface AppElementRepoParams {
+export interface AppElementRepoParams extends ListViewParams {
view: GerritView.REPO;
detail?: RepoDetailView;
repo: RepoName;
- offset?: string | number;
- filter?: string | null;
}
export interface AppElementDocSearchParams {
diff --git a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
index 988366c..7fee4a0 100644
--- a/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-plugin-host/gr-plugin-host.ts
@@ -37,7 +37,7 @@
getPluginLoader().loadPlugins(pluginsPending);
}
- updated(changedProperties: PropertyValues<GrPluginHost>) {
+ override updated(changedProperties: PropertyValues<GrPluginHost>) {
if (changedProperties.has('config') && this.config) {
this._configChanged(this.config);
}
diff --git a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
index 8ed6611..45a93bf 100644
--- a/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-popup-interface/gr-popup-interface.ts
@@ -51,6 +51,11 @@
return dom(this.popup) as unknown as HTMLElement;
}
+ appendContent(el: HTMLElement) {
+ if (!this.popup) throw new Error('popup element not (yet) available');
+ this.popup.appendChild(el);
+ }
+
/**
* Opens the popup, inserts it into DOM over current UI.
* Creates the popup if not previously created. Creates popup content element,
diff --git a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.ts b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.ts
index f913cf6..6580ad6 100644
--- a/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.ts
+++ b/polygerrit-ui/app/elements/plugins/gr-theme-api/gr-custom-plugin-header.ts
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/* eslint-disable lit/no-legacy-template-syntax,lit/prefer-static-styles */
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {html} from '@polymer/polymer/lib/utils/html-tag';
import {customElement, property} from '@polymer/decorators';
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
index 536beb4..bd6835c 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info.ts
@@ -26,7 +26,6 @@
import {EditableAccountField} from '../../../constants/constants';
import {appContext} from '../../../services/app-context';
import {fireEvent} from '../../../utils/event-util';
-import {KeydownEvent} from '../../../types/events';
@customElement('gr-account-info')
export class GrAccountInfo extends PolymerElement {
@@ -247,7 +246,7 @@
this._hasNameChange = true;
}
- _handleKeydown(e: KeydownEvent) {
+ _handleKeydown(e: KeyboardEvent) {
if (e.keyCode === 13) {
// Enter
e.stopPropagation();
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_html.ts b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_html.ts
index 514f00e..51259c8 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_html.ts
@@ -56,7 +56,7 @@
<span class="title">Registered</span>
<span class="value">
<gr-date-formatter
- has-tooltip=""
+ withTooltip
date-str="[[_account.registered_on]]"
></gr-date-formatter>
</span>
diff --git a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_test.ts b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_test.ts
index ab27b1e..f1813a4 100644
--- a/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_test.ts
+++ b/polygerrit-ui/app/elements/settings/gr-account-info/gr-account-info_test.ts
@@ -27,7 +27,7 @@
createServerInfo,
} from '../../../test/test-data-generators';
import {IronInputElement} from '@polymer/iron-input';
-import {SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonStubbedMember} from 'sinon';
import {RestApiService} from '../../../services/gr-rest-api/gr-rest-api';
const basicFixture = fixtureFromElement('gr-account-info');
diff --git a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
index eca38d9..a972db3 100644
--- a/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
+++ b/polygerrit-ui/app/elements/settings/gr-agreements-list/gr-agreements-list.ts
@@ -41,7 +41,7 @@
});
}
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -71,7 +71,7 @@
`;
}
- render() {
+ override render() {
return html` <div class="gr-form-styles">
<table id="agreements">
<thead>
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
index b79e448..96b1ded 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor.ts
@@ -15,22 +15,18 @@
* limitations under the License.
*/
import '../../shared/gr-button/gr-button';
-import '../../shared/gr-date-formatter/gr-date-formatter';
import '../../../styles/shared-styles';
import '../../../styles/gr-form-styles';
import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-change-table-editor_html';
-import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
import {customElement, property, observe} from '@polymer/decorators';
import {ServerInfo} from '../../../types/common';
import {appContext} from '../../../services/app-context';
-
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ChangeTableMixin(PolymerElement);
+import {columnNames} from '../../change-list/gr-change-list/gr-change-list';
@customElement('gr-change-table-editor')
-export class GrChangeTableEditor extends base {
+export class GrChangeTableEditor extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -51,18 +47,33 @@
@observe('serverConfig')
_configChanged(config: ServerInfo) {
- this.defaultColumns = this.getEnabledColumns(
- this.columnNames,
- config,
- this.flagsService.enabledExperiments
+ this.defaultColumns = columnNames.filter(col =>
+ this._isColumnEnabled(col, config, this.flagsService.enabledExperiments)
);
if (!this.displayedColumns) return;
this.displayedColumns = this.displayedColumns.filter(column =>
- this.isColumnEnabled(column, config, this.flagsService.enabledExperiments)
+ this._isColumnEnabled(
+ column,
+ config,
+ this.flagsService.enabledExperiments
+ )
);
}
/**
+ * Is the column disabled by a server config or experiment? For example the
+ * assignee feature might be disabled and thus the corresponding column is
+ * also disabled.
+ *
+ */
+ _isColumnEnabled(column: string, config: ServerInfo, experiments: string[]) {
+ if (!config || !config.change) return true;
+ if (column === 'Assignee') return !!config.change.enable_assignee;
+ if (column === 'Comments') return experiments.includes('comments-column');
+ return true;
+ }
+
+ /**
* Get the list of enabled column names from whichever checkboxes are
* checked (excluding the number checkbox).
*/
@@ -79,6 +90,13 @@
.map(checkbox => checkbox.name);
}
+ _computeIsColumnHidden(columnToCheck?: string, columnsToDisplay?: string[]) {
+ if (!columnsToDisplay || !columnToCheck) {
+ return false;
+ }
+ return !columnsToDisplay.includes(columnToCheck);
+ }
+
/**
* Handle a click on a checkbox container and relay the click to the checkbox it
* contains.
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_html.ts b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_html.ts
index a05ec73..e756a20 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_html.ts
@@ -74,7 +74,7 @@
type="checkbox"
name="[[item]]"
on-click="_handleTargetClick"
- checked$="[[!isColumnHidden(item, displayedColumns)]]"
+ checked$="[[!_computeIsColumnHidden(item, displayedColumns)]]"
/>
</td>
</tr>
diff --git a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_test.ts b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_test.ts
index 4f61972..4f8d0a0 100644
--- a/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_test.ts
+++ b/polygerrit-ui/app/elements/settings/gr-change-table-editor/gr-change-table-editor_test.ts
@@ -117,7 +117,7 @@
test('_getDisplayedColumns', () => {
const enabledColumns = columns.filter(column =>
- element.isColumnEnabled(column, element.serverConfig!, [])
+ element._isColumnEnabled(column, element.serverConfig!, [])
);
assert.deepEqual(element._getDisplayedColumns(), enabledColumns);
const input = queryAndAssert<HTMLInputElement>(
diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
index 6354c9a..59f6a39 100644
--- a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
+++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.ts
@@ -75,7 +75,7 @@
return Promise.all(promises);
}
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
formStyles,
@@ -113,9 +113,9 @@
];
}
- render() {
+ override render() {
return html` <div class="gr-form-styles">
- <div ?hidden=${this._passwordUrl}>
+ <div ?hidden=${!!this._passwordUrl}>
<section>
<span class="title">Username</span>
<span class="value">${this._username ?? ''}</span>
@@ -125,7 +125,7 @@
>
</div>
<span ?hidden=${!this._passwordUrl}>
- <a href="${this._passwordUrl}" target="_blank" rel="noopener">
+ <a href="${this._passwordUrl!}" target="_blank" rel="noopener">
Obtain password</a
>
(opens in a new tab)
@@ -134,7 +134,7 @@
<gr-overlay
id="generatedPasswordOverlay"
@iron-overlay-closed=${this._generatedPasswordOverlayClosed}
- with-backdrop=""
+ with-backdrop
>
<div class="gr-form-styles">
<section id="generatedPasswordDisplay">
diff --git a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
index ace1e1a..c392a13 100644
--- a/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
+++ b/polygerrit-ui/app/elements/settings/gr-menu-editor/gr-menu-editor.ts
@@ -16,7 +16,6 @@
*/
import '@polymer/iron-input/iron-input';
import '../../shared/gr-button/gr-button';
-import '../../shared/gr-date-formatter/gr-date-formatter';
import '../../../styles/shared-styles';
import '../../../styles/gr-form-styles';
import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
@@ -24,7 +23,6 @@
import {htmlTemplate} from './gr-menu-editor_html';
import {customElement, property} from '@polymer/decorators';
import {TopMenuItemInfo} from '../../../types/common';
-import {KeydownEvent} from '../../../types/events';
@customElement('gr-menu-editor')
export class GrMenuEditor extends PolymerElement {
@@ -91,7 +89,7 @@
return !newName?.length || !newUrl?.length;
}
- _handleInputKeydown(e: KeydownEvent) {
+ _handleInputKeydown(e: KeyboardEvent) {
if (e.keyCode === 13) {
e.stopPropagation();
this._handleAddButton();
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
index 453bc3f..3533fd6 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.ts
@@ -29,7 +29,6 @@
import '../gr-change-table-editor/gr-change-table-editor';
import '../../shared/gr-button/gr-button';
import {GrButton} from '../../shared/gr-button/gr-button';
-import '../../shared/gr-date-formatter/gr-date-formatter';
import '../../shared/gr-diff-preferences/gr-diff-preferences';
import '../../shared/gr-page-nav/gr-page-nav';
import '../../shared/gr-select/gr-select';
@@ -47,7 +46,6 @@
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-settings-view_html';
import {getDocsBaseUrl} from '../../../utils/url-util';
-import {ChangeTableMixin} from '../../../mixins/gr-change-table-mixin/gr-change-table-mixin';
import {customElement, property, observe} from '@polymer/decorators';
import {AppElementParams} from '../../gr-app-types';
import {GrAccountInfo} from '../gr-account-info/gr-account-info';
@@ -64,7 +62,6 @@
import {GrSshEditor} from '../gr-ssh-editor/gr-ssh-editor';
import {GrGpgEditor} from '../gr-gpg-editor/gr-gpg-editor';
import {GrEmailEditor} from '../gr-email-editor/gr-email-editor';
-import {KeydownEvent} from '../../../types/events';
import {fireAlert, fireTitleChange} from '../../../utils/event-util';
import {appContext} from '../../../services/app-context';
import {GerritView} from '../../../services/router/router-model';
@@ -76,6 +73,7 @@
EmailStrategy,
TimeFormat,
} from '../../../constants/constants';
+import {columnNames} from '../../change-list/gr-change-list/gr-change-list';
const PREFS_SECTION_FIELDS: Array<keyof PreferencesInput> = [
'changes_per_page',
@@ -85,6 +83,7 @@
'diff_view',
'publish_comments_on_push',
'disable_keyboard_shortcuts',
+ 'disable_token_highlighting',
'work_in_progress_by_default',
'default_base_for_merges',
'signed_off_by',
@@ -124,6 +123,7 @@
showSizeBarsInFileList: HTMLInputElement;
publishCommentsOnPush: HTMLInputElement;
disableKeyboardShortcuts: HTMLInputElement;
+ disableTokenHighlighting: HTMLInputElement;
relativeDateInChangeTable: HTMLInputElement;
changesPerPageSelect: HTMLInputElement;
dateTimeFormatSelect: HTMLInputElement;
@@ -137,11 +137,8 @@
};
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ChangeTableMixin(PolymerElement);
-
@customElement('gr-settings-view')
-export class GrSettingsView extends base {
+export class GrSettingsView extends PolymerElement {
static get template() {
return htmlTemplate;
}
@@ -260,8 +257,10 @@
this._localMenu = this._cloneMenu(prefs.my);
this._localChangeTableColumns =
prefs.change_table.length === 0
- ? this.columnNames
- : this.renameProjectToRepoColumn(prefs.change_table);
+ ? columnNames
+ : prefs.change_table.map(column =>
+ column === 'Project' ? 'Repo' : column
+ );
})
);
@@ -408,6 +407,13 @@
);
}
+ _handleDisableTokenHighlightingChanged() {
+ this.set(
+ '_localPrefs.disable_token_highlighting',
+ this.$.disableTokenHighlighting.checked
+ );
+ }
+
_handleWorkInProgressByDefault() {
this.set(
'_localPrefs.work_in_progress_by_default',
@@ -482,7 +488,7 @@
this.$.emailEditor.save();
}
- _handleNewEmailKeydown(e: KeydownEvent) {
+ _handleNewEmailKeydown(e: KeyboardEvent) {
if (e.keyCode === 13) {
// Enter
e.stopPropagation();
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
index 1ed0d57..78c4a62 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_html.ts
@@ -309,6 +309,19 @@
</span>
</section>
<section>
+ <label for="disableTokenHighlighting" class="title"
+ >Disable token highlighting on hover</label
+ >
+ <span class="value">
+ <input
+ id="disableTokenHighlighting"
+ type="checkbox"
+ checked$="[[_localPrefs.disable_token_highlighting]]"
+ on-change="_handleDisableTokenHighlightingChanged"
+ />
+ </span>
+ </section>
+ <section>
<label for="insertSignedOff" class="title">
Insert Signed-off-by Footer For Inline Edit Changes
</label>
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.ts b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.ts
index 26705ee..8194d5b 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.ts
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.ts
@@ -244,6 +244,13 @@
);
assert.equal(
(
+ valueOf('Disable token highlighting on hover', 'preferences')!
+ .firstElementChild as HTMLInputElement
+ ).checked,
+ false
+ );
+ assert.equal(
+ (
valueOf(
'Insert Signed-off-by Footer For Inline Edit Changes',
'preferences'
diff --git a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
index 66103fd..31c62b1 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-chip/gr-account-chip.ts
@@ -128,6 +128,7 @@
override render() {
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
.container {
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
index f746c29..9897a9f 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label.ts
@@ -206,18 +206,7 @@
></gr-hovercard-account>`
: ''}
${hasAttention
- ? html`<gr-button
- id="attentionButton"
- link=""
- aria-label="Remove user from attention set"
- @click=${this._handleRemoveAttentionClick}
- ?disabled=${!this._computeAttentionButtonEnabled(
- highlightAttention,
- account,
- change,
- this.selected,
- this._selfAccount
- )}
+ ? html` <gr-tooltip-content
?has-tooltip=${this._computeAttentionButtonEnabled(
highlightAttention,
account,
@@ -233,11 +222,25 @@
this.selected,
this._selfAccount
)}"
- ><iron-icon
- class="attention"
- icon="gr-icons:attention"
- ></iron-icon>
- </gr-button>`
+ >
+ <gr-button
+ id="attentionButton"
+ link=""
+ aria-label="Remove user from attention set"
+ @click=${this._handleRemoveAttentionClick}
+ ?disabled=${!this._computeAttentionButtonEnabled(
+ highlightAttention,
+ account,
+ change,
+ this.selected,
+ this._selfAccount
+ )}
+ ><iron-icon
+ class="attention"
+ icon="gr-icons:attention"
+ ></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>`
: ''}
</span>
<span
diff --git a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
index b302bee..f0c9106 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-link/gr-account-link.ts
@@ -20,6 +20,7 @@
import {AccountInfo, ChangeInfo} from '../../../types/common';
import {LitElement, css, html} from 'lit';
import {customElement, property} from 'lit/decorators';
+import {ParsedChangeInfo} from '../../../types/types';
@customElement('gr-account-link')
export class GrAccountLink extends LitElement {
@@ -35,7 +36,7 @@
* related features like adding the user as a reviewer.
*/
@property({type: Object})
- change?: ChangeInfo;
+ change?: ChangeInfo | ParsedChangeInfo;
/**
* Should this user be considered to be in the attention set, regardless
@@ -95,7 +96,7 @@
?hideStatus=${this.hideStatus}
?firstName=${this.firstName}
.voteableText=${this.voteableText}
- part="gr-account-link-text => gr-account-label-text"
+ exportparts="gr-account-label-text: gr-account-link-text"
>
</gr-account-label>
</a>
diff --git a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
index c5d1f03..d97e38e 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-list/gr-account-list.ts
@@ -39,7 +39,6 @@
import {PaperInputElementExt} from '../../../types/types';
import {fireAlert} from '../../../utils/event-util';
import {accountOrGroupKey} from '../../../utils/account-util';
-import {KeydownEvent} from '../../../types/events';
const VALID_EMAIL_ALERT = 'Please input a valid email.';
@@ -360,7 +359,7 @@
}
}
- _handleChipKeydown(e: KeydownEvent) {
+ _handleChipKeydown(e: KeyboardEvent) {
const chip = e.target as GrAccountChip;
const chips = this.accountChips;
const index = chips.indexOf(chip);
diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
index 895c99b..fa547dc 100644
--- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
+++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.ts
@@ -30,7 +30,7 @@
@customElement('gr-alert')
export class GrAlert extends LitElement {
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -43,7 +43,6 @@
bottom: 1.25rem;
border-radius: var(--border-radius);
box-shadow: var(--elevation-level-2);
- color: var(--tooltip-text-color);
left: 1.25rem;
position: fixed;
transform: translateY(5rem);
@@ -73,11 +72,10 @@
vertical-align: bottom;
word-break: break-all;
}
- .action {
- color: var(--link-color);
- font-weight: var(--font-weight-bold);
+ gr-button.action {
+ --text-color: var(--tooltip-button-text-color);
+ --gr-button-padding: 0 var(--spacing-s);
margin-left: var(--spacing-l);
- text-decoration: none;
}
`,
];
@@ -93,18 +91,9 @@
>`;
}
- render() {
- // To pass CSS mixins for @apply to Polymer components, they need to appear
- // in <style> inside the template.
- const style = html`<style>
- .action {
- --gr-button: {
- padding: 0;
- }
- }
- </style>`;
+ override render() {
const {text, actionText} = this;
- return html`${style}
+ return html`
<div class="content-wrapper">
<span class="text">${text}</span>
<gr-button
@@ -115,7 +104,8 @@
>${actionText}
</gr-button>
${this.renderDismissButton()}
- </div> `;
+ </div>
+ `;
}
/**
diff --git a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
index 3f52650..524b197 100644
--- a/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
+++ b/polygerrit-ui/app/elements/shared/gr-autocomplete/gr-autocomplete.ts
@@ -26,9 +26,10 @@
import {property, customElement, observe} from '@polymer/decorators';
import {GrAutocompleteDropdown} from '../gr-autocomplete-dropdown/gr-autocomplete-dropdown';
import {PaperInputElementExt} from '../../../types/types';
-import {CustomKeyboardEvent} from '../../../types/events';
import {fireEvent} from '../../../utils/event-util';
import {debounce, DelayedTask} from '../../../utils/async-util';
+import {PropertyType} from '../../../types/common';
+import {modifierPressed} from '../../../utils/dom-util';
const TOKENIZE_REGEX = /(?:[^\s"]+|"[^"]*")+/g;
const DEBOUNCE_WAIT_MS = 200;
@@ -40,9 +41,9 @@
};
}
-export type AutocompleteQuery = (
+export type AutocompleteQuery<T = string> = (
text: string
-) => Promise<AutocompleteSuggestion[]>;
+) => Promise<Array<AutocompleteSuggestion<T>>>;
declare global {
interface HTMLElementTagNameMap {
@@ -50,11 +51,11 @@
}
}
-export interface AutocompleteSuggestion {
+export interface AutocompleteSuggestion<T = string> {
name?: string;
label?: string;
- value?: string;
- text?: string;
+ value?: T;
+ text?: T;
}
export interface AutocompleteCommitEventDetail {
@@ -102,7 +103,7 @@
*
*/
@property({type: Object})
- query: AutocompleteQuery = () => Promise.resolve([]);
+ query?: AutocompleteQuery = () => Promise.resolve([]);
/**
* The number of characters that must be typed before suggestions are
@@ -298,6 +299,12 @@
if (this._disableSuggestions) {
return;
}
+
+ const query = this.query;
+ if (!query) {
+ return;
+ }
+
if (text.length < threshold) {
this.value = '';
return;
@@ -308,7 +315,7 @@
}
const update = () => {
- this.query(text).then(suggestions => {
+ query(text).then(suggestions => {
if (text !== this.text) {
// Late response.
return;
@@ -351,7 +358,7 @@
* _handleKeydown used for key handling in the this.$.input AND all child
* autocomplete options.
*/
- _handleKeydown(e: CustomKeyboardEvent) {
+ _handleKeydown(e: KeyboardEvent) {
this._focused = true;
switch (e.keyCode) {
case 38: // Up
@@ -376,7 +383,7 @@
}
break;
case 13: // Enter
- if (this.modifierPressed(e)) {
+ if (modifierPressed(e)) {
break;
}
e.preventDefault();
@@ -505,3 +512,24 @@
return showSearchIcon ? 'showSearchIcon' : '';
}
}
+
+/**
+ * Often gr-autocomplete is used for BranchName, RepoName, etc...
+ * GrTypedAutocomplete allows to define more precise typing in templates.
+ * For example, instead of
+ * $: {
+ * branchSelect: GrAutocomplete
+ * }
+ * you can write
+ * $: {
+ * branchSelect: GrTypedAutocomplete<BranchName>
+ * }
+ * And later user $.branchSelect.text without type conversion to BranchName.
+ */
+export interface GrTypedAutocomplete<
+ T extends PropertyType<GrAutocomplete, 'text'>
+> extends GrAutocomplete {
+ text: T;
+ value: T;
+ query?: AutocompleteQuery<T>;
+}
diff --git a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.ts b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.ts
index bb70855..b3c485a 100644
--- a/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-avatar/gr-avatar_test.ts
@@ -24,6 +24,7 @@
import {
createAccountWithEmail,
createAccountWithId,
+ createServerInfo,
} from '../../../test/test-data-generators';
const basicFixture = fixtureFromElement('gr-avatar');
@@ -116,9 +117,11 @@
suite('config set', () => {
setup(() => {
- stub('gr-avatar', '_getConfig').callsFake(() =>
- Promise.resolve({plugin: {has_avatars: true}})
- );
+ const config = {
+ ...createServerInfo(),
+ plugin: {has_avatars: true, js_resource_paths: []},
+ };
+ stub('gr-avatar', '_getConfig').returns(Promise.resolve(config));
element = basicFixture.instantiate();
});
@@ -154,9 +157,11 @@
let element: GrAvatar;
setup(() => {
- stub('gr-avatar', '_getConfig').callsFake(() =>
- Promise.resolve({plugin: {has_avatars: true}})
- );
+ const config = {
+ ...createServerInfo(),
+ plugin: {has_avatars: true, js_resource_paths: []},
+ };
+ stub('gr-avatar', '_getConfig').returns(Promise.resolve(config));
element = basicFixture.instantiate();
});
@@ -182,7 +187,7 @@
let element: GrAvatar;
setup(() => {
- stub('gr-avatar', '_getConfig').callsFake(() => Promise.resolve({}));
+ stub('gr-avatar', '_getConfig').returns(Promise.resolve(undefined));
element = basicFixture.instantiate();
});
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
index 1ece10a..8dc23e2 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button.ts
@@ -15,21 +15,13 @@
* limitations under the License.
*/
import '@polymer/paper-button/paper-button';
-import '../../../styles/shared-styles';
-import '../../../styles/gr-voting-styles';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {customElement, property, computed, observe} from '@polymer/decorators';
-import {htmlTemplate} from './gr-button_html';
-import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
-import {
- PolymerEvent,
- getEventPath,
- getKeyboardEvent,
- isModifierPressed,
-} from '../../../utils/dom-util';
+import {spinnerStyles} from '../../../styles/gr-spinner-styles';
+import {votingStyles} from '../../../styles/gr-voting-styles';
+import {css, html, LitElement, PropertyValues} from 'lit';
+import {customElement, property} from 'lit/decorators';
+import {getEventPath, modifierPressed} from '../../../utils/dom-util';
import {appContext} from '../../../services/app-context';
import {ReportingService} from '../../../services/gr-reporting/gr-reporting';
-import {CustomKeyboardEvent} from '../../../types/events';
declare global {
interface HTMLElementTagNameMap {
@@ -37,87 +29,208 @@
}
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
@customElement('gr-button')
-export class GrButton extends base {
- static get template() {
- return htmlTemplate;
- }
+export class GrButton extends LitElement {
+ private readonly reporting: ReportingService = appContext.reportingService;
/**
* Should this button be rendered as a vote chip? Then we are applying
* the .voteChip class (see gr-voting-styles) to the paper-button.
*/
- @property({type: Boolean, reflectToAttribute: true})
+ @property({type: Boolean, reflect: true})
voteChip = false;
- @property({type: Boolean, reflectToAttribute: true})
- downArrow = false;
-
- @property({type: Boolean, reflectToAttribute: true})
- link = false;
-
- @property({type: Boolean})
- noUppercase = false;
-
- @property({type: Boolean, reflectToAttribute: true})
- loading = false;
-
- @property({type: Boolean, reflectToAttribute: true})
- disabled: boolean | null = null;
-
- @property({type: String})
- tooltip = '';
-
// Note: don't assign a value to this, since constructor is called
// after created, the initial value maybe overridden by this
- @property({type: String})
- _initialTabindex?: string;
+ private initialTabindex?: string;
- @computed('disabled', 'loading')
- get _disabled() {
- return this.disabled || this.loading;
+ @property({type: Boolean, reflect: true, attribute: 'down-arrow'})
+ downArrow = false;
+
+ @property({type: Boolean, reflect: true})
+ link = false;
+
+ @property({type: Boolean, reflect: true})
+ loading = false;
+
+ @property({type: Boolean, reflect: true})
+ disabled: boolean | null = null;
+
+ static override get styles() {
+ return [
+ votingStyles,
+ spinnerStyles,
+ css`
+ /* general styles for all buttons */
+ :host {
+ --background-color: var(
+ --button-background-color,
+ var(--default-button-background-color)
+ );
+ --text-color: var(
+ --gr-button-text-color,
+ var(--default-button-text-color)
+ );
+ display: inline-block;
+ position: relative;
+ }
+ :host([hidden]) {
+ display: none;
+ }
+ :host([no-uppercase]) paper-button {
+ text-transform: none;
+ }
+ paper-button {
+ /* paper-button sets this to anti-aliased, which appears different than
+ bold font elsewhere on macOS. */
+ -webkit-font-smoothing: initial;
+ align-items: center;
+ background-color: var(--background-color);
+ color: var(--text-color);
+ display: flex;
+ font-family: inherit;
+ justify-content: center;
+ margin: var(--margin, 0);
+ min-width: var(--border, 0);
+ padding: var(--gr-button-padding, var(--spacing-s) var(--spacing-m));
+ }
+ paper-button[elevation='1'] {
+ box-shadow: var(--elevation-level-1);
+ }
+ paper-button[elevation='2'] {
+ box-shadow: var(--elevation-level-2);
+ }
+ paper-button[elevation='3'] {
+ box-shadow: var(--elevation-level-3);
+ }
+ paper-button[elevation='4'] {
+ box-shadow: var(--elevation-level-4);
+ }
+ paper-button[elevation='5'] {
+ box-shadow: var(--elevation-level-5);
+ }
+ paper-button:hover {
+ background: linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.12)),
+ var(--background-color);
+ }
+
+ /* Some mobile browsers treat focused element as hovered element.
+ As a result, element remains hovered after click (has grey background in default theme).
+ Use @media (hover:none) to remove background if
+ user's primary input mechanism can't hover over elements.
+ See: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover
+
+ Note 1: not all browsers support this media query
+ (see https://caniuse.com/#feat=css-media-interaction).
+ If browser doesn't support it, then the whole content of @media .. is ignored.
+ This is why the default behavior is placed outside of @media.
+ */
+ @media (hover: none) {
+ paper-button:hover {
+ background: transparent;
+ }
+ }
+
+ :host([primary]) {
+ --background-color: var(--primary-button-background-color);
+ --text-color: var(--primary-button-text-color);
+ }
+ :host([link][primary]) {
+ --text-color: var(--primary-button-background-color);
+ }
+
+ /* Keep below color definition for primary so that this takes precedence
+ when disabled. */
+ :host([disabled]),
+ :host([loading]) {
+ --background-color: var(--disabled-button-background-color);
+ --text-color: var(--deemphasized-text-color);
+ cursor: default;
+ }
+
+ /* Styles for link buttons specifically */
+ :host([link]) {
+ --background-color: transparent;
+ --margin: 0;
+ }
+ :host([link]) paper-button {
+ padding: var(--gr-button-padding, var(--spacing-s));
+ }
+ :host([disabled][link]),
+ :host([loading][link]) {
+ --background-color: transparent;
+ --text-color: var(--deemphasized-text-color);
+ cursor: default;
+ }
+
+ /* Styles for the optional down arrow */
+ :host(:not([down-arrow])) .downArrow {
+ display: none;
+ }
+ :host([down-arrow]) .downArrow {
+ border-top: 0.36em solid #ccc;
+ border-left: 0.36em solid transparent;
+ border-right: 0.36em solid transparent;
+ margin-bottom: var(--spacing-xxs);
+ margin-left: var(--spacing-m);
+ transition: border-top-color 200ms;
+ }
+ :host([down-arrow]) paper-button:hover .downArrow {
+ border-top-color: var(--deemphasized-text-color);
+ }
+ `,
+ ];
}
- @property({
- computed: 'computeAriaDisabled(disabled, loading)',
- reflectToAttribute: true,
- type: String,
- })
- ariaDisabled!: string;
-
- computeAriaDisabled() {
- return this._disabled ? 'true' : 'false';
+ override render() {
+ return html`<paper-button
+ ?raised="${!this.link}"
+ ?disabled="${this.disabled || this.loading}"
+ role="button"
+ tabindex="-1"
+ part="paper-button"
+ class="${this.voteChip ? 'voteChip' : ''}"
+ >
+ ${this.loading ? html`<span class="loadingSpin"></span>` : ''}
+ <slot></slot>
+ <i class="downArrow"></i>
+ </paper-button>`;
}
- computePaperButtonClass(voteChip?: boolean) {
- return voteChip ? 'voteChip' : '';
- }
-
- private readonly reporting: ReportingService = appContext.reportingService;
-
constructor() {
super();
- this._initialTabindex = this.getAttribute('tabindex') || '0';
- // TODO(TS): try avoid using unknown
- this.addEventListener('click', e =>
- this._handleAction(e as unknown as PolymerEvent)
- );
- this.addEventListener('keydown', e =>
- this._handleKeydown(e as unknown as CustomKeyboardEvent)
- );
+ this.initialTabindex = this.getAttribute('tabindex') || '0';
+ this.addEventListener('click', e => this._handleAction(e));
+ this.addEventListener('keydown', e => this._handleKeydown(e));
}
- override ready() {
- super.ready();
- this._ensureAttribute('role', 'button');
- this._ensureAttribute('tabindex', '0');
+ override updated(changedProperties: PropertyValues) {
+ if (changedProperties.has('disabled')) {
+ this.setAttribute(
+ 'tabindex',
+ this.disabled ? '-1' : this.initialTabindex || '0'
+ );
+ }
+ if (changedProperties.has('loading') || changedProperties.has('disabled')) {
+ this.setAttribute(
+ 'aria-disabled',
+ this.disabled || this.loading ? 'true' : 'false'
+ );
+ }
}
- _handleAction(e: PolymerEvent) {
- if (this._disabled) {
+ override connectedCallback() {
+ super.connectedCallback();
+ if (!this.getAttribute('role')) {
+ this.setAttribute('role', 'button');
+ }
+ if (!this.getAttribute('tabindex')) {
+ this.setAttribute('tabindex', '0');
+ }
+ }
+
+ _handleAction(e: MouseEvent) {
+ if (this.disabled || this.loading) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
@@ -127,20 +240,8 @@
this.reporting.reportInteraction('button-click', {path: getEventPath(e)});
}
- @observe('disabled')
- _disabledChanged(disabled: boolean) {
- this.setAttribute(
- 'tabindex',
- disabled ? '-1' : this._initialTabindex || '0'
- );
- this.updateStyles();
- }
-
- _handleKeydown(e: CustomKeyboardEvent) {
- if (isModifierPressed(e)) {
- return;
- }
- e = getKeyboardEvent(e);
+ _handleKeydown(e: KeyboardEvent) {
+ if (modifierPressed(e)) return;
// Handle `enter`, `space`.
if (e.keyCode === 13 || e.keyCode === 32) {
e.preventDefault();
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button_html.ts b/polygerrit-ui/app/elements/shared/gr-button/gr-button_html.ts
deleted file mode 100644
index 22ec2f4..0000000
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button_html.ts
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style include="gr-voting-styles">
- /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
- </style>
- <style include="gr-spinner-styles">
- /* general styles for all buttons */
- :host {
- --background-color: var(
- --button-background-color,
- var(--default-button-background-color)
- );
- --text-color: var(--default-button-text-color);
- display: inline-block;
- position: relative;
- }
- :host([hidden]) {
- display: none;
- }
- :host([no-uppercase]) paper-button {
- text-transform: none;
- }
- paper-button {
- /* The next lines contains a copy of paper-button style.
- Without a copy, the @apply works incorrectly with Polymer 2.
- @apply is deprecated and is not recommended to use. It is expected
- that @apply will be replaced with the ::part CSS pseudo-element.
- After replacement copied lines can be removed.
- */
- @apply --layout-inline;
- @apply --layout-center-center;
- position: relative;
- box-sizing: border-box;
- min-width: 5.14em;
- margin: 0 0.29em;
- background: transparent;
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
- -webkit-tap-highlight-color: transparent;
- font: inherit;
- text-transform: uppercase;
- outline-width: 0;
- border-top-left-radius: var(--border-radius);
- border-top-right-radius: var(--border-radius);
- border-bottom-right-radius: var(--border-radius);
- border-bottom-left-radius: var(--border-radius);
- -moz-user-select: none;
- -ms-user-select: none;
- -webkit-user-select: none;
- user-select: none;
- cursor: pointer;
- z-index: 0;
- padding: var(--spacing-m);
-
- @apply --paper-font-common-base;
- @apply --paper-button;
- /* End of copy*/
-
- /* paper-button sets this to anti-aliased, which appears different than
- bold font elsewhere on macOS. */
- -webkit-font-smoothing: initial;
- align-items: center;
- background-color: var(--background-color);
- color: var(--text-color);
- display: flex;
- font-family: inherit;
- justify-content: center;
- margin: var(--margin, 0);
- min-width: var(--border, 0);
- padding: var(--padding, 4px 8px);
- @apply --gr-button;
- }
- /* https://github.com/PolymerElements/paper-button/blob/2.x/paper-button.html */
- /* BEGIN: Copy from paper-button */
- paper-button[elevation='1'] {
- @apply --paper-material-elevation-1;
- }
- paper-button[elevation='2'] {
- @apply --paper-material-elevation-2;
- }
- paper-button[elevation='3'] {
- @apply --paper-material-elevation-3;
- }
- paper-button[elevation='4'] {
- @apply --paper-material-elevation-4;
- }
- paper-button[elevation='5'] {
- @apply --paper-material-elevation-5;
- }
- /* END: Copy from paper-button */
- paper-button:hover {
- background: linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.12)),
- var(--background-color);
- }
-
- /* Some mobile browsers treat focused element as hovered element.
- As a result, element remains hovered after click (has grey background in default theme).
- Use @media (hover:none) to remove background if
- user's primary input mechanism can't hover over elements.
- See: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hover
-
- Note 1: not all browsers support this media query
- (see https://caniuse.com/#feat=css-media-interaction).
- If browser doesn't support it, then the whole content of @media .. is ignored.
- This is why the default behavior is placed outside of @media.
- */
- @media (hover: none) {
- paper-button:hover {
- background: transparent;
- }
- }
-
- :host([primary]) {
- --background-color: var(--primary-button-background-color);
- --text-color: var(--primary-button-text-color);
- }
- :host([link][primary]) {
- --text-color: var(--primary-button-background-color);
- }
-
- /* Keep below color definition for primary so that this takes precedence
- when disabled. */
- :host([disabled]),
- :host([loading]) {
- --background-color: var(--disabled-button-background-color);
- --text-color: var(--deemphasized-text-color);
- cursor: default;
- }
-
- /* Styles for link buttons specifically */
- :host([link]) {
- --background-color: transparent;
- --margin: 0;
- --padding: var(--spacing-s);
- }
- :host([disabled][link]),
- :host([loading][link]) {
- --background-color: transparent;
- --text-color: var(--deemphasized-text-color);
- cursor: default;
- }
-
- /* Styles for the optional down arrow */
- :host(:not([down-arrow])) .downArrow {
- display: none;
- }
- :host([down-arrow]) .downArrow {
- border-top: 0.36em solid #ccc;
- border-left: 0.36em solid transparent;
- border-right: 0.36em solid transparent;
- margin-bottom: var(--spacing-xxs);
- margin-left: var(--spacing-m);
- transition: border-top-color 200ms;
- }
- :host([down-arrow]) paper-button:hover .downArrow {
- border-top-color: var(--deemphasized-text-color);
- }
- </style>
- <paper-button
- raised="[[!link]]"
- disabled="[[_disabled]]"
- tabindex="-1"
- part="paper-button"
- class$="[[computePaperButtonClass(voteChip)]]"
- >
- <template is="dom-if" if="[[loading]]">
- <span class="loadingSpin"></span>
- </template>
- <slot></slot>
- <i class="downArrow"></i>
- </paper-button>
-`;
diff --git a/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts b/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
index f0f122a..0149bd5 100644
--- a/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-button/gr-button_test.ts
@@ -17,6 +17,7 @@
import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
import '../../../test/common-test-setup-karma';
+import './gr-button';
import {addListener} from '@polymer/polymer/lib/utils/gestures';
import {appContext} from '../../../services/app-context';
import {html} from '@polymer/polymer/lib/utils/html-tag';
@@ -49,23 +50,26 @@
return spy;
};
- setup(() => {
+ setup(async () => {
element = basicFixture.instantiate();
+ await element.updateComplete;
});
- test('disabled is set by disabled', () => {
+ test('disabled is set by disabled', async () => {
const paperBtn = queryAndAssert<PaperButtonElement>(
element,
'paper-button'
);
assert.isFalse(paperBtn.disabled);
element.disabled = true;
+ await element.updateComplete;
assert.isTrue(paperBtn.disabled);
element.disabled = false;
+ await element.updateComplete;
assert.isFalse(paperBtn.disabled);
});
- test('loading set from listener', () => {
+ test('loading set from listener', async () => {
let resolve: Function;
element.addEventListener('click', e => {
const target = e.target as HTMLElement;
@@ -78,36 +82,44 @@
);
assert.isFalse(paperBtn.disabled);
MockInteractions.tap(element);
+ await element.updateComplete;
assert.isTrue(paperBtn.disabled);
assert.isTrue(element.hasAttribute('loading'));
resolve!();
- flush();
+ await element.updateComplete;
assert.isFalse(paperBtn.disabled);
assert.isFalse(element.hasAttribute('loading'));
});
- test('tabindex should be -1 if disabled', () => {
+ test('tabindex should be -1 if disabled', async () => {
element.disabled = true;
- assert.isTrue(element.getAttribute('tabindex') === '-1');
+ await element.updateComplete;
+ assert.equal(element.getAttribute('tabindex'), '-1');
});
// Regression tests for Issue: 11969
- test('tabindex should be reset to 0 if enabled', () => {
+ test('tabindex should be reset to 0 if enabled', async () => {
element.disabled = false;
+ await element.updateComplete;
assert.equal(element.getAttribute('tabindex'), '0');
element.disabled = true;
+ await element.updateComplete;
assert.equal(element.getAttribute('tabindex'), '-1');
element.disabled = false;
+ await element.updateComplete;
assert.equal(element.getAttribute('tabindex'), '0');
});
- test('tabindex should be preserved', () => {
+ test('tabindex should be preserved', async () => {
const tabIndexElement = tabindexFixture.instantiate() as GrButton;
tabIndexElement.disabled = false;
+ await element.updateComplete;
assert.equal(tabIndexElement.getAttribute('tabindex'), '3');
tabIndexElement.disabled = true;
+ await element.updateComplete;
assert.equal(tabIndexElement.getAttribute('tabindex'), '-1');
tabIndexElement.disabled = false;
+ await element.updateComplete;
assert.equal(tabIndexElement.getAttribute('tabindex'), '3');
});
@@ -152,8 +164,9 @@
}
suite('disabled', () => {
- setup(() => {
+ setup(async () => {
element.disabled = true;
+ await element.updateComplete;
});
for (const eventName of ['tap', 'click']) {
diff --git a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
index 5069ba4..a23621e 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
+++ b/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.ts
@@ -21,6 +21,11 @@
import {customElement, property} from '@polymer/decorators';
import {ChangeInfo} from '../../../types/common';
import {fireAlert} from '../../../utils/event-util';
+import {
+ Shortcut,
+ ShortcutSection,
+} from '../../../services/shortcuts/shortcuts-config';
+import {appContext} from '../../../services/app-context';
declare global {
interface HTMLElementTagNameMap {
@@ -48,6 +53,8 @@
@property({type: Object, notify: true})
change?: ChangeInfo;
+ private readonly shortcuts = appContext.shortcutsService;
+
_computeStarClass(starred?: boolean) {
return starred ? 'active' : '';
}
@@ -83,4 +90,8 @@
})
);
}
+
+ createTitle(shortcutName: Shortcut, section: ShortcutSection) {
+ return this.shortcuts.createTitle(shortcutName, section);
+ }
}
diff --git a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_html.ts b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_html.ts
index 2ca2744b..455bd4e 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_html.ts
@@ -80,8 +80,8 @@
}
</style>
<gr-tooltip-content
- has-tooltip=""
- position-below=""
+ has-tooltip
+ position-below
title="[[tooltipText]]"
max-width="40em"
>
@@ -101,9 +101,8 @@
</a>
</template>
<template is="dom-if" if="[[!hasStatusLink(revertedChange, resolveWeblinks, status)]]">
- <div class="chip" aria-label$="Label: [[status]]">
- [[_computeStatusString(status)]]
- </div>
+ <div class="chip" aria-label$="Label: [[status]]"
+ >[[_computeStatusString(status)]]</div>
</template>
</gr-tooltip-content>
</span>
diff --git a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_test.ts b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_test.ts
index a56f6f1..39fc7c6 100644
--- a/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-change-status/gr-change-status_test.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import sinon from 'sinon/pkg/sinon-esm';
import '../../../test/common-test-setup-karma';
import {createChange} from '../../../test/test-data-generators';
import './gr-change-status';
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
index 39a87a2..f1b74ac 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
@@ -14,9 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import '../../../styles/gr-a11y-styles';
import '../../../styles/shared-styles';
import '../gr-comment/gr-comment';
import '../../diff/gr-diff/gr-diff';
+import '../gr-copy-clipboard/gr-copy-clipboard';
import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-comment-thread_html';
import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
@@ -29,6 +31,7 @@
UIComment,
UIDraft,
UIRobot,
+ DraftInfo,
} from '../../../utils/comment-util';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {appContext} from '../../../services/app-context';
@@ -51,11 +54,12 @@
} from '../../../types/common';
import {GrComment} from '../gr-comment/gr-comment';
import {PolymerDeepPropertyChange} from '@polymer/polymer/interfaces';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {LineNumber, FILE} from '../../diff/gr-diff/gr-diff-line';
import {GrButton} from '../gr-button/gr-button';
+import {KnownExperimentId} from '../../../services/flags/flags';
import {DiffInfo, DiffPreferencesInfo} from '../../../types/diff';
-import {RenderPreferences} from '../../../api/diff';
+import {DiffLayer, RenderPreferences} from '../../../api/diff';
import {
check,
assertIsDefined,
@@ -203,6 +207,9 @@
@property({type: Object})
_selfAccount?: AccountDetailInfo;
+ @property({type: Array})
+ layers: DiffLayer[] = [];
+
get keyBindings() {
return {
'e shift+e': '_handleEKey',
@@ -211,6 +218,8 @@
private readonly reporting = appContext.reportingService;
+ private readonly flagsService = appContext.flagsService;
+
private readonly commentsService = appContext.commentsService;
readonly storage = appContext.storageService;
@@ -219,11 +228,16 @@
readonly restApiService = appContext.restApiService;
+ private readonly shortcuts = appContext.shortcutsService;
+
constructor() {
super();
this.addEventListener('comment-update', e =>
this._handleCommentUpdate(e as CustomEvent)
);
+ appContext.restApiService.getPreferences().then(prefs => {
+ this._initLayers(!!prefs?.disable_token_highlighting);
+ });
}
override connectedCallback() {
@@ -339,7 +353,8 @@
return GerritNav.getUrlForComment(changeNum, projectName, id);
}
- getHighlightRange() {
+ /** The parameter is for triggering re-computation only. */
+ getHighlightRange(_: unknown) {
const comment = this.comments?.[0];
if (!comment) return undefined;
if (comment.range) return comment.range;
@@ -354,21 +369,23 @@
return undefined;
}
- _getLayers(diff?: DiffInfo) {
- if (!diff) return [];
- const layers = [];
- layers.push(new TokenHighlightLayer(this));
- layers.push(this.syntaxLayer);
- return layers;
+ _initLayers(disableTokenHighlighting: boolean) {
+ if (
+ this.flagsService.isEnabled(KnownExperimentId.TOKEN_HIGHLIGHTING) &&
+ !disableTokenHighlighting
+ ) {
+ this.layers.push(new TokenHighlightLayer(this));
+ }
+ this.layers.push(this.syntaxLayer);
}
_getUrlForViewDiff(
comments: UIComment[],
changeNum?: NumericChangeId,
projectName?: RepoName
- ) {
- if (!changeNum) return;
- if (!projectName) return;
+ ): string {
+ if (!changeNum) return '';
+ if (!projectName) return '';
check(comments.length > 0, 'comment not found');
return GerritNav.getUrlForComment(changeNum, projectName, comments[0].id!);
}
@@ -414,7 +431,7 @@
});
}
- _isPatchsetLevelComment(path: string) {
+ _isPatchsetLevelComment(path?: string) {
return path === SpecialFilePath.PATCHSET_LEVEL_COMMENTS;
}
@@ -423,7 +440,7 @@
return this.showPortedComment && comment.id === this._orderedComments[0].id;
}
- _computeDisplayPath(path: string) {
+ _computeDisplayPath(path?: string) {
const displayPath = computeDisplayPath(path);
if (displayPath === SpecialFilePath.PATCHSET_LEVEL_COMMENTS) {
return 'Patchset';
@@ -482,8 +499,8 @@
return this._orderedComments[this._orderedComments.length - 1] || {};
}
- _handleEKey(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) {
+ _handleEKey(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) {
return;
}
@@ -547,14 +564,23 @@
if (isEditing) {
reply.__editing = true;
- }
-
- this.commentsService.addDraft(reply);
-
- if (!isEditing) {
+ this.commentsService.addDraft(reply);
+ } else {
assertIsDefined(this.changeNum, 'changeNum');
assertIsDefined(this.patchNum, 'patchNum');
- this.restApiService.saveDiffDraft(this.changeNum, this.patchNum, reply);
+ this.restApiService
+ .saveDiffDraft(this.changeNum, this.patchNum, reply)
+ .then(result => {
+ if (!result.ok) {
+ fireAlert(document, 'Unable to restore draft');
+ return;
+ }
+ this.restApiService.getResponseObject(result).then(obj => {
+ const resComment = obj as unknown as DraftInfo;
+ resComment.patch_set = reply.patch_set;
+ this.commentsService.addDraft(resComment);
+ });
+ });
}
}
@@ -729,7 +755,8 @@
return -1;
}
- _computeHostClass(unresolved?: boolean) {
+ /** 2nd parameter is for triggering re-computation only. */
+ _computeHostClass(unresolved?: boolean, _?: unknown) {
if (this.isRobotComment) {
return 'robotComment';
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
index bf9a9dc..c3faaa5 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_html.ts
@@ -17,6 +17,9 @@
import {html} from '@polymer/polymer/lib/utils/html-tag';
export const htmlTemplate = html`
+ <style include="gr-a11y-styles">
+ /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
+ </style>
<style include="shared-styles">
:host {
font-family: var(--font-family);
@@ -113,6 +116,16 @@
top: 4px;
cursor: pointer;
}
+ .fileName gr-copy-clipboard {
+ display: inline-block;
+ visibility: hidden;
+ vertical-align: top;
+ --gr-button-padding: 0px;
+ }
+ .fileName:focus-within gr-copy-clipboard,
+ .fileName:hover gr-copy-clipboard {
+ visibility: visible;
+ }
</style>
<template is="dom-if" if="[[showFilePath]]">
@@ -127,6 +140,10 @@
>
[[_computeDisplayPath(path)]]
</a>
+ <gr-copy-clipboard
+ hideInput=""
+ text="[[_computeDisplayPath(path)]]"
+ ></gr-copy-clipboard>
</template>
</div>
</template>
@@ -229,7 +246,7 @@
id="diff"
change-num="[[changeNum]]"
diff="[[_diff]]"
- layers="[[_getLayers(_diff)]]"
+ layers="[[layers]]"
path="[[path]]"
prefs="[[_prefs]]"
render-prefs="[[_renderPrefs]]"
@@ -238,9 +255,7 @@
</gr-diff>
<div class="view-diff-container">
<a href="[[_getUrlForViewDiff(comments, changeNum, projectName)]]">
- <gr-button link class="view-diff-button" on-click="_handleViewDiff">
- View Diff
- </gr-button>
+ <gr-button link class="view-diff-button">View Diff</gr-button>
</a>
</div>
</div>
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
index ecd9731..06d25b3 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
@@ -315,58 +315,64 @@
let element: GrCommentThread;
let addDraftServiceStub: SinonStub;
let saveDiffDraftStub: SinonStub;
+ let comment = {
+ id: '7afa4931_de3d65bd',
+ path: '/path/to/file.txt',
+ line: 5,
+ in_reply_to: 'baf0414d_60047215' as UrlEncodedCommentId,
+ updated: '2015-12-21 02:01:10.850000000',
+ message: 'Done',
+ };
+ const peanutButterComment = {
+ author: {
+ name: 'Mr. Peanutbutter',
+ email: 'tenn1sballchaser@aol.com' as EmailAddress as EmailAddress,
+ },
+ id: 'baf0414d_60047215' as UrlEncodedCommentId,
+ line: 5,
+ in_reply_to: 'baf0414d_60047215' as UrlEncodedCommentId,
+ message: 'is this a crossover episode!?',
+ updated: '2015-12-08 19:48:33.843000000' as Timestamp,
+ path: '/path/to/file.txt',
+ unresolved: true,
+ patch_set: 3 as PatchSetNum,
+ };
+ const mockResponse: Response = {
+ ...new Response(),
+ headers: {} as Headers,
+ redirected: false,
+ status: 200,
+ statusText: '',
+ type: '' as ResponseType,
+ url: '',
+ ok: true,
+ text() {
+ return Promise.resolve(")]}'\n" + JSON.stringify(comment));
+ },
+ };
+ let saveDiffDraftPromiseResolver: (value?: Response) => void;
setup(() => {
addDraftServiceStub = stubComments('addDraft');
stubRestApi('getLoggedIn').returns(Promise.resolve(false));
saveDiffDraftStub = stubRestApi('saveDiffDraft').returns(
- Promise.resolve({
- headers: {} as Headers,
- redirected: false,
- status: 200,
- statusText: '',
- type: '' as ResponseType,
- url: '',
- ok: true,
- text() {
- return Promise.resolve(
- ")]}'\n" +
- JSON.stringify({
- id: '7afa4931_de3d65bd',
- path: '/path/to/file.txt',
- line: 5,
- in_reply_to: 'baf0414d_60047215' as UrlEncodedCommentId,
- updated: '2015-12-21 02:01:10.850000000',
- message: 'Done',
- })
- );
- },
- } as unknown as Response)
+ new Promise<Response>(
+ resolve =>
+ (saveDiffDraftPromiseResolver = resolve as (value?: Response) => void)
+ )
);
stubRestApi('deleteDiffDraft').returns(
- Promise.resolve({ok: true} as unknown as Response)
+ Promise.resolve({...new Response(), ok: true})
);
element = withCommentFixture.instantiate();
element.patchNum = 1 as PatchSetNum;
element.changeNum = 1 as NumericChangeId;
- element.comments = [
- {
- author: {
- name: 'Mr. Peanutbutter',
- email: 'tenn1sballchaser@aol.com' as EmailAddress as EmailAddress,
- },
- id: 'baf0414d_60047215' as UrlEncodedCommentId,
- line: 5,
- message: 'is this a crossover episode!?',
- updated: '2015-12-08 19:48:33.843000000' as Timestamp,
- path: '/path/to/file.txt',
- unresolved: true,
- patch_set: 3 as PatchSetNum,
- },
- ];
+ element.comments = [peanutButterComment];
flush();
});
test('reply', () => {
+ saveDiffDraftPromiseResolver(mockResponse);
+
const commentEl = element.shadowRoot?.querySelector('gr-comment');
const reportStub = stubReporting('recordDraftInteraction');
assert.ok(commentEl);
@@ -385,6 +391,8 @@
});
test('quote reply', () => {
+ saveDiffDraftPromiseResolver(mockResponse);
+
const commentEl = element.shadowRoot?.querySelector('gr-comment');
const reportStub = stubReporting('recordDraftInteraction');
assert.ok(commentEl);
@@ -394,6 +402,10 @@
flush();
const draft = addDraftServiceStub.firstCall.args[0];
+ // the quote reply is not autmatically saved so verify that id is not set
+ assert.isNotOk(draft.id);
+ // verify that the draft returned was not saved
+ assert.isNotOk(saveDiffDraftStub.called);
assert.equal(draft.message, '> is this a crossover episode!?\n\n');
assert.equal(
draft.in_reply_to,
@@ -403,6 +415,7 @@
});
test('quote reply multiline', () => {
+ saveDiffDraftPromiseResolver(mockResponse);
const reportStub = stubReporting('recordDraftInteraction');
element.comments = [
{
@@ -436,6 +449,15 @@
});
test('ack', async () => {
+ saveDiffDraftPromiseResolver(mockResponse);
+ comment = {
+ id: '7afa4931_de3d65bd',
+ path: '/path/to/file.txt',
+ line: 5,
+ in_reply_to: 'baf0414d_60047215' as UrlEncodedCommentId,
+ updated: '2015-12-21 02:01:10.850000000',
+ message: 'Ack',
+ };
const reportStub = stubReporting('recordDraftInteraction');
element.changeNum = 42 as NumericChangeId;
element.patchNum = 1 as PatchSetNum;
@@ -450,11 +472,20 @@
const draft = addDraftServiceStub.firstCall.args[0];
assert.equal(draft.message, 'Ack');
assert.equal(draft.in_reply_to, 'baf0414d_60047215' as UrlEncodedCommentId);
- assert.equal(draft.unresolved, false);
+ assert.isNotOk(draft.unresolved);
assert.isTrue(reportStub.calledOnce);
});
test('done', async () => {
+ saveDiffDraftPromiseResolver(mockResponse);
+ comment = {
+ id: '7afa4931_de3d65bd',
+ path: '/path/to/file.txt',
+ line: 5,
+ in_reply_to: 'baf0414d_60047215' as UrlEncodedCommentId,
+ updated: '2015-12-21 02:01:10.850000000',
+ message: 'Done',
+ };
const reportStub = stubReporting('recordDraftInteraction');
assert.isFalse(saveDiffDraftStub.called);
element.changeNum = 42 as NumericChangeId;
@@ -467,14 +498,18 @@
tap(doneBtn!);
await flush();
const draft = addDraftServiceStub.firstCall.args[0];
+ // Since the reply is automatically saved, verify that draft.id is set in
+ // the model
+ assert.equal(draft.id, '7afa4931_de3d65bd');
assert.equal(draft.message, 'Done');
assert.equal(draft.in_reply_to, 'baf0414d_60047215' as UrlEncodedCommentId);
- assert.isFalse(draft.unresolved);
+ assert.isNotOk(draft.unresolved);
assert.isTrue(reportStub.calledOnce);
assert.isTrue(saveDiffDraftStub.called);
});
test('save', async () => {
+ saveDiffDraftPromiseResolver(mockResponse);
element.changeNum = 42 as NumericChangeId;
element.patchNum = 1 as PatchSetNum;
element.path = '/path/to/file.txt';
@@ -488,13 +523,21 @@
});
test('please fix', async () => {
+ comment = peanutButterComment;
element.changeNum = 42 as NumericChangeId;
element.patchNum = 1 as PatchSetNum;
const commentEl = element.shadowRoot?.querySelector('gr-comment');
assert.ok(commentEl);
const promise = mockPromise();
- commentEl!.addEventListener('create-fix-comment', () => {
- const draft = addDraftServiceStub.firstCall.args[0];
+ commentEl!.addEventListener('create-fix-comment', async () => {
+ assert.isTrue(saveDiffDraftStub.called);
+ assert.isFalse(addDraftServiceStub.called);
+ saveDiffDraftPromiseResolver(mockResponse);
+ // flushing so the saveDiffDraftStub resolves and the draft is returned
+ await flush();
+ assert.isTrue(saveDiffDraftStub.called);
+ assert.isTrue(addDraftServiceStub.called);
+ const draft = saveDiffDraftStub.firstCall.args[2];
assert.equal(
draft.message,
'> is this a crossover episode!?\n\nPlease fix.'
@@ -506,6 +549,8 @@
assert.isTrue(draft.unresolved);
promise.resolve();
});
+ assert.isFalse(saveDiffDraftStub.called);
+ assert.isFalse(addDraftServiceStub.called);
commentEl!.dispatchEvent(
new CustomEvent('create-fix-comment', {
detail: {comment: commentEl!.comment},
@@ -839,6 +884,7 @@
stubRestApi('getLoggedIn').returns(Promise.resolve(false));
stubRestApi('saveDiffDraft').returns(
Promise.resolve({
+ ...new Response(),
ok: true,
text() {
return Promise.resolve(
@@ -853,10 +899,10 @@
})
);
},
- } as unknown as Response)
+ })
);
stubRestApi('deleteDiffDraft').returns(
- Promise.resolve({ok: true} as unknown as Response)
+ Promise.resolve({...new Response(), ok: true})
);
element = withCommentFixture.instantiate();
element.patchNum = 1 as PatchSetNum;
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 418cd0e..0d4ad8c 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -20,7 +20,6 @@
import '../../plugins/gr-endpoint-param/gr-endpoint-param';
import '../gr-button/gr-button';
import '../gr-dialog/gr-dialog';
-import '../gr-date-formatter/gr-date-formatter';
import '../gr-formatted-text/gr-formatted-text';
import '../gr-icons/gr-icons';
import '../gr-overlay/gr-overlay';
@@ -50,6 +49,7 @@
import {GrConfirmDeleteCommentDialog} from '../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog';
import {
isDraft,
+ isRobot,
UIComment,
UIDraft,
UIRobot,
@@ -215,7 +215,7 @@
projectConfig?: ConfigInfo;
@property({type: Boolean})
- robotButtonDisabled?: boolean;
+ robotButtonDisabled = false;
@property({type: Boolean})
_hasHumanReply?: boolean;
@@ -234,7 +234,7 @@
side?: string;
@property({type: Boolean})
- resolved?: boolean;
+ resolved = false;
// Intentional to share the object across instances.
@property({type: Object})
@@ -319,12 +319,13 @@
super.disconnectedCallback();
}
- _getAuthor(comment: UIComment) {
- return comment.author || this._selfAccount;
+ /** 2nd argument is for *triggering* the computation only. */
+ _getAuthor(comment?: UIComment, _?: unknown) {
+ return comment?.author || this._selfAccount;
}
- _getUrlForComment(comment: UIComment) {
- if (!this.changeNum || !this.projectName) return '';
+ _getUrlForComment(comment?: UIComment) {
+ if (!comment || !this.changeNum || !this.projectName) return '';
if (!comment.id) throw new Error('comment must have an id');
return GerritNav.getUrlForComment(
this.changeNum as NumericChangeId,
@@ -436,8 +437,8 @@
this._showRobotActions = showActions && isRobotComment;
}
- hasPublishedComment(comments: UIComment[]) {
- if (!comments.length) return false;
+ hasPublishedComment(comments?: UIComment[]) {
+ if (!comments?.length) return false;
return comments.length > 1 || !isDraft(comments[0]);
}
@@ -675,7 +676,13 @@
@observe('comment.message')
_commentMessageChanged(message: string) {
- this._messageText = message || '';
+ /*
+ * Only overwrite the message text user has typed if there is no existing
+ * text typed by the user. This prevents the bug where creating another
+ * comment triggered a recomputation of comments and the text written by
+ * the user was lost.
+ */
+ if (!this._messageText) this._messageText = message || '';
}
_messageTextChanged(_: string, oldValue: string) {
@@ -803,7 +810,7 @@
);
}
- _hasNoFix(comment: UIComment) {
+ _hasNoFix(comment?: UIComment) {
return !comment || !(comment as UIRobot).fix_suggestions;
}
@@ -1032,9 +1039,10 @@
return overlay.open();
}
- _computeHideRunDetails(comment: UIRobot, collapsed: boolean) {
+ _computeHideRunDetails(comment: UIComment | undefined, collapsed: boolean) {
if (!comment) return true;
- return !(comment.robot_id && comment.url && !collapsed);
+ if (!isRobot(comment)) return true;
+ return !comment.url || collapsed;
}
_closeOverlay(overlay?: GrOverlay | null) {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
index b00bf8b..b77c4b2 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_html.ts
@@ -89,10 +89,7 @@
justify-content: flex-end;
}
.rightActions gr-button {
- --gr-button: {
- height: 20px;
- padding: 0 var(--spacing-s);
- }
+ --gr-button-padding: 0 var(--spacing-s);
}
.editMessage {
display: none;
@@ -190,10 +187,8 @@
}
#deleteBtn {
display: none;
- --gr-button: {
- color: var(--deemphasized-text-color);
- padding: 0;
- }
+ --gr-button-text-color: var(--deemphasized-text-color);
+ --gr-button-padding: 0;
}
#deleteBtn.showDeleteButtons {
display: block;
@@ -275,10 +270,10 @@
</template>
<gr-tooltip-content
class="draftTooltip"
- has-tooltip=""
+ has-tooltip
title="[[_computeDraftTooltip(_unableToSave)]]"
max-width="20em"
- show-icon=""
+ show-icon
>
<span class="draftLabel">[[_computeDraftText(_unableToSave)]]</span>
</gr-tooltip-content>
@@ -313,7 +308,7 @@
<template is="dom-if" if="[[comment.updated]]">
<span class="date" tabindex="0" on-click="_handleAnchorClick">
<gr-date-formatter
- has-tooltip=""
+ withTooltip
date-str="[[comment.updated]]"
></gr-date-formatter>
</span>
@@ -321,7 +316,7 @@
<div class="show-hide" tabindex="0">
<label
class="show-hide"
- aria-label="[[_computeShowHideAriaLabel(collapsed)]]"
+ aria-label$="[[_computeShowHideAriaLabel(collapsed)]]"
>
<input
type="checkbox"
@@ -357,7 +352,7 @@
<div class="respectfulReviewTip">
<div>
<gr-tooltip-content
- has-tooltip=""
+ has-tooltip
title="Tips for respectful code reviews."
>
<iron-icon
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
index 54d8ee8..b963d4b 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.ts
@@ -52,7 +52,7 @@
createFixSuggestionInfo,
} from '../../../test/test-data-generators';
import {Timer} from '../../../services/gr-reporting/gr-reporting';
-import {SinonFakeTimers, SinonStubbedMember} from 'sinon/pkg/sinon-esm';
+import {SinonFakeTimers, SinonStubbedMember} from 'sinon';
import {CreateFixCommentEvent} from '../../../types/events';
import {DraftInfo, UIRobot} from '../../../utils/comment-util';
import {MockTimer} from '../../../services/gr-reporting/gr-reporting_mock';
@@ -217,6 +217,29 @@
assert.isTrue(storageStub.called);
});
+ test('comment message sets messageText only when empty', () => {
+ element.changeNum = 1 as NumericChangeId;
+ element.patchNum = 1 as PatchSetNum;
+ element._messageText = '';
+ element.comment = {
+ author: {
+ name: 'Mr. Peanutbutter',
+ email: 'tenn1sballchaser@aol.com' as EmailAddress,
+ },
+ line: 5,
+ path: 'test',
+ __editing: true,
+ __draft: true,
+ message: 'hello world',
+ };
+ // messageText was empty so overwrite the message now
+ assert.equal(element._messageText, 'hello world');
+
+ element.comment!.message = 'new message';
+ // messageText was already set so do not overwrite it
+ assert.equal(element._messageText, 'hello world');
+ });
+
test('_getPatchNum', () => {
element.side = 'PARENT';
element.patchNum = 1 as PatchSetNum;
diff --git a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
index 2e95bd0..01422a9 100644
--- a/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
+++ b/polygerrit-ui/app/elements/shared/gr-copy-clipboard/gr-copy-clipboard.ts
@@ -81,35 +81,24 @@
iron-icon {
color: var(--deemphasized-text-color);
vertical-align: top;
+ --iron-icon-height: 20px;
+ --iron-icon-width: 20px;
+ }
+ gr-button {
+ display: block;
+ --gr-button-padding: 2px;
}
`,
];
}
override render() {
- // To pass CSS mixins for @apply to Polymer components, they need to appear
- // in <style> inside the template.
- const customStyle = html`
- <style>
- iron-icon {
- --iron-icon-height: 20px;
- --iron-icon-width: 20px;
- }
- gr-button {
- --gr-button: {
- padding: 2px;
- }
- }
- </style>
- `;
- return html`${customStyle}
+ return html`
<div class="text">
<iron-input
class="copyText"
- type="text"
@click="${this._handleInputClick}"
- readonly=""
- bind-value=${this.text}
+ .bindValue=${this.text ?? ''}
>
<input
id="input"
@@ -118,22 +107,26 @@
type="text"
@click="${this._handleInputClick}"
readonly=""
- .value=${this.text}
+ .value=${this.text ?? ''}
part="text-container-style"
/>
</iron-input>
- <gr-button
- id="copy-clipboard-button"
- link=""
+ <gr-tooltip-content
?has-tooltip=${this.hasTooltip}
- class="copyToClipboard"
title="${ifDefined(this.buttonTitle)}"
- @click="${this._copyToClipboard}"
- aria-label="Click to copy to clipboard"
>
- <iron-icon id="icon" icon="gr-icons:content-copy"></iron-icon>
- </gr-button>
- </div> `;
+ <gr-button
+ id="copy-clipboard-button"
+ link=""
+ class="copyToClipboard"
+ @click="${this._copyToClipboard}"
+ aria-label="Click to copy to clipboard"
+ >
+ <iron-icon id="icon" icon="gr-icons:content-copy"></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>
+ </div>
+ `;
}
focusOnCopy() {
diff --git a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
index 9dce127..9f65dd4 100644
--- a/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
+++ b/polygerrit-ui/app/elements/shared/gr-cursor-manager/gr-cursor-manager.ts
@@ -179,9 +179,6 @@
private async getVisibleEntries(
filter?: (el: Element) => boolean
): Promise<IntersectionObserverEntry[]> {
- if (!this._isIntersectionObserverSupported()) {
- throw new Error('Intersection observing not supported');
- }
if (!this.stops) {
return [];
}
@@ -218,14 +215,6 @@
});
}
- _isIntersectionObserverSupported() {
- // The copy of this method exists in gr-app-element.js under the
- // name _isCursorManagerSupportMoveToVisibleLine
- // If you update this method, you must update gr-app-element.js
- // as well.
- return 'IntersectionObserver' in window;
- }
-
/**
* Set the cursor to an arbitrary stop - if the given element is not one of
* the stops, unset the cursor.
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
index a3800a8..99f9265 100644
--- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
+++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter.ts
@@ -14,11 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import '../../../styles/shared-styles';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-date-formatter_html';
-import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
-import {property, customElement} from '@polymer/decorators';
+import '../gr-tooltip-content/gr-tooltip-content';
+import {css, html, LitElement} from 'lit';
+import {customElement, property} from 'lit/decorators';
import {
parseDate,
fromNow,
@@ -75,17 +73,10 @@
}
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
@customElement('gr-date-formatter')
-export class GrDateFormatter extends base {
- static get template() {
- return htmlTemplate;
- }
-
- @property({type: String, notify: true})
- dateStr: string | null = null;
+export class GrDateFormatter extends LitElement {
+ @property({type: String})
+ dateStr: string | undefined = undefined;
@property({type: Boolean})
showDateAndTime = false;
@@ -95,30 +86,20 @@
* native browser tooltip.
*/
@property({type: Boolean})
- override hasTooltip = false;
+ withTooltip = false;
@property({type: Boolean})
showYesterday = false;
- /**
- * The title to be used as the native tooltip or by the tooltip behavior.
- */
- @property({
- type: String,
- reflectToAttribute: true,
- computed: '_computeFullDateStr(dateStr, _timeFormat, _dateFormat)',
- })
- override title = '';
-
/** @type {?{short: string, full: string}} */
@property({type: Object})
- _dateFormat?: DateFormatPair;
+ private dateFormat?: DateFormatPair;
@property({type: String})
- _timeFormat?: string;
+ private timeFormat?: string;
@property({type: Boolean})
- _relative = false;
+ private relative = false;
@property({type: Boolean})
forceRelative = false;
@@ -132,76 +113,110 @@
super();
}
+ static override get styles() {
+ return [
+ css`
+ host {
+ color: inherit;
+ display: inline;
+ }
+ `,
+ ];
+ }
+
+ override render() {
+ if (!this.withTooltip) {
+ return this.renderDateString();
+ }
+
+ const fullDateStr = this.computeFullDateStr();
+ if (!fullDateStr) {
+ return this.renderDateString();
+ }
+ return html`
+ <gr-tooltip-content has-tooltip title=${fullDateStr}>
+ ${this.renderDateString()}
+ </gr-tooltip-content>
+ `;
+ }
+
+ private renderDateString() {
+ return html` <span>${this._computeDateStr()}</span>`;
+ }
+
override connectedCallback() {
super.connectedCallback();
this._loadPreferences();
}
+ // private but used by tests
_getUtcOffsetString() {
return utcOffsetString();
}
+ // private but used by tests
_loadPreferences() {
return this._getLoggedIn().then(loggedIn => {
if (!loggedIn) {
- this._timeFormat = TimeFormats.TIME_24;
- this._dateFormat = DateFormats.STD;
- this._relative = this.forceRelative;
+ this.timeFormat = TimeFormats.TIME_24;
+ this.dateFormat = DateFormats.STD;
+ this.relative = this.forceRelative;
return;
}
- return Promise.all([this._loadTimeFormat(), this._loadRelative()]);
+ return Promise.all([this._loadTimeFormat(), this.loadRelative()]);
});
}
+ // private but used in gr/file-list_test.js
_loadTimeFormat() {
- return this._getPreferences().then(preferences => {
+ return this.getPreferences().then(preferences => {
if (!preferences) {
throw Error('Preferences is not set');
}
- this._decideTimeFormat(preferences.time_format);
- this._decideDateFormat(preferences.date_format);
+ this.decideTimeFormat(preferences.time_format);
+ this.decideDateFormat(preferences.date_format);
});
}
- _decideTimeFormat(timeFormat: TimeFormat) {
+ private decideTimeFormat(timeFormat: TimeFormat) {
switch (timeFormat) {
case TimeFormat.HHMM_12:
- this._timeFormat = TimeFormats.TIME_12;
+ this.timeFormat = TimeFormats.TIME_12;
break;
case TimeFormat.HHMM_24:
- this._timeFormat = TimeFormats.TIME_24;
+ this.timeFormat = TimeFormats.TIME_24;
break;
default:
assertNever(timeFormat, `Invalid time format: ${timeFormat}`);
}
}
- _decideDateFormat(dateFormat: DateFormat) {
+ private decideDateFormat(dateFormat: DateFormat) {
switch (dateFormat) {
case DateFormat.STD:
- this._dateFormat = DateFormats.STD;
+ this.dateFormat = DateFormats.STD;
break;
case DateFormat.US:
- this._dateFormat = DateFormats.US;
+ this.dateFormat = DateFormats.US;
break;
case DateFormat.ISO:
- this._dateFormat = DateFormats.ISO;
+ this.dateFormat = DateFormats.ISO;
break;
case DateFormat.EURO:
- this._dateFormat = DateFormats.EURO;
+ this.dateFormat = DateFormats.EURO;
break;
case DateFormat.UK:
- this._dateFormat = DateFormats.UK;
+ this.dateFormat = DateFormats.UK;
break;
default:
assertNever(dateFormat, `Invalid date format: ${dateFormat}`);
}
}
- _loadRelative() {
- return this._getPreferences().then(prefs => {
+ private loadRelative() {
+ return this.getPreferences().then(prefs => {
// prefs.relative_date_in_change_table is not set when false.
- this._relative =
+ this.relative =
this.forceRelative || !!(prefs && prefs.relative_date_in_change_table);
});
}
@@ -210,70 +225,60 @@
return this.restApiService.getLoggedIn();
}
- _getPreferences() {
+ private getPreferences() {
return this.restApiService.getPreferences();
}
- _computeDateStr(
- dateStr?: Timestamp,
- timeFormat?: string,
- dateFormat?: DateFormatPair,
- relative?: boolean,
- showDateAndTime?: boolean,
- showYesterday?: boolean
- ) {
- if (!dateStr || !timeFormat || !dateFormat) {
+ // private but used by tests
+ _computeDateStr() {
+ if (!this.dateStr || !this.timeFormat || !this.dateFormat) {
return '';
}
- const date = parseDate(dateStr);
+ const date = parseDate(this.dateStr as Timestamp);
if (!isValidDate(date)) {
return '';
}
- if (relative) {
+ if (this.relative) {
return fromNow(date, this.relativeOptionNoAgo);
}
const now = new Date();
- let format = dateFormat.full;
+ let format = this.dateFormat.full;
if (isWithinDay(now, date)) {
- format = timeFormat;
- } else if (showYesterday && wasYesterday(now, date)) {
- return `Yesterday at ${formatDate(date, timeFormat)}`;
+ format = this.timeFormat;
+ } else if (this.showYesterday && wasYesterday(now, date)) {
+ return `Yesterday at ${formatDate(date, this.timeFormat)}`;
} else {
if (isWithinHalfYear(now, date)) {
- format = dateFormat.short;
+ format = this.dateFormat.short;
}
- if (this.showDateAndTime || showDateAndTime) {
- format = `${format} ${timeFormat}`;
+ if (this.showDateAndTime || this.showDateAndTime) {
+ format = `${format} ${this.timeFormat}`;
}
}
return formatDate(date, format);
}
- _timeToSecondsFormat(timeFormat: string | undefined) {
- return timeFormat === TimeFormats.TIME_12
- ? TimeFormats.TIME_12_WITH_SEC
- : TimeFormats.TIME_24_WITH_SEC;
- }
-
- _computeFullDateStr(
- dateStr?: Timestamp,
- timeFormat?: string,
- dateFormat?: DateFormatPair
- ) {
+ private computeFullDateStr() {
// Polymer 2: check for undefined
- if ([dateStr, timeFormat].includes(undefined) || !dateFormat) {
+ if (
+ [this.dateStr, this.timeFormat].includes(undefined) ||
+ !this.dateFormat
+ ) {
return undefined;
}
- if (!dateStr) {
+ if (!this.dateStr) {
return '';
}
- const date = parseDate(dateStr);
+ const date = parseDate(this.dateStr as Timestamp);
if (!isValidDate(date)) {
return '';
}
- let format = dateFormat.full + ', ';
- format += this._timeToSecondsFormat(timeFormat);
+ let format = this.dateFormat.full + ', ';
+ format +=
+ this.timeFormat === TimeFormats.TIME_12
+ ? TimeFormats.TIME_12_WITH_SEC
+ : TimeFormats.TIME_24_WITH_SEC;
return formatDate(date, format) + this._getUtcOffsetString();
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_html.ts b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_html.ts
deleted file mode 100644
index 4808832..0000000
--- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_html.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style>
- :host {
- color: inherit;
- display: inline;
- }
- </style>
- <span>
- [[_computeDateStr(dateStr, _timeFormat, _dateFormat, _relative,
- showDateAndTime, showYesterday)]]
- </span>
-`;
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.js b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.js
index 9a96c2d..860a7e7 100644
--- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.js
@@ -22,14 +22,18 @@
import {stubRestApi} from '../../../test/test-utils.js';
const basicFixture = fixtureFromTemplate(html`
-<gr-date-formatter date-str="2015-09-24 23:30:17.033000000"></gr-date-formatter>
+<gr-date-formatter withTooltip dateStr="2015-09-24 23:30:17.033000000">
+</gr-date-formatter>
+`);
+
+const lightFixture = fixtureFromTemplate(html`
+<gr-date-formatter dateStr="2015-09-24 23:30:17.033000000"></gr-date-formatter>
`);
suite('gr-date-formatter tests', () => {
let element;
setup(() => {
-
});
/**
@@ -41,7 +45,7 @@
return d;
}
- function testDates(nowStr, dateStr, expected, expectedWithDateAndTime,
+ async function testDates(nowStr, dateStr, expected, expectedWithDateAndTime,
expectedTooltip) {
// Normalize and convert the date to mimic server response.
dateStr = normalizedDate(dateStr)
@@ -50,13 +54,13 @@
.slice(0, -1);
sinon.useFakeTimers(normalizedDate(nowStr).getTime());
element.dateStr = dateStr;
- flush();
- const span = element.shadowRoot
- .querySelector('span');
+ await element.updateComplete;
+ const span = element.shadowRoot.querySelector('span');
+ const tooltip = element.shadowRoot.querySelector('gr-tooltip-content');
assert.equal(span.textContent.trim(), expected);
- assert.equal(element.title, expectedTooltip);
+ assert.equal(tooltip.title, expectedTooltip);
element.showDateAndTime = true;
- flush();
+ await element.updateComplete;
assert.equal(span.textContent.trim(), expectedWithDateAndTime);
}
@@ -81,35 +85,37 @@
test('invalid dates are quietly rejected', () => {
assert.notOk((new Date('foo')).valueOf());
- assert.equal(element._computeDateStr('foo', 'h:mm A'), '');
+ element.dateStr = 'foo';
+ element.timeFormat = 'h:mm A';
+ assert.equal(element._computeDateStr(), '');
});
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'15:34',
'15:34',
'Jul 29, 2015, 15:34:14');
});
- test('Within 24 hours on different days', () => {
- testDates('2015-07-29 03:34:14.985000000',
+ test('Within 24 hours on different days', async () => {
+ await testDates('2015-07-29 03:34:14.985000000',
'2015-07-28 20:25:14.985000000',
'Jul 28',
'Jul 28 20:25',
'Jul 28, 2015, 20:25:14');
});
- test('More than 24 hours but less than six months', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('More than 24 hours but less than six months', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-06-15 03:25:14.985000000',
'Jun 15',
'Jun 15 03:25',
'Jun 15, 2015, 03:25:14');
});
- test('More than six months', () => {
- testDates('2015-09-15 20:34:00.000000000',
+ test('More than six months', async () => {
+ await testDates('2015-09-15 20:34:00.000000000',
'2015-01-15 03:25:00.000000000',
'Jan 15, 2015',
'Jan 15, 2015 03:25',
@@ -128,24 +134,24 @@
return element._loadPreferences();
}));
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'15:34',
'15:34',
'07/29/15, 15:34:14');
});
- test('Within 24 hours on different days', () => {
- testDates('2015-07-29 03:34:14.985000000',
+ test('Within 24 hours on different days', async () => {
+ await testDates('2015-07-29 03:34:14.985000000',
'2015-07-28 20:25:14.985000000',
'07/28',
'07/28 20:25',
'07/28/15, 20:25:14');
});
- test('More than 24 hours but less than six months', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('More than 24 hours but less than six months', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-06-15 03:25:14.985000000',
'06/15',
'06/15 03:25',
@@ -164,24 +170,24 @@
return element._loadPreferences();
}));
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'15:34',
'15:34',
'2015-07-29, 15:34:14');
});
- test('Within 24 hours on different days', () => {
- testDates('2015-07-29 03:34:14.985000000',
+ test('Within 24 hours on different days', async () => {
+ await testDates('2015-07-29 03:34:14.985000000',
'2015-07-28 20:25:14.985000000',
'07-28',
'07-28 20:25',
'2015-07-28, 20:25:14');
});
- test('More than 24 hours but less than six months', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('More than 24 hours but less than six months', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-06-15 03:25:14.985000000',
'06-15',
'06-15 03:25',
@@ -200,24 +206,24 @@
return element._loadPreferences();
}));
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'15:34',
'15:34',
'29.07.2015, 15:34:14');
});
- test('Within 24 hours on different days', () => {
- testDates('2015-07-29 03:34:14.985000000',
+ test('Within 24 hours on different days', async () => {
+ await testDates('2015-07-29 03:34:14.985000000',
'2015-07-28 20:25:14.985000000',
'28. Jul',
'28. Jul 20:25',
'28.07.2015, 20:25:14');
});
- test('More than 24 hours but less than six months', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('More than 24 hours but less than six months', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-06-15 03:25:14.985000000',
'15. Jun',
'15. Jun 03:25',
@@ -236,24 +242,24 @@
return element._loadPreferences();
}));
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'15:34',
'15:34',
'29/07/2015, 15:34:14');
});
- test('Within 24 hours on different days', () => {
- testDates('2015-07-29 03:34:14.985000000',
+ test('Within 24 hours on different days', async () => {
+ await testDates('2015-07-29 03:34:14.985000000',
'2015-07-28 20:25:14.985000000',
'28/07',
'28/07 20:25',
'28/07/2015, 20:25:14');
});
- test('More than 24 hours but less than six months', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('More than 24 hours but less than six months', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-06-15 03:25:14.985000000',
'15/06',
'15/06 03:25',
@@ -273,8 +279,8 @@
})
);
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'3:34 PM',
'3:34 PM',
@@ -294,8 +300,8 @@
})
);
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'3:34 PM',
'3:34 PM',
@@ -315,8 +321,8 @@
})
);
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'3:34 PM',
'3:34 PM',
@@ -336,8 +342,8 @@
})
);
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'3:34 PM',
'3:34 PM',
@@ -357,8 +363,8 @@
})
);
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'3:34 PM',
'3:34 PM',
@@ -377,16 +383,16 @@
return element._loadPreferences();
}));
- test('Within 24 hours on same day', () => {
- testDates('2015-07-29 20:34:14.985000000',
+ test('Within 24 hours on same day', async () => {
+ await testDates('2015-07-29 20:34:14.985000000',
'2015-07-29 15:34:14.985000000',
'5 hours ago',
'5 hours ago',
'Jul 29, 2015, 3:34:14 PM');
});
- test('More than six months', () => {
- testDates('2015-09-15 20:34:00.000000000',
+ test('More than six months', async () => {
+ await testDates('2015-09-15 20:34:00.000000000',
'2015-01-15 03:25:00.000000000',
'8 months ago',
'8 months ago',
@@ -405,10 +411,10 @@
}));
test('Preferences are respected', () => {
- assert.equal(element._timeFormat, 'h:mm A');
- assert.equal(element._dateFormat.short, 'MM/DD');
- assert.equal(element._dateFormat.full, 'MM/DD/YY');
- assert.isTrue(element._relative);
+ assert.equal(element.timeFormat, 'h:mm A');
+ assert.equal(element.dateFormat.short, 'MM/DD');
+ assert.equal(element.dateFormat.full, 'MM/DD/YY');
+ assert.isTrue(element.relative);
});
});
@@ -419,10 +425,38 @@
}));
test('Default preferences are respected', () => {
- assert.equal(element._timeFormat, 'HH:mm');
- assert.equal(element._dateFormat.short, 'MMM DD');
- assert.equal(element._dateFormat.full, 'MMM DD, YYYY');
- assert.isFalse(element._relative);
+ assert.equal(element.timeFormat, 'HH:mm');
+ assert.equal(element.dateFormat.short, 'MMM DD');
+ assert.equal(element.dateFormat.full, 'MMM DD, YYYY');
+ assert.isFalse(element.relative);
+ });
+ });
+
+ suite('with tooltip', () => {
+ setup(async () => {
+ await stubRestAPI(null);
+ element = basicFixture.instantiate();
+ await element._loadPreferences();
+ await element.updateComplete;
+ });
+
+ test('Tooltip is present', () => {
+ const tooltip = element.shadowRoot.querySelector('gr-tooltip-content');
+ assert.isOk(tooltip);
+ });
+ });
+
+ suite('without tooltip', () => {
+ setup(async () => {
+ await stubRestAPI(null);
+ element = lightFixture.instantiate();
+ await element._loadPreferences();
+ await element.updateComplete;
+ });
+
+ test('Tooltip is absent', () => {
+ const tooltip = element.shadowRoot.querySelector('gr-tooltip-content');
+ assert.isNotOk(tooltip);
});
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
index 27c6341..97ee39e 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog.ts
@@ -15,13 +15,11 @@
* limitations under the License.
*/
import '../gr-button/gr-button';
-import '../../../styles/gr-font-styles';
-import '../../../styles/shared-styles';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-dialog_html';
-import {customElement, property, observe} from '@polymer/decorators';
+import {customElement, property, query} from 'lit/decorators';
import {GrButton} from '../gr-button/gr-button';
-import {KeydownEvent} from '../../../types/events';
+import {css, html, LitElement, PropertyValues} from 'lit';
+import {sharedStyles} from '../../../styles/shared-styles';
+import {fontStyles} from '../../../styles/gr-font-styles';
declare global {
interface HTMLElementTagNameMap {
@@ -29,18 +27,8 @@
}
}
-export interface GrDialog {
- $: {
- confirm: GrButton;
- };
-}
-
@customElement('gr-dialog')
-export class GrDialog extends PolymerElement {
- static get template() {
- return htmlTemplate;
- }
-
+export class GrDialog extends LitElement {
/**
* Fired when the confirm button is pressed.
*
@@ -53,33 +41,132 @@
* @event cancel
*/
- @property({type: String})
+ @query('#confirm')
+ confirmButton?: GrButton;
+
+ @property({type: String, attribute: 'confirm-label'})
confirmLabel = 'Confirm';
// Supplying an empty cancel label will hide the button completely.
- @property({type: String})
+ @property({type: String, attribute: 'cancel-label'})
cancelLabel = 'Cancel';
@property({type: Boolean})
disabled = false;
- @property({type: Boolean})
+ @property({type: Boolean, attribute: 'confirm-on-enter'})
confirmOnEnter = false;
- @property({type: String})
+ @property({type: String, attribute: 'confirm-tooltip'})
confirmTooltip?: string;
- override ready() {
- super.ready();
- this._ensureAttribute('role', 'dialog');
+ override firstUpdated(changedProperties: PropertyValues) {
+ super.firstUpdated(changedProperties);
+ if (!this.getAttribute('role')) this.setAttribute('role', 'dialog');
}
- @observe('confirmTooltip')
- _handleConfirmTooltipUpdate(confirmTooltip?: string) {
- if (confirmTooltip) {
- this.$.confirm.setAttribute('has-tooltip', 'true');
+ static override get styles() {
+ return [
+ sharedStyles,
+ fontStyles,
+ css`
+ :host {
+ color: var(--primary-text-color);
+ display: block;
+ max-height: 90vh;
+ overflow: auto;
+ }
+ .container {
+ display: flex;
+ flex-direction: column;
+ max-height: 90vh;
+ padding: var(--spacing-xl);
+ }
+ header {
+ flex-shrink: 0;
+ padding-bottom: var(--spacing-xl);
+ }
+ main {
+ display: flex;
+ flex-shrink: 1;
+ width: 100%;
+ flex: 1;
+ /* IMPORTANT: required for firefox */
+ min-height: 0px;
+ }
+ main .overflow-container {
+ flex: 1;
+ overflow: auto;
+ }
+ footer {
+ display: flex;
+ flex-shrink: 0;
+ justify-content: flex-end;
+ padding-top: var(--spacing-xl);
+ }
+ gr-button {
+ margin-left: var(--spacing-l);
+ }
+ .hidden {
+ display: none;
+ }
+ `,
+ ];
+ }
+
+ override render() {
+ // Note that we are using (e: Event) => this._handleKeyDown because the
+ // tests mock out _handleKeydown so the lookup needs to be dynamic, not
+ // bound statically here.
+ return html`
+ <div
+ class="container"
+ @keydown=${(e: KeyboardEvent) => this._handleKeydown(e)}
+ >
+ <header class="heading-3"><slot name="header"></slot></header>
+ <main>
+ <div class="overflow-container">
+ <slot name="main"></slot>
+ </div>
+ </main>
+ <footer>
+ <slot name="footer"></slot>
+ <gr-button
+ id="cancel"
+ class="${this.cancelLabel.length ? '' : 'hidden'}"
+ link
+ @click=${(e: Event) => this.handleCancelTap(e)}
+ >
+ ${this.cancelLabel}
+ </gr-button>
+ <gr-button
+ id="confirm"
+ link
+ primary
+ @click=${(e: Event) => this._handleConfirm(e)}
+ ?disabled=${this.disabled}
+ title=${this.confirmTooltip ?? ''}
+ >
+ ${this.confirmLabel}
+ </gr-button>
+ </footer>
+ </div>
+ `;
+ }
+
+ override updated(changedProperties: PropertyValues) {
+ if (changedProperties.has('confirmTooltip')) {
+ this.updateTooltip();
+ }
+ }
+
+ private updateTooltip() {
+ const confirmButton = this.confirmButton;
+ if (!confirmButton) return;
+ if (this.confirmTooltip) {
+ confirmButton.setAttribute('has-tooltip', 'true');
} else {
- this.$.confirm.removeAttribute('has-tooltip');
+ confirmButton.removeAttribute('has-tooltip');
}
}
@@ -98,7 +185,7 @@
);
}
- _handleCancelTap(e: Event) {
+ private handleCancelTap(e: Event) {
e.preventDefault();
e.stopPropagation();
this.dispatchEvent(
@@ -109,17 +196,13 @@
);
}
- _handleKeydown(e: KeydownEvent) {
+ _handleKeydown(e: KeyboardEvent) {
if (this.confirmOnEnter && e.keyCode === 13) {
this._handleConfirm(e);
}
}
resetFocus() {
- this.$.confirm.focus();
- }
-
- _computeCancelClass(cancelLabel: string) {
- return cancelLabel.length ? '' : 'hidden';
+ this.confirmButton!.focus();
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_html.ts b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_html.ts
deleted file mode 100644
index a5cf8f1..0000000
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_html.ts
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style include="gr-font-styles">
- /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
- </style>
- <style include="shared-styles">
- :host {
- color: var(--primary-text-color);
- display: block;
- max-height: 90vh;
- overflow: auto;
- }
- .container {
- display: flex;
- flex-direction: column;
- max-height: 90vh;
- padding: var(--spacing-xl);
- }
- header {
- flex-shrink: 0;
- padding-bottom: var(--spacing-xl);
- }
- main {
- display: flex;
- flex-shrink: 1;
- width: 100%;
- flex: 1;
- /* IMPORTANT: required for firefox */
- min-height: 0px;
- }
- main .overflow-container {
- flex: 1;
- overflow: auto;
- }
- footer {
- display: flex;
- flex-shrink: 0;
- justify-content: flex-end;
- padding-top: var(--spacing-xl);
- }
- gr-button {
- margin-left: var(--spacing-l);
- }
- .hidden {
- display: none;
- }
- </style>
- <div class="container" on-keydown="_handleKeydown">
- <header class="heading-3"><slot name="header"></slot></header>
- <main>
- <div class="overflow-container">
- <slot name="main"></slot>
- </div>
- </main>
- <footer>
- <slot name="footer"></slot>
- <gr-button
- id="cancel"
- class$="[[_computeCancelClass(cancelLabel)]]"
- link=""
- on-click="_handleCancelTap"
- >
- [[cancelLabel]]
- </gr-button>
- <gr-button
- id="confirm"
- link=""
- primary=""
- on-click="_handleConfirm"
- disabled="[[disabled]]"
- title$="[[confirmTooltip]]"
- >
- [[confirmLabel]]
- </gr-button>
- </footer>
- </div>
-`;
diff --git a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
index e7b7130..171fc6c 100644
--- a/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dialog/gr-dialog_test.ts
@@ -17,6 +17,7 @@
import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
import '../../../test/common-test-setup-karma';
+import './gr-dialog';
import {GrDialog} from './gr-dialog';
import {isHidden, queryAndAssert} from '../../../test/test-utils';
@@ -25,8 +26,9 @@
suite('gr-dialog tests', () => {
let element: GrDialog;
- setup(() => {
+ setup(async () => {
element = basicFixture.instantiate();
+ await element.updateComplete;
});
test('events', () => {
@@ -42,56 +44,59 @@
assert.equal(cancel.callCount, 1);
});
- test('confirmOnEnter', () => {
+ test('confirmOnEnter', async () => {
element.confirmOnEnter = false;
+ await element.updateComplete;
const handleConfirmStub = sinon.stub(element, '_handleConfirm');
const handleKeydownSpy = sinon.spy(element, '_handleKeydown');
- MockInteractions.pressAndReleaseKeyOn(
+ MockInteractions.keyDownOn(
queryAndAssert(element, 'main'),
13,
null,
'enter'
);
- flush();
+ await flush();
assert.isTrue(handleKeydownSpy.called);
assert.isFalse(handleConfirmStub.called);
element.confirmOnEnter = true;
- MockInteractions.pressAndReleaseKeyOn(
+ await element.updateComplete;
+
+ MockInteractions.keyDownOn(
queryAndAssert(element, 'main'),
13,
null,
'enter'
);
- flush();
+ await flush();
assert.isTrue(handleConfirmStub.called);
});
test('resetFocus', () => {
- const focusStub = sinon.stub(element.$.confirm, 'focus');
+ const focusStub = sinon.stub(element.confirmButton!, 'focus');
element.resetFocus();
assert.isTrue(focusStub.calledOnce);
});
suite('tooltip', () => {
test('tooltip not added by default', () => {
- assert.isNull(element.$.confirm.getAttribute('has-tooltip'));
+ assert.isNull(element.confirmButton!.getAttribute('has-tooltip'));
});
- test('tooltip added if confirm tooltip is passed', () => {
+ test('tooltip added if confirm tooltip is passed', async () => {
element.confirmTooltip = 'confirm tooltip';
- flush();
- assert(element.$.confirm.getAttribute('has-tooltip'));
+ await element.updateComplete;
+ assert(element.confirmButton!.getAttribute('has-tooltip'));
});
});
- test('empty cancel label hides cancel btn', () => {
+ test('empty cancel label hides cancel btn', async () => {
const cancelButton = queryAndAssert(element, '#cancel');
assert.isFalse(isHidden(cancelButton));
element.cancelLabel = '';
- flush();
+ await element.updateComplete;
assert.isTrue(isHidden(cancelButton));
});
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
index ef46cec..6180f35 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list.ts
@@ -88,7 +88,7 @@
disabled = false;
@property({type: String, notify: true})
- value?: string;
+ value: string | number = '';
@property({type: Boolean})
showCopyForTriggerText = false;
@@ -122,6 +122,10 @@
return item.mobileText ? item.mobileText : item.text;
}
+ computeStringValue(val: string | number) {
+ return String(val);
+ }
+
@observe('value', 'items')
_handleValueChange(value?: string, items?: DropdownItem[]) {
if (!value || !items) {
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list_html.ts b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list_html.ts
index 18a46a0..3875871 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown-list/gr-dropdown-list_html.ts
@@ -78,9 +78,8 @@
width: 100%;
}
gr-button {
- --gr-button: {
- @apply --trigger-style;
- }
+ font-family: var(--trigger-style-font-family);
+ --gr-button-text-color: var(--trigger-style-text-color);
}
gr-date-formatter {
color: var(--deemphasized-text-color);
@@ -123,6 +122,7 @@
class="dropdown-trigger"
on-click="_showDropdownTapHandler"
slot="dropdown-trigger"
+ no-uppercase
>
<span id="triggerText">[[text]]</span>
<gr-copy-clipboard
@@ -173,7 +173,10 @@
<gr-select bind-value="{{value}}">
<select>
<template is="dom-repeat" items="[[items]]">
- <option disabled$="[[item.disabled]]" value="[[item.value]]">
+ <option
+ disabled$="[[item.disabled]]"
+ value="[[computeStringValue(item.value)]]"
+ >
[[_computeMobileText(item)]]
</option>
</template>
diff --git a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
index 4bd98d6..3c07d94 100644
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown_html.ts
@@ -33,7 +33,6 @@
}
gr-button {
vertical-align: top;
- @apply --gr-button;
}
gr-avatar {
height: 2em;
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
index bd1046f..13b195e 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label.ts
@@ -26,12 +26,11 @@
import {IronDropdownElement} from '@polymer/iron-dropdown/iron-dropdown';
import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {PaperInputElementExt} from '../../../types/types';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {
AutocompleteQuery,
GrAutocomplete,
} from '../gr-autocomplete/gr-autocomplete';
-import {getKeyboardEvent} from '../../../utils/dom-util';
const AWAIT_MAX_ITERS = 10;
const AWAIT_STEP = 5;
@@ -205,8 +204,8 @@
this.getGrAutocomplete()) as HTMLInputElement;
}
- _handleEnter(e: CustomKeyboardEvent) {
- e = getKeyboardEvent(e);
+ _handleEnter(event: IronKeyboardEvent) {
+ const e = event.detail.keyboardEvent;
const target = (dom(e) as EventApi).rootTarget;
if (target === this._nativeInput) {
e.preventDefault();
@@ -214,8 +213,8 @@
}
}
- _handleEsc(e: CustomKeyboardEvent) {
- e = getKeyboardEvent(e);
+ _handleEsc(event: IronKeyboardEvent) {
+ const e = event.detail.keyboardEvent;
const target = (dom(e) as EventApi).rootTarget;
if (target === this._nativeInput) {
e.preventDefault();
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
index c303bed..e711e9d 100644
--- a/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-editable-label/gr-editable-label_html.ts
@@ -72,7 +72,7 @@
--iron-icon-width: 18px;
}
gr-button.pencil {
- --padding: 0px 0px;
+ --gr-button-padding: 0px 0px;
}
</style>
<template is="dom-if" if="[[!showAsEditPencil]]">
diff --git a/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts b/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
index 0f94b11..3f759b5 100644
--- a/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-file-status-chip/gr-file-status-chip.ts
@@ -36,7 +36,7 @@
@property({type: Object})
file?: NormalizedFileInfo;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -65,7 +65,7 @@
];
}
- render() {
+ override render() {
return html` <span
class="${this._computeStatusClass(this.file)}"
tabindex="0"
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
index a329736..06272ed 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account.ts
@@ -96,7 +96,7 @@
this.reporting = appContext.reportingService;
}
- connectedCallback() {
+ override connectedCallback() {
super.connectedCallback();
this.restApiService.getConfig().then(config => {
this._config = config;
@@ -131,7 +131,12 @@
return getLastUpdate(this.account, change);
}
- _showReviewerOrCCActions(account?: AccountInfo, change?: ChangeInfo) {
+ /** 3rd parameter is just for *triggering* re-computation. */
+ _showReviewerOrCCActions(
+ account?: AccountInfo,
+ change?: ChangeInfo,
+ _?: unknown
+ ) {
return !!this._selfAccount && isRemovableReviewer(change, account);
}
@@ -212,18 +217,38 @@
});
}
- _computeShowLabelNeedsAttention() {
+ /** Parameters are just for *triggering* re-computation. */
+ _computeShowLabelNeedsAttention(
+ _1: unknown,
+ _2: unknown,
+ _3: unknown,
+ _4: unknown
+ ) {
return this.isAttentionEnabled && this.hasUserAttention;
}
- _computeShowActionAddToAttentionSet() {
+ /** Parameters are just for *triggering* re-computation. */
+ _computeShowActionAddToAttentionSet(
+ _1: unknown,
+ _2: unknown,
+ _3: unknown,
+ _4: unknown,
+ _5: unknown
+ ) {
const involvedOrSelf =
isInvolved(this.change, this._selfAccount) ||
isSelf(this.account, this._selfAccount);
return involvedOrSelf && this.isAttentionEnabled && !this.hasUserAttention;
}
- _computeShowActionRemoveFromAttentionSet() {
+ /** Parameters are just for *triggering* re-computation. */
+ _computeShowActionRemoveFromAttentionSet(
+ _1: unknown,
+ _2: unknown,
+ _3: unknown,
+ _4: unknown,
+ _5: unknown
+ ) {
const involvedOrSelf =
isInvolved(this.change, this._selfAccount) ||
isSelf(this.account, this._selfAccount);
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_html.ts b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_html.ts
index f1f6bf8..adca888 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_html.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_html.ts
@@ -45,9 +45,7 @@
.action {
border-top: 1px solid var(--border-color);
padding: var(--spacing-s) var(--spacing-l);
- --gr-button: {
- padding: var(--spacing-s) var(--spacing-m);
- }
+ --gr-button-padding: var(--spacing-s) var(--spacing-m);
}
.attention {
background-color: var(--emphasis-color);
@@ -128,7 +126,7 @@
<span class="value">[[_computeReason(change)]]</span>
<template is="dom-if" if="[[_computeLastUpdate(change)]]">
(<gr-date-formatter
- has-tooltip
+ withTooltip
date-str="[[_computeLastUpdate(change)]]"
></gr-date-formatter
>)
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_test.js b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_test.js
index e9a224c..82f64d0 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account_test.js
@@ -109,7 +109,7 @@
stubRestApi('removeChangeReviewer').returns(Promise.resolve({ok: true}));
const reloadListener = sinon.spy();
element._target.addEventListener('reload', reloadListener);
- flush();
+ await flush();
const button = element.shadowRoot.querySelector('.removeReviewerOrCC');
assert.isOk(button);
assert.equal(button.innerText, 'Remove Reviewer');
@@ -132,7 +132,7 @@
const reloadListener = sinon.spy();
element._target.addEventListener('reload', reloadListener);
- flush();
+ await flush();
const button = element.shadowRoot.querySelector('.changeReviewerOrCC');
assert.isOk(button);
@@ -156,7 +156,7 @@
stubRestApi('removeChangeReviewer').returns(Promise.resolve({ok: true}));
const reloadListener = sinon.spy();
element._target.addEventListener('reload', reloadListener);
- flush();
+ await flush();
const button = element.shadowRoot.querySelector('.changeReviewerOrCC');
assert.isOk(button);
@@ -180,7 +180,7 @@
const reloadListener = sinon.spy();
element._target.addEventListener('reload', reloadListener);
- flush();
+ await flush();
const button = element.shadowRoot.querySelector('.removeReviewerOrCC');
assert.equal(button.innerText, 'Remove CC');
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
index 2bb9de5..82af365 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard-behavior.ts
@@ -19,7 +19,7 @@
import {getRootElement} from '../../../scripts/rootElement';
import {Constructor} from '../../../utils/common-util';
import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {property, observe} from '@polymer/decorators';
+import {observe, property} from '@polymer/decorators';
import {
pushScrollLock,
removeScrollLock,
@@ -134,8 +134,6 @@
this._target.addEventListener('focus', this.debounceShow);
this._target.addEventListener('mouseleave', this.debounceHide);
this._target.addEventListener('blur', this.debounceHide);
-
- // when click, dismiss immediately
this._target.addEventListener('click', this.hide);
// show the hovercard if mouse moves to hovercard
@@ -151,6 +149,11 @@
this.cancelShowTask();
this.cancelHideTask();
this.unlock();
+ this._target?.removeEventListener('mouseenter', this.debounceShow);
+ this._target?.removeEventListener('focus', this.debounceShow);
+ this._target?.removeEventListener('mouseleave', this.debounceHide);
+ this._target?.removeEventListener('blur', this.debounceHide);
+ this._target?.removeEventListener('click', this.hide);
super.disconnectedCallback();
}
@@ -160,14 +163,6 @@
this.container = getHovercardContainer({createIfNotExists: true});
}
- removeListeners() {
- this._target?.removeEventListener('mouseenter', this.debounceShow);
- this._target?.removeEventListener('focus', this.debounceShow);
- this._target?.removeEventListener('mouseleave', this.debounceHide);
- this._target?.removeEventListener('blur', this.debounceHide);
- this._target?.removeEventListener('click', this.hide);
- }
-
readonly debounceHide = () => {
this.cancelShowTask();
if (!this._isShowing || this.isScheduledToHide) return;
@@ -185,10 +180,10 @@
};
cancelHideTask() {
- if (this.hideTask) {
- this.hideTask.cancel();
- this.isScheduledToHide = false;
- }
+ if (!this.hideTask) return;
+ this.hideTask.cancel();
+ this.isScheduledToHide = false;
+ this.hideTask = undefined;
}
/**
@@ -315,10 +310,10 @@
}
cancelShowTask() {
- if (this.showTask) {
- this.showTask.cancel();
- this.isScheduledToShow = false;
- }
+ if (!this.showTask) return;
+ this.showTask.cancel();
+ this.isScheduledToShow = false;
+ this.showTask = undefined;
}
/**
@@ -332,7 +327,7 @@
* Shows/opens the hovercard. This occurs when the user triggers the
* `mousenter` event on the hovercard's `target` element.
*/
- readonly show = () => {
+ readonly show = async () => {
this.cancelHideTask();
this.cancelShowTask();
if (this._isShowing || !this.container) {
@@ -352,7 +347,7 @@
// Make sure that the hovercard actually rendered and all dom-if
// statements processed, so that we can measure the (invisible)
// hovercard properly in updatePosition().
- flush();
+ await flush();
this.updatePosition();
this.classList.remove(HIDE_CLASS);
};
@@ -470,10 +465,9 @@
};
export interface GrHovercardBehaviorInterface {
+ _target: HTMLElement | null;
+ _isShowing: boolean;
ready(): void;
- removeListeners(): void;
- debounceHide(): void;
- cancelHideTask(): void;
dispatchEventThroughTarget(eventName: string, detail?: unknown): void;
hide(e?: MouseEvent): void;
debounceShow(): void;
@@ -481,5 +475,4 @@
cancelShowTask(): void;
show(): void;
updatePosition(): void;
- updatePositionTo(position: string): void;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
index 27ef23f..d5e0061 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard/gr-hovercard_test.js
@@ -84,8 +84,8 @@
assert.notEqual(element.container, element.parentNode);
});
- test('show', () => {
- element.show({});
+ test('show', async () => {
+ await element.show({});
const style = getComputedStyle(element);
assert.isTrue(element._isShowing);
assert.isTrue(element.classList.contains('hovered'));
@@ -120,6 +120,7 @@
button.dispatchEvent(new CustomEvent('mouseenter'));
await enterPromise;
+ await flush();
assert.isTrue(element.isScheduledToShow);
element.showTask.flush();
assert.isTrue(element._isShowing);
@@ -152,6 +153,7 @@
button.dispatchEvent(new CustomEvent('mouseenter'));
await enterPromise;
+ await flush();
assert.isTrue(element.isScheduledToShow);
MockInteractions.tap(button);
diff --git a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
index 69573c7..da1a782 100644
--- a/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
+++ b/polygerrit-ui/app/elements/shared/gr-icons/gr-icons.ts
@@ -158,6 +158,8 @@
<g id="arrow-forward"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"/></g>
<!-- This SVG is a copy from material.io https://fonts.google.com/icons?selected=Material+Icons:feedback -->
<g id="feedback"><path d="M0 0h24v24H0z" fill="none"/><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 12h-2v-2h2v2zm0-4h-2V6h2v4z"/></g>
+ <!-- This SVG is a copy from material.io https://fonts.google.com/icons?selected=Material+Icons&icon.query=description -->
+ <g id="description"><path xmlns="http://www.w3.org/2000/svg" d="M0 0h24v24H0V0z" fill="none"/><path xmlns="http://www.w3.org/2000/svg" d="M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></g>
</defs>
</svg>
</iron-iconset-svg>`;
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.js
index 203784d..87f6052 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-actions-js-api_test.js
@@ -125,7 +125,7 @@
.querySelector('[data-action-key="' + key + '"]'));
});
- test('action button properties', () => {
+ test('action button properties', async () => {
const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!');
flush();
const button = element.shadowRoot
@@ -137,17 +137,17 @@
changeActions.setTitle(key, 'Yo hint');
changeActions.setEnabled(key, false);
changeActions.setIcon(key, 'pupper');
- flush();
+ await flush();
assert.equal(button.getAttribute('data-label'), 'Yo');
- assert.equal(button.getAttribute('title'), 'Yo hint');
+ assert.equal(button.parentElement.getAttribute('title'), 'Yo hint');
assert.isTrue(button.disabled);
assert.equal(button.querySelector('iron-icon').icon,
'gr-icons:pupper');
});
- test('hide action buttons', () => {
+ test('hide action buttons', async () => {
const key = changeActions.add(changeActions.ActionType.REVISION, 'Bork!');
- flush();
+ await flush();
let button = element.shadowRoot
.querySelector('[data-action-key="' + key + '"]');
assert.isOk(button);
@@ -168,7 +168,7 @@
.querySelector('[data-action-key="' + key + '"]'));
changeActions.setActionOverflow(
changeActions.ActionType.REVISION, key, true);
- flush();
+ await flush();
assert.isNotOk(element.shadowRoot
.querySelector('[data-action-key="' + key + '"]'));
assert.isFalse(element.$.moreActions.hidden);
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
index 85491ef..1d4bd06 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-gerrit.ts
@@ -34,6 +34,7 @@
import {fontStyles} from '../../../styles/gr-font-styles';
import {formStyles} from '../../../styles/gr-form-styles';
import {menuPageStyles} from '../../../styles/gr-menu-page-styles';
+import {spinnerStyles} from '../../../styles/gr-spinner-styles';
import {subpageStyles} from '../../../styles/gr-subpage-styles';
import {tableStyles} from '../../../styles/gr-table-styles';
@@ -125,6 +126,7 @@
font: fontStyles,
form: formStyles,
menuPage: menuPageStyles,
+ spinner: spinnerStyles,
subPage: subpageStyles,
table: tableStyles,
};
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
index 8ec2607..29db685 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-js-api-interface_test.js
@@ -23,7 +23,6 @@
import {getPluginLoader} from './gr-plugin-loader.js';
import {_testOnly_initGerritPluginApi} from './gr-gerrit.js';
import {stubBaseUrl} from '../../../test/test-utils.js';
-import sinon from 'sinon/pkg/sinon-esm';
import {stubRestApi} from '../../../test/test-utils.js';
import {appContext} from '../../../services/app-context.js';
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
index 6fc8f1b..7c99480 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-plugin-loader.ts
@@ -123,7 +123,10 @@
});
this.awaitPluginsLoaded().then(() => {
- this._getReporting().pluginsLoaded(this._getAllInstalledPluginNames());
+ const loaded = this.getPluginsByState(PluginState.LOADED);
+ const failed = this.getPluginsByState(PluginState.LOAD_FAILED);
+ this._getReporting().pluginsLoaded(loaded.map(p => p.name));
+ this._getReporting().pluginsFailed(failed.map(p => p.name));
});
}
@@ -140,14 +143,8 @@
return url.pathname && url.pathname.endsWith(suffix);
}
- _getAllInstalledPluginNames() {
- const installedPlugins = [];
- for (const plugin of this._plugins.values()) {
- if (plugin.state === PluginState.LOADED) {
- installedPlugins.push(plugin.name);
- }
- }
- return installedPlugins;
+ private getPluginsByState(state: PluginState) {
+ return [...this._plugins.values()].filter(p => p.state === state);
}
install(
@@ -190,16 +187,9 @@
}
}
- // The polygerrit uses version of sinon where you can't stub getter,
- // declare it as a function here
arePluginsLoaded() {
- // As the size of plugins is relatively small,
- // so the performance of this check should be reasonable
if (!this._pluginListLoaded) return false;
- for (const plugin of this._plugins.values()) {
- if (plugin.state === PluginState.PENDING) return false;
- }
- return true;
+ return this.getPluginsByState(PluginState.PENDING).length === 0;
}
_checkIfCompleted() {
@@ -214,15 +204,14 @@
}
_timeout() {
- const pendingPlugins = [];
- for (const plugin of this._plugins.values()) {
- if (plugin.state === PluginState.PENDING) {
- this._updatePluginState(plugin.url, PluginState.LOAD_FAILED);
- this._checkIfCompleted();
- pendingPlugins.push(plugin.url);
- }
+ const pending = this.getPluginsByState(PluginState.PENDING);
+ for (const plugin of pending) {
+ this._updatePluginState(plugin.url, PluginState.LOAD_FAILED);
}
- return `Timeout when loading plugins: ${pendingPlugins.join(',')}`;
+ this._checkIfCompleted();
+ return `Timeout when loading plugins: ${pending
+ .map(p => p.name)
+ .join(',')}`;
}
_failToLoad(message: string, pluginUrl?: string) {
@@ -252,6 +241,7 @@
plugin: null,
});
}
+ console.info(`Plugin ${key} ${state}`);
return this._plugins.get(key)!;
}
@@ -259,7 +249,6 @@
const pluginObj = this._updatePluginState(url, PluginState.LOADED);
pluginObj.plugin = plugin;
this._getReporting().pluginLoaded(plugin.getPluginName() || url);
- console.info(`Plugin ${plugin.getPluginName() || url} installed.`);
this._checkIfCompleted();
}
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
index 026ca4c..5a6d821 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info.ts
@@ -22,23 +22,28 @@
import '../gr-button/gr-button';
import '../gr-icons/gr-icons';
import '../gr-label/gr-label';
+import '../gr-tooltip-content/gr-tooltip-content';
import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-label-info_html';
import {GerritNav} from '../../core/gr-navigation/gr-navigation';
-import {customElement, property} from '@polymer/decorators';
import {
- ChangeInfo,
AccountInfo,
LabelInfo,
ApprovalInfo,
AccountId,
isQuickLabelInfo,
isDetailedLabelInfo,
+ LabelNameToInfoMap,
} from '../../../types/common';
+import {LitElement, css, html} from 'lit';
+import {customElement, property} from 'lit/decorators';
import {GrButton} from '../gr-button/gr-button';
import {getVotingRangeOrDefault} from '../../../utils/label-util';
import {appContext} from '../../../services/app-context';
+import {ParsedChangeInfo} from '../../../types/types';
+import {fontStyles} from '../../../styles/gr-font-styles';
+import {sharedStyles} from '../../../styles/shared-styles';
+import {votingStyles} from '../../../styles/gr-voting-styles';
+import {ifDefined} from 'lit/directives/if-defined';
declare global {
interface HTMLElementTagNameMap {
@@ -55,16 +60,12 @@
interface FormattedLabel {
className?: LabelClassName;
- account: ApprovalInfo;
+ account: ApprovalInfo | AccountInfo;
value: string;
}
@customElement('gr-label-info')
-export class GrLabelInfo extends PolymerElement {
- static get template() {
- return htmlTemplate;
- }
-
+export class GrLabelInfo extends LitElement {
@property({type: Object})
labelInfo?: LabelInfo;
@@ -72,7 +73,7 @@
label = '';
@property({type: Object})
- change?: ChangeInfo;
+ change?: ParsedChangeInfo;
@property({type: Object})
account?: AccountInfo;
@@ -87,11 +88,150 @@
// TODO(TS): not used, remove later
_xhrPromise?: Promise<void>;
+ static override get styles() {
+ return [
+ sharedStyles,
+ fontStyles,
+ votingStyles,
+ css`
+ .placeholder {
+ color: var(--deemphasized-text-color);
+ }
+ .hidden {
+ display: none;
+ }
+ /* Note that most of the .voteChip styles are coming from the
+ gr-voting-styles include. */
+ .voteChip {
+ display: flex;
+ justify-content: center;
+ margin-right: var(--spacing-s);
+ padding: 1px;
+ }
+ .max {
+ background-color: var(--vote-color-approved);
+ }
+ .min {
+ background-color: var(--vote-color-rejected);
+ }
+ .positive {
+ background-color: var(--vote-color-recommended);
+ border-radius: 12px;
+ border: 1px solid var(--vote-outline-recommended);
+ color: var(--chip-color);
+ }
+ .negative {
+ background-color: var(--vote-color-disliked);
+ border-radius: 12px;
+ border: 1px solid var(--vote-outline-disliked);
+ color: var(--chip-color);
+ }
+ .hidden {
+ display: none;
+ }
+ td {
+ vertical-align: top;
+ }
+ tr {
+ min-height: var(--line-height-normal);
+ }
+ gr-tooltip-content {
+ display: block;
+ }
+ gr-button {
+ vertical-align: top;
+ }
+ gr-button::part(paper-button) {
+ height: var(--line-height-normal);
+ width: var(--line-height-normal);
+ padding: 0;
+ }
+ gr-button[disabled] iron-icon {
+ color: var(--border-color);
+ }
+ gr-account-link {
+ --account-max-length: 100px;
+ margin-right: var(--spacing-xs);
+ }
+ iron-icon {
+ height: calc(var(--line-height-normal) - 2px);
+ width: calc(var(--line-height-normal) - 2px);
+ }
+ .labelValueContainer:not(:first-of-type) td {
+ padding-top: var(--spacing-s);
+ }
+ `,
+ ];
+ }
+
+ override render() {
+ return html` <p
+ class="placeholder ${this.computeShowPlaceholder(
+ this.labelInfo,
+ this.change?.labels
+ )}"
+ >
+ No votes
+ </p>
+ <table>
+ ${this.mapLabelInfo(
+ this.labelInfo,
+ this.account,
+ this.change?.labels
+ ).map(mappedLabel => this.renderLabel(mappedLabel))}
+ </table>`;
+ }
+
+ renderLabel(mappedLabel: FormattedLabel) {
+ const {labelInfo, change} = this;
+ return html` <tr class="labelValueContainer">
+ <td>
+ <gr-tooltip-content
+ has-tooltip
+ title="${this._computeValueTooltip(labelInfo, mappedLabel.value)}"
+ >
+ <gr-label class="${mappedLabel.className} voteChip font-small">
+ ${mappedLabel.value}
+ </gr-label>
+ </gr-tooltip-content>
+ </td>
+ <td>
+ <gr-account-link
+ .account="${mappedLabel.account}"
+ .change="${change}"
+ ></gr-account-link>
+ </td>
+ <td>
+ <gr-tooltip-content has-tooltip title="Remove vote">
+ <gr-button
+ link
+ aria-label="Remove vote"
+ @click="${this.onDeleteVote}"
+ data-account-id="${ifDefined(mappedLabel.account._account_id)}"
+ class="deleteBtn ${this.computeDeleteClass(
+ mappedLabel.account,
+ this.mutable,
+ change
+ )}"
+ >
+ <iron-icon icon="gr-icons:delete"></iron-icon>
+ </gr-button>
+ </gr-tooltip-content>
+ </td>
+ </tr>`;
+ }
+
/**
* This method also listens on change.labels.*,
* to trigger computation when a label is removed from the change.
+ *
+ * The third parameter is just for *triggering* computation.
*/
- _mapLabelInfo(labelInfo?: LabelInfo, account?: AccountInfo) {
+ private mapLabelInfo(
+ labelInfo?: LabelInfo,
+ account?: AccountInfo,
+ _?: LabelNameToInfoMap
+ ): FormattedLabel[] {
const result: FormattedLabel[] = [];
if (!labelInfo) {
return result;
@@ -106,7 +246,8 @@
{
value: ok ? '👍️' : '👎️',
className: ok ? LabelClassName.POSITIVE : LabelClassName.NEGATIVE,
- account: ok ? labelInfo.approved : labelInfo.rejected,
+ // executed only if approved or rejected is not undefined
+ account: ok ? labelInfo.approved! : labelInfo.rejected!,
},
];
}
@@ -141,7 +282,7 @@
labelClassName = LabelClassName.NEGATIVE;
}
}
- const formattedLabel = {
+ const formattedLabel: FormattedLabel = {
value: `${labelValPrefix}${label.value}`,
className: labelClassName,
account: label,
@@ -165,16 +306,16 @@
* @param reviewer An object describing the reviewer that left the
* vote.
*/
- _computeDeleteClass(
+ private computeDeleteClass(
reviewer: ApprovalInfo,
mutable: boolean,
- change: ChangeInfo
+ change?: ParsedChangeInfo
) {
if (!mutable || !change || !change.removable_reviewers) {
return 'hidden';
}
const removable = change.removable_reviewers;
- if (removable.find(r => r._account_id === reviewer._account_id)) {
+ if (removable.find(r => r._account_id === reviewer?._account_id)) {
return '';
}
return 'hidden';
@@ -184,7 +325,7 @@
* Closure annotation for Polymer.prototype.splice is off.
* For now, suppressing annotations.
*/
- _onDeleteVote(e: MouseEvent) {
+ private onDeleteVote(e: MouseEvent) {
if (!this.change) return;
e.preventDefault();
@@ -218,7 +359,7 @@
});
}
- _computeValueTooltip(labelInfo: LabelInfo, score: string) {
+ _computeValueTooltip(labelInfo: LabelInfo | undefined, score: string) {
if (
!labelInfo ||
!isDetailedLabelInfo(labelInfo) ||
@@ -232,8 +373,13 @@
/**
* This method also listens change.labels.* in
* order to trigger computation when a label is removed from the change.
+ *
+ * The second parameter is just for *triggering* computation.
*/
- _computeShowPlaceholder(labelInfo?: LabelInfo) {
+ private computeShowPlaceholder(
+ labelInfo?: LabelInfo,
+ _?: LabelNameToInfoMap
+ ) {
if (!labelInfo) {
return '';
}
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_html.ts b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_html.ts
deleted file mode 100644
index f31b57f..0000000
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_html.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style include="gr-font-styles">
- /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
- </style>
- <style include="gr-voting-styles">
- /* Workaround for empty style block - see https://github.com/Polymer/tools/issues/408 */
- </style>
- <style include="shared-styles">
- .placeholder {
- color: var(--deemphasized-text-color);
- }
- .hidden {
- display: none;
- }
- /* Note that most of the .voteChip styles are coming from the
- gr-voting-styles include. */
- .voteChip {
- display: flex;
- justify-content: center;
- margin-right: var(--spacing-s);
- padding: 1px;
- }
- .max {
- background-color: var(--vote-color-approved);
- }
- .min {
- background-color: var(--vote-color-rejected);
- }
- .positive {
- background-color: var(--vote-color-recommended);
- border-radius: 12px;
- border: 1px solid var(--vote-outline-recommended);
- color: var(--chip-color);
- }
- .negative {
- background-color: var(--vote-color-disliked);
- border-radius: 12px;
- border: 1px solid var(--vote-outline-disliked);
- color: var(--chip-color);
- }
- .hidden {
- display: none;
- }
- td {
- vertical-align: top;
- }
- tr {
- min-height: var(--line-height-normal);
- }
- gr-button {
- vertical-align: top;
- --gr-button: {
- height: var(--line-height-normal);
- width: var(--line-height-normal);
- padding: 0;
- }
- }
- gr-button[disabled] iron-icon {
- color: var(--border-color);
- }
- gr-account-link {
- --account-max-length: 100px;
- margin-right: var(--spacing-xs);
- }
- iron-icon {
- height: calc(var(--line-height-normal) - 2px);
- width: calc(var(--line-height-normal) - 2px);
- }
- .labelValueContainer:not(:first-of-type) td {
- padding-top: var(--spacing-s);
- }
- </style>
- <p
- class$="placeholder [[_computeShowPlaceholder(labelInfo, change.labels.*)]]"
- >
- No votes
- </p>
- <table>
- <template
- is="dom-repeat"
- items="[[_mapLabelInfo(labelInfo, account, change.labels.*)]]"
- as="mappedLabel"
- >
- <tr class="labelValueContainer">
- <td>
- <gr-label
- has-tooltip=""
- title="[[_computeValueTooltip(labelInfo, mappedLabel.value)]]"
- class$="[[mappedLabel.className]] voteChip font-small"
- >
- [[mappedLabel.value]]
- </gr-label>
- </td>
- <td>
- <gr-account-link
- account="[[mappedLabel.account]]"
- change="[[change]]"
- ></gr-account-link>
- </td>
- <td>
- <gr-button
- link=""
- aria-label="Remove vote"
- on-click="_onDeleteVote"
- tooltip="Remove vote"
- data-account-id$="[[mappedLabel.account._account_id]]"
- class$="deleteBtn [[_computeDeleteClass(mappedLabel.account, mutable, change)]]"
- >
- <iron-icon icon="gr-icons:delete"></iron-icon>
- </gr-button>
- </td>
- </tr>
- </template>
- </table>
-`;
diff --git a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.ts b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.ts
index b3235fa..cad1f69 100644
--- a/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-label-info/gr-label-info_test.ts
@@ -31,7 +31,7 @@
import {GrAccountLink} from '../gr-account-link/gr-account-link';
import {
createAccountWithIdNameAndEmail,
- createChange,
+ createParsedChange,
} from '../../../test/test-data-generators';
import {LabelInfo} from '../../../types/common';
@@ -46,7 +46,7 @@
// Needed to trigger computed bindings.
element.account = {};
- element.change = {...createChange(), labels: {}};
+ element.change = {...createParsedChange(), labels: {}};
});
suite('remove reviewer votes', () => {
@@ -60,21 +60,23 @@
sinon.stub(element, '_computeValueTooltip').returns('');
element.account = account;
element.change = {
- ...createChange(),
+ ...createParsedChange(),
labels: {'Code-Review': label},
};
element.labelInfo = label;
element.label = 'Code-Review';
- await flush();
+ await element.updateComplete;
});
- test('_computeCanDeleteVote', () => {
+ test('_computeCanDeleteVote', async () => {
element.mutable = false;
+ await element.updateComplete;
const removeButton = queryAndAssert<GrButton>(element, 'gr-button');
assert.isTrue(isHidden(removeButton));
element.change!.removable_reviewers = [account];
element.mutable = true;
+ await element.updateComplete;
assert.isFalse(isHidden(removeButton));
});
@@ -109,14 +111,14 @@
suite('label color and order', () => {
test('valueless label rejected', async () => {
element.labelInfo = {rejected: {name: 'someone'}};
- await flush();
+ await element.updateComplete;
const labels = queryAll<GrLabel>(element, 'gr-label');
assert.isTrue(labels[0].classList.contains('negative'));
});
test('valueless label approved', async () => {
element.labelInfo = {approved: {name: 'someone'}};
- await flush();
+ await element.updateComplete;
const labels = queryAll<GrLabel>(element, 'gr-label');
assert.isTrue(labels[0].classList.contains('positive'));
});
@@ -137,7 +139,7 @@
'+2': 'Ready to submit',
},
};
- await flush();
+ await element.updateComplete;
const labels = queryAll<GrLabel>(element, 'gr-label');
assert.isTrue(labels[0].classList.contains('max'));
assert.isTrue(labels[1].classList.contains('positive'));
@@ -157,7 +159,7 @@
'+1': 'Looks good to me',
},
};
- await flush();
+ await element.updateComplete;
const labels = queryAll<GrLabel>(element, 'gr-label');
assert.isTrue(labels[0].classList.contains('max'));
assert.isTrue(labels[1].classList.contains('min'));
@@ -175,7 +177,7 @@
'+2': 'Looks good to me',
},
};
- await flush();
+ await element.updateComplete;
const labels = queryAll<GrLabel>(element, 'gr-label');
assert.isTrue(labels[0].classList.contains('max'));
assert.isTrue(labels[1].classList.contains('positive'));
@@ -195,7 +197,7 @@
'+1': 'Looks good to me',
},
};
- await flush();
+ await element.updateComplete;
const chips = queryAll<GrAccountLink>(element, 'gr-account-link');
assert.equal(chips[0].account!._account_id, element.account._account_id);
});
@@ -217,7 +219,7 @@
assert.equal(element._computeValueTooltip(labelInfo, score), '');
});
- test('placeholder', () => {
+ test('placeholder', async () => {
const values = {
'0': 'No score',
'+1': 'good',
@@ -226,30 +228,37 @@
'-2': 'terrible',
};
element.labelInfo = {};
+ await element.updateComplete;
assert.isFalse(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {all: [], values};
+ await element.updateComplete;
assert.isFalse(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {all: [{value: 1}], values};
+ await element.updateComplete;
assert.isTrue(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {rejected: account};
+ await element.updateComplete;
assert.isTrue(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {rejected: account, all: [{value: 1}], values};
+ await element.updateComplete;
assert.isTrue(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {approved: account};
+ await element.updateComplete;
assert.isTrue(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
element.labelInfo = {approved: account, all: [{value: 1}], values};
+ await element.updateComplete;
assert.isTrue(
isHidden(queryAndAssert<HTMLParagraphElement>(element, '.placeholder'))
);
diff --git a/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts b/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
index fd10145..842b35e 100644
--- a/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
+++ b/polygerrit-ui/app/elements/shared/gr-label/gr-label.ts
@@ -21,10 +21,8 @@
* used in gr-label-info.
*/
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {customElement} from '@polymer/decorators';
-import {htmlTemplate} from './gr-label_html';
-import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators';
declare global {
interface HTMLElementTagNameMap {
@@ -32,12 +30,13 @@
}
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
@customElement('gr-label')
-export class GrLabel extends base {
- static get template() {
- return htmlTemplate;
+export class GrLabel extends LitElement {
+ static override get styles() {
+ return [];
+ }
+
+ override render() {
+ return html` <slot></slot> `;
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
index f5a0c4d..7008db2 100644
--- a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
+++ b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text.ts
@@ -14,10 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-limited-text_html';
-import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
-import {customElement, observe, property} from '@polymer/decorators';
+import {customElement, property} from 'lit/decorators';
+import {html, LitElement} from 'lit';
declare global {
interface HTMLElementTagNameMap {
@@ -25,9 +23,6 @@
}
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
/**
* The gr-limited-text element is for displaying text with a maximum length
* (in number of characters) to display. If the length of the text exceeds the
@@ -35,57 +30,56 @@
* and a tooltip containing the full text is enabled.
*/
@customElement('gr-limited-text')
-export class GrLimitedText extends base {
- static get template() {
- return htmlTemplate;
- }
-
+export class GrLimitedText extends LitElement {
/** The un-truncated text to display. */
@property({type: String})
- text?: string;
+ text = '';
/** The maximum length for the text to display before truncating. */
@property({type: Number})
- limit?: number;
+ limit = 0;
@property({type: String})
tooltip?: string;
- /** Boolean property used by TooltipMixin. */
- @property({type: Boolean})
- override hasTooltip = false;
+ static override get styles() {
+ return [];
+ }
- /** Boolean property used by TooltipMixin. */
- @property({type: Boolean})
- disableTooltip = false;
-
- /**
- * The text or limit have changed. Recompute whether a tooltip needs to be
- * enabled.
- */
- @observe('text', 'tooltip', 'limit')
- _updateTitle(text?: string, tooltip?: string, limit?: number) {
- text = text ?? '';
- tooltip = tooltip ?? '';
- limit = limit ?? 0;
-
- this.hasTooltip = !!tooltip || (!!limit && text.length > limit);
- if (this.hasTooltip && !this.disableTooltip) {
- // Combine the text and title if over-length
- if (limit && text.length > limit) {
- this.title = `${text}${tooltip ? ` (${tooltip})` : ''}`;
- } else {
- this.title = tooltip;
- }
+ override render() {
+ if (this.tooltip || this.tooLong()) {
+ return html` <gr-tooltip-content
+ has-tooltip
+ .title=${this.renderTooltip()}
+ >
+ ${this.renderText()}
+ </gr-tooltip-content>`;
} else {
- this.title = '';
+ return this.renderText();
}
}
- _computeDisplayText(text?: string, limit?: number) {
- if (!!limit && !!text && text.length > limit) {
- return text.substr(0, limit - 1) + '…';
+ // Should be private but used in tests.
+ renderText() {
+ if (this.tooLong()) {
+ return this.text.substr(0, this.limit - 1) + '…';
}
- return text;
+ return this.text;
+ }
+
+ private renderTooltip() {
+ if (this.tooLong()) {
+ return `${this.text}${this.tooltip ? ` (${this.tooltip})` : ''}`;
+ } else if (this.tooltip) {
+ return this.tooltip;
+ } else {
+ return '';
+ }
+ }
+
+ private tooLong() {
+ if (!this.limit) return false;
+ if (!this.text) return false;
+ return this.text.length > this.limit;
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_html.ts b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_html.ts
deleted file mode 100644
index b942d07..0000000
--- a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_html.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html` [[_computeDisplayText(text, limit)]] `;
diff --git a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_test.js b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_test.js
index 3b99d6d..e3e72d0 100644
--- a/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-limited-text/gr-limited-text_test.js
@@ -23,77 +23,65 @@
suite('gr-limited-text tests', () => {
let element;
- setup(() => {
+ setup(async () => {
element = basicFixture.instantiate();
+ await element.updateComplete;
});
- test('tooltip without title input', () => {
- const updateSpy = sinon.spy(element, '_updateTitle');
+ test('tooltip without title input', async () => {
element.text = 'abc 123';
- flush();
- assert.isTrue(updateSpy.calledOnce);
- assert.isNotOk(element.getAttribute('title'));
- assert.isFalse(element.hasTooltip);
+ await element.updateComplete;
+ assert.isNotOk(element.shadowRoot.querySelector('gr-tooltip-content'));
element.limit = 10;
- flush();
- assert.isTrue(updateSpy.calledTwice);
- assert.isNotOk(element.getAttribute('title'));
- assert.isFalse(element.hasTooltip);
+ await element.updateComplete;
+ assert.isNotOk(element.shadowRoot.querySelector('gr-tooltip-content'));
element.limit = 3;
- flush();
- assert.equal(updateSpy.callCount, 3);
- assert.equal(element.getAttribute('title'), 'abc 123');
- assert.equal(element.title, 'abc 123');
- assert.isTrue(element.hasTooltip);
+ await element.updateComplete;
+ assert.isOk(element.shadowRoot.querySelector('gr-tooltip-content'));
+ assert.equal(
+ element.shadowRoot.querySelector('gr-tooltip-content').title,
+ 'abc 123');
element.limit = 100;
- flush();
- assert.equal(updateSpy.callCount, 4);
- assert.isFalse(element.hasTooltip);
+ await element.updateComplete;
+ assert.isNotOk(element.shadowRoot.querySelector('gr-tooltip-content'));
element.limit = null;
- flush();
- assert.equal(updateSpy.callCount, 5);
- assert.isNotOk(element.getAttribute('title'));
- assert.isFalse(element.hasTooltip);
+ await element.updateComplete;
+ assert.isNotOk(element.shadowRoot.querySelector('gr-tooltip-content'));
});
- test('with tooltip input', () => {
- const updateSpy = sinon.spy(element, '_updateTitle');
+ test('with tooltip input', async () => {
element.tooltip = 'abc 123';
- flush();
- assert.isTrue(updateSpy.calledOnce);
- assert.isTrue(element.hasTooltip);
- assert.equal(element.getAttribute('title'), 'abc 123');
- assert.equal(element.title, 'abc 123');
+ await element.updateComplete;
+ let tooltipContent = element.shadowRoot.querySelector('gr-tooltip-content');
+ assert.isOk(tooltipContent);
+ assert.equal(tooltipContent.title, 'abc 123');
element.text = 'abc';
- flush();
- assert.equal(element.getAttribute('title'), 'abc 123');
- assert.isTrue(element.hasTooltip);
+ await element.updateComplete;
+ tooltipContent = element.shadowRoot.querySelector('gr-tooltip-content');
+ assert.isOk(tooltipContent);
+ assert.equal(tooltipContent.title, 'abc 123');
element.text = 'abcdef';
element.limit = 3;
- flush();
- assert.equal(element.getAttribute('title'), 'abcdef (abc 123)');
- assert.isTrue(element.hasTooltip);
+ await element.updateComplete;
+ tooltipContent = element.shadowRoot.querySelector('gr-tooltip-content');
+ assert.isOk(tooltipContent);
+ assert.equal(tooltipContent.title, 'abcdef (abc 123)');
});
test('_computeDisplayText', () => {
- assert.equal(element._computeDisplayText('foo bar', 100), 'foo bar');
- assert.equal(element._computeDisplayText('foo bar', 4), 'foo…');
- assert.equal(element._computeDisplayText('foo bar', null), 'foo bar');
- });
-
- test('when disable tooltip', () => {
- sinon.spy(element, '_updateTitle');
- element.text = 'abcdefghijklmn';
- element.disableTooltip = true;
- element.limit = 10;
- flush();
- assert.equal(element.getAttribute('title'), '');
+ element.text = 'foo bar';
+ element.limit = 100;
+ assert.equal(element.renderText(), 'foo bar');
+ element.limit = 4;
+ assert.equal(element.renderText(), 'foo…');
+ element.limit = 0;
+ assert.equal(element.renderText(), 'foo bar');
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
index 5bf5a8f..801b8bf 100644
--- a/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-linked-chip/gr-linked-chip.ts
@@ -50,7 +50,7 @@
@property({type: Number})
limit?: number;
- static get styles() {
+ static override get styles() {
return [
sharedStyles,
css`
@@ -84,9 +84,10 @@
];
}
- render() {
+ override render() {
// To pass CSS mixins for @apply to Polymer components, they need to appear
// in <style> inside the template.
+ /* eslint-disable lit/prefer-static-styles */
const customStyle = html`
<style>
gr-button::part(paper-button),
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
index 055c45f..4f02897 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
@@ -53,7 +53,7 @@
filter?: string;
@property({type: Number})
- offset?: number;
+ offset = 0;
@property({type: Boolean})
loading?: boolean;
@@ -102,8 +102,8 @@
offset: number,
direction: number,
itemsPerPage: number,
- filter: string,
- path: string
+ filter: string | undefined,
+ path = ''
) {
// Offset could be a string when passed from the router.
offset = +(offset || 0);
diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
index 1622365..1b84089 100644
--- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
+++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts
@@ -40,6 +40,9 @@
IronOverlayBehavior as IronOverlayBehavior
);
+/**
+ * @attr {Boolean} with-backdrop - inherited from IronOverlay
+ */
@customElement('gr-overlay')
export class GrOverlay extends base {
static get template() {
diff --git a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
index b2477dd..423a1a8 100644
--- a/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
+++ b/polygerrit-ui/app/elements/shared/gr-page-nav/gr-page-nav.ts
@@ -53,7 +53,7 @@
this.bodyScrollHandler = () => this._handleBodyScroll();
}
- connectedCallback() {
+ override connectedCallback() {
super.connectedCallback();
window.addEventListener('scroll', this.bodyScrollHandler);
}
diff --git a/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts b/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
index e71add9..571272d 100644
--- a/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
+++ b/polygerrit-ui/app/elements/shared/gr-select/gr-select.ts
@@ -34,7 +34,7 @@
}
@property({type: String, notify: true})
- bindValue?: string;
+ bindValue?: string | number;
get nativeSelect() {
// gr-select is not a shadow component
@@ -49,14 +49,12 @@
// It's possible to have a value of 0.
if (this.bindValue !== undefined) {
// Set for chrome/safari so it happens instantly
- this.nativeSelect.value = this.bindValue;
+ this.nativeSelect.value = String(this.bindValue);
// Async needed for firefox to populate value. It was trying to do it
// before options from a dom-repeat were rendered previously.
// See https://bugs.chromium.org/p/gerrit/issues/detail?id=7735
setTimeout(() => {
- // TODO(TS): maybe should check for undefined before assigning
- // or fallback to ''
- this.nativeSelect.value = this.bindValue!;
+ this.nativeSelect.value = String(this.bindValue);
}, 1);
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
index ce1eec3..434da1f 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea.ts
@@ -33,7 +33,7 @@
Item,
ItemSelectedEvent,
} from '../gr-autocomplete-dropdown/gr-autocomplete-dropdown';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
const MAX_ITEMS_DROPDOWN = 10;
@@ -238,7 +238,7 @@
this._setEmoji(this.$.emojiSuggestions.getCurrentText());
}
- _handleEnterByKey(e: CustomKeyboardEvent) {
+ _handleEnterByKey(e: IronKeyboardEvent) {
// Enter should have newline behavior if the picker is closed or if the user
// has only typed ':'. Also make sure that shortcuts aren't clobbered.
if (this._hideEmojiAutocomplete || this.disableEnterKeyForSelectingEmoji) {
@@ -420,7 +420,7 @@
);
}
- private indent(e: CustomKeyboardEvent): void {
+ private indent(e: IronKeyboardEvent): void {
if (!document.queryCommandSupported('insertText')) {
return;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts
index 7790c73..7e59692 100644
--- a/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-textarea/gr-textarea_test.ts
@@ -20,7 +20,7 @@
import {GrTextarea} from './gr-textarea';
import {html} from '@polymer/polymer/lib/utils/html-tag';
import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
-import {CustomKeyboardEvent} from '../../../types/events';
+import {IronKeyboardEvent} from '../../../types/events';
import {ItemSelectedEvent} from '../gr-autocomplete-dropdown/gr-autocomplete-dropdown';
const basicFixture = fixtureFromElement('gr-textarea');
@@ -240,7 +240,7 @@
element._handleEnterByKey(
new CustomEvent('keydown', {
detail: {keyboardEvent: {keyCode: 13}},
- }) as CustomKeyboardEvent
+ }) as IronKeyboardEvent
);
await flush();
assert.deepEqual(indentCommand.args[0], ['insertText', false, '\n ']);
@@ -252,7 +252,7 @@
element._handleEnterByKey(
new CustomEvent('keydown', {
detail: {keyboardEvent: {keyCode: 13, ctrlKey: true}},
- }) as CustomKeyboardEvent
+ }) as IronKeyboardEvent
);
await flush();
assert.isTrue(indentCommand.notCalled);
@@ -260,7 +260,7 @@
element._handleEnterByKey(
new CustomEvent('keydown', {
detail: {keyboardEvent: {keyCode: 13, metaKey: true}},
- }) as CustomKeyboardEvent
+ }) as IronKeyboardEvent
);
await flush();
assert.isTrue(indentCommand.notCalled);
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
index 9d228ab..0585aec8 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content.ts
@@ -15,10 +15,13 @@
* limitations under the License.
*/
import '../gr-icons/gr-icons';
-import {PolymerElement} from '@polymer/polymer/polymer-element';
-import {htmlTemplate} from './gr-tooltip-content_html';
-import {TooltipMixin} from '../../../mixins/gr-tooltip-mixin/gr-tooltip-mixin';
-import {customElement, property} from '@polymer/decorators';
+import '../gr-tooltip/gr-tooltip';
+import {getRootElement} from '../../../scripts/rootElement';
+import {GrTooltip} from '../gr-tooltip/gr-tooltip';
+import {css, html, LitElement, PropertyValues} from 'lit';
+import {customElement, property, state} from 'lit/decorators';
+
+const BOTTOM_OFFSET = 7.2; // Height of the arrow in tooltip.
declare global {
interface HTMLElementTagNameMap {
@@ -26,21 +29,202 @@
}
}
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
-/**
- * Transclude anything inside and wrap them to support tooltip functionality.
- */
@customElement('gr-tooltip-content')
-export class GrTooltipContent extends base {
- static get template() {
- return htmlTemplate;
- }
+export class GrTooltipContent extends LitElement {
+ @property({type: Boolean, attribute: 'has-tooltip', reflect: true})
+ hasTooltip = false;
- @property({type: String, reflectToAttribute: true})
+ @property({type: Boolean, attribute: 'position-below', reflect: true})
+ positionBelow = false;
+
+ @property({type: String, attribute: 'max-width', reflect: true})
maxWidth?: string;
- @property({type: Boolean})
+ @property({type: Boolean, attribute: 'show-icon'})
showIcon = false;
+
+ // Should be private but used in tests.
+ @state()
+ isTouchDevice = 'ontouchstart' in document.documentElement;
+
+ // Should be private but used in tests.
+ tooltip: GrTooltip | null = null;
+
+ @state()
+ private originalTitle = '';
+
+ private hasSetupTooltipListeners = false;
+
+ private readonly windowScrollHandler: () => void;
+
+ private readonly showHandler: () => void;
+
+ private readonly hideHandler: (e: Event) => void;
+
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
+ constructor() {
+ super();
+ this.windowScrollHandler = () => this._handleWindowScroll();
+ this.showHandler = () => this._handleShowTooltip();
+ this.hideHandler = (e: Event | undefined) => this._handleHideTooltip(e);
+ }
+
+ override disconnectedCallback() {
+ this._handleHideTooltip(undefined);
+ this.removeEventListener('mouseenter', this.showHandler);
+ window.removeEventListener('scroll', this.windowScrollHandler);
+ super.disconnectedCallback();
+ }
+
+ static override get styles() {
+ return [
+ css`
+ iron-icon {
+ width: var(--line-height-normal);
+ height: var(--line-height-normal);
+ vertical-align: top;
+ }
+ `,
+ ];
+ }
+
+ override render() {
+ return html`
+ <slot></slot>
+ ${this.renderIcon()}
+ `;
+ }
+
+ renderIcon() {
+ if (!this.showIcon) return;
+ return html`<iron-icon icon="gr-icons:info"></iron-icon>`;
+ }
+
+ override updated(changedProperties: PropertyValues) {
+ if (changedProperties.has('hasTooltip')) {
+ this.setupTooltipListeners();
+ }
+ }
+
+ private setupTooltipListeners() {
+ if (!this.hasTooltip) {
+ if (this.hasSetupTooltipListeners) {
+ // if attribute set to false, remove the listener
+ this.removeEventListener('mouseenter', this.showHandler);
+ this.hasSetupTooltipListeners = false;
+ }
+ return;
+ }
+
+ if (this.hasSetupTooltipListeners) {
+ return;
+ }
+ this.hasSetupTooltipListeners = true;
+ this.addEventListener('mouseenter', this.showHandler);
+ }
+
+ _handleShowTooltip() {
+ if (this.isTouchDevice) {
+ return;
+ }
+
+ if (
+ !this.hasAttribute('title') ||
+ this.getAttribute('title') === '' ||
+ this.tooltip
+ ) {
+ return;
+ }
+
+ // Store the title attribute text then set it to an empty string to
+ // prevent it from showing natively.
+ this.originalTitle = this.getAttribute('title') || '';
+ this.setAttribute('title', '');
+
+ const tooltip = document.createElement('gr-tooltip');
+ tooltip.text = this.originalTitle;
+ tooltip.maxWidth = this.getAttribute('max-width') || '';
+ tooltip.positionBelow = this.hasAttribute('position-below');
+
+ // Set visibility to hidden before appending to the DOM so that
+ // calculations can be made based on the element’s size.
+ tooltip.style.visibility = 'hidden';
+ getRootElement().appendChild(tooltip);
+ this._positionTooltip(tooltip);
+ tooltip.style.visibility = 'initial';
+
+ this.tooltip = tooltip;
+ window.addEventListener('scroll', this.windowScrollHandler);
+ this.addEventListener('mouseleave', this.hideHandler);
+ this.addEventListener('click', this.hideHandler);
+ tooltip.addEventListener('mouseleave', this.hideHandler);
+ }
+
+ _handleHideTooltip(e: Event | undefined) {
+ if (this.isTouchDevice) {
+ return;
+ }
+ if (!this.hasAttribute('title') || !this.originalTitle) {
+ return;
+ }
+ // Do not hide if mouse left this or this.tooltip and came to this or
+ // this.tooltip
+ if (
+ (e as MouseEvent)?.relatedTarget === this.tooltip ||
+ (e as MouseEvent)?.relatedTarget === this
+ ) {
+ return;
+ }
+
+ window.removeEventListener('scroll', this.windowScrollHandler);
+ this.removeEventListener('mouseleave', this.hideHandler);
+ this.removeEventListener('click', this.hideHandler);
+ this.setAttribute('title', this.originalTitle);
+ this.tooltip?.removeEventListener('mouseleave', this.hideHandler);
+
+ if (this.tooltip?.parentNode) {
+ this.tooltip.parentNode.removeChild(this.tooltip);
+ }
+ this.tooltip = null;
+ }
+
+ _handleWindowScroll() {
+ if (!this.tooltip) {
+ return;
+ }
+ // This wait is needed for tooltips to be positioned correctly in Firefox
+ // and Safari.
+ this.updateComplete.then(() => this._positionTooltip(this.tooltip));
+ }
+
+ // private but used in tests.
+ async _positionTooltip(tooltip: GrTooltip | null) {
+ if (tooltip === null) return;
+ const rect = this.getBoundingClientRect();
+ const boxRect = tooltip.getBoundingClientRect();
+ if (!tooltip.parentElement) {
+ return;
+ }
+ const parentRect = tooltip.parentElement.getBoundingClientRect();
+ const top = rect.top - parentRect.top;
+ const left = rect.left - parentRect.left + (rect.width - boxRect.width) / 2;
+ const right = parentRect.width - left - boxRect.width;
+ if (left < 0) {
+ tooltip.updateStyles({
+ '--gr-tooltip-arrow-center-offset': `${left}px`,
+ });
+ } else if (right < 0) {
+ tooltip.updateStyles({
+ '--gr-tooltip-arrow-center-offset': `${-0.5 * right}px`,
+ });
+ }
+ tooltip.style.left = `${Math.max(0, left)}px`;
+
+ if (!this.positionBelow) {
+ tooltip.style.top = `${Math.max(0, top)}px`;
+ tooltip.style.transform = `translateY(calc(-100% - ${BOTTOM_OFFSET}px))`;
+ } else {
+ tooltip.style.top = `${top + rect.height + BOTTOM_OFFSET}px`;
+ }
+ }
}
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_html.ts b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_html.ts
deleted file mode 100644
index 952420d..0000000
--- a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_html.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import {html} from '@polymer/polymer/lib/utils/html-tag';
-
-export const htmlTemplate = html`
- <style>
- iron-icon {
- width: var(--line-height-normal);
- height: var(--line-height-normal);
- vertical-align: top;
- }
- </style>
- <slot></slot
- ><!--
- --><iron-icon icon="gr-icons:info" hidden$="[[!showIcon]]"></iron-icon>
-`;
diff --git a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_test.js b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_test.js
index f905eaa..8d3bbb0 100644
--- a/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-tooltip-content/gr-tooltip-content_test.js
@@ -17,35 +17,162 @@
import '../../../test/common-test-setup-karma.js';
import './gr-tooltip-content.js';
-import {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-const basicFixture = fixtureFromTemplate(html`
-<gr-tooltip-content>
- </gr-tooltip-content>
-`);
+const basicFixture = fixtureFromElement('gr-tooltip-content');
suite('gr-tooltip-content tests', () => {
let element;
- setup(() => {
+
+ function makeTooltip(tooltipRect, parentRect) {
+ return {
+ getBoundingClientRect() { return tooltipRect; },
+ updateStyles: sinon.stub(),
+ style: {left: 0, top: 0},
+ parentElement: {
+ getBoundingClientRect() { return parentRect; },
+ },
+ };
+ }
+
+ setup(async () => {
element = basicFixture.instantiate();
+ element.title = 'title';
+ await element.updateComplete;
});
test('icon is not visible by default', () => {
- assert.equal(dom(element.root)
- .querySelector('iron-icon').hidden, true);
+ assert.isNotOk(element.shadowRoot.querySelector('iron-icon'));
});
- test('position-below attribute is reflected', () => {
+ test('icon is visible with showIcon property', async () => {
+ element.showIcon = true;
+ await element.updateComplete;
+ assert.isOk(element.shadowRoot.querySelector('iron-icon'));
+ });
+
+ test('position-below attribute is reflected', async () => {
assert.isFalse(element.hasAttribute('position-below'));
element.positionBelow = true;
+ await element.updateComplete;
assert.isTrue(element.hasAttribute('position-below'));
});
- test('icon is visible with showIcon property', () => {
- element.showIcon = true;
- assert.equal(dom(element.root)
- .querySelector('iron-icon').hidden, false);
+ test('normal position', () => {
+ sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
+ return {top: 100, left: 100, width: 200};
+ });
+ const tooltip = makeTooltip(
+ {height: 30, width: 50},
+ {top: 0, left: 0, width: 1000});
+
+ element._positionTooltip(tooltip);
+ assert.isFalse(tooltip.updateStyles.called);
+ assert.equal(tooltip.style.left, '175px');
+ assert.equal(tooltip.style.top, '100px');
+ });
+
+ test('left side position', () => {
+ sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
+ return {top: 100, left: 10, width: 50};
+ });
+ const tooltip = makeTooltip(
+ {height: 30, width: 120},
+ {top: 0, left: 0, width: 1000});
+
+ element._positionTooltip(tooltip);
+ assert.isTrue(tooltip.updateStyles.called);
+ const offset = tooltip.updateStyles
+ .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
+ assert.isBelow(parseFloat(offset.replace(/px$/, '')), 0);
+ assert.equal(tooltip.style.left, '0px');
+ assert.equal(tooltip.style.top, '100px');
+ });
+
+ test('right side position', () => {
+ sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
+ return {top: 100, left: 950, width: 50};
+ });
+ const tooltip = makeTooltip(
+ {height: 30, width: 120},
+ {top: 0, left: 0, width: 1000});
+
+ element._positionTooltip(tooltip);
+ assert.isTrue(tooltip.updateStyles.called);
+ const offset = tooltip.updateStyles
+ .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
+ assert.isAbove(parseFloat(offset.replace(/px$/, '')), 0);
+ assert.equal(tooltip.style.left, '915px');
+ assert.equal(tooltip.style.top, '100px');
+ });
+
+ test('position to bottom', () => {
+ sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
+ return {top: 100, left: 950, width: 50, height: 50};
+ });
+ const tooltip = makeTooltip(
+ {height: 30, width: 120},
+ {top: 0, left: 0, width: 1000});
+
+ element.positionBelow = true;
+ element._positionTooltip(tooltip);
+ assert.isTrue(tooltip.updateStyles.called);
+ const offset = tooltip.updateStyles
+ .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
+ assert.isAbove(parseFloat(offset.replace(/px$/, '')), 0);
+ assert.equal(tooltip.style.left, '915px');
+ assert.equal(tooltip.style.top, '157.2px');
+ });
+
+ test('hides tooltip when detached', async () => {
+ sinon.stub(element, '_handleHideTooltip');
+ element.remove();
+ await element.updateComplete;
+ assert.isTrue(element._handleHideTooltip.called);
+ });
+
+ test('sets up listeners when has-tooltip is changed', async () => {
+ const addListenerStub = sinon.stub(element, 'addEventListener');
+ element.hasTooltip = true;
+ await element.updateComplete;
+ assert.isTrue(addListenerStub.called);
+ });
+
+ test('clean up listeners when has-tooltip changed to false', async () => {
+ const removeListenerStub = sinon.stub(element, 'removeEventListener');
+ element.hasTooltip = true;
+ await element.updateComplete;
+ element.hasTooltip = false;
+ await element.updateComplete;
+ assert.isTrue(removeListenerStub.called);
+ });
+
+ test('do not display tooltips on touch devices', async () => {
+ // On touch devices, tooltips should not be shown.
+ element.isTouchDevice = true;
+ await element.updateComplete;
+
+ // fire mouse-enter
+ element._handleShowTooltip();
+ await element.updateComplete;
+ assert.isNotOk(element.tooltip);
+
+ // fire mouse-enter
+ element._handleHideTooltip();
+ await element.updateComplete;
+ assert.isNotOk(element.tooltip);
+
+ // On other devices, tooltips should be shown.
+ element.isTouchDevice = false;
+
+ // fire mouse-enter
+ element._handleShowTooltip();
+ await element.updateComplete;
+ assert.isOk(element.tooltip);
+
+ // fire mouse-enter
+ element._handleHideTooltip();
+ await element.updateComplete;
+ assert.isNotOk(element.tooltip);
});
});
diff --git a/polygerrit-ui/app/elements/shared/gr-vote-chip/gr-vote-chip.ts b/polygerrit-ui/app/elements/shared/gr-vote-chip/gr-vote-chip.ts
index 5b9ad5c..3762d8d 100644
--- a/polygerrit-ui/app/elements/shared/gr-vote-chip/gr-vote-chip.ts
+++ b/polygerrit-ui/app/elements/shared/gr-vote-chip/gr-vote-chip.ts
@@ -45,7 +45,7 @@
private readonly flagsService = appContext.flagsService;
- static get styles() {
+ static override get styles() {
return [
css`
.vote-chip.max {
@@ -81,13 +81,13 @@
.vote-chip,
.chip-angle {
display: flex;
- width: var(--gr-vote-chip-width, 18px);
- height: var(--gr-vote-chip-height, 18px);
+ width: var(--gr-vote-chip-width, 16px);
+ height: var(--gr-vote-chip-height, 16px);
+ font-size: var(--font-size-small);
justify-content: center;
- margin-right: var(--spacing-s);
padding: 1px;
border-radius: var(--border-radius);
- line-height: var(--gr-vote-chip-width, 18px);
+ line-height: var(--gr-vote-chip-width, 16px);
}
.vote-chip {
position: relative;
@@ -106,7 +106,7 @@
];
}
- render() {
+ override render() {
if (!this.flagsService.isEnabled(KnownExperimentId.SUBMIT_REQUIREMENTS_UI))
return;
if (!this.vote?.value) return;
diff --git a/polygerrit-ui/app/empty_test.sh b/polygerrit-ui/app/empty_test.sh
deleted file mode 100755
index e69de29..0000000
--- a/polygerrit-ui/app/empty_test.sh
+++ /dev/null
diff --git a/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin.ts b/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin.ts
deleted file mode 100644
index 9e4608f..0000000
--- a/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin.ts
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {PolymerElement} from '@polymer/polymer';
-import {Constructor} from '../../utils/common-util';
-import {property} from '@polymer/decorators';
-import {ServerInfo} from '../../types/common';
-
-/**
- * @polymer
- * @mixinFunction
- */
-export const ChangeTableMixin = <T extends Constructor<PolymerElement>>(
- superClass: T
-) => {
- /**
- * @polymer
- * @mixinClass
- */
- class Mixin extends superClass {
- @property({type: Array})
- readonly columnNames: string[] = [
- 'Subject',
- 'Status',
- 'Owner',
- 'Assignee',
- 'Reviewers',
- 'Comments',
- 'Repo',
- 'Branch',
- 'Updated',
- 'Size',
- ];
-
- isColumnHidden(columnToCheck?: string, columnsToDisplay?: string[]) {
- if (!columnsToDisplay || !columnToCheck) {
- return false;
- }
- return !columnsToDisplay.includes(columnToCheck);
- }
-
- /**
- * Is the column disabled by a server config or experiment? For example the
- * assignee feature might be disabled and thus the corresponding column is
- * also disabled.
- *
- */
- isColumnEnabled(column: string, config: ServerInfo, experiments: string[]) {
- if (!config || !config.change) return true;
- if (column === 'Assignee') return !!config.change.enable_assignee;
- if (column === 'Comments') return experiments.includes('comments-column');
- return true;
- }
-
- /**
- * @return enabled columns, see isColumnEnabled().
- */
- getEnabledColumns(
- columns: string[],
- config: ServerInfo,
- experiments: string[]
- ) {
- return columns.filter(col =>
- this.isColumnEnabled(col, config, experiments)
- );
- }
-
- /**
- * The Project column was renamed to Repo, but some users may have
- * preferences that use its old name. If that column is found, rename it
- * before use.
- *
- * @return If the column was renamed, returns a new array
- * with the corrected name. Otherwise, it returns the original param.
- */
- renameProjectToRepoColumn(columns: string[]) {
- const projectIndex = columns.indexOf('Project');
- if (projectIndex === -1) {
- return columns;
- }
- const newColumns = [...columns];
- newColumns[projectIndex] = 'Repo';
- return newColumns;
- }
- }
-
- return Mixin as T & Constructor<ChangeTableMixinInterface>;
-};
-
-export interface ChangeTableMixinInterface {
- readonly columnNames: string[];
- isColumnHidden(columnToCheck?: string, columnsToDisplay?: string[]): boolean;
- isColumnEnabled(
- column: string,
- config: ServerInfo,
- experiments: string[]
- ): boolean;
- getEnabledColumns(
- columns: string[],
- config: ServerInfo,
- experiments: string[]
- ): string[];
- renameProjectToRepoColumn(columns: string[]): string[];
-}
diff --git a/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin_test.js b/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin_test.js
deleted file mode 100644
index 8bc223f..0000000
--- a/polygerrit-ui/app/mixins/gr-change-table-mixin/gr-change-table-mixin_test.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../test/common-test-setup-karma.js';
-import {ChangeTableMixin} from './gr-change-table-mixin.js';
-import {PolymerElement} from '@polymer/polymer/polymer-element.js';
-
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ChangeTableMixin(PolymerElement);
-
-class GrChangeTableMixinTestElement extends base {
- static get is() { return 'gr-change-table-mixin-test-element'; }
-}
-
-customElements.define(GrChangeTableMixinTestElement.is,
- GrChangeTableMixinTestElement);
-
-const basicFixture = fixtureFromElement(
- 'gr-change-table-mixin-test-element');
-
-suite('gr-change-table-mixin tests', () => {
- let element;
-
- setup(() => {
- element = basicFixture.instantiate();
- });
-
- test('isColumnHidden', () => {
- const columnToCheck = 'Repo';
- let columnsToDisplay = [
- 'Subject',
- 'Status',
- 'Owner',
- 'Assignee',
- 'Repo',
- 'Branch',
- 'Updated',
- 'Size',
- ];
- assert.isFalse(element.isColumnHidden(columnToCheck, columnsToDisplay));
-
- columnsToDisplay = [
- 'Subject',
- 'Status',
- 'Owner',
- 'Assignee',
- 'Branch',
- 'Updated',
- 'Size',
- ];
- assert.isTrue(element.isColumnHidden(columnToCheck, columnsToDisplay));
- });
-
- test('renameProjectToRepoColumn maps Project to Repo', () => {
- const columns = [
- 'Subject',
- 'Status',
- 'Owner',
- ];
- assert.deepEqual(element.renameProjectToRepoColumn(columns),
- columns.slice(0));
- assert.deepEqual(
- element.renameProjectToRepoColumn(columns.concat(['Project'])),
- columns.slice(0).concat(['Repo']));
- });
-});
-
diff --git a/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin.ts b/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin.ts
deleted file mode 100644
index 70d212c..0000000
--- a/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import {encodeURL, getBaseUrl} from '../../utils/url-util';
-import {PolymerElement} from '@polymer/polymer';
-import {Constructor} from '../../utils/common-util';
-
-/**
- * @polymer
- * @mixinFunction
- */
-export const ListViewMixin = <T extends Constructor<PolymerElement>>(
- superClass: T
-) => {
- /**
- * @polymer
- * @mixinClass
- */
- class Mixin extends superClass {
- computeLoadingClass(loading: boolean): string {
- return loading ? 'loading' : '';
- }
-
- computeShownItems<T>(items: T[]): T[] {
- return items.slice(0, 25);
- }
-
- getUrl(path: string, item: string) {
- return getBaseUrl() + path + encodeURL(item, true);
- }
-
- getFilterValue<T extends ListViewParams>(params: T): string {
- if (!params) {
- return '';
- }
- return params.filter || '';
- }
-
- getOffsetValue<T extends ListViewParams>(params: T): number {
- if (params?.offset) {
- return Number(params.offset);
- }
- return 0;
- }
- }
-
- return Mixin as T & Constructor<ListViewMixinInterface>;
-};
-
-export interface ListViewMixinInterface {
- computeLoadingClass(loading: boolean): string;
- computeShownItems<T>(items: T[]): T[];
- getUrl(path: string, item: string): string;
- getFilterValue<T extends ListViewParams>(params: T): string;
- getOffsetValue<T extends ListViewParams>(params: T): number;
-}
-
-export interface ListViewParams {
- filter?: string | null;
- offset?: number | string;
-}
diff --git a/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin_test.js b/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin_test.js
deleted file mode 100644
index d2b429f..0000000
--- a/polygerrit-ui/app/mixins/gr-list-view-mixin/gr-list-view-mixin_test.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import '../../test/common-test-setup-karma.js';
-import {ListViewMixin} from './gr-list-view-mixin.js';
-import {PolymerElement} from '@polymer/polymer/polymer-element.js';
-
-const basicFixture = fixtureFromElement(
- 'gr-list-view-mixin-test-element');
-
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = ListViewMixin(PolymerElement);
-
-class GrListViewMixinTestElement extends base {
- static get is() { return 'gr-list-view-mixin-test-element'; }
-}
-
-customElements.define(GrListViewMixinTestElement.is,
- GrListViewMixinTestElement);
-
-suite('gr-list-view-mixin tests', () => {
- let element;
-
- setup(() => {
- element = basicFixture.instantiate();
- });
-
- test('computeLoadingClass', () => {
- assert.equal(element.computeLoadingClass(true), 'loading');
- assert.equal(element.computeLoadingClass(false), '');
- });
-
- test('computeShownItems', () => {
- const myArr = new Array(26);
- assert.equal(element.computeShownItems(myArr).length, 25);
- });
-
- test('getUrl', () => {
- assert.equal(element.getUrl('/path/to/something/', 'item'),
- '/path/to/something/item');
- assert.equal(element.getUrl('/path/to/something/', 'item%test'),
- '/path/to/something/item%2525test');
- });
-
- test('getFilterValue', () => {
- let params;
- assert.equal(element.getFilterValue(params), '');
-
- params = {filter: null};
- assert.equal(element.getFilterValue(params), '');
-
- params = {filter: 'test'};
- assert.equal(element.getFilterValue(params), 'test');
- });
-
- test('getOffsetValue', () => {
- let params;
- assert.equal(element.getOffsetValue(params), 0);
-
- params = {offset: null};
- assert.equal(element.getOffsetValue(params), 0);
-
- params = {offset: 1};
- assert.equal(element.getOffsetValue(params), 1);
- });
-});
-
diff --git a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
deleted file mode 100644
index 3e20d1d..0000000
--- a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin.ts
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import '../../elements/shared/gr-tooltip/gr-tooltip';
-import {flush} from '@polymer/polymer/lib/legacy/polymer.dom';
-import {getRootElement} from '../../scripts/rootElement';
-import {property, observe} from '@polymer/decorators';
-import {GrTooltip} from '../../elements/shared/gr-tooltip/gr-tooltip';
-import {PolymerElement} from '@polymer/polymer';
-import {Constructor} from '../../utils/common-util';
-
-const BOTTOM_OFFSET = 7.2; // Height of the arrow in tooltip.
-
-/** The interface corresponding to TooltipMixin */
-export interface TooltipMixinInterface {
- hasTooltip: boolean;
- positionBelow: boolean;
- _isTouchDevice: boolean;
- _tooltip: GrTooltip | null;
- _titleText: string;
- _hasSetupTooltipListeners: boolean;
-}
-
-/**
- * @polymer
- * @mixinFunction
- */
-export const TooltipMixin = <T extends Constructor<PolymerElement>>(
- superClass: T
-) => {
- /**
- * @polymer
- * @mixinClass
- */
- class Mixin extends superClass {
- @property({type: Boolean})
- hasTooltip = false;
-
- @property({type: Boolean, reflectToAttribute: true})
- positionBelow = false;
-
- @property({type: Boolean})
- _isTouchDevice = 'ontouchstart' in document.documentElement;
-
- @property({type: Object})
- _tooltip: GrTooltip | null = null;
-
- @property({type: String})
- _titleText = '';
-
- @property({type: Boolean})
- _hasSetupTooltipListeners = false;
-
- // Handler for mouseenter event
- private mouseenterHandler?: (e: MouseEvent) => void;
-
- // Handler for scrolling on window
- private readonly windowScrollHandler: () => void;
-
- // Handler for showing the tooltip, will be attached to certain events
- private readonly showHandler: () => void;
-
- // Handler for hiding the tooltip, will be attached to certain events
- private readonly hideHandler: (e: Event) => void;
-
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
- constructor(..._: any[]) {
- super();
- this.windowScrollHandler = () => this._handleWindowScroll();
- this.showHandler = () => this._handleShowTooltip();
- this.hideHandler = (e: Event | undefined) => this._handleHideTooltip(e);
- }
-
- override disconnectedCallback() {
- // NOTE: if you define your own `detached` in your component
- // then this won't take affect (as its not a class yet)
- this._handleHideTooltip(undefined);
- if (this.mouseenterHandler) {
- this.removeEventListener('mouseenter', this.mouseenterHandler);
- }
- window.removeEventListener('scroll', this.windowScrollHandler);
- super.disconnectedCallback();
- }
-
- @observe('hasTooltip')
- _setupTooltipListeners() {
- if (!this.mouseenterHandler) {
- this.mouseenterHandler = this.showHandler;
- }
-
- if (!this.hasTooltip) {
- // if attribute set to false, remove the listener
- this.removeEventListener('mouseenter', this.mouseenterHandler);
- this._hasSetupTooltipListeners = false;
- return;
- }
-
- if (this._hasSetupTooltipListeners) {
- return;
- }
- this._hasSetupTooltipListeners = true;
-
- this.addEventListener('mouseenter', this.mouseenterHandler);
- }
-
- _handleShowTooltip() {
- if (this._isTouchDevice) {
- return;
- }
-
- if (
- !this.hasAttribute('title') ||
- this.getAttribute('title') === '' ||
- this._tooltip
- ) {
- return;
- }
-
- // Store the title attribute text then set it to an empty string to
- // prevent it from showing natively.
- this._titleText = this.getAttribute('title') || '';
- this.setAttribute('title', '');
-
- const tooltip = document.createElement('gr-tooltip');
- tooltip.text = this._titleText;
- tooltip.maxWidth = this.getAttribute('max-width') || '';
- tooltip.positionBelow = this.hasAttribute('position-below');
-
- // Set visibility to hidden before appending to the DOM so that
- // calculations can be made based on the element’s size.
- tooltip.style.visibility = 'hidden';
- getRootElement().appendChild(tooltip);
- this._positionTooltip(tooltip);
- tooltip.style.visibility = 'initial';
-
- this._tooltip = tooltip;
- window.addEventListener('scroll', this.windowScrollHandler);
- this.addEventListener('mouseleave', this.hideHandler);
- this.addEventListener('click', this.hideHandler);
- tooltip.addEventListener('mouseleave', this.hideHandler);
- }
-
- _handleHideTooltip(e: Event | undefined) {
- if (this._isTouchDevice) {
- return;
- }
- if (!this.hasAttribute('title') || !this._titleText) {
- return;
- }
- // Do not hide if mouse left this or this._tooltip and came to this or
- // this._tooltip
- if (
- (e as MouseEvent)?.relatedTarget === this._tooltip ||
- (e as MouseEvent)?.relatedTarget === this
- ) {
- return;
- }
-
- window.removeEventListener('scroll', this.windowScrollHandler);
- this.removeEventListener('mouseleave', this.hideHandler);
- this.removeEventListener('click', this.hideHandler);
- this.setAttribute('title', this._titleText);
- this._tooltip?.removeEventListener('mouseleave', this.hideHandler);
-
- if (this._tooltip?.parentNode) {
- this._tooltip.parentNode.removeChild(this._tooltip);
- }
- this._tooltip = null;
- }
-
- _handleWindowScroll() {
- if (!this._tooltip) {
- return;
- }
-
- this._positionTooltip(this._tooltip);
- }
-
- _positionTooltip(tooltip: GrTooltip) {
- // This flush is needed for tooltips to be positioned correctly in Firefox
- // and Safari.
- flush();
- const rect = this.getBoundingClientRect();
- const boxRect = tooltip.getBoundingClientRect();
- if (!tooltip.parentElement) {
- return;
- }
- const parentRect = tooltip.parentElement.getBoundingClientRect();
- const top = rect.top - parentRect.top;
- const left =
- rect.left - parentRect.left + (rect.width - boxRect.width) / 2;
- const right = parentRect.width - left - boxRect.width;
- if (left < 0) {
- tooltip.updateStyles({
- '--gr-tooltip-arrow-center-offset': `${left}px`,
- });
- } else if (right < 0) {
- tooltip.updateStyles({
- '--gr-tooltip-arrow-center-offset': `${-0.5 * right}px`,
- });
- }
- tooltip.style.left = `${Math.max(0, left)}px`;
-
- if (!this.positionBelow) {
- tooltip.style.top = `${Math.max(0, top)}px`;
- tooltip.style.transform = `translateY(calc(-100% - ${BOTTOM_OFFSET}px))`;
- } else {
- tooltip.style.top = `${top + rect.height + BOTTOM_OFFSET}px`;
- }
- }
- }
-
- return Mixin as T & Constructor<TooltipMixinInterface>;
-};
diff --git a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin_test.js b/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin_test.js
deleted file mode 100644
index 69e6e86..0000000
--- a/polygerrit-ui/app/mixins/gr-tooltip-mixin/gr-tooltip-mixin_test.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * @license
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../test/common-test-setup-karma.js';
-import {PolymerElement} from '@polymer/polymer/polymer-element.js';
-import {TooltipMixin} from './gr-tooltip-mixin.js';
-
-const basicFixture = fixtureFromElement('gr-tooltip-mixin-element');
-
-// This avoids JSC_DYNAMIC_EXTENDS_WITHOUT_JSDOC closure compiler error.
-const base = TooltipMixin(PolymerElement);
-
-class GrTooltipMixinTestElement extends base {
- static get is() {
- return 'gr-tooltip-mixin-element';
- }
-}
-
-customElements.define(GrTooltipMixinTestElement.is,
- GrTooltipMixinTestElement);
-
-suite('gr-tooltip-mixin tests', () => {
- let element;
-
- function makeTooltip(tooltipRect, parentRect) {
- return {
- getBoundingClientRect() { return tooltipRect; },
- updateStyles: sinon.stub(),
- style: {left: 0, top: 0},
- parentElement: {
- getBoundingClientRect() { return parentRect; },
- },
- };
- }
-
- setup(() => {
- element = basicFixture.instantiate();
- });
-
- test('normal position', () => {
- sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
- return {top: 100, left: 100, width: 200};
- });
- const tooltip = makeTooltip(
- {height: 30, width: 50},
- {top: 0, left: 0, width: 1000});
-
- element._positionTooltip(tooltip);
- assert.isFalse(tooltip.updateStyles.called);
- assert.equal(tooltip.style.left, '175px');
- assert.equal(tooltip.style.top, '100px');
- });
-
- test('left side position', () => {
- sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
- return {top: 100, left: 10, width: 50};
- });
- const tooltip = makeTooltip(
- {height: 30, width: 120},
- {top: 0, left: 0, width: 1000});
-
- element._positionTooltip(tooltip);
- assert.isTrue(tooltip.updateStyles.called);
- const offset = tooltip.updateStyles
- .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
- assert.isBelow(parseFloat(offset.replace(/px$/, '')), 0);
- assert.equal(tooltip.style.left, '0px');
- assert.equal(tooltip.style.top, '100px');
- });
-
- test('right side position', () => {
- sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
- return {top: 100, left: 950, width: 50};
- });
- const tooltip = makeTooltip(
- {height: 30, width: 120},
- {top: 0, left: 0, width: 1000});
-
- element._positionTooltip(tooltip);
- assert.isTrue(tooltip.updateStyles.called);
- const offset = tooltip.updateStyles
- .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
- assert.isAbove(parseFloat(offset.replace(/px$/, '')), 0);
- assert.equal(tooltip.style.left, '915px');
- assert.equal(tooltip.style.top, '100px');
- });
-
- test('position to bottom', () => {
- sinon.stub(element, 'getBoundingClientRect').callsFake(() => {
- return {top: 100, left: 950, width: 50, height: 50};
- });
- const tooltip = makeTooltip(
- {height: 30, width: 120},
- {top: 0, left: 0, width: 1000});
-
- element.positionBelow = true;
- element._positionTooltip(tooltip);
- assert.isTrue(tooltip.updateStyles.called);
- const offset = tooltip.updateStyles
- .lastCall.args[0]['--gr-tooltip-arrow-center-offset'];
- assert.isAbove(parseFloat(offset.replace(/px$/, '')), 0);
- assert.equal(tooltip.style.left, '915px');
- assert.equal(tooltip.style.top, '157.2px');
- });
-
- test('hides tooltip when detached', () => {
- sinon.stub(element, '_handleHideTooltip');
- element.remove();
- flush();
- assert.isTrue(element._handleHideTooltip.called);
- });
-
- test('sets up listeners when has-tooltip is changed', () => {
- const addListenerStub = sinon.stub(element, 'addEventListener');
- element.hasTooltip = true;
- assert.isTrue(addListenerStub.called);
- });
-
- test('clean up listeners when has-tooltip changed to false', () => {
- const removeListenerStub = sinon.stub(element, 'removeEventListener');
- element.hasTooltip = true;
- element.hasTooltip = false;
- assert.isTrue(removeListenerStub.called);
- });
-});
-
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
index 5c4c9ce..3d1e120 100644
--- a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
+++ b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin.ts
@@ -14,104 +14,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/*
-
-How to Add a Keyboard Shortcut
-==============================
-
-A keyboard shortcut is composed of the following parts:
-
- 1. A semantic identifier (e.g. OPEN_CHANGE, NEXT_PAGE)
- 2. Documentation for the keyboard shortcut help dialog
- 3. A binding between key combos and the semantic identifier
- 4. A binding between the semantic identifier and a listener
-
-Parts (1) and (2) for all shortcuts are defined in this file. The semantic
-identifier is declared in the Shortcut enum near the head of this script:
-
- const Shortcut = {
- // ...
- TOGGLE_LEFT_PANE: 'TOGGLE_LEFT_PANE',
- // ...
- };
-
-Immediately following the Shortcut enum definition, there is a _describe
-function defined which is then invoked many times to populate the help dialog.
-Add a new invocation here to document the shortcut:
-
- _describe(Shortcut.TOGGLE_LEFT_PANE, ShortcutSection.DIFFS,
- 'Hide/show left diff');
-
-When an attached view binds one or more key combos to this shortcut, the help
-dialog will display this text in the given section (in this case, "Diffs"). See
-the ShortcutSection enum immediately below for the list of supported sections.
-
-Part (3), the actual key bindings, are declared by gr-app. In the future, this
-system may be expanded to allow key binding customizations by plugins or user
-preferences. Key bindings are defined in the following forms:
-
- // Ordinary shortcut with a single binding.
- this.bindShortcut(
- Shortcut.TOGGLE_LEFT_PANE, 'shift+a');
-
- // Ordinary shortcut with multiple bindings.
- this.bindShortcut(
- Shortcut.CURSOR_NEXT_FILE, 'j', 'down');
-
- // A "go-key" keyboard shortcut, which is combined with a previously and
- // continuously pressed "go" key (the go-key is hard-coded as 'g').
- this.bindShortcut(
- Shortcut.GO_TO_OPENED_CHANGES, SPECIAL_SHORTCUT.GO_KEY, 'o');
-
- // A "doc-only" keyboard shortcut. This declares the key-binding for help
- // dialog purposes, but doesn't actually implement the binding. It is up
- // to some element to implement this binding using iron-a11y-keys-behavior's
- // keyBindings property.
- this.bindShortcut(
- Shortcut.EXPAND_ALL_COMMENT_THREADS, SPECIAL_SHORTCUT.DOC_ONLY, 'e');
-
-Part (4), the listener definitions, are declared by the view or element that
-implements the shortcut behavior. This is done by implementing a method named
-keyboardShortcuts() in an element that mixes in this behavior, returning an
-object that maps semantic identifiers (as property names) to listener method
-names, like this:
-
- keyboardShortcuts() {
- return {
- [Shortcut.TOGGLE_LEFT_PANE]: '_handleToggleLeftPane',
- };
- },
-
-You can implement key bindings in an element that is hosted by a view IF that
-element is always attached exactly once under that view (e.g. the search bar in
-gr-app). When that is not the case, you will have to define a doc-only binding
-in gr-app, declare the shortcut in the view that hosts the element, and use
-iron-a11y-keys-behavior's keyBindings attribute to implement the binding in the
-element. An example of this is in comment threads. A diff view supports actions
-on comment threads, but there may be zero or many comment threads attached at
-any given point. So the shortcut is declared as doc-only by the diff view and
-by gr-app, and actually implemented by gr-comment-thread.
-
-NOTE: doc-only shortcuts will not be customizable in the same way that other
-shortcuts are.
-*/
-
import {IronA11yKeysBehavior} from '@polymer/iron-a11y-keys-behavior/iron-a11y-keys-behavior';
-import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {mixinBehaviors} from '@polymer/polymer/lib/legacy/class';
import {property} from '@polymer/decorators';
import {PolymerElement} from '@polymer/polymer';
import {check, Constructor} from '../../utils/common-util';
-import {getKeyboardEvent, isModifierPressed} from '../../utils/dom-util';
-import {CustomKeyboardEvent} from '../../types/events';
+import {isModifierPressed} from '../../utils/dom-util';
+import {IronKeyboardEvent} from '../../types/events';
import {appContext} from '../../services/app-context';
+import {
+ Shortcut,
+ ShortcutSection,
+ SPECIAL_SHORTCUT,
+} from '../../services/shortcuts/shortcuts-config';
+import {
+ ShortcutListener,
+ SectionView,
+} from '../../services/shortcuts/shortcuts-service';
-/** Enum for all special shortcuts */
-export enum SPECIAL_SHORTCUT {
- DOC_ONLY = 'DOC_ONLY',
- GO_KEY = 'GO_KEY',
- V_KEY = 'V_KEY',
-}
+export {
+ Shortcut,
+ ShortcutSection,
+ SPECIAL_SHORTCUT,
+ ShortcutListener,
+ SectionView,
+};
// The maximum age of a keydown event to be used in a jump navigation. This
// is only for cases when the keyup event is lost.
@@ -119,625 +46,6 @@
const V_KEY_TIMEOUT_MS = 1000;
-/**
- * Enum for all shortcut sections, where that shortcut should be applied to.
- */
-export enum ShortcutSection {
- ACTIONS = 'Actions',
- DIFFS = 'Diffs',
- EVERYWHERE = 'Global Shortcuts',
- FILE_LIST = 'File list',
- NAVIGATION = 'Navigation',
- REPLY_DIALOG = 'Reply dialog',
-}
-
-/**
- * Enum for all possible shortcut names.
- */
-export enum Shortcut {
- OPEN_SHORTCUT_HELP_DIALOG = 'OPEN_SHORTCUT_HELP_DIALOG',
- GO_TO_USER_DASHBOARD = 'GO_TO_USER_DASHBOARD',
- GO_TO_OPENED_CHANGES = 'GO_TO_OPENED_CHANGES',
- GO_TO_MERGED_CHANGES = 'GO_TO_MERGED_CHANGES',
- GO_TO_ABANDONED_CHANGES = 'GO_TO_ABANDONED_CHANGES',
- GO_TO_WATCHED_CHANGES = 'GO_TO_WATCHED_CHANGES',
-
- CURSOR_NEXT_CHANGE = 'CURSOR_NEXT_CHANGE',
- CURSOR_PREV_CHANGE = 'CURSOR_PREV_CHANGE',
- OPEN_CHANGE = 'OPEN_CHANGE',
- NEXT_PAGE = 'NEXT_PAGE',
- PREV_PAGE = 'PREV_PAGE',
- TOGGLE_CHANGE_REVIEWED = 'TOGGLE_CHANGE_REVIEWED',
- TOGGLE_CHANGE_STAR = 'TOGGLE_CHANGE_STAR',
- REFRESH_CHANGE_LIST = 'REFRESH_CHANGE_LIST',
- OPEN_SUBMIT_DIALOG = 'OPEN_SUBMIT_DIALOG',
-
- OPEN_REPLY_DIALOG = 'OPEN_REPLY_DIALOG',
- OPEN_DOWNLOAD_DIALOG = 'OPEN_DOWNLOAD_DIALOG',
- EXPAND_ALL_MESSAGES = 'EXPAND_ALL_MESSAGES',
- COLLAPSE_ALL_MESSAGES = 'COLLAPSE_ALL_MESSAGES',
- UP_TO_DASHBOARD = 'UP_TO_DASHBOARD',
- UP_TO_CHANGE = 'UP_TO_CHANGE',
- TOGGLE_DIFF_MODE = 'TOGGLE_DIFF_MODE',
- REFRESH_CHANGE = 'REFRESH_CHANGE',
- EDIT_TOPIC = 'EDIT_TOPIC',
- DIFF_AGAINST_BASE = 'DIFF_AGAINST_BASE',
- DIFF_AGAINST_LATEST = 'DIFF_AGAINST_LATEST',
- DIFF_BASE_AGAINST_LEFT = 'DIFF_BASE_AGAINST_LEFT',
- DIFF_RIGHT_AGAINST_LATEST = 'DIFF_RIGHT_AGAINST_LATEST',
- DIFF_BASE_AGAINST_LATEST = 'DIFF_BASE_AGAINST_LATEST',
-
- NEXT_LINE = 'NEXT_LINE',
- PREV_LINE = 'PREV_LINE',
- VISIBLE_LINE = 'VISIBLE_LINE',
- NEXT_CHUNK = 'NEXT_CHUNK',
- PREV_CHUNK = 'PREV_CHUNK',
- TOGGLE_ALL_DIFF_CONTEXT = 'TOGGLE_ALL_DIFF_CONTEXT',
- NEXT_COMMENT_THREAD = 'NEXT_COMMENT_THREAD',
- PREV_COMMENT_THREAD = 'PREV_COMMENT_THREAD',
- EXPAND_ALL_COMMENT_THREADS = 'EXPAND_ALL_COMMENT_THREADS',
- COLLAPSE_ALL_COMMENT_THREADS = 'COLLAPSE_ALL_COMMENT_THREADS',
- LEFT_PANE = 'LEFT_PANE',
- RIGHT_PANE = 'RIGHT_PANE',
- TOGGLE_LEFT_PANE = 'TOGGLE_LEFT_PANE',
- NEW_COMMENT = 'NEW_COMMENT',
- SAVE_COMMENT = 'SAVE_COMMENT',
- OPEN_DIFF_PREFS = 'OPEN_DIFF_PREFS',
- TOGGLE_DIFF_REVIEWED = 'TOGGLE_DIFF_REVIEWED',
-
- NEXT_FILE = 'NEXT_FILE',
- PREV_FILE = 'PREV_FILE',
- NEXT_FILE_WITH_COMMENTS = 'NEXT_FILE_WITH_COMMENTS',
- PREV_FILE_WITH_COMMENTS = 'PREV_FILE_WITH_COMMENTS',
- NEXT_UNREVIEWED_FILE = 'NEXT_UNREVIEWED_FILE',
- CURSOR_NEXT_FILE = 'CURSOR_NEXT_FILE',
- CURSOR_PREV_FILE = 'CURSOR_PREV_FILE',
- OPEN_FILE = 'OPEN_FILE',
- TOGGLE_FILE_REVIEWED = 'TOGGLE_FILE_REVIEWED',
- TOGGLE_ALL_INLINE_DIFFS = 'TOGGLE_ALL_INLINE_DIFFS',
- TOGGLE_INLINE_DIFF = 'TOGGLE_INLINE_DIFF',
- TOGGLE_HIDE_ALL_COMMENT_THREADS = 'TOGGLE_HIDE_ALL_COMMENT_THREADS',
- OPEN_FILE_LIST = 'OPEN_FILE_LIST',
-
- OPEN_FIRST_FILE = 'OPEN_FIRST_FILE',
- OPEN_LAST_FILE = 'OPEN_LAST_FILE',
-
- SEARCH = 'SEARCH',
- SEND_REPLY = 'SEND_REPLY',
- EMOJI_DROPDOWN = 'EMOJI_DROPDOWN',
- TOGGLE_BLAME = 'TOGGLE_BLAME',
-}
-
-export type SectionView = Array<{binding: string[][]; text: string}>;
-
-/**
- * The interface for listener for shortcut events.
- */
-export type ShortcutListener = (
- viewMap?: Map<ShortcutSection, SectionView>
-) => void;
-
-interface ShortcutHelpItem {
- shortcut: Shortcut;
- text: string;
-}
-
-// TODO(TS): rename to something more meaningful
-const _help = new Map<ShortcutSection, ShortcutHelpItem[]>();
-
-function _describe(shortcut: Shortcut, section: ShortcutSection, text: string) {
- if (!_help.has(section)) {
- _help.set(section, []);
- }
- const shortcuts = _help.get(section);
- if (shortcuts) {
- shortcuts.push({shortcut, text});
- }
-}
-
-_describe(Shortcut.SEARCH, ShortcutSection.EVERYWHERE, 'Search');
-_describe(
- Shortcut.OPEN_SHORTCUT_HELP_DIALOG,
- ShortcutSection.EVERYWHERE,
- 'Show this dialog'
-);
-_describe(
- Shortcut.GO_TO_USER_DASHBOARD,
- ShortcutSection.EVERYWHERE,
- 'Go to User Dashboard'
-);
-_describe(
- Shortcut.GO_TO_OPENED_CHANGES,
- ShortcutSection.EVERYWHERE,
- 'Go to Opened Changes'
-);
-_describe(
- Shortcut.GO_TO_MERGED_CHANGES,
- ShortcutSection.EVERYWHERE,
- 'Go to Merged Changes'
-);
-_describe(
- Shortcut.GO_TO_ABANDONED_CHANGES,
- ShortcutSection.EVERYWHERE,
- 'Go to Abandoned Changes'
-);
-_describe(
- Shortcut.GO_TO_WATCHED_CHANGES,
- ShortcutSection.EVERYWHERE,
- 'Go to Watched Changes'
-);
-
-_describe(
- Shortcut.CURSOR_NEXT_CHANGE,
- ShortcutSection.ACTIONS,
- 'Select next change'
-);
-_describe(
- Shortcut.CURSOR_PREV_CHANGE,
- ShortcutSection.ACTIONS,
- 'Select previous change'
-);
-_describe(
- Shortcut.OPEN_CHANGE,
- ShortcutSection.ACTIONS,
- 'Show selected change'
-);
-_describe(Shortcut.NEXT_PAGE, ShortcutSection.ACTIONS, 'Go to next page');
-_describe(Shortcut.PREV_PAGE, ShortcutSection.ACTIONS, 'Go to previous page');
-_describe(
- Shortcut.OPEN_REPLY_DIALOG,
- ShortcutSection.ACTIONS,
- 'Open reply dialog to publish comments and add reviewers'
-);
-_describe(
- Shortcut.OPEN_DOWNLOAD_DIALOG,
- ShortcutSection.ACTIONS,
- 'Open download overlay'
-);
-_describe(
- Shortcut.EXPAND_ALL_MESSAGES,
- ShortcutSection.ACTIONS,
- 'Expand all messages'
-);
-_describe(
- Shortcut.COLLAPSE_ALL_MESSAGES,
- ShortcutSection.ACTIONS,
- 'Collapse all messages'
-);
-_describe(
- Shortcut.REFRESH_CHANGE,
- ShortcutSection.ACTIONS,
- 'Reload the change at the latest patch'
-);
-_describe(
- Shortcut.TOGGLE_CHANGE_REVIEWED,
- ShortcutSection.ACTIONS,
- 'Mark/unmark change as reviewed'
-);
-_describe(
- Shortcut.TOGGLE_FILE_REVIEWED,
- ShortcutSection.ACTIONS,
- 'Toggle review flag on selected file'
-);
-_describe(
- Shortcut.REFRESH_CHANGE_LIST,
- ShortcutSection.ACTIONS,
- 'Refresh list of changes'
-);
-_describe(
- Shortcut.TOGGLE_CHANGE_STAR,
- ShortcutSection.ACTIONS,
- 'Star/unstar change'
-);
-_describe(
- Shortcut.OPEN_SUBMIT_DIALOG,
- ShortcutSection.ACTIONS,
- 'Open submit dialog'
-);
-_describe(Shortcut.EDIT_TOPIC, ShortcutSection.ACTIONS, 'Add a change topic');
-_describe(
- Shortcut.DIFF_AGAINST_BASE,
- ShortcutSection.ACTIONS,
- 'Diff against base'
-);
-_describe(
- Shortcut.DIFF_AGAINST_LATEST,
- ShortcutSection.ACTIONS,
- 'Diff against latest patchset'
-);
-_describe(
- Shortcut.DIFF_BASE_AGAINST_LEFT,
- ShortcutSection.ACTIONS,
- 'Diff base against left'
-);
-_describe(
- Shortcut.DIFF_RIGHT_AGAINST_LATEST,
- ShortcutSection.ACTIONS,
- 'Diff right against latest'
-);
-_describe(
- Shortcut.DIFF_BASE_AGAINST_LATEST,
- ShortcutSection.ACTIONS,
- 'Diff base against latest'
-);
-
-_describe(Shortcut.NEXT_LINE, ShortcutSection.DIFFS, 'Go to next line');
-_describe(Shortcut.PREV_LINE, ShortcutSection.DIFFS, 'Go to previous line');
-_describe(
- Shortcut.DIFF_AGAINST_BASE,
- ShortcutSection.DIFFS,
- 'Diff against base'
-);
-_describe(
- Shortcut.DIFF_AGAINST_LATEST,
- ShortcutSection.DIFFS,
- 'Diff against latest patchset'
-);
-_describe(
- Shortcut.DIFF_BASE_AGAINST_LEFT,
- ShortcutSection.DIFFS,
- 'Diff base against left'
-);
-_describe(
- Shortcut.DIFF_RIGHT_AGAINST_LATEST,
- ShortcutSection.DIFFS,
- 'Diff right against latest'
-);
-_describe(
- Shortcut.DIFF_BASE_AGAINST_LATEST,
- ShortcutSection.DIFFS,
- 'Diff base against latest'
-);
-_describe(
- Shortcut.VISIBLE_LINE,
- ShortcutSection.DIFFS,
- 'Move cursor to currently visible code'
-);
-_describe(Shortcut.NEXT_CHUNK, ShortcutSection.DIFFS, 'Go to next diff chunk');
-_describe(
- Shortcut.PREV_CHUNK,
- ShortcutSection.DIFFS,
- 'Go to previous diff chunk'
-);
-_describe(
- Shortcut.TOGGLE_ALL_DIFF_CONTEXT,
- ShortcutSection.DIFFS,
- 'Toggle all diff context'
-);
-_describe(
- Shortcut.NEXT_COMMENT_THREAD,
- ShortcutSection.DIFFS,
- 'Go to next comment thread'
-);
-_describe(
- Shortcut.PREV_COMMENT_THREAD,
- ShortcutSection.DIFFS,
- 'Go to previous comment thread'
-);
-_describe(
- Shortcut.EXPAND_ALL_COMMENT_THREADS,
- ShortcutSection.DIFFS,
- 'Expand all comment threads'
-);
-_describe(
- Shortcut.COLLAPSE_ALL_COMMENT_THREADS,
- ShortcutSection.DIFFS,
- 'Collapse all comment threads'
-);
-_describe(
- Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS,
- ShortcutSection.DIFFS,
- 'Hide/Display all comment threads'
-);
-_describe(Shortcut.LEFT_PANE, ShortcutSection.DIFFS, 'Select left pane');
-_describe(Shortcut.RIGHT_PANE, ShortcutSection.DIFFS, 'Select right pane');
-_describe(
- Shortcut.TOGGLE_LEFT_PANE,
- ShortcutSection.DIFFS,
- 'Hide/show left diff'
-);
-_describe(Shortcut.NEW_COMMENT, ShortcutSection.DIFFS, 'Draft new comment');
-_describe(Shortcut.SAVE_COMMENT, ShortcutSection.DIFFS, 'Save comment');
-_describe(
- Shortcut.OPEN_DIFF_PREFS,
- ShortcutSection.DIFFS,
- 'Show diff preferences'
-);
-_describe(
- Shortcut.TOGGLE_DIFF_REVIEWED,
- ShortcutSection.DIFFS,
- 'Mark/unmark file as reviewed'
-);
-_describe(
- Shortcut.TOGGLE_DIFF_MODE,
- ShortcutSection.DIFFS,
- 'Toggle unified/side-by-side diff'
-);
-_describe(
- Shortcut.NEXT_UNREVIEWED_FILE,
- ShortcutSection.DIFFS,
- 'Mark file as reviewed and go to next unreviewed file'
-);
-_describe(Shortcut.TOGGLE_BLAME, ShortcutSection.DIFFS, 'Toggle blame');
-
-_describe(Shortcut.NEXT_FILE, ShortcutSection.NAVIGATION, 'Go to next file');
-_describe(
- Shortcut.PREV_FILE,
- ShortcutSection.NAVIGATION,
- 'Go to previous file'
-);
-_describe(
- Shortcut.NEXT_FILE_WITH_COMMENTS,
- ShortcutSection.NAVIGATION,
- 'Go to next file that has comments'
-);
-_describe(
- Shortcut.PREV_FILE_WITH_COMMENTS,
- ShortcutSection.NAVIGATION,
- 'Go to previous file that has comments'
-);
-_describe(
- Shortcut.OPEN_FIRST_FILE,
- ShortcutSection.NAVIGATION,
- 'Go to first file'
-);
-_describe(
- Shortcut.OPEN_LAST_FILE,
- ShortcutSection.NAVIGATION,
- 'Go to last file'
-);
-_describe(
- Shortcut.UP_TO_DASHBOARD,
- ShortcutSection.NAVIGATION,
- 'Up to dashboard'
-);
-_describe(Shortcut.UP_TO_CHANGE, ShortcutSection.NAVIGATION, 'Up to change');
-
-_describe(
- Shortcut.CURSOR_NEXT_FILE,
- ShortcutSection.FILE_LIST,
- 'Select next file'
-);
-_describe(
- Shortcut.CURSOR_PREV_FILE,
- ShortcutSection.FILE_LIST,
- 'Select previous file'
-);
-_describe(Shortcut.OPEN_FILE, ShortcutSection.FILE_LIST, 'Go to selected file');
-_describe(
- Shortcut.TOGGLE_ALL_INLINE_DIFFS,
- ShortcutSection.FILE_LIST,
- 'Show/hide all inline diffs'
-);
-_describe(
- Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS,
- ShortcutSection.FILE_LIST,
- 'Hide/Display all comment threads'
-);
-_describe(
- Shortcut.TOGGLE_INLINE_DIFF,
- ShortcutSection.FILE_LIST,
- 'Show/hide selected inline diff'
-);
-
-_describe(Shortcut.SEND_REPLY, ShortcutSection.REPLY_DIALOG, 'Send reply');
-_describe(
- Shortcut.EMOJI_DROPDOWN,
- ShortcutSection.REPLY_DIALOG,
- 'Emoji dropdown'
-);
-
-/**
- * Shortcut manager, holds all hosts, bindings and listeners.
- */
-export class ShortcutManager {
- private readonly activeHosts = new Map<PolymerElement, Map<string, string>>();
-
- private readonly bindings = new Map<Shortcut, string[]>();
-
- public _testOnly_getBindings() {
- return this.bindings;
- }
-
- public _testOnly_isEmpty() {
- return this.activeHosts.size === 0 && this.listeners.size === 0;
- }
-
- private readonly listeners = new Set<ShortcutListener>();
-
- bindShortcut(shortcut: Shortcut, ...bindings: string[]) {
- this.bindings.set(shortcut, bindings);
- }
-
- getBindingsForShortcut(shortcut: Shortcut) {
- return this.bindings.get(shortcut);
- }
-
- attachHost(host: PolymerElement, shortcuts: Map<string, string>) {
- this.activeHosts.set(host, shortcuts);
- this.notifyListeners();
- }
-
- detachHost(host: PolymerElement) {
- if (this.activeHosts.delete(host)) {
- this.notifyListeners();
- return true;
- }
- return false;
- }
-
- addListener(listener: ShortcutListener) {
- this.listeners.add(listener);
- listener(this.directoryView());
- }
-
- removeListener(listener: ShortcutListener) {
- return this.listeners.delete(listener);
- }
-
- getDescription(section: ShortcutSection, shortcutName: Shortcut) {
- const bindings = _help.get(section);
- let desc = '';
- if (bindings) {
- const binding = bindings.find(
- binding => binding.shortcut === shortcutName
- );
- desc = binding ? binding.text : '';
- }
- return desc;
- }
-
- getShortcut(shortcutName: Shortcut) {
- const bindings = this.bindings.get(shortcutName);
- return bindings
- ? bindings
- .map(binding => this.describeBinding(binding).join('+'))
- .join(',')
- : '';
- }
-
- activeShortcutsBySection() {
- const activeShortcuts = new Set<string>();
- this.activeHosts.forEach(shortcuts => {
- shortcuts.forEach((_, shortcut) => activeShortcuts.add(shortcut));
- });
-
- const activeShortcutsBySection = new Map<
- ShortcutSection,
- ShortcutHelpItem[]
- >();
- _help.forEach((shortcutList, section) => {
- shortcutList.forEach(shortcutHelp => {
- if (activeShortcuts.has(shortcutHelp.shortcut)) {
- if (!activeShortcutsBySection.has(section)) {
- activeShortcutsBySection.set(section, []);
- }
- // From previous condition, the `get(section)`
- // should always return a valid result
- activeShortcutsBySection.get(section)!.push(shortcutHelp);
- }
- });
- });
- return activeShortcutsBySection;
- }
-
- directoryView() {
- const view = new Map<ShortcutSection, SectionView>();
- this.activeShortcutsBySection().forEach((shortcutHelps, section) => {
- const sectionView: Array<{binding: string[][]; text: string}> = [];
- shortcutHelps.forEach(shortcutHelp => {
- const bindingDesc = this.describeBindings(shortcutHelp.shortcut);
- if (!bindingDesc) {
- return;
- }
- this.distributeBindingDesc(bindingDesc).forEach(bindingDesc => {
- sectionView.push({
- binding: bindingDesc,
- text: shortcutHelp.text,
- });
- });
- });
- view.set(section, sectionView);
- });
- return view;
- }
-
- distributeBindingDesc(bindingDesc: string[][]): string[][][] {
- if (
- bindingDesc.length === 1 ||
- this.comboSetDisplayWidth(bindingDesc) < 21
- ) {
- return [bindingDesc];
- }
- // Find the largest prefix of bindings that is under the
- // size threshold.
- const head = [bindingDesc[0]];
- for (let i = 1; i < bindingDesc.length; i++) {
- head.push(bindingDesc[i]);
- if (this.comboSetDisplayWidth(head) >= 21) {
- head.pop();
- return [head].concat(this.distributeBindingDesc(bindingDesc.slice(i)));
- }
- }
- return [];
- }
-
- comboSetDisplayWidth(bindingDesc: string[][]) {
- const bindingSizer = (binding: string[]) =>
- binding.reduce((acc, key) => acc + key.length, 0);
- // Width is the sum of strings + (n-1) * 2 to account for the word
- // "or" joining them.
- return (
- bindingDesc.reduce((acc, binding) => acc + bindingSizer(binding), 0) +
- 2 * (bindingDesc.length - 1)
- );
- }
-
- describeBindings(shortcut: Shortcut): string[][] | null {
- const bindings = this.bindings.get(shortcut);
- if (!bindings) {
- return null;
- }
- if (bindings[0] === SPECIAL_SHORTCUT.GO_KEY) {
- return bindings
- .slice(1)
- .map(binding => this._describeKey(binding))
- .map(binding => ['g'].concat(binding));
- }
- if (bindings[0] === SPECIAL_SHORTCUT.V_KEY) {
- return bindings
- .slice(1)
- .map(binding => this._describeKey(binding))
- .map(binding => ['v'].concat(binding));
- }
-
- return bindings
- .filter(binding => binding !== SPECIAL_SHORTCUT.DOC_ONLY)
- .map(binding => this.describeBinding(binding));
- }
-
- _describeKey(key: string) {
- switch (key) {
- case 'shift':
- return 'Shift';
- case 'meta':
- return 'Meta';
- case 'ctrl':
- return 'Ctrl';
- case 'enter':
- return 'Enter';
- case 'up':
- return '\u2191'; // ↑
- case 'down':
- return '\u2193'; // ↓
- case 'left':
- return '\u2190'; // ←
- case 'right':
- return '\u2192'; // →
- default:
- return key;
- }
- }
-
- describeBinding(binding: string) {
- // single key bindings
- if (binding.length === 1) {
- return [binding];
- }
- return binding
- .split(':')[0]
- .split('+')
- .map(part => this._describeKey(part));
- }
-
- notifyListeners() {
- const view = this.directoryView();
- this.listeners.forEach(listener => listener(view));
- }
-}
-
-const shortcutManager = new ShortcutManager();
-
interface IronA11yKeysMixinConstructor {
// Note: this is needed to have same interface as other mixins
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -773,11 +81,7 @@
ShortcutSection = ShortcutSection;
- private _disableKeyboardShortcuts = false;
-
- private readonly restApiService = appContext.restApiService;
-
- private reporting = appContext.reportingService;
+ private readonly shortcuts = appContext.shortcutsService;
/** Used to disable shortcuts when the element is not visible. */
private observer?: IntersectionObserver;
@@ -796,76 +100,18 @@
/** Are shortcuts currently enabled? True only when element is visible. */
private bindingsEnabled = false;
- modifierPressed(event: CustomKeyboardEvent) {
+ modifierPressed(e: IronKeyboardEvent) {
/* We are checking for g/v as modifiers pressed. There are cases such as
* pressing v and then /, where we want the handler for / to be triggered.
* TODO(dhruvsri): find a way to support that keyboard combination
*/
- const e = getKeyboardEvent(event);
return (
isModifierPressed(e) || !!this._inGoKeyMode() || !!this.inVKeyMode()
);
}
- shouldSuppressKeyboardShortcut(event: CustomKeyboardEvent) {
- if (this._disableKeyboardShortcuts) return true;
- const e = getKeyboardEvent(event);
- // TODO(TS): maybe override the EventApi, narrow it down to Element always
- const target = (dom(e) as EventApi).rootTarget as Element;
- const tagName = target.tagName;
- const type = target.getAttribute('type');
- if (
- // Suppress shortcuts on <input> and <textarea>, but not on
- // checkboxes, because we want to enable workflows like 'click
- // mark-reviewed and then press ] to go to the next file'.
- (tagName === 'INPUT' && type !== 'checkbox') ||
- tagName === 'TEXTAREA' ||
- // Suppress shortcuts if the key is 'enter'
- // and target is an anchor or button or paper-tab.
- (e.keyCode === 13 &&
- (tagName === 'A' || tagName === 'BUTTON' || tagName === 'PAPER-TAB'))
- ) {
- return true;
- }
- for (let i = 0; e.path && i < e.path.length; i++) {
- // TODO(TS): narrow this down to Element from EventTarget first
- if ((e.path[i] as Element).tagName === 'GR-OVERLAY') {
- return true;
- }
- }
-
- // eg: {key: "k:keydown", ..., from: "gr-diff-view"}
- let key = `${(e as unknown as KeyboardEvent).key}:${e.type}`;
- if (this._inGoKeyMode()) key = 'g+' + key;
- if (this.inVKeyMode()) key = 'v+' + key;
- if (e.shiftKey) key = 'shift+' + key;
- if (e.ctrlKey) key = 'ctrl+' + key;
- if (e.metaKey) key = 'meta+' + key;
- if (e.altKey) key = 'alt+' + key;
- this.reporting.reportInteraction('shortcut-triggered', {
- key,
- from: this.nodeName ?? 'unknown',
- });
- return false;
- }
-
- // Alias for getKeyboardEvent.
- getKeyboardEvent(e: CustomKeyboardEvent) {
- return getKeyboardEvent(e);
- }
-
- bindShortcut(shortcut: Shortcut, ...bindings: string[]) {
- shortcutManager.bindShortcut(shortcut, ...bindings);
- }
-
- createTitle(shortcutName: Shortcut, section: ShortcutSection) {
- const desc = shortcutManager.getDescription(section, shortcutName);
- const shortcut = shortcutManager.getShortcut(shortcutName);
- return desc && shortcut ? `${desc} (shortcut: ${shortcut})` : '';
- }
-
_addOwnKeyBindings(shortcut: Shortcut, handler: string) {
- const bindings = shortcutManager.getBindingsForShortcut(shortcut);
+ const bindings = this.shortcuts.getBindingsForShortcut(shortcut);
if (!bindings) {
return;
}
@@ -890,11 +136,6 @@
override connectedCallback() {
super.connectedCallback();
- this.restApiService.getPreferences().then(prefs => {
- if (prefs?.disable_keyboard_shortcuts) {
- this._disableKeyboardShortcuts = true;
- }
- });
this.createVisibilityObserver();
this.enableBindings();
}
@@ -941,7 +182,7 @@
const shortcuts = new Map<string, string>(
Object.entries(this.keyboardShortcuts())
);
- shortcutManager.attachHost(this, shortcuts);
+ this.shortcuts.attachHost(this, shortcuts);
for (const [key, value] of shortcuts.entries()) {
this._addOwnKeyBindings(key as Shortcut, value);
@@ -977,7 +218,7 @@
private disableBindings() {
if (!this.bindingsEnabled) return;
this.bindingsEnabled = false;
- if (shortcutManager.detachHost(this)) {
+ if (this.shortcuts.detachHost(this)) {
this.removeOwnKeyBindings();
}
}
@@ -990,16 +231,8 @@
return {};
}
- addKeyboardShortcutDirectoryListener(listener: ShortcutListener) {
- shortcutManager.addListener(listener);
- }
-
- removeKeyboardShortcutDirectoryListener(listener: ShortcutListener) {
- shortcutManager.removeListener(listener);
- }
-
- _handleVKeyDown(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleVKeyDown(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
this._shortcut_v_key_last_pressed = Date.now();
}
@@ -1016,11 +249,11 @@
);
}
- _handleVAction(e: CustomKeyboardEvent) {
+ _handleVAction(e: IronKeyboardEvent) {
if (
!this.inVKeyMode() ||
!this._shortcut_v_table.has(e.detail.key) ||
- this.shouldSuppressKeyboardShortcut(e)
+ this.shortcuts.shouldSuppress(e)
) {
return;
}
@@ -1033,8 +266,8 @@
}
}
- _handleGoKeyDown(e: CustomKeyboardEvent) {
- if (this.shouldSuppressKeyboardShortcut(e)) return;
+ _handleGoKeyDown(e: IronKeyboardEvent) {
+ if (this.shortcuts.shouldSuppress(e)) return;
this._shortcut_go_key_last_pressed = Date.now();
}
@@ -1053,11 +286,11 @@
);
}
- _handleGoAction(e: CustomKeyboardEvent) {
+ _handleGoAction(e: IronKeyboardEvent) {
if (
!this._inGoKeyMode() ||
!this._shortcut_go_table.has(e.detail.key) ||
- this.shouldSuppressKeyboardShortcut(e)
+ this.shortcuts.shouldSuppress(e)
) {
return;
}
@@ -1071,7 +304,10 @@
}
}
- return Mixin as T & Constructor<KeyboardShortcutMixinInterface>;
+ return Mixin as T &
+ Constructor<
+ KeyboardShortcutMixinInterface & KeyboardShortcutMixinInterfaceTesting
+ >;
};
// The following doesn't work (IronA11yKeysBehavior crashes):
@@ -1084,7 +320,10 @@
// This is a workaround
export const KeyboardShortcutMixin = <T extends Constructor<PolymerElement>>(
superClass: T
-): T & Constructor<KeyboardShortcutMixinInterface> =>
+): T &
+ Constructor<
+ KeyboardShortcutMixinInterface & KeyboardShortcutMixinInterfaceTesting
+ > =>
InternalKeyboardShortcutMixin(
// TODO(TS): mixinBehaviors in some lib is returning: `new () => T` instead
// which will fail the type check due to missing IronA11yKeysBehavior interface
@@ -1094,21 +333,14 @@
/** The interface corresponding to KeyboardShortcutMixin */
export interface KeyboardShortcutMixinInterface {
- Shortcut: typeof Shortcut;
- ShortcutSection: typeof ShortcutSection;
+ keyboardShortcuts(): {[key: string]: string | null};
+ modifierPressed(event: IronKeyboardEvent): boolean;
+}
+
+export interface KeyboardShortcutMixinInterfaceTesting {
_shortcut_go_key_last_pressed: number | null;
_shortcut_v_key_last_pressed: number | null;
_shortcut_go_table: Map<string, string>;
_shortcut_v_table: Map<string, string>;
- keyboardShortcuts(): {[key: string]: string | null};
- createTitle(name: Shortcut, section: ShortcutSection): string;
- bindShortcut(shortcut: Shortcut, ...bindings: string[]): void;
- shouldSuppressKeyboardShortcut(event: CustomKeyboardEvent): boolean;
- modifierPressed(event: CustomKeyboardEvent): boolean;
- addKeyboardShortcutDirectoryListener(listener: ShortcutListener): void;
- removeKeyboardShortcutDirectoryListener(listener: ShortcutListener): void;
-}
-
-export function _testOnly_getShortcutManagerInstance() {
- return shortcutManager;
+ _handleGoAction: (e: IronKeyboardEvent) => void;
}
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.js b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.js
deleted file mode 100644
index 4536ecd..0000000
--- a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.js
+++ /dev/null
@@ -1,424 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import '../../test/common-test-setup-karma.js';
-import {
- KeyboardShortcutMixin, Shortcut,
- ShortcutManager, ShortcutSection, SPECIAL_SHORTCUT,
-} from './keyboard-shortcut-mixin.js';
-import {html} from '@polymer/polymer/lib/utils/html-tag.js';
-import {PolymerElement} from '@polymer/polymer/polymer-element.js';
-import {mockPromise} from '../../test/test-utils.js';
-
-const basicFixture =
- fixtureFromElement('keyboard-shortcut-mixin-test-element');
-
-const withinOverlayFixture = fixtureFromTemplate(html`
-<gr-overlay>
- <keyboard-shortcut-mixin-test-element>
- </keyboard-shortcut-mixin-test-element>
-</gr-overlay>
-`);
-
-class GrKeyboardShortcutMixinTestElement extends
- KeyboardShortcutMixin(PolymerElement) {
- static get is() {
- return 'keyboard-shortcut-mixin-test-element';
- }
-
- get keyBindings() {
- return {
- k: '_handleKey',
- enter: '_handleKey',
- };
- }
-
- _handleKey() {}
-}
-
-customElements.define(GrKeyboardShortcutMixinTestElement.is,
- GrKeyboardShortcutMixinTestElement);
-
-suite('keyboard-shortcut-mixin tests', () => {
- let element;
- let overlay;
-
- setup(() => {
- element = basicFixture.instantiate();
- overlay = withinOverlayFixture.instantiate();
- });
-
- suite('ShortcutManager', () => {
- test('bindings management', () => {
- const mgr = new ShortcutManager();
- const NEXT_FILE = Shortcut.NEXT_FILE;
-
- assert.isUndefined(mgr.getBindingsForShortcut(NEXT_FILE));
- mgr.bindShortcut(NEXT_FILE, ']', '}', 'right');
- assert.deepEqual(
- mgr.getBindingsForShortcut(NEXT_FILE),
- [']', '}', 'right']);
- });
-
- test('getShortcut', () => {
- const mgr = new ShortcutManager();
- const NEXT_FILE = Shortcut.NEXT_FILE;
-
- assert.isUndefined(mgr.getBindingsForShortcut(NEXT_FILE));
- mgr.bindShortcut(NEXT_FILE, ']', '}', 'right');
- assert.equal(mgr.getShortcut(NEXT_FILE), '],},→');
- });
-
- test('getShortcut with modifiers', () => {
- const mgr = new ShortcutManager();
- const NEXT_FILE = Shortcut.NEXT_FILE;
-
- assert.isUndefined(mgr.getBindingsForShortcut(NEXT_FILE));
- mgr.bindShortcut(NEXT_FILE, 'Shift+a:key');
- assert.equal(mgr.getShortcut(NEXT_FILE), 'Shift+a');
- });
-
- suite('binding descriptions', () => {
- function mapToObject(m) {
- const o = {};
- m.forEach((v, k) => o[k] = v);
- return o;
- }
-
- test('single combo description', () => {
- const mgr = new ShortcutManager();
- assert.deepEqual(mgr.describeBinding('a'), ['a']);
- assert.deepEqual(mgr.describeBinding('a:keyup'), ['a']);
- assert.deepEqual(mgr.describeBinding('ctrl+a'), ['Ctrl', 'a']);
- assert.deepEqual(
- mgr.describeBinding('ctrl+shift+up:keyup'),
- ['Ctrl', 'Shift', '↑']);
- });
-
- test('combo set description', () => {
- const mgr = new ShortcutManager();
- assert.isNull(mgr.describeBindings(Shortcut.NEXT_FILE));
-
- mgr.bindShortcut(Shortcut.GO_TO_OPENED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY, 'o');
- assert.deepEqual(
- mgr.describeBindings(Shortcut.GO_TO_OPENED_CHANGES),
- [['g', 'o']]);
-
- mgr.bindShortcut(Shortcut.NEXT_FILE, SPECIAL_SHORTCUT.DOC_ONLY,
- ']', 'ctrl+shift+right:keyup');
- assert.deepEqual(
- mgr.describeBindings(Shortcut.NEXT_FILE),
- [[']'], ['Ctrl', 'Shift', '→']]);
-
- mgr.bindShortcut(Shortcut.PREV_FILE, '[');
- assert.deepEqual(mgr.describeBindings(Shortcut.PREV_FILE), [['[']]);
- });
-
- test('combo set description width', () => {
- const mgr = new ShortcutManager();
- assert.strictEqual(mgr.comboSetDisplayWidth([['u']]), 1);
- assert.strictEqual(mgr.comboSetDisplayWidth([['g', 'o']]), 2);
- assert.strictEqual(mgr.comboSetDisplayWidth([['Shift', 'r']]), 6);
- assert.strictEqual(mgr.comboSetDisplayWidth([['x'], ['y']]), 4);
- assert.strictEqual(
- mgr.comboSetDisplayWidth([['x'], ['y'], ['Shift', 'z']]),
- 12);
- });
-
- test('distribute shortcut help', () => {
- const mgr = new ShortcutManager();
- assert.deepEqual(mgr.distributeBindingDesc([['o']]), [[['o']]]);
- assert.deepEqual(
- mgr.distributeBindingDesc([['g', 'o']]),
- [[['g', 'o']]]);
- assert.deepEqual(
- mgr.distributeBindingDesc([['ctrl', 'shift', 'meta', 'enter']]),
- [[['ctrl', 'shift', 'meta', 'enter']]]);
- assert.deepEqual(
- mgr.distributeBindingDesc([
- ['ctrl', 'shift', 'meta', 'enter'],
- ['o'],
- ]),
- [
- [['ctrl', 'shift', 'meta', 'enter']],
- [['o']],
- ]);
- assert.deepEqual(
- mgr.distributeBindingDesc([
- ['ctrl', 'enter'],
- ['meta', 'enter'],
- ['ctrl', 's'],
- ['meta', 's'],
- ]),
- [
- [['ctrl', 'enter'], ['meta', 'enter']],
- [['ctrl', 's'], ['meta', 's']],
- ]);
- });
-
- test('active shortcuts by section', () => {
- const mgr = new ShortcutManager();
- mgr.bindShortcut(Shortcut.NEXT_FILE, ']');
- mgr.bindShortcut(Shortcut.NEXT_LINE, 'j');
- mgr.bindShortcut(Shortcut.GO_TO_OPENED_CHANGES, 'g+o');
- mgr.bindShortcut(Shortcut.SEARCH, '/');
-
- assert.deepEqual(
- mapToObject(mgr.activeShortcutsBySection()),
- {});
-
- mgr.attachHost({}, new Map([[Shortcut.NEXT_FILE, null]]));
- assert.deepEqual(
- mapToObject(mgr.activeShortcutsBySection()),
- {
- [ShortcutSection.NAVIGATION]: [
- {shortcut: Shortcut.NEXT_FILE, text: 'Go to next file'},
- ],
- });
-
- mgr.attachHost({}, new Map([[Shortcut.NEXT_LINE, null]]));
- assert.deepEqual(
- mapToObject(mgr.activeShortcutsBySection()),
- {
- [ShortcutSection.DIFFS]: [
- {shortcut: Shortcut.NEXT_LINE, text: 'Go to next line'},
- ],
- [ShortcutSection.NAVIGATION]: [
- {shortcut: Shortcut.NEXT_FILE, text: 'Go to next file'},
- ],
- });
-
- mgr.attachHost({}, new Map([
- [Shortcut.SEARCH, null],
- [Shortcut.GO_TO_OPENED_CHANGES, null],
- ]));
- assert.deepEqual(
- mapToObject(mgr.activeShortcutsBySection()),
- {
- [ShortcutSection.DIFFS]: [
- {shortcut: Shortcut.NEXT_LINE, text: 'Go to next line'},
- ],
- [ShortcutSection.EVERYWHERE]: [
- {shortcut: Shortcut.SEARCH, text: 'Search'},
- {
- shortcut: Shortcut.GO_TO_OPENED_CHANGES,
- text: 'Go to Opened Changes',
- },
- ],
- [ShortcutSection.NAVIGATION]: [
- {shortcut: Shortcut.NEXT_FILE, text: 'Go to next file'},
- ],
- });
- });
-
- test('directory view', () => {
- const mgr = new ShortcutManager();
- mgr.bindShortcut(Shortcut.NEXT_FILE, ']');
- mgr.bindShortcut(Shortcut.NEXT_LINE, 'j');
- mgr.bindShortcut(Shortcut.GO_TO_OPENED_CHANGES,
- SPECIAL_SHORTCUT.GO_KEY, 'o');
- mgr.bindShortcut(Shortcut.SEARCH, '/');
- mgr.bindShortcut(
- Shortcut.SAVE_COMMENT, 'ctrl+enter', 'meta+enter',
- 'ctrl+s', 'meta+s');
-
- assert.deepEqual(mapToObject(mgr.directoryView()), {});
-
- mgr.attachHost({}, new Map([
- [Shortcut.GO_TO_OPENED_CHANGES, null],
- [Shortcut.NEXT_FILE, null],
- [Shortcut.NEXT_LINE, null],
- [Shortcut.SAVE_COMMENT, null],
- [Shortcut.SEARCH, null],
- ]));
- assert.deepEqual(
- mapToObject(mgr.directoryView()),
- {
- [ShortcutSection.DIFFS]: [
- {binding: [['j']], text: 'Go to next line'},
- {
- binding: [['Ctrl', 'Enter'], ['Meta', 'Enter']],
- text: 'Save comment',
- },
- {
- binding: [['Ctrl', 's'], ['Meta', 's']],
- text: 'Save comment',
- },
- ],
- [ShortcutSection.EVERYWHERE]: [
- {binding: [['/']], text: 'Search'},
- {binding: [['g', 'o']], text: 'Go to Opened Changes'},
- ],
- [ShortcutSection.NAVIGATION]: [
- {binding: [[']']], text: 'Go to next file'},
- ],
- });
- });
- });
- });
-
- test('doesn’t block kb shortcuts for non-allowed els', async () => {
- const divEl = document.createElement('div');
- element.appendChild(divEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isFalse(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(divEl, 75, null, 'k');
- await promise;
- });
-
- test('blocks kb shortcuts for input els', async () => {
- const inputEl = document.createElement('input');
- element.appendChild(inputEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isTrue(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(inputEl, 75, null, 'k');
- await promise;
- });
-
- test('doesn’t block kb shortcuts for checkboxes', async () => {
- const inputEl = document.createElement('input');
- inputEl.setAttribute('type', 'checkbox');
- element.appendChild(inputEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isFalse(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(inputEl, 75, null, 'k');
- await promise;
- });
-
- test('blocks kb shortcuts for textarea els', async () => {
- const textareaEl = document.createElement('textarea');
- element.appendChild(textareaEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isTrue(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(textareaEl, 75, null, 'k');
- await promise;
- });
-
- test('blocks kb shortcuts for anything in a gr-overlay', async () => {
- const divEl = document.createElement('div');
- const element =
- overlay.querySelector('keyboard-shortcut-mixin-test-element');
- element.appendChild(divEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isTrue(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(divEl, 75, null, 'k');
- await promise;
- });
-
- test('blocks enter shortcut on an anchor', async () => {
- const anchorEl = document.createElement('a');
- const element =
- overlay.querySelector('keyboard-shortcut-mixin-test-element');
- element.appendChild(anchorEl);
- const promise = mockPromise();
- element._handleKey = e => {
- assert.isTrue(element.shouldSuppressKeyboardShortcut(e));
- promise.resolve();
- };
- MockInteractions.keyDownOn(anchorEl, 13, null, 'enter');
- await promise;
- });
-
- test('modifierPressed returns accurate values', () => {
- const spy = sinon.spy(element, 'modifierPressed');
- element._handleKey = e => {
- element.modifierPressed(e);
- };
- MockInteractions.keyDownOn(element, 75, 'shift', 'k');
- assert.isTrue(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, null, 'k');
- assert.isFalse(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, 'ctrl', 'k');
- assert.isTrue(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, null, 'k');
- assert.isFalse(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, 'meta', 'k');
- assert.isTrue(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, null, 'k');
- assert.isFalse(spy.lastCall.returnValue);
- MockInteractions.keyDownOn(element, 75, 'alt', 'k');
- assert.isTrue(spy.lastCall.returnValue);
- });
-
- suite('GO_KEY timing', () => {
- let handlerStub;
-
- setup(() => {
- element._shortcut_go_table.set('a', '_handleA');
- handlerStub = element._handleA = sinon.stub();
- sinon.stub(Date, 'now').returns(10000);
- });
-
- test('success', () => {
- const e = {detail: {key: 'a'}, preventDefault: () => {}};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._shortcut_go_key_last_pressed = 9000;
- element._handleGoAction(e);
- assert.isTrue(handlerStub.calledOnce);
- assert.strictEqual(handlerStub.lastCall.args[0], e);
- });
-
- test('go key not pressed', () => {
- const e = {detail: {key: 'a'}, preventDefault: () => {}};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._shortcut_go_key_last_pressed = null;
- element._handleGoAction(e);
- assert.isFalse(handlerStub.called);
- });
-
- test('go key pressed too long ago', () => {
- const e = {detail: {key: 'a'}, preventDefault: () => {}};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._shortcut_go_key_last_pressed = 3000;
- element._handleGoAction(e);
- assert.isFalse(handlerStub.called);
- });
-
- test('should suppress', () => {
- const e = {detail: {key: 'a'}, preventDefault: () => {}};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(true);
- element._shortcut_go_key_last_pressed = 9000;
- element._handleGoAction(e);
- assert.isFalse(handlerStub.called);
- });
-
- test('unrecognized key', () => {
- const e = {detail: {key: 'f'}, preventDefault: () => {}};
- sinon.stub(element, 'shouldSuppressKeyboardShortcut').returns(false);
- element._shortcut_go_key_last_pressed = 9000;
- element._handleGoAction(e);
- assert.isFalse(handlerStub.called);
- });
- });
-});
-
diff --git a/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.ts b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.ts
new file mode 100644
index 0000000..01ad6cc
--- /dev/null
+++ b/polygerrit-ui/app/mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin_test.ts
@@ -0,0 +1,139 @@
+/**
+ * @license
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import '../../test/common-test-setup-karma';
+import {KeyboardShortcutMixin} from './keyboard-shortcut-mixin';
+import {PolymerElement} from '@polymer/polymer/polymer-element';
+import '../../elements/shared/gr-overlay/gr-overlay';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+import {IronKeyboardEvent} from '../../types/events';
+
+class GrKeyboardShortcutMixinTestElement extends KeyboardShortcutMixin(
+ PolymerElement
+) {
+ static get is() {
+ return 'keyboard-shortcut-mixin-test-element';
+ }
+
+ get keyBindings() {
+ return {
+ k: '_handleKey',
+ enter: '_handleKey',
+ };
+ }
+
+ _handleKey(_: any) {}
+
+ _handleA(_: any) {}
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ 'keyboard-shortcut-mixin-test-element': GrKeyboardShortcutMixinTestElement;
+ }
+}
+
+customElements.define(
+ GrKeyboardShortcutMixinTestElement.is,
+ GrKeyboardShortcutMixinTestElement
+);
+
+const basicFixture = fixtureFromElement('keyboard-shortcut-mixin-test-element');
+
+suite('keyboard-shortcut-mixin tests', () => {
+ let element: GrKeyboardShortcutMixinTestElement;
+
+ setup(async () => {
+ element = basicFixture.instantiate();
+ await flush();
+ });
+
+ test('modifierPressed returns accurate values', () => {
+ const spy = sinon.spy(element, 'modifierPressed');
+ element._handleKey = e => {
+ element.modifierPressed(e);
+ };
+ MockInteractions.keyDownOn(element, 75, 'shift', 'k');
+ assert.isTrue(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, null, 'k');
+ assert.isFalse(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, 'ctrl', 'k');
+ assert.isTrue(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, null, 'k');
+ assert.isFalse(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, 'meta', 'k');
+ assert.isTrue(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, null, 'k');
+ assert.isFalse(spy.lastCall.returnValue);
+ MockInteractions.keyDownOn(element, 75, 'alt', 'k');
+ assert.isTrue(spy.lastCall.returnValue);
+ });
+
+ suite('GO_KEY timing', () => {
+ let handlerStub: sinon.SinonStub;
+
+ setup(() => {
+ element._shortcut_go_table.set('a', '_handleA');
+ handlerStub = element._handleA = sinon.stub();
+ sinon.stub(Date, 'now').returns(10000);
+ });
+
+ test('success', () => {
+ const e = {
+ detail: {key: 'a'},
+ preventDefault: () => {},
+ composedPath: () => [],
+ } as unknown as IronKeyboardEvent;
+ element._shortcut_go_key_last_pressed = 9000;
+ element._handleGoAction(e);
+ assert.isTrue(handlerStub.calledOnce);
+ assert.strictEqual(handlerStub.lastCall.args[0], e);
+ });
+
+ test('go key not pressed', () => {
+ const e = {
+ detail: {key: 'a'},
+ preventDefault: () => {},
+ composedPath: () => [],
+ } as unknown as IronKeyboardEvent;
+ element._shortcut_go_key_last_pressed = null;
+ element._handleGoAction(e);
+ assert.isFalse(handlerStub.called);
+ });
+
+ test('go key pressed too long ago', () => {
+ const e = {
+ detail: {key: 'a'},
+ preventDefault: () => {},
+ composedPath: () => [],
+ } as unknown as IronKeyboardEvent;
+ element._shortcut_go_key_last_pressed = 3000;
+ element._handleGoAction(e);
+ assert.isFalse(handlerStub.called);
+ });
+
+ test('unrecognized key', () => {
+ const e = {
+ detail: {key: 'f'},
+ preventDefault: () => {},
+ composedPath: () => [],
+ } as unknown as IronKeyboardEvent;
+ element._shortcut_go_key_last_pressed = 9000;
+ element._handleGoAction(e);
+ assert.isFalse(handlerStub.called);
+ });
+ });
+});
diff --git a/polygerrit-ui/app/services/app-context-init.ts b/polygerrit-ui/app/services/app-context-init.ts
index ade9529..3a6f7c5 100644
--- a/polygerrit-ui/app/services/app-context-init.ts
+++ b/polygerrit-ui/app/services/app-context-init.ts
@@ -27,6 +27,7 @@
import {ConfigService} from './config/config-service';
import {UserService} from './user/user-service';
import {CommentsService} from './comments/comments-service';
+import {ShortcutsService} from './shortcuts/shortcuts-service';
type ServiceName = keyof AppContext;
type ServiceCreator<T> = () => T;
@@ -82,5 +83,6 @@
storageService: () => new GrStorageService(),
configService: () => new ConfigService(),
userService: () => new UserService(appContext.restApiService),
+ shortcutsService: () => new ShortcutsService(appContext.reportingService),
});
}
diff --git a/polygerrit-ui/app/services/app-context.ts b/polygerrit-ui/app/services/app-context.ts
index 161378d..e5828d6 100644
--- a/polygerrit-ui/app/services/app-context.ts
+++ b/polygerrit-ui/app/services/app-context.ts
@@ -26,6 +26,7 @@
import {ConfigService} from './config/config-service';
import {UserService} from './user/user-service';
import {CommentsService} from './comments/comments-service';
+import {ShortcutsService} from './shortcuts/shortcuts-service';
export interface AppContext {
flagsService: FlagsService;
@@ -40,6 +41,7 @@
storageService: StorageService;
configService: ConfigService;
userService: UserService;
+ shortcutsService: ShortcutsService;
}
/**
diff --git a/polygerrit-ui/app/services/checks/checks-model.ts b/polygerrit-ui/app/services/checks/checks-model.ts
index f5d6e35..75c24b6 100644
--- a/polygerrit-ui/app/services/checks/checks-model.ts
+++ b/polygerrit-ui/app/services/checks/checks-model.ts
@@ -353,7 +353,7 @@
export const fakeRun0: CheckRun = {
pluginName: 'f0',
internalRunId: 'f0',
- checkName: 'FAKE Error Finder Finder Finder',
+ checkName: 'FAKE Error Finder Finder Finder Finder Finder Finder Finder',
labelName: 'Presubmit',
isSingleAttempt: true,
isLatestAttempt: true,
@@ -546,7 +546,7 @@
pluginName: 'f4',
internalRunId: 'f4',
checkName: 'FAKE Elimination Long Long Long Long Long',
- status: RunStatus.COMPLETED,
+ status: RunStatus.RUNNABLE,
attempt: 1,
isSingleAttempt: false,
isLatestAttempt: false,
diff --git a/polygerrit-ui/app/services/checks/checks-util.ts b/polygerrit-ui/app/services/checks/checks-util.ts
index 37ebe9d..18cc076 100644
--- a/polygerrit-ui/app/services/checks/checks-util.ts
+++ b/polygerrit-ui/app/services/checks/checks-util.ts
@@ -167,6 +167,19 @@
return {...action, name};
}
+export function headerForStatus(status: RunStatus) {
+ switch (status) {
+ case RunStatus.COMPLETED:
+ return 'Completed';
+ case RunStatus.RUNNABLE:
+ return 'Not run';
+ case RunStatus.RUNNING:
+ return 'Running';
+ default:
+ assertNever(status, `Unsupported status: ${status}`);
+ }
+}
+
function primaryActionName(status: RunStatus) {
switch (status) {
case RunStatus.COMPLETED:
diff --git a/polygerrit-ui/app/services/flags/flags.ts b/polygerrit-ui/app/services/flags/flags.ts
index 21f3aa4..2839874 100644
--- a/polygerrit-ui/app/services/flags/flags.ts
+++ b/polygerrit-ui/app/services/flags/flags.ts
@@ -25,7 +25,7 @@
*/
export enum KnownExperimentId {
NEW_IMAGE_DIFF_UI = 'UiFeature__new_image_diff_ui',
+ TOKEN_HIGHLIGHTING = 'UiFeature__token_highlighting',
CHECKS_DEVELOPER = 'UiFeature__checks_developer',
- NEW_REPLY_DIALOG = 'UiFeature__new_reply_dialog',
SUBMIT_REQUIREMENTS_UI = 'UiFeature__submit_requirements_ui',
}
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
index 1445a59..06f1a0c 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
@@ -57,6 +57,7 @@
reportExtension(name: string): void;
pluginLoaded(name: string): void;
pluginsLoaded(pluginsList?: string[]): void;
+ pluginsFailed(pluginsList?: string[]): void;
error(err: Error, reporter?: string, details?: EventDetails): void;
/**
* Reset named timer.
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index 0df7d12..65a5784 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -636,6 +636,18 @@
);
}
+ pluginsFailed(pluginsList?: string[]) {
+ if (!pluginsList || pluginsList.length === 0) return;
+ this.reporter(
+ LIFECYCLE.TYPE,
+ LIFECYCLE.CATEGORY.PLUGINS_INSTALLED,
+ LifeCycle.PLUGINS_FAILED,
+ undefined,
+ {pluginsList: pluginsList || []},
+ true
+ );
+ }
+
/**
* Reset named Timing.
*/
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
index 13461bf..337cf2f 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
@@ -56,6 +56,7 @@
},
pluginLoaded: () => {},
pluginsLoaded: () => {},
+ pluginsFailed: () => {},
recordDraftInteraction: () => {},
reporter: () => {},
reportErrorDialog: (message: string) => {
diff --git a/polygerrit-ui/app/services/shortcuts/shortcuts-config.ts b/polygerrit-ui/app/services/shortcuts/shortcuts-config.ts
new file mode 100644
index 0000000..bd004d7
--- /dev/null
+++ b/polygerrit-ui/app/services/shortcuts/shortcuts-config.ts
@@ -0,0 +1,552 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** Enum for all special shortcuts */
+export enum SPECIAL_SHORTCUT {
+ DOC_ONLY = 'DOC_ONLY',
+ GO_KEY = 'GO_KEY',
+ V_KEY = 'V_KEY',
+}
+
+/**
+ * Enum for all shortcut sections, where that shortcut should be applied to.
+ */
+export enum ShortcutSection {
+ ACTIONS = 'Actions',
+ DIFFS = 'Diffs',
+ EVERYWHERE = 'Global Shortcuts',
+ FILE_LIST = 'File list',
+ NAVIGATION = 'Navigation',
+ REPLY_DIALOG = 'Reply dialog',
+}
+
+/**
+ * Enum for all possible shortcut names.
+ */
+export enum Shortcut {
+ OPEN_SHORTCUT_HELP_DIALOG = 'OPEN_SHORTCUT_HELP_DIALOG',
+ GO_TO_USER_DASHBOARD = 'GO_TO_USER_DASHBOARD',
+ GO_TO_OPENED_CHANGES = 'GO_TO_OPENED_CHANGES',
+ GO_TO_MERGED_CHANGES = 'GO_TO_MERGED_CHANGES',
+ GO_TO_ABANDONED_CHANGES = 'GO_TO_ABANDONED_CHANGES',
+ GO_TO_WATCHED_CHANGES = 'GO_TO_WATCHED_CHANGES',
+
+ CURSOR_NEXT_CHANGE = 'CURSOR_NEXT_CHANGE',
+ CURSOR_PREV_CHANGE = 'CURSOR_PREV_CHANGE',
+ OPEN_CHANGE = 'OPEN_CHANGE',
+ NEXT_PAGE = 'NEXT_PAGE',
+ PREV_PAGE = 'PREV_PAGE',
+ TOGGLE_CHANGE_REVIEWED = 'TOGGLE_CHANGE_REVIEWED',
+ TOGGLE_CHANGE_STAR = 'TOGGLE_CHANGE_STAR',
+ REFRESH_CHANGE_LIST = 'REFRESH_CHANGE_LIST',
+ OPEN_SUBMIT_DIALOG = 'OPEN_SUBMIT_DIALOG',
+ TOGGLE_ATTENTION_SET = 'TOGGLE_ATTENTION_SET',
+
+ OPEN_REPLY_DIALOG = 'OPEN_REPLY_DIALOG',
+ OPEN_DOWNLOAD_DIALOG = 'OPEN_DOWNLOAD_DIALOG',
+ EXPAND_ALL_MESSAGES = 'EXPAND_ALL_MESSAGES',
+ COLLAPSE_ALL_MESSAGES = 'COLLAPSE_ALL_MESSAGES',
+ UP_TO_DASHBOARD = 'UP_TO_DASHBOARD',
+ UP_TO_CHANGE = 'UP_TO_CHANGE',
+ TOGGLE_DIFF_MODE = 'TOGGLE_DIFF_MODE',
+ REFRESH_CHANGE = 'REFRESH_CHANGE',
+ EDIT_TOPIC = 'EDIT_TOPIC',
+ DIFF_AGAINST_BASE = 'DIFF_AGAINST_BASE',
+ DIFF_AGAINST_LATEST = 'DIFF_AGAINST_LATEST',
+ DIFF_BASE_AGAINST_LEFT = 'DIFF_BASE_AGAINST_LEFT',
+ DIFF_RIGHT_AGAINST_LATEST = 'DIFF_RIGHT_AGAINST_LATEST',
+ DIFF_BASE_AGAINST_LATEST = 'DIFF_BASE_AGAINST_LATEST',
+
+ NEXT_LINE = 'NEXT_LINE',
+ PREV_LINE = 'PREV_LINE',
+ VISIBLE_LINE = 'VISIBLE_LINE',
+ NEXT_CHUNK = 'NEXT_CHUNK',
+ PREV_CHUNK = 'PREV_CHUNK',
+ TOGGLE_ALL_DIFF_CONTEXT = 'TOGGLE_ALL_DIFF_CONTEXT',
+ NEXT_COMMENT_THREAD = 'NEXT_COMMENT_THREAD',
+ PREV_COMMENT_THREAD = 'PREV_COMMENT_THREAD',
+ EXPAND_ALL_COMMENT_THREADS = 'EXPAND_ALL_COMMENT_THREADS',
+ COLLAPSE_ALL_COMMENT_THREADS = 'COLLAPSE_ALL_COMMENT_THREADS',
+ LEFT_PANE = 'LEFT_PANE',
+ RIGHT_PANE = 'RIGHT_PANE',
+ TOGGLE_LEFT_PANE = 'TOGGLE_LEFT_PANE',
+ NEW_COMMENT = 'NEW_COMMENT',
+ SAVE_COMMENT = 'SAVE_COMMENT',
+ OPEN_DIFF_PREFS = 'OPEN_DIFF_PREFS',
+ TOGGLE_DIFF_REVIEWED = 'TOGGLE_DIFF_REVIEWED',
+
+ NEXT_FILE = 'NEXT_FILE',
+ PREV_FILE = 'PREV_FILE',
+ NEXT_FILE_WITH_COMMENTS = 'NEXT_FILE_WITH_COMMENTS',
+ PREV_FILE_WITH_COMMENTS = 'PREV_FILE_WITH_COMMENTS',
+ NEXT_UNREVIEWED_FILE = 'NEXT_UNREVIEWED_FILE',
+ CURSOR_NEXT_FILE = 'CURSOR_NEXT_FILE',
+ CURSOR_PREV_FILE = 'CURSOR_PREV_FILE',
+ OPEN_FILE = 'OPEN_FILE',
+ TOGGLE_FILE_REVIEWED = 'TOGGLE_FILE_REVIEWED',
+ TOGGLE_ALL_INLINE_DIFFS = 'TOGGLE_ALL_INLINE_DIFFS',
+ TOGGLE_INLINE_DIFF = 'TOGGLE_INLINE_DIFF',
+ TOGGLE_HIDE_ALL_COMMENT_THREADS = 'TOGGLE_HIDE_ALL_COMMENT_THREADS',
+ OPEN_FILE_LIST = 'OPEN_FILE_LIST',
+
+ OPEN_FIRST_FILE = 'OPEN_FIRST_FILE',
+ OPEN_LAST_FILE = 'OPEN_LAST_FILE',
+
+ SEARCH = 'SEARCH',
+ SEND_REPLY = 'SEND_REPLY',
+ EMOJI_DROPDOWN = 'EMOJI_DROPDOWN',
+ TOGGLE_BLAME = 'TOGGLE_BLAME',
+}
+
+export interface ShortcutHelpItem {
+ shortcut: Shortcut;
+ text: string;
+ bindings: string[];
+}
+
+export const config = new Map<ShortcutSection, ShortcutHelpItem[]>();
+
+function describe(
+ shortcut: Shortcut,
+ section: ShortcutSection,
+ text: string,
+ binding: string,
+ ...moreBindings: string[]
+) {
+ if (!config.has(section)) {
+ config.set(section, []);
+ }
+ const shortcuts = config.get(section);
+ if (shortcuts) {
+ shortcuts.push({shortcut, text, bindings: [binding, ...moreBindings]});
+ }
+}
+
+describe(Shortcut.SEARCH, ShortcutSection.EVERYWHERE, 'Search', '/');
+describe(
+ Shortcut.OPEN_SHORTCUT_HELP_DIALOG,
+ ShortcutSection.EVERYWHERE,
+ 'Show this dialog',
+ '?'
+);
+describe(
+ Shortcut.GO_TO_USER_DASHBOARD,
+ ShortcutSection.EVERYWHERE,
+ 'Go to User Dashboard',
+ SPECIAL_SHORTCUT.GO_KEY,
+ 'i'
+);
+describe(
+ Shortcut.GO_TO_OPENED_CHANGES,
+ ShortcutSection.EVERYWHERE,
+ 'Go to Opened Changes',
+ SPECIAL_SHORTCUT.GO_KEY,
+ 'o'
+);
+describe(
+ Shortcut.GO_TO_MERGED_CHANGES,
+ ShortcutSection.EVERYWHERE,
+ 'Go to Merged Changes',
+ SPECIAL_SHORTCUT.GO_KEY,
+ 'm'
+);
+describe(
+ Shortcut.GO_TO_ABANDONED_CHANGES,
+ ShortcutSection.EVERYWHERE,
+ 'Go to Abandoned Changes',
+ SPECIAL_SHORTCUT.GO_KEY,
+ 'a'
+);
+describe(
+ Shortcut.GO_TO_WATCHED_CHANGES,
+ ShortcutSection.EVERYWHERE,
+ 'Go to Watched Changes',
+ SPECIAL_SHORTCUT.GO_KEY,
+ 'w'
+);
+
+describe(
+ Shortcut.CURSOR_NEXT_CHANGE,
+ ShortcutSection.ACTIONS,
+ 'Select next change',
+ 'j'
+);
+describe(
+ Shortcut.CURSOR_PREV_CHANGE,
+ ShortcutSection.ACTIONS,
+ 'Select previous change',
+ 'k'
+);
+describe(
+ Shortcut.OPEN_CHANGE,
+ ShortcutSection.ACTIONS,
+ 'Show selected change',
+ 'o'
+);
+describe(
+ Shortcut.NEXT_PAGE,
+ ShortcutSection.ACTIONS,
+ 'Go to next page',
+ 'n',
+ ']'
+);
+describe(
+ Shortcut.PREV_PAGE,
+ ShortcutSection.ACTIONS,
+ 'Go to previous page',
+ 'p',
+ '['
+);
+describe(
+ Shortcut.OPEN_REPLY_DIALOG,
+ ShortcutSection.ACTIONS,
+ 'Open reply dialog to publish comments and add reviewers',
+ 'a:keyup'
+);
+describe(
+ Shortcut.OPEN_DOWNLOAD_DIALOG,
+ ShortcutSection.ACTIONS,
+ 'Open download overlay',
+ 'd:keyup'
+);
+describe(
+ Shortcut.EXPAND_ALL_MESSAGES,
+ ShortcutSection.ACTIONS,
+ 'Expand all messages',
+ 'x'
+);
+describe(
+ Shortcut.COLLAPSE_ALL_MESSAGES,
+ ShortcutSection.ACTIONS,
+ 'Collapse all messages',
+ 'z'
+);
+describe(
+ Shortcut.REFRESH_CHANGE,
+ ShortcutSection.ACTIONS,
+ 'Reload the change at the latest patch',
+ 'shift+r:keyup'
+);
+describe(
+ Shortcut.TOGGLE_CHANGE_REVIEWED,
+ ShortcutSection.ACTIONS,
+ 'Mark/unmark change as reviewed',
+ 'r:keyup'
+);
+describe(
+ Shortcut.TOGGLE_FILE_REVIEWED,
+ ShortcutSection.ACTIONS,
+ 'Toggle review flag on selected file',
+ 'r:keyup'
+);
+describe(
+ Shortcut.REFRESH_CHANGE_LIST,
+ ShortcutSection.ACTIONS,
+ 'Refresh list of changes',
+ 'shift+r:keyup'
+);
+describe(
+ Shortcut.TOGGLE_CHANGE_STAR,
+ ShortcutSection.ACTIONS,
+ 'Star/unstar change',
+ 's:keydown'
+);
+describe(
+ Shortcut.OPEN_SUBMIT_DIALOG,
+ ShortcutSection.ACTIONS,
+ 'Open submit dialog',
+ 'shift+s'
+);
+describe(
+ Shortcut.TOGGLE_ATTENTION_SET,
+ ShortcutSection.ACTIONS,
+ 'Toggle attention set status',
+ 'shift+t'
+);
+describe(
+ Shortcut.EDIT_TOPIC,
+ ShortcutSection.ACTIONS,
+ 'Add a change topic',
+ 't'
+);
+describe(
+ Shortcut.DIFF_AGAINST_BASE,
+ ShortcutSection.DIFFS,
+ 'Diff against base',
+ SPECIAL_SHORTCUT.V_KEY,
+ 'down',
+ 's'
+);
+describe(
+ Shortcut.DIFF_AGAINST_LATEST,
+ ShortcutSection.DIFFS,
+ 'Diff against latest patchset',
+ SPECIAL_SHORTCUT.V_KEY,
+ 'up',
+ 'w'
+);
+describe(
+ Shortcut.DIFF_BASE_AGAINST_LEFT,
+ ShortcutSection.DIFFS,
+ 'Diff base against left',
+ SPECIAL_SHORTCUT.V_KEY,
+ 'left',
+ 'a'
+);
+describe(
+ Shortcut.DIFF_RIGHT_AGAINST_LATEST,
+ ShortcutSection.DIFFS,
+ 'Diff right against latest',
+ SPECIAL_SHORTCUT.V_KEY,
+ 'right',
+ 'd'
+);
+describe(
+ Shortcut.DIFF_BASE_AGAINST_LATEST,
+ ShortcutSection.DIFFS,
+ 'Diff base against latest',
+ SPECIAL_SHORTCUT.V_KEY,
+ 'b'
+);
+
+describe(
+ Shortcut.NEXT_LINE,
+ ShortcutSection.DIFFS,
+ 'Go to next line',
+ 'j',
+ 'down'
+);
+describe(
+ Shortcut.PREV_LINE,
+ ShortcutSection.DIFFS,
+ 'Go to previous line',
+ 'k',
+ 'up'
+);
+describe(
+ Shortcut.VISIBLE_LINE,
+ ShortcutSection.DIFFS,
+ 'Move cursor to currently visible code',
+ '.'
+);
+describe(
+ Shortcut.NEXT_CHUNK,
+ ShortcutSection.DIFFS,
+ 'Go to next diff chunk',
+ 'n'
+);
+describe(
+ Shortcut.PREV_CHUNK,
+ ShortcutSection.DIFFS,
+ 'Go to previous diff chunk',
+ 'p'
+);
+describe(
+ Shortcut.TOGGLE_ALL_DIFF_CONTEXT,
+ ShortcutSection.DIFFS,
+ 'Toggle all diff context',
+ 'shift+x'
+);
+describe(
+ Shortcut.NEXT_COMMENT_THREAD,
+ ShortcutSection.DIFFS,
+ 'Go to next comment thread',
+ 'shift+n'
+);
+describe(
+ Shortcut.PREV_COMMENT_THREAD,
+ ShortcutSection.DIFFS,
+ 'Go to previous comment thread',
+ 'shift+p'
+);
+describe(
+ Shortcut.EXPAND_ALL_COMMENT_THREADS,
+ ShortcutSection.DIFFS,
+ 'Expand all comment threads',
+ SPECIAL_SHORTCUT.DOC_ONLY,
+ 'e'
+);
+describe(
+ Shortcut.COLLAPSE_ALL_COMMENT_THREADS,
+ ShortcutSection.DIFFS,
+ 'Collapse all comment threads',
+ SPECIAL_SHORTCUT.DOC_ONLY,
+ 'shift+e'
+);
+describe(
+ Shortcut.TOGGLE_HIDE_ALL_COMMENT_THREADS,
+ ShortcutSection.DIFFS,
+ 'Hide/Display all comment threads',
+ 'h'
+);
+describe(
+ Shortcut.LEFT_PANE,
+ ShortcutSection.DIFFS,
+ 'Select left pane',
+ 'shift+left'
+);
+describe(
+ Shortcut.RIGHT_PANE,
+ ShortcutSection.DIFFS,
+ 'Select right pane',
+ 'shift+right'
+);
+describe(
+ Shortcut.TOGGLE_LEFT_PANE,
+ ShortcutSection.DIFFS,
+ 'Hide/show left diff',
+ 'shift+a'
+);
+describe(Shortcut.NEW_COMMENT, ShortcutSection.DIFFS, 'Draft new comment', 'c');
+describe(
+ Shortcut.SAVE_COMMENT,
+ ShortcutSection.DIFFS,
+ 'Save comment',
+ 'ctrl+enter',
+ 'meta+enter',
+ 'ctrl+s',
+ 'meta+s'
+);
+describe(
+ Shortcut.OPEN_DIFF_PREFS,
+ ShortcutSection.DIFFS,
+ 'Show diff preferences',
+ ','
+);
+describe(
+ Shortcut.TOGGLE_DIFF_REVIEWED,
+ ShortcutSection.DIFFS,
+ 'Mark/unmark file as reviewed',
+ 'r:keyup'
+);
+describe(
+ Shortcut.TOGGLE_DIFF_MODE,
+ ShortcutSection.DIFFS,
+ 'Toggle unified/side-by-side diff',
+ 'm:keyup'
+);
+describe(
+ Shortcut.NEXT_UNREVIEWED_FILE,
+ ShortcutSection.DIFFS,
+ 'Mark file as reviewed and go to next unreviewed file',
+ 'shift+m'
+);
+describe(
+ Shortcut.TOGGLE_BLAME,
+ ShortcutSection.DIFFS,
+ 'Toggle blame',
+ 'b:keyup'
+);
+describe(Shortcut.OPEN_FILE_LIST, ShortcutSection.DIFFS, 'Open file list', 'f');
+describe(
+ Shortcut.NEXT_FILE,
+ ShortcutSection.NAVIGATION,
+ 'Go to next file',
+ ']'
+);
+describe(
+ Shortcut.PREV_FILE,
+ ShortcutSection.NAVIGATION,
+ 'Go to previous file',
+ '['
+);
+describe(
+ Shortcut.NEXT_FILE_WITH_COMMENTS,
+ ShortcutSection.NAVIGATION,
+ 'Go to next file that has comments',
+ 'shift+j'
+);
+describe(
+ Shortcut.PREV_FILE_WITH_COMMENTS,
+ ShortcutSection.NAVIGATION,
+ 'Go to previous file that has comments',
+ 'shift+k'
+);
+describe(
+ Shortcut.OPEN_FIRST_FILE,
+ ShortcutSection.NAVIGATION,
+ 'Go to first file',
+ ']'
+);
+describe(
+ Shortcut.OPEN_LAST_FILE,
+ ShortcutSection.NAVIGATION,
+ 'Go to last file',
+ '['
+);
+describe(
+ Shortcut.UP_TO_DASHBOARD,
+ ShortcutSection.NAVIGATION,
+ 'Up to dashboard',
+ 'u'
+);
+describe(
+ Shortcut.UP_TO_CHANGE,
+ ShortcutSection.NAVIGATION,
+ 'Up to change',
+ 'u'
+);
+
+describe(
+ Shortcut.CURSOR_NEXT_FILE,
+ ShortcutSection.FILE_LIST,
+ 'Select next file',
+ 'j',
+ 'down'
+);
+describe(
+ Shortcut.CURSOR_PREV_FILE,
+ ShortcutSection.FILE_LIST,
+ 'Select previous file',
+ 'k',
+ 'up'
+);
+describe(
+ Shortcut.OPEN_FILE,
+ ShortcutSection.FILE_LIST,
+ 'Go to selected file',
+ 'o',
+ 'enter'
+);
+describe(
+ Shortcut.TOGGLE_ALL_INLINE_DIFFS,
+ ShortcutSection.FILE_LIST,
+ 'Show/hide all inline diffs',
+ 'shift+i'
+);
+describe(
+ Shortcut.TOGGLE_INLINE_DIFF,
+ ShortcutSection.FILE_LIST,
+ 'Show/hide selected inline diff',
+ 'i'
+);
+
+describe(
+ Shortcut.SEND_REPLY,
+ ShortcutSection.REPLY_DIALOG,
+ 'Send reply',
+ SPECIAL_SHORTCUT.DOC_ONLY,
+ 'ctrl+enter',
+ 'meta+enter'
+);
+describe(
+ Shortcut.EMOJI_DROPDOWN,
+ ShortcutSection.REPLY_DIALOG,
+ 'Emoji dropdown',
+ SPECIAL_SHORTCUT.DOC_ONLY,
+ ':'
+);
diff --git a/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts b/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts
new file mode 100644
index 0000000..d0e2d49
--- /dev/null
+++ b/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts
@@ -0,0 +1,317 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {
+ config,
+ Shortcut,
+ ShortcutHelpItem,
+ ShortcutSection,
+ SPECIAL_SHORTCUT,
+} from './shortcuts-config';
+import {disableShortcuts$} from '../user/user-model';
+import {IronKeyboardEvent, isIronKeyboardEvent} from '../../types/events';
+import {isElementTarget} from '../../utils/dom-util';
+import {ReportingService} from '../gr-reporting/gr-reporting';
+
+export type SectionView = Array<{binding: string[][]; text: string}>;
+
+/**
+ * The interface for listener for shortcut events.
+ */
+export type ShortcutListener = (
+ viewMap?: Map<ShortcutSection, SectionView>
+) => void;
+
+const COMBO_KEYS = ['g', 'v'];
+
+/**
+ * Shortcuts service, holds all hosts, bindings and listeners.
+ */
+export class ShortcutsService {
+ /**
+ * Keeps track of the components that are currently active such that we can
+ * show a shortcut help dialog that only shows the shortcuts that are
+ * currently relevant.
+ */
+ private readonly activeHosts = new Map<unknown, Map<string, string>>();
+
+ /** Static map built in the constructor by iterating over the config. */
+ private readonly bindings = new Map<Shortcut, string[]>();
+
+ private readonly listeners = new Set<ShortcutListener>();
+
+ /**
+ * Maps keys (e.g. 'g') to the timestamp when they have last been pressed.
+ * This enabled key combinations like 'g+o' where we can check whether 'g' was
+ * pressed recently when 'o' is processed. Keys of this map must be items of
+ * COMBO_KEYS. Values are Date timestamps in milliseconds.
+ */
+ private readonly keyLastPressed = new Map<string, number>();
+
+ /** Keeps track of the corresponding user preference. */
+ private shortcutsDisabled = false;
+
+ constructor(readonly reporting?: ReportingService) {
+ for (const section of config.keys()) {
+ const items = config.get(section) ?? [];
+ for (const item of items) {
+ this.bindings.set(item.shortcut, item.bindings);
+ }
+ }
+ disableShortcuts$.subscribe(x => (this.shortcutsDisabled = x));
+ document.addEventListener('keydown', (e: KeyboardEvent) => {
+ if (!COMBO_KEYS.includes(e.key)) return;
+ if (this.shouldSuppress(e)) return;
+ this.keyLastPressed.set(e.key, Date.now());
+ });
+ }
+
+ public _testOnly_isEmpty() {
+ return this.activeHosts.size === 0 && this.listeners.size === 0;
+ }
+
+ shouldSuppress(event: IronKeyboardEvent | KeyboardEvent) {
+ if (this.shortcutsDisabled) return true;
+ const e = isIronKeyboardEvent(event) ? event.detail.keyboardEvent : event;
+
+ // Note that when you listen on document, then `e.currentTarget` will be the
+ // document and `e.target` will be `<gr-app>` due to shadow dom, but by
+ // using the composedPath() you can actually find the true origin of the
+ // event.
+ const rootTarget = e.composedPath()[0];
+ if (!isElementTarget(rootTarget)) return false;
+ const tagName = rootTarget.tagName;
+ const type = rootTarget.getAttribute('type');
+
+ if (
+ // Suppress shortcuts on <input> and <textarea>, but not on
+ // checkboxes, because we want to enable workflows like 'click
+ // mark-reviewed and then press ] to go to the next file'.
+ (tagName === 'INPUT' && type !== 'checkbox') ||
+ tagName === 'TEXTAREA' ||
+ // Suppress shortcuts if the key is 'enter'
+ // and target is an anchor or button or paper-tab.
+ (e.keyCode === 13 &&
+ (tagName === 'A' || tagName === 'BUTTON' || tagName === 'PAPER-TAB'))
+ ) {
+ return true;
+ }
+ const path: EventTarget[] = e.composedPath() ?? [];
+ for (const el of path) {
+ if (!isElementTarget(el)) continue;
+ if (el.tagName === 'GR-OVERLAY') return true;
+ }
+ // eg: {key: "k:keydown", ..., from: "gr-diff-view"}
+ let key = `${e.key}:${e.type}`;
+ // TODO(brohlfs): Re-enable reporting of g- and v-keys.
+ // if (this._inGoKeyMode()) key = 'g+' + key;
+ // if (this.inVKeyMode()) key = 'v+' + key;
+ if (e.shiftKey) key = 'shift+' + key;
+ if (e.ctrlKey) key = 'ctrl+' + key;
+ if (e.metaKey) key = 'meta+' + key;
+ if (e.altKey) key = 'alt+' + key;
+ let from = 'unknown';
+ if (isElementTarget(e.currentTarget)) {
+ from = e.currentTarget.tagName;
+ }
+ this.reporting?.reportInteraction('shortcut-triggered', {key, from});
+ return false;
+ }
+
+ createTitle(shortcutName: Shortcut, section: ShortcutSection) {
+ const desc = this.getDescription(section, shortcutName);
+ const shortcut = this.getShortcut(shortcutName);
+ return desc && shortcut ? `${desc} (shortcut: ${shortcut})` : '';
+ }
+
+ getBindingsForShortcut(shortcut: Shortcut) {
+ return this.bindings.get(shortcut);
+ }
+
+ attachHost(host: unknown, shortcuts: Map<string, string>) {
+ this.activeHosts.set(host, shortcuts);
+ this.notifyListeners();
+ }
+
+ detachHost(host: unknown) {
+ if (!this.activeHosts.delete(host)) return false;
+ this.notifyListeners();
+ return true;
+ }
+
+ addListener(listener: ShortcutListener) {
+ this.listeners.add(listener);
+ listener(this.directoryView());
+ }
+
+ removeListener(listener: ShortcutListener) {
+ return this.listeners.delete(listener);
+ }
+
+ getDescription(section: ShortcutSection, shortcutName: Shortcut) {
+ const bindings = config.get(section);
+ if (!bindings) return '';
+ const binding = bindings.find(binding => binding.shortcut === shortcutName);
+ return binding?.text ?? '';
+ }
+
+ getShortcut(shortcutName: Shortcut) {
+ const bindings = this.bindings.get(shortcutName);
+ if (!bindings) return '';
+ return bindings
+ .map(binding => this.describeBinding(binding).join('+'))
+ .join(',');
+ }
+
+ activeShortcutsBySection() {
+ const activeShortcuts = new Set<string>();
+ this.activeHosts.forEach(shortcuts => {
+ shortcuts.forEach((_, shortcut) => activeShortcuts.add(shortcut));
+ });
+
+ const activeShortcutsBySection = new Map<
+ ShortcutSection,
+ ShortcutHelpItem[]
+ >();
+ config.forEach((shortcutList, section) => {
+ shortcutList.forEach(shortcutHelp => {
+ if (activeShortcuts.has(shortcutHelp.shortcut)) {
+ if (!activeShortcutsBySection.has(section)) {
+ activeShortcutsBySection.set(section, []);
+ }
+ // From previous condition, the `get(section)`
+ // should always return a valid result
+ activeShortcutsBySection.get(section)!.push(shortcutHelp);
+ }
+ });
+ });
+ return activeShortcutsBySection;
+ }
+
+ directoryView() {
+ const view = new Map<ShortcutSection, SectionView>();
+ this.activeShortcutsBySection().forEach((shortcutHelps, section) => {
+ const sectionView: SectionView = [];
+ shortcutHelps.forEach(shortcutHelp => {
+ const bindingDesc = this.describeBindings(shortcutHelp.shortcut);
+ if (!bindingDesc) {
+ return;
+ }
+ this.distributeBindingDesc(bindingDesc).forEach(bindingDesc => {
+ sectionView.push({
+ binding: bindingDesc,
+ text: shortcutHelp.text,
+ });
+ });
+ });
+ view.set(section, sectionView);
+ });
+ return view;
+ }
+
+ distributeBindingDesc(bindingDesc: string[][]): string[][][] {
+ if (
+ bindingDesc.length === 1 ||
+ this.comboSetDisplayWidth(bindingDesc) < 21
+ ) {
+ return [bindingDesc];
+ }
+ // Find the largest prefix of bindings that is under the
+ // size threshold.
+ const head = [bindingDesc[0]];
+ for (let i = 1; i < bindingDesc.length; i++) {
+ head.push(bindingDesc[i]);
+ if (this.comboSetDisplayWidth(head) >= 21) {
+ head.pop();
+ return [head].concat(this.distributeBindingDesc(bindingDesc.slice(i)));
+ }
+ }
+ return [];
+ }
+
+ comboSetDisplayWidth(bindingDesc: string[][]) {
+ const bindingSizer = (binding: string[]) =>
+ binding.reduce((acc, key) => acc + key.length, 0);
+ // Width is the sum of strings + (n-1) * 2 to account for the word
+ // "or" joining them.
+ return (
+ bindingDesc.reduce((acc, binding) => acc + bindingSizer(binding), 0) +
+ 2 * (bindingDesc.length - 1)
+ );
+ }
+
+ describeBindings(shortcut: Shortcut): string[][] | null {
+ const bindings = this.bindings.get(shortcut);
+ if (!bindings) {
+ return null;
+ }
+ if (bindings[0] === SPECIAL_SHORTCUT.GO_KEY) {
+ return bindings
+ .slice(1)
+ .map(binding => this._describeKey(binding))
+ .map(binding => ['g'].concat(binding));
+ }
+ if (bindings[0] === SPECIAL_SHORTCUT.V_KEY) {
+ return bindings
+ .slice(1)
+ .map(binding => this._describeKey(binding))
+ .map(binding => ['v'].concat(binding));
+ }
+
+ return bindings
+ .filter(binding => binding !== SPECIAL_SHORTCUT.DOC_ONLY)
+ .map(binding => this.describeBinding(binding));
+ }
+
+ _describeKey(key: string) {
+ switch (key) {
+ case 'shift':
+ return 'Shift';
+ case 'meta':
+ return 'Meta';
+ case 'ctrl':
+ return 'Ctrl';
+ case 'enter':
+ return 'Enter';
+ case 'up':
+ return '\u2191'; // ↑
+ case 'down':
+ return '\u2193'; // ↓
+ case 'left':
+ return '\u2190'; // ←
+ case 'right':
+ return '\u2192'; // →
+ default:
+ return key;
+ }
+ }
+
+ describeBinding(binding: string) {
+ // single key bindings
+ if (binding.length === 1) {
+ return [binding];
+ }
+ return binding
+ .split(':')[0]
+ .split('+')
+ .map(part => this._describeKey(part));
+ }
+
+ notifyListeners() {
+ const view = this.directoryView();
+ this.listeners.forEach(listener => listener(view));
+ }
+}
diff --git a/polygerrit-ui/app/services/shortcuts/shortcuts-service_test.ts b/polygerrit-ui/app/services/shortcuts/shortcuts-service_test.ts
new file mode 100644
index 0000000..0998a4c
--- /dev/null
+++ b/polygerrit-ui/app/services/shortcuts/shortcuts-service_test.ts
@@ -0,0 +1,293 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import '../../test/common-test-setup-karma';
+import {ShortcutsService} from '../../services/shortcuts/shortcuts-service';
+import {Shortcut, ShortcutSection} from './shortcuts-config';
+import * as MockInteractions from '@polymer/iron-test-helpers/mock-interactions';
+
+async function keyEventOn(
+ el: HTMLElement,
+ callback: (e: KeyboardEvent) => void,
+ keyCode = 75,
+ key = 'k'
+): Promise<KeyboardEvent> {
+ let resolve: (e: KeyboardEvent) => void;
+ const promise = new Promise<KeyboardEvent>(r => (resolve = r));
+ el.addEventListener('keydown', (e: KeyboardEvent) => {
+ callback(e);
+ resolve(e);
+ });
+ MockInteractions.keyDownOn(el, keyCode, null, key);
+ return await promise;
+}
+
+suite('shortcuts-service tests', () => {
+ let service: ShortcutsService;
+
+ setup(() => {
+ service = new ShortcutsService();
+ });
+
+ suite('shouldSuppress', () => {
+ test('do not suppress shortcut event from <div>', async () => {
+ await keyEventOn(document.createElement('div'), e => {
+ assert.isFalse(service.shouldSuppress(e));
+ });
+ });
+
+ test('suppress shortcut event from <input>', async () => {
+ await keyEventOn(document.createElement('input'), e => {
+ assert.isTrue(service.shouldSuppress(e));
+ });
+ });
+
+ test('suppress shortcut event from <textarea>', async () => {
+ await keyEventOn(document.createElement('textarea'), e => {
+ assert.isTrue(service.shouldSuppress(e));
+ });
+ });
+
+ test('do not suppress shortcut event from checkbox <input>', async () => {
+ const inputEl = document.createElement('input');
+ inputEl.setAttribute('type', 'checkbox');
+ await keyEventOn(inputEl, e => {
+ assert.isFalse(service.shouldSuppress(e));
+ });
+ });
+
+ test('suppress shortcut event from children of <gr-overlay>', async () => {
+ const overlay = document.createElement('gr-overlay');
+ const div = document.createElement('div');
+ overlay.appendChild(div);
+ await keyEventOn(div, e => {
+ assert.isTrue(service.shouldSuppress(e));
+ });
+ });
+
+ test('suppress "enter" shortcut event from <a>', async () => {
+ await keyEventOn(document.createElement('a'), e => {
+ assert.isFalse(service.shouldSuppress(e));
+ });
+ await keyEventOn(
+ document.createElement('a'),
+ e => assert.isTrue(service.shouldSuppress(e)),
+ 13,
+ 'enter'
+ );
+ });
+ });
+
+ test('getShortcut', () => {
+ const NEXT_FILE = Shortcut.NEXT_FILE;
+ assert.equal(service.getShortcut(NEXT_FILE), ']');
+ });
+
+ test('getShortcut with modifiers', () => {
+ const NEXT_FILE = Shortcut.TOGGLE_LEFT_PANE;
+ assert.equal(service.getShortcut(NEXT_FILE), 'Shift+a');
+ });
+
+ suite('binding descriptions', () => {
+ function mapToObject<K, V>(m: Map<K, V>) {
+ const o: any = {};
+ m.forEach((v: V, k: K) => (o[k] = v));
+ return o;
+ }
+
+ test('single combo description', () => {
+ assert.deepEqual(service.describeBinding('a'), ['a']);
+ assert.deepEqual(service.describeBinding('a:keyup'), ['a']);
+ assert.deepEqual(service.describeBinding('ctrl+a'), ['Ctrl', 'a']);
+ assert.deepEqual(service.describeBinding('ctrl+shift+up:keyup'), [
+ 'Ctrl',
+ 'Shift',
+ '↑',
+ ]);
+ });
+
+ test('combo set description', () => {
+ assert.deepEqual(
+ service.describeBindings(Shortcut.GO_TO_OPENED_CHANGES),
+ [['g', 'o']]
+ );
+ assert.deepEqual(service.describeBindings(Shortcut.SAVE_COMMENT), [
+ ['Ctrl', 'Enter'],
+ ['Meta', 'Enter'],
+ ['Ctrl', 's'],
+ ['Meta', 's'],
+ ]);
+ assert.deepEqual(service.describeBindings(Shortcut.PREV_FILE), [['[']]);
+ });
+
+ test('combo set description width', () => {
+ assert.strictEqual(service.comboSetDisplayWidth([['u']]), 1);
+ assert.strictEqual(service.comboSetDisplayWidth([['g', 'o']]), 2);
+ assert.strictEqual(service.comboSetDisplayWidth([['Shift', 'r']]), 6);
+ assert.strictEqual(service.comboSetDisplayWidth([['x'], ['y']]), 4);
+ assert.strictEqual(
+ service.comboSetDisplayWidth([['x'], ['y'], ['Shift', 'z']]),
+ 12
+ );
+ });
+
+ test('distribute shortcut help', () => {
+ assert.deepEqual(service.distributeBindingDesc([['o']]), [[['o']]]);
+ assert.deepEqual(service.distributeBindingDesc([['g', 'o']]), [
+ [['g', 'o']],
+ ]);
+ assert.deepEqual(
+ service.distributeBindingDesc([['ctrl', 'shift', 'meta', 'enter']]),
+ [[['ctrl', 'shift', 'meta', 'enter']]]
+ );
+ assert.deepEqual(
+ service.distributeBindingDesc([
+ ['ctrl', 'shift', 'meta', 'enter'],
+ ['o'],
+ ]),
+ [[['ctrl', 'shift', 'meta', 'enter']], [['o']]]
+ );
+ assert.deepEqual(
+ service.distributeBindingDesc([
+ ['ctrl', 'enter'],
+ ['meta', 'enter'],
+ ['ctrl', 's'],
+ ['meta', 's'],
+ ]),
+ [
+ [
+ ['ctrl', 'enter'],
+ ['meta', 'enter'],
+ ],
+ [
+ ['ctrl', 's'],
+ ['meta', 's'],
+ ],
+ ]
+ );
+ });
+
+ test('active shortcuts by section', () => {
+ assert.deepEqual(mapToObject(service.activeShortcutsBySection()), {});
+
+ service.attachHost({}, new Map([[Shortcut.NEXT_FILE, 'null']]));
+ assert.deepEqual(mapToObject(service.activeShortcutsBySection()), {
+ [ShortcutSection.NAVIGATION]: [
+ {
+ shortcut: Shortcut.NEXT_FILE,
+ text: 'Go to next file',
+ bindings: [']'],
+ },
+ ],
+ });
+
+ service.attachHost({}, new Map([[Shortcut.NEXT_LINE, 'null']]));
+ assert.deepEqual(mapToObject(service.activeShortcutsBySection()), {
+ [ShortcutSection.DIFFS]: [
+ {
+ shortcut: Shortcut.NEXT_LINE,
+ text: 'Go to next line',
+ bindings: ['j', 'down'],
+ },
+ ],
+ [ShortcutSection.NAVIGATION]: [
+ {
+ shortcut: Shortcut.NEXT_FILE,
+ text: 'Go to next file',
+ bindings: [']'],
+ },
+ ],
+ });
+
+ service.attachHost(
+ {},
+ new Map([
+ [Shortcut.SEARCH, 'null'],
+ [Shortcut.GO_TO_OPENED_CHANGES, 'null'],
+ ])
+ );
+ assert.deepEqual(mapToObject(service.activeShortcutsBySection()), {
+ [ShortcutSection.DIFFS]: [
+ {
+ shortcut: Shortcut.NEXT_LINE,
+ text: 'Go to next line',
+ bindings: ['j', 'down'],
+ },
+ ],
+ [ShortcutSection.EVERYWHERE]: [
+ {
+ shortcut: Shortcut.SEARCH,
+ text: 'Search',
+ bindings: ['/'],
+ },
+ {
+ shortcut: Shortcut.GO_TO_OPENED_CHANGES,
+ text: 'Go to Opened Changes',
+ bindings: ['GO_KEY', 'o'],
+ },
+ ],
+ [ShortcutSection.NAVIGATION]: [
+ {
+ shortcut: Shortcut.NEXT_FILE,
+ text: 'Go to next file',
+ bindings: [']'],
+ },
+ ],
+ });
+ });
+
+ test('directory view', () => {
+ assert.deepEqual(mapToObject(service.directoryView()), {});
+
+ service.attachHost(
+ {},
+ new Map([
+ [Shortcut.GO_TO_OPENED_CHANGES, 'null'],
+ [Shortcut.NEXT_FILE, 'null'],
+ [Shortcut.NEXT_LINE, 'null'],
+ [Shortcut.SAVE_COMMENT, 'null'],
+ [Shortcut.SEARCH, 'null'],
+ ])
+ );
+ assert.deepEqual(mapToObject(service.directoryView()), {
+ [ShortcutSection.DIFFS]: [
+ {binding: [['j'], ['↓']], text: 'Go to next line'},
+ {
+ binding: [
+ ['Ctrl', 'Enter'],
+ ['Meta', 'Enter'],
+ ],
+ text: 'Save comment',
+ },
+ {
+ binding: [
+ ['Ctrl', 's'],
+ ['Meta', 's'],
+ ],
+ text: 'Save comment',
+ },
+ ],
+ [ShortcutSection.EVERYWHERE]: [
+ {binding: [['/']], text: 'Search'},
+ {binding: [['g', 'o']], text: 'Go to Opened Changes'},
+ ],
+ [ShortcutSection.NAVIGATION]: [
+ {binding: [[']']], text: 'Go to next file'},
+ ],
+ });
+ });
+ });
+});
diff --git a/polygerrit-ui/app/services/user/user-model.ts b/polygerrit-ui/app/services/user/user-model.ts
index 4115a71..72ce3e1 100644
--- a/polygerrit-ui/app/services/user/user-model.ts
+++ b/polygerrit-ui/app/services/user/user-model.ts
@@ -60,3 +60,8 @@
map(preferences => preferences?.my ?? []),
distinctUntilChanged()
);
+
+export const disableShortcuts$ = preferences$.pipe(
+ map(preferences => preferences?.disable_keyboard_shortcuts ?? false),
+ distinctUntilChanged()
+);
diff --git a/polygerrit-ui/app/styles/gr-a11y-styles.ts b/polygerrit-ui/app/styles/gr-a11y-styles.ts
new file mode 100644
index 0000000..a1fa62b
--- /dev/null
+++ b/polygerrit-ui/app/styles/gr-a11y-styles.ts
@@ -0,0 +1,42 @@
+/**
+ * @license
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {css} from 'lit';
+
+export const a11yStyles = css`
+ .assistive-tech-only {
+ user-select: none;
+ clip: rect(1px, 1px, 1px, 1px);
+ height: 1px;
+ margin: 0;
+ overflow: hidden;
+ padding: 0;
+ position: absolute;
+ white-space: nowrap;
+ width: 1px;
+ z-index: -1000;
+ }
+`;
+
+const $_documentContainer = document.createElement('template');
+$_documentContainer.innerHTML = `<dom-module id="gr-a11y-styles">
+ <template>
+ <style>
+ ${a11yStyles.cssText}
+ </style>
+ </template>
+</dom-module>`;
+document.head.appendChild($_documentContainer.content);
diff --git a/polygerrit-ui/app/styles/gr-menu-page-styles.ts b/polygerrit-ui/app/styles/gr-menu-page-styles.ts
index 0471a4e..5f58571 100644
--- a/polygerrit-ui/app/styles/gr-menu-page-styles.ts
+++ b/polygerrit-ui/app/styles/gr-menu-page-styles.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {css} from 'lit-element';
+import {css} from 'lit';
export const menuPageStyles = css`
:host {
diff --git a/polygerrit-ui/app/styles/gr-spinner-styles.ts b/polygerrit-ui/app/styles/gr-spinner-styles.ts
index 0f8341f..6015be4 100644
--- a/polygerrit-ui/app/styles/gr-spinner-styles.ts
+++ b/polygerrit-ui/app/styles/gr-spinner-styles.ts
@@ -16,13 +16,6 @@
*/
import {css} from 'lit';
-// Mark the file as a module. Otherwise typescript assumes this is a script
-// and $_documentContainer is a global variable.
-// See: https://www.typescriptlang.org/docs/handbook/modules.html
-export {};
-
-const $_documentContainer = document.createElement('template');
-
export const spinnerStyles = css`
.loadingSpin {
border: 2px solid var(--disabled-button-background-color);
@@ -43,6 +36,7 @@
}
`;
+const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<dom-module id="gr-spinner-styles">
<template>
<style>
diff --git a/polygerrit-ui/app/styles/gr-voting-styles.ts b/polygerrit-ui/app/styles/gr-voting-styles.ts
index 12d0784..a623d99 100644
--- a/polygerrit-ui/app/styles/gr-voting-styles.ts
+++ b/polygerrit-ui/app/styles/gr-voting-styles.ts
@@ -18,24 +18,26 @@
// Mark the file as a module. Otherwise typescript assumes this is a script
// and $_documentContainer is a global variable.
// See: https://www.typescriptlang.org/docs/handbook/modules.html
-export {};
+import {css} from 'lit';
+
+export const votingStyles = css`
+ .voteChip {
+ border: 1px solid var(--border-color);
+ /* max rounded */
+ border-radius: 1em;
+ box-shadow: none;
+ box-sizing: border-box;
+ min-width: 3em;
+ color: var(--vote-text-color);
+ }
+`;
const $_documentContainer = document.createElement('template');
-
$_documentContainer.innerHTML = `<dom-module id="gr-voting-styles">
<template>
<style>
- .voteChip {
- border: 1px solid var(--border-color);
- /* max rounded */
- border-radius: 1em;
- box-shadow: none;
- box-sizing: border-box;
- min-width: 3em;
- color: var(--vote-text-color);
- }
+ ${votingStyles.cssText}
</style>
</template>
</dom-module>`;
-
document.head.appendChild($_documentContainer.content);
diff --git a/polygerrit-ui/app/styles/shared-styles.ts b/polygerrit-ui/app/styles/shared-styles.ts
index b58d5b9..98f6eb2 100644
--- a/polygerrit-ui/app/styles/shared-styles.ts
+++ b/polygerrit-ui/app/styles/shared-styles.ts
@@ -224,19 +224,6 @@
--iron-autogrow-textarea_-_white-space: pre-wrap;
}
- .assistive-tech-only {
- user-select: none;
- clip: rect(1px, 1px, 1px, 1px);
- height: 1px;
- margin: 0;
- overflow: hidden;
- padding: 0;
- position: absolute;
- white-space: nowrap;
- width: 1px;
- z-index: -1000;
- }
-
/**
* TODO: Remove these rules and change (plugin) users to rely on
* gr-spinner-styles directly.
diff --git a/polygerrit-ui/app/styles/themes/app-theme.ts b/polygerrit-ui/app/styles/themes/app-theme.ts
index f1711ac..8b00a79 100644
--- a/polygerrit-ui/app/styles/themes/app-theme.ts
+++ b/polygerrit-ui/app/styles/themes/app-theme.ts
@@ -185,6 +185,7 @@
--vote-text-color: black;
--status-text-color: white;
--tooltip-text-color: white;
+ --tooltip-button-text-color: var(--gerrit-blue-dark);
--negative-red-text-color: var(--red-600);
--positive-green-text-color: var(--green-700);
--indirect-ancestor-text-color: var(--green-700);
@@ -284,7 +285,7 @@
--font-weight-bold: 500;
--font-weight-h1: 400;
--font-weight-h2: 400;
- --font-weight-h3: 400;
+ --font-weight-h3: var(--font-weight-bold, 500);
--context-control-button-font: var(--font-weight-normal) var(--font-size-normal) var(--font-family);
--code-hint-font-weight: 500;
--image-diff-button-font: var(--font-weight-normal) var(--font-size-normal) var(--font-family);
diff --git a/polygerrit-ui/app/styles/themes/dark-theme.ts b/polygerrit-ui/app/styles/themes/dark-theme.ts
index a5e725d..a24a666 100644
--- a/polygerrit-ui/app/styles/themes/dark-theme.ts
+++ b/polygerrit-ui/app/styles/themes/dark-theme.ts
@@ -94,7 +94,8 @@
--reviewed-text-color: var(--gray-300);
--vote-text-color: black;
--status-text-color: black;
- --tooltip-text-color: var(--gray-200);
+ --tooltip-text-color: var(--gray-900);
+ --tooltip-button-text-color: var(--gerrit-blue-light);
--negative-red-text-color: var(--red-200);
--positive-green-text-color: var(--green-200);
--indirect-ancestor-text-color: var(--green-200);
@@ -115,7 +116,7 @@
--hover-background-color: rgba(161, 194, 250, 0.2);
--disabled-button-background-color: #484a4d;
--selection-background-color: rgba(161, 194, 250, 0.1);
- --tooltip-background-color: var(--gray-800);
+ --tooltip-background-color: var(--gray-200);
/* comment background colors */
--comment-background-color: #3c3f43;
diff --git a/polygerrit-ui/app/test/@types/sinon-esm.d.ts b/polygerrit-ui/app/test/@types/sinon-esm.d.ts
deleted file mode 100644
index 9074a7a..0000000
--- a/polygerrit-ui/app/test/@types/sinon-esm.d.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * @license
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-declare module 'sinon/pkg/sinon-esm' {
- // sinon-esm doesn't have it's own d.ts, reexport all types from sinon
- // This is a trick - @types/sinon adds interfaces and sinon instance
- // to a global variables/namespace. We reexport it here, so we
- // can use in our code when importing sinon-esm
- // eslint-disable-next-line import/no-default-export
- export default sinon;
- const sinon: Sinon.SinonStatic;
- export {SinonSpy, SinonFakeTimers, SinonStubbedMember};
-}
diff --git a/polygerrit-ui/app/test/common-test-setup.ts b/polygerrit-ui/app/test/common-test-setup.ts
index 5096e09..949c268 100644
--- a/polygerrit-ui/app/test/common-test-setup.ts
+++ b/polygerrit-ui/app/test/common-test-setup.ts
@@ -30,10 +30,7 @@
registerTestCleanup,
addIronOverlayBackdropStyleEl,
removeIronOverlayBackdropStyleEl,
- TestKeyboardShortcutBinder,
} from './test-utils';
-import {_testOnly_getShortcutManagerInstance} from '../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
-import sinon from 'sinon/pkg/sinon-esm';
import {safeTypesBridge} from '../utils/safe-types-util';
import {_testOnly_initGerritPluginApi} from '../elements/shared/gr-js-api-interface/gr-gerrit';
import {initGlobalVariables} from '../elements/gr-app-global-var-init';
@@ -46,6 +43,7 @@
import {cleanUpStorage} from '../services/storage/gr-storage_mock';
import {updatePreferences} from '../services/user/user-model';
import {createDefaultPreferences} from '../constants/constants';
+import {appContext} from '../services/app-context';
declare global {
interface Window {
@@ -102,14 +100,13 @@
// If the following asserts fails - then window.stub is
// overwritten by some other code.
assert.equal(getCleanupsCount(), 0);
+ _testOnlyInitAppContext();
// The following calls is nessecary to avoid influence of previously executed
// tests.
- TestKeyboardShortcutBinder.push();
- _testOnlyInitAppContext();
initGlobalVariables();
_testOnly_initGerritPluginApi();
- const mgr = _testOnly_getShortcutManagerInstance();
- assert.isTrue(mgr._testOnly_isEmpty());
+ const shortcuts = appContext.shortcutsService;
+ assert.isTrue(shortcuts._testOnly_isEmpty());
const selection = document.getSelection();
if (selection) {
selection.removeAllRanges();
@@ -198,7 +195,6 @@
teardown(() => {
sinon.restore();
cleanupTestUtils();
- TestKeyboardShortcutBinder.pop();
checkGlobalSpace();
removeIronOverlayBackdropStyleEl();
cancelAllTasks();
diff --git a/polygerrit-ui/app/test/test-data-generators.ts b/polygerrit-ui/app/test/test-data-generators.ts
index c82c15b..db84043 100644
--- a/polygerrit-ui/app/test/test-data-generators.ts
+++ b/polygerrit-ui/app/test/test-data-generators.ts
@@ -106,6 +106,8 @@
SubmitRequirementResultInfo,
SubmitRequirementStatus,
} from '../api/rest-api';
+import {RunResult} from '../services/checks/checks-model';
+import {Category, RunStatus} from '../api/checks';
export function dateToTimestamp(date: Date): Timestamp {
const nanosecondSuffix = '.000000000';
@@ -688,3 +690,19 @@
submittability_expression_result: createSubmitRequirementExpressionInfo(),
};
}
+
+export function createRunResult(): RunResult {
+ return {
+ attemptDetails: [],
+ category: Category.INFO,
+ checkName: 'test-name',
+ internalResultId: 'test-internal-result-id',
+ internalRunId: 'test-internal-run-id',
+ isLatestAttempt: true,
+ isSingleAttempt: true,
+ pluginName: 'test-plugin-name',
+ status: RunStatus.COMPLETED,
+ summary: 'This is the test summary.',
+ message: 'This is the test message.',
+ };
+}
diff --git a/polygerrit-ui/app/test/test-utils.ts b/polygerrit-ui/app/test/test-utils.ts
index 156217c..1cde372 100644
--- a/polygerrit-ui/app/test/test-utils.ts
+++ b/polygerrit-ui/app/test/test-utils.ts
@@ -17,13 +17,9 @@
import '../types/globals';
import {_testOnly_resetPluginLoader} from '../elements/shared/gr-js-api-interface/gr-plugin-loader';
import {_testOnly_resetEndpoints} from '../elements/shared/gr-js-api-interface/gr-plugin-endpoints';
-import {
- _testOnly_getShortcutManagerInstance,
- Shortcut,
-} from '../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
import {appContext} from '../services/app-context';
import {RestApiService} from '../services/gr-rest-api/gr-rest-api';
-import {SinonSpy} from 'sinon/pkg/sinon-esm';
+import {SinonSpy} from 'sinon';
import {StorageService} from '../services/storage/gr-storage';
import {AuthService} from '../services/gr-auth/gr-auth';
import {ReportingService} from '../services/gr-reporting/gr-reporting';
@@ -53,44 +49,6 @@
return getComputedStyle(el).getPropertyValue('display') !== 'none';
}
-// Some tests/elements can define its own binding. We want to restore bindings
-// at the end of the test. The TestKeyboardShortcutBinder store bindings in
-// stack, so it is possible to override bindings in nested suites.
-export class TestKeyboardShortcutBinder {
- private static stack: TestKeyboardShortcutBinder[] = [];
-
- static push() {
- const testBinder = new TestKeyboardShortcutBinder();
- this.stack.push(testBinder);
- return _testOnly_getShortcutManagerInstance();
- }
-
- static pop() {
- const item = this.stack.pop();
- if (!item) {
- throw new Error('stack is empty');
- }
- item._restoreShortcuts();
- }
-
- private readonly originalBinding: Map<Shortcut, string[]>;
-
- constructor() {
- this.originalBinding = new Map(
- _testOnly_getShortcutManagerInstance()._testOnly_getBindings()
- );
- }
-
- _restoreShortcuts() {
- const bindings =
- _testOnly_getShortcutManagerInstance()._testOnly_getBindings();
- bindings.clear();
- this.originalBinding.forEach((value, key) => {
- bindings.set(key, value);
- });
- }
-}
-
// Provide reset plugins function to clear installed plugins between tests.
// No gr-app found (running tests)
export const resetPlugins = () => {
diff --git a/polygerrit-ui/app/tsconfig.json b/polygerrit-ui/app/tsconfig.json
index 79dae41..5040496 100644
--- a/polygerrit-ui/app/tsconfig.json
+++ b/polygerrit-ui/app/tsconfig.json
@@ -25,6 +25,7 @@
"noUnusedLocals": true, /* Report errors on unused locals. */
"noUnusedParameters": true, /* Report errors on unused parameters. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
+ "noImplicitOverride": true,
"noFallthroughCasesInSwitch": true,/* Report errors for fallthrough cases in switch statement. */
"skipLibCheck": true, /* Do not check node_modules */
@@ -39,7 +40,38 @@
"incremental": true,
"experimentalDecorators": true,
- "allowUmdGlobalAccess": true
+ "allowUmdGlobalAccess": true,
+
+ /* typeRoots for IDE (see tsconfig_bazel.json for Bazel) */
+ "typeRoots": [
+ "node_modules/@types",
+ "../node_modules/@types"
+ ],
+
+ "plugins": [
+ {
+ "name": "ts-lit-plugin",
+ "strict": true,
+ "rules": {
+ "no-unknown-tag-name": "error",
+ "no-unclosed-tag": "error",
+ "no-unknown-property": "error",
+ "no-unintended-mixed-binding": "error",
+ "no-invalid-boolean-binding": "error",
+ "no-expressionless-property-binding": "error",
+ "no-noncallable-event-binding": "error",
+ "no-boolean-in-attribute-binding": "error",
+ "no-complex-attribute-binding": "error",
+ "no-nullable-attribute-binding": "error",
+ "no-incompatible-type-binding": "error",
+ "no-invalid-directive-binding": "error",
+ "no-incompatible-property-type": "error",
+ "no-unknown-property-converter": "error",
+ "no-invalid-attribute-name": "error",
+ "no-invalid-tag-name": "error"
+ }
+ }
+ ]
},
// With the * pattern (without an extension), only supported files
// are included. The supported files are .ts, .tsx, .d.ts.
diff --git a/polygerrit-ui/app/tsconfig_bazel_test.json b/polygerrit-ui/app/tsconfig_bazel_test.json
index 9c2ff93..7137e23 100644
--- a/polygerrit-ui/app/tsconfig_bazel_test.json
+++ b/polygerrit-ui/app/tsconfig_bazel_test.json
@@ -2,7 +2,6 @@
"extends": "./tsconfig_bazel.json",
"compilerOptions": {
"typeRoots": [
- "./test/@types",
"../../external/ui_dev_npm/node_modules/@polymer/iron-test-helpers",
"../../external/ui_npm/node_modules/@types",
"../../external/ui_dev_npm/node_modules/@types"
diff --git a/polygerrit-ui/app/types/common.ts b/polygerrit-ui/app/types/common.ts
index 98c60d2..1617aa3 100644
--- a/polygerrit-ui/app/types/common.ts
+++ b/polygerrit-ui/app/types/common.ts
@@ -1143,6 +1143,7 @@
default_base_for_merges: DefaultBase;
publish_comments_on_push?: boolean;
disable_keyboard_shortcuts?: boolean;
+ disable_token_highlighting?: boolean;
work_in_progress_by_default?: boolean;
// The email_format doesn't mentioned in doc, but exists in Java class GeneralPreferencesInfo
email_format?: EmailFormat;
diff --git a/polygerrit-ui/app/types/events.ts b/polygerrit-ui/app/types/events.ts
index 0069321..c78f61a 100644
--- a/polygerrit-ui/app/types/events.ts
+++ b/polygerrit-ui/app/types/events.ts
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {PatchSetNum} from './common';
import {UIComment} from '../utils/comment-util';
import {FetchRequest} from './types';
@@ -69,10 +68,6 @@
'editable-content-save': EditableContentSaveEvent;
'location-change': LocationChangeEvent;
'iron-announce': IronAnnounceEvent;
- /* prettier-ignore */
- 'keydown': KeydownEvent;
- /* prettier-ignore */
- 'keypress': KeypressEvent;
'line-mouse-enter': LineNumberEvent;
'line-mouse-leave': LineNumberEvent;
'line-cursor-moved-in': LineNumberEvent;
@@ -148,10 +143,6 @@
}
export type IronAnnounceEvent = CustomEvent<IronAnnounceEventDetail>;
-export type KeydownEvent = CustomKeyboardEvent;
-
-export type KeypressEvent = InputEvent;
-
export interface LocationChangeEventDetail {
hash: string;
pathname: string;
@@ -252,20 +243,28 @@
export type TitleChangeEvent = CustomEvent<TitleChangeEventDetail>;
/**
- * Keyboard events emitted from polymer elements.
+ * Keyboard events emitted from elements using IronA11yKeysBehavior: That means
+ * that the element returns a list of handlers from either `keyBindings()` or
+ * from `keyboardShortcuts()`. This event should not be used in Lit elements
+ * and will be obsolete once the Lit migration is completed.
*/
-export interface CustomKeyboardEvent extends CustomEvent, EventApi {
- event: CustomKeyboardEvent;
- detail: {
- keyboardEvent?: CustomKeyboardEvent;
- // TODO(TS): maybe should mark as optional and check before accessing
- key: string;
- };
- readonly altKey: boolean;
- readonly changedTouches: TouchList;
- readonly ctrlKey: boolean;
- readonly metaKey: boolean;
- readonly shiftKey: boolean;
- readonly keyCode: number;
- readonly repeat: boolean;
+export interface IronKeyboardEvent extends CustomEvent {
+ detail: IronKeyboardEventDetail;
+}
+
+export interface IronKeyboardEventDetail {
+ keyboardEvent: KeyboardEvent;
+ key: string;
+ combo?: string;
+}
+
+export function isIronKeyboardEvent(
+ e: IronKeyboardEvent | Event | CustomEvent
+): e is IronKeyboardEvent {
+ const ike = e as IronKeyboardEvent;
+ return !!ike?.detail?.keyboardEvent;
+}
+
+export interface IronKeyboardEventListener {
+ (evt: IronKeyboardEvent): void;
}
diff --git a/polygerrit-ui/app/types/globals.ts b/polygerrit-ui/app/types/globals.ts
index a06c2c4..b5bd2aa 100644
--- a/polygerrit-ui/app/types/globals.ts
+++ b/polygerrit-ui/app/types/globals.ts
@@ -75,4 +75,8 @@
lineNumber?: number; // non-standard property
columnNumber?: number; // non-standard property
}
+
+ interface ShadowRoot {
+ getSelection?: () => Selection | null;
+ }
}
diff --git a/polygerrit-ui/app/utils/access-util.ts b/polygerrit-ui/app/utils/access-util.ts
index 44830e2..165eacf 100644
--- a/polygerrit-ui/app/utils/access-util.ts
+++ b/polygerrit-ui/app/utils/access-util.ts
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import {LabelName} from '../types/common';
+import {GitRef, LabelName} from '../types/common';
export enum AccessPermissionId {
ABANDON = 'abandon',
@@ -156,7 +156,7 @@
}
export interface PermissionArrayItem<T> {
- id: string;
+ id: GitRef;
value: T;
}
@@ -175,7 +175,7 @@
return Object.keys(obj)
.map(key => {
return {
- id: key,
+ id: key as GitRef,
value: obj[key],
};
})
diff --git a/polygerrit-ui/app/utils/async-util.ts b/polygerrit-ui/app/utils/async-util.ts
index c82f5e4..90ee5a5 100644
--- a/polygerrit-ui/app/utils/async-util.ts
+++ b/polygerrit-ui/app/utils/async-util.ts
@@ -117,9 +117,9 @@
* Ensure only one call is made within THROTTLE_INTERVAL_MS and any call within
* this interval is ignored
*/
-export function throttleWrap(fn: (e: Event) => void) {
+export function throttleWrap<T>(fn: (e: T) => void) {
let lastCall: number | undefined;
- return (e: Event) => {
+ return (e: T) => {
if (
lastCall !== undefined &&
Date.now() - lastCall < THROTTLE_INTERVAL_MS
diff --git a/polygerrit-ui/app/utils/attention-set-util.ts b/polygerrit-ui/app/utils/attention-set-util.ts
index 631b633..dcd2863 100644
--- a/polygerrit-ui/app/utils/attention-set-util.ts
+++ b/polygerrit-ui/app/utils/attention-set-util.ts
@@ -16,6 +16,7 @@
*/
import {AccountInfo, ChangeInfo, ServerInfo} from '../types/common';
+import {ParsedChangeInfo} from '../types/types';
import {
getAccountTemplate,
isServiceUser,
@@ -29,7 +30,7 @@
export function hasAttention(
account?: AccountInfo,
- change?: ChangeInfo
+ change?: ChangeInfo | ParsedChangeInfo
): boolean {
return (
canHaveAttention(account) &&
@@ -41,7 +42,7 @@
export function getReason(
config?: ServerInfo,
account?: AccountInfo,
- change?: ChangeInfo
+ change?: ChangeInfo | ParsedChangeInfo
) {
if (!hasAttention(account, change)) return '';
if (change?.attention_set === undefined) return '';
diff --git a/polygerrit-ui/app/utils/change-util.ts b/polygerrit-ui/app/utils/change-util.ts
index c94493b..278e7f3 100644
--- a/polygerrit-ui/app/utils/change-util.ts
+++ b/polygerrit-ui/app/utils/change-util.ts
@@ -215,7 +215,7 @@
}
export function isUploader(
- change?: ChangeInfo,
+ change?: ChangeInfo | ParsedChangeInfo,
account?: AccountInfo
): boolean {
if (!change || !account) return false;
@@ -224,7 +224,7 @@
}
export function isInvolved(
- change?: ChangeInfo,
+ change?: ChangeInfo | ParsedChangeInfo,
account?: AccountInfo
): boolean {
const owner = isOwner(change, account);
diff --git a/polygerrit-ui/app/utils/common-util.ts b/polygerrit-ui/app/utils/common-util.ts
index 5370cf9..9e3bc74 100644
--- a/polygerrit-ui/app/utils/common-util.ts
+++ b/polygerrit-ui/app/utils/common-util.ts
@@ -100,16 +100,19 @@
}
export function query<E extends Element = Element>(
- el: Element | undefined,
+ el: Element | null | undefined,
selector: string
): E | undefined {
if (!el) return undefined;
- const root = el.shadowRoot ?? el;
- return root.querySelector<E>(selector) ?? undefined;
+ if (el.shadowRoot) {
+ const r = el.shadowRoot.querySelector<E>(selector);
+ if (r) return r;
+ }
+ return el.querySelector<E>(selector) ?? undefined;
}
export function queryAndAssert<E extends Element = Element>(
- el: Element | undefined,
+ el: Element | null | undefined,
selector: string
): E {
const found = query<E>(el, selector);
diff --git a/polygerrit-ui/app/utils/dom-util.ts b/polygerrit-ui/app/utils/dom-util.ts
index e7cc956..ead47bb 100644
--- a/polygerrit-ui/app/utils/dom-util.ts
+++ b/polygerrit-ui/app/utils/dom-util.ts
@@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-import {dom, EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
+import {EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
import {check} from './common-util';
-import {CustomKeyboardEvent} from '../types/events';
+import {IronKeyboardEvent} from '../types/events';
/**
* Event emitted from polymer elements.
@@ -37,6 +36,17 @@
return 'shadowRoot' in el;
}
+export function isElement(node: Node): node is Element {
+ return node.nodeType === 1;
+}
+
+export function isElementTarget(
+ target: EventTarget | null | undefined
+): target is Element {
+ if (!target) return false;
+ return 'nodeType' in target && isElement(target as Node);
+}
+
// TODO: maybe should have a better name for this
function getPathFromNode(el: EventTarget) {
let tagName = '';
@@ -171,7 +181,7 @@
* getEventPath(e); // eg: div.class1>p#pid.class2
* }
*/
-export function getEventPath<T extends PolymerEvent>(e?: T) {
+export function getEventPath<T extends MouseEvent>(e?: T) {
if (!e) return '';
let path = e.composedPath();
@@ -227,7 +237,7 @@
// document.activeElement is not enough, because it's not getting activeElement
// without looking inside of shadow roots. This will find best activeElement.
export function findActiveElement(
- root: DocumentOrShadowRoot | null,
+ root: Document | ShadowRoot | null,
ignoreDialogs?: boolean
): HTMLElement | null {
if (root === null) {
@@ -257,7 +267,7 @@
export function isSafari() {
return (
/^((?!chrome|android).)*safari/i.test(navigator.userAgent) ||
- (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
+ /iPad|iPhone|iPod/.test(navigator.userAgent)
);
}
@@ -298,23 +308,14 @@
return e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
}
-// Deprecated. Try using "normal" KeyboardEvent and modifierPressed() above.
-export function isModifierPressed(event: CustomKeyboardEvent) {
- const e = getKeyboardEvent(event);
- return e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
-}
-
-export function isShiftPressed(event: CustomKeyboardEvent) {
- const e = getKeyboardEvent(event);
+export function shiftPressed(e: KeyboardEvent) {
return e.shiftKey;
}
-export function getKeyboardEvent(e: CustomKeyboardEvent): CustomKeyboardEvent {
- const event = dom(e.detail ? e.detail.keyboardEvent : e);
- // TODO(TS): worth checking if this still holds or not, if no, remove this.
- // When e is a keyboardEvent, e.event is not null.
- if ('event' in event && (event as CustomKeyboardEvent).event) {
- return (event as CustomKeyboardEvent).event;
- }
- return event as CustomKeyboardEvent;
+export function isModifierPressed(e: IronKeyboardEvent) {
+ return modifierPressed(e.detail.keyboardEvent);
+}
+
+export function isShiftPressed(e: IronKeyboardEvent) {
+ return shiftPressed(e.detail.keyboardEvent);
}
diff --git a/polygerrit-ui/app/utils/label-util.ts b/polygerrit-ui/app/utils/label-util.ts
index 16e6803..884afd7 100644
--- a/polygerrit-ui/app/utils/label-util.ts
+++ b/polygerrit-ui/app/utils/label-util.ts
@@ -15,6 +15,7 @@
* limitations under the License.
*/
import {
+ isQuickLabelInfo,
SubmitRequirementResultInfo,
SubmitRequirementStatus,
} from '../api/rest-api';
@@ -121,6 +122,30 @@
return label.all?.filter(x => x._account_id === account._account_id)[0];
}
+export function getAllUniqueApprovals(labelInfo?: LabelInfo) {
+ if (!labelInfo || !isDetailedLabelInfo(labelInfo)) return [];
+ const uniqueApprovals = (labelInfo.all ?? [])
+ .filter(
+ (approvalInfo, index, array) =>
+ index === array.findIndex(other => other.value === approvalInfo.value)
+ )
+ .sort((a, b) => -(a.value ?? 0) + (b.value ?? 0));
+ return uniqueApprovals;
+}
+
+export function hasVotes(labelInfo: LabelInfo): boolean {
+ if (isDetailedLabelInfo(labelInfo)) {
+ return (labelInfo.all ?? []).some(
+ approval =>
+ getLabelStatus(labelInfo, approval.value) !== LabelStatus.NEUTRAL
+ );
+ }
+ if (isQuickLabelInfo(labelInfo)) {
+ return !!labelInfo.rejected || !!labelInfo.approved;
+ }
+ return false;
+}
+
export function labelCompare(labelName1: string, labelName2: string) {
if (labelName1 === CODE_REVIEW && labelName2 === CODE_REVIEW) return 0;
if (labelName1 === CODE_REVIEW) return -1;
diff --git a/polygerrit-ui/app/utils/path-list-util.ts b/polygerrit-ui/app/utils/path-list-util.ts
index fd922fc..411421e 100644
--- a/polygerrit-ui/app/utils/path-list-util.ts
+++ b/polygerrit-ui/app/utils/path-list-util.ts
@@ -95,13 +95,13 @@
});
}
-export function computeDisplayPath(path: string) {
+export function computeDisplayPath(path?: string) {
if (path === SpecialFilePath.COMMIT_MESSAGE) {
return 'Commit message';
} else if (path === SpecialFilePath.MERGE_LIST) {
return 'Merge list';
}
- return path;
+ return path ?? '';
}
export function isMagicPath(path?: string) {
diff --git a/polygerrit-ui/karma.conf.js b/polygerrit-ui/karma.conf.js
index 00ebc63..a3b694f 100644
--- a/polygerrit-ui/karma.conf.js
+++ b/polygerrit-ui/karma.conf.js
@@ -22,6 +22,7 @@
if(runUnderBazel) {
// Run under bazel
return [
+ `external/plugins_npm/node_modules`,
`external/ui_npm/node_modules`,
`external/ui_dev_npm/node_modules`
];
@@ -58,11 +59,11 @@
}
module.exports = function(config) {
- const localDirName = path.resolve(__dirname, '../.ts-out/polygerrit-ui/app');
- const rootDir = runUnderBazel ?
- 'polygerrit-ui/app/_pg_with_tests_out/' : localDirName + '/';
- const testFilesLocationPattern =
- `${rootDir}**/!(template_test_srcs)/`;
+ let root = config.root;
+ if (!root) {
+ console.warn(`--root argument not set. Falling back to __dirname.`)
+ root = path.resolve(__dirname) + '/';
+ }
// Use --test-files to specify pattern for a test files.
// It can be just a file name, without a path:
// --test-files async-foreach-behavior_test.js
@@ -83,7 +84,9 @@
} else {
filePattern = '*_test.js';
}
- const testFilesPattern = testFilesLocationPattern + filePattern;
+ const testFilesPattern = root + '**/' + filePattern;
+
+ console.info(`Karma test file pattern: ${testFilesPattern}`)
// Special patch for grep parameters (see details in the grep-patch-karam.js)
const additionalFiles = runUnderBazel ? [] : ['polygerrit-ui/grep-patch-karma.js'];
config.set({
diff --git a/polygerrit-ui/karma_test.sh b/polygerrit-ui/karma_test.sh
index 5fab442..940b969 100755
--- a/polygerrit-ui/karma_test.sh
+++ b/polygerrit-ui/karma_test.sh
@@ -1,4 +1,6 @@
#!/bin/bash
set -euo pipefail
-./$1 start $2 --single-run
+./$1 start $2 \
+ --root 'polygerrit-ui/app/_pg_with_tests_out/**/' \
+ --test-files '*_test.js'
diff --git a/proto/entities.proto b/proto/entities.proto
index d4ff736..de8f647 100644
--- a/proto/entities.proto
+++ b/proto/entities.proto
@@ -133,6 +133,7 @@
optional string tag = 6;
optional Account_Id real_account_id = 7;
optional bool post_submit = 8;
+ optional bool copied = 9;
// Deleted fields, should not be reused:
reserved 4; // changeOpen
diff --git a/resources/com/google/gerrit/server/mail/ChangeHeader.soy b/resources/com/google/gerrit/server/mail/ChangeHeader.soy
index 5dfe671..3d0edab 100644
--- a/resources/com/google/gerrit/server/mail/ChangeHeader.soy
+++ b/resources/com/google/gerrit/server/mail/ChangeHeader.soy
@@ -20,10 +20,10 @@
{@param attentionSet: ?}
{if $attentionSet}
Attention is currently required from:{sp}
- {for $attentionSetUser in $attentionSet}
+ {for $attentionSetUser, $index in $attentionSet}
{$attentionSetUser}
// add commas or dot.
- {if isLast($attentionSetUser)}.
+ {if $index == length($attentionSet) - 1}.
{else},{sp}
{/if}
{/for}
diff --git a/resources/com/google/gerrit/server/mail/ChangeHeaderHtml.soy b/resources/com/google/gerrit/server/mail/ChangeHeaderHtml.soy
index 191737f..0d8da38 100644
--- a/resources/com/google/gerrit/server/mail/ChangeHeaderHtml.soy
+++ b/resources/com/google/gerrit/server/mail/ChangeHeaderHtml.soy
@@ -21,10 +21,10 @@
{@param attentionSet: ?}
{if $attentionSet}
<p> Attention is currently required from:{sp}
- {for $attentionSetUser in $attentionSet}
+ {for $attentionSetUser, $index in $attentionSet}
{$attentionSetUser}
//add commas or dot.
- {if isLast($attentionSetUser)}.
+ {if $index == length($attentionSet) - 1}.
{else},{sp}
{/if}
{/for} </p>
diff --git a/resources/com/google/gerrit/server/mail/Comment.soy b/resources/com/google/gerrit/server/mail/Comment.soy
index 4b923e6..4b66401 100644
--- a/resources/com/google/gerrit/server/mail/Comment.soy
+++ b/resources/com/google/gerrit/server/mail/Comment.soy
@@ -48,8 +48,8 @@
{\n}
{/if}
- {for $line in $comment.lines}
- {if isFirst($line)}
+ {for $line, $index in $comment.lines}
+ {if $index == 0}
{if $comment.startLine != 0}
{$comment.link}
{/if}
diff --git a/resources/com/google/gerrit/server/mail/DeleteReviewer.soy b/resources/com/google/gerrit/server/mail/DeleteReviewer.soy
index a3ed3ee..ae2a9c4 100644
--- a/resources/com/google/gerrit/server/mail/DeleteReviewer.soy
+++ b/resources/com/google/gerrit/server/mail/DeleteReviewer.soy
@@ -26,8 +26,8 @@
{@param email: ?}
{@param fromName: ?}
{$fromName} has removed{sp}
- {for $reviewerName in $email.reviewerNames}
- {if not isFirst($reviewerName)},{sp}{/if}
+ {for $reviewerName, $index in $email.reviewerNames}
+ {if $index > 0},{sp}{/if}
{$reviewerName}
{/for}{sp}
from this change.{sp}
diff --git a/resources/com/google/gerrit/server/mail/DeleteReviewerHtml.soy b/resources/com/google/gerrit/server/mail/DeleteReviewerHtml.soy
index 76a9199..fdcbbe7 100644
--- a/resources/com/google/gerrit/server/mail/DeleteReviewerHtml.soy
+++ b/resources/com/google/gerrit/server/mail/DeleteReviewerHtml.soy
@@ -25,9 +25,9 @@
{$fromName}{sp}
<strong>
removed{sp}
- {for $reviewerName in $email.reviewerNames}
- {if not isFirst($reviewerName)}
- {if isLast($reviewerName)}{sp}and{else},{/if}{sp}
+ {for $reviewerName, $index in $email.reviewerNames}
+ {if $index > 0}
+ {if $index == (length($email.reviewerNames) - 1)}{sp}and{else},{/if}{sp}
{/if}
{$reviewerName}
{/for}
diff --git a/resources/com/google/gerrit/server/mail/Merged.soy b/resources/com/google/gerrit/server/mail/Merged.soy
index e268a31..b8a19fc 100644
--- a/resources/com/google/gerrit/server/mail/Merged.soy
+++ b/resources/com/google/gerrit/server/mail/Merged.soy
@@ -30,7 +30,7 @@
{if $email.changeUrl} ( {$email.changeUrl} ){/if}{\n}
{\n}
- {$email.stickyApprovalDiff}
+ {if $email.stickyApprovalDiff} ( {$email.stickyApprovalDiff} ){/if}
Change subject: {$change.subject}{\n}
......................................................................{\n}
diff --git a/resources/com/google/gerrit/server/mail/MergedHtml.soy b/resources/com/google/gerrit/server/mail/MergedHtml.soy
index d2f7bfd..ac4afb3 100644
--- a/resources/com/google/gerrit/server/mail/MergedHtml.soy
+++ b/resources/com/google/gerrit/server/mail/MergedHtml.soy
@@ -32,9 +32,11 @@
</p>
{/if}
- {call mailTemplate.UnifiedDiff}
- {param diffLines: $email.stickyApprovalDiffHtml /}
- {/call}
+ {if $email.stickyApprovalDiffHtml}
+ {call mailTemplate.UnifiedDiff}
+ {param diffLines: $email.stickyApprovalDiffHtml /}
+ {/call}
+ {/if}
<div style="white-space:pre-wrap">{$email.approvals}</div>
diff --git a/resources/com/google/gerrit/server/mail/NewChange.soy b/resources/com/google/gerrit/server/mail/NewChange.soy
index aa2b946..c5f34b4 100644
--- a/resources/com/google/gerrit/server/mail/NewChange.soy
+++ b/resources/com/google/gerrit/server/mail/NewChange.soy
@@ -30,8 +30,8 @@
{if $email.reviewerNames or $email.removedReviewerNames}
{if $email.reviewerNames}
Hello{sp}
- {for $reviewerName in $email.reviewerNames}
- {if not isFirst($reviewerName)},{sp}{/if}
+ {for $reviewerName, $index in $email.reviewerNames}
+ {if $index > 0},{sp}{/if}
{$reviewerName}
{/for},
@@ -43,8 +43,8 @@
{/if}
{if $email.removedReviewerNames}
{$fromName} has removed{sp}
- {for $reviewerName in $email.removedReviewerNames}
- {if not isFirst($reviewerName)},{sp}{/if}
+ {for $reviewerName, $index in $email.removedReviewerNames}
+ {if $index > 0},{sp}{/if}
{$reviewerName}
{/for}{sp}
from this change.{sp}
diff --git a/resources/com/google/gerrit/server/mail/NewChangeHtml.soy b/resources/com/google/gerrit/server/mail/NewChangeHtml.soy
index 272c3ef..008226f 100644
--- a/resources/com/google/gerrit/server/mail/NewChangeHtml.soy
+++ b/resources/com/google/gerrit/server/mail/NewChangeHtml.soy
@@ -29,9 +29,9 @@
{if $email.reviewerNames or $email.removedReviewerNames}
{if $email.reviewerNames}
{$fromName} would like{sp}
- {for $reviewerName in $email.reviewerNames}
- {if not isFirst($reviewerName)}
- {if isLast($reviewerName)}{sp}and{else},{/if}{sp}
+ {for $reviewerName, $index in $email.reviewerNames}
+ {if $index > 0}
+ {if $index == length($email.reviewerNames) - 1}{sp}and{else},{/if}{sp}
{/if}
{$reviewerName}
{/for}{sp}
@@ -44,9 +44,9 @@
{$fromName}{sp}
<strong>
removed{sp}
- {for $reviewerName in $email.removedReviewerNames}
- {if not isFirst($reviewerName)}
- {if isLast($reviewerName)}{sp}and{else},{/if}{sp}
+ {for $reviewerName, $index in $email.removedReviewerNames}
+ {if $index > 0}
+ {if $index == length($email.removedReviewerNames) - 1}{sp}and{else},{/if}{sp}
{/if}
{$reviewerName}
{/for}
diff --git a/tools/BUILD b/tools/BUILD
index 545a206..64b0665 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -68,77 +68,398 @@
# Error Prone errors enabled by default; see ../.bazelrc for how this is
# enabled. This warnings list is originally based on:
# https://github.com/bazelbuild/BUILD_file_generator/blob/master/tools/bazel_defs/java.bzl
+# Additionally, items used internally in google is added. Such items have
+# the same or higher verbosity level than in google.
# However, feel free to add any additional errors. Thus far they have all been pretty useful.
-# TODO(davido): Enable ImmutableAnnotationChecker again when these issues are fixed:
-# https://github.com/google/error-prone/issues/1348
-# https://github.com/bazelbuild/bazel/issues/9378
+# All warnings are commented to avoid noise in the output.
+# Newer versions of error-prone have XepDisableAllWarnings flag which could
+# be used instead of commenting. Bazel should be updated to use a new version
+# of error-prone.
java_package_configuration(
name = "error_prone",
javacopts = [
"-XepDisableWarningsInGeneratedCode",
+ # The XepDisableWarningsInGeneratedCode disables only warnings, but
+ # not errors. We should manually exclude all files generated by
+ # AutoValue; such files always start $AutoValue_.....
+ # XepExcludedPaths is a regexp. If you need more paths - use | as
+ # separator.
+ "-XepExcludedPaths:.*/\\\\$$AutoValue_.*\\.java",
+ "-Xep:AlmostJavadoc:ERROR",
+ "-Xep:AlwaysThrows:ERROR",
"-Xep:AmbiguousMethodReference:ERROR",
+ "-Xep:AnnotateFormatMethod:ERROR",
+ "-Xep:ArgumentSelectionDefectChecker:ERROR",
+ "-Xep:ArrayAsKeyOfSetOrMap:ERROR",
+ "-Xep:ArrayEquals:ERROR",
+ "-Xep:ArrayFillIncompatibleType:ERROR",
+ "-Xep:ArrayHashCode:ERROR",
+ "-Xep:ArrayToString:ERROR",
+ "-Xep:ArraysAsListPrimitiveArray:ERROR",
+ "-Xep:AssertEqualsArgumentOrderChecker:ERROR",
+ "-Xep:AssertionFailureIgnored:ERROR",
+ "-Xep:AsyncCallableReturnsNull:ERROR",
+ "-Xep:AsyncFunctionReturnsNull:ERROR",
+ "-Xep:AutoValueConstructorOrderChecker:ERROR",
"-Xep:AutoValueFinalMethods:ERROR",
+ # "-Xep:AutoValueImmutableFields:WARN",
+ # "-Xep:AutoValueSubclassLeaked:WARN",
"-Xep:BadAnnotationImplementation:ERROR",
"-Xep:BadComparable:ERROR",
+ # "-Xep:BadImport:WARN",
+ "-Xep:BadInstanceof:ERROR",
+ "-Xep:BadShiftAmount:ERROR",
+ "-Xep:BanSerializableRead:ERROR",
+ "-Xep:BigDecimalEquals:ERROR",
+ "-Xep:BigDecimalLiteralDouble:ERROR",
"-Xep:BoxedPrimitiveConstructor:ERROR",
+ "-Xep:BoxedPrimitiveEquality:ERROR",
+ "-Xep:BundleDeserializationCast:ERROR",
+ "-Xep:ByteBufferBackingArray:ERROR",
+ "-Xep:CacheLoaderNull:ERROR",
"-Xep:CannotMockFinalClass:ERROR",
+ "-Xep:CanonicalDuration:ERROR",
+ # "-Xep:CatchAndPrintStackTrace:WARN",
+ "-Xep:CatchFail:ERROR",
+ "-Xep:ChainedAssertionLosesContext:ERROR",
+ "-Xep:ChainingConstructorIgnoresParameter:ERROR",
+ "-Xep:CharacterGetNumericValue:ERROR",
+ "-Xep:CheckNotNullMultipleTimes:ERROR",
+ "-Xep:CheckReturnValue:ERROR",
"-Xep:ClassCanBeStatic:ERROR",
+ "-Xep:ClassName:ERROR",
"-Xep:ClassNewInstance:ERROR",
+ "-Xep:CollectionIncompatibleType:ERROR",
+ "-Xep:CollectionToArraySafeParameter:ERROR",
+ "-Xep:CollectionUndefinedEquality:ERROR",
+ "-Xep:CollectorShouldNotUseState:ERROR",
+ "-Xep:ComparableAndComparator:ERROR",
+ "-Xep:ComparableType:ERROR",
+ "-Xep:CompareToZero:ERROR",
+ "-Xep:ComparingThisWithNull:ERROR",
+ "-Xep:ComparisonOutOfRange:ERROR",
+ "-Xep:CompatibleWithAnnotationMisuse:ERROR",
+ "-Xep:CompileTimeConstant:ERROR",
+ "-Xep:ComplexBooleanConstant:ERROR",
+ "-Xep:ComputeIfAbsentAmbiguousReference:ERROR",
+ "-Xep:ConditionalExpressionNumericPromotion:ERROR",
+ "-Xep:ConstantOverflow:ERROR",
+ "-Xep:DaggerProvidesNull:ERROR",
+ "-Xep:DangerousLiteralNull:ERROR",
+ "-Xep:DateChecker:ERROR",
"-Xep:DateFormatConstant:ERROR",
+ "-Xep:DeadException:ERROR",
+ "-Xep:DeadThread:ERROR",
"-Xep:DefaultCharset:ERROR",
+ # "-Xep:DefaultPackage:WARN",
+ "-Xep:DepAnn:ERROR",
+ "-Xep:DeprecatedVariable:ERROR",
+ "-Xep:DiscardedPostfixExpression:ERROR",
+ "-Xep:DoNotCall:ERROR",
+ "-Xep:DoNotCallSuggester:ERROR",
+ "-Xep:DoNotClaimAnnotations:ERROR",
+ "-Xep:DoNotMock:ERROR",
+ "-Xep:DoNotMockAutoValue:ERROR",
+ "-Xep:DoubleBraceInitialization:ERROR",
"-Xep:DoubleCheckedLocking:ERROR",
- "-Xep:ElementsCountedInLoop:ERROR",
+ "-Xep:DuplicateMapKeys:ERROR",
+ "-Xep:DurationFrom:ERROR",
+ "-Xep:DurationGetTemporalUnit:ERROR",
+ "-Xep:DurationTemporalUnit:ERROR",
+ "-Xep:DurationToLongTimeUnit:ERROR",
+ "-Xep:EmptyBlockTag:ERROR",
+ # "-Xep:EmptyCatch:WARN",
+ "-Xep:EmptySetMultibindingContributions:ERROR",
+ # "-Xep:EqualsGetClass:WARN",
"-Xep:EqualsHashCode:ERROR",
"-Xep:EqualsIncompatibleType:ERROR",
+ "-Xep:EqualsNaN:ERROR",
+ "-Xep:EqualsNull:ERROR",
+ "-Xep:EqualsReference:ERROR",
+ "-Xep:EqualsUnsafeCast:ERROR",
+ "-Xep:EqualsUsingHashCode:ERROR",
+ "-Xep:EqualsWrongThing:ERROR",
+ "-Xep:ErroneousThreadPoolConstructorChecker:ERROR",
+ # "-Xep:EscapedEntity:WARN",
"-Xep:ExpectedExceptionChecker:ERROR",
+ "-Xep:ExtendingJUnitAssert:ERROR",
+ "-Xep:ExtendsAutoValue:ERROR",
+ "-Xep:FallThrough:ERROR",
"-Xep:Finally:ERROR",
+ "-Xep:FloatCast:ERROR",
+ "-Xep:FloatingPointAssertionWithinEpsilon:ERROR",
"-Xep:FloatingPointLiteralPrecision:ERROR",
+ "-Xep:FloggerArgumentToString:ERROR",
+ "-Xep:FloggerFormatString:ERROR",
+ "-Xep:FloggerLogVarargs:ERROR",
+ "-Xep:FloggerSplitLogStatement:ERROR",
+ "-Xep:FloggerStringConcatenation:ERROR",
+ "-Xep:ForOverride:ERROR",
+ "-Xep:FormatString:ERROR",
"-Xep:FormatStringAnnotation:ERROR",
"-Xep:FragmentInjection:ERROR",
"-Xep:FragmentNotInstantiable:ERROR",
+ "-Xep:FromTemporalAccessor:ERROR",
"-Xep:FunctionalInterfaceClash:ERROR",
- "-Xep:FutureReturnValueIgnored:ERROR",
+ "-Xep:FunctionalInterfaceMethodChanged:ERROR",
+ # "-Xep:FutureReturnValueIgnored:ERROR", // this check has a bug.
+ "-Xep:FuturesGetCheckedIllegalExceptionType:ERROR",
+ "-Xep:GetClassOnAnnotation:ERROR",
+ "-Xep:GetClassOnClass:ERROR",
"-Xep:GetClassOnEnum:ERROR",
- "-Xep:ImmutableAnnotationChecker:OFF",
+ "-Xep:GuardedBy:ERROR",
+ "-Xep:GuiceAssistedInjectScoping:ERROR",
+ "-Xep:GuiceAssistedParameters:ERROR",
+ "-Xep:HashtableContains:ERROR",
+ "-Xep:HidingField:ERROR",
+ "-Xep:IdentityBinaryExpression:ERROR",
+ "-Xep:IdentityHashMapBoxing:ERROR",
+ "-Xep:IdentityHashMapUsage:ERROR",
+ "-Xep:IgnoredPureGetter:ERROR",
+ "-Xep:Immutable:ERROR",
+ "-Xep:ImmutableAnnotationChecker:ERROR",
"-Xep:ImmutableEnumChecker:ERROR",
+ "-Xep:ImmutableModification:ERROR",
+ "-Xep:Incomparable:ERROR",
+ "-Xep:IncompatibleArgumentType:ERROR",
"-Xep:IncompatibleModifiers:ERROR",
+ # "-Xep:InconsistentCapitalization:WARN",
+ "-Xep:InconsistentHashCode:ERROR",
+ "-Xep:IncrementInForLoopAndHeader:ERROR",
+ "-Xep:IndexOfChar:ERROR",
+ "-Xep:InexactVarargsConditional:ERROR",
+ "-Xep:InfiniteRecursion:ERROR",
"-Xep:InjectOnConstructorOfAbstractClass:ERROR",
+ "-Xep:InheritDoc:ERROR",
+ # "-Xep:InlineFormatString:WARN",
+ "-Xep:InlineMeInliner:ERROR",
+ "-Xep:InlineMeSuggester:ERROR",
+ "-Xep:InlineMeValidator:ERROR",
"-Xep:InputStreamSlowMultibyteRead:ERROR",
+ "-Xep:InsecureCryptoUsage:ERROR",
+ "-Xep:InstanceOfAndCastMatchWrongType:ERROR",
+ "-Xep:InstantTemporalUnit:ERROR",
+ "-Xep:IntLongMath:ERROR",
+ # "-Xep:InvalidBlockTag:WARN",
+ # "-Xep:InvalidInlineTag:WARN",
+ "-Xep:InvalidJavaTimeConstant:ERROR",
+ "-Xep:InvalidLink:ERROR",
+ # "-Xep:InvalidParam:WARN",
+ "-Xep:InvalidPatternSyntax:ERROR",
+ "-Xep:InvalidThrows:ERROR",
+ "-Xep:InvalidThrowsLink:ERROR",
+ "-Xep:InvalidTimeZoneID:ERROR",
+ "-Xep:InvalidZoneId:ERROR",
+ "-Xep:IsInstanceIncompatibleType:ERROR",
+ "-Xep:IsInstanceOfClass:ERROR",
+ "-Xep:IsLoggableTagLength:ERROR",
"-Xep:IterableAndIterator:ERROR",
+ "-Xep:IterablePathParameter:ERROR",
"-Xep:JUnit3FloatingPointComparisonWithoutDelta:ERROR",
+ "-Xep:JUnit3TestNotRun:ERROR",
+ "-Xep:JUnit4ClassAnnotationNonStatic:ERROR",
+ "-Xep:JUnit4ClassUsedInJUnit3:ERROR",
+ "-Xep:JUnit4SetUpNotRun:ERROR",
+ "-Xep:JUnit4TearDownNotRun:ERROR",
+ "-Xep:JUnit4TestNotRun:ERROR",
+ "-Xep:JUnit4TestsNotRunWithinEnclosed:ERROR",
"-Xep:JUnitAmbiguousTestClass:ERROR",
- "-Xep:LiteralClassName:ERROR",
+ "-Xep:JUnitAssertSameCheck:ERROR",
+ "-Xep:JUnitParameterMethodNotFound:ERROR",
+ "-Xep:JavaDurationGetSecondsGetNano:ERROR",
+ "-Xep:JavaDurationWithNanos:ERROR",
+ "-Xep:JavaDurationWithSeconds:ERROR",
+ "-Xep:JavaInstantGetSecondsGetNano:ERROR",
+ # "-Xep:JavaLangClash:WARN",
+ "-Xep:JavaLocalDateTimeGetNano:ERROR",
+ "-Xep:JavaLocalTimeGetNano:ERROR",
+ "-Xep:JavaPeriodGetDays:ERROR",
+ "-Xep:JavaTimeDefaultTimeZone:ERROR",
+ "-Xep:JavaUtilDate:ERROR",
+ # "-Xep:JdkObsolete:WARN",
+ "-Xep:JodaConstructors:ERROR",
+ "-Xep:JodaDateTimeConstants:ERROR",
+ "-Xep:JodaDurationWithMillis:ERROR",
+ "-Xep:JodaInstantWithMillis:ERROR",
+ "-Xep:JodaNewPeriod:ERROR",
+ "-Xep:JodaPlusMinusLong:ERROR",
+ "-Xep:JodaTimeConverterManager:ERROR",
+ "-Xep:JodaToSelf:ERROR",
+ "-Xep:JodaWithDurationAddedLong:ERROR",
+ "-Xep:LiteByteStringUtf8:ERROR",
+ "-Xep:LiteEnumValueOf:ERROR",
+ "-Xep:LiteProtoToString:ERROR",
+ "-Xep:LocalDateTemporalAmount:ERROR",
+ "-Xep:LockNotBeforeTry:ERROR",
+ "-Xep:LockOnBoxedPrimitive:ERROR",
+ "-Xep:LogicalAssignment:ERROR",
+ "-Xep:LongFloatConversion:ERROR",
+ "-Xep:LongLiteralLowerCaseSuffix:ERROR",
+ "-Xep:LoopConditionChecker:ERROR",
+ "-Xep:LoopOverCharArray:ERROR",
+ "-Xep:LossyPrimitiveCompare:ERROR",
+ "-Xep:MathAbsoluteRandom:ERROR",
+ "-Xep:MathRoundIntLong:ERROR",
+ "-Xep:MemoizeConstantVisitorStateLookups:ERROR",
+ "-Xep:MislabeledAndroidString:ERROR",
"-Xep:MissingCasesInEnumSwitch:ERROR",
"-Xep:MissingFail:ERROR",
"-Xep:MissingOverride:ERROR",
+ "-Xep:MissingSummary:ERROR",
+ "-Xep:MissingSuperCall:ERROR",
+ "-Xep:MissingTestCall:ERROR",
+ "-Xep:MisusedDayOfYear:ERROR",
+ "-Xep:MisusedWeekYear:ERROR",
+ "-Xep:MixedDescriptors:ERROR",
+ # "-Xep:MixedMutabilityReturnType:WARN",
+ "-Xep:MockitoUsage:ERROR",
+ "-Xep:ModifiedButNotUsed:ERROR",
+ "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
+ "-Xep:ModifySourceCollectionInStream:ERROR",
+ "-Xep:ModifyingCollectionWithItself:ERROR",
+ "-Xep:MultipleParallelOrSequentialCalls:ERROR",
+ "-Xep:MultipleUnaryOperatorsInMethodCall:ERROR",
+ "-Xep:MustBeClosedChecker:ERROR",
"-Xep:MutableConstantField:ERROR",
+ # "-Xep:MutablePublicArray:WARN",
+ "-Xep:NCopiesOfChar:ERROR",
"-Xep:NarrowingCompoundAssignment:ERROR",
+ "-Xep:NestedInstanceOfConditions:ERROR",
"-Xep:NonAtomicVolatileUpdate:ERROR",
+ "-Xep:NonCanonicalStaticImport:ERROR",
+ # "-Xep:NonCanonicalType:WARN",
+ "-Xep:NonFinalCompileTimeConstant:ERROR",
"-Xep:NonOverridingEquals:ERROR",
+ "-Xep:NonRuntimeAnnotation:ERROR",
+ "-Xep:NullOptional:ERROR",
+ "-Xep:NullTernary:ERROR",
"-Xep:NullableConstructor:ERROR",
"-Xep:NullablePrimitive:ERROR",
+ "-Xep:NullablePrimitiveArray:ERROR",
"-Xep:NullableVoid:ERROR",
+ "-Xep:ObjectEqualsForPrimitives:ERROR",
"-Xep:ObjectToString:ERROR",
+ "-Xep:ObjectsHashCodePrimitive:ERROR",
"-Xep:OperatorPrecedence:ERROR",
+ "-Xep:OptionalEquality:ERROR",
+ "-Xep:OptionalMapToOptional:ERROR",
+ "-Xep:OptionalMapUnusedValue:ERROR",
+ "-Xep:OptionalNotPresent:ERROR",
+ "-Xep:OptionalOfRedundantMethod:ERROR",
+ "-Xep:OrphanedFormatString:ERROR",
+ "-Xep:OutlineNone:ERROR",
+ "-Xep:OverlappingQualifierAndScopeAnnotation:ERROR",
+ "-Xep:OverrideThrowableToString:ERROR",
+ "-Xep:Overrides:ERROR",
"-Xep:OverridesGuiceInjectableMethod:ERROR",
+ "-Xep:OverridesJavaxInjectableMethod:ERROR",
+ "-Xep:PackageInfo:ERROR",
+ # "-Xep:ParameterName:WARN",
+ "-Xep:ParametersButNotParameterized:ERROR",
+ "-Xep:ParcelableCreator:ERROR",
+ "-Xep:PeriodFrom:ERROR",
+ "-Xep:PeriodGetTemporalUnit:ERROR",
+ "-Xep:PeriodTimeMath:ERROR",
+ "-Xep:PreconditionsCheckNotNullRepeated:ERROR",
"-Xep:PreconditionsInvalidPlaceholder:ERROR",
- "-Xep:ProtoFieldPreconditionsCheckNotNull:ERROR",
+ "-Xep:PrimitiveAtomicReference:ERROR",
+ "-Xep:PrivateSecurityContractProtoAccess:ERROR",
+ # "-Xep:ProtectedMembersInFinalClass:WARN",
+ "-Xep:ProtoBuilderReturnValueIgnored:ERROR",
+ "-Xep:ProtoDurationGetSecondsGetNano:ERROR",
+ "-Xep:ProtoFieldNullComparison:ERROR",
+ "-Xep:ProtoRedundantSet:ERROR",
+ "-Xep:ProtoStringFieldReferenceEquality:ERROR",
+ "-Xep:ProtoTimestampGetSecondsGetNano:ERROR",
+ "-Xep:ProtoTruthMixedDescriptors:ERROR",
"-Xep:ProtocolBufferOrdinal:ERROR",
+ "-Xep:ProvidesMethodOutsideOfModule:ERROR",
+ "-Xep:RandomCast:ERROR",
+ "-Xep:RandomModInteger:ERROR",
+ "-Xep:ReachabilityFenceUsage:ERROR",
+ "-Xep:RectIntersectReturnValueIgnored:ERROR",
"-Xep:ReferenceEquality:ERROR",
+ "-Xep:RefersToDaggerCodegen:ERROR",
+ "-Xep:RemovedInJDK11:ERROR",
"-Xep:RequiredModifiers:ERROR",
+ "-Xep:RestrictedApiChecker:ERROR",
+ "-Xep:RethrowReflectiveOperationExceptionAsLinkageError:ERROR",
+ "-Xep:ReturnFromVoid:ERROR",
+ "-Xep:ReturnValueIgnored:ERROR",
+ "-Xep:RxReturnValueIgnored:ERROR",
+ # "-Xep:SameNameButDifferent:WARN",
+ "-Xep:SelfAssignment:ERROR",
+ "-Xep:SelfComparison:ERROR",
+ "-Xep:SelfEquals:ERROR",
"-Xep:ShortCircuitBoolean:ERROR",
- "-Xep:SimpleDateFormatConstant:ERROR",
+ "-Xep:ShouldHaveEvenArgs:ERROR",
+ "-Xep:SizeGreaterThanOrEqualsZero:ERROR",
+ "-Xep:StaticAssignmentInConstructor:ERROR",
"-Xep:StaticGuardedByInstance:ERROR",
+ "-Xep:StaticMockMember:ERROR",
+ "-Xep:StaticQualifiedUsingExpression:ERROR",
+ "-Xep:StreamToString:ERROR",
+ "-Xep:StringBuilderInitWithChar:ERROR",
"-Xep:StringEquality:ERROR",
+ # "-Xep:StringSplitter:WARN",
+ "-Xep:SubstringOfZero:ERROR",
+ "-Xep:SuppressWarningsDeprecated:ERROR",
+ "-Xep:SwigMemoryLeak:ERROR",
"-Xep:SynchronizeOnNonFinalField:ERROR",
+ "-Xep:TemporalAccessorGetChronoField:ERROR",
+ "-Xep:TestParametersNotInitialized:ERROR",
+ "-Xep:TheoryButNoTheories:ERROR",
+ # "-Xep:ThreadJoinLoop:WARN",
+ "-Xep:ThreadLocalUsage:ERROR",
+ # "-Xep:ThreadPriorityCheck:WARN",
+ "-Xep:ThreeLetterTimeZoneID:ERROR",
+ "-Xep:ThrowIfUncheckedKnownChecked:ERROR",
+ "-Xep:ThrowNull:ERROR",
+ "-Xep:TimeUnitConversionChecker:ERROR",
+ "-Xep:ToStringReturnsNull:ERROR",
+ "-Xep:TreeToString:ERROR",
+ # "-Xep:TruthAssertExpected:WARN",
"-Xep:TruthConstantAsserts:ERROR",
+ "-Xep:TruthGetOrDefault:ERROR",
+ "-Xep:TruthIncompatibleType:ERROR",
+ "-Xep:TruthSelfEquals:ERROR",
+ "-Xep:TryFailThrowable:ERROR",
+ "-Xep:TypeEquals:ERROR",
+ "-Xep:TypeNameShadowing:ERROR",
+ "-Xep:TypeParameterQualifier:ERROR",
"-Xep:TypeParameterShadowing:ERROR",
"-Xep:TypeParameterUnusedInFormals:ERROR",
"-Xep:URLEqualsHashCode:ERROR",
+ # "-Xep:UndefinedEquals:WARN",
+ "-Xep:UnescapedEntity:ERROR",
+ "-Xep:UnnecessaryAssignment:ERROR",
+ "-Xep:UnnecessaryCheckNotNull:ERROR",
+ # "-Xep:UnnecessaryLambda:WARN",
+ "-Xep:UnnecessaryMethodInvocationMatcher:ERROR",
+ "-Xep:UnnecessaryMethodReference:ERROR",
+ # "-Xep:UnnecessaryParentheses:WARN",
+ "-Xep:UnnecessaryTypeArgument:ERROR",
+ "-Xep:UnrecognisedJavadocTag:ERROR",
+ "-Xep:UnsafeFinalization:ERROR",
+ "-Xep:UnsafeReflectiveConstructionCast:ERROR",
"-Xep:UnsynchronizedOverridesSynchronized:ERROR",
+ "-Xep:UnusedAnonymousClass:ERROR",
+ "-Xep:UnusedCollectionModifiedInPlace:ERROR",
"-Xep:UnusedException:ERROR",
+ "-Xep:UnusedMethod:ERROR",
+ "-Xep:UnusedNestedClass:ERROR",
+ "-Xep:UnusedVariable:ERROR",
+ "-Xep:UseBinds:ERROR",
+ "-Xep:UseCorrectAssertInTests:ERROR",
+ "-Xep:VarTypeName:ERROR",
+ "-Xep:VariableNameSameAsType:ERROR",
"-Xep:WaitNotInLoop:ERROR",
+ "-Xep:WakelockReleasedDangerously:ERROR",
"-Xep:WildcardImport:ERROR",
+ "-Xep:WithSignatureDiscouraged:ERROR",
+ "-Xep:WrongOneof:ERROR",
+ "-Xep:XorPower:ERROR",
+ "-Xep:ZoneIdOfZ:ERROR",
],
packages = ["error_prone_packages"],
)
diff --git a/tools/bzl/js.bzl b/tools/bzl/js.bzl
index eedf0a1..c8d6e4b 100644
--- a/tools/bzl/js.bzl
+++ b/tools/bzl/js.bzl
@@ -142,3 +142,36 @@
"zip -Drq $$ROOT/$@ -g .",
]),
)
+
+def karma_test(name, srcs, data):
+ """Creates a Karma test target.
+
+ It can be used both for the main Gerrit js bundle, but also for plugins. So
+ it should be extremely easy to add Karma test capabilities for new plugins.
+
+ We are sharing one karma.conf.js file. If you want to customize that, then
+ consider using command line arguments that the config file can process, see
+ the `root` argument for an example.
+
+ Args:
+ name: The name of the test rule.
+ srcs: The shell script to invoke, where you can set command line
+ arguments for Karma and its config.
+ data: The bundle of JavaScript files with the tests included.
+ """
+
+ native.sh_test(
+ name = name,
+ size = "enormous",
+ srcs = srcs,
+ args = [
+ "$(location //polygerrit-ui:karma_bin)",
+ "$(location //polygerrit-ui:karma.conf.js)",
+ ],
+ data = data + [
+ "//polygerrit-ui:karma_bin",
+ "//polygerrit-ui:karma.conf.js",
+ ],
+ # Should not run sandboxed.
+ tags = ["karma", "local", "manual"],
+ )
diff --git a/tools/js/eslint.bzl b/tools/js/eslint.bzl
index b32e2bc..eb4d37a 100644
--- a/tools/js/eslint.bzl
+++ b/tools/js/eslint.bzl
@@ -16,6 +16,34 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary", "nodejs_test")
+def plugin_eslint():
+ """ Convenience wrapper macro of eslint() for Gerrit js plugins
+
+ Args:
+ name: name of the rule
+ """
+ eslint(
+ name = "lint",
+ srcs = native.glob(["**/*.ts"]),
+ config = ".eslintrc.js",
+ data = [
+ "tsconfig.json",
+ "//plugins:.eslintrc.js",
+ "//plugins:.prettierrc.js",
+ "//plugins:tsconfig-plugins-base.json",
+ ],
+ extensions = [".ts"],
+ ignore = "//plugins:.eslintignore",
+ plugins = [
+ "@npm//eslint-config-google",
+ "@npm//eslint-plugin-html",
+ "@npm//eslint-plugin-import",
+ "@npm//eslint-plugin-jsdoc",
+ "@npm//eslint-plugin-prettier",
+ "@npm//gts",
+ ],
+ )
+
def eslint(name, plugins, srcs, config, ignore, extensions = [".js"], data = []):
""" Macro to define eslint rules for files.
@@ -87,7 +115,7 @@
"*_test_require_patch.js",
"--ignore-pattern",
"*_test_loader.js",
- "./", # Relative to the config file location
+ "./", # Relative to the config file location
],
# Should not run sandboxed.
tags = [
diff --git a/twinkie.patch b/twinkie.patch
deleted file mode 100644
index 0a61243..0000000
--- a/twinkie.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/node_modules/twinkie/src/app/index.js
-+++ b/node_modules/twinkie/src/app/index.js
-@@ -250,7 +250,7 @@ twinkie --tsconfig tsconfig.json --outdir output_dir [--files file_list] [--outt
- incremental: false,
- noEmit: true,
- },
-- files: [...allProgramFilesNames, generatedFiles],
-+ files: [...allProgramFilesNames, ...generatedFiles],
- };
- fs.writeFileSync(cmdLineOptions.outputTsConfig, JSON.stringify(tsconfigContent, null, 2));
- }
diff --git a/yarn.lock b/yarn.lock
index 7e13131..3ddfac6 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -30,6 +30,13 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
+"@babel/runtime@^7.10.2":
+ version "7.15.4"
+ resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.4.tgz#fd17d16bfdf878e6dd02d19753a39fa8a8d9c84a"
+ integrity sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==
+ dependencies:
+ regenerator-runtime "^0.13.4"
+
"@bazel/rollup@^3.5.0":
version "3.8.0"
resolved "https://registry.yarnpkg.com/@bazel/rollup/-/rollup-3.8.0.tgz#850f56176d73e3b7d99a43c7e33df21ecc6ac161"
@@ -79,6 +86,14 @@
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf"
integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==
+"@mrmlnc/readdir-enhanced@^2.2.1":
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
+ integrity sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g==
+ dependencies:
+ call-me-maybe "^1.0.1"
+ glob-to-regexp "^0.3.0"
+
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
@@ -92,6 +107,11 @@
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b"
integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==
+"@nodelib/fs.stat@^1.1.2":
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
+ integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==
+
"@nodelib/fs.walk@^1.2.3":
version "1.2.8"
resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a"
@@ -191,9 +211,9 @@
integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==
"@types/node@*":
- version "16.7.10"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-16.7.10.tgz#7aa732cc47341c12a16b7d562f519c2383b6d4fc"
- integrity sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==
+ version "16.9.6"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.6.tgz#040a64d7faf9e5d9e940357125f0963012e66f04"
+ integrity sha512-YHUZhBOMTM3mjFkXVcK+WwAcYmyhe1wL4lfqNtzI0b3qAy7yuSetnM7QJazgE5PFmgVTNGiLOgRFfJMqW7XpSQ==
"@types/node@^10.1.0":
version "10.17.60"
@@ -354,6 +374,21 @@
dependencies:
sprintf-js "~1.0.2"
+arr-diff@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
+ integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=
+
+arr-flatten@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
+ integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==
+
+arr-union@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
+ integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=
+
array-includes@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.3.tgz#c7f619b382ad2afaf5326cddfdc0afc61af7690a"
@@ -370,6 +405,11 @@
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
+array-unique@^0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
+ integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=
+
array.prototype.flat@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz#6ef638b43312bd401b4c6199fdec7e2dc9e9a123"
@@ -384,16 +424,39 @@
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=
+assign-symbols@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
+ integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=
+
astral-regex@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
+atob@^2.1.2:
+ version "2.1.2"
+ resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
+ integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
+
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
+base@^0.11.1:
+ version "0.11.2"
+ resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
+ integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==
+ dependencies:
+ cache-base "^1.0.1"
+ class-utils "^0.3.5"
+ component-emitter "^1.2.1"
+ define-property "^1.0.0"
+ isobject "^3.0.1"
+ mixin-deep "^1.2.0"
+ pascalcase "^0.1.1"
+
boolbase@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e"
@@ -421,6 +484,22 @@
balanced-match "^1.0.0"
concat-map "0.0.1"
+braces@^2.3.1:
+ version "2.3.2"
+ resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729"
+ integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==
+ dependencies:
+ arr-flatten "^1.1.0"
+ array-unique "^0.3.2"
+ extend-shallow "^2.0.1"
+ fill-range "^4.0.0"
+ isobject "^3.0.1"
+ repeat-element "^1.1.2"
+ snapdragon "^0.8.1"
+ snapdragon-node "^2.0.1"
+ split-string "^3.0.2"
+ to-regex "^3.0.1"
+
braces@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
@@ -433,6 +512,21 @@
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
+cache-base@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
+ integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==
+ dependencies:
+ collection-visit "^1.0.0"
+ component-emitter "^1.2.1"
+ get-value "^2.0.6"
+ has-value "^1.0.0"
+ isobject "^3.0.1"
+ set-value "^2.0.0"
+ to-object-path "^0.3.0"
+ union-value "^1.0.0"
+ unset-value "^1.0.0"
+
cacheable-request@^6.0.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912"
@@ -454,6 +548,11 @@
function-bind "^1.1.1"
get-intrinsic "^1.0.2"
+call-me-maybe@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b"
+ integrity sha1-JtII6onje1y95gJQoV8DHBak1ms=
+
callsites@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
@@ -468,7 +567,7 @@
map-obj "^4.0.0"
quick-lru "^4.0.1"
-camelcase@^5.3.1:
+camelcase@^5.0.0, camelcase@^5.3.1:
version "5.3.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
@@ -478,7 +577,7 @@
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
-chalk@^2.0.0:
+chalk@^2.0.0, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
@@ -517,6 +616,16 @@
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46"
integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==
+class-utils@^0.3.5:
+ version "0.3.6"
+ resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
+ integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==
+ dependencies:
+ arr-union "^3.1.0"
+ define-property "^0.2.5"
+ isobject "^3.0.0"
+ static-extend "^0.1.1"
+
cli-boxes@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.1.tgz#ddd5035d25094fce220e9cab40a45840a440318f"
@@ -534,6 +643,15 @@
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6"
integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==
+cliui@^6.0.0:
+ version "6.0.0"
+ resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
+ integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
+ dependencies:
+ string-width "^4.2.0"
+ strip-ansi "^6.0.0"
+ wrap-ansi "^6.2.0"
+
clone-response@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b"
@@ -541,6 +659,14 @@
dependencies:
mimic-response "^1.0.0"
+collection-visit@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
+ integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=
+ dependencies:
+ map-visit "^1.0.0"
+ object-visit "^1.0.0"
+
color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
@@ -575,6 +701,11 @@
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.1.5.tgz#453627ef8f67dbcec44e79a9bd5baa37f0bce9b2"
integrity sha512-RePCE4leIhBlmrqiYTvaqEeGYg7qpSl4etaIabKtdOQVi+mSTIBBklGUwIr79GXYnl3LpMwmDw4KeR2stNc6FA==
+component-emitter@^1.2.1:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
+ integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==
+
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -592,6 +723,11 @@
write-file-atomic "^3.0.0"
xdg-basedir "^4.0.0"
+copy-descriptor@^0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
+ integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=
+
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
@@ -621,7 +757,7 @@
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2"
integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==
-debug@^2.6.9:
+debug@^2.2.0, debug@^2.3.3, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@@ -655,6 +791,11 @@
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
+decode-uri-component@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
+ integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
+
decompress-response@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3"
@@ -684,6 +825,37 @@
dependencies:
object-keys "^1.0.12"
+define-property@^0.2.5:
+ version "0.2.5"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116"
+ integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=
+ dependencies:
+ is-descriptor "^0.1.0"
+
+define-property@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6"
+ integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY=
+ dependencies:
+ is-descriptor "^1.0.0"
+
+define-property@^2.0.2:
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d"
+ integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==
+ dependencies:
+ is-descriptor "^1.0.2"
+ isobject "^3.0.1"
+
+didyoumean2@4.1.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/didyoumean2/-/didyoumean2-4.1.0.tgz#f813cb7c82c249443e599be077f76e88f24b85e4"
+ integrity sha512-qTBmfQoXvhKO75D/05C8m+fteQmn4U46FWYiLhXtZQInzitXLWY0EQ/2oKnpAz9g2lQWW8jYcLcT+hPJGT+kig==
+ dependencies:
+ "@babel/runtime" "^7.10.2"
+ leven "^3.1.0"
+ lodash.deburr "^4.1.0"
+
dir-glob@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f"
@@ -954,6 +1126,15 @@
semver "^7.3.5"
spdx-expression-parse "^3.0.1"
+eslint-plugin-lit@^1.5.1:
+ version "1.5.1"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-lit/-/eslint-plugin-lit-1.5.1.tgz#e5b86fee4aeb6023ad4bb90b3d9e462ca8eff755"
+ integrity sha512-pYB0QM11uyOk5L55QfGhBmWi8a56PkNsnx+zVpY4bxz9YVquEo4BeRnFmf9AwFyT89rhGud9QruFhM2xJ4piwg==
+ dependencies:
+ parse5 "^6.0.1"
+ parse5-htmlparser2-tree-adapter "^6.0.1"
+ requireindex "^1.2.0"
+
eslint-plugin-node@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz#c95544416ee4ada26740a30474eefc5402dc671d"
@@ -973,6 +1154,11 @@
dependencies:
prettier-linter-helpers "^1.0.0"
+eslint-plugin-regex@^1.8.0:
+ version "1.8.0"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-regex/-/eslint-plugin-regex-1.8.0.tgz#4bd111cf5235fb76a4a7f77d7ffcb7b3777b8a77"
+ integrity sha512-rmzVvpoxHKgvcYDo9d1X9RMFOtyOV3A6taD3KWE6gIID2dHoc8RPd0YAjDSJ0LG35wnehQBfsNB+F7q4eYqXqw==
+
eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
@@ -1109,6 +1295,34 @@
signal-exit "^3.0.3"
strip-final-newline "^2.0.0"
+expand-brackets@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
+ integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI=
+ dependencies:
+ debug "^2.3.3"
+ define-property "^0.2.5"
+ extend-shallow "^2.0.1"
+ posix-character-classes "^0.1.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
+extend-shallow@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
+ integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=
+ dependencies:
+ is-extendable "^0.1.0"
+
+extend-shallow@^3.0.0, extend-shallow@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8"
+ integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=
+ dependencies:
+ assign-symbols "^1.0.0"
+ is-extendable "^1.0.1"
+
external-editor@^3.0.3:
version "3.1.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495"
@@ -1118,6 +1332,20 @@
iconv-lite "^0.4.24"
tmp "^0.0.33"
+extglob@^2.0.4:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543"
+ integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==
+ dependencies:
+ array-unique "^0.3.2"
+ define-property "^1.0.0"
+ expand-brackets "^2.1.4"
+ extend-shallow "^2.0.1"
+ fragment-cache "^0.2.1"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
@@ -1128,7 +1356,19 @@
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==
-fast-glob@^3.1.1:
+fast-glob@^2.2.6:
+ version "2.2.7"
+ resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d"
+ integrity sha512-g1KuQwHOZAmOZMuBtHdxDtju+T2RT8jgCC9aANsbpdiDDTSnjgfuVsIBNKbUeJI3oKMRExcfNDtJl4OhbffMsw==
+ dependencies:
+ "@mrmlnc/readdir-enhanced" "^2.2.1"
+ "@nodelib/fs.stat" "^1.1.2"
+ glob-parent "^3.1.0"
+ is-glob "^4.0.0"
+ merge2 "^1.2.3"
+ micromatch "^3.1.10"
+
+fast-glob@^3.1.1, fast-glob@^3.2.2:
version "3.2.7"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1"
integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==
@@ -1170,6 +1410,16 @@
dependencies:
flat-cache "^3.0.4"
+fill-range@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
+ integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=
+ dependencies:
+ extend-shallow "^2.0.1"
+ is-number "^3.0.0"
+ repeat-string "^1.6.1"
+ to-regex-range "^2.1.0"
+
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
@@ -1205,6 +1455,18 @@
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.2.tgz#64bfed5cb68fe3ca78b3eb214ad97b63bedce561"
integrity sha512-JaTY/wtrcSyvXJl4IMFHPKyFur1sE9AUqc0QnhOaJ0CxHtAoIV8pYDzeEfAaNEtGkOfq4gr3LBFmdXW5mOQFnA==
+for-in@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
+ integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=
+
+fragment-cache@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19"
+ integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=
+ dependencies:
+ map-cache "^0.2.2"
+
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -1225,6 +1487,11 @@
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
+get-caller-file@^2.0.1:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
+ integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
+
get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6"
@@ -1253,6 +1520,19 @@
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7"
integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==
+get-value@^2.0.3, get-value@^2.0.6:
+ version "2.0.6"
+ resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
+ integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=
+
+glob-parent@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
+ integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=
+ dependencies:
+ is-glob "^3.1.0"
+ path-dirname "^1.0.0"
+
glob-parent@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
@@ -1260,6 +1540,11 @@
dependencies:
is-glob "^4.0.1"
+glob-to-regexp@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
+ integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=
+
glob@^7.1.3:
version "7.1.7"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
@@ -1374,6 +1659,37 @@
dependencies:
has-symbols "^1.0.2"
+has-value@^0.3.1:
+ version "0.3.1"
+ resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f"
+ integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=
+ dependencies:
+ get-value "^2.0.3"
+ has-values "^0.1.4"
+ isobject "^2.0.0"
+
+has-value@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177"
+ integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=
+ dependencies:
+ get-value "^2.0.6"
+ has-values "^1.0.0"
+ isobject "^3.0.0"
+
+has-values@^0.1.4:
+ version "0.1.4"
+ resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771"
+ integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E=
+
+has-values@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f"
+ integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=
+ dependencies:
+ is-number "^3.0.0"
+ kind-of "^4.0.0"
+
has-yarn@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77"
@@ -1521,6 +1837,20 @@
has "^1.0.3"
side-channel "^1.0.4"
+is-accessor-descriptor@^0.1.6:
+ version "0.1.6"
+ resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
+ integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=
+ dependencies:
+ kind-of "^3.0.2"
+
+is-accessor-descriptor@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656"
+ integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==
+ dependencies:
+ kind-of "^6.0.0"
+
is-arrayish@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
@@ -1541,6 +1871,11 @@
call-bind "^1.0.2"
has-tostringtag "^1.0.0"
+is-buffer@^1.1.5:
+ version "1.1.6"
+ resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
+ integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==
+
is-callable@^1.1.4, is-callable@^1.2.3:
version "1.2.4"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945"
@@ -1560,6 +1895,20 @@
dependencies:
has "^1.0.3"
+is-data-descriptor@^0.1.4:
+ version "0.1.4"
+ resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
+ integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=
+ dependencies:
+ kind-of "^3.0.2"
+
+is-data-descriptor@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7"
+ integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==
+ dependencies:
+ kind-of "^6.0.0"
+
is-date-object@^1.0.1:
version "1.0.5"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f"
@@ -1567,7 +1916,37 @@
dependencies:
has-tostringtag "^1.0.0"
-is-extglob@^2.1.1:
+is-descriptor@^0.1.0:
+ version "0.1.6"
+ resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca"
+ integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==
+ dependencies:
+ is-accessor-descriptor "^0.1.6"
+ is-data-descriptor "^0.1.4"
+ kind-of "^5.0.0"
+
+is-descriptor@^1.0.0, is-descriptor@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec"
+ integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==
+ dependencies:
+ is-accessor-descriptor "^1.0.0"
+ is-data-descriptor "^1.0.0"
+ kind-of "^6.0.2"
+
+is-extendable@^0.1.0, is-extendable@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
+ integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=
+
+is-extendable@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4"
+ integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==
+ dependencies:
+ is-plain-object "^2.0.4"
+
+is-extglob@^2.1.0, is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=
@@ -1582,6 +1961,13 @@
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
+is-glob@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
+ integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=
+ dependencies:
+ is-extglob "^2.1.0"
+
is-glob@^4.0.0, is-glob@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc"
@@ -1614,6 +2000,13 @@
dependencies:
has-tostringtag "^1.0.0"
+is-number@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"
+ integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=
+ dependencies:
+ kind-of "^3.0.2"
+
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
@@ -1634,6 +2027,13 @@
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4=
+is-plain-object@^2.0.3, is-plain-object@^2.0.4:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
+ integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==
+ dependencies:
+ isobject "^3.0.1"
+
is-regex@^1.1.3:
version "1.1.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958"
@@ -1666,16 +2066,38 @@
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=
+is-windows@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
+ integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==
+
is-yarn-global@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232"
integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==
+isarray@1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
+ integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
+
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
+isobject@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
+ integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=
+ dependencies:
+ isarray "1.0.0"
+
+isobject@^3.0.0, isobject@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
+ integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
+
js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
@@ -1745,7 +2167,26 @@
dependencies:
json-buffer "3.0.0"
-kind-of@^6.0.3:
+kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
+ integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=
+ dependencies:
+ is-buffer "^1.1.5"
+
+kind-of@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57"
+ integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc=
+ dependencies:
+ is-buffer "^1.1.5"
+
+kind-of@^5.0.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
+ integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==
+
+kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
@@ -1757,6 +2198,11 @@
dependencies:
package-json "^6.3.0"
+leven@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2"
+ integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==
+
levn@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
@@ -1770,6 +2216,20 @@
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
+lit-analyzer@1.2.1, lit-analyzer@^1.2.1:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/lit-analyzer/-/lit-analyzer-1.2.1.tgz#725331a4019ae870dd631d4dd709d39a237161ea"
+ integrity sha512-OEARBhDidyaQENavLbzpTKbEmu5rnAI+SdYsH4ia1BlGlLiqQXoym7uH1MaRPtwtUPbkhUfT4OBDZ+74VHc3Cg==
+ dependencies:
+ chalk "^2.4.2"
+ didyoumean2 "4.1.0"
+ fast-glob "^2.2.6"
+ parse5 "5.1.0"
+ ts-simple-type "~1.0.5"
+ vscode-css-languageservice "4.3.0"
+ vscode-html-languageservice "3.1.0"
+ web-component-analyzer "~1.1.1"
+
load-json-file@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b"
@@ -1800,6 +2260,11 @@
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
+lodash.deburr@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/lodash.deburr/-/lodash.deburr-4.1.0.tgz#ddb1bbb3ef07458c0177ba07de14422cb033ff9b"
+ integrity sha1-3bG7s+8HRYwBd7oH3hRCLLAz/5s=
+
lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
@@ -1844,6 +2309,11 @@
dependencies:
semver "^6.0.0"
+map-cache@^0.2.2:
+ version "0.2.2"
+ resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
+ integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=
+
map-obj@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d"
@@ -1854,6 +2324,13 @@
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7"
integrity sha512-+WA2/1sPmDj1dlvvJmB5G6JKfY9dpn7EVBUL06+y6PoljPkh+6V1QihwxNkbcGxCRjt2b0F9K0taiCuo7MbdFQ==
+map-visit@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
+ integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=
+ dependencies:
+ object-visit "^1.0.0"
+
meow@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/meow/-/meow-9.0.0.tgz#cd9510bc5cac9dee7d03c73ee1f9ad959f4ea364"
@@ -1877,11 +2354,30 @@
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
-merge2@^1.3.0:
+merge2@^1.2.3, merge2@^1.3.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
+micromatch@^3.1.10:
+ version "3.1.10"
+ resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
+ integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==
+ dependencies:
+ arr-diff "^4.0.0"
+ array-unique "^0.3.2"
+ braces "^2.3.1"
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ extglob "^2.0.4"
+ fragment-cache "^0.2.1"
+ kind-of "^6.0.2"
+ nanomatch "^1.2.9"
+ object.pick "^1.3.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.2"
+
micromatch@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9"
@@ -1933,6 +2429,14 @@
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
+mixin-deep@^1.2.0:
+ version "1.3.2"
+ resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
+ integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==
+ dependencies:
+ for-in "^1.0.2"
+ is-extendable "^1.0.1"
+
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
@@ -1953,6 +2457,23 @@
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
+nanomatch@^1.2.9:
+ version "1.2.13"
+ resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
+ integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==
+ dependencies:
+ arr-diff "^4.0.0"
+ array-unique "^0.3.2"
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ fragment-cache "^0.2.1"
+ is-windows "^1.0.2"
+ kind-of "^6.0.2"
+ object.pick "^1.3.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
@@ -2002,6 +2523,15 @@
dependencies:
boolbase "~1.0.0"
+object-copy@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c"
+ integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw=
+ dependencies:
+ copy-descriptor "^0.1.0"
+ define-property "^0.2.5"
+ kind-of "^3.0.3"
+
object-inspect@^1.11.0, object-inspect@^1.9.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1"
@@ -2012,6 +2542,13 @@
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==
+object-visit@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb"
+ integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=
+ dependencies:
+ isobject "^3.0.0"
+
object.assign@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940"
@@ -2022,6 +2559,13 @@
has-symbols "^1.0.1"
object-keys "^1.1.1"
+object.pick@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747"
+ integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=
+ dependencies:
+ isobject "^3.0.1"
+
object.values@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30"
@@ -2140,6 +2684,18 @@
json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6"
+parse5-htmlparser2-tree-adapter@^6.0.1:
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6"
+ integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==
+ dependencies:
+ parse5 "^6.0.1"
+
+parse5@5.1.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/parse5/-/parse5-5.1.0.tgz#c59341c9723f414c452975564c7c00a68d58acd2"
+ integrity sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==
+
parse5@^3.0.1:
version "3.0.3"
resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.3.tgz#042f792ffdd36851551cf4e9e066b3874ab45b5c"
@@ -2147,6 +2703,21 @@
dependencies:
"@types/node" "*"
+parse5@^6.0.1:
+ version "6.0.1"
+ resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b"
+ integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==
+
+pascalcase@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
+ integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
+
+path-dirname@^1.0.0:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
+ integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=
+
path-exists@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
@@ -2208,6 +2779,11 @@
dependencies:
find-up "^2.1.0"
+posix-character-classes@^0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
+ integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
+
prelude-ls@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -2352,6 +2928,19 @@
indent-string "^4.0.0"
strip-indent "^3.0.0"
+regenerator-runtime@^0.13.4:
+ version "0.13.9"
+ resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
+ integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==
+
+regex-not@^1.0.0, regex-not@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c"
+ integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==
+ dependencies:
+ extend-shallow "^3.0.2"
+ safe-regex "^1.1.0"
+
regexpp@^3.0.0, regexpp@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
@@ -2376,16 +2965,46 @@
dependencies:
rc "^1.2.8"
+repeat-element@^1.1.2:
+ version "1.1.4"
+ resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.4.tgz#be681520847ab58c7568ac75fbfad28ed42d39e9"
+ integrity sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==
+
+repeat-string@^1.6.1:
+ version "1.6.1"
+ resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
+ integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc=
+
+require-directory@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
+ integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=
+
require-from-string@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
+require-main-filename@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
+ integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
+
+requireindex@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
+ integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==
+
resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
+resolve-url@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
+ integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=
+
resolve@^1.10.0, resolve@^1.10.1, resolve@^1.20.0:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
@@ -2409,6 +3028,11 @@
onetime "^5.1.0"
signal-exit "^3.0.2"
+ret@~0.1.10:
+ version "0.1.15"
+ resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
+ integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==
+
reusify@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
@@ -2452,6 +3076,13 @@
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
+safe-regex@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"
+ integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4=
+ dependencies:
+ ret "~0.1.10"
+
"safer-buffer@>= 2.1.2 < 3":
version "2.1.2"
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
@@ -2486,6 +3117,21 @@
dependencies:
lru-cache "^6.0.0"
+set-blocking@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
+ integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc=
+
+set-value@^2.0.0, set-value@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b"
+ integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==
+ dependencies:
+ extend-shallow "^2.0.1"
+ is-extendable "^0.1.1"
+ is-plain-object "^2.0.3"
+ split-string "^3.0.1"
+
shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
@@ -2526,6 +3172,47 @@
astral-regex "^2.0.0"
is-fullwidth-code-point "^3.0.0"
+snapdragon-node@^2.0.1:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
+ integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==
+ dependencies:
+ define-property "^1.0.0"
+ isobject "^3.0.0"
+ snapdragon-util "^3.0.1"
+
+snapdragon-util@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2"
+ integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==
+ dependencies:
+ kind-of "^3.2.0"
+
+snapdragon@^0.8.1:
+ version "0.8.2"
+ resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d"
+ integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==
+ dependencies:
+ base "^0.11.1"
+ debug "^2.2.0"
+ define-property "^0.2.5"
+ extend-shallow "^2.0.1"
+ map-cache "^0.2.2"
+ source-map "^0.5.6"
+ source-map-resolve "^0.5.0"
+ use "^3.1.0"
+
+source-map-resolve@^0.5.0:
+ version "0.5.3"
+ resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a"
+ integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==
+ dependencies:
+ atob "^2.1.2"
+ decode-uri-component "^0.2.0"
+ resolve-url "^0.2.1"
+ source-map-url "^0.4.0"
+ urix "^0.1.0"
+
source-map-support@0.5.9:
version "0.5.9"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f"
@@ -2542,6 +3229,16 @@
buffer-from "^1.0.0"
source-map "^0.6.0"
+source-map-url@^0.4.0:
+ version "0.4.1"
+ resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56"
+ integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==
+
+source-map@^0.5.6:
+ version "0.5.7"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
+ integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
+
source-map@^0.6.0:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
@@ -2578,11 +3275,26 @@
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.10.tgz#0d9becccde7003d6c658d487dd48a32f0bf3014b"
integrity sha512-oie3/+gKf7QtpitB0LYLETe+k8SifzsX4KixvpOsbI6S0kRiRQ5MKOio8eMSAKQ17N06+wdEOXRiId+zOxo0hA==
+split-string@^3.0.1, split-string@^3.0.2:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
+ integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==
+ dependencies:
+ extend-shallow "^3.0.0"
+
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
+static-extend@^0.1.1:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
+ integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=
+ dependencies:
+ define-property "^0.2.5"
+ object-copy "^0.1.0"
+
string-width@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
@@ -2717,11 +3429,26 @@
dependencies:
os-tmpdir "~1.0.2"
+to-object-path@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
+ integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=
+ dependencies:
+ kind-of "^3.0.2"
+
to-readable-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771"
integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==
+to-regex-range@^2.1.0:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38"
+ integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=
+ dependencies:
+ is-number "^3.0.0"
+ repeat-string "^1.6.1"
+
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
@@ -2729,11 +3456,33 @@
dependencies:
is-number "^7.0.0"
+to-regex@^3.0.1, to-regex@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce"
+ integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==
+ dependencies:
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ regex-not "^1.0.2"
+ safe-regex "^1.1.0"
+
trim-newlines@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144"
integrity sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==
+ts-lit-plugin@^1.2.1:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/ts-lit-plugin/-/ts-lit-plugin-1.2.1.tgz#7fca17a454645c14911917fa7f17ade582fa3056"
+ integrity sha512-k/Me+aT1N9ckC/KuJCAlAJgCHFezOxuOGOzBE0q42xnKbJnUMNl08WqWF6C7OKecCPHIMRk5Wj5o6MDsmt9+qA==
+ dependencies:
+ lit-analyzer "1.2.1"
+
+ts-simple-type@~1.0.5:
+ version "1.0.7"
+ resolved "https://registry.yarnpkg.com/ts-simple-type/-/ts-simple-type-1.0.7.tgz#03930af557528dd40eaa121913c7035a0baaacf8"
+ integrity sha512-zKmsCQs4dZaeSKjEA7pLFDv7FHHqAFLPd0Mr//OIJvu8M+4p4bgSFJwZSEBEg3ec9W7RzRz1vi8giiX0+mheBQ==
+
tsconfig-paths@^3.11.0:
version "3.11.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz#954c1fe973da6339c78e06b03ce2e48810b65f36"
@@ -2763,10 +3512,10 @@
dependencies:
tslib "^1.8.1"
-twinkie@^1.1.2:
- version "1.1.2"
- resolved "https://registry.yarnpkg.com/twinkie/-/twinkie-1.1.2.tgz#c301e4fc26d00d61d3d7e5be030dc6a2264271da"
- integrity sha512-4KwhyrcrRb0WWJKMX/aT+npmMZC0h+sA//+bLhNupmuKvesrH2vEZDe6yIr48FMWKEsdA2xNdQqw/3MapZ5qXQ==
+twinkie@^1.1.3:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/twinkie/-/twinkie-1.1.3.tgz#1a6f0cd11c59e245bc2d16c7c9fc1ec13e477229"
+ integrity sha512-8Y1U/UCtf8JC4snuV4KAo4e9nwJcKZUoMVOApihJzua4JJWeGB/2RYqAusKk3cUczJeZRGzirHpP1hkArcbA8A==
dependencies:
"@types/minimatch" "3.0.3"
cheerio "1.0.0-rc.2"
@@ -2812,16 +3561,16 @@
dependencies:
is-typedarray "^1.0.0"
-typescript@4.0.5:
- version "4.0.5"
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
- integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==
-
-typescript@4.3.2:
+typescript@4.0.5, typescript@4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
+typescript@^3.8.3:
+ version "3.9.10"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8"
+ integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==
+
unbox-primitive@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"
@@ -2832,6 +3581,16 @@
has-symbols "^1.0.2"
which-boxed-primitive "^1.0.2"
+union-value@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847"
+ integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==
+ dependencies:
+ arr-union "^3.1.0"
+ get-value "^2.0.6"
+ is-extendable "^0.1.1"
+ set-value "^2.0.1"
+
unique-string@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d"
@@ -2839,6 +3598,14 @@
dependencies:
crypto-random-string "^2.0.0"
+unset-value@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
+ integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=
+ dependencies:
+ has-value "^0.3.1"
+ isobject "^3.0.0"
+
update-notifier@^5.0.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-5.1.0.tgz#4ab0d7c7f36a231dd7316cf7729313f0214d9ad9"
@@ -2866,6 +3633,11 @@
dependencies:
punycode "^2.1.0"
+urix@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
+ integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=
+
url-parse-lax@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c"
@@ -2873,6 +3645,11 @@
dependencies:
prepend-http "^2.0.0"
+use@^3.1.0:
+ version "3.1.1"
+ resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
+ integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==
+
util-deprecate@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
@@ -2891,6 +3668,56 @@
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"
+vscode-css-languageservice@4.3.0:
+ version "4.3.0"
+ resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-4.3.0.tgz#40c797d664ab6188cace33cfbb19b037580a9318"
+ integrity sha512-BkQAMz4oVHjr0oOAz5PdeE72txlLQK7NIwzmclfr+b6fj6I8POwB+VoXvrZLTbWt9hWRgfvgiQRkh5JwrjPJ5A==
+ dependencies:
+ vscode-languageserver-textdocument "^1.0.1"
+ vscode-languageserver-types "3.16.0-next.2"
+ vscode-nls "^4.1.2"
+ vscode-uri "^2.1.2"
+
+vscode-html-languageservice@3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-3.1.0.tgz#265b53bda595e6947b16b0fb8c604e1e58685393"
+ integrity sha512-QAyRHI98bbEIBCqTzZVA0VblGU40na0txggongw5ZgTj9UVsVk5XbLT16O9OTcbqBGSqn0oWmFDNjK/XGIDcqg==
+ dependencies:
+ vscode-languageserver-textdocument "^1.0.1"
+ vscode-languageserver-types "3.16.0-next.2"
+ vscode-nls "^4.1.2"
+ vscode-uri "^2.1.2"
+
+vscode-languageserver-textdocument@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.1.tgz#178168e87efad6171b372add1dea34f53e5d330f"
+ integrity sha512-UIcJDjX7IFkck7cSkNNyzIz5FyvpQfY7sdzVy+wkKN/BLaD4DQ0ppXQrKePomCxTS7RrolK1I0pey0bG9eh8dA==
+
+vscode-languageserver-types@3.16.0-next.2:
+ version "3.16.0-next.2"
+ resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0-next.2.tgz#940bd15c992295a65eae8ab6b8568a1e8daa3083"
+ integrity sha512-QjXB7CKIfFzKbiCJC4OWC8xUncLsxo19FzGVp/ADFvvi87PlmBSCAtZI5xwGjF5qE0xkLf0jjKUn3DzmpDP52Q==
+
+vscode-nls@^4.1.2:
+ version "4.1.2"
+ resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
+ integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
+
+vscode-uri@^2.1.2:
+ version "2.1.2"
+ resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.1.2.tgz#c8d40de93eb57af31f3c715dd650e2ca2c096f1c"
+ integrity sha512-8TEXQxlldWAuIODdukIb+TR5s+9Ds40eSJrw+1iDDA9IFORPjMELarNQE3myz5XIkWWpdprmJjm1/SxMlWOC8A==
+
+web-component-analyzer@~1.1.1:
+ version "1.1.6"
+ resolved "https://registry.yarnpkg.com/web-component-analyzer/-/web-component-analyzer-1.1.6.tgz#d9bd904d904a711c19ba6046a45b60a7ee3ed2e9"
+ integrity sha512-1PyBkb/jijDEVE+Pnk3DTmVHD8takipdvAwvZv1V8jIidsSIJ5nhN87Gs+4dpEb1vw48yp8dnbZKkvMYJ+C0VQ==
+ dependencies:
+ fast-glob "^3.2.2"
+ ts-simple-type "~1.0.5"
+ typescript "^3.8.3"
+ yargs "^15.3.1"
+
which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"
@@ -2902,6 +3729,11 @@
is-string "^1.0.5"
is-symbol "^1.0.3"
+which-module@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
+ integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
+
which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
@@ -2921,6 +3753,15 @@
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
+wrap-ansi@^6.2.0:
+ version "6.2.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
+ integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
+ dependencies:
+ ansi-styles "^4.0.0"
+ string-width "^4.1.0"
+ strip-ansi "^6.0.0"
+
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
@@ -2950,12 +3791,42 @@
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==
+y18n@^4.0.0:
+ version "4.0.3"
+ resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf"
+ integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==
+
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
+yargs-parser@^18.1.2:
+ version "18.1.3"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
+ integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
+ dependencies:
+ camelcase "^5.0.0"
+ decamelize "^1.2.0"
+
yargs-parser@^20.2.3:
version "20.2.9"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
+
+yargs@^15.3.1:
+ version "15.4.1"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8"
+ integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==
+ dependencies:
+ cliui "^6.0.0"
+ decamelize "^1.2.0"
+ find-up "^4.1.0"
+ get-caller-file "^2.0.1"
+ require-directory "^2.1.1"
+ require-main-filename "^2.0.0"
+ set-blocking "^2.0.0"
+ string-width "^4.2.0"
+ which-module "^2.0.0"
+ y18n "^4.0.0"
+ yargs-parser "^18.1.2"