mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
refactor: improve links inside editor
This commit is contained in:
committed by
Carlos Valente
parent
bf99646ad5
commit
8adca908b3
@@ -22,10 +22,3 @@
|
|||||||
.label {
|
.label {
|
||||||
color: $label-gray;
|
color: $label-gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
.link {
|
|
||||||
color: $label-gray;
|
|
||||||
font-size: $text-body-size;
|
|
||||||
text-decoration: underline;
|
|
||||||
text-underline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { navigatorConstants } from '../../../viewerConfig';
|
|||||||
import { setClientRemote } from '../../hooks/useSocket';
|
import { setClientRemote } from '../../hooks/useSocket';
|
||||||
import useUrlPresets from '../../hooks-query/useUrlPresets';
|
import useUrlPresets from '../../hooks-query/useUrlPresets';
|
||||||
import Info from '../info/Info';
|
import Info from '../info/Info';
|
||||||
|
import AppLink from '../link/app-link/AppLink';
|
||||||
|
|
||||||
import style from './RedirectClientModal.module.scss';
|
import style from './RedirectClientModal.module.scss';
|
||||||
|
|
||||||
@@ -58,9 +59,7 @@ export function RedirectClientModal(props: RedirectClientModalProps) {
|
|||||||
Either by selecting a URL Preset or entering a custom path.
|
Either by selecting a URL Preset or entering a custom path.
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<a href='/editor?settings=feature_settings__urlpresets' target='_blank' className={style.link}>
|
<AppLink search='settings=feature_settings__urlpresets'>Manage URL Presets</AppLink>
|
||||||
Manage URL Presets
|
|
||||||
</a>
|
|
||||||
</Info>
|
</Info>
|
||||||
<div>
|
<div>
|
||||||
<span className={style.label}>Select View or URL Preset</span>
|
<span className={style.label}>Select View or URL Preset</span>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
@use "../../../../theme/mixins" as *;
|
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
@include action-link;
|
color: $label-gray;
|
||||||
font-size: $inner-section-text-size;
|
font-size: $text-body-size;
|
||||||
}
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 2px;
|
||||||
|
|
||||||
.linkIcon {
|
&:hover {
|
||||||
margin-left: $element-inner-spacing;
|
color: $blue-400;
|
||||||
display: inline-block;
|
}
|
||||||
@include rotate-fourty-five;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
import { MouseEvent, ReactNode } from 'react';
|
import { type PropsWithChildren } from 'react';
|
||||||
import { IoArrowUp } from '@react-icons/all-files/io5/IoArrowUp';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import { openLink } from '../../../utils/linkUtils';
|
|
||||||
|
|
||||||
import style from './AppLink.module.scss';
|
import style from './AppLink.module.scss';
|
||||||
|
|
||||||
interface AppLinkProps {
|
interface AppLinkProps {
|
||||||
href: string;
|
search: string;
|
||||||
children: ReactNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AppLink(props: AppLinkProps) {
|
/**
|
||||||
const { href, children } = props;
|
* Component used to navigate to an editor link inside the same window
|
||||||
|
* Handles the path to respect Ontime Clouds base URL
|
||||||
|
*/
|
||||||
|
export default function AppLink(props: PropsWithChildren<AppLinkProps>) {
|
||||||
|
const { search, children } = props;
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {
|
const handleClick = () => navigate({ search });
|
||||||
event.preventDefault();
|
|
||||||
openLink(href);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a href='#!' target='_blank' rel='noreferrer' className={style.link} onClick={handleClick}>
|
<button onClick={handleClick} className={style.link}>
|
||||||
{children} <IoArrowUp className={style.linkIcon} />
|
{children}
|
||||||
</a>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,3 @@
|
|||||||
color: $ontime-roll;
|
color: $ontime-roll;
|
||||||
font-size: $text-body-size;
|
font-size: $text-body-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reportLink {
|
|
||||||
color: $label-gray;
|
|
||||||
font-size: $text-body-size;
|
|
||||||
text-decoration: underline;
|
|
||||||
text-underline-offset: 2px;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Tooltip } from '@chakra-ui/react';
|
|||||||
import { MaybeNumber, Playback, TimerPhase } from 'ontime-types';
|
import { MaybeNumber, Playback, TimerPhase } from 'ontime-types';
|
||||||
import { dayInMs, millisToString } from 'ontime-utils';
|
import { dayInMs, millisToString } from 'ontime-utils';
|
||||||
|
|
||||||
|
import AppLink from '../../../../common/components/link/app-link/AppLink';
|
||||||
import { useTimer } from '../../../../common/hooks/useSocket';
|
import { useTimer } from '../../../../common/hooks/useSocket';
|
||||||
import useReport from '../../../../common/hooks-query/useReport';
|
import useReport from '../../../../common/hooks-query/useReport';
|
||||||
import { formatDuration } from '../../../../common/utils/time';
|
import { formatDuration } from '../../../../common/utils/time';
|
||||||
@@ -98,11 +99,7 @@ function StoppedStatus() {
|
|||||||
const hasReport = Object.keys(data).length > 0;
|
const hasReport = Object.keys(data).length > 0;
|
||||||
|
|
||||||
if (hasReport) {
|
if (hasReport) {
|
||||||
return (
|
return <AppLink search='settings=feature_settings__report'>Go to report management</AppLink>;
|
||||||
<a className={style.reportLink} href='/editor?settings=feature_settings__report'>
|
|
||||||
Go to report management
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { CSSProperties, useCallback } from 'react';
|
import { CSSProperties, useCallback } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
|
||||||
import { Button } from '@chakra-ui/react';
|
|
||||||
import { CustomFieldLabel, OntimeEvent } from 'ontime-types';
|
import { CustomFieldLabel, OntimeEvent } from 'ontime-types';
|
||||||
|
|
||||||
|
import AppLink from '../../../common/components/link/app-link/AppLink';
|
||||||
import { useEventAction } from '../../../common/hooks/useEventAction';
|
import { useEventAction } from '../../../common/hooks/useEventAction';
|
||||||
import useCustomFields from '../../../common/hooks-query/useCustomFields';
|
import useCustomFields from '../../../common/hooks-query/useCustomFields';
|
||||||
import { getAccessibleColour } from '../../../common/utils/styleUtils';
|
import { getAccessibleColour } from '../../../common/utils/styleUtils';
|
||||||
@@ -29,7 +28,6 @@ export default function EventEditor(props: EventEditorProps) {
|
|||||||
const { event } = props;
|
const { event } = props;
|
||||||
const { data: customFields } = useCustomFields();
|
const { data: customFields } = useCustomFields();
|
||||||
const { updateEvent } = useEventAction();
|
const { updateEvent } = useEventAction();
|
||||||
const [_searchParams, setSearchParams] = useSearchParams();
|
|
||||||
|
|
||||||
const isEditor = window.location.pathname.includes('editor');
|
const isEditor = window.location.pathname.includes('editor');
|
||||||
|
|
||||||
@@ -45,10 +43,6 @@ export default function EventEditor(props: EventEditorProps) {
|
|||||||
[event?.id, updateEvent],
|
[event?.id, updateEvent],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleOpenCustomManager = () => {
|
|
||||||
setSearchParams({ settings: 'feature_settings__custom' });
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!event) {
|
if (!event) {
|
||||||
return <EventEditorEmpty />;
|
return <EventEditorEmpty />;
|
||||||
}
|
}
|
||||||
@@ -83,11 +77,7 @@ export default function EventEditor(props: EventEditorProps) {
|
|||||||
<div className={style.column}>
|
<div className={style.column}>
|
||||||
<Editor.Title>
|
<Editor.Title>
|
||||||
Custom Fields
|
Custom Fields
|
||||||
{isEditor && (
|
{isEditor && <AppLink search='settings=feature_settings__custom'>Manage</AppLink>}
|
||||||
<Button variant='ontime-subtle' size='sm' onClick={handleOpenCustomManager}>
|
|
||||||
Manage
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</Editor.Title>
|
</Editor.Title>
|
||||||
|
|
||||||
{Object.keys(customFields).map((fieldKey) => {
|
{Object.keys(customFields).map((fieldKey) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user