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 { cloneDeep } from "lodash/fp"
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
|
||||
import { FIELDS } from "constants/backend"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import ValuesList from "components/common/ValuesList.svelte"
|
||||
|
@ -30,6 +31,12 @@
|
|||
table => table._id !== $backendUiStore.draftTable._id
|
||||
)
|
||||
$: 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() {
|
||||
backendUiStore.update(state => {
|
||||
|
@ -87,7 +94,7 @@
|
|||
</script>
|
||||
|
||||
<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
|
||||
disabled={originalName}
|
||||
|
@ -101,7 +108,7 @@
|
|||
{/each}
|
||||
</Select>
|
||||
|
||||
{#if field.type !== 'link'}
|
||||
{#if field.type !== 'link' && !uneditable}
|
||||
<Toggle
|
||||
checked={required}
|
||||
on:change={onChangeRequired}
|
||||
|
@ -157,7 +164,7 @@
|
|||
bind:value={field.fieldName} />
|
||||
{/if}
|
||||
<footer class="create-column-options">
|
||||
{#if originalName}
|
||||
{#if !uneditable && originalName}
|
||||
<TextButton text on:click={confirmDelete}>Delete Column</TextButton>
|
||||
{/if}
|
||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<script>
|
||||
import { goto } from "@sveltech/routify"
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { TableNames } from "constants"
|
||||
import ListItem from "./ListItem.svelte"
|
||||
import CreateTableModal from "./modals/CreateTableModal.svelte"
|
||||
import EditTablePopover from "./popovers/EditTablePopover.svelte"
|
||||
|
@ -42,7 +43,7 @@
|
|||
{#each $backendUiStore.tables as table, idx}
|
||||
<NavItem
|
||||
border={idx > 0}
|
||||
icon="ri-table-line"
|
||||
icon={`ri-${table._id === TableNames.USERS ? 'user' : 'table'}-line`}
|
||||
text={table.name}
|
||||
selected={selectedView === `all_${table._id}`}
|
||||
on:click={() => selectTable(table)}>
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
key: "GENERAL",
|
||||
component: General,
|
||||
},
|
||||
{
|
||||
title: "Users",
|
||||
key: "USERS",
|
||||
component: Users,
|
||||
},
|
||||
{
|
||||
title: "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 = {
|
||||
main: {
|
||||
props: {
|
||||
|
|
|
@ -68,16 +68,11 @@
|
|||
<div class="toprightnav">
|
||||
<ThemeEditor />
|
||||
<FeedbackNavLink />
|
||||
<div class="topnavitemright">
|
||||
<a target="_blank" href="https://docs.budibase.com">
|
||||
<i class="ri-question-line" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="topnavitemright">
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://github.com/Budibase/budibase/discussions">
|
||||
<i class="ri-discuss-line" />
|
||||
<i class="ri-question-line" />
|
||||
</a>
|
||||
</div>
|
||||
<SettingsLink />
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
FACKEL
|
|
@ -67,6 +67,39 @@ async function createInstance(template) {
|
|||
if (!ok) {
|
||||
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 }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const CouchDB = require("../../db")
|
||||
const bcrypt = require("../../utilities/bcrypt")
|
||||
const { generateUserID, getUserParams } = require("../../db/utils")
|
||||
const { generateUserID, getUserParams, ViewNames } = require("../../db/utils")
|
||||
const {
|
||||
BUILTIN_LEVEL_ID_ARRAY,
|
||||
} = require("../../utilities/security/accessLevels")
|
||||
|
@ -44,6 +44,7 @@ exports.create = async function(ctx) {
|
|||
type: "user",
|
||||
accessLevelId,
|
||||
permissions: permissions || [BUILTIN_PERMISSION_NAMES.POWER],
|
||||
tableId: ViewNames.USERS,
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -38,6 +38,6 @@ function replicateLocal() {
|
|||
})
|
||||
}
|
||||
|
||||
// replicateLocal()
|
||||
replicateLocal()
|
||||
|
||||
module.exports = Pouch
|
||||
|
|
|
@ -20,6 +20,7 @@ const DocumentTypes = {
|
|||
const ViewNames = {
|
||||
LINK: "by_link",
|
||||
ROUTING: "screen_routes",
|
||||
USERS: "ta_users",
|
||||
}
|
||||
|
||||
exports.ViewNames = ViewNames
|
||||
|
@ -80,13 +81,12 @@ exports.generateTableID = () => {
|
|||
exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
||||
if (tableId == null) {
|
||||
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.
|
||||
*/
|
||||
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 { budibaseAppsDir } = require("./utilities/budibaseDir")
|
||||
const { openNewGitHubIssue, debugInfo } = require("electron-util")
|
||||
const open = require("open")
|
||||
|
||||
const budibaseDir = budibaseAppsDir()
|
||||
const envFile = join(budibaseDir, ".env")
|
||||
|
@ -42,7 +41,7 @@ async function startApp() {
|
|||
|
||||
function handleRedirect(e, url) {
|
||||
e.preventDefault()
|
||||
open(url)
|
||||
shell.openExternal(url)
|
||||
}
|
||||
|
||||
async function createWindow() {
|
||||
|
|
Loading…
Reference in New Issue