Skip to content

Commit b0d7dd0

Browse files
authored
Merge pull request #13 from InfuseAI/feature/sc-22145/release-crane-1-0-0
Release Crane 1.0.0 Final Check
2 parents c1b039f + e24d271 commit b0d7dd0

File tree

8 files changed

+86
-15
lines changed

8 files changed

+86
-15
lines changed

src/App.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
import React, { Suspense } from 'react';
1+
import React, { useState, useEffect, Suspense } from 'react';
22
import {
33
HashRouter as Router,
44
Redirect,
55
Route,
66
Switch,
77
} from 'react-router-dom';
88
import './App.less';
9-
import { Layout, Skeleton } from 'antd';
9+
import { Alert, Button, Space, Layout, Skeleton } from 'antd';
1010
import Sidebar from './Sidebar';
1111
import BuildImage from './BuildImage';
1212
import ListImage from './ListImage';
1313
import Settings from './Settings';
14+
import { send } from './utils/ipcClient';
1415
import CreatePrimeHubImage from './CreatePrimeHubImage';
1516
const { Footer } = Layout;
1617

18+
const OK = 'ok';
19+
1720
const Crane = () => {
21+
const [missingDocker, setMissingDocker] = useState(false);
1822
const siderWidth = {
1923
collapsed: 80,
2024
unCollapsed: 190,
2125
};
2226

27+
useEffect(() => {
28+
(async () => {
29+
// @ts-ignore
30+
const pong = await send('ping_docker');
31+
console.log('Ping docker:', pong);
32+
if (pong !== OK) {
33+
setMissingDocker(true);
34+
}
35+
})();
36+
}, []);
37+
2338
return (
2439
<Layout
2540
style={{
@@ -29,6 +44,28 @@ const Crane = () => {
2944
<Router>
3045
<Sidebar collapsed={true} width={siderWidth.unCollapsed} />
3146
<Layout className='site-layout'>
47+
{missingDocker ? (
48+
<Alert
49+
message='Error: Missing Docker runtime.'
50+
description='Can not detect system docker, please check your docker enviroment.'
51+
type='error'
52+
showIcon
53+
action={
54+
<Space>
55+
<Button
56+
size='small'
57+
type='primary'
58+
href='https://docs.docker.com/get-docker/'
59+
target='_blank'
60+
>
61+
Get Docker
62+
</Button>
63+
</Space>
64+
}
65+
/>
66+
) : (
67+
<></>
68+
)}
3269
<Suspense
3370
fallback={
3471
<div className='site-layout-background'>
@@ -38,7 +75,7 @@ const Crane = () => {
3875
>
3976
<Switch>
4077
<Route exact path='/' component={BuildImage} />
41-
<Route path='/settings' component={Settings} />
78+
<Route path='/settings/:tabName' component={Settings} />
4279
<Route path='/images' component={ListImage} />
4380
<Route
4481
path='/createPrimeHubImage'

src/BuildImage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ export default function BuildImage() {
118118

119119
const initialValues = {
120120
base_image_url: 'jupyter/base-notebook:latest',
121-
apt: `curl\ngit`,
122121
};
123122

124123
useEffect(() => {

src/CreatePrimeHubImage.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const { Content } = Layout;
2222
const { Option } = Select;
2323

2424
export default function CreatePrimeHubImage() {
25-
const hisotry = useHistory();
25+
const history = useHistory();
2626
const location = useLocation();
2727
const { search } = location;
2828
const [form] = Form.useForm();
@@ -85,7 +85,16 @@ export default function CreatePrimeHubImage() {
8585
console.log(error);
8686
notification.error({
8787
message: 'PrimeHub Connection Failed',
88-
description: `Unable to fetch PrimeHub user group info.`,
88+
duration: 5,
89+
description: (
90+
<div>
91+
Unable to fetch PrimeHub user group info.{' '}
92+
{/* eslint-disable-next-line */}
93+
<a onClick={() => history.push('/settings/primehub')}>
94+
App Settings
95+
</a>
96+
</div>
97+
),
8998
});
9099
}
91100
}
@@ -121,7 +130,7 @@ export default function CreatePrimeHubImage() {
121130
message: 'PrimeHub',
122131
description: `Image: ${get(result, 'data.createImage.name')} created.`,
123132
});
124-
hisotry.push('/images/');
133+
history.push('/images/');
125134
} catch (error) {
126135
console.log(error);
127136
notification.error({

src/ListImage.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,28 @@ export default function ListImage() {
2929
const [imageList, updateImageList] = useState([]);
3030
const [logDrawerVisible, setLogDrawerVisible] = useState(false);
3131
const [logText, setLogText] = useLocalStorage('push_log');
32-
const buildNotification = (name, isSuccess) => {
32+
const buildNotification = (name, isSuccess, payload) => {
3333
if (isSuccess) {
3434
notification['success']({
3535
message: 'Push Success',
3636
description: `Image ${name || ''} pushed`,
3737
});
3838
} else {
39+
const err = payload.output.find((x) => x.error);
3940
notification['error']({
4041
message: 'Push Failed',
41-
description: `Image ${name || ''} push failed`,
42+
description: (
43+
<div>
44+
Image ${name || ''} push failed
45+
<br />
46+
{err.error.split('\n').map((line) => (
47+
<span>
48+
{line}
49+
<br />
50+
</span>
51+
))}
52+
</div>
53+
),
4254
});
4355
}
4456
};
@@ -47,7 +59,7 @@ export default function ListImage() {
4759
listen(ipc_name, (payload) => {
4860
if (payload.stage === Status.FINISHED) {
4961
const name = ipc_name.replace('push-log-', '');
50-
buildNotification(name, !payload.output.find((x) => x.error));
62+
buildNotification(name, !payload.output.find((x) => x.error), payload);
5163
setLogDrawerVisible(false);
5264
unlisten(ipc_name);
5365
} else if (payload.stage === Status.PROGRESSING) {

src/Settings.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
notification,
1111
Space,
1212
} from 'antd';
13+
import { useParams } from 'react-router-dom';
1314
import { send } from './utils/ipcClient';
1415
import {
1516
ApolloClient,
@@ -23,6 +24,7 @@ const { Content } = Layout;
2324
const { TabPane } = Tabs;
2425

2526
export default function Settings() {
27+
const { tabName } = useParams<{ tabName: string }>();
2628
const [dockerHubForm] = Form.useForm();
2729
const [primeHubForm] = Form.useForm();
2830
const onDockerHubFinish = async (values) => {
@@ -125,8 +127,12 @@ export default function Settings() {
125127
className='site-layout-background'
126128
style={{ padding: 24, minHeight: 360 }}
127129
>
128-
<Tabs defaultActiveKey='1' size='large' style={{ marginBottom: 32 }}>
129-
<TabPane tab='DOCKER HUB' key='1'>
130+
<Tabs
131+
defaultActiveKey={tabName}
132+
size='large'
133+
style={{ marginBottom: 32 }}
134+
>
135+
<TabPane tab='DOCKER HUB' key='dockerhub'>
130136
<Form
131137
layout='vertical'
132138
form={dockerHubForm}
@@ -148,7 +154,7 @@ export default function Settings() {
148154
</Form.Item>
149155
</Form>
150156
</TabPane>
151-
<TabPane tab='PRIMEHUB' key='2' forceRender={true}>
157+
<TabPane tab='PRIMEHUB' key='primehub' forceRender={true}>
152158
<Alert
153159
style={{ margin: '8px 0 16px' }}
154160
className='primehub-alert'

src/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function Sidebar(prop) {
6464
key='settings'
6565
icon={<SettingOutlined />}
6666
>
67-
<Link to='/settings' style={{ color: 'white' }}>
67+
<Link to='/settings/dockerhub' style={{ color: 'white' }}>
6868
Settings
6969
</Link>
7070
</Menu.Item>

src/electron/ServerHandlers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ export function writeDockerfile(dockerfileContent) {
7575
const handlers = {
7676
build_events: [],
7777
build_status: '',
78+
ping_docker: async (args) => {
79+
try {
80+
await docker.ping();
81+
} catch (error) {
82+
return error;
83+
}
84+
return 'ok';
85+
},
7886
'get-dockerhub-credential': async () => {
7987
return await getCredential(dockerHubCredentialKeyName);
8088
},

src/electron/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function createBackgroundWindow(args) {
5050
height: 640,
5151
minWidth: 1024,
5252
minHeight: 640,
53-
show: false,
53+
show: true,
5454
webPreferences: {
5555
nodeIntegration: true,
5656
contextIsolation: false,

0 commit comments

Comments
 (0)