Browse Source

fix(gui): reload app info after setting license

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4917/head
Pranav C 2 years ago
parent
commit
196e4a5b61
  1. 5
      packages/nc-gui/components/account/License.vue
  2. 11
      packages/nc-gui/composables/useGlobal/actions.ts
  3. 1
      packages/nc-gui/composables/useGlobal/types.ts

5
packages/nc-gui/components/account/License.vue

@ -1,12 +1,14 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { extractSdkResponseErrorMsg, useApi } from '#imports' import { extractSdkResponseErrorMsg, useApi,useGlobal } from '#imports'
const { api, isLoading } = useApi() const { api, isLoading } = useApi()
const {$e} = useNuxtApp() const {$e} = useNuxtApp()
const {loadAppInfo} = useGlobal()
let key = $ref('') let key = $ref('')
const loadLicense = async () => { const loadLicense = async () => {
@ -22,6 +24,7 @@ const setLicense = async () => {
try { try {
await api.orgLicense.set({ key: key }) await api.orgLicense.set({ key: key })
message.success('License key updated') message.success('License key updated')
await loadAppInfo();
} catch (e) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }

11
packages/nc-gui/composables/useGlobal/actions.ts

@ -43,5 +43,14 @@ export function useGlobalActions(state: State): Actions {
}) })
} }
return { signIn, signOut, refreshToken } const loadAppInfo = async () => {
try {
const nuxtApp = useNuxtApp()
state.appInfo.value = await nuxtApp.$api.utils.appInfo()
} catch (e) {
console.error(e)
}
}
return { signIn, signOut, refreshToken, loadAppInfo }
} }

1
packages/nc-gui/composables/useGlobal/types.ts

@ -61,6 +61,7 @@ export interface Actions {
signOut: () => void signOut: () => void
signIn: (token: string) => void signIn: (token: string) => void
refreshToken: () => void refreshToken: () => void
loadAppInfo: () => void
} }
export type ReadonlyState = Readonly<Pick<State, 'token' | 'user'>> & Omit<State, 'token' | 'user'> export type ReadonlyState = Readonly<Pick<State, 'token' | 'user'>> & Omit<State, 'token' | 'user'>

Loading…
Cancel
Save