Frontend changes for the user column migration work.
This commit is contained in:
parent
42e31d19fb
commit
a701933f48
|
@ -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,
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue