diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-19 21:09:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-19 21:09:34 +0300 |
commit | d4e22f4ade1ce4dfd54f4d1740f074b2be441705 (patch) | |
tree | 5f1f1bbe3c7673905804170bfd1becf665d4b0b5 /app/assets/javascripts/lib | |
parent | c18599314d98c0aa4dfe7d56423469f0b641d066 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/lib')
-rw-r--r-- | app/assets/javascripts/lib/utils/http_status.js | 56 | ||||
-rw-r--r-- | app/assets/javascripts/lib/utils/poll.js | 4 |
2 files changed, 29 insertions, 31 deletions
diff --git a/app/assets/javascripts/lib/utils/http_status.js b/app/assets/javascripts/lib/utils/http_status.js index c5190592bb6..ec0d8d433a5 100644 --- a/app/assets/javascripts/lib/utils/http_status.js +++ b/app/assets/javascripts/lib/utils/http_status.js @@ -1,45 +1,43 @@ -/** - * exports HTTP status codes - */ +export const HTTP_STATUS_ABORTED = 0; +export const HTTP_STATUS_CREATED = 201; +export const HTTP_STATUS_ACCEPTED = 202; +export const HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION = 203; +export const HTTP_STATUS_NO_CONTENT = 204; +export const HTTP_STATUS_RESET_CONTENT = 205; +export const HTTP_STATUS_PARTIAL_CONTENT = 206; +export const HTTP_STATUS_MULTI_STATUS = 207; +export const HTTP_STATUS_ALREADY_REPORTED = 208; +export const HTTP_STATUS_IM_USED = 226; +export const HTTP_STATUS_METHOD_NOT_ALLOWED = 405; +export const HTTP_STATUS_CONFLICT = 409; +export const HTTP_STATUS_GONE = 410; +export const HTTP_STATUS_PAYLOAD_TOO_LARGE = 413; +export const HTTP_STATUS_UNPROCESSABLE_ENTITY = 422; +export const HTTP_STATUS_TOO_MANY_REQUESTS = 429; +// TODO move the rest of the status codes to primitive constants +// https://docs.gitlab.com/ee/development/fe_guide/style/javascript.html#export-constants-as-primitives const httpStatusCodes = { - ABORTED: 0, OK: 200, - CREATED: 201, - ACCEPTED: 202, - NON_AUTHORITATIVE_INFORMATION: 203, - NO_CONTENT: 204, - RESET_CONTENT: 205, - PARTIAL_CONTENT: 206, - MULTI_STATUS: 207, - ALREADY_REPORTED: 208, - IM_USED: 226, - MULTIPLE_CHOICES: 300, BAD_REQUEST: 400, UNAUTHORIZED: 401, FORBIDDEN: 403, NOT_FOUND: 404, - METHOD_NOT_ALLOWED: 405, - CONFLICT: 409, - GONE: 410, - PAYLOAD_TOO_LARGE: 413, - UNPROCESSABLE_ENTITY: 422, - TOO_MANY_REQUESTS: 429, INTERNAL_SERVER_ERROR: 500, SERVICE_UNAVAILABLE: 503, }; export const successCodes = [ httpStatusCodes.OK, - httpStatusCodes.CREATED, - httpStatusCodes.ACCEPTED, - httpStatusCodes.NON_AUTHORITATIVE_INFORMATION, - httpStatusCodes.NO_CONTENT, - httpStatusCodes.RESET_CONTENT, - httpStatusCodes.PARTIAL_CONTENT, - httpStatusCodes.MULTI_STATUS, - httpStatusCodes.ALREADY_REPORTED, - httpStatusCodes.IM_USED, + HTTP_STATUS_CREATED, + HTTP_STATUS_ACCEPTED, + HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION, + HTTP_STATUS_NO_CONTENT, + HTTP_STATUS_RESET_CONTENT, + HTTP_STATUS_PARTIAL_CONTENT, + HTTP_STATUS_MULTI_STATUS, + HTTP_STATUS_ALREADY_REPORTED, + HTTP_STATUS_IM_USED, ]; export default httpStatusCodes; diff --git a/app/assets/javascripts/lib/utils/poll.js b/app/assets/javascripts/lib/utils/poll.js index 71782c9a4ce..73add1e37ee 100644 --- a/app/assets/javascripts/lib/utils/poll.js +++ b/app/assets/javascripts/lib/utils/poll.js @@ -1,5 +1,5 @@ import { normalizeHeaders } from './common_utils'; -import httpStatusCodes, { successCodes } from './http_status'; +import { HTTP_STATUS_ABORTED, successCodes } from './http_status'; /** * Polling utility for handling realtime updates. @@ -108,7 +108,7 @@ export default class Poll { }) .catch((error) => { notificationCallback(false); - if (error.status === httpStatusCodes.ABORTED) { + if (error.status === HTTP_STATUS_ABORTED) { return; } errorCallback(error); |