@budibase/frontend-core 2.12.1 → 2.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.3",
|
|
4
4
|
"description": "Budibase frontend core libraries used in builder and client",
|
|
5
5
|
"author": "Budibase",
|
|
6
6
|
"license": "MPL-2.0",
|
|
7
7
|
"svelte": "src/index.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@budibase/bbui": "2.12.
|
|
10
|
-
"@budibase/shared-core": "2.12.
|
|
9
|
+
"@budibase/bbui": "2.12.3",
|
|
10
|
+
"@budibase/shared-core": "2.12.3",
|
|
11
11
|
"dayjs": "^1.10.8",
|
|
12
12
|
"lodash": "^4.17.21",
|
|
13
13
|
"socket.io-client": "^4.6.1",
|
|
14
14
|
"svelte": "^3.46.2"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "d82a3912eadf1074938c6d38b4fb1cbc61afe445"
|
|
17
17
|
}
|
package/src/api/tables.js
CHANGED
|
@@ -140,4 +140,13 @@ export const buildTableEndpoints = API => ({
|
|
|
140
140
|
},
|
|
141
141
|
})
|
|
142
142
|
},
|
|
143
|
+
migrateColumn: async ({ tableId, oldColumn, newColumn }) => {
|
|
144
|
+
return await API.post({
|
|
145
|
+
url: `/api/tables/${tableId}/migrate`,
|
|
146
|
+
body: {
|
|
147
|
+
oldColumn,
|
|
148
|
+
newColumn,
|
|
149
|
+
},
|
|
150
|
+
})
|
|
151
|
+
},
|
|
143
152
|
})
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { getContext, onMount, tick } from "svelte"
|
|
3
3
|
import { canBeDisplayColumn, canBeSortColumn } from "@budibase/shared-core"
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Icon,
|
|
6
|
+
Popover,
|
|
7
|
+
Menu,
|
|
8
|
+
MenuItem,
|
|
9
|
+
clickOutside,
|
|
10
|
+
Modal,
|
|
11
|
+
} from "@budibase/bbui"
|
|
5
12
|
import GridCell from "./GridCell.svelte"
|
|
6
13
|
import { getColumnIcon } from "../lib/utils"
|
|
14
|
+
import MigrationModal from "../controls/MigrationModal.svelte"
|
|
7
15
|
import { debounce } from "../../../utils/utils"
|
|
8
16
|
import { FieldType, FormulaTypes } from "@budibase/types"
|
|
17
|
+
import { TableNames } from "../../../constants"
|
|
9
18
|
|
|
10
19
|
export let column
|
|
11
20
|
export let idx
|
|
@@ -45,6 +54,7 @@
|
|
|
45
54
|
let editIsOpen = false
|
|
46
55
|
let timeout
|
|
47
56
|
let popover
|
|
57
|
+
let migrationModal
|
|
48
58
|
let searchValue
|
|
49
59
|
let input
|
|
50
60
|
|
|
@@ -189,6 +199,11 @@
|
|
|
189
199
|
})
|
|
190
200
|
}
|
|
191
201
|
|
|
202
|
+
const openMigrationModal = () => {
|
|
203
|
+
migrationModal.show()
|
|
204
|
+
open = false
|
|
205
|
+
}
|
|
206
|
+
|
|
192
207
|
const startSearching = async () => {
|
|
193
208
|
$focusedCellId = null
|
|
194
209
|
searchValue = ""
|
|
@@ -224,6 +239,10 @@
|
|
|
224
239
|
onMount(() => subscribe("close-edit-column", cancelEdit))
|
|
225
240
|
</script>
|
|
226
241
|
|
|
242
|
+
<Modal bind:this={migrationModal}>
|
|
243
|
+
<MigrationModal {column} />
|
|
244
|
+
</Modal>
|
|
245
|
+
|
|
227
246
|
<div
|
|
228
247
|
class="header-cell"
|
|
229
248
|
class:open
|
|
@@ -363,6 +382,11 @@
|
|
|
363
382
|
>
|
|
364
383
|
Hide column
|
|
365
384
|
</MenuItem>
|
|
385
|
+
{#if $config.canEditColumns && column.schema.type === "link" && column.schema.tableId === TableNames.USERS}
|
|
386
|
+
<MenuItem icon="User" on:click={openMigrationModal}>
|
|
387
|
+
Migrate to user column
|
|
388
|
+
</MenuItem>
|
|
389
|
+
{/if}
|
|
366
390
|
</Menu>
|
|
367
391
|
{/if}
|
|
368
392
|
</Popover>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import {
|
|
3
|
+
ModalContent,
|
|
4
|
+
notifications,
|
|
5
|
+
Input,
|
|
6
|
+
InlineAlert,
|
|
7
|
+
} from "@budibase/bbui"
|
|
8
|
+
import { getContext } from "svelte"
|
|
9
|
+
import { ValidColumnNameRegex } from "@budibase/shared-core"
|
|
10
|
+
import { FieldSubtype, FieldType, RelationshipType } from "@budibase/types"
|
|
11
|
+
|
|
12
|
+
const { API, definition, rows } = getContext("grid")
|
|
13
|
+
|
|
14
|
+
export let column
|
|
15
|
+
|
|
16
|
+
let newColumnName = `${column.schema.name} migrated`
|
|
17
|
+
$: error = checkNewColumnName(newColumnName)
|
|
18
|
+
|
|
19
|
+
const checkNewColumnName = newColumnName => {
|
|
20
|
+
if (newColumnName === "") {
|
|
21
|
+
return "Column name can't be empty."
|
|
22
|
+
}
|
|
23
|
+
if (newColumnName in $definition.schema) {
|
|
24
|
+
return "New column name can't be the same as an existing column name."
|
|
25
|
+
}
|
|
26
|
+
if (newColumnName.match(ValidColumnNameRegex) === null) {
|
|
27
|
+
return "Illegal character; must be alpha-numeric."
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const migrateUserColumn = async () => {
|
|
32
|
+
let subtype = FieldSubtype.USERS
|
|
33
|
+
if (column.schema.relationshipType === RelationshipType.ONE_TO_MANY) {
|
|
34
|
+
subtype = FieldSubtype.USER
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
await API.migrateColumn({
|
|
39
|
+
tableId: $definition._id,
|
|
40
|
+
oldColumn: column.schema,
|
|
41
|
+
newColumn: {
|
|
42
|
+
name: newColumnName,
|
|
43
|
+
type: FieldType.BB_REFERENCE,
|
|
44
|
+
subtype,
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
notifications.success("Column migrated")
|
|
48
|
+
} catch (e) {
|
|
49
|
+
notifications.error(`Failed to migrate: ${e.message}`)
|
|
50
|
+
}
|
|
51
|
+
await rows.actions.refreshData()
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<ModalContent
|
|
56
|
+
title="Migrate column"
|
|
57
|
+
confirmText="Continue"
|
|
58
|
+
cancelText="Cancel"
|
|
59
|
+
onConfirm={migrateUserColumn}
|
|
60
|
+
disabled={error !== undefined}
|
|
61
|
+
size="M"
|
|
62
|
+
>
|
|
63
|
+
This operation will kick off a migration of the column "{column.schema.name}"
|
|
64
|
+
to a new column, with the name provided - this operation may take a moment to
|
|
65
|
+
complete.
|
|
66
|
+
|
|
67
|
+
<InlineAlert
|
|
68
|
+
type="error"
|
|
69
|
+
header="Are you sure?"
|
|
70
|
+
message="This will leave bindings which utilised the user relationship column in a state where they will need to be updated to use the new column instead."
|
|
71
|
+
/>
|
|
72
|
+
<Input bind:value={newColumnName} label="New column name" {error} />
|
|
73
|
+
</ModalContent>
|