Skip to content

Commit a8330c2

Browse files
committed
AMBARI-26175 Register version capabilities in Ambari Admin
Replace stack
1 parent 982c545 commit a8330c2

File tree

8 files changed

+2577
-3
lines changed

8 files changed

+2577
-3
lines changed

ambari-admin/src/main/resources/ui/ambari-admin/src/__mocks__/mockOperatingSystems.ts

Lines changed: 620 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
/* eslint-disable @typescript-eslint/ban-ts-comment */
19+
/* eslint-disable @typescript-eslint/ban-types */
20+
import { useState } from 'react'
21+
import { Button, Form, FormControl, Modal } from 'react-bootstrap'
22+
import toast from 'react-hot-toast'
23+
import { get } from 'lodash'
24+
import DefaultButton from '../DefaultButton'
25+
import VersionsApi from '../../api/versions'
26+
import { ReadOptions } from '../../constants'
27+
28+
type ModalProps = {
29+
isOpen: boolean
30+
onClose: () => void
31+
onReadVersion: Function
32+
}
33+
34+
const AddVersionModal = ({ isOpen, onClose, onReadVersion }: ModalProps) => {
35+
const [uploadOption, setUploadOption] = useState(ReadOptions.FILE)
36+
const [file, setFile] = useState()
37+
const [fileUrl, setFileUrl] = useState('')
38+
const readVersionInfo = async () => {
39+
try {
40+
if (uploadOption === ReadOptions.FILE && file) {
41+
const reader = new FileReader()
42+
reader.onload = async function (event) {
43+
const fileContents = get(event, 'target.result', undefined)
44+
const versionResources = await VersionsApi.readVersionInfo(
45+
fileContents,
46+
{
47+
'Content-Type': 'text/xml',
48+
},
49+
)
50+
onReadVersion(versionResources)
51+
}
52+
reader.readAsText(file)
53+
} else if (uploadOption === ReadOptions.URL && fileUrl) {
54+
// Fetch the content from the URL
55+
const versionResources = await VersionsApi.readVersionInfo({
56+
VersionDefinition: {
57+
version_url: fileUrl,
58+
},
59+
})
60+
onReadVersion(versionResources)
61+
}
62+
} catch (err) {
63+
toast.error('Could not read version defintion')
64+
}
65+
}
66+
const handleClose=()=>{
67+
setFile(undefined)
68+
setFileUrl('')
69+
onClose()
70+
}
71+
return (
72+
<Modal show={isOpen} onHide={onClose} data-testid="add-version-modal">
73+
<Modal.Header>
74+
<Modal.Title>Add Version</Modal.Title>
75+
</Modal.Header>
76+
<Modal.Body>
77+
<Form.Check
78+
checked={uploadOption === ReadOptions.FILE}
79+
type="radio"
80+
id={ReadOptions.FILE}
81+
onChange={() => {
82+
setUploadOption(ReadOptions.FILE)
83+
}}
84+
label="Upload Version Definition File"
85+
className="px-0"
86+
/>
87+
<FormControl
88+
type="file"
89+
className="py-1"
90+
onChange={() => {
91+
//@ts-ignore
92+
setFile((event?.target as HTMLInputElement)?.files?.[0])
93+
}}
94+
disabled={uploadOption !== ReadOptions.FILE}
95+
/>
96+
<Form.Check
97+
id={ReadOptions.URL}
98+
checked={uploadOption === ReadOptions.URL}
99+
onChange={() => {
100+
setUploadOption(ReadOptions.URL)
101+
}}
102+
type="radio"
103+
label="Version Definition File URL"
104+
className="px-0 mt-3"
105+
/>
106+
<FormControl
107+
type="text"
108+
className="py-1"
109+
disabled={uploadOption !== ReadOptions.URL}
110+
placeholder="Enter URL to Version Definition File"
111+
value={fileUrl}
112+
onChange={(e) => {
113+
setFileUrl(e.target.value)
114+
}}
115+
/>
116+
</Modal.Body>
117+
<Modal.Footer>
118+
<DefaultButton size="sm" onClick={handleClose}>
119+
CANCEL
120+
</DefaultButton>
121+
<Button
122+
variant="success"
123+
size="sm"
124+
onClick={readVersionInfo}
125+
disabled={!file && !fileUrl}
126+
>
127+
READ VERSION INFO
128+
</Button>
129+
</Modal.Footer>
130+
</Modal>
131+
)
132+
}
133+
134+
export default AddVersionModal
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
import { Button, Modal } from "react-bootstrap";
19+
20+
type PropTypes = {
21+
onClose: () => void;
22+
isOpen: boolean;
23+
};
24+
25+
const LostNetworkModal = ({ onClose, isOpen }: PropTypes) => {
26+
const options = [
27+
"Configure your hosts for access to the Internet.",
28+
" If you are using an Internet Proxy, refer to the Ambari Documentation on how to configure Ambari to use the Internet Proxy.",
29+
"Use the Local Repository option.",
30+
];
31+
return (
32+
<Modal show={isOpen} onHide={onClose} size="lg">
33+
<Modal.Header closeButton>
34+
<Modal.Title>Public Repository Option Disabled</Modal.Title>
35+
</Modal.Header>
36+
<Modal.Body style={{ fontSize: 12 }}>
37+
Ambari does not have access to the Internet and cannot use the Public
38+
Repository for installing the software. Your Options:
39+
<ul>
40+
{options.map((opt:string)=>{
41+
return <li key="opt" className="mt-2" style={{fontSize:12}}>
42+
{opt}
43+
</li>
44+
})}
45+
</ul>
46+
</Modal.Body>
47+
<Modal.Footer>
48+
<Button variant="success" onClick={onClose}>
49+
OK
50+
</Button>
51+
</Modal.Footer>
52+
</Modal>
53+
);
54+
};
55+
56+
export default LostNetworkModal;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
import { Button, Modal } from "react-bootstrap";
19+
import DefaultButton from "../DefaultButton";
20+
21+
type PropTypes = {
22+
isOpen: boolean;
23+
onClose: () => void;
24+
onCancel: () => void;
25+
};
26+
27+
const RedhatSatelliteUsageInfo = ({ isOpen, onClose, onCancel }: PropTypes) => {
28+
return (
29+
<Modal show={isOpen} onHide={onClose}>
30+
<Modal.Header closeButton>
31+
<Modal.Title>Use RedHat Satellite/Spacewalk</Modal.Title>
32+
</Modal.Header>
33+
<Modal.Body>
34+
In order for Ambari to install packages from the right repositories, it
35+
is recommended that you edit the names of the repo's for each operating
36+
system so they match the channel names in your RedHat
37+
Satellite/Spacewalk instance.
38+
</Modal.Body>
39+
<Modal.Footer>
40+
<DefaultButton size="sm" onClick={onCancel}>
41+
Cancel
42+
</DefaultButton>
43+
<Button
44+
variant="success"
45+
size="sm"
46+
onClick={onClose}
47+
className="rounded-1"
48+
>
49+
OK
50+
</Button>
51+
</Modal.Footer>
52+
</Modal>
53+
);
54+
};
55+
56+
export default RedhatSatelliteUsageInfo;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
export enum ReadOptions {
19+
FILE = "file",
20+
URL = "url",
21+
}

ambari-admin/src/main/resources/ui/ambari-admin/src/router/RoutesList.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import { Redirect } from "react-router-dom";
1919
import Users from "../screens/Users";
2020
import WIP from "../components/WIP";
21+
import Register from "../screens/StackVersions/Register";
22+
import { VersionsList } from "../screens/StackVersions";
2123

2224

2325

@@ -43,19 +45,19 @@ export default [
4345
{
4446
path: "/stackVersions/create",
4547
exact: true,
46-
Element: () => <WIP />,
48+
Element: () => <Register readOnly={false} />,
4749
name: "Stack Versions",
4850
},
4951
{
5052
path: "/stackVersions/:stack/:version/edit",
5153
exact: true,
52-
Element: () => <WIP />,
54+
Element: () => <Register readOnly />,
5355
name: "Stack Versions",
5456
},
5557
{
5658
path: "/stackVersions",
5759
exact: true,
58-
Element: () => <WIP />,
60+
Element: () => <VersionsList />,
5961
name: "Stack Versions",
6062
},
6163
{

0 commit comments

Comments
 (0)