user table and relationships complete
This commit is contained in:
parent
b44b2cf881
commit
a92d54f9a7
|
@ -2,6 +2,7 @@
|
||||||
import { Input, Button, TextButton, Select, Toggle } from "@budibase/bbui"
|
import { Input, Button, TextButton, Select, Toggle } from "@budibase/bbui"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
|
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
import ValuesList from "components/common/ValuesList.svelte"
|
import ValuesList from "components/common/ValuesList.svelte"
|
||||||
|
@ -30,6 +31,12 @@
|
||||||
table => table._id !== $backendUiStore.draftTable._id
|
table => table._id !== $backendUiStore.draftTable._id
|
||||||
)
|
)
|
||||||
$: required = !!field?.constraints?.presence || primaryDisplay
|
$: required = !!field?.constraints?.presence || primaryDisplay
|
||||||
|
$: uneditable = $backendUiStore.selectedTable?._id === TableNames.USERS && UNEDITABLE_USER_FIELDS.includes(field.name)
|
||||||
|
$: {
|
||||||
|
console.log($backendUiStore.selectedTable)
|
||||||
|
console.log(field.name)
|
||||||
|
console.log(uneditable)
|
||||||
|
}
|
||||||
|
|
||||||
async function saveColumn() {
|
async function saveColumn() {
|
||||||
backendUiStore.update(state => {
|
backendUiStore.update(state => {
|
||||||
|
@ -87,7 +94,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="actions" class:hidden={deletion}>
|
<div class="actions" class:hidden={deletion}>
|
||||||
<Input label="Name" thin bind:value={field.name} />
|
<Input label="Name" thin bind:value={field.name} disabled={uneditable} />
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
disabled={originalName}
|
disabled={originalName}
|
||||||
|
@ -101,7 +108,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
{#if field.type !== 'link'}
|
{#if field.type !== 'link' && !uneditable}
|
||||||
<Toggle
|
<Toggle
|
||||||
checked={required}
|
checked={required}
|
||||||
on:change={onChangeRequired}
|
on:change={onChangeRequired}
|
||||||
|
@ -157,7 +164,7 @@
|
||||||
bind:value={field.fieldName} />
|
bind:value={field.fieldName} />
|
||||||
{/if}
|
{/if}
|
||||||
<footer class="create-column-options">
|
<footer class="create-column-options">
|
||||||
{#if originalName}
|
{#if !uneditable && originalName}
|
||||||
<TextButton text on:click={confirmDelete}>Delete Column</TextButton>
|
<TextButton text on:click={confirmDelete}>Delete Column</TextButton>
|
||||||
{/if}
|
{/if}
|
||||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto } from "@sveltech/routify"
|
import { goto } from "@sveltech/routify"
|
||||||
import { backendUiStore } from "builderStore"
|
import { backendUiStore } from "builderStore"
|
||||||
|
import { TableNames } from "constants"
|
||||||
import ListItem from "./ListItem.svelte"
|
import ListItem from "./ListItem.svelte"
|
||||||
import CreateTableModal from "./modals/CreateTableModal.svelte"
|
import CreateTableModal from "./modals/CreateTableModal.svelte"
|
||||||
import EditTablePopover from "./popovers/EditTablePopover.svelte"
|
import EditTablePopover from "./popovers/EditTablePopover.svelte"
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
{#each $backendUiStore.tables as table, idx}
|
{#each $backendUiStore.tables as table, idx}
|
||||||
<NavItem
|
<NavItem
|
||||||
border={idx > 0}
|
border={idx > 0}
|
||||||
icon="ri-table-line"
|
icon={`ri-${table._id === TableNames.USERS ? 'user' : 'table'}-line`}
|
||||||
text={table.name}
|
text={table.name}
|
||||||
selected={selectedView === `all_${table._id}`}
|
selected={selectedView === `all_${table._id}`}
|
||||||
on:click={() => selectTable(table)}>
|
on:click={() => selectTable(table)}>
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
key: "GENERAL",
|
key: "GENERAL",
|
||||||
component: General,
|
component: General,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Users",
|
||||||
|
key: "USERS",
|
||||||
|
component: Users,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "API Keys",
|
title: "API Keys",
|
||||||
key: "API_KEYS",
|
key: "API_KEYS",
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
export const TableNames = {
|
||||||
|
USERS: "ta_users",
|
||||||
|
}
|
||||||
|
|
||||||
|
// fields on the user table that cannot be edited
|
||||||
|
export const UNEDITABLE_USER_FIELDS = ["username", "password", "accessLevelId"]
|
||||||
|
|
||||||
export const DEFAULT_PAGES_OBJECT = {
|
export const DEFAULT_PAGES_OBJECT = {
|
||||||
main: {
|
main: {
|
||||||
props: {
|
props: {
|
||||||
|
|
|
@ -68,16 +68,11 @@
|
||||||
<div class="toprightnav">
|
<div class="toprightnav">
|
||||||
<ThemeEditor />
|
<ThemeEditor />
|
||||||
<FeedbackNavLink />
|
<FeedbackNavLink />
|
||||||
<div class="topnavitemright">
|
|
||||||
<a target="_blank" href="https://docs.budibase.com">
|
|
||||||
<i class="ri-question-line" />
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="topnavitemright">
|
<div class="topnavitemright">
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://github.com/Budibase/budibase/discussions">
|
href="https://github.com/Budibase/budibase/discussions">
|
||||||
<i class="ri-discuss-line" />
|
<i class="ri-question-line" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<SettingsLink />
|
<SettingsLink />
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
FACKEL
|
|
@ -67,6 +67,39 @@ async function createInstance(template) {
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
throw "Error loading database dump from template."
|
throw "Error loading database dump from template."
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// create the users table
|
||||||
|
await db.put({
|
||||||
|
_id: "ta_users",
|
||||||
|
type: "table",
|
||||||
|
views: {},
|
||||||
|
name: "Users",
|
||||||
|
schema: {
|
||||||
|
username: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
length: {
|
||||||
|
maximum: "",
|
||||||
|
},
|
||||||
|
presence: true,
|
||||||
|
},
|
||||||
|
fieldName: "username",
|
||||||
|
name: "username",
|
||||||
|
},
|
||||||
|
accessLevelId: {
|
||||||
|
fieldName: "accessLevelId",
|
||||||
|
name: "accessLevelId",
|
||||||
|
type: "options",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
presence: false,
|
||||||
|
inclusion: Object.values(BUILTIN_LEVEL_IDS),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
primaryDisplay: "username",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return { _id: appId }
|
return { _id: appId }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const CouchDB = require("../../db")
|
const CouchDB = require("../../db")
|
||||||
const bcrypt = require("../../utilities/bcrypt")
|
const bcrypt = require("../../utilities/bcrypt")
|
||||||
const { generateUserID, getUserParams } = require("../../db/utils")
|
const { generateUserID, getUserParams, ViewNames } = require("../../db/utils")
|
||||||
const {
|
const {
|
||||||
BUILTIN_LEVEL_ID_ARRAY,
|
BUILTIN_LEVEL_ID_ARRAY,
|
||||||
} = require("../../utilities/security/accessLevels")
|
} = require("../../utilities/security/accessLevels")
|
||||||
|
@ -44,6 +44,7 @@ exports.create = async function(ctx) {
|
||||||
type: "user",
|
type: "user",
|
||||||
accessLevelId,
|
accessLevelId,
|
||||||
permissions: permissions || [BUILTIN_PERMISSION_NAMES.POWER],
|
permissions: permissions || [BUILTIN_PERMISSION_NAMES.POWER],
|
||||||
|
tableId: ViewNames.USERS,
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -38,6 +38,6 @@ function replicateLocal() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// replicateLocal()
|
replicateLocal()
|
||||||
|
|
||||||
module.exports = Pouch
|
module.exports = Pouch
|
||||||
|
|
|
@ -20,6 +20,7 @@ const DocumentTypes = {
|
||||||
const ViewNames = {
|
const ViewNames = {
|
||||||
LINK: "by_link",
|
LINK: "by_link",
|
||||||
ROUTING: "screen_routes",
|
ROUTING: "screen_routes",
|
||||||
|
USERS: "ta_users",
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.ViewNames = ViewNames
|
exports.ViewNames = ViewNames
|
||||||
|
@ -80,13 +81,12 @@ exports.generateTableID = () => {
|
||||||
exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
||||||
if (tableId == null) {
|
if (tableId == null) {
|
||||||
return getDocParams(DocumentTypes.ROW, null, otherProps)
|
return getDocParams(DocumentTypes.ROW, null, otherProps)
|
||||||
} else {
|
|
||||||
const endOfKey =
|
|
||||||
rowId == null
|
|
||||||
? `${tableId}${SEPARATOR}`
|
|
||||||
: `${tableId}${SEPARATOR}${rowId}`
|
|
||||||
return getDocParams(DocumentTypes.ROW, endOfKey, otherProps)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const endOfKey =
|
||||||
|
rowId == null ? `${tableId}${SEPARATOR}` : `${tableId}${SEPARATOR}${rowId}`
|
||||||
|
|
||||||
|
return getDocParams(DocumentTypes.ROW, endOfKey, otherProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,7 @@ exports.getUserParams = (username = null, otherProps = {}) => {
|
||||||
* @returns {string} The new user ID which the user doc can be stored under.
|
* @returns {string} The new user ID which the user doc can be stored under.
|
||||||
*/
|
*/
|
||||||
exports.generateUserID = username => {
|
exports.generateUserID = username => {
|
||||||
return `${DocumentTypes.USER}${SEPARATOR}${username}`
|
return `${DocumentTypes.ROW}${SEPARATOR}${ViewNames.USERS}${SEPARATOR}${DocumentTypes.USER}${SEPARATOR}${username}`
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,6 @@ const { existsSync } = require("fs-extra")
|
||||||
const initialiseBudibase = require("./utilities/initialiseBudibase")
|
const initialiseBudibase = require("./utilities/initialiseBudibase")
|
||||||
const { budibaseAppsDir } = require("./utilities/budibaseDir")
|
const { budibaseAppsDir } = require("./utilities/budibaseDir")
|
||||||
const { openNewGitHubIssue, debugInfo } = require("electron-util")
|
const { openNewGitHubIssue, debugInfo } = require("electron-util")
|
||||||
const open = require("open")
|
|
||||||
|
|
||||||
const budibaseDir = budibaseAppsDir()
|
const budibaseDir = budibaseAppsDir()
|
||||||
const envFile = join(budibaseDir, ".env")
|
const envFile = join(budibaseDir, ".env")
|
||||||
|
@ -42,7 +41,7 @@ async function startApp() {
|
||||||
|
|
||||||
function handleRedirect(e, url) {
|
function handleRedirect(e, url) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
open(url)
|
shell.openExternal(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createWindow() {
|
async function createWindow() {
|
||||||
|
|
Loading…
Reference in New Issue