Moved some settings between general and ui tabs
This commit is contained in:
parent
04e80b339c
commit
500e138643
4 changed files with 60 additions and 123 deletions
|
@ -7,28 +7,22 @@ import { bindActionCreators } from 'redux';
|
||||||
import { actionCreators } from '../../../store';
|
import { actionCreators } from '../../../store';
|
||||||
|
|
||||||
// Typescript
|
// Typescript
|
||||||
import { OtherSettingsForm } from '../../../interfaces';
|
import { UISettingsForm } from '../../../interfaces';
|
||||||
|
|
||||||
// UI
|
// UI
|
||||||
import { InputGroup, Button, SettingsHeadline } from '../../UI';
|
import { InputGroup, Button, SettingsHeadline } from '../../UI';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { otherSettingsTemplate, inputHandler } from '../../../utility';
|
import { uiSettingsTemplate, inputHandler } from '../../../utility';
|
||||||
|
|
||||||
export const UISettings = (): JSX.Element => {
|
export const UISettings = (): JSX.Element => {
|
||||||
const {
|
const { loading, config } = useSelector((state: State) => state.config);
|
||||||
config: { loading, config },
|
|
||||||
bookmarks: { categories },
|
|
||||||
} = useSelector((state: State) => state);
|
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { updateConfig, sortApps, sortCategories, sortBookmarks } =
|
const { updateConfig } = bindActionCreators(actionCreators, dispatch);
|
||||||
bindActionCreators(actionCreators, dispatch);
|
|
||||||
|
|
||||||
// Initial state
|
// Initial state
|
||||||
const [formData, setFormData] = useState<OtherSettingsForm>(
|
const [formData, setFormData] = useState<UISettingsForm>(uiSettingsTemplate);
|
||||||
otherSettingsTemplate
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get config
|
// Get config
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -46,16 +40,6 @@ export const UISettings = (): JSX.Element => {
|
||||||
|
|
||||||
// Update local page title
|
// Update local page title
|
||||||
document.title = formData.customTitle;
|
document.title = formData.customTitle;
|
||||||
|
|
||||||
// Sort entities with new settings
|
|
||||||
if (formData.useOrdering !== config.useOrdering) {
|
|
||||||
sortApps();
|
|
||||||
sortCategories();
|
|
||||||
|
|
||||||
for (let { id } of categories) {
|
|
||||||
sortBookmarks(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Input handler
|
// Input handler
|
||||||
|
@ -63,7 +47,7 @@ export const UISettings = (): JSX.Element => {
|
||||||
e: ChangeEvent<HTMLInputElement | HTMLSelectElement>,
|
e: ChangeEvent<HTMLInputElement | HTMLSelectElement>,
|
||||||
options?: { isNumber?: boolean; isBool?: boolean }
|
options?: { isNumber?: boolean; isBool?: boolean }
|
||||||
) => {
|
) => {
|
||||||
inputHandler<OtherSettingsForm>({
|
inputHandler<UISettingsForm>({
|
||||||
e,
|
e,
|
||||||
options,
|
options,
|
||||||
setStateHandler: setFormData,
|
setStateHandler: setFormData,
|
||||||
|
@ -88,6 +72,36 @@ export const UISettings = (): JSX.Element => {
|
||||||
/>
|
/>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* === SEARCH OPTIONS === */}
|
||||||
|
<SettingsHeadline text="Search" />
|
||||||
|
{/* HIDE SEARCHBAR */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="hideSearch">Hide search bar</label>
|
||||||
|
<select
|
||||||
|
id="hideSearch"
|
||||||
|
name="hideSearch"
|
||||||
|
value={formData.hideSearch ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
|
{/* AUTOFOCUS SEARCHBAR */}
|
||||||
|
<InputGroup>
|
||||||
|
<label htmlFor="disableAutofocus">Disable search bar autofocus</label>
|
||||||
|
<select
|
||||||
|
id="disableAutofocus"
|
||||||
|
name="disableAutofocus"
|
||||||
|
value={formData.disableAutofocus ? 1 : 0}
|
||||||
|
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
||||||
|
>
|
||||||
|
<option value={1}>True</option>
|
||||||
|
<option value={0}>False</option>
|
||||||
|
</select>
|
||||||
|
</InputGroup>
|
||||||
|
|
||||||
{/* === HEADER OPTIONS === */}
|
{/* === HEADER OPTIONS === */}
|
||||||
<SettingsHeadline text="Header" />
|
<SettingsHeadline text="Header" />
|
||||||
{/* HIDE HEADER */}
|
{/* HIDE HEADER */}
|
||||||
|
@ -160,8 +174,8 @@ export const UISettings = (): JSX.Element => {
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
onChange={(e) => inputChangeHandler(e)}
|
||||||
/>
|
/>
|
||||||
<span>
|
<span>
|
||||||
Greetings must be separated with semicolon. Only 4 messages can be
|
Greetings must be separated with semicolon. All 4 messages must be
|
||||||
used
|
filled, even if they are the same
|
||||||
</span>
|
</span>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
|
@ -193,85 +207,8 @@ export const UISettings = (): JSX.Element => {
|
||||||
<span>Names must be separated with semicolon</span>
|
<span>Names must be separated with semicolon</span>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
|
||||||
{/* === BEAHVIOR OPTIONS === */}
|
{/* === SECTIONS OPTIONS === */}
|
||||||
<SettingsHeadline text="App Behavior" />
|
<SettingsHeadline text="Sections" />
|
||||||
{/* PIN APPS */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="pinAppsByDefault">
|
|
||||||
Pin new applications by default
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
id="pinAppsByDefault"
|
|
||||||
name="pinAppsByDefault"
|
|
||||||
value={formData.pinAppsByDefault ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* PIN CATEGORIES */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="pinCategoriesByDefault">
|
|
||||||
Pin new categories by default
|
|
||||||
</label>
|
|
||||||
<select
|
|
||||||
id="pinCategoriesByDefault"
|
|
||||||
name="pinCategoriesByDefault"
|
|
||||||
value={formData.pinCategoriesByDefault ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* SORT TYPE */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="useOrdering">Sorting type</label>
|
|
||||||
<select
|
|
||||||
id="useOrdering"
|
|
||||||
name="useOrdering"
|
|
||||||
value={formData.useOrdering}
|
|
||||||
onChange={(e) => inputChangeHandler(e)}
|
|
||||||
>
|
|
||||||
<option value="createdAt">By creation date</option>
|
|
||||||
<option value="name">Alphabetical order</option>
|
|
||||||
<option value="orderId">Custom order</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* APPS OPPENING */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="appsSameTab">Open applications in the same tab</label>
|
|
||||||
<select
|
|
||||||
id="appsSameTab"
|
|
||||||
name="appsSameTab"
|
|
||||||
value={formData.appsSameTab ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* BOOKMARKS OPPENING */}
|
|
||||||
<InputGroup>
|
|
||||||
<label htmlFor="bookmarksSameTab">Open bookmarks in the same tab</label>
|
|
||||||
<select
|
|
||||||
id="bookmarksSameTab"
|
|
||||||
name="bookmarksSameTab"
|
|
||||||
value={formData.bookmarksSameTab ? 1 : 0}
|
|
||||||
onChange={(e) => inputChangeHandler(e, { isBool: true })}
|
|
||||||
>
|
|
||||||
<option value={1}>True</option>
|
|
||||||
<option value={0}>False</option>
|
|
||||||
</select>
|
|
||||||
</InputGroup>
|
|
||||||
|
|
||||||
{/* === MODULES OPTIONS === */}
|
|
||||||
<SettingsHeadline text="Modules" />
|
|
||||||
{/* HIDE APPS */}
|
{/* HIDE APPS */}
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="hideApps">Hide applications</label>
|
<label htmlFor="hideApps">Hide applications</label>
|
||||||
|
|
|
@ -9,28 +9,28 @@ export interface WeatherForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GeneralForm {
|
export interface GeneralForm {
|
||||||
hideSearch: boolean;
|
|
||||||
defaultSearchProvider: string;
|
defaultSearchProvider: string;
|
||||||
searchSameTab: boolean;
|
searchSameTab: boolean;
|
||||||
disableAutofocus: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OtherSettingsForm {
|
|
||||||
customTitle: string;
|
|
||||||
pinAppsByDefault: boolean;
|
pinAppsByDefault: boolean;
|
||||||
pinCategoriesByDefault: boolean;
|
pinCategoriesByDefault: boolean;
|
||||||
hideHeader: boolean;
|
|
||||||
hideApps: boolean;
|
|
||||||
hideCategories: boolean;
|
|
||||||
useOrdering: string;
|
useOrdering: string;
|
||||||
appsSameTab: boolean;
|
appsSameTab: boolean;
|
||||||
bookmarksSameTab: boolean;
|
bookmarksSameTab: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UISettingsForm {
|
||||||
|
customTitle: string;
|
||||||
|
hideHeader: boolean;
|
||||||
|
hideApps: boolean;
|
||||||
|
hideCategories: boolean;
|
||||||
useAmericanDate: boolean;
|
useAmericanDate: boolean;
|
||||||
greetingsSchema: string;
|
greetingsSchema: string;
|
||||||
daySchema: string;
|
daySchema: string;
|
||||||
monthSchema: string;
|
monthSchema: string;
|
||||||
showTime: boolean;
|
showTime: boolean;
|
||||||
hideDate: boolean;
|
hideDate: boolean;
|
||||||
|
hideSearch: boolean;
|
||||||
|
disableAutofocus: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DockerSettingsForm {
|
export interface DockerSettingsForm {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
DockerSettingsForm,
|
DockerSettingsForm,
|
||||||
OtherSettingsForm,
|
UISettingsForm,
|
||||||
GeneralForm,
|
GeneralForm,
|
||||||
ThemeSettingsForm,
|
ThemeSettingsForm,
|
||||||
WeatherForm,
|
WeatherForm,
|
||||||
|
@ -10,5 +10,5 @@ export type ConfigFormData =
|
||||||
| WeatherForm
|
| WeatherForm
|
||||||
| GeneralForm
|
| GeneralForm
|
||||||
| DockerSettingsForm
|
| DockerSettingsForm
|
||||||
| OtherSettingsForm
|
| UISettingsForm
|
||||||
| ThemeSettingsForm;
|
| ThemeSettingsForm;
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
import {
|
import {
|
||||||
DockerSettingsForm,
|
DockerSettingsForm,
|
||||||
OtherSettingsForm,
|
UISettingsForm,
|
||||||
GeneralForm,
|
GeneralForm,
|
||||||
ThemeSettingsForm,
|
ThemeSettingsForm,
|
||||||
WeatherForm,
|
WeatherForm,
|
||||||
} from '../../interfaces';
|
} from '../../interfaces';
|
||||||
|
|
||||||
export const otherSettingsTemplate: OtherSettingsForm = {
|
export const uiSettingsTemplate: UISettingsForm = {
|
||||||
customTitle: document.title,
|
customTitle: document.title,
|
||||||
pinAppsByDefault: true,
|
|
||||||
pinCategoriesByDefault: true,
|
|
||||||
hideHeader: false,
|
hideHeader: false,
|
||||||
hideApps: false,
|
hideApps: false,
|
||||||
hideCategories: false,
|
hideCategories: false,
|
||||||
useOrdering: 'createdAt',
|
|
||||||
appsSameTab: false,
|
|
||||||
bookmarksSameTab: false,
|
|
||||||
useAmericanDate: false,
|
useAmericanDate: false,
|
||||||
greetingsSchema: 'Good evening!;Good afternoon!;Good morning!;Good night!',
|
greetingsSchema: 'Good evening!;Good afternoon!;Good morning!;Good night!',
|
||||||
daySchema: 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday',
|
daySchema: 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday',
|
||||||
|
@ -23,6 +18,8 @@ export const otherSettingsTemplate: OtherSettingsForm = {
|
||||||
'January;February;March;April;May;June;July;August;September;October;November;December',
|
'January;February;March;April;May;June;July;August;September;October;November;December',
|
||||||
showTime: false,
|
showTime: false,
|
||||||
hideDate: false,
|
hideDate: false,
|
||||||
|
hideSearch: false,
|
||||||
|
disableAutofocus: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const weatherSettingsTemplate: WeatherForm = {
|
export const weatherSettingsTemplate: WeatherForm = {
|
||||||
|
@ -34,10 +31,13 @@ export const weatherSettingsTemplate: WeatherForm = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const generalSettingsTemplate: GeneralForm = {
|
export const generalSettingsTemplate: GeneralForm = {
|
||||||
hideSearch: false,
|
|
||||||
searchSameTab: false,
|
searchSameTab: false,
|
||||||
defaultSearchProvider: 'l',
|
defaultSearchProvider: 'l',
|
||||||
disableAutofocus: false,
|
pinAppsByDefault: true,
|
||||||
|
pinCategoriesByDefault: true,
|
||||||
|
useOrdering: 'createdAt',
|
||||||
|
appsSameTab: false,
|
||||||
|
bookmarksSameTab: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const dockerSettingsTemplate: DockerSettingsForm = {
|
export const dockerSettingsTemplate: DockerSettingsForm = {
|
||||||
|
|
Loading…
Reference in a new issue