Skip to content

Commit da34a87

Browse files
fixing nits based on reviews
WIP WIP WIP
1 parent 395fdb5 commit da34a87

File tree

12 files changed

+106
-103
lines changed

12 files changed

+106
-103
lines changed

desktop/core/src/desktop/js/apps/admin/Components/utils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
// limitations under the License.
1616

1717
export const SERVER_LOGS_API_URL = '/api/v1/logs';
18-
export const INSTALL_APP_EXAMPLES_API_URL = '/api/v1/check_config';
18+
export const CHECK_CONFIG_EXAMPLES_API_URL = '/api/v1/check_config';
1919
export const ANALYTICS_PREFERENCES_API_URL = '/about/update_preferences';
20+
export const INSTALL_APP_EXAMPLES_API_URL = '/api/v1/install_app_examples';

desktop/core/src/desktop/js/apps/admin/Configuration/ConfigurationTab.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// limitations under the License.
1616

1717
import React, { useState, useEffect, useMemo } from 'react';
18-
import { Spin } from 'antd';
18+
import Loading from 'cuix/dist/components/Loading';
1919
import Alert from 'cuix/dist/components/Alert';
2020
import { i18nReact } from '../../../utils/i18nReact';
2121
import AdminHeader from '../AdminHeader';
@@ -151,7 +151,7 @@ const Configuration: React.FC = (): JSX.Element => {
151151

152152
return (
153153
<div className="config-component">
154-
<Spin spinning={loading}>
154+
<Loading spinning={loading}>
155155
{error && (
156156
<Alert
157157
message={`Error: ${error}`}
@@ -183,7 +183,7 @@ const Configuration: React.FC = (): JSX.Element => {
183183
))}
184184
</>
185185
)}
186-
</Spin>
186+
</Loading>
187187
</div>
188188
);
189189
};

desktop/core/src/desktop/js/apps/admin/Metrics/MetricsTab.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import React, { useState, useEffect } from 'react';
1818
import MetricsTable, { MetricsResponse, MetricsTableProps } from './MetricsTable';
19-
import { Spin } from 'antd';
19+
import Loading from 'cuix/dist/components/Loading';
2020
import Alert from 'cuix/dist/components/Alert';
2121
import { get } from '../../../api/utils';
2222
import { i18nReact } from '../../../utils/i18nReact';
@@ -95,7 +95,7 @@ const Metrics: React.FC = (): JSX.Element => {
9595

9696
return (
9797
<div className="cuix antd metrics-component">
98-
<Spin spinning={loading}>
98+
<Loading spinning={loading}>
9999
{!error && (
100100
<AdminHeader
101101
options={['All', ...filteredKeys]}
@@ -125,7 +125,7 @@ const Metrics: React.FC = (): JSX.Element => {
125125
</div>
126126
))}
127127
</div>
128-
</Spin>
128+
</Loading>
129129
</div>
130130
);
131131
};

desktop/core/src/desktop/js/apps/admin/Metrics/MetricsTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const MetricsTable: React.FC<MetricsTableProps> = ({ caption, dataSource }) => {
114114
() =>
115115
dataSource.map(item => ({
116116
...item,
117-
name: t(metricLabels[item.name]) || item.name
117+
name: metricLabels[item.name] || item.name
118118
})),
119119
[dataSource]
120120
);

desktop/core/src/desktop/js/apps/admin/Overview/Analytics.tsx

+18-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import React, { useState } from 'react';
1818
import huePubSub from '../../../utils/huePubSub';
1919
import { i18nReact } from '../../../utils/i18nReact';
20-
import { Checkbox } from 'antd';
20+
import Input from 'cuix/dist/components/Input';
2121
import { post } from '../../../api/utils';
2222
import { ANALYTICS_PREFERENCES_API_URL } from '../Components/utils';
2323
import './Overview.scss';
@@ -32,20 +32,16 @@ const Analytics = (): JSX.Element => {
3232
const { t } = i18nReact.useTranslation();
3333

3434
const saveCollectUsagePreference = async (collectUsage: boolean) => {
35-
try {
36-
const response = await post<UpdatePreferences>(ANALYTICS_PREFERENCES_API_URL, {
37-
collect_usage: collectUsage ? 'on' : null
38-
});
35+
const response = await post<UpdatePreferences>(ANALYTICS_PREFERENCES_API_URL, {
36+
collect_usage: collectUsage ? 'on' : null
37+
});
3938

40-
if (response.status === 0) {
41-
huePubSub.publish('hue.global.info', { message: t('Configuration updated') });
42-
} else {
43-
huePubSub.publish('hue.global.error', {
44-
message: t('Error updating configuration')
45-
});
46-
}
47-
} catch (err) {
48-
huePubSub.publish('hue.global.error', { message: String(err) });
39+
if (response.status === 0) {
40+
huePubSub.publish('hue.global.info', { message: t('Configuration updated') });
41+
} else {
42+
huePubSub.publish('hue.global.error', {
43+
message: t('Error updating configuration')
44+
});
4945
}
5046
};
5147

@@ -58,8 +54,14 @@ const Analytics = (): JSX.Element => {
5854
return (
5955
<div className="overview-analytics">
6056
<h3>{t('Anonymous usage analytics')}</h3>
61-
<div>
62-
<Checkbox id="usage_analytics" checked={collectUsage} onChange={handleCheckboxChange} />
57+
<div className="analytics-checkbox-container">
58+
<Input
59+
type="checkbox"
60+
className="analytics__checkbox-icon"
61+
id="usage_analytics"
62+
checked={collectUsage}
63+
onChange={handleCheckboxChange}
64+
/>
6365
<label htmlFor="usage_analytics" className="usage__analytics">
6466
{t('Help improve Hue with anonymous usage analytics.')}
6567
</label>

desktop/core/src/desktop/js/apps/admin/Overview/ConfigStatus.tsx

+52-57
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
// limitations under the License.
1616

1717
import React from 'react';
18-
// import { Spin } from 'antd';
1918
import Loading from 'cuix/dist/components/Loading';
2019
import Alert from 'cuix/dist/components/Alert';
2120
import Table from 'cuix/dist/components/Table';
2221
import useLoadData from '../../../utils/hooks/useLoadData/useLoadData';
23-
import { INSTALL_APP_EXAMPLES_API_URL } from '../Components/utils';
22+
import { CHECK_CONFIG_EXAMPLES_API_URL } from '../Components/utils';
2423
import { i18nReact } from '../../../utils/i18nReact';
2524
import './Overview.scss';
2625

@@ -35,7 +34,7 @@ interface CheckConfigResponse {
3534

3635
function ConfigStatus(): JSX.Element {
3736
const { t } = i18nReact.useTranslation();
38-
const { data, loading, error } = useLoadData<CheckConfigResponse>(INSTALL_APP_EXAMPLES_API_URL);
37+
const { data, loading, error } = useLoadData<CheckConfigResponse>(CHECK_CONFIG_EXAMPLES_API_URL);
3938

4039
const columns = [
4140
{
@@ -48,7 +47,7 @@ function ConfigStatus(): JSX.Element {
4847
<div>
4948
{record.value && (
5049
<p>
51-
{t('Current value')}: <span className="config__table-name">{record.value}</span>
50+
{t('Current value')}: <span className="config__table-value">{record.value}</span>
5251
</p>
5352
)}
5453
<p>{record.message}</p>
@@ -57,67 +56,63 @@ function ConfigStatus(): JSX.Element {
5756
}
5857
];
5958

60-
if (error) {
61-
return (
62-
<div>
63-
<Alert
64-
message={t(`Error: ${error}`)}
65-
description={t('An error occurred while attempting to install app examples.')}
66-
type="error"
67-
/>
68-
</div>
69-
);
70-
}
71-
72-
if (loading) {
73-
return <Loading spinning={loading} className="config__spin" />;
74-
}
75-
7659
const configErrorsExist = Boolean(data?.configErrors?.length);
7760

7861
return (
7962
<div className="overview-config">
80-
<h1>{t('Checking current configuration')}</h1>
81-
{data?.hueConfigDir && (
82-
<div>
83-
{t('Configuration files located in: ')}
84-
<span className="config__address-value">{data['hueConfigDir']}</span>
85-
</div>
63+
{loading && <Loading spinning={loading} className="config__spin" />}
64+
{error && (
65+
<Alert
66+
message={`${t('Error:')} ${error}`}
67+
description={t('An error occurred while attempting to load the configuration status.')}
68+
type="error"
69+
/>
8670
)}
87-
88-
{configErrorsExist && data ? (
71+
{!loading && !error && (
8972
<>
90-
<Alert
91-
message={
92-
<span>
93-
<a
94-
href="https://docs.gethue.com/administrator/configuration/"
95-
target="_blank"
96-
className="config__link"
97-
>
98-
{t('Potential misconfiguration detected.')}
99-
</a>{' '}
100-
{t('Fix and restart Hue.')}
101-
</span>
102-
}
103-
type="warning"
104-
className="config__alert-margin"
105-
/>
73+
<h1>{t('Checking current configuration')}</h1>
74+
{data?.hueConfigDir && (
75+
<div>
76+
{t('Configuration files located in: ')}
77+
<span className="config__address-value">{data['hueConfigDir']}</span>
78+
</div>
79+
)}
10680

107-
<Table
108-
dataSource={data['configErrors']}
109-
columns={columns}
110-
rowKey={record => `${record.name}-${record.message.slice(1, 50)}`}
111-
pagination={false}
112-
showHeader={false}
113-
/>
81+
{configErrorsExist && data ? (
82+
<>
83+
<Alert
84+
message={
85+
<span>
86+
<a
87+
href="https://docs.gethue.com/administrator/configuration/"
88+
target="_blank"
89+
className="config__link"
90+
>
91+
{t('Potential misconfiguration detected.')}
92+
</a>{' '}
93+
{t('Fix and restart Hue.')}
94+
</span>
95+
}
96+
type="warning"
97+
className="config__alert-margin"
98+
/>
99+
100+
<Table
101+
dataSource={data['configErrors']}
102+
columns={columns}
103+
rowKey={record => `${record.name}-${record.message.slice(1, 50)}`}
104+
pagination={false}
105+
showHeader={false}
106+
/>
107+
</>
108+
) : (
109+
<Alert
110+
message={t('All OK. Configuration check passed.')}
111+
type="success"
112+
className="config__alert-margin"
113+
/>
114+
)}
114115
</>
115-
) : (
116-
<Alert
117-
message={t('All OK. Configuration check passed.')}
118-
type="success"
119-
className="config__alert-margin"
120-
/>
121116
)}
122117
</div>
123118
);

desktop/core/src/desktop/js/apps/admin/Overview/Examples.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import React, { useState } from 'react';
1818
import { Button } from 'antd';
1919
import { DownloadOutlined } from '@ant-design/icons';
20+
import { INSTALL_APP_EXAMPLES_API_URL } from '../Components/utils';
2021
import { post } from '../../../api/utils';
2122
import huePubSub from '../../../utils/huePubSub';
2223
import { i18nReact } from '../../../utils/i18nReact';
@@ -43,24 +44,21 @@ const Examples = (): JSX.Element => {
4344

4445
const handleInstall = async exampleApp => {
4546
setInstallingAppId(exampleApp.id);
46-
const url = '/api/v1/install_app_examples';
47+
const url = INSTALL_APP_EXAMPLES_API_URL;
4748
const data = { app_name: exampleApp.id };
4849

4950
if (exampleApp.data) {
5051
data['data'] = exampleApp.data;
5152
}
5253

53-
post<InstallExamplesResponse>(url, data, {
54-
method: 'POST',
55-
silenceErrors: true
56-
})
54+
post<InstallExamplesResponse>(url, data)
5755
.then(response => {
58-
const message = response.message ? t(response.message) : t('Examples refreshed');
56+
const message = response.message ? response.message : t('Examples refreshed');
5957
huePubSub.publish('hue.global.info', { message });
6058
})
6159
.catch(error => {
6260
const errorMessage = error.message
63-
? t(error.message)
61+
? error.message
6462
: t('An error occurred while installing examples.');
6563
huePubSub.publish('hue.global.error', { message: errorMessage });
6664
})
@@ -80,7 +78,7 @@ const Examples = (): JSX.Element => {
8078
disabled={installingAppId === exampleApp.id}
8179
icon={<DownloadOutlined />}
8280
>
83-
{installingAppId === exampleApp.id ? t('Installing...') : t(exampleApp.name)}
81+
{installingAppId === exampleApp.id ? t('Installing...') : exampleApp.name}
8482
</Button>
8583
</div>
8684
))}

desktop/core/src/desktop/js/apps/admin/Overview/Overview.scss

+13-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
margin: 10px 0;
4646
}
4747

48-
.config__table-name {
48+
.config__table-name, .config__table-value {
4949
color: $fluidx-gray-900;
5050
font-size: 12px;
5151
border-radius: 5px;
@@ -60,9 +60,19 @@
6060
height: 100vh;
6161
}
6262

63+
.analytics-checkbox-container {
64+
display: flex;
65+
align-items: center;
66+
}
67+
68+
.analytics__checkbox-icon {
69+
width: auto;
70+
height: auto;
71+
min-height: 0;
72+
}
73+
6374
.usage__analytics {
64-
display: inline-block;
65-
padding: 5px;
75+
margin-left: 8px;
6676
}
6777

6878
.overview__trademark-text {

desktop/core/src/desktop/js/apps/admin/Overview/OverviewTab.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ import Examples from './Examples';
2020
import ConfigStatus from './ConfigStatus';
2121
import Analytics from './Analytics';
2222
import { i18nReact } from '../../../utils/i18nReact';
23-
import { getLastKnownConfig } from '../../../config/hueConfig';
2423
import './Overview.scss';
2524

2625
const Overview = (): JSX.Element => {
2726
const { t } = i18nReact.useTranslation();
2827

29-
const config = getLastKnownConfig();
30-
const isAdmin = config?.hue_config.is_admin ?? false;
3128
const items = [
3229
{
3330
label: t('Config Status'),
@@ -46,14 +43,11 @@ const Overview = (): JSX.Element => {
4643
}
4744
];
4845

49-
if (!isAdmin) {
50-
return <></>;
51-
}
5246
return (
5347
<div className="hue-overview-component">
5448
<Tabs tabPosition="left" items={items} />
5549
<div className="overview__trademark-text">
56-
Hue and the Hue logo are trademarks of Cloudera, Inc.
50+
t('Hue and the Hue logo are trademarks of Cloudera, Inc.')
5751
</div>
5852
</div>
5953
);

desktop/core/src/desktop/js/apps/admin/ServerLogs/ServerLogsHeader.scss

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858

5959
.server__checkbox-icon {
6060
margin-right: 2px;
61+
width: auto;
62+
height: auto;
63+
min-height: 0;
6164
}
6265

6366
.server__download-button {

0 commit comments

Comments
 (0)