-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Showing
12 changed files
with
170 additions
and
17 deletions.
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
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
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
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
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
39 changes: 39 additions & 0 deletions
39
packages/web/src/package/ui/KeyDialog/Tags/FilterTagMissingInfo.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,39 @@ | ||
import { Alert, AlertTitle, Box } from '@mui/material'; | ||
import { useDialogContext } from '../dialogContext'; | ||
import { MissingTagsList } from './MissingTagsList'; | ||
|
||
export const FilterTagMissingInfo = () => { | ||
const filterTag = useDialogContext((c) => c.uiProps.filterTag); | ||
const filterTagMissing = useDialogContext((c) => c.filterTagMissing); | ||
|
||
if (!filterTagMissing) { | ||
return null; | ||
} | ||
|
||
if (filterTag) | ||
return ( | ||
<Alert severity="error" sx={{ mt: 1, mb: 1, fontSize: 15 }}> | ||
<AlertTitle>Missing Required Tag</AlertTitle> | ||
{filterTag.length > 1 ? ( | ||
<Box> | ||
This app is configured to use only keys tagged with the{' '} | ||
<MissingTagsList tags={filterTag} />. Add one of them to continue. | ||
</Box> | ||
) : ( | ||
<Box> | ||
This app is configured to use only keys tagged with the{' '} | ||
<MissingTagsList tags={filterTag} />. Add this tag to continue. | ||
</Box> | ||
)} | ||
<Box mt={1}> | ||
<a | ||
href="https://docs.tolgee.io/js-sdk/filter_by_tags" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Read more in the docs | ||
</a> | ||
</Box> | ||
</Alert> | ||
); | ||
}; |
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,37 @@ | ||
import { styled } from '@mui/material'; | ||
import { useDialogActions } from '../dialogContext'; | ||
|
||
const StyledTag = styled('div')` | ||
display: inline-flex; | ||
outline: 0; | ||
cursor: default; | ||
padding: 1px 8px; | ||
border-radius: 12px; | ||
align-items: center; | ||
font-size: 14px; | ||
background: ${({ theme }) => theme.palette.grey[200]}; | ||
border: 1px solid transparent; | ||
max-width: 100%; | ||
box-sizing: border-box; | ||
border: 1px solid ${({ theme }) => theme.palette.text.secondary}; | ||
margin: -2px 0px; | ||
cursor: pointer; | ||
&:focus-within, | ||
&:hover { | ||
border: 1px solid ${({ theme }) => theme.palette.primary.main}; | ||
color: ${({ theme }) => theme.palette.primary.main}; | ||
} | ||
`; | ||
|
||
type Props = { | ||
name: string; | ||
}; | ||
|
||
export const MissingTag = ({ name }: Props) => { | ||
const { setTags } = useDialogActions(); | ||
function addTag(name: string) { | ||
setTags((values) => [...values.filter((t) => t !== name), name]); | ||
} | ||
|
||
return <StyledTag onClick={() => addTag(name)}>{name}</StyledTag>; | ||
}; |
35 changes: 35 additions & 0 deletions
35
packages/web/src/package/ui/KeyDialog/Tags/MissingTagsList.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,35 @@ | ||
import React from 'react'; | ||
import { MissingTag } from './MissingTag'; | ||
|
||
type Props = { | ||
tags: string[]; | ||
}; | ||
|
||
export const MissingTagsList = ({ tags }: Props) => { | ||
return ( | ||
<> | ||
{tags.map((tag, index) => { | ||
if (index === 0) { | ||
return ( | ||
<React.Fragment key={tag}> | ||
<MissingTag name={tag} /> | ||
</React.Fragment> | ||
); | ||
} else if (index < tags.length - 1) { | ||
return ( | ||
<React.Fragment key={tag}> | ||
, <MissingTag name={tag} /> | ||
</React.Fragment> | ||
); | ||
} else { | ||
return ( | ||
<React.Fragment key={tag}> | ||
{' '} | ||
or <MissingTag name={tag} /> | ||
</React.Fragment> | ||
); | ||
} | ||
})} | ||
</> | ||
); | ||
}; |
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