-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add link to folder
- Loading branch information
Showing
6 changed files
with
104 additions
and
15 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
43 changes: 43 additions & 0 deletions
43
front/app/containers/Admin/projects/project/projectHeader/LinkToFolderSettings.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,43 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Icon, Text, colors } from '@citizenlab/cl2-component-library'; | ||
|
||
import useProjectFolderById from 'api/project_folders/useProjectFolderById'; | ||
|
||
import useLocalize from 'hooks/useLocalize'; | ||
|
||
import { createHighlighterLink } from 'components/Highlighter'; | ||
|
||
import Link from 'utils/cl-router/Link'; | ||
import { truncate } from 'utils/textUtils'; | ||
|
||
interface Props { | ||
folderId: string; | ||
projectId: string; | ||
} | ||
|
||
export const fragmentId = 'folder'; | ||
const LinkToFolderSettings = ({ folderId, projectId }: Props) => { | ||
const { data: projectFolder } = useProjectFolderById(folderId); | ||
const localize = useLocalize(); | ||
|
||
if (!projectFolder) return null; | ||
|
||
return ( | ||
<Link | ||
to={createHighlighterLink( | ||
`/admin/projects/${projectId}/settings#${fragmentId}` | ||
)} | ||
data-cy="e2e-folder-preview-link-to-settings" | ||
> | ||
<Box display="flex" alignItems="center" gap="4px"> | ||
<Icon name="folder-solid" fill={colors.coolGrey600} width="14px" /> | ||
<Text color="coolGrey600" m="0px" fontSize="s" p="0"> | ||
{truncate(localize(projectFolder.data.attributes.title_multiloc), 40)} | ||
</Text> | ||
</Box> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default LinkToFolderSettings; |
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