Skip to content

Commit

Permalink
Feat (FE2): Support fe2 terminology and urls
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhankoral authored Nov 13, 2023
2 parents 556ddc0 + 0552f69 commit de7dd34
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 34 deletions.
10 changes: 7 additions & 3 deletions speckle_connector/src/preferences/preferences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 15 additions & 7 deletions ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
>
<v-tabs-slider class="mx-sm-1"></v-tabs-slider>
<v-tab href="#streams">
{{"Streams"}}
{{ streamsText }}
</v-tab>
<v-tab href="#mapper">
{{"Mapper"}}
Expand Down Expand Up @@ -88,7 +88,7 @@
<v-text-field
v-model="streamSearchQuery"
prepend-inner-icon="mdi-magnify"
label="Search streams"
:label="searchText"
background-color="background"
hide-details
clearable
Expand All @@ -101,6 +101,7 @@
</v-container>
<create-stream-dialog
v-if="accounts().length !== 0"
:is-f-e2="preferences && preferences.user && preferences.user.fe2"
:account-id="activeAccount().userInfo.id"
:server-url="activeAccount().serverInfo.url"
/>
Expand All @@ -115,7 +116,7 @@
</v-tab-item>
<v-tab-item :key="2" value="mapper">
<v-card flat>
<mapper></mapper>
<mapper :stream-text="streamText" :branch-text="branchText"></mapper>
</v-card>
</v-tab-item>
</v-tabs-items>
Expand Down Expand Up @@ -174,7 +175,7 @@ export default {
size: {
type: Number,
default: 42
},
}
},
data() {
return {
Expand All @@ -183,7 +184,11 @@ export default {
createStreamByIdDialog: false,
createStreamByIdText: "",
preferences: {},
tab: "streams"
tab: "streams",
searchText: '',
streamsText: 'Streams',
streamText: 'Stream',
branchText: 'Branch'
}
},
computed: {
Expand All @@ -209,8 +214,11 @@ 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.streamText = this.preferences.user.fe2 ? 'Project' : 'Stream'
this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch'
this.$vuetify.theme.dark = this.preferences.user.dark_theme
})
Expand Down
12 changes: 11 additions & 1 deletion ui/src/components/Mapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
</v-container>
</v-expansion-panel-header>
<v-expansion-panel-content>
<mapper-source :source-state="this.sourceState"/>
<mapper-source :stream-text="streamText" :branch-text="branchText" :source-state="this.sourceState"/>
</v-expansion-panel-content>
</v-expansion-panel>

Expand Down Expand Up @@ -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'),
Expand Down
12 changes: 10 additions & 2 deletions ui/src/components/MapperSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<v-container class="pa-0">
<v-autocomplete
v-model="sourceStreamId"
label="Stream"
:label="streamText"
:items="allStreamsList"
item-text="name"
item-value="id"
Expand All @@ -12,7 +12,7 @@
<v-autocomplete
v-model="sourceBranchId"
class="pt-0 mb-n5"
label="Branch"
:label="branchText"
:items="allBranchesList"
:disabled="sourceStreamId === null"
item-text="name"
Expand Down Expand Up @@ -63,6 +63,14 @@ export default {
props: {
streamSearchQuery: { type: String, default: null },
sourceState: { type: String, default: 'Not Set' },
streamText: {
type: String,
default: ''
},
branchText: {
type: String,
default: ''
}
},
data() {
return {
Expand Down
26 changes: 22 additions & 4 deletions ui/src/components/StreamCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<v-toolbar-title class="ml-0" style="position: relative; left: -10px">
<!-- Uncomment when pinning is in place and add style="position: relative; left: -10px" to the element above :) -->
<v-btn
v-tooltip="'Pin this stream - it will be saved to this file.'"
v-tooltip="`Pin this ${streamText.toLowerCase()} - it will be saved to this file.`"
icon
x-small
@click="toggleSavedStream"
Expand Down Expand Up @@ -66,7 +66,11 @@
<template #activator="{ on, attrs }">
<v-slide-x-transition>
<div v-show="hover">
<create-branch-dialog :stream-name="stream.name" :stream-id="streamId"/>
<create-branch-dialog
:is-f-e2="preferences && preferences.user && preferences.user.fe2"
:stream-name="stream.name"
:stream-id="streamId"
/>
</div>
</v-slide-x-transition>
<v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on">
Expand Down Expand Up @@ -133,7 +137,7 @@
hide-details
dense
flat
placeholder="Write your commit message here"
:placeholder="`Write your ${commitText.toLowerCase()} message here`"
/>
</div>
</v-slide-y-transition>
Expand Down Expand Up @@ -204,7 +208,11 @@ export default {
commitId: 'latest',
commitMessage: null,
invalid: false,
diffing: false
diffing: false,
streamText: '',
branchText: '',
commitText: '',
preferences: {}
}
},
apollo: {
Expand Down Expand Up @@ -286,6 +294,16 @@ 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'
})
// Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}})
bus.$on(`deactivate-diffing-${this.streamId}`, () => {
this.diffing = false
})
Expand Down
16 changes: 12 additions & 4 deletions ui/src/components/dialogs/CreateBranchDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<v-dialog v-model="showCreateBranch">
<template #activator="{ on: dialog, attrs }">
<v-btn
v-tooltip="'Create Branch'"
v-tooltip="`Create ${isFE2 ? 'Model' : 'Branch'}`"
icon x-small class="ml-0 mr-1"
v-bind="attrs"
v-on="{...dialog}"
Expand All @@ -15,10 +15,10 @@
</template>
<v-card>
<v-card-title class="text-h5 mb-1">
Create a New Branch
{{ `Create a New ${isFE2 ? 'Model' : 'Branch'}` }}
</v-card-title>
<v-card-subtitle class="py-0 my-0 font-italic">
under {{ streamName }} stream
{{ `under ${streamName} ${isFE2 ? 'project' : 'stream'}` }}
</v-card-subtitle>
<v-container class="px-6" pb-0>
<v-text-field
Expand All @@ -27,7 +27,7 @@
hide-details
dense
flat
placeholder="Branch Name"
:placeholder="`${isFE2 ? 'Model' : 'Branch'} Name`"
/>
<v-text-field
v-model="description"
Expand Down Expand Up @@ -75,6 +75,14 @@ export default {
streamName: {
type: String,
default: null
},
isFE2: {
type: Boolean,
default: false
},
branchTooltipName: {
type: String,
default: ''
}
},
data() {
Expand Down
15 changes: 10 additions & 5 deletions ui/src/components/dialogs/CreateStreamDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
left
>
mdi-plus-circle
</v-icon>Create New Stream
</v-icon>
{{ `Create New ${isFE2 ? 'Project': 'Stream'}` }}
</v-btn>
</template>

<v-card>
<v-card-title class="text-h5">
Create a New Stream
{{ `Create a New ${isFE2 ? 'Project' : 'Stream'}` }}
</v-card-title>
<v-container class="px-6" pb-0>
<!--
Expand Down Expand Up @@ -55,7 +56,7 @@
hide-details
dense
flat
placeholder="Stream Name (Optional)"
:placeholder="`${isFE2 ? 'Project' : 'Stream'} Name (Optional)`"
/>
<v-text-field
v-model="description"
Expand All @@ -67,7 +68,7 @@
/>
<v-switch
v-model="privateStream"
:label="'Private Stream'"
:label="`Private ${isFE2 ? 'Project' : 'Stream'}`"
></v-switch>
</v-container>

Expand Down Expand Up @@ -169,6 +170,10 @@ export default {
serverUrl: {
type: String,
default: null
},
isFE2: {
type: Boolean,
default: false
}
},
data() {
Expand Down Expand Up @@ -200,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!){
Expand Down
24 changes: 23 additions & 1 deletion ui/src/components/dialogs/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@
Settings
</v-card-title>
<v-container class="px-6" pb-0>
<!-- Switch Theme -->

<!-- User preferences -->
<div class="sm1 mt-3">User Preferences</div>
<v-divider class="mb-2"/>

<!-- Switch Theme -->
<v-btn icon small class="mx-1" @click="switchTheme">
<v-icon>mdi-theme-light-dark</v-icon>
</v-btn>
<span>Color Mode</span>

<!-- FE2 -->
<v-switch
:input-value="fe2"
class="pt-3 mt-n2 mb-n7"
:label="'FE2'"
@change="fe2Handler"
/>

<!-- Register objects as Speckle Entity on send/receive -->
<v-switch
:input-value="registerSpeckleEntity"
Expand Down Expand Up @@ -133,6 +144,7 @@ export default {
includeComponentAttributes: this.preferences.model.include_component_entity_attributes,
mergeCoplanarFaces: this.preferences.model.merge_coplanar_faces,
diffing: this.preferences.user.diffing,
fe2: this.preferences.user.fe2,
registerSpeckleEntity: this.preferences.user.register_speckle_entity
}
},
Expand All @@ -147,6 +159,7 @@ export default {
this.includeComponentAttributes = newValue.model.include_component_entity_attributes
this.mergeCoplanarFaces = newValue.model.merge_coplanar_faces
this.diffing = newValue.user.diffing
this.fe2 = newValue.user.fe2
this.registerSpeckleEntity = newValue.user.register_speckle_entity
},
deep: true,
Expand All @@ -161,6 +174,15 @@ export default {
}
},
methods: {
fe2Handler(newValue){
this.fe2 = !!newValue
sketchup.exec({
name: "user_preferences_updated",
data: {preference_hash: "configSketchup", preference: "fe2", value: this.fe2}
})
this.$mixpanel.track('Connector Action', { name: 'Toggle FE2' })
sketchup.exec({name: "collect_preferences", data: {}})
},
diffingHandler(newValue){
this.diffing = !!newValue
sketchup.exec({
Expand Down
Loading

0 comments on commit de7dd34

Please sign in to comment.