-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #758 from digirati-co-uk/project-heading-blocks
Project heading block
- Loading branch information
Showing
8 changed files
with
135 additions
and
46 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
40 changes: 40 additions & 0 deletions
40
services/madoc-ts/src/frontend/site/features/contributor/StartContributingButton.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,40 @@ | ||
import React from 'react'; | ||
import { useProjectStatus } from '../../hooks/use-project-status'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useSiteConfiguration } from '../SiteConfigurationContext'; | ||
import { useUser } from '../../../shared/hooks/use-site'; | ||
import { useProjectPageConfiguration } from '../../hooks/use-project-page-configuration'; | ||
import { useProjectShadowConfiguration } from '../../hooks/use-project-shadow-configuration'; | ||
import { GoToRandomManifest } from './GoToRandomManifest'; | ||
import { GoToRandomCanvas } from './GoToRandomCanvas'; | ||
|
||
export const StartContributingButton: React.FC = () => { | ||
const { isActive } = useProjectStatus(); | ||
const { t } = useTranslation(); | ||
const { | ||
project: { claimGranularity }, | ||
} = useSiteConfiguration(); | ||
const user = useUser(); | ||
const isAdmin = user && user.scope && user.scope.indexOf('site.admin') !== -1; | ||
const canContribute = isAdmin || (user && user.scope && user.scope.indexOf('models.contribute') !== -1); | ||
const options = useProjectPageConfiguration(); | ||
const { showCaptureModelOnManifest } = useProjectShadowConfiguration(); | ||
|
||
return ( | ||
<div> | ||
{!options.hideStartContributing && isActive && canContribute ? ( | ||
claimGranularity === 'manifest' || showCaptureModelOnManifest ? ( | ||
<GoToRandomManifest | ||
$primary | ||
$large | ||
label={{ none: [t('Start contributing')] }} | ||
navigateToModel | ||
manifestModel={showCaptureModelOnManifest} | ||
/> | ||
) : ( | ||
<GoToRandomCanvas $primary $large label={{ none: [t('Start contributing')] }} navigateToModel /> | ||
) | ||
) : null} | ||
</div> | ||
); | ||
}; |
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