From 5a34d17947341419f2d77f89db48ce49eae91fc9 Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 17 Jan 2017 15:59:18 +0100 Subject: [PATCH] Toggle track changes in a project based on the owner's feature switch --- .../app/coffee/Features/Project/ProjectEditorHandler.coffee | 6 ++++++ services/web/app/coffee/models/User.coffee | 2 +- services/web/app/views/project/editor/editor.jade | 2 +- services/web/app/views/project/editor/header.jade | 2 +- services/web/public/coffee/ide.coffee | 5 +---- .../review-panel/controllers/ReviewPanelController.coffee | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/web/app/coffee/Features/Project/ProjectEditorHandler.coffee b/services/web/app/coffee/Features/Project/ProjectEditorHandler.coffee index 1a10321544..e25ff29b28 100644 --- a/services/web/app/coffee/Features/Project/ProjectEditorHandler.coffee +++ b/services/web/app/coffee/Features/Project/ProjectEditorHandler.coffee @@ -19,6 +19,11 @@ module.exports = ProjectEditorHandler = if !result.invites? result.invites = [] + + hasTrackChanges = false + for member in members + if member.privilegeLevel == "owner" and member.user?.featureSwitches?.track_changes + hasTrackChanges = true {owner, ownerFeatures, members} = @buildOwnerAndMembersViews(members) result.owner = owner @@ -32,6 +37,7 @@ module.exports = ProjectEditorHandler = compileGroup:"standard" templates: false references: false + trackChanges: hasTrackChanges }) return result diff --git a/services/web/app/coffee/models/User.coffee b/services/web/app/coffee/models/User.coffee index f120422128..c6e469a1f4 100644 --- a/services/web/app/coffee/models/User.coffee +++ b/services/web/app/coffee/models/User.coffee @@ -39,7 +39,7 @@ UserSchema = new Schema references: { type:Boolean, default: Settings.defaultFeatures.references } } featureSwitches : { - pdfng: { type: Boolean } + track_changes: { type: Boolean } } referal_id : {type:String, default:() -> uuid.v4().split("-")[0]} refered_users: [ type:ObjectId, ref:'User' ] diff --git a/services/web/app/views/project/editor/editor.jade b/services/web/app/views/project/editor/editor.jade index d31be444af..f57eb4dd2a 100644 --- a/services/web/app/views/project/editor/editor.jade +++ b/services/web/app/views/project/editor/editor.jade @@ -52,7 +52,7 @@ div.full-size( syntax-validation="settings.syntaxValidation", review-panel="reviewPanel", events-bridge="reviewPanelEventsBridge" - track-changes-enabled="trackChangesFeatureFlag", + track-changes-enabled="project.features.trackChanges", track-changes= "editor.trackChanges", doc-id="editor.open_doc_id" renderer-data="reviewPanel.rendererData" diff --git a/services/web/app/views/project/editor/header.jade b/services/web/app/views/project/editor/header.jade index d1305d28b9..601b18e9cf 100644 --- a/services/web/app/views/project/editor/header.jade +++ b/services/web/app/views/project/editor/header.jade @@ -87,7 +87,7 @@ header.toolbar.toolbar-header.toolbar-with-labels( a.btn.btn-full-height( href, - ng-if="trackChangesFeatureFlag", + ng-if="project.features.trackChanges", ng-class="{ active: ui.reviewPanelOpen }" ng-click="toggleReviewPanel()" ) diff --git a/services/web/public/coffee/ide.coffee b/services/web/public/coffee/ide.coffee index 370f144ee1..9baaf1c66f 100644 --- a/services/web/public/coffee/ide.coffee +++ b/services/web/public/coffee/ide.coffee @@ -57,9 +57,6 @@ define [ else this.$originalApply(fn); - if window.location.search.match /tcon=true/ # track changes on - $scope.trackChangesFeatureFlag = true - $scope.state = { loading: true load_progress: 40 @@ -70,7 +67,7 @@ define [ view: "editor" chatOpen: false pdfLayout: 'sideBySide' - reviewPanelOpen: localStorage("ui.reviewPanelOpen.#{window.project_id}") and $scope.trackChangesFeatureFlag + reviewPanelOpen: localStorage("ui.reviewPanelOpen.#{window.project_id}") and $scope.project.features.trackChanges showCodeCheckerOnboarding: !window.userSettings.syntaxValidation? } $scope.user = window.user diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index 91792255de..717513e884 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -129,7 +129,7 @@ define [ entries = $scope.reviewPanel.entries[$scope.editor.open_doc_id] or {} Object.keys(entries).length ), (nEntries) -> - $scope.reviewPanel.hasEntries = nEntries > 0 and $scope.trackChangesFeatureFlag + $scope.reviewPanel.hasEntries = nEntries > 0 and $scope.project.features.trackChanges $scope.$watch "ui.reviewPanelOpen", (reviewPanelOpen) -> return if !reviewPanelOpen?