-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce48f97
commit ba27f38
Showing
6 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"rules": { | ||
"react/jsx-handler-names": "off", | ||
"react/require-default-props": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
line-height: 17px; | ||
} | ||
|
||
.paneFunctions { | ||
padding: 8px; | ||
} | ||
|
||
.contextMenuContainer { | ||
padding: 8px; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/@sanity/desk-tool/src/panes/documentPane/documentPanel/header/validationMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import Button from 'part:@sanity/components/buttons/default' | ||
import ValidationList from 'part:@sanity/components/validation/list' | ||
import ErrorOutlineIcon from 'part:@sanity/base/error-outline-icon' | ||
import React from 'react' | ||
import {Tooltip} from 'react-tippy' | ||
|
||
interface ValidationMenuProps { | ||
isOpen: boolean | ||
markers: any[] | ||
onClose: () => void | ||
onToggle: () => void | ||
schemaType: any | ||
setFocusPath: (path: any) => void | ||
} | ||
|
||
export function ValidationMenu(props: ValidationMenuProps) { | ||
const {isOpen, markers, onClose, onToggle, schemaType, setFocusPath} = props | ||
const validationMarkers = markers.filter(marker => marker.type === 'validation') | ||
const validationErrorMarkers = validationMarkers.filter(marker => marker.level === 'error') | ||
const validationWarningwarnings = validationMarkers.filter(marker => marker.level === 'warning') | ||
|
||
if (validationErrorMarkers.length === 0 && validationWarningwarnings.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<Tooltip | ||
arrow | ||
distance={13} | ||
html={ | ||
<ValidationList | ||
documentType={schemaType} | ||
markers={validationMarkers} | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
onFocus={setFocusPath} | ||
showLink | ||
/> | ||
} | ||
inertia={false} | ||
interactive | ||
onRequestClose={onClose} | ||
open={isOpen} | ||
position="bottom" | ||
theme="light" | ||
trigger="click" | ||
> | ||
<Button | ||
color={validationErrorMarkers.length > 0 ? 'danger' : 'warning'} | ||
kind="simple" | ||
icon={ErrorOutlineIcon} | ||
onClick={onToggle} | ||
padding="small" | ||
selected={isOpen} | ||
title="Show validation issues" | ||
/> | ||
</Tooltip> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters