diff --git a/.dockerignore b/.dockerignore index 34cd20923..a8a84cccb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,7 @@ .github docs default.etcd +browser *.gz *.tar.gz *.bzip2 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index e93bf3cda..e5ae404ed 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -46,3 +46,4 @@ jobs: make crosscompile make verify make verify-healing + cd browser && npm install && npm run test && cd .. diff --git a/CREDITS b/CREDITS index fe24fa77c..40f722b28 100644 --- a/CREDITS +++ b/CREDITS @@ -4205,6 +4205,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================================ +github.com/felixge/httpsnoop +https://github.com/felixge/httpsnoop +---------------------------------------------------------------- +Copyright (c) 2016 Felix Geisendörfer (felix@debuggable.com) + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +================================================================ + github.com/fortytw2/leaktest https://github.com/fortytw2/leaktest ---------------------------------------------------------------- @@ -5758,6 +5783,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================================ +github.com/gorilla/handlers +https://github.com/gorilla/handlers +---------------------------------------------------------------- +Copyright (c) 2013 The Gorilla Handlers Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +================================================================ + github.com/gorilla/mux https://github.com/gorilla/mux ---------------------------------------------------------------- @@ -10680,6 +10733,214 @@ https://github.com/minio/minio-go/v7 ================================================================ +github.com/minio/rpc +https://github.com/minio/rpc +---------------------------------------------------------------- + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + +================================================================ + github.com/minio/selfupdate https://github.com/minio/selfupdate ---------------------------------------------------------------- diff --git a/Dockerfile.cicd b/Dockerfile.cicd index 15b3ad416..f0f4264e7 100644 --- a/Dockerfile.cicd +++ b/Dockerfile.cicd @@ -1,3 +1,16 @@ +# Copyright 2020 MinIO, Inc. +# +# 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. FROM golang:1.16-alpine as builder LABEL maintainer="MinIO Inc " diff --git a/README.md b/README.md index d2c5a9334..e8d1a0eb0 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,14 @@ Run the following command to run the latest stable image of MinIO on a Docker co docker run -p 9000:9000 minio/minio server /data ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as -the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` -commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for -supported languages. +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +[Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, +see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. + > NOTE: To deploy MinIO on Docker with persistent storage, you must map local persistent directories from the host OS to the container using the `docker -v` option. For example, `-v /mnt/data:/data` maps the host OS drive at `/mnt/data` to `/data` on the Docker container. @@ -41,10 +45,15 @@ Run the following command to run the bleeding-edge image of MinIO on a Docker co docker run -p 9000:9000 minio/minio:edge server /data ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. + > NOTE: To deploy MinIO on Docker with persistent storage, you must map local persistent directories from the host OS to the container using the `docker -v` option. For example, `-v /mnt/data:/data` maps the host OS drive at `/mnt/data` to `/data` on the Docker container. @@ -73,7 +82,11 @@ brew uninstall minio brew install minio/stable/minio ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. @@ -87,7 +100,11 @@ chmod +x minio ./minio server /data ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. @@ -113,7 +130,11 @@ The following table lists supported architectures. Replace the `wget` URL with t | 64-bit PowerPC LE (ppc64le) | https://dl.min.io/server/minio/release/linux-ppc64le/minio | | IBM Z-Series (S390X) | https://dl.min.io/server/minio/release/linux-s390x/minio | -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. @@ -137,7 +158,11 @@ Use the following command to run a standalone MinIO server on the Windows host. minio.exe server D:\ ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. @@ -165,10 +190,15 @@ Use the following commands to compile and run a standalone MinIO server from sou GO111MODULE=on go get github.com/minio/minio ``` -The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See +The MinIO deployment starts using default root credentials `minioadmin:minioadmin`. You can test the deployment using the MinIO Browser, an embedded +web-based object browser built into MinIO Server. Point a web browser running on the host machine to http://127.0.0.1:9000 and log in with the +root credentials. You can use the Browser to create buckets, upload objects, and browse the contents of the MinIO server. + +You can also connect using any S3-compatible tool, such as the MinIO Client `mc` commandline tool. See [Test using MinIO Client `mc`](#test-using-minio-client-mc) for more information on using the `mc` commandline tool. For application developers, see https://docs.min.io/docs/ and click **MinIO SDKs** in the navigation to view MinIO SDKs for supported languages. + > NOTE: Standalone MinIO servers are best suited for early development and evaluation. Certain features such as versioning, object locking, and bucket replication require distributed deploying MinIO with Erasure Coding. For extended development and production, deploy MinIO with Erasure Coding enabled - specifically, with a *minimum* of 4 drives per MinIO server. See [MinIO Erasure Code Quickstart Guide](https://docs.min.io/docs/minio-erasure-code-quickstart-guide.html) @@ -240,6 +270,11 @@ The above statement is also valid for all gateway backends. # Test MinIO Connectivity +## Test using MinIO Browser +MinIO Server comes with an embedded web based object browser. Point your web browser to http://127.0.0.1:9000 to ensure your server has started successfully. + +![Screenshot](https://github.com/minio/minio/blob/master/docs/screenshots/minio-browser.png?raw=true) + ## Test using MinIO Client `mc` `mc` provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff etc. It supports filesystems and Amazon S3 compatible cloud storage services. Follow the MinIO Client [Quickstart Guide](https://docs.min.io/docs/minio-client-quickstart-guide) for further instructions. diff --git a/browser/.babelrc b/browser/.babelrc new file mode 100644 index 000000000..f9e96ea25 --- /dev/null +++ b/browser/.babelrc @@ -0,0 +1,9 @@ +{ + "presets": [ + "es2015", + "react" + ], + "plugins": [ + "transform-object-rest-spread" + ] +} \ No newline at end of file diff --git a/browser/.editorconfig b/browser/.editorconfig new file mode 100644 index 000000000..3674a17f4 --- /dev/null +++ b/browser/.editorconfig @@ -0,0 +1,16 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.json] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/browser/.esformatter b/browser/.esformatter new file mode 100644 index 000000000..1677d7c4b --- /dev/null +++ b/browser/.esformatter @@ -0,0 +1,23 @@ +{ + "plugins": [ + "esformatter-jsx" + ], + // Copied from https://github.com/royriojas/esformatter-jsx + "jsx": { + "formatJSX": true, //Duh! that's the default + "attrsOnSameLineAsTag": false, // move each attribute to its own line + "maxAttrsOnTag": 3, // if lower or equal than 3 attributes, they will be kept on a single line + "firstAttributeOnSameLine": true, // keep the first attribute in the same line as the tag + "formatJSXExpressions": true, // default true, if false jsxExpressions won't be recursively formatted + "JSXExpressionsSingleLine": true, // default true, if false the JSXExpressions might span several lines + "alignWithFirstAttribute": false, // do not align attributes with the first tag + "spaceInJSXExpressionContainers": " ", // default to one space. Make it empty if you don't like spaces between JSXExpressionContainers + "removeSpaceBeforeClosingJSX": false, // default false. if true => + "closingTagOnNewLine": false, // default false. if true attributes on multiple lines will close the tag on a new line + "JSXAttributeQuotes": "", // possible values "single" or "double". Leave it as empty string if you don't want to modify the attributes' quotes + "htmlOptions": { + // put here the options for js-beautify.html + } + } +} + diff --git a/browser/.gitignore b/browser/.gitignore new file mode 100644 index 000000000..38edf38cf --- /dev/null +++ b/browser/.gitignore @@ -0,0 +1,18 @@ +**/*.swp +cover.out +*~ +minio +!*/ +site/ +**/*.test +**/*.sublime-workspace +/.idea/ +/Minio.iml +**/access.log +build +vendor/**/*.js +vendor/**/*.json +.DS_Store +*.syso +coverage.txt +node_modules diff --git a/browser/.prettierrc b/browser/.prettierrc new file mode 100644 index 000000000..cce9d3c08 --- /dev/null +++ b/browser/.prettierrc @@ -0,0 +1,3 @@ +{ + "semi": false +} diff --git a/browser/LICENSE b/browser/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/browser/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/browser/README.md b/browser/README.md new file mode 100644 index 000000000..3023a86e4 --- /dev/null +++ b/browser/README.md @@ -0,0 +1,103 @@ +# MinIO File Browser + +``MinIO Browser`` provides minimal set of UI to manage buckets and objects on ``minio`` server. + + +## Installation + +### Install node +```sh +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash +exec -l $SHELL +nvm install stable +``` + +### Install node dependencies +```sh +npm install +``` + +## Generating Assets + +> NOTE: if you are not part of MinIO organization please do not run this yourself and submit in a PR. Static assets in PRs are allowed only for authorized users. + +```sh +npm run release +``` + +This generates `release` in the current directory. + + +## Run MinIO Browser with live reload + +### Run MinIO Browser with live reload + +```sh +npm run dev +``` + +Open [http://localhost:8080/minio/](http://localhost:8080/minio/) in your browser to play with the application. + +### Run MinIO Browser with live reload on custom port + +Edit `browser/webpack.config.js` + +```diff +diff --git a/browser/webpack.config.js b/browser/webpack.config.js +index 3ccdaba..9496c56 100644 +--- a/browser/webpack.config.js ++++ b/browser/webpack.config.js +@@ -58,6 +58,7 @@ var exports = { + historyApiFallback: { + index: '/minio/' + }, ++ port: 8888, + proxy: { + '/minio/webrpc': { + target: 'http://localhost:9000', +@@ -97,7 +98,7 @@ var exports = { + if (process.env.NODE_ENV === 'dev') { + exports.entry = [ + 'webpack/hot/dev-server', +- 'webpack-dev-server/client?http://localhost:8080', ++ 'webpack-dev-server/client?http://localhost:8888', + path.resolve(__dirname, 'app/index.js') + ] + } +``` + +```sh +npm run dev +``` + +Open [http://localhost:8888/minio/](http://localhost:8888/minio/) in your browser to play with the application. + +### Run MinIO Browser with live reload on any IP + +Edit `browser/webpack.config.js` + +```diff +diff --git a/browser/webpack.config.js b/browser/webpack.config.js +index 8bdbba53..139f6049 100644 +--- a/browser/webpack.config.js ++++ b/browser/webpack.config.js +@@ -71,6 +71,7 @@ var exports = { + historyApiFallback: { + index: '/minio/' + }, ++ host: '0.0.0.0', + proxy: { + '/minio/webrpc': { + target: 'http://localhost:9000', +``` + +```sh +npm run dev +``` + +Open [http://IP:8080/minio/](http://IP:8080/minio/) in your browser to play with the application. + + +## Run tests + + npm run test diff --git a/browser/app/css/loader.css b/browser/app/css/loader.css new file mode 100644 index 000000000..bba70295f --- /dev/null +++ b/browser/app/css/loader.css @@ -0,0 +1,98 @@ +.page-load { + position: fixed; + width: 100%; + height: 100%; + top: 0; + left: 0; + background: #002a37; + z-index: 100; + transition: opacity 200ms; + -webkit-transition: opacity 200ms; +} + +.pl-0{ + opacity: 0; +} + +.pl-1 { + display: none; +} + +.pl-inner { + position: absolute; + width: 100px; + height: 100px; + left: 50%; + margin-left: -50px; + top: 50%; + margin-top: -50px; + text-align: center; + -webkit-animation: fade-in 500ms; + animation: fade-in 500ms; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + animation-delay: 350ms; + -webkit-animation-delay: 350ms; + -webkit-backface-visibility: visible; + backface-visibility: visible; +} + +.pl-inner:before { + content: ''; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + display: block; + -webkit-animation: spin 1000ms infinite linear; + animation: spin 1000ms infinite linear; + border: 1px solid rgba(255, 255, 255, 0.2);; + border-left-color: #fff; + border-radius: 50%; +} + +.pl-inner > img { + width: 30px; + margin-top: 21px; +} + +@-webkit-keyframes fade-in { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +@keyframes fade-in { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} diff --git a/browser/app/fonts/lato/lato-normal.woff b/browser/app/fonts/lato/lato-normal.woff new file mode 100755 index 000000000..f2317755c Binary files /dev/null and b/browser/app/fonts/lato/lato-normal.woff differ diff --git a/browser/app/fonts/lato/lato-normal.woff2 b/browser/app/fonts/lato/lato-normal.woff2 new file mode 100755 index 000000000..2a119ebd5 Binary files /dev/null and b/browser/app/fonts/lato/lato-normal.woff2 differ diff --git a/browser/app/img/arrow.svg b/browser/app/img/arrow.svg new file mode 100644 index 000000000..fb5574ff8 --- /dev/null +++ b/browser/app/img/arrow.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/browser/app/img/browsers/chrome.png b/browser/app/img/browsers/chrome.png new file mode 100644 index 000000000..278ef4d15 Binary files /dev/null and b/browser/app/img/browsers/chrome.png differ diff --git a/browser/app/img/browsers/firefox.png b/browser/app/img/browsers/firefox.png new file mode 100644 index 000000000..2803f10a7 Binary files /dev/null and b/browser/app/img/browsers/firefox.png differ diff --git a/browser/app/img/browsers/safari.png b/browser/app/img/browsers/safari.png new file mode 100644 index 000000000..4ed52b904 Binary files /dev/null and b/browser/app/img/browsers/safari.png differ diff --git a/browser/app/img/favicon/favicon-16x16.png b/browser/app/img/favicon/favicon-16x16.png new file mode 100644 index 000000000..1ef69e777 Binary files /dev/null and b/browser/app/img/favicon/favicon-16x16.png differ diff --git a/browser/app/img/favicon/favicon-32x32.png b/browser/app/img/favicon/favicon-32x32.png new file mode 100644 index 000000000..24f73811b Binary files /dev/null and b/browser/app/img/favicon/favicon-32x32.png differ diff --git a/browser/app/img/favicon/favicon-96x96.png b/browser/app/img/favicon/favicon-96x96.png new file mode 100644 index 000000000..7410eca4c Binary files /dev/null and b/browser/app/img/favicon/favicon-96x96.png differ diff --git a/browser/app/img/login-img-bck.svg b/browser/app/img/login-img-bck.svg new file mode 100644 index 000000000..2dd8593c5 --- /dev/null +++ b/browser/app/img/login-img-bck.svg @@ -0,0 +1,50 @@ + + + + Untitled + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/browser/app/img/logo.svg b/browser/app/img/logo.svg new file mode 100644 index 000000000..504777e9d --- /dev/null +++ b/browser/app/img/logo.svg @@ -0,0 +1,12 @@ + + + + logo + Created with Sketch. + + + + + \ No newline at end of file diff --git a/browser/app/img/more-h-light.svg b/browser/app/img/more-h-light.svg new file mode 100644 index 000000000..0c2e2da60 --- /dev/null +++ b/browser/app/img/more-h-light.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/browser/app/img/more-h.svg b/browser/app/img/more-h.svg new file mode 100644 index 000000000..cf69dcf6b --- /dev/null +++ b/browser/app/img/more-h.svg @@ -0,0 +1 @@ + diff --git a/browser/app/img/select-caret.svg b/browser/app/img/select-caret.svg new file mode 100644 index 000000000..b2b26b86b --- /dev/null +++ b/browser/app/img/select-caret.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/browser/app/index.html b/browser/app/index.html new file mode 100644 index 000000000..61cc6e39d --- /dev/null +++ b/browser/app/index.html @@ -0,0 +1,59 @@ + + + + + + MinIO Browser + + + + + + + + + +
+
+ +
+
+
+ + + + + + + diff --git a/browser/app/index.js b/browser/app/index.js new file mode 100644 index 000000000..4856f0a11 --- /dev/null +++ b/browser/app/index.js @@ -0,0 +1,43 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 "babel-polyfill" +import "./less/main.less" +import "@fortawesome/fontawesome-free/css/all.css" +import "material-design-iconic-font/dist/css/material-design-iconic-font.min.css" + +import React from "react" +import ReactDOM from "react-dom" +import { Router, Route } from "react-router-dom" +import { Provider } from "react-redux" + +import history from "./js/history" +import configureStore from "./js/store/configure-store" +import hideLoader from "./js/loader" +import App from "./js/App" + +const store = configureStore() + +ReactDOM.render( + + + + + , + document.getElementById("root") +) + +hideLoader() diff --git a/browser/app/js/App.js b/browser/app/js/App.js new file mode 100644 index 000000000..825661b43 --- /dev/null +++ b/browser/app/js/App.js @@ -0,0 +1,34 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { Route, Switch, Redirect } from "react-router-dom" +import Browser from "./browser/Browser" +import Login from "./browser/Login" +import OpenIDLogin from "./browser/OpenIDLogin" +import web from "./web" + +export const App = () => { + return ( + + + + + + ) +} + +export default App diff --git a/browser/app/js/__tests__/App.test.js b/browser/app/js/__tests__/App.test.js new file mode 100644 index 000000000..4084a089c --- /dev/null +++ b/browser/app/js/__tests__/App.test.js @@ -0,0 +1,65 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { shallow, mount } from "enzyme" +import { MemoryRouter } from "react-router-dom" +import App from "../App" + +jest.mock("../browser/Login", () => () =>
Login
) +jest.mock("../browser/Browser", () => () =>
Browser
) + +describe("App", () => { + it("should render without crashing", () => { + shallow() + }) + + it("should render Login component for '/login' route", () => { + const wrapper = mount( + + + + ) + expect(wrapper.text()).toBe("Login") + }) + + it("should render Browser component for '/' route", () => { + const wrapper = mount( + + + + ) + expect(wrapper.text()).toBe("Browser") + }) + + it("should render Browser component for '/bucket' route", () => { + const wrapper = mount( + + + + ) + expect(wrapper.text()).toBe("Browser") + }) + + it("should render Browser component for '/bucket/a/b/c' route", () => { + const wrapper = mount( + + + + ) + expect(wrapper.text()).toBe("Browser") + }) +}) diff --git a/browser/app/js/__tests__/jsonrpc-test.js b/browser/app/js/__tests__/jsonrpc-test.js new file mode 100644 index 000000000..cc2c34e9e --- /dev/null +++ b/browser/app/js/__tests__/jsonrpc-test.js @@ -0,0 +1,41 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 JSONrpc from "../jsonrpc" + +describe("jsonrpc", () => { + it("should fail with invalid endpoint", done => { + try { + let jsonRPC = new JSONrpc({ + endpoint: "htt://localhost:9000", + namespace: "Test" + }) + } catch (e) { + done() + } + }) + it("should succeed with valid endpoint", () => { + let jsonRPC = new JSONrpc({ + endpoint: "http://localhost:9000/webrpc", + namespace: "Test" + }) + expect(jsonRPC.version).toEqual("2.0") + expect(jsonRPC.host).toEqual("localhost") + expect(jsonRPC.port).toEqual("9000") + expect(jsonRPC.path).toEqual("/webrpc") + expect(jsonRPC.scheme).toEqual("http") + }) +}) diff --git a/browser/app/js/alert/Alert.js b/browser/app/js/alert/Alert.js new file mode 100644 index 000000000..7603a19d8 --- /dev/null +++ b/browser/app/js/alert/Alert.js @@ -0,0 +1,30 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import AlertComponent from "react-bootstrap/lib/Alert" + +const Alert = ({ show, type, message, onDismiss }) => ( + +
{message}
+
+) + +export default Alert diff --git a/browser/app/js/alert/AlertContainer.js b/browser/app/js/alert/AlertContainer.js new file mode 100644 index 000000000..fd1e4ebe9 --- /dev/null +++ b/browser/app/js/alert/AlertContainer.js @@ -0,0 +1,41 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { connect } from "react-redux" +import Alert from "./Alert" +import * as alertActions from "./actions" + +export const AlertContainer = ({ alert, clearAlert }) => { + if (!alert.message) { + return "" + } + return +} + +const mapStateToProps = state => { + return { + alert: state.alert + } +} + +const mapDispatchToProps = dispatch => { + return { + clearAlert: () => dispatch(alertActions.clear()) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(AlertContainer) diff --git a/browser/app/js/alert/__tests___/Alert.test.js b/browser/app/js/alert/__tests___/Alert.test.js new file mode 100644 index 000000000..62eaa27b8 --- /dev/null +++ b/browser/app/js/alert/__tests___/Alert.test.js @@ -0,0 +1,34 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { shallow, mount } from "enzyme" +import Alert from "../Alert" + +describe("Alert", () => { + it("should render without crashing", () => { + shallow() + }) + + it("should call onDismiss when close button is clicked", () => { + const onDismiss = jest.fn() + const wrapper = mount( + + ) + wrapper.find("button").simulate("click", { preventDefault: jest.fn() }) + expect(onDismiss).toHaveBeenCalled() + }) +}) diff --git a/browser/app/js/alert/__tests___/AlertContainer.test.js b/browser/app/js/alert/__tests___/AlertContainer.test.js new file mode 100644 index 000000000..ced273540 --- /dev/null +++ b/browser/app/js/alert/__tests___/AlertContainer.test.js @@ -0,0 +1,34 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { shallow, mount } from "enzyme" +import { AlertContainer } from "../AlertContainer" + +describe("Alert", () => { + it("should render without crashing", () => { + shallow( + + ) + }) + + it("should render nothing if message is empty", () => { + const wrapper = shallow( + + ) + expect(wrapper.find("Alert").length).toBe(0) + }) +}) diff --git a/browser/app/js/alert/__tests___/actions.test.js b/browser/app/js/alert/__tests___/actions.test.js new file mode 100644 index 000000000..b7b561f69 --- /dev/null +++ b/browser/app/js/alert/__tests___/actions.test.js @@ -0,0 +1,69 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 configureStore from "redux-mock-store" +import thunk from "redux-thunk" +import * as actionsAlert from "../actions" + +const middlewares = [thunk] +const mockStore = configureStore(middlewares) + +jest.useFakeTimers() + +describe("Alert actions", () => { + it("creates alert/SET action", () => { + const store = mockStore() + const expectedActions = [ + { + type: "alert/SET", + alert: { id: 0, message: "Test alert", type: "danger" } + } + ] + store.dispatch(actionsAlert.set({ message: "Test alert", type: "danger" })) + const actions = store.getActions() + expect(actions).toEqual(expectedActions) + }) + + it("creates alert/CLEAR action for non danger alerts", () => { + const store = mockStore() + const expectedActions = [ + { + type: "alert/SET", + alert: { id: 1, message: "Test alert" } + }, + { + type: "alert/CLEAR", + alert: { id: 1 } + } + ] + store.dispatch(actionsAlert.set({ message: "Test alert" })) + jest.runAllTimers() + const actions = store.getActions() + expect(actions).toEqual(expectedActions) + }) + + it("creates alert/CLEAR action directly", () => { + const store = mockStore() + const expectedActions = [ + { + type: "alert/CLEAR" + } + ] + store.dispatch(actionsAlert.clear()) + const actions = store.getActions() + expect(actions).toEqual(expectedActions) + }) +}) diff --git a/browser/app/js/alert/__tests___/reducer.test.js b/browser/app/js/alert/__tests___/reducer.test.js new file mode 100644 index 000000000..19c7ac7bb --- /dev/null +++ b/browser/app/js/alert/__tests___/reducer.test.js @@ -0,0 +1,87 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 reducer from "../reducer" +import * as actionsAlert from "../actions" + +describe("alert reducer", () => { + it("should return the initial state", () => { + expect(reducer(undefined, {})).toEqual({ + show: false, + type: "danger" + }) + }) + + it("should handle SET_ALERT", () => { + expect( + reducer(undefined, { + type: actionsAlert.SET, + alert: { id: 1, type: "danger", message: "Test message" } + }) + ).toEqual({ + show: true, + id: 1, + type: "danger", + message: "Test message" + }) + }) + + it("should clear alert if id not passed", () => { + expect( + reducer( + { show: true, type: "danger", message: "Test message" }, + { + type: actionsAlert.CLEAR + } + ) + ).toEqual({ + show: false, + type: "danger" + }) + }) + + it("should clear alert if id is matching", () => { + expect( + reducer( + { show: true, id: 1, type: "danger", message: "Test message" }, + { + type: actionsAlert.CLEAR, + alert: { id: 1 } + } + ) + ).toEqual({ + show: false, + type: "danger" + }) + }) + + it("should not clear alert if id is not matching", () => { + expect( + reducer( + { show: true, id: 1, type: "danger", message: "Test message" }, + { + type: actionsAlert.CLEAR, + alert: { id: 2 } + } + ) + ).toEqual({ + show: true, + id: 1, + type: "danger", + message: "Test message" + }) + }) +}) diff --git a/browser/app/js/alert/actions.js b/browser/app/js/alert/actions.js new file mode 100644 index 000000000..d602039ee --- /dev/null +++ b/browser/app/js/alert/actions.js @@ -0,0 +1,46 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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. + */ + +export const SET = "alert/SET" +export const CLEAR = "alert/CLEAR" + +export let alertId = 0 + +export const set = alert => { + const id = alertId++ + return (dispatch, getState) => { + if (alert.type !== "danger" || alert.autoClear) { + setTimeout(() => { + dispatch({ + type: CLEAR, + alert: { + id + } + }) + }, 5000) + } + dispatch({ + type: SET, + alert: Object.assign({}, alert, { + id + }) + }) + } +} + +export const clear = () => { + return { type: CLEAR } +} diff --git a/browser/app/js/alert/reducer.js b/browser/app/js/alert/reducer.js new file mode 100644 index 000000000..4fae949a5 --- /dev/null +++ b/browser/app/js/alert/reducer.js @@ -0,0 +1,41 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 * as actionsAlert from "./actions" + +const initialState = { + show: false, + type: "danger" +} +export default (state = initialState, action) => { + switch (action.type) { + case actionsAlert.SET: + return { + show: true, + id: action.alert.id, + type: action.alert.type, + message: action.alert.message + } + case actionsAlert.CLEAR: + if (action.alert && action.alert.id != state.id) { + return state + } else { + return initialState + } + default: + return state + } +} diff --git a/browser/app/js/browser/AboutModal.js b/browser/app/js/browser/AboutModal.js new file mode 100644 index 000000000..63591cff9 --- /dev/null +++ b/browser/app/js/browser/AboutModal.js @@ -0,0 +1,60 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { Modal } from "react-bootstrap" +import logo from "../../img/logo.svg" + +export const AboutModal = ({ serverInfo, hideAbout }) => { + const { version, platform, runtime } = serverInfo + return ( + + +
+
+ + + +
+
+
    +
  • +
    Version
    + {version} +
  • +
  • +
    Platform
    + {platform} +
  • +
  • +
    Runtime
    + {runtime} +
  • +
+
+
+
+ ) +} + +export default AboutModal diff --git a/browser/app/js/browser/Browser.js b/browser/app/js/browser/Browser.js new file mode 100644 index 000000000..a1930f887 --- /dev/null +++ b/browser/app/js/browser/Browser.js @@ -0,0 +1,40 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import classNames from "classnames" +import { connect } from "react-redux" +import SideBar from "./SideBar" +import MainContent from "./MainContent" +import AlertContainer from "../alert/AlertContainer" + +class Browser extends React.Component { + render() { + return ( +
+ + + +
+ ) + } +} + +export default connect(state => state)(Browser) diff --git a/browser/app/js/browser/BrowserDropdown.js b/browser/app/js/browser/BrowserDropdown.js new file mode 100644 index 000000000..ed1bdd917 --- /dev/null +++ b/browser/app/js/browser/BrowserDropdown.js @@ -0,0 +1,135 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { connect } from "react-redux" +import { Dropdown } from "react-bootstrap" +import * as browserActions from "./actions" +import web from "../web" +import history from "../history" +import AboutModal from "./AboutModal" +import ChangePasswordModal from "./ChangePasswordModal" + +export class BrowserDropdown extends React.Component { + constructor(props) { + super(props) + this.state = { + showAboutModal: false, + showChangePasswordModal: false + } + } + showAbout(e) { + e.preventDefault() + this.setState({ + showAboutModal: true + }) + } + hideAbout() { + this.setState({ + showAboutModal: false + }) + } + showChangePassword(e) { + e.preventDefault() + this.setState({ + showChangePasswordModal: true + }) + } + hideChangePassword() { + this.setState({ + showChangePasswordModal: false + }) + } + componentDidMount() { + const { fetchServerInfo } = this.props + fetchServerInfo() + } + logout(e) { + e.preventDefault() + web.Logout() + history.replace("/login") + } + render() { + const { serverInfo } = this.props + return ( +
  • + + + + + +
  • + + Change Password + + {this.state.showChangePasswordModal && ( + + )} +
  • +
  • + + Documentation + +
  • +
  • + + GitHub + +
  • +
  • + + Get Support + +
  • +
  • + + About + + {this.state.showAboutModal && ( + + )} +
  • +
  • + + Logout + +
  • + + + + ) + } +} + +const mapStateToProps = state => { + return { + serverInfo: state.browser.serverInfo + } +} + +const mapDispatchToProps = dispatch => { + return { + fetchServerInfo: () => dispatch(browserActions.fetchServerInfo()) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(BrowserDropdown) diff --git a/browser/app/js/browser/ChangePasswordModal.js b/browser/app/js/browser/ChangePasswordModal.js new file mode 100644 index 000000000..b21464c13 --- /dev/null +++ b/browser/app/js/browser/ChangePasswordModal.js @@ -0,0 +1,260 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { connect } from "react-redux" +import web from "../web" +import * as alertActions from "../alert/actions" +import { getRandomAccessKey, getRandomSecretKey } from "../utils" +import jwtDecode from "jwt-decode" +import classNames from "classnames" + +import { Modal, ModalBody, ModalHeader } from "react-bootstrap" +import InputGroup from "./InputGroup" +import { ACCESS_KEY_MIN_LENGTH, SECRET_KEY_MIN_LENGTH } from "../constants" + +export class ChangePasswordModal extends React.Component { + constructor(props) { + super(props) + this.state = { + currentAccessKey: "", + currentSecretKey: "", + currentSecretKeyVisible: false, + newAccessKey: "", + newSecretKey: "", + newSecretKeyVisible: false + } + } + // When its shown, it loads the access key from JWT token + componentWillMount() { + const token = jwtDecode(web.GetToken()) + this.setState({ + currentAccessKey: token.sub, + newAccessKey: token.sub + }) + } + + // Save the auth params and set them. + setAuth(e) { + const { showAlert } = this.props + + if (this.canUpdateCredentials()) { + const currentAccessKey = this.state.currentAccessKey + const currentSecretKey = this.state.currentSecretKey + const newAccessKey = this.state.newAccessKey + const newSecretKey = this.state.newSecretKey + web + .SetAuth({ + currentAccessKey, + currentSecretKey, + newAccessKey, + newSecretKey + }) + .then(data => { + showAlert({ + type: "success", + message: "Credentials updated successfully." + }) + }) + .catch(err => { + showAlert({ + type: "danger", + message: err.message + }) + }) + } + } + + generateAuth(e) { + const { serverInfo } = this.props + this.setState({ + newSecretKey: getRandomSecretKey(), + newSecretKeyVisible: true + }) + } + + canChangePassword() { + const { serverInfo } = this.props + // Password change is not allowed for temporary users(STS) + if(serverInfo.userInfo.isTempUser) { + return false + } + + // Password change is only allowed for regular users + if (!serverInfo.userInfo.isIAMUser) { + return false + } + + return true + } + + canUpdateCredentials() { + return ( + this.state.currentAccessKey.length > 0 && + this.state.currentSecretKey.length > 0 && + this.state.newAccessKey.length >= ACCESS_KEY_MIN_LENGTH && + this.state.newSecretKey.length >= SECRET_KEY_MIN_LENGTH + ) + } + + render() { + const { hideChangePassword, serverInfo } = this.props + const allowChangePassword = this.canChangePassword() + + if (!allowChangePassword) { + return ( + + Change Password + + Credentials of this user cannot be updated through MinIO Browser. + +
    + +
    +
    + ) + } + + return ( + + Change Password + +
    + + + { + this.setState({ + currentSecretKeyVisible: !this.state.currentSecretKeyVisible + }) + }} + className={ + "toggle-password fas fa-eye " + + (this.state.currentSecretKeyVisible ? "toggled" : "") + } + /> + { + this.setState({ currentSecretKey: e.target.value }) + }} + id="currentSecretKey" + label="Current Secret Key" + name="currentSecretKey" + type={this.state.currentSecretKeyVisible ? "text" : "password"} + spellCheck="false" + required="required" + autoComplete="false" + align="ig-left" + /> +
    + +
    + { + this.setState({ + newSecretKeyVisible: !this.state.newSecretKeyVisible + }) + }} + className={ + "toggle-password fas fa-eye " + + (this.state.newSecretKeyVisible ? "toggled" : "") + } + /> + { + this.setState({ newSecretKey: e.target.value }) + }} + id="newSecretKey" + label="New Secret Key" + name="newSecretKey" + type={this.state.newSecretKeyVisible ? "text" : "password"} + spellCheck="false" + required="required" + autoComplete="false" + align="ig-left" + onChange={e => { + this.setState({ newSecretKey: e.target.value }) + }} + /> +
    +
    +
    + + + +
    +
    + ) + } +} + +const mapStateToProps = state => { + return { + serverInfo: state.browser.serverInfo + } +} + +const mapDispatchToProps = dispatch => { + return { + showAlert: alert => dispatch(alertActions.set(alert)) + } +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(ChangePasswordModal) diff --git a/browser/app/js/browser/ConfirmModal.js b/browser/app/js/browser/ConfirmModal.js new file mode 100644 index 000000000..3d7e6402f --- /dev/null +++ b/browser/app/js/browser/ConfirmModal.js @@ -0,0 +1,57 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { Modal, ModalBody } from "react-bootstrap" + +let ConfirmModal = ({ + baseClass, + icon, + text, + sub, + okText, + cancelText, + okHandler, + cancelHandler, + show +}) => { + return ( + + +
    + +
    +
    {text}
    +
    {sub}
    +
    +
    + + +
    +
    + ) +} + +export default ConfirmModal diff --git a/browser/app/js/browser/Header.js b/browser/app/js/browser/Header.js new file mode 100644 index 000000000..f9266ff81 --- /dev/null +++ b/browser/app/js/browser/Header.js @@ -0,0 +1,45 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import ObjectsSearch from "../objects/ObjectsSearch" +import Path from "../objects/Path" +import StorageInfo from "./StorageInfo" +import BrowserDropdown from "./BrowserDropdown" +import web from "../web" +import { minioBrowserPrefix } from "../constants" + +export const Header = () => { + const loggedIn = web.LoggedIn() + return ( +
    + + {loggedIn && } + {loggedIn && } + +
    + ) +} + +export default Header diff --git a/browser/app/js/browser/Host.js b/browser/app/js/browser/Host.js new file mode 100644 index 000000000..010fdd4a5 --- /dev/null +++ b/browser/app/js/browser/Host.js @@ -0,0 +1,26 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" + +export const Host = () => ( + +) + +export default Host diff --git a/browser/app/js/browser/InputGroup.js b/browser/app/js/browser/InputGroup.js new file mode 100644 index 000000000..3d82389d7 --- /dev/null +++ b/browser/app/js/browser/InputGroup.js @@ -0,0 +1,70 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" + +let InputGroup = ({ + label, + id, + name, + value, + onChange, + type, + spellCheck, + required, + readonly, + autoComplete, + align, + className +}) => { + var input = ( + + ) + if (readonly) + input = ( + + ) + return ( +
    + {input} + + +
    + ) +} + +export default InputGroup diff --git a/browser/app/js/browser/Login.js b/browser/app/js/browser/Login.js new file mode 100644 index 000000000..39b84e446 --- /dev/null +++ b/browser/app/js/browser/Login.js @@ -0,0 +1,187 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { connect } from "react-redux" +import logo from "../../img/logo.svg" +import Alert from "../alert/Alert" +import * as actionsAlert from "../alert/actions" +import InputGroup from "./InputGroup" +import web from "../web" +import { Redirect, Link } from "react-router-dom" +import OpenIDLoginButton from './OpenIDLoginButton' + +export class Login extends React.Component { + constructor(props) { + super(props) + this.state = { + accessKey: "", + secretKey: "", + discoveryDoc: {}, + clientId: "" + } + } + + // Handle field changes + accessKeyChange(e) { + this.setState({ + accessKey: e.target.value + }) + } + + secretKeyChange(e) { + this.setState({ + secretKey: e.target.value + }) + } + + handleSubmit(event) { + event.preventDefault() + const { showAlert, clearAlert, history } = this.props + let message = "" + if (this.state.accessKey === "") { + message = "Access Key cannot be empty" + } + if (this.state.secretKey === "") { + message = "Secret Key cannot be empty" + } + if (message) { + showAlert("danger", message) + return + } + web + .Login({ + username: this.state.accessKey, + password: this.state.secretKey + }) + .then(res => { + // Clear alerts from previous login attempts + clearAlert() + + history.push("/") + }) + .catch(e => { + showAlert("danger", e.message) + }) + } + + componentWillMount() { + const { clearAlert } = this.props + // Clear out any stale message in the alert of previous page + clearAlert() + document.body.classList.add("is-guest") + } + + componentDidMount() { + web.GetDiscoveryDoc().then(({ DiscoveryDoc, clientId }) => { + this.setState({ + clientId, + discoveryDoc: DiscoveryDoc + }) + }) + } + + componentWillUnmount() { + document.body.classList.remove("is-guest") + } + + render() { + const { clearAlert, alert } = this.props + if (web.LoggedIn()) { + return + } + let alertBox = + // Make sure you don't show a fading out alert box on the initial web-page load. + if (!alert.message) alertBox = "" + + const showOpenID = Boolean(this.state.discoveryDoc && this.state.discoveryDoc.authorization_endpoint) + return ( +
    + {alertBox} +
    +
    + + + + + {showOpenID && ( +
    +
    or
    + { + this.state.clientId ? ( + + Log in with OpenID + + ) : ( + + Log in with OpenID + + ) + } +
    + )} +
    +
    + + + +
    {window.location.host}
    +
    +
    + ) + } +} + +const mapDispatchToProps = dispatch => { + return { + showAlert: (type, message) => + dispatch(actionsAlert.set({ type: type, message: message })), + clearAlert: () => dispatch(actionsAlert.clear()) + } +} + +export default connect( + state => state, + mapDispatchToProps +)(Login) diff --git a/browser/app/js/browser/MainActions.js b/browser/app/js/browser/MainActions.js new file mode 100644 index 000000000..44145c3a6 --- /dev/null +++ b/browser/app/js/browser/MainActions.js @@ -0,0 +1,106 @@ +/* + * MinIO Object Storage (c) 2021 MinIO, Inc. + * + * 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 React from "react" +import { connect } from "react-redux" +import { Dropdown, OverlayTrigger, Tooltip } from "react-bootstrap" +import web from "../web" +import * as actionsBuckets from "../buckets/actions" +import * as uploadsActions from "../uploads/actions" +import { getPrefixWritable } from "../objects/selectors" + +export const MainActions = ({ + prefixWritable, + uploadFile, + showMakeBucketModal +}) => { + const uploadTooltip = Upload file + const makeBucketTooltip = ( + Create bucket + ) + const onFileUpload = e => { + e.preventDefault() + let files = e.target.files + let filesToUploadCount = files.length + for (let i = 0; i < filesToUploadCount; i++) { + uploadFile(files.item(i)) + } + e.target.value = null + } + + const loggedIn = web.LoggedIn() + + if (loggedIn || prefixWritable) { + return ( + + + + + + + + + + + + + + {loggedIn && ( + + { + e.preventDefault() + showMakeBucketModal() + }} + > + + + + )} + + + ) + } else { + return