From f9962fefe8d48adce75ce5b551dd748576215500 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Wed, 31 Mar 2021 17:46:43 +0200 Subject: [PATCH] React git-bridge modal (#3869) GitOrigin-RevId: 5b2609ed9ad7909a10cb08342053e955447688f5 --- services/web/config/settings.defaults.coffee | 1 + .../web/frontend/extracted-translations.json | 10 ++++ .../js/shared/context/application-context.js | 7 ++- .../web/frontend/stories/fixtures/context.js | 2 + .../stories/git-bridge-modal.stories.js | 48 +++++++++++++++++++ .../web/frontend/stylesheets/app/editor.less | 4 ++ services/web/locales/en.json | 5 ++ .../frontend/helpers/render-with-context.js | 1 + 8 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 services/web/frontend/stories/git-bridge-modal.stories.js diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index da192da698..1c3bfb540a 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -727,6 +727,7 @@ module.exports = settings = overleafModuleImports: { # modules to import (an empty array for each set of modules) createFileModes: [] + gitBridge: [] } csp: { diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 01b770e99c..30809190d9 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -1,7 +1,9 @@ { + "access_your_projects_with_git": "", "account_settings": "", "anyone_with_link_can_edit": "", "anyone_with_link_can_view": "", + "ask_proj_owner_to_upgrade_for_git_bridge": "", "ask_proj_owner_to_upgrade_for_longer_compiles": "", "auto_compile": "", "autocompile_disabled": "", @@ -23,11 +25,13 @@ "change_project_owner": "", "chat": "", "clear_cached_files": "", + "clone_with_git": "", "close": "", "clsi_maintenance": "", "clsi_unavailable": "", "code_check_failed": "", "code_check_failed_explanation": "", + "collaborate_online_and_offline": "", "collabs_per_proj": "", "collapse": "", "common": "", @@ -46,6 +50,7 @@ "creating": "", "delete": "", "deleting": "", + "demonstrating_git_integration": "", "dismiss": "", "dismiss_error_popup": "", "done": "", @@ -68,6 +73,8 @@ "full_doc_history": "", "full_screen": "", "generic_something_went_wrong": "", + "get_collaborative_benefits": "", + "git_bridge_modal_description": "", "give_feedback": "", "go_to_error_location": "", "headers": "", @@ -167,6 +174,7 @@ "start_free_trial": "", "stop_compile": "", "stop_on_validation_error": "", + "store_your_work": "", "sure_you_want_to_delete": "", "sync_to_dropbox": "", "sync_to_github": "", @@ -182,11 +190,13 @@ "too_many_requests": "", "too_recently_compiled": "", "total_words": "", + "try_it_for_free": "", "turn_off_link_sharing": "", "turn_on_link_sharing": "", "unlimited_projects": "", "upgrade_for_longer_compiles": "", "upload": "", + "use_your_own_machine": "", "validation_issue_description": "", "validation_issue_entry_description": "", "view_all_errors": "", diff --git a/services/web/frontend/js/shared/context/application-context.js b/services/web/frontend/js/shared/context/application-context.js index 0993e3ca98..dd39ee6337 100644 --- a/services/web/frontend/js/shared/context/application-context.js +++ b/services/web/frontend/js/shared/context/application-context.js @@ -10,15 +10,18 @@ ApplicationContext.Provider.propTypes = { id: PropTypes.string.isRequired }), exposedSettings: PropTypes.shape({ + appName: PropTypes.string.isRequired, enableSubscriptions: PropTypes.bool - }) + }), + gitBridgePublicBaseUrl: PropTypes.string.isRequired }) } export function ApplicationProvider({ children }) { const applicationContextValue = { user: window.user, - exposedSettings: ExposedSettings + exposedSettings: ExposedSettings, + gitBridgePublicBaseUrl: window.gitBridgePublicBaseUrl } return ( diff --git a/services/web/frontend/stories/fixtures/context.js b/services/web/frontend/stories/fixtures/context.js index 38a63b8d8c..442a59b89d 100644 --- a/services/web/frontend/stories/fixtures/context.js +++ b/services/web/frontend/stories/fixtures/context.js @@ -24,4 +24,6 @@ export function setupContext() { removeListener: sinon.stub() } } + window.ExposedSettings = window.ExposedSettings || {} + window.ExposedSettings.gitBridgePublicBaseUrl = 'https://git.stories.com' } diff --git a/services/web/frontend/stories/git-bridge-modal.stories.js b/services/web/frontend/stories/git-bridge-modal.stories.js new file mode 100644 index 0000000000..17780a86e5 --- /dev/null +++ b/services/web/frontend/stories/git-bridge-modal.stories.js @@ -0,0 +1,48 @@ +import React from 'react' +import { ContextRoot } from '../js/shared/context/root-context' +import { setupContext } from './fixtures/context' +import importOverleafModules from '../macros/import-overleaf-module.macro' + +const [ + { + import: { default: GitBridgeModal } + } +] = importOverleafModules('gitBridge') + +setupContext() + +export const GitBridgeUrlModal = args => +GitBridgeUrlModal.args = { + type: 'show_url' +} + +export const CollaboratorModal = args => +CollaboratorModal.args = { + type: 'collaborator' +} + +export const TeaserModal = args => +TeaserModal.args = { + type: 'teaser' +} + +export default { + title: 'Modals / Git Bridge Modal', + component: GitBridgeModal, + args: { + show: true + }, + argTypes: { + handleHide: { action: 'handleHide' }, + startFreeTrial: { action: 'startFreeTrial' } + }, + decorators: [ + Story => ( + <> + + + + + ) + ] +} diff --git a/services/web/frontend/stylesheets/app/editor.less b/services/web/frontend/stylesheets/app/editor.less index bd01e4a71e..2434232948 100644 --- a/services/web/frontend/stylesheets/app/editor.less +++ b/services/web/frontend/stylesheets/app/editor.less @@ -623,6 +623,10 @@ CodeMirror text-align: center; } +.teaser-refresh-label { + text-align: center; +} + .teaser-img, .dropbox-teaser-img { .img-responsive; diff --git a/services/web/locales/en.json b/services/web/locales/en.json index 56b42b5d3d..69981adff9 100644 --- a/services/web/locales/en.json +++ b/services/web/locales/en.json @@ -454,6 +454,11 @@ "tagline_student_monthly": "Great for a single term", "all_premium_features": "All premium features", "sync_dropbox_github": "Sync with Dropbox and GitHub", + "demonstrating_git_integration": "Demonstrating Git integration", + "collaborate_online_and_offline": "Collaborate online and offline, using your own workflow", + "get_collaborative_benefits": "Get the collaborative benefits from __appName__, even if you prefer to work offline", + "use_your_own_machine": "Use your own machine, with your own setup", + "store_your_work": "Store your work on your own infrastructure", "track_changes": "Track changes", "tooltip_hide_pdf": "Click to hide the PDF", "tooltip_show_pdf": "Click to show the PDF", diff --git a/services/web/test/frontend/helpers/render-with-context.js b/services/web/test/frontend/helpers/render-with-context.js index c89483d123..f0d9daa4a8 100644 --- a/services/web/test/frontend/helpers/render-with-context.js +++ b/services/web/test/frontend/helpers/render-with-context.js @@ -12,6 +12,7 @@ export function renderWithEditorContext( ) { window.user = user || window.user window.ExposedSettings.appName = 'test' + window.gitBridgePublicBaseUrl = 'git.overleaf.test' window.project_id = projectId != null ? projectId : window.project_id window._ide = { $scope: {