Skip to content

Commit

Permalink
frontend: input field variants
Browse files Browse the repository at this point in the history
the default config for some components have changed, so standard variant
had to be specified
  • Loading branch information
ErvinRacz committed Dec 19, 2024
1 parent 874ef2b commit aabfe8a
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 36 deletions.
4 changes: 3 additions & 1 deletion frontend/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],

addons: [
'@storybook/addon-links',
Expand All @@ -12,6 +12,8 @@ module.exports = {
options: {}
},

staticDirs: ['../public'],

docs: {
autodocs: true
}
Expand Down
9 changes: 6 additions & 3 deletions frontend/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import themesConf from '../src/lib/themes';
import { StylesProvider } from '@mui/styles';
import '../src/i18n/config';
import ThemeProviderNexti18n from '../src/i18n/ThemeProviderNexti18n';
import { StyledEngineProvider } from '@mui/material/styles';

const darkTheme = themesConf['dark'];
const lightTheme = themesConf['light'];
Expand All @@ -12,9 +13,11 @@ const withThemeProvider = (Story, context) => {
const theme = backgroundColor !== 'dark' ? lightTheme : darkTheme;

const ourThemeProvider = (
<ThemeProviderNexti18n theme={theme}>
<Story {...context} />
</ThemeProviderNexti18n>
<StyledEngineProvider injectFirst>
<ThemeProviderNexti18n theme={theme}>
<Story {...context} />
</ThemeProviderNexti18n>
</StyledEngineProvider>
);
if (process.env.NODE_ENV !== 'test') {
return ourThemeProvider;
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"lint:fix": "eslint -c package.json --fix 'src/**/*.{js,jsx,ts,tsx}'",
"i18n": "npx --no-install i18next ./src/**/ts* ./src/**/**/*.ts* ./src/**/**/**/*.ts* -c ./src/i18n/i18next-parser.config.js",
"tsc": "tsc",
"storybook": "storybook dev -p 6006 -s public",
"build-storybook": "storybook build -s public"
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"browserslist": {
"production": [
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/Activity/ActivityContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ const useStyles = makeStyles({
toolbar: {
padding: 0,
},
caption: {
select: {
fontSize: '.85em',
},
select: {
selectLabel: {
fontSize: '.85em',
},
displayedRows: {
fontSize: '.85em',
},
});
Expand Down Expand Up @@ -102,6 +105,8 @@ function Container() {
return entries;
}

console.log(classes);

return (
<>
<ListHeader title={t('activity|Activity')} />
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/Applications/ApplicationEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default function ApplicationEdit(props: ApplicationEditProps) {
<Field
name="name"
component={TextField}
variant="standard"
margin="dense"
label={t('frequent|Name')}
type="text"
Expand All @@ -84,6 +85,7 @@ export default function ApplicationEdit(props: ApplicationEditProps) {
<Field
name="product_id"
component={TextField}
variant="standard"
margin="dense"
label={t('frequent|Product ID')}
type="text"
Expand All @@ -93,6 +95,7 @@ export default function ApplicationEdit(props: ApplicationEditProps) {
<Field
name="description"
component={TextField}
variant="standard"
margin="dense"
label={t('frequent|Description')}
type="text"
Expand All @@ -102,6 +105,7 @@ export default function ApplicationEdit(props: ApplicationEditProps) {
<Field
type="text"
name="appToClone"
variant="standard"
label={t('applications|Groups/Channels')}
select
helperText={t(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Channels/ChannelAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ const useStyles = makeStyles((theme: Theme) => ({
export default function ChannelAvatar(props: ChannelAvatarProps) {
const classes = useStyles(props);

return <Avatar className={classes.colorAvatar}>{props.children || ''}</Avatar>;
return <Avatar className={classes.colorAvatar}>{props.children || ' '}</Avatar>;
}
5 changes: 3 additions & 2 deletions frontend/src/components/Channels/ChannelEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export default function ChannelEdit(props: ChannelEditProps) {
<Field
name="name"
component={TextField}
variant="standard"
margin="dense"
label={t('frequent|Name')}
InputLabelProps={{ shrink: true }}
Expand All @@ -199,8 +200,8 @@ export default function ChannelEdit(props: ChannelEditProps) {
</Grid>
</Grid>
</Grid>
<FormControl variant="standard" margin="dense" disabled={!isCreation} fullWidth>
<InputLabel>Architecture</InputLabel>
<FormControl margin="dense" disabled={!isCreation} fullWidth>
<InputLabel variant="standard">Architecture</InputLabel>
<MuiSelect
variant="standard"
value={arch}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function GroupDetailsForm(props: GroupDetailsFormProps) {
<Field
name="name"
component={TextField}
variant="standard"
margin="dense"
label="Name"
required
Expand All @@ -30,11 +31,14 @@ export default function GroupDetailsForm(props: GroupDetailsFormProps) {
/>
</Grid>
<Grid item xs={4}>
<FormControl variant="standard" margin="dense" fullWidth>
<InputLabel shrink>{t('groups|Channel')}</InputLabel>
<FormControl margin="dense" fullWidth>
<InputLabel variant="standard" shrink>
{t('groups|Channel')}
</InputLabel>
<Field
name="channel"
component={Select}
variant="standard"
displayEmpty
defaultValue={values.channel}
onChange={(e: any) => {
Expand All @@ -56,6 +60,7 @@ export default function GroupDetailsForm(props: GroupDetailsFormProps) {
<Field
name="track"
component={TextField}
variant="standard"
margin="dense"
label={t('groups|Track (identifier for clients, filled with the group ID if omitted)')}
fullWidth
Expand All @@ -66,6 +71,7 @@ export default function GroupDetailsForm(props: GroupDetailsFormProps) {
<Field
name="description"
component={TextField}
variant="standard"
margin="dense"
label={t('groups|Description')}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default function GroupPolicyForm(props: GroupPolicyFormProps) {
<Field
name="maxUpdates"
component={TextField}
variant="standard"
label={t('groups|Max number of updates')}
margin="dense"
type="number"
Expand All @@ -143,6 +144,7 @@ export default function GroupPolicyForm(props: GroupPolicyFormProps) {
<Field
name="updatesPeriodRange"
component={TextField}
variant="standard"
margin="dense"
type="number"
fullWidth
Expand All @@ -156,6 +158,7 @@ export default function GroupPolicyForm(props: GroupPolicyFormProps) {
<Field
name="updatesPeriodUnit"
component={TextField}
variant="standard"
margin="dense"
select
fullWidth
Expand All @@ -182,6 +185,7 @@ export default function GroupPolicyForm(props: GroupPolicyFormProps) {
<Field
name="updatesTimeout"
component={TextField}
variant="standard"
margin="dense"
type="number"
defaultValue={values.updatesTimeout}
Expand All @@ -193,6 +197,7 @@ export default function GroupPolicyForm(props: GroupPolicyFormProps) {
<Field
name="updatesTimeoutUnit"
component={TextField}
variant="standard"
margin="dense"
select
fullWidth
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Instances/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="name"
component={TextField}
variant="standard"
margin="dense"
label={t('instances|Name')}
type="text"
Expand Down
12 changes: 5 additions & 7 deletions frontend/src/components/Instances/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ function InstanceFilter(props: InstanceFilterProps) {
<Box pr={2}>
<Grid container spacing={2} justifyContent="flex-end">
<Grid item xs={5}>
<FormControl variant="standard" fullWidth disabled={props.disabled}>
<InputLabel htmlFor="select-status" shrink>
<FormControl fullWidth disabled={props.disabled}>
<InputLabel variant="standard" htmlFor="select-status" shrink>
{t('instances|Filter Status')}
</InputLabel>
<Select
variant="standard"
onChange={(event: any) => changeFilter('status', event.target.value)}
input={<Input id="select-status" />}
renderValue={(selected: any) =>
Expand All @@ -107,12 +106,11 @@ function InstanceFilter(props: InstanceFilterProps) {
</FormControl>
</Grid>
<Grid item xs={5}>
<FormControl variant="standard" fullWidth disabled={props.disabled}>
<InputLabel htmlFor="select-versions" shrink>
<FormControl fullWidth disabled={props.disabled}>
<InputLabel variant="standard" htmlFor="select-versions" shrink>
{t('instances|Filter Version')}
</InputLabel>
<Select
variant="standard"
onChange={(event: SelectChangeEvent<string>) =>
changeFilter('version', event.target.value)
}
Expand Down Expand Up @@ -419,7 +417,7 @@ function ListView(props: { application: Application; group: Group }) {
</Box>
</Grid>
<Grid item>
<InputLabel htmlFor="instance-search-filter" shrink>
<InputLabel variant="standard" htmlFor="instance-search-filter" shrink>
{t('frequent|Search')}
</InputLabel>
<SearchInput
Expand Down
19 changes: 13 additions & 6 deletions frontend/src/components/Packages/EditDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ function EditDialog(props: EditDialogProps) {
)}
<Grid container justifyContent="space-between">
<Grid item>
<FormControl variant="standard" margin="dense" className={classes.topSelect}>
<InputLabel>Type</InputLabel>
<FormControl margin="dense" className={classes.topSelect}>
<InputLabel variant="standard">Type</InputLabel>
<MuiSelect
variant="standard"
value={packageType}
Expand All @@ -159,13 +159,12 @@ function EditDialog(props: EditDialogProps) {
</Grid>
<Grid item>
<FormControl
variant="standard"
margin="dense"
fullWidth
className={classes.topSelect}
disabled={!isCreation}
>
<InputLabel>{t('packages|Architecture')}</InputLabel>
<InputLabel variant="standard">{t('packages|Architecture')}</InputLabel>
<MuiSelect variant="standard" value={arch} onChange={handleArchChange}>
{Object.keys(ARCHES).map((key: string) => {
const archName = ARCHES[parseInt(key)];
Expand All @@ -191,6 +190,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="url"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|URL')}
type="url"
Expand All @@ -200,6 +200,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="filename"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Filename')}
type="text"
Expand All @@ -209,6 +210,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="description"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Description')}
type="text"
Expand All @@ -220,6 +222,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="version"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Version')}
type="text"
Expand All @@ -232,6 +235,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="size"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Size')}
type="number"
Expand All @@ -244,6 +248,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="hash"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Hash')}
type="text"
Expand All @@ -257,6 +262,7 @@ function EditDialog(props: EditDialogProps) {
<Field
name="flatcarHash"
component={TextField}
variant="standard"
margin="dense"
label={t('packages|Flatcar Action SHA256')}
type="text"
Expand All @@ -267,11 +273,12 @@ function EditDialog(props: EditDialogProps) {
fullWidth
/>
)}
<FormControl variant="standard" margin="dense" fullWidth>
<InputLabel>Channels Blacklist</InputLabel>
<FormControl margin="dense" fullWidth>
<InputLabel variant="standard">Channels Blacklist</InputLabel>
<Field
name="channelsBlacklist"
component={Select}
variant="standard"
multiple
renderValue={(selected: string[]) =>
getChannelsNames(selected).join(' / ')
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/components/Packages/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function FileListItem(props: FileListItemProps) {
</Grid>
<Grid item xs={12}>
<TextField
variant="standard"
name="name"
margin="dense"
label={t('packages|Name')}
Expand All @@ -123,7 +122,6 @@ function FileListItem(props: FileListItemProps) {
<Grid item container spacing={1}>
<Grid item xs={6}>
<TextField
variant="standard"
name="size"
margin="dense"
label={t('packages|Size')}
Expand All @@ -138,7 +136,6 @@ function FileListItem(props: FileListItemProps) {
</Grid>
<Grid item xs={6}>
<TextField
variant="standard"
name="hash"
margin="dense"
label={t('packages|SHA1 Hash (base64)')}
Expand All @@ -155,7 +152,6 @@ function FileListItem(props: FileListItemProps) {
</Grid>
<Grid item xs={6}>
<TextField
variant="standard"
name="hash256"
margin="dense"
label={t('packages|SHA256 Hash (hex)')}
Expand Down
Loading

0 comments on commit aabfe8a

Please sign in to comment.