Frontend changes for the user column migration work.

This commit is contained in:
Sam Rose 2023-10-23 17:57:25 +01:00
parent 42e31d19fb
commit a701933f48
No known key found for this signature in database
2 changed files with 33 additions and 0 deletions

View File

@ -140,4 +140,13 @@ export const buildTableEndpoints = API => ({
},
})
},
migrateColumn: async ({ tableId, oldColumn, newColumn }) => {
return await API.post({
url: `/api/tables/${tableId}/migrate`,
body: {
oldColumn,
newColumn,
},
})
},
})

View File

@ -10,6 +10,7 @@
export let orderable = true
const {
API,
reorder,
isReordering,
isResizing,
@ -114,6 +115,24 @@
open = false
}
const migrateUserColumn = async () => {
let subtype = "users"
if (column.schema.relationshipType === "one-to-many") {
subtype = "user"
}
await API.migrateColumn({
tableId: $definition._id,
oldColumn: column.schema,
newColumn: {
name: `${column.schema.name} migrated`,
type: "bb_reference",
subtype,
},
})
open = false
}
const duplicateColumn = async () => {
open = false
@ -262,6 +281,11 @@
>
Hide column
</MenuItem>
{#if column.schema.type === "link" && column.schema.tableId === "ta_users"}
<MenuItem icon="User" on:click={migrateUserColumn}>
Migrate to user column
</MenuItem>
{/if}
</Menu>
{/if}
</Popover>