From fa112a70b112f065764df0d96b4b398cad2532c7 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 10 Nov 2023 15:10:13 +0300 Subject: [PATCH 1/3] Switch to FE2 as user preferences --- .../src/preferences/preferences.rb | 10 +++++--- ui/src/App.vue | 14 +++++++---- ui/src/components/StreamCard.vue | 20 ++++++++++++---- .../components/dialogs/CreateBranchDialog.vue | 6 ++++- .../components/dialogs/CreateStreamDialog.vue | 7 +++++- ui/src/components/dialogs/SettingsDialog.vue | 24 ++++++++++++++++++- ui/src/views/Streams.vue | 13 ++++++++-- 7 files changed, 77 insertions(+), 17 deletions(-) diff --git a/speckle_connector/src/preferences/preferences.rb b/speckle_connector/src/preferences/preferences.rb index 3cde47d0..2fcd7ea7 100644 --- a/speckle_connector/src/preferences/preferences.rb +++ b/speckle_connector/src/preferences/preferences.rb @@ -12,9 +12,9 @@ module Preferences include Immutable::ImmutableUtils DICT_HANDLER = SketchupModel::Dictionary::SpeckleModelDictionaryHandler # rubocop:disable Layout/LineLength - DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false}');" + DEFAULT_CONFIG = "('configSketchup', '{\"dark_theme\":false, \"diffing\":false, \"register_speckle_entity\":false}, \"fe2\":false');" # rubocop:enable Layout/LineLength - DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false}' + DEFAULT_PREFERENCES = '{"dark_theme":false, "diffing":false, "register_speckle_entity": false, "fe2": false}' # @param sketchup_model [Sketchup::Model] active model. def self.read_preferences(sketchup_model) @@ -35,7 +35,9 @@ def self.data_complete?(row_data) return false if row_data.empty? data = JSON.parse(row_data.first.first) - return false if data['dark_theme'].nil? || data['diffing'].nil? || data['register_speckle_entity'].nil? + if data['dark_theme'].nil? || data['fe2'].nil? || data['diffing'].nil? || data['register_speckle_entity'].nil? + return false + end true end @@ -65,11 +67,13 @@ def self.validate_user_preferences(database) data_hash = JSON.parse(row_data).to_h # Get current theme value dark_theme = data_hash['dark_theme'] + fe2 = data_hash['fe2'] diffing = data_hash['diffing'] register_speckle_entity = data_hash['register_speckle_entity'] { dark_theme: dark_theme, + fe2: fe2, diffing: diffing, register_speckle_entity: register_speckle_entity }.freeze diff --git a/ui/src/App.vue b/ui/src/App.vue index 3822820a..823c4e5b 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -15,7 +15,7 @@ > - {{"Streams"}} + {{ streamsText }} {{"Mapper"}} @@ -88,7 +88,7 @@ @@ -183,7 +184,9 @@ export default { createStreamByIdDialog: false, createStreamByIdText: "", preferences: {}, - tab: "streams" + tab: "streams", + searchText: '', + streamsText: 'Streams' } }, computed: { @@ -209,8 +212,9 @@ export default { }) bus.$on('update-preferences', async (preferences) => { - let prefs = JSON.parse(preferences) - this.preferences = prefs + this.preferences = JSON.parse(preferences) + this.searchText = this.preferences.user.fe2 ? 'Search projects' : 'Search streams' + this.streamsText = this.preferences.user.fe2 ? 'Projects' : 'Streams' this.$vuetify.theme.dark = this.preferences.user.dark_theme }) diff --git a/ui/src/components/StreamCard.vue b/ui/src/components/StreamCard.vue index 7f486e71..65882327 100644 --- a/ui/src/components/StreamCard.vue +++ b/ui/src/components/StreamCard.vue @@ -13,7 +13,7 @@
- +
@@ -133,7 +133,7 @@ hide-details dense flat - placeholder="Write your commit message here" + :placeholder="`Write your ${commitText.toLowerCase()} message here`" /> @@ -204,7 +204,10 @@ export default { commitId: 'latest', commitMessage: null, invalid: false, - diffing: false + diffing: false, + streamText: '', + branchText: '', + commitText: '' } }, apollo: { @@ -286,6 +289,15 @@ export default { } }, mounted() { + bus.$on('update-preferences', async (preferences) => { + const pref = JSON.parse(preferences) + this.streamText = pref.user.fe2 ? 'Project' : 'Stream' + this.branchText = pref.user.fe2 ? 'Model' : 'Branch' + this.commitText = pref.user.fe2 ? 'Version' : 'Commit' + }) + // Collect preferences to render UI according to it + sketchup.exec({name: "collect_preferences", data: {}}) + bus.$on(`deactivate-diffing-${this.streamId}`, () => { this.diffing = false }) diff --git a/ui/src/components/dialogs/CreateBranchDialog.vue b/ui/src/components/dialogs/CreateBranchDialog.vue index 6150f106..03da9a42 100644 --- a/ui/src/components/dialogs/CreateBranchDialog.vue +++ b/ui/src/components/dialogs/CreateBranchDialog.vue @@ -3,7 +3,7 @@ @@ -169,6 +170,10 @@ export default { serverUrl: { type: String, default: null + }, + isFE2: { + type: Boolean, + default: false } }, data() { diff --git a/ui/src/components/dialogs/SettingsDialog.vue b/ui/src/components/dialogs/SettingsDialog.vue index 89a52a69..1809126d 100644 --- a/ui/src/components/dialogs/SettingsDialog.vue +++ b/ui/src/components/dialogs/SettingsDialog.vue @@ -16,14 +16,25 @@ Settings - + +
User Preferences
+ + mdi-theme-light-dark Color Mode + + + - More Streams + {{ `More ${streamsText}` }}
@@ -64,7 +64,8 @@ export default { data() { return { showMoreEnabled: true, - savedStreams: [] + savedStreams: [], + streamsText: '' } }, computed: { @@ -80,6 +81,14 @@ export default { } }, mounted() { + bus.$on('update-preferences', async (preferences) => { + const pref = JSON.parse(preferences) + this.streamsText = pref.user.fe2 ? 'Projects' : 'Streams' + }) + + // Collect preferences to render UI according to it + sketchup.exec({name: "collect_preferences", data: {}}) + bus.$on("deactivate-diffing-except", (exceptedStreamId) => { this.savedStreams.forEach((streamId) => { if (streamId !== exceptedStreamId){ From b8d4f3d946c93b627de9163023bd33a54513eeed Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 10 Nov 2023 15:43:39 +0300 Subject: [PATCH 2/3] Parse FE2 urls to add projects via `ADD BY ID OR URL` --- ui/src/components/dialogs/CreateStreamDialog.vue | 2 +- ui/src/utils/streamWrapper.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/src/components/dialogs/CreateStreamDialog.vue b/ui/src/components/dialogs/CreateStreamDialog.vue index 1f708b0f..29cbf184 100644 --- a/ui/src/components/dialogs/CreateStreamDialog.vue +++ b/ui/src/components/dialogs/CreateStreamDialog.vue @@ -205,7 +205,7 @@ export default { }, async getStream(){ try { - const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl) + const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, this.isFE2) let res = await this.$apollo.query({ query: gql` query Stream($id: String!){ diff --git a/ui/src/utils/streamWrapper.js b/ui/src/utils/streamWrapper.js index dda02f4e..c11890c4 100644 --- a/ui/src/utils/streamWrapper.js +++ b/ui/src/utils/streamWrapper.js @@ -1,7 +1,11 @@ require('url') export class StreamWrapper { - constructor(streamIdOrUrl, accountId, serverUrl) { + constructor(streamIdOrUrl, accountId, serverUrl, isFE2) { + this.isFE2 = isFE2 + this.streamsKey = this.isFE2 ? 'projects/': 'streams/' + this.branchesKey = this.isFE2 ? 'models/': 'branches/' + this.commitsKey = this.isFE2 ? 'versions/': 'commits/' this.originalOutput = streamIdOrUrl try { this.streamWrapperFromUrl(streamIdOrUrl) @@ -18,7 +22,7 @@ export class StreamWrapper { this.segments = this.url.pathname.split('/').map((segment) => segment + '/') this.serverUrl = this.url.origin - if (this.segments.length >= 4 && this.segments[3]?.toLowerCase() === "branches/"){ + if (this.segments.length >= 4 && this.segments[3]?.toLowerCase() === this.branchesKey){ this.streamId = this.segments[2].replace("/", "") if (this.segments.length > 5) { @@ -32,7 +36,7 @@ export class StreamWrapper { } else { switch (this.segments.length){ case 3: // ie http://speckle.server/streams/8fecc9aa6d - if (this.segments[1].toLowerCase() === "streams/") + if (this.segments[1].toLowerCase() === this.streamsKey) this.streamId = this.segments[2].replace("/", ""); else throw new Error(`Cannot parse ${this.originalOutput} into a stream wrapper class`); @@ -48,7 +52,7 @@ export class StreamWrapper { break; case 5: // ie http://speckle.server/streams/8fecc9aa6d/commits/76a23d7179 switch (this.segments[3].toLowerCase()){ - case "commits/": + case this.commitsKey: this.streamId = this.segments[2].replace("/", ""); this.commitId = this.segments[4].replace("/", ""); break; @@ -57,7 +61,7 @@ export class StreamWrapper { this.branchName = this.segments[3].replace("/", ""); this.commitId = this.segments[4].replace("/", ""); break; - case "branches/": + case this.branchesKey: this.streamId = this.segments[2].replace("/", ""); this.branchName = this.segments[4].replace("/", ""); break; From 0552f695f9426fdb8fe6426bd6ae682017264632 Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Fri, 10 Nov 2023 16:49:51 +0300 Subject: [PATCH 3/3] Update FE2 terms for Mapper Tool --- ui/src/App.vue | 10 +++++++--- ui/src/components/Mapper.vue | 12 +++++++++++- ui/src/components/MapperSource.vue | 12 ++++++++++-- ui/src/components/StreamCard.vue | 10 ++++++++-- ui/src/components/dialogs/CreateBranchDialog.vue | 12 ++++++++---- ui/src/components/dialogs/CreateStreamDialog.vue | 6 +++--- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/ui/src/App.vue b/ui/src/App.vue index 823c4e5b..b94e5e40 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -116,7 +116,7 @@ - + @@ -175,7 +175,7 @@ export default { size: { type: Number, default: 42 - }, + } }, data() { return { @@ -186,7 +186,9 @@ export default { preferences: {}, tab: "streams", searchText: '', - streamsText: 'Streams' + streamsText: 'Streams', + streamText: 'Stream', + branchText: 'Branch' } }, computed: { @@ -215,6 +217,8 @@ export default { this.preferences = JSON.parse(preferences) this.searchText = this.preferences.user.fe2 ? 'Search projects' : 'Search streams' this.streamsText = this.preferences.user.fe2 ? 'Projects' : 'Streams' + this.streamText = this.preferences.user.fe2 ? 'Project' : 'Stream' + this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch' this.$vuetify.theme.dark = this.preferences.user.dark_theme }) diff --git a/ui/src/components/Mapper.vue b/ui/src/components/Mapper.vue index 262d29a7..8823c9f4 100644 --- a/ui/src/components/Mapper.vue +++ b/ui/src/components/Mapper.vue @@ -89,7 +89,7 @@ - + @@ -300,6 +300,16 @@ global.mappedEntitiesUpdated = function (mappedEntities) { export default { name: "Mapper", + props: { + streamText: { + type: String, + default: '' + }, + branchText: { + type: String, + default: '' + } + }, components: { MapperSource: () => import('@/components/MapperSource.vue'), GlobalToast: () => import('@/components/GlobalToast'), diff --git a/ui/src/components/MapperSource.vue b/ui/src/components/MapperSource.vue index 29d3119c..674f6a32 100644 --- a/ui/src/components/MapperSource.vue +++ b/ui/src/components/MapperSource.vue @@ -2,7 +2,7 @@
- +
@@ -207,7 +211,8 @@ export default { diffing: false, streamText: '', branchText: '', - commitText: '' + commitText: '', + preferences: {} } }, apollo: { @@ -291,6 +296,7 @@ export default { mounted() { bus.$on('update-preferences', async (preferences) => { const pref = JSON.parse(preferences) + this.preferences = pref this.streamText = pref.user.fe2 ? 'Project' : 'Stream' this.branchText = pref.user.fe2 ? 'Model' : 'Branch' this.commitText = pref.user.fe2 ? 'Version' : 'Commit' diff --git a/ui/src/components/dialogs/CreateBranchDialog.vue b/ui/src/components/dialogs/CreateBranchDialog.vue index 03da9a42..0bc90d07 100644 --- a/ui/src/components/dialogs/CreateBranchDialog.vue +++ b/ui/src/components/dialogs/CreateBranchDialog.vue @@ -3,7 +3,7 @@