Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #330

Merged
merged 17 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ab6fc66
Fix link props in visual query builder (Fixes #315)
jaclarke Feb 23, 2024
a87c38f
Filter multi cardinality configs that can't be set at session level
jaclarke Feb 23, 2024
aeae928
Override `force_database_error` config when fetching schema/configs (…
jaclarke Feb 23, 2024
7ac063a
Fix loading full value of truncated data when editing multi str field…
jaclarke Feb 23, 2024
a3c2c1b
Improve rendering of long/multiline strings in dataview changes preview
jaclarke Feb 23, 2024
cc1b2a6
Trim trailing semicolon in dataview filter (Fixes #301)
jaclarke Feb 23, 2024
b60384c
Always order `id` column first in dataview (Fixes #300)
jaclarke Feb 23, 2024
d4a42b6
Add max height to inline editor in dataview (Partly fixes #303 and #313)
jaclarke Feb 23, 2024
ef718ea
Fix enum config select element being clipped in session config panel
jaclarke Feb 23, 2024
96a85a2
Default boolean config's to opposite of database default when enablin…
jaclarke Feb 23, 2024
1eaef1b
Don't try to convert null implicitLimit into number (Fixes #238)
jaclarke Feb 26, 2024
221b425
Fix copying of text in readonly code editor (Fixes #327)
jaclarke Feb 26, 2024
0bb41cf
In data editor, automatically link new inserted row when in edit mode…
jaclarke Feb 26, 2024
473deb0
Open nested data view in edit mode if parent is new inserted row (Fix…
jaclarke Feb 26, 2024
001c515
Correctly pluralise row count in dataview (Fixes #227)
jaclarke Feb 26, 2024
2c4d19f
De-duplicate queries when navigating repl history with ctrl+up/down (…
jaclarke Feb 26, 2024
55e6751
Update ui tests runner to use new cors config
jaclarke Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions shared/codeEditor/codeEditor.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
.codeEditor {
display: contents;

:global(.cm-content) {
user-select: text;
}

&.terminalCursor {
:global {
.cm-cursorLayer {
Expand Down
13 changes: 9 additions & 4 deletions shared/inspector/buildScalar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function renderValue(
showTypeTag: boolean = true,
overrideStyles: {[key: string]: string} = {},
implicitLength?: number,
noMultiline: boolean = false
singleLineLimit?: boolean | number
): {body: JSX.Element; height?: number} {
if (value == null) {
return {body: <span className={styles.scalar_empty}>{"{}"}</span>};
Expand Down Expand Up @@ -155,17 +155,22 @@ export function renderValue(

// @ts-ignore - Intentional fallthrough
case "std::json":
value = noMultiline ? value : prettyPrintJSON(value);
value = singleLineLimit ? value : prettyPrintJSON(value);
case "std::str": {
const str = noMultiline ? toSingleLineStr(value) : strToString(value);
const str = singleLineLimit
? toSingleLineStr(
value,
singleLineLimit === true ? undefined : singleLineLimit
)
: strToString(value);
return {
body: (
<span className={styles.scalar_string}>
{str}
{implicitLength && value.length === implicitLength ? "…" : ""}
</span>
),
height: noMultiline ? 1 : (str as string).split("\n").length,
height: singleLineLimit ? 1 : (str as string).split("\n").length,
};
}
}
Expand Down
15 changes: 15 additions & 0 deletions shared/studio/components/dataEditor/dataEditor.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
background: #262626;
}
}

& > .panel {
max-height: calc(100vh - 230px);
overflow: auto;
@include hideScrollbar;
}
}

.actions {
Expand Down Expand Up @@ -155,8 +161,13 @@
font-size: 14px;
line-height: 22px;
min-height: 32px;
max-height: 300px;
white-space: pre;
@include hideScrollbar;

.dataEditor & {
resize: vertical;
}
}

@include darkTheme {
Expand Down Expand Up @@ -202,6 +213,10 @@
border-radius: 4px 0 0 4px;
}
}

.dataEditor > & textarea {
max-height: calc(100vh - 200px);
}
}

.errMessage {
Expand Down
62 changes: 38 additions & 24 deletions shared/studio/components/dataEditor/editor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useEffect, useRef} from "react";
import {action, makeObservable, observable} from "mobx";
import {action, makeObservable, observable, runInAction} from "mobx";

import cn from "@edgedb/common/utils/classNames";

Expand Down Expand Up @@ -33,40 +33,54 @@ export class DataEditorState {
) {
makeObservable(this);

if (isEditorValue) {
this.value = value;
const _init = (_value: any) =>
runInAction(() => {
if (isEditorValue) {
this.value = _value;
} else {
this.value =
_value != null
? isMulti
? _value.map((val: any) => valueToEditorValue(val, type))
: valueToEditorValue(_value, type)
: isRequired
? isMulti
? []
: newPrimitiveValue(type)[0]
: null;
}

this.hasError =
this.value === null
? false
: isMulti
? (this.value as EditorValue[]).some(
(v: any) => !isEditorValueValid(v, type)
)
: !isEditorValueValid(this.value, type);

this.loaded = true;
});

if (value instanceof Promise) {
value.then((_value) => _init(_value));
} else {
this.value =
value != null
? isMulti
? value.map((val: any) => valueToEditorValue(val, type))
: valueToEditorValue(value, type)
: isRequired
? isMulti
? []
: newPrimitiveValue(type)[0]
: null;
_init(value);
}

this.hasError =
this.value === null
? false
: isMulti
? (this.value as EditorValue[]).some(
(v: any) => !isEditorValueValid(v, type)
)
: !isEditorValueValid(this.value, type);
}

@observable
loaded = false;

isEdited = false;

@observable.ref value: EditorValue | null;
@observable.ref value: EditorValue | null = null;
@action setValue(val: EditorValue | null) {
this.value = val;
this.isEdited = true;
}

@observable hasError: boolean;
@observable hasError: boolean = false;
@action setError(err: boolean) {
this.hasError = err;
}
Expand Down
9 changes: 8 additions & 1 deletion shared/studio/components/sessionState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,14 @@ function ListItem({
) : null}
</div>

<div className={cn(styles.itemValue, {[styles.inactive]: !active})}>
<div
className={cn(styles.itemValue, {
[styles.inactive]: !active,
[styles.noOverflow]: !(
type.schemaType === "Scalar" && type.enum_values != null
),
})}
>
{active ? (
<>
<Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,15 @@
align-items: center;
min-height: 32px;
min-width: 0;
overflow-x: auto;

@include hideScrollbar;

@include darkTheme {
--select-option-color: #adadad;
}

&.noOverflow {
overflow-x: auto;
@include hideScrollbar;
}
}

.setNullButton {
Expand Down
4 changes: 3 additions & 1 deletion shared/studio/components/visualQuerybuilder/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ function renderQuery(query: QueryBuilderShape, indent: string): string {
...[...query.props].map(
([name, type]) =>
(type ? `[is ${escapeName(type, true)}].` : "") +
escapeName(name, false)
(name.startsWith("@")
? `@${escapeName(name.slice(1), false)}`
: escapeName(name, false))
),
...[...query.links].map(
([name, subQuery]) =>
Expand Down
4 changes: 4 additions & 0 deletions shared/studio/state/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type QueryOpts = {
newCodec?: boolean;
ignoreSessionConfig?: boolean;
implicitLimit?: bigint;
ignoreForceDatabaseError?: boolean;
};

type PendingQuery = {
Expand Down Expand Up @@ -214,6 +215,9 @@ export class Connection extends Model({
if (opts.ignoreSessionConfig) {
state = Session.defaults().withGlobals(state.globals);
}
if (opts.ignoreForceDatabaseError) {
state = state.withConfig({force_database_error: "false"});
}

if (kind === "execute") {
await this.conn.rawExecute(
Expand Down
15 changes: 12 additions & 3 deletions shared/studio/state/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ export class DatabaseState extends Model({
}

async updateObjectCount() {
const {result} = await this.connection.query(`select count(std::Object)`);
const {result} = await this.connection.query(
`select count(std::Object)`,
undefined,
{ignoreSessionConfig: true, ignoreForceDatabaseError: true}
);
if (result) {
runInAction(() => {
this.objectCount = Number(result[0]);
Expand Down Expand Up @@ -195,7 +199,9 @@ export class DatabaseState extends Model({
} FILTER NOT EXISTS .children).id
),
version := sys::get_version(),
}`
}`,
undefined,
{ignoreSessionConfig: true, ignoreForceDatabaseError: true}
)
.then(({result}) => ({
migrationId: (result![0].migrationId[0] ?? null) as
Expand Down Expand Up @@ -235,7 +241,10 @@ export class DatabaseState extends Model({
try {
rawData = yield* _await(
conn
.query(getIntrospectionQuery(edgedbVersion))
.query(getIntrospectionQuery(edgedbVersion), undefined, {
ignoreSessionConfig: true,
ignoreForceDatabaseError: true,
})
.then(({result}) => {
return result![0] as RawIntrospectionResult;
})
Expand Down
34 changes: 24 additions & 10 deletions shared/studio/state/sessionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ import {
newPrimitiveValue,
parseEditorValue,
PrimitiveType,
valueToEditorValue,
} from "../components/dataEditor/utils";
import {fetchSessionState, storeSessionState} from "../idbStore";
import {connCtx} from "./connection";
import {dbCtx} from "./database";
import {instanceCtx} from "./instance";

type DraftStateItem = {
interface DraftStateItem {
active: boolean;
type: Frozen<SchemaType>;
description?: string;
value: Frozen<EditorValue | null>;
value: Frozen<EditorValue>;
error: boolean;
};
}

interface DraftStateGlobalItem extends Omit<DraftStateItem, "value"> {
value: Frozen<EditorValue | null>;
}

type DraftState = {
globals: {
[key: string]: DraftStateItem;
[key: string]: DraftStateGlobalItem;
};
config: {
[key: string]: DraftStateItem;
Expand Down Expand Up @@ -186,6 +191,7 @@ export class SessionState extends Model({
.filter(
(prop) =>
prop.name !== "id" &&
prop.cardinality !== "Many" &&
!prop.annotations.some(
(anno) =>
(anno.name === "cfg::system" || anno.name === "cfg::internal") &&
Expand Down Expand Up @@ -221,15 +227,16 @@ export class SessionState extends Model({
}

for (const configName of this.configNames) {
const type = configType.properties[configName].target!;
const configSchema = configType.properties[configName];
const type = configSchema.target!;
const storedItem = sessionStateData?.config[configName];
const newVal =
storedItem?.value == null
? newPrimitiveValue(type as PrimitiveType)
: null;
draftState.config[configName] = {
type: frozen(type, FrozenCheckMode.Off),
description: configType.properties[configName].annotations.find(
description: configSchema.annotations.find(
(anno) => anno.name === "std::description"
)?.["@value"],
active: storedItem?.active ?? false,
Expand Down Expand Up @@ -337,18 +344,25 @@ export class SessionState extends Model({
const result = await conn.query(
`select cfg::Config {${this.configNames.join(", ")}}`,
undefined,
{ignoreSessionConfig: true}
{ignoreSessionConfig: true, ignoreForceDatabaseError: true}
);

if (result.result) {
const values = result.result![0];
runInAction(() => (this.configValues = values));
for (const configName of this.configNames) {
if (this.draftState?.config[configName].value === null) {
const config = this.draftState?.config[configName];
if (config?.active === false) {
let value = values[configName];
if (typeof value === "boolean") {
value = !value;
}
objectActions.set(
this.draftState.config[configName],
this.draftState!.config[configName],
"value",
values[configName].toString()
frozen(
valueToEditorValue(value, config.type.data as PrimitiveType)
)
);
}
}
Expand Down
Loading
Loading