Skip to content

Commit 66edadc

Browse files
Merge pull request #24 from UncoderIO/ui-fix-3
Add UI improvements
2 parents 7bd8d38 + 093ed6a commit 66edadc

File tree

75 files changed

+838
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+838
-282
lines changed

uncoder-os/.env.common

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MODULE_VERSION=1.1.0

uncoder-os/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ yarn-error.log*
2020
# .env
2121

2222
/.idea
23+
.editorconfig

uncoder-os/configs/webpack.common.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,25 @@ const rules = [
1919
onlyCompileBundledFiles: true,
2020
},
2121
}],
22-
exclude: /node_modules/,
22+
exclude: [/node_modules/, /workers/],
23+
},
24+
{
25+
test: /\.worker\.ts$/,
26+
use: [
27+
{
28+
loader: 'worker-loader',
29+
options: {
30+
inline: 'no-fallback',
31+
},
32+
},
33+
'babel-loader',
34+
{
35+
loader: 'ts-loader',
36+
options: {
37+
onlyCompileBundledFiles: true,
38+
},
39+
}],
40+
exclude: [/node_modules/],
2341
},
2442
{
2543
test: /\.svg$/,

uncoder-os/configs/webpack.compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const plugins = [
1212
name: 'uncoder',
1313
filename: 'remoteEntry.js',
1414
exposes: {
15-
'./UncoderEditor': './src/pages/UncoderEditor/bootstrap',
15+
'./UncoderEditor': './src/pages/UncoderEditor/bootstrap.tsx',
1616
},
1717
shared: packageJson.dependencies,
1818
}),

uncoder-os/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"react": "^18",
1717
"react-ace": "^10.1.0",
1818
"react-dom": "^18",
19+
"react-error-boundary": "^4.0.11",
1920
"react-redux": "^8.1.3",
21+
"react-tooltip": "^5.24.0",
2022
"redux": "^4.2.1",
2123
"simplebar-react": "^3.2.4"
2224
},
@@ -63,6 +65,7 @@
6365
"webpack": "^5.89.0",
6466
"webpack-cli": "^5.1.4",
6567
"webpack-dev-server": "^4.15.1",
66-
"webpack-merge": "^5.10.0"
68+
"webpack-merge": "^5.10.0",
69+
"worker-loader": "^3.0.8"
6770
}
6871
}

uncoder-os/src/App.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React, { FC, Suspense } from 'react';
2+
import { MainPage } from './pages/MainPage';
3+
import { Spinner } from './components/Spinner';
4+
5+
const App: FC = () => (
6+
<Suspense fallback={<Spinner />}>
7+
<MainPage />
8+
</Suspense>
9+
);
10+
11+
export default App;

uncoder-os/src/assets/svg/GridIcon.svg

Lines changed: 54 additions & 1 deletion
Loading
Lines changed: 27 additions & 0 deletions
Loading

uncoder-os/src/components/Buttons/Button/Button.sass

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
font-weight: 400
1515
font-size: 14px
1616
color: $textDarkBlue
17+
text-decoration: none
1718
transition: background-color .1s
1819
cursor: pointer
20+
&:hover
21+
text-decoration: none
1922
&:disabled,
2023
&.disabled
2124
&,
@@ -58,3 +61,5 @@
5861
font-size: 16px
5962
&.button--icon
6063
min-width: 30px
64+
&--inline
65+
display: inline-flex
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { AnchorHTMLAttributes, FC } from 'react';
2+
3+
import './Button.sass';
4+
5+
type ButtonLinkPropsType = AnchorHTMLAttributes<Element> & {
6+
classes?: string;
7+
};
8+
9+
export const ButtonLink: FC<ButtonLinkPropsType> = ({
10+
children,
11+
classes = '',
12+
...otherProps
13+
}) => (
14+
<a className={`button ${classes}`} {...otherProps}>
15+
{children}
16+
</a>
17+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { Button } from './Button';
2+
export { ButtonLink } from './ButtonLink';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@import ../../../assets/sass/helpers/variables
2+
3+
.button--upper
4+
&:disabled, &:disabled:hover
5+
border-color: $borderDisabled
6+
background-color: $iconDisabled
7+
box-shadow: none
8+
z-index: 1

uncoder-os/src/components/Buttons/TranslateButton/TranslateButton.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
import React, { FC } from 'react';
22
import { Button } from '../Button';
3+
import { Tooltip } from '../../Tooltip';
34
import { useTranslateButton } from './useTranslateButton';
45

6+
import './TranslateButton.sass';
7+
58
export const TranslateButton: FC = () => {
6-
const { onClickHandler } = useTranslateButton();
9+
const { isActive, disabledMessage, onClickHandler } = useTranslateButton();
10+
11+
if (!isActive) {
12+
return (
13+
<Tooltip anchor="translate-button-disabled" content={disabledMessage} positionStrategy="fixed">
14+
<Button
15+
classes="button--upper button--semi button--green button--m"
16+
children="Translate"
17+
aria-label="translate"
18+
type="button"
19+
disabled={!isActive}
20+
/>
21+
</Tooltip>
22+
);
23+
}
724

825
return (
926
<Button

uncoder-os/src/components/Buttons/TranslateButton/useTranslateButton.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@ import { translateIocsFromInputEditor, translateTextFromInputEditor } from '../.
22
import { useDispatch, useSelector } from 'react-redux';
33
import { Dispatch } from '@reduxjs/toolkit';
44
import { inputEditorPlatformCodeSelector } from '../../../reduxData/inputEditor';
5+
import { EditorValueTypes } from '../../../types/editorValueTypes';
6+
import { iocSettingsSelector } from '../../../reduxData/iocSettings';
57

68
export const useTranslateButton = () => {
7-
const parser = useSelector(inputEditorPlatformCodeSelector);
89
const dispatch = useDispatch<Dispatch<any>>();
10+
const parser = useSelector(inputEditorPlatformCodeSelector);
11+
const { includeIocTypes } = useSelector(iocSettingsSelector);
12+
913
const onClickHandler = async () => {
10-
if (parser === 'ioc') {
14+
if (parser === EditorValueTypes.ioc) {
1115
dispatch(translateIocsFromInputEditor());
1216
return;
1317
}
1418

1519
dispatch(translateTextFromInputEditor());
1620
};
1721

22+
const isActive = includeIocTypes.length > 0 || parser !== 'ioc';
23+
24+
const disabledMessage = 'IOC Types is not specified';
25+
1826
return {
27+
isActive,
28+
disabledMessage,
1929
onClickHandler,
2030
};
2131
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { Button } from './Button';
1+
export { Button, ButtonLink } from './Button';
22
export * from './TranslateButton';

uncoder-os/src/components/Dropdown/DropdownLayouts/DropdownIocSettingsMenu/DropdownIocSettingsMenu.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ export const DropdownIocSettingsMenu: FC = () => {
2727
{
2828
iocTypesFields.map((field) => (
2929
<div className="ioc-settings-menu-list__item m-r-16 m-b-6" key={field.name}>
30-
<Checkbox label={field.label} checked={field.checked} name={field.name}/>
30+
<Checkbox label={field.label} checked={field.checked} name={field.name} readOnly/>
3131
</div>
3232
))
3333
}
3434
{
3535
(iocTypeErrorMessage?.length) && (
36-
<HelperText children={iocTypeErrorMessage} />
36+
<HelperText children={iocTypeErrorMessage}/>
3737
)
3838
}
3939
</div>
@@ -44,13 +44,13 @@ export const DropdownIocSettingsMenu: FC = () => {
4444
{
4545
hashTypesFields.map((field) => (
4646
<div className="ioc-settings-menu-list__item m-r-16 m-b-6" key={field.name}>
47-
<Checkbox label={field.label} checked={field.checked} name={field.name}/>
47+
<Checkbox label={field.label} checked={field.checked} name={field.name} readOnly/>
4848
</div>
4949
))
5050
}
5151
</div>
5252
<div className="ioc-settings-menu__label m-b-10">
53-
<Label label="IOCs per query" />
53+
<Label label="IOCs per query"/>
5454
</div>
5555
<div className="ioc-settings-menu__slider m-b-12">
5656
<RangeSlider
@@ -63,7 +63,7 @@ export const DropdownIocSettingsMenu: FC = () => {
6363
/>
6464
</div>
6565
<div className="ioc-settings-menu__label m-b-10">
66-
<Label label="Exceptions" />
66+
<Label label="Exceptions"/>
6767
</div>
6868
<div className="ioc-settings-menu-list__textarea m-b-8">
6969
<Textarea

uncoder-os/src/components/Dropdown/DropdownLayouts/ReplaceSettingsMenu/ReplaceSettingsMenu.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const ReplaceSettingsMenu: FC<DropdownDefaultMenuPropsType> = ({ width =
1515
replaceSettings,
1616
isSelectAll,
1717
} = useReplaceSettings();
18-
console.log(replaceSettings);
18+
1919
return (
2020
<div className="dropdown-menu-checkbox-list" style={{ width }}>
2121
<div className="dropdown-menu-checkbox-list__item">
@@ -25,7 +25,12 @@ export const ReplaceSettingsMenu: FC<DropdownDefaultMenuPropsType> = ({ width =
2525
{
2626
replaceSettings.map((field) => (
2727
<div className="dropdown-menu-checkbox-list__item" key={field.name}>
28-
<Checkbox label={field.label} checked={field.checked} name={field.name}/>
28+
<Checkbox
29+
label={field.label}
30+
checked={field.checked}
31+
name={field.name}
32+
readOnly={true}
33+
/>
2934
</div>
3035
))
3136
}

uncoder-os/src/components/Dropdown/DropdownLayouts/ReplaceSettingsMenu/useReplaceSettings.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@ const replaceSettings = [
2121
checked: false,
2222
},
2323
];
24+
2425
export const useReplaceSettings = () => {
25-
const {
26-
iocParsingRules,
27-
} = useSelector(iocSettingsSelector);
2826
const dispatch = useDispatch<Dispatch<any>>();
27+
const { iocParsingRules } = useSelector(iocSettingsSelector);
2928

3029
const onChangeReplaceSettings = (event: ChangeEvent<HTMLInputElement>) => {
3130
const { checked, name } = event.target;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@import ../../assets/sass/helpers/variables
2+
3+
.error-boundary-page
4+
min-height: calc(100vh - 236px)
5+
display: flex
6+
align-items: center
7+
justify-content: center
8+
flex-direction: column
9+
&__wrap
10+
text-align: center
11+
&__title
12+
font-size: 32px
13+
font-weight: 600
14+
&__description
15+
h3
16+
font-size: 14px
17+
font-weight: 400
18+
color: $textSubdued
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { FC } from 'react';
2+
import { FallbackProps } from 'react-error-boundary';
3+
import { ButtonLink } from '../Buttons';
4+
5+
import { ReactComponent as LittleDownIcon } from '../../assets/svg/LittleDownIcon.svg';
6+
7+
import './ErrorBoundaryFallback.sass';
8+
9+
interface IErrorBoundaryFallbackPropsType extends FallbackProps {}
10+
11+
export const ErrorBoundaryFallback: FC <IErrorBoundaryFallbackPropsType> = () => (
12+
<div className="error-boundary-page">
13+
<div className="error-boundary-page__wrap">
14+
<div className="error-boundary-page__body">
15+
<div className="error-boundary-page__icon m-b-32">
16+
<LittleDownIcon />
17+
</div>
18+
<h1 className="error-boundary-page__title m-b-16">
19+
Something Went Wrong
20+
</h1>
21+
<div className="error-boundary-page__description m-b-24">
22+
<h3 className="m-b-16">
23+
Please, try again or reach out to us
24+
on <a className="link link--underline link--green" href="https://discord.com/invite/yYd47bA2XV" target="_blank">Discord</a>.
25+
</h3>
26+
</div>
27+
<div className="error-boundary-page__button">
28+
<ButtonLink className="button button--upper button--semi button--green button--m button--inline" href="/">
29+
TRY AGAIN
30+
</ButtonLink>
31+
</div>
32+
</div>
33+
</div>
34+
</div>
35+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ErrorBoundaryFallback } from './ErrorBoundaryFallback';

uncoder-os/src/components/FileUploader/InputEditorFileUploadButton/InputEditorFileUploadButton.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { FC } from 'react';
22
import { useInputEditorFileUploadButton } from './useInputEditorFileUploadButton';
33
import { FileUploader } from '../FileUploader';
44
import { Button } from '../../Buttons';
5+
import { Tooltip } from '../../Tooltip';
56
import { ReactComponent as UploadIcon } from '../../../assets/svg/UploadIcon.svg';
67

78
export const InputEditorFileUploadButton: FC = () => {
@@ -12,9 +13,11 @@ export const InputEditorFileUploadButton: FC = () => {
1213
handleFile={uploadHandler}
1314
accept=".csv,.json,.txt"
1415
>
15-
<Button classes="button--icon button--xs button--default button--bg m-r-6" aria-label="input-upload" type="button">
16-
<UploadIcon />
17-
</Button>
16+
<Tooltip content="Upload IOCs" positionStrategy="fixed">
17+
<Button classes="button--icon button--xs button--default button--bg m-r-6" aria-label="input-upload" type="button">
18+
<UploadIcon />
19+
</Button>
20+
</Tooltip>
1821
</FileUploader>
1922
);
2023
};

0 commit comments

Comments
 (0)