Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PUI] User settings panel updates #7944

Merged
merged 32 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
d5431f5
Simplify user theme settings
SchrodingersGat Aug 21, 2024
dd1d5dc
Cleanup
SchrodingersGat Aug 21, 2024
c83feb1
Fix permission on user list endpoint
SchrodingersGat Aug 21, 2024
cae3c50
Update AccountDetailPanel to use modal form
SchrodingersGat Aug 21, 2024
0d06ffd
Update components
SchrodingersGat Aug 21, 2024
4e27371
Merge branch 'master' of github.com:inventree/InvenTree into theme-si…
SchrodingersGat Aug 21, 2024
b9f8604
UI updates
SchrodingersGat Aug 22, 2024
a8ff676
Implement default colors
SchrodingersGat Aug 22, 2024
19f25f8
Display more user details (read only)
SchrodingersGat Aug 22, 2024
16f56ea
Add specific "MeUserSerializer"
SchrodingersGat Aug 22, 2024
fc36f0b
Add <YesNoUndefinedButton>
SchrodingersGat Aug 22, 2024
682dbc8
Allow role checks to be bypassed for a given view
SchrodingersGat Aug 22, 2024
1657595
Enable 'GET' metadata
SchrodingersGat Aug 22, 2024
f3acd22
Add info on new user account
SchrodingersGat Aug 22, 2024
d02b702
Merge branch 'master' into theme-simplificatio
SchrodingersGat Aug 23, 2024
aa24235
Merge branch 'master' into theme-simplificatio
SchrodingersGat Aug 25, 2024
937f797
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 5, 2024
14487ad
Fix boolean expression wrapper
SchrodingersGat Sep 5, 2024
8d4b2d0
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 5, 2024
792dcaa
Ruff fixes
SchrodingersGat Sep 5, 2024
2c8ef50
Adjust icon
SchrodingersGat Sep 5, 2024
fe18d78
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 5, 2024
8071ded
Update unit test
SchrodingersGat Sep 6, 2024
19dd6ee
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 6, 2024
55a2d02
Bummp API version
SchrodingersGat Sep 6, 2024
698ca9f
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 6, 2024
467c9c1
Merge remote-tracking branch 'origin/master' into theme-simplificatio
SchrodingersGat Sep 6, 2024
fb97e2d
Merge branch 'theme-simplificatio' of github.com:SchrodingersGat/Inve…
SchrodingersGat Sep 6, 2024
e23f4d1
Merge remote-tracking branch 'origin/master' into theme-simplificatio
SchrodingersGat Sep 9, 2024
61a0acf
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 10, 2024
a2f7dc3
Merge branch 'master' into theme-simplificatio
SchrodingersGat Sep 14, 2024
bbcd6b4
Table layout fix
SchrodingersGat Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Container, Grid, SimpleGrid } from '@mantine/core';

import { AccountDetailPanel } from './AccountDetailPanel';
import { DisplaySettingsPanel } from './DisplaySettingsPanel';
import { UserTheme } from './UserThemePanel';

export function AccountContent() {
Expand All @@ -18,9 +17,6 @@ export function AccountContent() {
<Grid.Col>
<UserTheme height={SECONDARY_COL_HEIGHT} />
</Grid.Col>
<Grid.Col>
<DisplaySettingsPanel height={SECONDARY_COL_HEIGHT} />
</Grid.Col>
</Grid>
</SimpleGrid>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Trans, t } from '@lingui/macro';
import {
ColorInput,
Button,
ColorPicker,
Container,
DEFAULT_THEME,
Group,
Loader,
Select,
Slider,
Table,
Title
Title,
useMantineTheme
} from '@mantine/core';
import { useState } from 'react';

import { SizeMarks } from '../../../../defaults/defaults';
import { ColorToggle } from '../../../../components/items/ColorToggle';
import { LanguageSelect } from '../../../../components/items/LanguageSelect';
import { IS_DEV } from '../../../../main';
import { useLocalState } from '../../../../states/LocalState';
import { theme } from '../../../../theme';

function getLkp(color: string) {
return { [DEFAULT_THEME.colors[color][6]]: color };
Expand All @@ -26,50 +26,29 @@ const LOOKUP = Object.assign(
);

export function UserTheme({ height }: { height: number }) {
// primary color
const [themeLoader, setThemeLoader] = useLocalState((state) => [
state.loader,
state.setLoader
]);

const theme = useMantineTheme();

// Set theme primary color
function changePrimary(color: string) {
useLocalState.setState({ primaryColor: LOOKUP[color] });
}
// white color
const [whiteColor, setWhiteColor] = useState(theme.white);
function changeWhite(color: string) {
useLocalState.setState({ whiteColor: color });
setWhiteColor(color);
}
// black color
const [blackColor, setBlackColor] = useState(theme.black);
function changeBlack(color: string) {
useLocalState.setState({ blackColor: color });
setBlackColor(color);
}
// radius
function getMark(value: number) {
const obj = SizeMarks.find((mark) => mark.value === value);
if (obj) return obj;
return SizeMarks[0];
}
function getDefaultRadius() {
const obj = SizeMarks.find(
(mark) => mark.label === useLocalState.getState().radius
);
if (obj) return obj.value;
return 50;
}
const [radius, setRadius] = useState(getDefaultRadius());
function changeRadius(value: number) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I get this right, that this removes the ability to use a "rounder" radius than by default? I really liked to set it to a rounder radius than default, so this was really helpful. I once thought about defining default options on the via the config/env for these values here, because I always have to change this on a new client, and I know that pushing a rounder radius to core is not well liked by others.

setRadius(value);
useLocalState.setState({ radius: getMark(value).label });

function enablePseudoLang(): void {
useLocalState.setState({ language: 'pseudo-LOCALE' });
}
// loader

// Custom loading indicator
const loaderDate = [
{ value: 'bars', label: t`bars` },
{ value: 'oval', label: t`oval` },
{ value: 'dots', label: t`dots` }
{ value: 'bars', label: t`Bars` },
{ value: 'oval', label: t`Oval` },
{ value: 'dots', label: t`Dots` }
];
const [themeLoader, setThemeLoader] = useLocalState((state) => [
state.loader,
state.setLoader
]);

function changeLoader(value: string | null) {
if (value === null) return;
setThemeLoader(value);
Expand All @@ -78,69 +57,72 @@ export function UserTheme({ height }: { height: number }) {
return (
<Container w="100%" mih={height} p={0}>
<Title order={3}>
<Trans>Theme</Trans>
<Trans>Display Settings</Trans>
</Title>
<Table>
<Table.Tbody>
<Table.Tr>
<Table.Td>
<Trans>Primary color</Trans>
</Table.Td>
<Table.Td>
<ColorPicker
format="hex"
onChange={changePrimary}
withPicker={false}
swatches={Object.keys(LOOKUP)}
/>
</Table.Td>
</Table.Tr>
<Table.Tr>
<Table.Td>
<Trans>White color</Trans>
<Trans>Language</Trans>
</Table.Td>
<Table.Td>
<ColorInput value={whiteColor} onChange={changeWhite} />
</Table.Td>
</Table.Tr>
<Table.Tr>
<Table.Td>
<Trans>Black color</Trans>
<LanguageSelect width={200} />
</Table.Td>
<Table.Td>
<ColorInput value={blackColor} onChange={changeBlack} />
{IS_DEV && (
<Button onClick={enablePseudoLang} variant="light">
<Trans>Use pseudo language</Trans>
</Button>
)}
</Table.Td>
</Table.Tr>
<Table.Tr>
<Table.Td>
<Trans>Border Radius</Trans>
<Trans>Color Mode</Trans>
</Table.Td>
<Table.Td>
<Slider
label={(val) => getMark(val).label}
defaultValue={50}
step={25}
marks={SizeMarks}
value={radius}
onChange={changeRadius}
mb={18}
/>
<Group justify="left">
<ColorToggle />
</Group>
</Table.Td>
<Table.Td></Table.Td>
</Table.Tr>
<Table.Tr>
<Table.Td>
<Trans>Loader</Trans>
</Table.Td>
<Table.Td>
<Group align="center">
<Group justify="left">
<Select
data={loaderDate}
value={themeLoader}
onChange={changeLoader}
/>
<Loader type={themeLoader} mah={18} />
</Group>
</Table.Td>
<Table.Td>
<Group justify="left">
<Loader type={themeLoader} mah={16} size="sm" />
</Group>
</Table.Td>
</Table.Tr>
<Table.Tr>
<Table.Td>
<Trans>Highlight color</Trans>
</Table.Td>
<Table.Td>
<ColorPicker
format="hex"
onChange={changePrimary}
withPicker={false}
swatches={Object.keys(LOOKUP)}
/>
</Table.Td>
<Table.Td>
<Button color={theme.primaryColor} variant="light">
<Trans>Example</Trans>
</Button>
</Table.Td>
</Table.Tr>
</Table.Tbody>
</Table>
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/tables/InvenTreeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function InvenTreeTable<T = any>({
getTableColumnNames,
setTableColumnNames,
getTableSorting,
setTableSorting
setTableSorting,
loader
} = useLocalState();
const [fieldNames, setFieldNames] = useState<Record<string, string>>({});

Expand Down Expand Up @@ -699,7 +700,7 @@ export function InvenTreeTable<T = any>({
withTableBorder
striped
highlightOnHover
loaderType="dots"
loaderType={loader}
pinLastColumn={tableProps.rowActions != undefined}
idAccessor={tableProps.idAccessor}
minHeight={300}
Expand Down
Loading