feat(dui): add disable cache toggle to main menu (#99)
* feat(dui): adds disable cache setting * fix(dui): excludes non-sharp dui connectors manually with slug check * chore(dui): adds todo * feat(dui): adds version check to isDisableCacheSupported
This commit is contained in:
@@ -36,6 +36,23 @@
|
|||||||
{{ isDarkTheme ? 'Light theme' : 'Dark theme' }}
|
{{ isDarkTheme ? 'Light theme' : 'Dark theme' }}
|
||||||
</div>
|
</div>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|
||||||
|
<MenuItem
|
||||||
|
v-if="isDisableCacheSupported"
|
||||||
|
v-slot="{ active }"
|
||||||
|
@click="toggleCache"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:class="[
|
||||||
|
active ? 'bg-highlight-1' : '',
|
||||||
|
'my-1 text-body-2xs flex justify-between px-2 py-1 text-foreground cursor-pointer transition mx-1 rounded'
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<span>Disable Cache</span>
|
||||||
|
<span v-if="isCacheDisabled" class="text-primary font-bold ml-2">✓</span>
|
||||||
|
</div>
|
||||||
|
</MenuItem>
|
||||||
|
|
||||||
<div class="border-t border-outline-3 mt-1">
|
<div class="border-t border-outline-3 mt-1">
|
||||||
<MenuItem v-if="app.$revitMapperBinding" v-slot="{ active }">
|
<MenuItem v-if="app.$revitMapperBinding" v-slot="{ active }">
|
||||||
<button
|
<button
|
||||||
@@ -120,12 +137,40 @@ import { storeToRefs } from 'pinia'
|
|||||||
import { XMarkIcon, Bars3Icon } from '@heroicons/vue/20/solid'
|
import { XMarkIcon, Bars3Icon } from '@heroicons/vue/20/solid'
|
||||||
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
||||||
import { useConfigStore } from '~/store/config'
|
import { useConfigStore } from '~/store/config'
|
||||||
|
import { useHostAppStore } from '~/store/hostApp'
|
||||||
|
|
||||||
const app = useNuxtApp()
|
const app = useNuxtApp()
|
||||||
|
|
||||||
const uiConfigStore = useConfigStore()
|
const uiConfigStore = useConfigStore()
|
||||||
const { isDarkTheme, hasConfigBindings, isDevMode } = storeToRefs(uiConfigStore)
|
const { isDarkTheme, hasConfigBindings, isDevMode, isCacheDisabled } =
|
||||||
const { toggleTheme } = uiConfigStore
|
storeToRefs(uiConfigStore)
|
||||||
|
const { toggleTheme, toggleCache } = uiConfigStore
|
||||||
|
|
||||||
|
const hostAppStore = useHostAppStore()
|
||||||
|
const { hostAppName, connectorVersion } = storeToRefs(hostAppStore)
|
||||||
|
|
||||||
|
const isDisableCacheSupported = computed(() => {
|
||||||
|
const appName = hostAppName.value
|
||||||
|
const version = connectorVersion.value
|
||||||
|
|
||||||
|
if (!appName || !version) return false
|
||||||
|
|
||||||
|
// excludes non-sharp connectors (assuming they don't have backend cache bypass)
|
||||||
|
const nonSharpApps = ['sketchup', 'archicad', 'vectorworks']
|
||||||
|
if (nonSharpApps.includes(appName.toLowerCase())) return false
|
||||||
|
|
||||||
|
// always show in dev environments
|
||||||
|
if (version.includes('dev') || version.includes('local')) return true
|
||||||
|
|
||||||
|
// for sharp connectors, check if version is >= 3.18.0
|
||||||
|
const targetVersion = '3.18.0'
|
||||||
|
return (
|
||||||
|
version.localeCompare(targetVersion, undefined, {
|
||||||
|
numeric: true,
|
||||||
|
sensitivity: 'base'
|
||||||
|
}) >= 0
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const { $showDevTools, $openUrl } = useNuxtApp()
|
const { $showDevTools, $openUrl } = useNuxtApp()
|
||||||
const showAccountsDialog = ref(false)
|
const showAccountsDialog = ref(false)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export type GlobalConfig = {
|
|||||||
|
|
||||||
export type ConnectorConfig = {
|
export type ConnectorConfig = {
|
||||||
darkTheme: boolean
|
darkTheme: boolean
|
||||||
|
disableCache?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AccountsConfig = {
|
export type AccountsConfig = {
|
||||||
@@ -48,7 +49,7 @@ export class MockedConfigBinding implements IConfigBinding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getConfig() {
|
public async getConfig() {
|
||||||
return await { darkTheme: false }
|
return await { darkTheme: false, disableCache: false }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getGlobalConfig() {
|
public async getGlobalConfig() {
|
||||||
|
|||||||
+13
-2
@@ -8,11 +8,14 @@ export const useConfigStore = defineStore('configStore', () => {
|
|||||||
|
|
||||||
const userSelectedWorkspaceId = ref<string>()
|
const userSelectedWorkspaceId = ref<string>()
|
||||||
|
|
||||||
const config = ref<ConnectorConfig>({ darkTheme: true })
|
const config = ref<ConnectorConfig>({ darkTheme: true, disableCache: false })
|
||||||
|
|
||||||
const isDarkTheme = computed(() => {
|
const isDarkTheme = computed(() => {
|
||||||
return config.value?.darkTheme
|
return config.value?.darkTheme
|
||||||
})
|
})
|
||||||
|
const isCacheDisabled = computed(() => {
|
||||||
|
return config.value?.disableCache || false
|
||||||
|
})
|
||||||
const isDevMode = ref(false)
|
const isDevMode = ref(false)
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
@@ -20,6 +23,11 @@ export const useConfigStore = defineStore('configStore', () => {
|
|||||||
$configBinding.updateConfig(config.value)
|
$configBinding.updateConfig(config.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const toggleCache = () => {
|
||||||
|
config.value.disableCache = !config.value.disableCache
|
||||||
|
$configBinding.updateConfig(config.value)
|
||||||
|
}
|
||||||
|
|
||||||
const setUserSelectedWorkspace = (workspaceId: string) => {
|
const setUserSelectedWorkspace = (workspaceId: string) => {
|
||||||
userSelectedWorkspaceId.value = workspaceId
|
userSelectedWorkspaceId.value = workspaceId
|
||||||
try {
|
try {
|
||||||
@@ -33,7 +41,8 @@ export const useConfigStore = defineStore('configStore', () => {
|
|||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
if (!$configBinding) return
|
if (!$configBinding) return
|
||||||
config.value = await $configBinding.getConfig()
|
const fetchedConfig = await $configBinding.getConfig()
|
||||||
|
config.value = { disableCache: false, ...fetchedConfig }
|
||||||
const workspacesConfig = await $configBinding.getWorkspacesConfig()
|
const workspacesConfig = await $configBinding.getWorkspacesConfig()
|
||||||
if (workspacesConfig && workspacesConfig.userSelectedWorkspaceId) {
|
if (workspacesConfig && workspacesConfig.userSelectedWorkspaceId) {
|
||||||
userSelectedWorkspaceId.value = workspacesConfig.userSelectedWorkspaceId
|
userSelectedWorkspaceId.value = workspacesConfig.userSelectedWorkspaceId
|
||||||
@@ -51,9 +60,11 @@ export const useConfigStore = defineStore('configStore', () => {
|
|||||||
config,
|
config,
|
||||||
hasConfigBindings,
|
hasConfigBindings,
|
||||||
isDarkTheme,
|
isDarkTheme,
|
||||||
|
isCacheDisabled,
|
||||||
isDevMode,
|
isDevMode,
|
||||||
userSelectedWorkspaceId,
|
userSelectedWorkspaceId,
|
||||||
toggleTheme,
|
toggleTheme,
|
||||||
|
toggleCache,
|
||||||
setUserSelectedWorkspace
|
setUserSelectedWorkspace
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user