Skip to content

Commit

Permalink
Show invalid links in red.
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed May 14, 2024
1 parent 54bc2b1 commit 7308722
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
disabledText,
icon,
instructionWarningParameter,
instructionInvalidParameter,
} from '../../ClassNames';
import InlinePopover from '../../../InlinePopover';
import ExternalEventsAutoComplete from './ExternalEventsAutoComplete';
Expand Down Expand Up @@ -141,6 +142,15 @@ export default class LinkEvent extends React.Component<EventRendererProps, *> {
);
};

isInvalidLink = (target: string): boolean => {
const { project } = this.props.scope;
return (
target.length > 0 &&
!project.hasExternalEventsNamed(target) &&
!project.hasLayoutNamed(target)
);
};

render() {
const linkEvent = gd.asLinkEvent(this.props.event);
const target = linkEvent.getTarget();
Expand Down Expand Up @@ -178,7 +188,15 @@ export default class LinkEvent extends React.Component<EventRendererProps, *> {
}}
tabIndex={0}
>
{this.isLinkedToWrongLayout(target) ? (
{this.isInvalidLink(target) ? (
<span
className={classNames({
[instructionInvalidParameter]: true,
})}
>
{target}
</span>
) : this.isLinkedToWrongLayout(target) ? (
<span
className={classNames({
[instructionWarningParameter]: true,
Expand Down
4 changes: 4 additions & 0 deletions newIDE/app/src/UI/Theme/Global/EventsSheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@
color: var(--event-sheet-instruction-parameter-warning-color);
text-decoration: var(--event-sheet-instruction-parameter-warning-color) underline wavy;
}
.gd-events-sheet .link-container .instruction-invalid-parameter {
color: var(--event-sheet-instruction-parameter-error-color);
text-decoration: var(--event-sheet-instruction-parameter-error-color) underline wavy;
}

.gd-events-sheet .link-container .selectable {
color: var(--event-sheet-link-selectable-link-color);
Expand Down

0 comments on commit 7308722

Please sign in to comment.