feat(ui): add optional token for auth

This commit is contained in:
Mary Hipp 2023-04-05 13:08:39 -04:00
parent f6c6f61da6
commit e69a65b304
2 changed files with 7 additions and 0 deletions

View File

@ -71,6 +71,7 @@ interface InvokeProps extends PropsWithChildren {
apiUrl?: string; apiUrl?: string;
disabledPanels?: string[]; disabledPanels?: string[];
disabledTabs?: InvokeTabName[]; disabledTabs?: InvokeTabName[];
token?: string;
} }
declare function Invoke(props: InvokeProps): JSX.Element; declare function Invoke(props: InvokeProps): JSX.Element;

View File

@ -27,18 +27,24 @@ interface Props extends PropsWithChildren {
apiUrl?: string; apiUrl?: string;
disabledPanels?: string[]; disabledPanels?: string[];
disabledTabs?: InvokeTabName[]; disabledTabs?: InvokeTabName[];
token?: string;
} }
export default function Component({ export default function Component({
apiUrl, apiUrl,
disabledPanels = [], disabledPanels = [],
disabledTabs = [], disabledTabs = [],
token,
children, children,
}: Props) { }: Props) {
useEffect(() => { useEffect(() => {
if (apiUrl) OpenAPI.BASE = apiUrl; if (apiUrl) OpenAPI.BASE = apiUrl;
}, [apiUrl]); }, [apiUrl]);
useEffect(() => {
if (token) OpenAPI.TOKEN = token;
}, [token]);
return ( return (
<React.StrictMode> <React.StrictMode>
<Provider store={store}> <Provider store={store}>