From 082c9885f25e04ff93d6233e415f2db94e086784 Mon Sep 17 00:00:00 2001 From: ilkin-overleaf <100852799+ilkin-overleaf@users.noreply.github.com> Date: Mon, 31 Oct 2022 17:02:59 +0200 Subject: [PATCH] Merge pull request #10132 from overleaf/ii-dashboard-are-you-affiliated-migration [web] Project dashboard are you affiliated migration GitOrigin-RevId: 455ad915dd023c5fab3ce9a5165aa7e960915f1f --- .../Features/Project/ProjectListController.js | 1 + services/web/app/views/project/list-react.pug | 1 + .../web/frontend/extracted-translations.json | 1 + .../components/project-list-root.tsx | 4 + .../components/sidebar/add-affiliation.tsx | 34 +++++++++ .../project-list/add-affiliation.stories.tsx | 29 +++++++ services/web/locales/en.json | 1 + .../sidebar/add-affiliation.test.tsx | 76 +++++++++++++++++++ 8 files changed, 147 insertions(+) create mode 100644 services/web/frontend/js/features/project-list/components/sidebar/add-affiliation.tsx create mode 100644 services/web/frontend/stories/project-list/add-affiliation.stories.tsx create mode 100644 services/web/test/frontend/features/project-list/components/sidebar/add-affiliation.test.tsx diff --git a/services/web/app/src/Features/Project/ProjectListController.js b/services/web/app/src/Features/Project/ProjectListController.js index b24df18cd1..9e0a05ee14 100644 --- a/services/web/app/src/Features/Project/ProjectListController.js +++ b/services/web/app/src/Features/Project/ProjectListController.js @@ -293,6 +293,7 @@ async function projectListReactPage(req, res, next) { notifications, notificationsInstitution, user, + userAffiliations, userEmails, reconfirmedViaSAML, allInReconfirmNotificationPeriods, diff --git a/services/web/app/views/project/list-react.pug b/services/web/app/views/project/list-react.pug index b52e2839fc..cac3ebd9ac 100644 --- a/services/web/app/views/project/list-react.pug +++ b/services/web/app/views/project/list-react.pug @@ -13,6 +13,7 @@ block append meta meta(name="ol-userEmails" data-type="json" content=userEmails) meta(name="ol-allInReconfirmNotificationPeriods" data-type="json" content=allInReconfirmNotificationPeriods) meta(name="ol-user" data-type="json" content=user) + meta(name="ol-userAffiliations" data-type="json" content=userAffiliations) meta(name="ol-reconfirmedViaSAML" content=reconfirmedViaSAML) meta(name="ol-survey" data-type="json" content=survey) meta(name="ol-tags" data-type="json" content=tags) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 3cc1ba1ffe..300eb19157 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -30,6 +30,7 @@ "archived": "", "archived_projects": "", "archiving_projects_wont_affect_collaborators": "", + "are_you_affiliated_with_an_institution": "", "are_you_still_at": "", "ascending": "", "ask_proj_owner_to_upgrade_for_git_bridge": "", diff --git a/services/web/frontend/js/features/project-list/components/project-list-root.tsx b/services/web/frontend/js/features/project-list/components/project-list-root.tsx index 1bac43455c..1205aecd7c 100644 --- a/services/web/frontend/js/features/project-list/components/project-list-root.tsx +++ b/services/web/frontend/js/features/project-list/components/project-list-root.tsx @@ -10,6 +10,7 @@ import CurrentPlanWidget from './current-plan-widget/current-plan-widget' import NewProjectButton from './new-project-button' import ProjectListTable from './table/project-list-table' import SidebarFilters from './sidebar/sidebar-filters' +import AddAffiliation, { useAddAffiliation } from './sidebar/add-affiliation' import SurveyWidget from './survey-widget' import WelcomeMessage from './welcome-message' import LoadingBranded from '../../../shared/components/loading-branded' @@ -42,6 +43,7 @@ function ProjectListPageContent() { setSearchText, selectedProjects, } = useProjectListContext() + const { show: showAddAffiliationWidget } = useAddAffiliation() useEffect(() => { eventTracking.sendMB('loads_v2_dash', {}) @@ -62,6 +64,8 @@ function ProjectListPageContent() { diff --git a/services/web/frontend/js/features/project-list/components/sidebar/add-affiliation.tsx b/services/web/frontend/js/features/project-list/components/sidebar/add-affiliation.tsx new file mode 100644 index 0000000000..057aae94b2 --- /dev/null +++ b/services/web/frontend/js/features/project-list/components/sidebar/add-affiliation.tsx @@ -0,0 +1,34 @@ +import { useTranslation } from 'react-i18next' +import { Button } from 'react-bootstrap' +import { useProjectListContext } from '../../context/project-list-context' +import getMeta from '../../../../utils/meta' +import { Affiliation } from '../../../../../../types/affiliation' +import { ExposedSettings } from '../../../../../../types/exposed-settings' + +export function useAddAffiliation() { + const { totalProjectsCount } = useProjectListContext() + const { isOverleaf } = getMeta('ol-ExposedSettings') as ExposedSettings + const userAffiliations = getMeta('ol-userAffiliations', []) as Affiliation[] + + return { show: isOverleaf && totalProjectsCount && !userAffiliations.length } +} + +function AddAffiliation() { + const { t } = useTranslation() + const { show } = useAddAffiliation() + + if (!show) { + return null + } + + return ( +
{t('are_you_affiliated_with_an_institution')}
+ +