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

Fix Errors & Warnings #1074

Merged
merged 4 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions src/Components/Configuration/EditCard/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ function Base(props: BaseExtendedProps): ReactElement | null {
className={classes.textField}
InputLabelProps={{ shrink: true }}
label="Title"
placeholder={'Card Title'}
value={props.card.title}
placeholder="Card Title"
value={props.card.title || 'Card'}
onChange={props.handleChange && props.handleChange('title')}
/>
</Grid>
Expand All @@ -112,7 +112,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
<FormControl className={classes.textField}>
<InputLabel htmlFor="type">Type</InputLabel>
<Select
value={props.card.type}
value={props.card.type || 'entity'}
onChange={props.handleSelectChange}
inputProps={{
name: 'type',
Expand Down Expand Up @@ -140,7 +140,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
type="number"
label="Elevation"
placeholder="1"
value={props.card.elevation}
value={props.card.elevation || '1'}
onChange={props.handleChange && props.handleChange('elevation')}
/>
</Grid>
Expand All @@ -158,7 +158,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
/>
),
}}
value={props.card.background}
value={props.card.background || 'default'}
onChange={props.handleChange && props.handleChange('background')}
/>
</Grid>
Expand All @@ -175,7 +175,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
InputLabelProps={{ shrink: true }}
label="Padding"
placeholder="12px"
value={props.card.padding}
value={props.card.padding || '12px'}
onChange={props.handleChange && props.handleChange('padding')}
/>
</Grid>
Expand Down Expand Up @@ -206,7 +206,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
type="number"
label="Width"
placeholder="1"
value={props.card.width}
value={props.card.width || '1'}
onChange={props.handleChange && props.handleChange('width')}
/>
</Grid>
Expand All @@ -218,7 +218,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
type="number"
label="Height"
placeholder="1"
value={props.card.height}
value={props.card.height || '1'}
onChange={props.handleChange && props.handleChange('height')}
/>
</Grid>
Expand All @@ -235,7 +235,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
<FormControl className={classes.textField}>
<InputLabel htmlFor="title_justify">Title Justify</InputLabel>
<Select
value={props.card.title_justify}
value={props.card.title_justify || 'left'}
onChange={props.handleSelectChange}
inputProps={{
name: 'title_justify',
Expand All @@ -257,7 +257,7 @@ function Base(props: BaseExtendedProps): ReactElement | null {
type="text"
label="Title Font Size"
placeholder="initial"
value={props.card.title_size}
value={props.card.title_size || 'initial'}
onChange={props.handleChange && props.handleChange('title_size')}
/>
</Grid>
Expand Down
16 changes: 7 additions & 9 deletions src/Components/Configuration/EditCard/Entity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Entity(props: EntityProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Entity"
placeholder="sensor.myamazingsensor"
value={props.card.entity}
value={props.card.entity || ''}
onChange={props.handleChange && props.handleChange('entity')}
/>
)}
Expand All @@ -121,7 +121,7 @@ function Entity(props: EntityProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Icon"
placeholder="thermometer"
value={props.card.icon}
value={props.card.icon || ''}
onChange={props.handleChange && props.handleChange('icon')}
/>
</Grid>
Expand Down Expand Up @@ -152,7 +152,7 @@ function Entity(props: EntityProps): ReactElement {
type="text"
label="Icon Size"
placeholder="initial"
value={props.card.icon_size}
value={props.card.icon_size || 'initial'}
onChange={props.handleChange && props.handleChange('icon_size')}
/>
</Grid>
Expand All @@ -165,7 +165,7 @@ function Entity(props: EntityProps): ReactElement {
type="text"
label="State Font Size"
placeholder="initial"
value={props.card.state_size}
value={props.card.state_size || 'initial'}
onChange={
props.handleChange && props.handleChange('state_size')
}
Expand All @@ -184,7 +184,7 @@ function Entity(props: EntityProps): ReactElement {
<FormControl className={classes.textField}>
<InputLabel htmlFor="chart">Chart</InputLabel>
<Select
value={props.card.chart ? props.card.chart : ''}
value={props.card.chart || ''}
onChange={props.handleSelectChange}
inputProps={{
name: 'chart',
Expand Down Expand Up @@ -214,9 +214,7 @@ function Entity(props: EntityProps): ReactElement {
<FormControl className={classes.textField}>
<InputLabel htmlFor="chart_detail">Chart Detail</InputLabel>
<Select
value={
props.card.chart_detail ? props.card.chart_detail : 3
}
value={props.card.chart_detail || 3}
onChange={props.handleSelectChange}
inputProps={{
name: 'chart_detail',
Expand Down Expand Up @@ -245,7 +243,7 @@ function Entity(props: EntityProps): ReactElement {
min: 1,
max: 48,
}}
value={props.card.chart_from}
value={props.card.chart_from || '6'}
onChange={
props.handleChange && props.handleChange('chart_from')
}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Configuration/EditCard/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Frame(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="URL"
placeholder="https://timmo.dev/home-panel"
value={props.card.url}
value={props.card.url || ''}
onChange={props.handleChange && props.handleChange('url')}
/>
</Grid>
Expand All @@ -33,7 +33,7 @@ function Frame(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Height"
placeholder="auto"
value={props.card.height}
value={props.card.height || 'auto'}
onChange={props.handleChange && props.handleChange('height')}
/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Configuration/EditCard/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Image(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="URL"
placeholder="https://timmo.dev/home-panel"
value={props.card.url}
value={props.card.url || ''}
onChange={props.handleChange && props.handleChange('url')}
/>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Configuration/EditCard/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Markdown(props: BaseProps): ReactElement {
multiline
label="Content"
placeholder="- Markdown"
value={props.card.content}
value={props.card.content || ''}
onChange={props.handleChange && props.handleChange('content')}
/>
</Grid>
Expand All @@ -34,7 +34,7 @@ function Markdown(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Height"
placeholder="auto"
value={props.card.height}
value={props.card.height || 'auto'}
onChange={props.handleChange && props.handleChange('height')}
/>
</Grid>
Expand Down
9 changes: 6 additions & 3 deletions src/Components/Configuration/EditCard/News.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useStyles = makeStyles(() => ({

function News(props: BaseProps): ReactElement {
const [sources, setSources] = useState<Option[]>();
const [source, setSource] = useState<Option | null>();
const [source, setSource] = useState<Option | null>(null);
const [error, setError] = useState<string>();

function handleChange(
Expand Down Expand Up @@ -81,7 +81,7 @@ function News(props: BaseProps): ReactElement {
disabled
InputLabelProps={{ shrink: true }}
label="Source"
value={error}
value={error || ''}
/>
) : (
sources && (
Expand All @@ -90,6 +90,9 @@ function News(props: BaseProps): ReactElement {
fullWidth
options={sources}
getOptionLabel={(option: Option): string => option.label}
getOptionSelected={(option: Option): boolean =>
option.value === source?.value
}
value={source}
onChange={handleChange}
renderInput={(params): ReactElement => (
Expand All @@ -105,7 +108,7 @@ function News(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Height"
placeholder="auto"
value={props.card.height}
value={props.card.height || 'auto'}
onChange={props.handleChange && props.handleChange('height')}
/>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Configuration/EditCard/RSS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function RSS(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="URL"
placeholder="https://status.home-assistant.io/history.rss"
value={props.card.url}
value={props.card.url || ''}
onChange={props.handleChange && props.handleChange('url')}
/>
</Grid>
Expand All @@ -33,7 +33,7 @@ function RSS(props: BaseProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Height"
placeholder="auto"
value={props.card.height}
value={props.card.height || 'auto'}
onChange={props.handleChange && props.handleChange('height')}
/>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Configuration/EditGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function EditGroup(props: EditGroupProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Name"
placeholder={'Group Name'}
defaultValue={props.group.name}
defaultValue={props.group.name || ''}
onChange={handleChange('name')}
/>
</Grid>
Expand All @@ -92,7 +92,7 @@ function EditGroup(props: EditGroupProps): ReactElement {
type="number"
label="Width"
placeholder="2"
defaultValue={props.group.width}
defaultValue={props.group.width || ''}
onChange={handleChange('width')}
/>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Configuration/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function EditPage(props: EditPageProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Name"
placeholder={'Page Name'}
defaultValue={props.page.name}
defaultValue={props.page.name || ''}
onChange={handleChange('name')}
/>
</Grid>
Expand All @@ -131,7 +131,7 @@ function EditPage(props: EditPageProps): ReactElement {
InputLabelProps={{ shrink: true }}
label="Icon"
placeholder={'home'}
defaultValue={props.page.icon}
defaultValue={props.page.icon || ''}
onChange={handleChange('icon')}
/>
</Grid>
Expand Down
10 changes: 5 additions & 5 deletions src/Components/Configuration/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function Item(props: ItemProps): ReactElement {
/>
),
}}
value={value}
value={value || ''}
onChange={handleChange(props.path, 'color')}
/>
);
Expand All @@ -200,7 +200,7 @@ function Item(props: ItemProps): ReactElement {
className={classes.root}
placeholder={String(props.item.default)}
type={typeof props.item.default === 'number' ? 'number' : 'text'}
value={value}
value={value || ''}
onChange={handleChange(
props.path,
typeof props.item.default === 'number' ? 'number' : 'string'
Expand All @@ -213,7 +213,7 @@ function Item(props: ItemProps): ReactElement {
className={classes.root}
type={showPassword ? 'text' : 'password'}
placeholder={String(props.item.default)}
value={value}
value={value || ''}
onChange={handleChange(
props.path,
typeof props.item.default === 'number' ? 'number' : 'string'
Expand All @@ -239,7 +239,7 @@ function Item(props: ItemProps): ReactElement {
className={classes.radioGroup}
aria-label={props.item.title}
name={typeof props.item.name === 'string' ? props.item.name : ''}
value={value}
value={value || ''}
onChange={handleRadioChange(props.path)}>
{props.item.items &&
props.item.items.map(
Expand All @@ -252,7 +252,7 @@ function Item(props: ItemProps): ReactElement {
return (
<FormControlLabel
key={key}
value={key}
value={key || ''}
label={rItem}
control={<Radio color="primary" />}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HomeAssistant/Cards/AlarmPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function AlarmPanel(props: EntityProps): ReactElement | null {
disabled={props.entity.state === 'pending'}
placeholder="1234"
type="number"
value={code}
value={code || ''}
onChange={handleCodeChange}
/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HomeAssistant/Cards/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ function Media(props: EntityProps): ReactElement | null {
{(!props.card.width || props.card.width > 2) && (
<Grid item>
<Select
value={props.entity.attributes.source}
value={props.entity.attributes.source || ''}
disabled={
!props.entity.attributes.source_list ||
props.entity.state === 'off'
Expand Down
4 changes: 2 additions & 2 deletions src/Components/HomeAssistant/Cards/Number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function NumberEntity(props: EntityProps): ReactElement {
<Slider
onChange={handleSliderChange}
onChangeCommitted={handleSliderChangeComplete}
value={number}
value={number || 0}
getAriaValueText={(value: number): string => `${value}`}
aria-labelledby="input-slider"
valueLabelDisplay="auto"
Expand All @@ -120,7 +120,7 @@ function NumberEntity(props: EntityProps): ReactElement {
) : (
<Grid item>
<Input
value={number}
value={number || 0}
margin="dense"
onChange={handleInputChange}
onBlur={handleBlur}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HomeAssistant/Cards/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function TextEntity(props: EntityProps): ReactElement {
justify="center">
<Grid item>
<Input
value={text}
value={text || ''}
margin="dense"
onChange={handleInputChange}
inputProps={{
Expand Down
2 changes: 1 addition & 1 deletion src/Components/HomeAssistant/HomeAssistantLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function HomeAssistantLogin(props: HomeAssistantLoginProps): ReactElement {
autoCapitalize: 'none',
autoComplete: 'url',
}}
value={url}
value={url || ''}
onChange={handleChange}
/>
</FormControl>
Expand Down
Loading