Procházet zdrojové kódy

Merge pull request #169 from sharelatex/as-import-v1

V1 Import Modal
Alasdair Smith před 8 roky
rodič
revize
2d66fd7280

+ 56 - 0
services/web/app/views/project/list/modals.pug

@@ -313,3 +313,59 @@ script(type="text/ng-template", id="userProfileModalTemplate")
 
 	.modal-footer
 		button.btn.btn-info(ng-click="done()") #{translate("done")}
+
+script(type="text/ng-template", id="v1ImportModalTemplate")
+	.modal-header
+		button.close(ng-click="dismiss()") ×
+		h3 #{translate("import_project_to_v2")}
+
+	.modal-body.v1-import-wrapper
+		.v1-import-step-1(ng-show="step === 1")
+			img.v1-import-img(
+				src="/img/v1-import/v2-editor.png"
+				alt="The new V2 Editor."
+			)
+			h2.v1-import-title Try importing your project to V2!
+			p Some exciting copy about the new features:
+			ul
+				li Some stuff
+				li Some more stuff
+				li Yet more stuff
+
+		.v1-import-step-2(ng-show="step === 2")
+			div.v1-import-warning(aria-label="Warning symbol.")
+				i.fa.fa-exclamation-triangle
+			h2.v1-import-title #[strong Warning:] Overleaf V2 is in beta
+			p Once importing your project you will lose access to the some of the features of Overleaf V1. This includes the git bridge, journal integrations, WYSIWYG and linked files. We’re working on bringing these features to V2!
+			p Once you have imported a project to V2 you #[strong cannot go back to V1].
+			p Are you sure you want to import to V2?
+
+	.modal-footer.v1-import-footer
+		div(ng-show="step === 1")
+			if settings.overleaf && settings.overleaf.host
+				a.btn.btn-primary.v1-import-btn(
+					ng-href=settings.overleaf.host + "/{{project.id}}"
+				) #{translate("open_in_v1")}
+			button.btn.btn-primary.v1-import-btn(
+				ng-click="moveToConfirmation()"
+			) #{translate("import_to_v2")}
+		div(ng-show="step === 2")
+			form(
+				async-form="v1Import",
+				name="v1ImportForm",
+				action="{{'/overleaf/project/'+ project.id + '/import'}}"
+				method="POST"
+				ng-cloak
+			)
+				input(name='_csrf', type='hidden', value=csrfToken)
+				form-messages(for="v1ImportForm")
+				if settings.overleaf && settings.overleaf.host
+					a.btn.btn-primary.v1-import-btn(
+						ng-href=settings.overleaf.host + "/{{project.id}}"
+						ng-class="{disabled: v1ImportForm.inflight || v1ImportForm.success}"
+					) #{translate("never_mind_open_in_v1")}
+				input.btn.btn-primary.v1-import-btn(
+					type="submit",
+					value=translate('yes_im_sure')
+					ng-disabled="v1ImportForm.inflight || v1ImportForm.success"
+				)

+ 4 - 5
services/web/app/views/project/list/v1-item.pug

@@ -5,11 +5,10 @@
 		tooltip-append-to-body="true"
 	)
 	span
-		if settings.overleaf && settings.overleaf.host
-			a.projectName(
-					href=settings.overleaf.host + "/{{project.id}}"
-				stop-propagation="click"
-			) {{project.name}}
+		button.btn.btn-link.v1ProjectName(
+			ng-click="openV1ImportModal(project)"
+			stop-propagation="click"
+		) {{project.name}}
 
 .col-xs-2
 	span.owner {{ownerName()}}

+ 10 - 0
services/web/public/coffee/main/project-list/modal-controllers.coffee

@@ -123,3 +123,13 @@ define [
 		$scope.onComplete = (error, name, response) ->
 			if response.project_id?
 				window.location = '/project/' + response.project_id
+
+	App.controller 'V1ImportModalController', ($scope, $modalInstance, project) ->
+		$scope.project = project
+		$scope.step = 1
+
+		$scope.dismiss = () ->
+			$modalInstance.dismiss('cancel')
+
+		$scope.moveToConfirmation = () ->
+			$scope.step = 2

+ 10 - 0
services/web/public/coffee/main/project-list/project-list.coffee

@@ -442,6 +442,16 @@ define [
 				path = "/project/#{selected_project_ids[0]}/download/zip"
 
 			window.location = path
+
+		$scope.openV1ImportModal = (project) ->
+			$modal.open(
+				templateUrl: 'v1ImportModalTemplate'
+				controller: 'V1ImportModalController'
+				size: 'lg'
+				windowClass: 'v1-import-modal'
+				resolve:
+					project: () -> project
+			)
 			
 		if storedUIOpts?.filter?
 			if storedUIOpts.filter == "tag" and storedUIOpts.selectedTagId?

binární
services/web/public/img/v1-import/v2-editor.png


+ 24 - 0
services/web/public/stylesheets/app/list/v1-import-modal.less

@@ -0,0 +1,24 @@
+.v1-import-title {
+	text-align: center;
+}
+
+.v1-import-img {
+	width: 100%;
+}
+
+.v1-import-warning {
+	text-align: center;
+	color: #fdce02;
+	font-size: 14em;
+	line-height: 1em;
+}
+
+.v1-import-footer {
+	display: flex;
+	justify-content: space-evenly;
+	text-align: left;
+}
+
+	.v1-import-btn {
+		width: 20rem;
+	}

+ 6 - 0
services/web/public/stylesheets/app/project-list.less

@@ -1,3 +1,5 @@
+@import "./list/v1-import-modal.less";
+
 @announcements-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
 
 @keyframes pulse {
@@ -332,6 +334,10 @@ ul.project-list {
 		.projectName {
 			margin-right: @line-height-computed / 4;
 		}
+		.v1ProjectName {
+			margin-right: @line-height-computed / 4;
+			padding: 0;
+		}
 
 		.tag-label {
 			margin-left: @line-height-computed / 4;