refactor: migrate chakra alert to custom component

This commit is contained in:
Carlos Valente
2025-02-17 14:12:20 +01:00
committed by Carlos Valente
parent 10bf4b93ee
commit c8bf74a719
7 changed files with 78 additions and 115 deletions
@@ -14,7 +14,6 @@ interface ExternalLinkProps {
export default function ExternalLink(props: ExternalLinkProps) { export default function ExternalLink(props: ExternalLinkProps) {
const { href, inline, children } = props; const { href, inline, children } = props;
const classes = cx([style.link, inline ? style.inline : null]);
const handleClick = (event: MouseEvent) => { const handleClick = (event: MouseEvent) => {
event.preventDefault(); event.preventDefault();
@@ -22,8 +21,14 @@ export default function ExternalLink(props: ExternalLinkProps) {
}; };
return ( return (
<a href='#!' target='_blank' rel='noreferrer' className={classes} onClick={handleClick}> <a
{children} <IoOpenOutline /> href='#!'
target='_blank'
rel='noreferrer'
className={cx([style.link, inline && style.inline])}
onClick={handleClick}
>
{children} <IoOpenOutline style={{ fontSize: '1em' }} />
</a> </a>
); );
} }
@@ -1,16 +1,6 @@
import { useEffect, useMemo } from 'react'; import { useEffect, useMemo } from 'react';
import { Controller, useFieldArray, useForm } from 'react-hook-form'; import { Controller, useFieldArray, useForm } from 'react-hook-form';
import { import { Button, IconButton, Input, Radio, RadioGroup, Select } from '@chakra-ui/react';
Alert,
AlertDescription,
AlertIcon,
Button,
IconButton,
Input,
Radio,
RadioGroup,
Select,
} from '@chakra-ui/react';
import { IoAdd } from '@react-icons/all-files/io5/IoAdd'; import { IoAdd } from '@react-icons/all-files/io5/IoAdd';
import { IoTrash } from '@react-icons/all-files/io5/IoTrash'; import { IoTrash } from '@react-icons/all-files/io5/IoTrash';
import { Automation, AutomationDTO, HTTPOutput, isHTTPOutput, isOSCOutput, OSCOutput } from 'ontime-types'; import { Automation, AutomationDTO, HTTPOutput, isHTTPOutput, isOSCOutput, OSCOutput } from 'ontime-types';
@@ -18,6 +8,7 @@ import { Automation, AutomationDTO, HTTPOutput, isHTTPOutput, isOSCOutput, OSCOu
import { addAutomation, editAutomation, testOutput } from '../../../../common/api/automation'; import { addAutomation, editAutomation, testOutput } from '../../../../common/api/automation';
import { maybeAxiosError } from '../../../../common/api/utils'; import { maybeAxiosError } from '../../../../common/api/utils';
import ExternalLink from '../../../../common/components/external-link/ExternalLink'; import ExternalLink from '../../../../common/components/external-link/ExternalLink';
import Info from '../../../../common/components/info/Info';
import Tag from '../../../../common/components/tag/Tag'; import Tag from '../../../../common/components/tag/Tag';
import useAutomationSettings from '../../../../common/hooks-query/useAutomationSettings'; import useAutomationSettings from '../../../../common/hooks-query/useAutomationSettings';
import useCustomFields from '../../../../common/hooks-query/useCustomFields'; import useCustomFields from '../../../../common/hooks-query/useCustomFields';
@@ -291,13 +282,10 @@ export default function AutomationForm(props: AutomationFormProps) {
<div className={style.innerColumn}> <div className={style.innerColumn}>
<h3>Outputs</h3> <h3>Outputs</h3>
<Alert status='info' variant='ontime-on-dark-info'> <Info>
<AlertIcon /> Automation outputs can be used to send data from Ontime to external software.
<AlertDescription> <ExternalLink href={integrationsDocsUrl}>See the documentation for templates</ExternalLink>
Automation outputs can be used to send data from Ontime to external software. </Info>
<ExternalLink href={integrationsDocsUrl}>See the documentation for templates</ExternalLink>
</AlertDescription>
</Alert>
{fieldOutputs.map((output, index) => { {fieldOutputs.map((output, index) => {
if (isOSCOutput(output)) { if (isOSCOutput(output)) {
@@ -1,6 +1,6 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { useFieldArray, useForm } from 'react-hook-form'; import { useFieldArray, useForm } from 'react-hook-form';
import { Alert, AlertDescription, AlertIcon, Button, IconButton, Input, Switch } from '@chakra-ui/react'; import { Button, IconButton, Input, Switch } from '@chakra-ui/react';
import { IoAdd } from '@react-icons/all-files/io5/IoAdd'; import { IoAdd } from '@react-icons/all-files/io5/IoAdd';
import { IoOpenOutline } from '@react-icons/all-files/io5/IoOpenOutline'; import { IoOpenOutline } from '@react-icons/all-files/io5/IoOpenOutline';
import { IoTrash } from '@react-icons/all-files/io5/IoTrash'; import { IoTrash } from '@react-icons/all-files/io5/IoTrash';
@@ -10,6 +10,7 @@ import { postUrlPresets } from '../../../../common/api/urlPresets';
import { maybeAxiosError } from '../../../../common/api/utils'; import { maybeAxiosError } from '../../../../common/api/utils';
import TooltipActionBtn from '../../../../common/components/buttons/TooltipActionBtn'; import TooltipActionBtn from '../../../../common/components/buttons/TooltipActionBtn';
import ExternalLink from '../../../../common/components/external-link/ExternalLink'; import ExternalLink from '../../../../common/components/external-link/ExternalLink';
import Info from '../../../../common/components/info/Info';
import useUrlPresets from '../../../../common/hooks-query/useUrlPresets'; import useUrlPresets from '../../../../common/hooks-query/useUrlPresets';
import { preventEscape } from '../../../../common/utils/keyEvent'; import { preventEscape } from '../../../../common/utils/keyEvent';
import { handleLinks } from '../../../../common/utils/linkUtils'; import { handleLinks } from '../../../../common/utils/linkUtils';
@@ -108,32 +109,29 @@ export default function UrlPresetsForm() {
</Panel.InlineElements> </Panel.InlineElements>
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Alert status='info' variant='ontime-on-dark-info'> <Info>
<AlertIcon /> URL presets are user defined aliases to Ontime URLs
<AlertDescription> <br />
URL presets are user defined aliases to Ontime URLs <br />
<br /> <b>Preset Name</b> <br />
<br /> The alias for the URL. This will be the URL you will be calling. eg: <br />
<b>Preset Name</b> <br /> <Panel.BlockQuote>
The alias for the URL. This will be the URL you will be calling. eg: <br /> Preset name <Panel.Highlight>cam3</Panel.Highlight> called as{' '}
<Panel.BlockQuote> <Panel.Highlight>http://localhost:4001/cam3</Panel.Highlight>
Preset name <Panel.Highlight>cam3</Panel.Highlight> called as{' '} </Panel.BlockQuote>
<Panel.Highlight>http://localhost:4001/cam3</Panel.Highlight> <br />
</Panel.BlockQuote> <b>URL Segment</b> <br />
<br /> The corresponding alias path and configuration parameters. eg: <br />
<b>URL Segment</b> <br /> <Panel.BlockQuote>
The corresponding alias path and configuration parameters. eg: <br /> URL segment <Panel.Highlight>backstage?hidePast=true&stopCycle=true</Panel.Highlight> corresponds to
<Panel.BlockQuote> complete URL
URL segment <Panel.Highlight>backstage?hidePast=true&stopCycle=true</Panel.Highlight> corresponds to <Panel.Highlight>http://localhost:4001/backstage?hidePast=true&stopCycle=true</Panel.Highlight>
complete URL </Panel.BlockQuote>
<Panel.Highlight>http://localhost:4001/backstage?hidePast=true&stopCycle=true</Panel.Highlight> <br />
</Panel.BlockQuote> You will need to save the changes before the presets are functional.
<br /> <br />
You will need to save the changes before the presets are functional. <ExternalLink href={urlPresetsDocs}>See the docs</ExternalLink>
<br /> </Info>
<ExternalLink href={urlPresetsDocs}>See the docs</ExternalLink>
</AlertDescription>
</Alert>
<Panel.Section> <Panel.Section>
<Panel.Loader isLoading={isLoading} /> <Panel.Loader isLoading={isLoading} />
<Panel.Title> <Panel.Title>
@@ -1,10 +1,11 @@
import { useState } from 'react'; import { useState } from 'react';
import { Alert, AlertDescription, AlertIcon, Button } from '@chakra-ui/react'; import { Button } from '@chakra-ui/react';
import { IoAdd } from '@react-icons/all-files/io5/IoAdd'; import { IoAdd } from '@react-icons/all-files/io5/IoAdd';
import { CustomField, CustomFieldLabel } from 'ontime-types'; import { CustomField, CustomFieldLabel } from 'ontime-types';
import { deleteCustomField, editCustomField, postCustomField } from '../../../../../common/api/customFields'; import { deleteCustomField, editCustomField, postCustomField } from '../../../../../common/api/customFields';
import ExternalLink from '../../../../../common/components/external-link/ExternalLink'; import ExternalLink from '../../../../../common/components/external-link/ExternalLink';
import Info from '../../../../../common/components/info/Info';
import useCustomFields from '../../../../../common/hooks-query/useCustomFields'; import useCustomFields from '../../../../../common/hooks-query/useCustomFields';
import { customFieldsDocsUrl } from '../../../../../externals'; import { customFieldsDocsUrl } from '../../../../../externals';
import * as Panel from '../../../panel-utils/PanelUtils'; import * as Panel from '../../../panel-utils/PanelUtils';
@@ -55,20 +56,17 @@ export default function CustomFields() {
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Panel.Section> <Panel.Section>
<Alert status='info' variant='ontime-on-dark-info'> <Info>
<AlertIcon /> Custom fields allow for additional information to be added to an event.
<AlertDescription> <br />
Custom fields allow for additional information to be added to an event. <br />
<br /> This data is not used by Ontime, but provides place for cueing or department specific information (eg.
<br /> light, sound, camera).
This data is not used by Ontime, but provides place for cueing or department specific information (eg. <br />
light, sound, camera). <br />
<br /> Custom fields can be used width the Integrations feature using the generated key.
<br /> <ExternalLink href={customFieldsDocsUrl}>See the docs</ExternalLink>
Custom fields can be used width the Integrations feature using the generated key. </Info>
<ExternalLink href={customFieldsDocsUrl}>See the docs</ExternalLink>
</AlertDescription>
</Alert>
</Panel.Section> </Panel.Section>
<Panel.Section> <Panel.Section>
{isAdding && <CustomFieldForm onSubmit={handleCreate} onCancel={handleCancel} />} {isAdding && <CustomFieldForm onSubmit={handleCreate} onCancel={handleCancel} />}
@@ -1,15 +1,17 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { Controller, useForm } from 'react-hook-form'; import { Controller, useForm } from 'react-hook-form';
import { Alert, AlertDescription, AlertIcon, Button, Input, Switch } from '@chakra-ui/react'; import { Button, Input, Switch } from '@chakra-ui/react';
import { ViewSettings } from 'ontime-types'; import { ViewSettings } from 'ontime-types';
import { maybeAxiosError } from '../../../../common/api/utils'; import { maybeAxiosError } from '../../../../common/api/utils';
import { postViewSettings } from '../../../../common/api/viewSettings'; import { postViewSettings } from '../../../../common/api/viewSettings';
import ExternalLink from '../../../../common/components/external-link/ExternalLink'; import ExternalLink from '../../../../common/components/external-link/ExternalLink';
import Info from '../../../../common/components/info/Info';
import { SwatchPickerRHF } from '../../../../common/components/input/colour-input/SwatchPicker'; import { SwatchPickerRHF } from '../../../../common/components/input/colour-input/SwatchPicker';
import useInfo from '../../../../common/hooks-query/useInfo'; import useInfo from '../../../../common/hooks-query/useInfo';
import useViewSettings from '../../../../common/hooks-query/useViewSettings'; import useViewSettings from '../../../../common/hooks-query/useViewSettings';
import { preventEscape } from '../../../../common/utils/keyEvent'; import { preventEscape } from '../../../../common/utils/keyEvent';
import { isOntimeCloud } from '../../../../externals';
import * as Panel from '../../panel-utils/PanelUtils'; import * as Panel from '../../panel-utils/PanelUtils';
const cssOverrideDocsUrl = 'https://docs.getontime.no/features/custom-styling/'; const cssOverrideDocsUrl = 'https://docs.getontime.no/features/custom-styling/';
@@ -85,16 +87,19 @@ export default function ViewSettingsForm() {
</Panel.InlineElements> </Panel.InlineElements>
</Panel.SubHeader> </Panel.SubHeader>
<Panel.Divider /> <Panel.Divider />
<Alert status='info' variant='ontime-on-dark-info'> <Info>
<AlertIcon /> You can the Ontime views or customise its styles by modifying the provided CSS file.
<AlertDescription> <br />
You can the Ontime views or customise its styles by modifying the provided CSS file. <br /> {!isOntimeCloud && (
The CSS file is in the user directory at {`${info.publicDir}/user/styles/override.css`} <>
<br /> <br />
<br /> The loaded CSS file is in the user directory at{' '}
<ExternalLink href={cssOverrideDocsUrl}>See the docs</ExternalLink> <Panel.BlockQuote>{`${info.publicDir}/user/styles/override.css`}</Panel.BlockQuote>
</AlertDescription> <br />
</Alert> </>
)}
<ExternalLink href={cssOverrideDocsUrl}>See the docs</ExternalLink>
</Info>
<Panel.Section> <Panel.Section>
<Panel.Loader isLoading={isLoading} /> <Panel.Loader isLoading={isLoading} />
<Panel.ListGroup> <Panel.ListGroup>
@@ -1,27 +0,0 @@
import { Alert, AlertDescription, AlertIcon } from '@chakra-ui/react';
import * as Panel from '../../panel-utils/PanelUtils';
import EditorSettingsForm from './EditorSettingsForm';
export default function InterfacePanel() {
return (
<>
<Panel.Header>Interface</Panel.Header>
<Panel.Section>
<Alert status='info' variant='ontime-on-dark-info'>
<AlertIcon />
<AlertDescription>
Interface settings
<br />
<br />
These concern settings that are applied to this user in this browser.
<br />
It will not affect other users or other browsers.
</AlertDescription>
</Alert>
</Panel.Section>
<EditorSettingsForm />
</>
);
}
@@ -1,21 +1,17 @@
import { Alert, AlertDescription, AlertIcon } from '@chakra-ui/react';
import ExternalLink from '../../../../common/components/external-link/ExternalLink'; import ExternalLink from '../../../../common/components/external-link/ExternalLink';
import Info from '../../../../common/components/info/Info';
const googleSheetDocsUrl = 'https://docs.getontime.no/features/import-spreadsheet-gsheet/'; const googleSheetDocsUrl = 'https://docs.getontime.no/features/import-spreadsheet-gsheet/';
export default function GSheetInfo() { export default function GSheetInfo() {
return ( return (
<Alert status='info' variant='ontime-on-dark-info'> <Info>
<AlertIcon /> Ontime allows you to synchronize your rundown with a Google Sheet.
<AlertDescription> <br />
Ontime allows you to synchronize your rundown with a Google Sheet. <br />
<br /> To enable this feature, you will need to generate tokens in your Google account and provide them to Ontime.
<br /> <br />
To enable this feature, you will need to generate tokens in your Google account and provide them to Ontime. Once set up, you will be able to synchronize data between Ontime and your Google Sheet. <br />
<br /> <ExternalLink href={googleSheetDocsUrl}>See the docs</ExternalLink>
Once set up, you will be able to synchronize data between Ontime and your Google Sheet. <br /> </Info>
<ExternalLink href={googleSheetDocsUrl}>See the docs</ExternalLink>
</AlertDescription>
</Alert>
); );
} }