Skip to content

Commit

Permalink
revert(web, framework, novui): Revert autocomplete in Studio (novuhq#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont authored Aug 1, 2024
1 parent ebdcdbd commit 194a65b
Show file tree
Hide file tree
Showing 28 changed files with 76 additions and 854 deletions.
1 change: 0 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"bcast",
"behaviour",
"bestguess",
"tiptap",
"binipdisplay",
"bitauth",
"bitjson",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/app/events/e2e/bridge-trigger.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ contexts.forEach((context: Context) => {
controlSchema: {
type: 'object',
properties: {
name: { type: 'string', default: 'Hello {{payload.name}}' },
name: { type: 'string', default: 'Hello {{name}}' },
},
} as const,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const LocalStudioHeader: FC = () => {
borderBottom: 'none !important',
zIndex: 'sticky',
padding: '50',
// TODO: because this component is directly from mantine, it doesn't respect layer styles
bgColor: 'surface.page !important',
})}
>
<HStack justifyContent="space-between" width="full" display="flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LocalizedMessage, Text } from '@novu/novui';
import { Flex, Stack } from '@novu/novui/jsx';
import { FC } from 'react';
import { css } from '@novu/novui/css';
import { Popover, useColorScheme } from '@novu/design-system';
import { Popover, Tooltip, useColorScheme } from '@novu/design-system';
import { useDisclosure } from '@mantine/hooks';

type LocalStudioSidebarOrganizationDisplayProps = {
Expand All @@ -24,9 +24,6 @@ export const LocalStudioSidebarOrganizationDisplay: FC<LocalStudioSidebarOrganiz
offset={0}
withinPortal
title="Novu Local Studio"
classNames={{
dropdown: css({ bg: 'surface.popover !important', border: 'none !important', shadow: 'medium !important' }),
}}
target={
<Flex gap="50" py="75" px="100" onMouseEnter={open} onMouseLeave={close}>
<img
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import reportWebVitals from './reportWebVitals';
import { LAUNCH_DARKLY_CLIENT_SIDE_ID } from './config';

import './index.css';
import '@novu/novui/components.css';
import '@novu/novui/styles.css';

(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ function WorkflowFloatingMenuButton({ Icon, tooltipLabel, onClick }: IWorkflowFl
padding: '75 !important',
borderRadius: '100',
_hover: {
bg: 'select.option.surface.selected',
// TODO: this doesn't work due to all the !important in novui... need to fix layer styles
bg: 'legacy.B30 !important',
'& svg': {
color: 'typography.text.main !important',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useDocsModal } from '../../../../components/docs/useDocsModal';
import { When } from '../../../../components/utils/When';
import { ControlsEmptyPanel } from './ControlsEmptyPanel';
import { useTelemetry } from '../../../../hooks/useNovuAPI';
import { getSuggestionVariables, subscriberVariables } from '../../../utils';

export type OnChangeType = 'step' | 'payload';

Expand Down Expand Up @@ -49,16 +48,6 @@ export const WorkflowStepEditorControlsPanel: FC<IWorkflowStepEditorControlsPane
);
}, [workflow?.payload?.schema, workflow?.options?.payloadSchema, workflow?.payloadSchema]);

const payloadProperties = useMemo(() => {
const payloadObject =
workflow?.payload?.schema?.properties ||
workflow?.options?.payloadSchema?.properties ||
workflow?.payloadSchema?.properties ||
{};

return getSuggestionVariables(payloadObject, 'payload');
}, [workflow?.payload?.schema, workflow?.options?.payloadSchema, workflow?.payloadSchema]);

const haveControlProperties = useMemo(() => {
return Object.keys(step?.controls?.schema?.properties || step?.inputs?.schema?.properties || {}).length > 0;
}, [step?.controls?.schema, step?.inputs?.schema]);
Expand Down Expand Up @@ -104,7 +93,6 @@ export const WorkflowStepEditorControlsPanel: FC<IWorkflowStepEditorControlsPane
onChange={(data, id) => handleOnChange('step', data, id)}
schema={step?.controls?.schema || step?.inputs?.schema || {}}
formData={defaultControls || {}}
variables={[...(subscriberVariables || []), ...(payloadProperties || [])]}
/>
</When>
<When truthy={!haveControlProperties}>
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/studio/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './routing';
export * from './variables';
14 changes: 0 additions & 14 deletions apps/web/src/studio/utils/variables.ts

This file was deleted.

17 changes: 5 additions & 12 deletions libs/novui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"require": "./styled-system/jsx/index.js",
"import": "./styled-system/jsx/index.js"
},
"./styles.css": "./src/index.css"
"./styles.css": "./styled-system/styles.css",
"./components.css": "./node_modules/@mantine/core/styles.layer.css"
},
"scripts": {
"dev": "pnpm build && pnpm storybook",
Expand Down Expand Up @@ -130,21 +131,13 @@
}
},
"dependencies": {
"@mantine/code-highlight": "^7.11.2",
"@mantine/core": "^7.11.2",
"@mantine/hooks": "^7.11.2",
"@mantine/tiptap": "^7.11.2",
"@mantine/code-highlight": "^7.10.2",
"@mantine/core": "^7.10.0",
"@mantine/hooks": "^7.10.0",
"@rjsf/core": "^5.17.1",
"@rjsf/utils": "^5.17.1",
"@rjsf/validator-ajv8": "^5.17.1",
"@tanstack/react-table": "^8.17.3",
"@tiptap/extension-document": "^2.5.0",
"@tiptap/extension-mention": "^2.5.0",
"@tiptap/extension-paragraph": "^2.5.0",
"@tiptap/extension-text": "^2.5.0",
"@tiptap/pm": "^3.0.0",
"@tiptap/react": "^3.0.0",
"@tiptap/suggestion": "^2.5.0",
"react-icons": "^5.0.1"
}
}
2 changes: 0 additions & 2 deletions libs/novui/src/index.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@layer reset, base, mantine, tokens, recipes, utilities;

@import '@mantine/core/styles.layer.css';
@import '@mantine/tiptap/styles.layer.css';
@import '../styled-system/styles.css';
13 changes: 1 addition & 12 deletions libs/novui/src/json-schema-components/JsonSchemaForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,7 @@ const Template: StoryFn<typeof JsonSchemaForm> = ({ colorPalette, ...args }) =>
Save
</Button>
</HStack>
<JsonSchemaForm
{...args}
variables={[
'fakeautocomplete.foo',
'fakeautocomplete.bar',
'fakeautocomplete.fizz',
'fakeautocomplete.buzz',
'fakeautocomplete.croissantia',
'fakeautocomplete.olympics',
'fakeautocomplete.reallylongstringthatshouldoverflow',
]}
/>
<JsonSchemaForm {...args} />
</form>
);
};
Expand Down
15 changes: 6 additions & 9 deletions libs/novui/src/json-schema-components/JsonSchemaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { CoreProps } from '../types';
import { ArrayFieldItemTemplate, ArrayFieldTemplate, ArrayFieldTitleTemplate } from './templates/ArrayFieldTemplate';
import { AddButton, MoveDownButton, MoveUpButton, RemoveButton } from './templates/IconButton';
import { ObjectFieldTemplate } from './templates/ObjectFieldTemplate';
import { CheckboxWidget, SelectWidget, InputEditorWidget } from './widgets';
import { CheckboxWidget, InputWidget, SelectWidget, TextareaWidget } from './widgets';
import { JSON_SCHEMA_FORM_ID_DELIMITER } from './utils';

const WIDGETS: RegistryWidgetsType = {
CheckboxWidget: CheckboxWidget,
SelectWidget: SelectWidget,
TextWidget: InputEditorWidget,
URLWidget: InputEditorWidget,
EmailWidget: InputEditorWidget,
TextWidget: TextareaWidget,
URLWidget: InputWidget,
EmailWidget: InputWidget,
};

const UI_SCHEMA: UiSchema = {
Expand All @@ -31,15 +31,13 @@ const UI_SCHEMA: UiSchema = {

export type JsonSchemaFormProps<TFormData = any> = JsxStyleProps &
CoreProps &
Pick<FormProps<TFormData>, 'onChange' | 'onSubmit' | 'onBlur' | 'schema' | 'formData' | 'tagName'> & {
variables?: string[];
};
Pick<FormProps<TFormData>, 'onChange' | 'onSubmit' | 'onBlur' | 'schema' | 'formData' | 'tagName'>;

/**
* Specialized form editor for data passed as JSON.
*/
export function JsonSchemaForm<TFormData = any>(props: JsonSchemaFormProps<TFormData>) {
const [cssProps, { className, variables, ...formProps }] = splitCssProps(props);
const [cssProps, { className, ...formProps }] = splitCssProps(props);

return (
<Form
Expand All @@ -62,7 +60,6 @@ export function JsonSchemaForm<TFormData = any>(props: JsonSchemaFormProps<TForm
widgets={WIDGETS}
validator={validator}
autoComplete={'false'}
formContext={{ variables }}
idSeparator={JSON_SCHEMA_FORM_ID_DELIMITER}
liveValidate
templates={{
Expand Down
134 changes: 0 additions & 134 deletions libs/novui/src/json-schema-components/widgets/InputEditorWidget.tsx

This file was deleted.

24 changes: 24 additions & 0 deletions libs/novui/src/json-schema-components/widgets/InputWidget.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { getInputProps, WidgetProps } from '@rjsf/utils';
import { Input, TextInputType } from '../../components/input/Input';

export const InputWidget = (props: WidgetProps) => {
const { type, value, label, schema, onChange, options, required, readonly, rawErrors, disabled } = props;
const inputProps = getInputProps(schema, type, options);

return (
<Input
description={props.schema.description}
onChange={(event) => {
event.preventDefault();
onChange(event.target.value);
}}
value={value || value === 0 ? value : ''}
required={required}
label={label}
type={inputProps.type as TextInputType}
error={rawErrors?.length > 0 && rawErrors}
readOnly={readonly}
disabled={disabled}
/>
);
};
Loading

0 comments on commit 194a65b

Please sign in to comment.