From bf1efeaa698cb08d6be8b3665f5752f8477a7ad9 Mon Sep 17 00:00:00 2001 From: Raathigeshan Kugarajan Date: Sat, 16 Jul 2016 13:34:35 +0530 Subject: [PATCH] Refactor status codes to separate file. Closes #27. --- src/client/components/http/ResponseCode.jsx | 154 +------------------- src/client/stores/httpStatusCodes.js | 150 +++++++++++++++++++ 2 files changed, 154 insertions(+), 150 deletions(-) create mode 100644 src/client/stores/httpStatusCodes.js diff --git a/src/client/components/http/ResponseCode.jsx b/src/client/components/http/ResponseCode.jsx index 0fd97ef..3b2c4c8 100644 --- a/src/client/components/http/ResponseCode.jsx +++ b/src/client/components/http/ResponseCode.jsx @@ -1,157 +1,11 @@ import React, {Component, PropTypes} from 'react'; +import responseCodes from '../../stores/httpStatusCodes'; class ResponseCode extends Component { constructor(props) { super(props); this.state = { - responseCodes: [{ - label: '100 Continue', - value: '100' - }, { - label: '101 Switching Protocol', - value: '101' - }, { - label: '200 OK', - value: '200' - }, { - label: '201 Created', - value: '201' - }, { - label: '202 Accepted', - value: '202' - }, { - label: '203 Non-Authoritative Information', - value: '203' - }, { - label: '204 No Content', - value: '204' - }, { - label: '205 Reset Content', - value: '205' - }, { - label: '206 Partial Content', - value: '206' - }, { - label: '300 Multiple Choice', - value: '300' - }, { - label: '301 Moved Permanently', - value: '301' - }, { - label: '302 Found', - value: '302' - }, { - label: '303 See Other', - value: '303' - }, { - label: '304 Not Modified', - value: '304' - }, { - label: '305 Use Proxy', - value: '305' - }, { - label: '307 Temporary Redirect', - value: '307' - }, { - label: '308 Permanent Redirect', - value: '308' - }, { - label: '400 Bad Request', - value: '400' - }, { - label: '401 Unauthorized', - value: '401' - }, { - label: '402 Payment Required', - value: '402' - }, { - label: '403 Forbidden', - value: '403' - }, { - label: '404 Not Found', - value: '404' - }, { - label: '405 Method Not Allowed', - value: '405' - }, { - label: '406 Not Acceptable', - value: '406' - }, { - label: '407 Proxy Authentication Required', - value: '407' - }, { - label: '408 Request Timeout', - value: '408' - }, { - label: '409 Conflict', - value: '409' - }, { - label: '410 Gone', - value: '410' - }, { - label: '411 Lenght Required', - value: '411' - }, { - label: '412 Precondition Failed', - value: '412' - }, { - label: '413 Payload Too Large', - value: '413' - }, { - label: '414 URI Too Long', - value: '414' - }, { - label: '415 Unsupported Media Type', - value: '415' - }, { - label: '416 Requested Range Not Satisfiable', - value: '416' - }, { - label: '417 Expectation Failed', - value: '417' - }, { - label: '418 I\'m a teapot', - value: '418' - }, { - label: '421 Misdirected Request', - value: '421' - }, { - label: '426 Upgrade Required', - value: '426' - }, { - label: '428 Precondition Required', - value: '428' - }, { - label: '429 Too Many Requests', - value: '429' - }, { - label: '431 Request Header Fields Too Large', - value: '431' - }, { - label: '500 Internal Server Error', - value: '500' - }, { - label: '501 Not Implemented', - value: '501' - }, { - label: '502 Service Unavailable', - value: '502' - }, { - label: '504 Gateway Timeout', - value: '504' - }, { - label: '505 HTTP Version Not Supported', - value: '505' - }, { - label: '506 Variant Also Negotiates', - value: '506' - }, { - label: '507 Variant Also Negotiates', - value: '507' - }, { - label: '511 Network Authentication Required', - value: '511' - }] + responseCodes: responseCodes } } componentDidMount() { @@ -165,7 +19,7 @@ class ResponseCode extends Component { getLabel = (value) => { for (let code of this.state.responseCodes) { if (code.value === value) { - return code.label; + return `${code.value} ${code.label}`; } } } @@ -177,7 +31,7 @@ class ResponseCode extends Component { render() { let items = this.state.responseCodes.map((responseCode) => { return (
{ this.handleOnChange(responseCode.value) } }> - {responseCode.label} + {`${responseCode.value} ${responseCode.label}`}
); }); diff --git a/src/client/stores/httpStatusCodes.js b/src/client/stores/httpStatusCodes.js new file mode 100644 index 0000000..177eb34 --- /dev/null +++ b/src/client/stores/httpStatusCodes.js @@ -0,0 +1,150 @@ +export default [ + { + label: 'Continue', + value: '100' + }, { + label: 'Switching Protocol', + value: '101' + }, { + label: 'OK', + value: '200' + }, { + label: 'Created', + value: '201' + }, { + label: 'Accepted', + value: '202' + }, { + label: 'Non-Authoritative Information', + value: '203' + }, { + label: 'No Content', + value: '204' + }, { + label: 'Reset Content', + value: '205' + }, { + label: 'Partial Content', + value: '206' + }, { + label: 'Multiple Choice', + value: '300' + }, { + label: 'Moved Permanently', + value: '301' + }, { + label: 'Found', + value: '302' + }, { + label: 'See Other', + value: '303' + }, { + label: 'Not Modified', + value: '304' + }, { + label: 'Use Proxy', + value: '305' + }, { + label: 'Temporary Redirect', + value: '307' + }, { + label: 'Permanent Redirect', + value: '308' + }, { + label: 'Bad Request', + value: '400' + }, { + label: 'Unauthorized', + value: '401' + }, { + label: 'Payment Required', + value: '402' + }, { + label: 'Forbidden', + value: '403' + }, { + label: 'Not Found', + value: '404' + }, { + label: 'Method Not Allowed', + value: '405' + }, { + label: 'Not Acceptable', + value: '406' + }, { + label: 'Proxy Authentication Required', + value: '407' + }, { + label: 'Request Timeout', + value: '408' + }, { + label: 'Conflict', + value: '409' + }, { + label: 'Gone', + value: '410' + }, { + label: 'Lenght Required', + value: '411' + }, { + label: 'Precondition Failed', + value: '412' + }, { + label: 'Payload Too Large', + value: '413' + }, { + label: 'URI Too Long', + value: '414' + }, { + label: 'Unsupported Media Type', + value: '415' + }, { + label: 'Requested Range Not Satisfiable', + value: '416' + }, { + label: 'Expectation Failed', + value: '417' + }, { + label: 'I\'m a teapot', + value: '418' + }, { + label: 'Misdirected Request', + value: '421' + }, { + label: 'Upgrade Required', + value: '426' + }, { + label: 'Precondition Required', + value: '428' + }, { + label: 'Too Many Requests', + value: '429' + }, { + label: 'Request Header Fields Too Large', + value: '431' + }, { + label: 'Internal Server Error', + value: '500' + }, { + label: 'Not Implemented', + value: '501' + }, { + label: 'Service Unavailable', + value: '502' + }, { + label: 'Gateway Timeout', + value: '504' + }, { + label: 'HTTP Version Not Supported', + value: '505' + }, { + label: 'Variant Also Negotiates', + value: '506' + }, { + label: 'Variant Also Negotiates', + value: '507' + }, { + label: 'Network Authentication Required', + value: '511' + } +]; \ No newline at end of file