Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/plugins/lists/base/AddFab/AddEntryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const errorStyle = (theme: Theme) => css`

const AddEntryDialog: FC<Props> = ({ open = false, onClose }) => {
const { addEntryProps } = usePluginContainer();
const { addEntryOptionalProps } = usePluginContainer();
const initialValues: Record<string, string> = addEntryProps.reduce(
(obj, { name }) => ({
...obj,
Expand Down Expand Up @@ -63,6 +64,16 @@ const AddEntryDialog: FC<Props> = ({ open = false, onClose }) => {
autoFocus={index === 0}
/>
))}
{addEntryOptionalProps?.map(({ name, label, type, arrayid }, index) => (
<TextField
key={name}
id={name}
label={label}
type={type}
fullWidth
name={type === 'array' ? `${arrayid}[${index - 1}].${name}` : name}
/>
))}
</DialogContent>
<DialogActions>
<Button onClick={onClose} type="button">
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/lists/base/hooks/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface EntryFields {
label: string;
name: string;
type?: string;
arrayid?: string;
}

interface ListState<T extends Entry> {
Expand All @@ -44,6 +45,7 @@ interface ListState<T extends Entry> {
useMenuProps?: () => OverflowMenuProps[];
sortByOptions: Option[];
addEntryProps: EntryFields[];
addEntryOptionalProps?: EntryFields[];
}

const PluginContext = createContext<unknown>(null);
Expand Down
19 changes: 18 additions & 1 deletion src/plugins/lists/movies/hooks.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo, useCallback } from 'react';
import { useFlexgetAPI, APIRequest, RequestState } from 'core/api';
import { Method, camelize } from 'utils/fetch';
import { SortBy, Movie } from './types';
import { SortBy, Movie, MovieIds } from './types';
import { createPluginContainer } from '../base/hooks/api';

const movieToEntry = (movie: Movie): Movie => ({
Expand Down Expand Up @@ -73,11 +73,28 @@ export const MovieListContainer = createPluginContainer(() => {
label: 'Movie Name',
name: 'movieName',
},
],
[],
),
addEntryOptionalProps: useMemo(
() => [
{
label: 'Movie Year',
name: 'movieYear',
type: 'number',
},
{
label: 'IMDB ID',
name: MovieIds.IMDB,
type: 'array',
arrayid: 'movie_identifiers',
},
{
label: 'TMDB ID',
name: MovieIds.TMDB,
type: 'array',
arrayid: 'movie_identifiers',
},
],
[],
),
Expand Down