zRains commented on code in PR #3971: URL: https://github.com/apache/ambari/pull/3971#discussion_r2020146114
########## ambari-admin/src/main/resources/ui/ambari-admin/src/screens/StackVersions/Register.tsx: ########## @@ -0,0 +1,1287 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +/* eslint-disable no-useless-escape */ +/* eslint-disable no-unsafe-optional-chaining */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/no-explicit-any */ Review Comment: Please try to avoid using these identifiers; if certain factors necessitate their use, please specify the reasons. ########## ambari-admin/src/main/resources/ui/ambari-admin/src/components/AddVersionModal/index.tsx: ########## @@ -0,0 +1,134 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/ban-types */ +import { useState } from 'react' +import { Button, Form, FormControl, Modal } from 'react-bootstrap' +import toast from 'react-hot-toast' +import { get } from 'lodash' +import DefaultButton from '../DefaultButton' +import VersionsApi from '../../api/versions' +import { ReadOptions } from '../../constants' + +type ModalProps = { + isOpen: boolean + onClose: () => void + onReadVersion: Function Review Comment: Type is vague, please specify. ########## ambari-admin/src/main/resources/ui/ambari-admin/src/components/AddVersionModal/index.tsx: ########## @@ -0,0 +1,134 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +/* eslint-disable @typescript-eslint/ban-ts-comment */ +/* eslint-disable @typescript-eslint/ban-types */ +import { useState } from 'react' +import { Button, Form, FormControl, Modal } from 'react-bootstrap' +import toast from 'react-hot-toast' +import { get } from 'lodash' +import DefaultButton from '../DefaultButton' +import VersionsApi from '../../api/versions' +import { ReadOptions } from '../../constants' + +type ModalProps = { + isOpen: boolean + onClose: () => void + onReadVersion: Function +} + +const AddVersionModal = ({ isOpen, onClose, onReadVersion }: ModalProps) => { + const [uploadOption, setUploadOption] = useState(ReadOptions.FILE) + const [file, setFile] = useState() + const [fileUrl, setFileUrl] = useState('') + const readVersionInfo = async () => { + try { + if (uploadOption === ReadOptions.FILE && file) { + const reader = new FileReader() + reader.onload = async function (event) { + const fileContents = get(event, 'target.result', undefined) + const versionResources = await VersionsApi.readVersionInfo( + fileContents, + { + 'Content-Type': 'text/xml', + }, + ) + onReadVersion(versionResources) + } + reader.readAsText(file) + } else if (uploadOption === ReadOptions.URL && fileUrl) { + // Fetch the content from the URL + const versionResources = await VersionsApi.readVersionInfo({ + VersionDefinition: { + version_url: fileUrl, + }, + }) + onReadVersion(versionResources) + } + } catch (err) { + toast.error('Could not read version defintion') + } + } + const handleClose=()=>{ + setFile(undefined) + setFileUrl('') + onClose() + } + return ( + <Modal show={isOpen} onHide={onClose} data-testid="add-version-modal"> + <Modal.Header> + <Modal.Title>Add Version</Modal.Title> + </Modal.Header> + <Modal.Body> + <Form.Check + checked={uploadOption === ReadOptions.FILE} + type="radio" + id={ReadOptions.FILE} + onChange={() => { + setUploadOption(ReadOptions.FILE) + }} + label="Upload Version Definition File" + className="px-0" + /> + <FormControl + type="file" + className="py-1" + onChange={() => { + //@ts-ignore Review Comment: Please try to avoid using this identifier. ########## ambari-admin/src/main/resources/ui/ambari-admin/src/components/LostNetworkModal/index.tsx: ########## @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 { Button, Modal } from "react-bootstrap"; + +type PropTypes = { + onClose: () => void; + isOpen: boolean; +}; + +const LostNetworkModal = ({ onClose, isOpen }: PropTypes) => { + const options = [ + "Configure your hosts for access to the Internet.", + " If you are using an Internet Proxy, refer to the Ambari Documentation on how to configure Ambari to use the Internet Proxy.", + "Use the Local Repository option.", + ]; + return ( + <Modal show={isOpen} onHide={onClose} size="lg"> + <Modal.Header closeButton> + <Modal.Title>Public Repository Option Disabled</Modal.Title> + </Modal.Header> + <Modal.Body style={{ fontSize: 12 }}> Review Comment: Please try to avoid using inline styles; you can use Tailwind instead. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
