2021-08-13 12:24:47 +02:00
|
|
|
<script>
|
|
|
|
import Provider from "./Provider.svelte"
|
2022-02-25 14:26:11 +01:00
|
|
|
import { authStore, devToolsStore } from "stores"
|
2022-01-20 11:16:13 +01:00
|
|
|
import { ActionTypes } from "constants"
|
|
|
|
import { Constants } from "@budibase/frontend-core"
|
2021-08-13 12:24:47 +02:00
|
|
|
|
|
|
|
// Register this as a refreshable datasource so that user changes cause
|
|
|
|
// the user object to be refreshed
|
|
|
|
$: actions = [
|
|
|
|
{
|
|
|
|
type: ActionTypes.RefreshDatasource,
|
|
|
|
callback: () => authStore.actions.fetchUser(),
|
2022-01-20 11:16:13 +01:00
|
|
|
metadata: {
|
|
|
|
dataSource: { type: "table", tableId: Constants.TableNames.USERS },
|
|
|
|
},
|
2021-08-13 12:24:47 +02:00
|
|
|
},
|
|
|
|
]
|
|
|
|
</script>
|
|
|
|
|
2022-02-25 14:26:11 +01:00
|
|
|
<Provider
|
|
|
|
key="user"
|
|
|
|
data={{ ...$authStore, roleId: $devToolsStore.role || $authStore?.roleId }}
|
|
|
|
{actions}
|
|
|
|
>
|
2021-08-13 12:24:47 +02:00
|
|
|
<slot />
|
|
|
|
</Provider>
|