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

enhance AutoField and QodexActionExec components with metadata support and default response handling #44

Merged
merged 57 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d5e7f5e
enhance AutoField and QodexActionExec components with metadata suppor…
Dec 10, 2024
26ecf11
update reqraft dependency to version 0.6.10 and improve error handlin…
Dec 10, 2024
be2fe45
update @qoretechnologies/ts-toolkit dependency to version 0.4.10 and …
Dec 10, 2024
019b953
update @qoretechnologies/ts-toolkit dependency to version 0.4.11
Dec 10, 2024
d3bcaf9
Performance fixes
Dec 11, 2024
3edcdb4
remove unnecessary sleep duration in _testsSelectItemFromCollection f…
Dec 11, 2024
05d5191
add waitFor to ensure condition field is present before changing its …
Dec 11, 2024
92f12f4
refactor CI workflow to run story tests with vitest and silence test …
Foxhoundn Dec 12, 2024
ae1939c
disable Chromatic for AddNewSetWithEventTrigger story
Foxhoundn Dec 12, 2024
406e9c9
disable Chromatic for CreateNewSetWithEventTrigger story
Foxhoundn Dec 12, 2024
f20064b
refactor: simplify fixedValue assignment and use fixOptions for value…
Foxhoundn Dec 12, 2024
8f1cdaf
refactor: enhance fixOptions to streamline fixedValue assignment and …
Foxhoundn Dec 12, 2024
a8a0981
fix: update Basic story to use an empty object instead of undefined f…
Foxhoundn Dec 12, 2024
0896890
refactor: update longStringField debounce time and improve state hand…
Dec 14, 2024
31a27b9
refactor: update SelectField tests to use single quotes for string li…
Dec 14, 2024
d73e693
refactor: enhance item display handling in SelectField and streamline…
Dec 14, 2024
b6ae4aa
fix: update localValue initialization in RichTextField to handle defa…
Dec 14, 2024
d46124e
feat: add 'onlyChanged' option to chromatic config and update reqore …
Dec 15, 2024
e3b9513
refactor: update type assertion in SaveValueModal for better clarity
Dec 15, 2024
30a1d3f
refactor: simplify useQorusStorage function by condensing return stat…
Dec 15, 2024
a3bb2b9
refactor: remove unnecessary props and streamline component configura…
Dec 15, 2024
86aa3b7
refactor: enhance Options component by improving label and intent han…
Dec 15, 2024
37386bb
refactor: enhance Options component by integrating filterable and sor…
Dec 15, 2024
b91b10e
refactor: update Options component to include flat prop and adjust la…
Foxhoundn Dec 16, 2024
8df8e5b
refactor: update Options component to enable flat prop and adjust pad…
Foxhoundn Dec 16, 2024
db1aca5
refactor: update various components to enhance functionality and impr…
Foxhoundn Dec 17, 2024
9013356
refactor: enhance SelectField and story tests by adding ReqoreTag and…
Foxhoundn Dec 18, 2024
2db2c0e
refactor: add sleep delays in CreateNewSetWithEventTrigger story for …
Foxhoundn Dec 18, 2024
2cd5310
refactor: remove unnecessary state management logic from CreateNewSet…
Foxhoundn Dec 18, 2024
a51658b
refactor: increase timeout duration in _testsSelectAppOrAction for im…
Foxhoundn Dec 18, 2024
904deaa
refactor: increase sleep duration in AddNewSetWithEventTrigger story …
Foxhoundn Dec 18, 2024
6b569a1
refactor: add test exclusion tag to AddNewSetWithEventTrigger story f…
Foxhoundn Dec 18, 2024
66fd9f1
refactor: remove unused NewValueCanBeSaved story and adjust Connectio…
Foxhoundn Dec 18, 2024
fe2b98c
refactor: add debounce sleep to ValueCanBeSaved story for improved bu…
Foxhoundn Dec 18, 2024
ed30add
refactor: increase debounce sleep duration in ValueCanBeSaved story f…
Foxhoundn Dec 18, 2024
5c4011d
Performance optimized options
Dec 23, 2024
ea9d707
refactor: streamline URL handling and improve state management in For…
Foxhoundn Dec 25, 2024
8e4a1d8
Options fix
Foxhoundn Dec 25, 2024
b3d354c
refactor: Introduced local state to the options component to prevent …
Foxhoundn Dec 25, 2024
45c005d
refactor: replace useDebounce with useUpdateEffect for improved state…
Foxhoundn Dec 25, 2024
dcea1ee
refactor: simplify websocket handling in Storybook and update selecto…
Foxhoundn Dec 25, 2024
c1a7a9a
refactor: update input selectors in Mapper and FSM stories for improv…
Foxhoundn Dec 25, 2024
252cd2d
refactor: enhance websocket handling in Storybook by using useEffect …
Foxhoundn Dec 25, 2024
489eb6c
refactor: increase sleep duration in FSM stories for improved state t…
Foxhoundn Dec 25, 2024
d3065d5
refactor: increase sleep duration in FSM stories for improved state t…
Foxhoundn Dec 25, 2024
d8de15a
refactor: extend sleep duration in FSM stories for improved test reli…
Foxhoundn Dec 25, 2024
e95d4c4
refactor: extend sleep duration in FSM state tests for improved timin…
Foxhoundn Dec 25, 2024
66410bd
Bug fixes
Foxhoundn Dec 26, 2024
7c33f7e
refactor: enhance AppCatalogue component with sorting and query handl…
Foxhoundn Dec 30, 2024
3cb8df9
refactor: update AppSelector action handling and improve font styling…
Dec 30, 2024
c6545e6
refactor: update AppSelector action handling to include condition for…
Dec 30, 2024
8c75392
refactor: improve app sorting logic and enhance UI elements in AppCat…
Dec 30, 2024
3036ce2
refactor: enhance pull request workflow with concurrency settings and…
Dec 30, 2024
5e39295
refactor: improve styling of color picker component for better usabil…
Dec 30, 2024
857cd9f
refactor: streamline description handling and improve mapper validati…
Dec 31, 2024
e107d3d
refactor: update error handling in withMapper to use response status …
Dec 31, 2024
ad61539
refactor: update long description in stories to include truncation lo…
Dec 31, 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
9 changes: 5 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
env:
QORUS_TOKEN: ${{ secrets.QORUS_TOKEN }}
# Steps represent a sequence of tasks that will be executed as part of the job
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
# Get current time for the commit
- name: Get current time
Expand Down Expand Up @@ -73,11 +76,9 @@ jobs:
run: |
yarn test

- name: Serve Storybook and run tests
- name: Run story tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
"npx http-server storybook-static --port 6006 --silent" \
"npx wait-on tcp:6006 && yarn test-storybook"
yarn vitest src/stories

- name: Publish to Chromatic
id: chromatic_publish
Expand Down
7 changes: 5 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ const StorybookWrapper = ({ context, Story }: any) => {
);

React.useEffect(() => {
if (context.args.isFullIDE) {
if (context.args.isFullIDE || context.args.useRealWebSockets) {
// @ts-ignore
window._useWebsocketsInStorybook = true;
} else {
// @ts-ignore
window._useWebsocketsInStorybook = false;
}
}, [context.args.isFullIDE]);
}, [context.args.isFullIDE, context.args.useRealWebSockets]);

// @ts-ignore
React.useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
{
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"deepscan.enable": true
}
Binary file modified .yarn/install-state.gz
Binary file not shown.
22 changes: 11 additions & 11 deletions __tests__/fields/select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('renders <SelectField /> with default items', () => {

render(
<ReqoreUIProvider>
<Select defaultItems={items} onChange={onChange} name="test" />
<Select defaultItems={items} onChange={onChange} name='test' />
</ReqoreUIProvider>
);

Expand All @@ -42,7 +42,7 @@ test('renders <SelectField /> with default items and value', () => {

render(
<ReqoreUIProvider>
<Select defaultItems={items} value="Test3" onChange={onChange} name="test" />
<Select defaultItems={items} value='Test3' onChange={onChange} name='test' />
</ReqoreUIProvider>
);

Expand All @@ -56,7 +56,7 @@ test('renders <SelectField /> with default items, onChange is fired', () => {

render(
<ReqoreUIProvider>
<Select defaultItems={items} onChange={onChange} name="test" />
<Select defaultItems={items} onChange={onChange} name='test' />
</ReqoreUIProvider>
);

Expand All @@ -79,7 +79,7 @@ test('renders <SelectField /> with 1 item, auto selects it', () => {

render(
<ReqoreUIProvider>
<Select defaultItems={[{ name: 'Single item' }]} autoSelect onChange={onChange} name="test" />
<Select defaultItems={[{ name: 'Single item' }]} autoSelect onChange={onChange} name='test' />
</ReqoreUIProvider>
);

Expand All @@ -95,7 +95,7 @@ test('renders <SelectField /> with default items with description and value', ()

render(
<ReqoreUIProvider>
<Select defaultItems={itemsWithDescription} value="Test3" onChange={onChange} name="test" />
<Select defaultItems={itemsWithDescription} value='Test3' onChange={onChange} name='test' />
</ReqoreUIProvider>
);

Expand All @@ -120,9 +120,9 @@ test('renders <SelectField /> with default items and value, with forced dropdown
<ReqoreUIProvider>
<Select
defaultItems={itemsWithDescription}
value="Test3"
value='Test3'
onChange={onChange}
name="test"
name='test'
forceDropdown
/>
</ReqoreUIProvider>
Expand All @@ -144,7 +144,7 @@ test('renders <SelectField /> with items fetched from backend', async () => {
get_message={{ action: 'select-items' }}
return_message={{ action: 'select-items-response', return_value: 'testData' }}
onChange={onChange}
name="test"
name='test'
/>
</ReqoreUIProvider>
);
Expand Down Expand Up @@ -174,7 +174,7 @@ test('renders <SelectField /> with items fetched from backend and with filters',
get_message={{ action: 'select-items' }}
return_message={{ action: 'select-items-response', return_value: 'testData' }}
onChange={onChange}
name="test"
name='test'
filters={['filterMe']}
/>
</ReqoreUIProvider>
Expand All @@ -189,7 +189,7 @@ test('renders <SelectField /> with items fetched from backend and with filters',

expect(document.querySelectorAll('.reqore-modal').length).toBe(1);
expect(document.querySelectorAll('.reqore-collection-item').length).toBe(4);
expect(document.querySelectorAll('.reqore-button-badge').length).toBe(2);
expect(document.querySelectorAll('.reqore-button-badge').length).toBe(3);

fireEvent.click(screen.getAllByText('Filterme')[0]);

Expand All @@ -207,7 +207,7 @@ test('renders <SelectField /> with predicate filter', () => {
<Select
defaultItems={items}
onChange={onChange}
name="test"
name='test'
predicate={(name) => name.includes('filter me')}
/>
</ReqoreUIProvider>
Expand Down
3 changes: 2 additions & 1 deletion chromatic.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"projectId": "Project:65aa373e9d8605ecea107ce1",
"projectToken": "chpt_1aaa74dd9c1b035",
"zip": true
"zip": true,
"onlyChanged": true
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"@monaco-editor/react": "^4.6.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@qoretechnologies/python-parser": "^0.4.10",
"@qoretechnologies/reqore": "^0.48.18",
"@qoretechnologies/reqraft": "^0.6.9",
"@qoretechnologies/ts-toolkit": "^0.4.8",
"@qoretechnologies/reqore": "^0.48.24",
"@qoretechnologies/reqraft": "^0.6.10",
"@qoretechnologies/ts-toolkit": "0.4.13",
"@sentry/browser": "^7.109.0",
"@svgr/webpack": "^5.5.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ const App: FunctionComponent<IApp> = ({
{tab === 'Interfaces' && <InterfacesView type={subtab} />}
{!tab || (tab == 'CreateInterface' && <InterfaceCreator />)}
</>
<div id='reqore-portal' />
</div>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/Topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import { useReqraftStorage } from '@qoretechnologies/reqraft';
import { useState } from 'react';
import { GlobalSearch } from './components/GlobalSearch';
import { GlobalSettings } from './components/GlobalSettings';
import { useWhyDidYouUpdate } from './hooks/useWhyDidYouUpdate';

export const Topbar = () => {
const [isSidebarOpen, update] = useReqraftStorage<boolean>('sidebar-open', true, false);
const [isSettingsOpen, setIsSettingsOpen] = useState(false);

useWhyDidYouUpdate('TopBar', { isSidebarOpen, isSettingsOpen });

return (
<>
{isSettingsOpen && (
Expand Down
1 change: 0 additions & 1 deletion src/common/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ a:hover,
a:focus,
a:visited,
a:active {
text-decoration: none;
color: inherit;
}

Expand Down
12 changes: 8 additions & 4 deletions src/common/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,20 +414,24 @@ export const vscode =
action: 'select-items-response',
testData: [
{
name: 'Item 1',
display_name: 'Item 1',
value: 'Item 1',
desc: 'Item 1 description',
},
{
name: 'Item 2',
display_name: 'Item 2',
value: 'Item 2',
desc: 'Item 2 description',
},
{
name: 'Item 3',
display_name: 'Item 3',
value: 'Item 3',
desc: 'Item 3 description',
filterMe: true,
},
{
name: 'Item 4',
display_name: 'Item 4',
value: 'Item 4',
desc: 'Item 4 description',
},
],
Expand Down
175 changes: 175 additions & 0 deletions src/components/AllowedValues/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import { ReqoreMultiSelect } from '@qoretechnologies/reqore';
import { IReqoreButtonProps } from '@qoretechnologies/reqore/dist/components/Button';
import { IReqorePanelProps } from '@qoretechnologies/reqore/dist/components/Panel';
import { TQorusType } from '@qoretechnologies/ts-toolkit';
import { size as count } from 'lodash';
import { memo, useCallback, useMemo } from 'react';
import { apiHost } from '../../common/vscode';
import { useSavedValues } from '../../hooks/useSavedValues';
import { ConnectionManagement } from '../ConnectionManagement';
import Select, { ISelectFieldItem } from '../Field/select';

export interface IFieldAllowedValuesProps
extends Pick<IReqoreButtonProps, 'size' | 'disabled' | 'readOnly'> {
items: ISelectFieldItem[];
type: TQorusType;
value: unknown;
name?: string;
onChange: (name: string, value: unknown) => void;
allowCreation?: boolean;
showDescription?: boolean;
app?: string;
action?: string;
showSavedValues?: boolean;
}

export const FieldAllowedValues = memo(
({
items = [],
type,
onChange,
value,
allowCreation,
showSavedValues,
showDescription,
size,
disabled,
app,
action,
name,
readOnly,
}: IFieldAllowedValuesProps) => {
const savedValues = useSavedValues(type);

const getAllowedItemActionsByType = useCallback(
(
type: TQorusType,
item: unknown,
items: ISelectFieldItem[],
metadata?: ISelectFieldItem['metadata']
): IReqorePanelProps['actions'] => {
switch (type) {
case 'connection': {
return [
{
as: ConnectionManagement,
props: {
selectedConnection: item,
//onChange: (value) => handleChange(name, value),
allowedValues: items,
redirectUri: `${apiHost}grant`,
app,
metadata,
action,
compact: true,
size,
},
},
];
}
default: {
return [];
}
}
},
[size, app, action]
);

const fullItems = useMemo(() => {
let result: ISelectFieldItem[] = [
...items.map(({ metadata, ...rest }) => ({
actions: getAllowedItemActionsByType(type, value, items, metadata),
...rest,
})),
];

if (showSavedValues && !readOnly && !disabled) {
result = [
...result,
...savedValues.map(({ display_name, value, short_desc, actions }) => ({
display_name: display_name.value,
short_desc: short_desc.value,
value: value.value,
icon: 'SaveLine',
badge: 'Saved',
actions,
})),
] as ISelectFieldItem[];
}

return result;
}, [items, savedValues, type, value, showSavedValues, disabled, readOnly]);

const handleMultiSelectChange = useCallback(
(value: string[]) => {
onChange(name, value);
},
[onChange]
);

const multiSelectItems = useMemo(
() =>
items.map((item) => ({
value: item.value,
label: item.display_name,
description: item.short_desc,
intent: item.intent,
})),
[JSON.stringify(items)]
);

if (!count(fullItems) || type === 'enum' || (!count(items) && !showSavedValues)) {
return null;
}

if (type === 'list' && count(items)) {
return (
<ReqoreMultiSelect
items={multiSelectItems}
canCreateItems={allowCreation}
canRemoveItems
selectedItemSize='small'
value={value as string[]}
onValueChange={handleMultiSelectChange}
/>
);
}

// These are simple allowed values
if (count(items) && !allowCreation) {
return (
<Select
defaultItems={fullItems}
value={value}
autoSelect
name={name}
onChange={onChange}
type={type}
fluid
fixed={false}
showDescription={Boolean(showDescription || showDescription === undefined)}
style={{ width: '100%' }}
size={size}
disabled={disabled}
/>
);
}

return (
<Select
defaultItems={fullItems}
name={name}
onChange={onChange}
type={type}
fluid
fixed={false}
showDescription={false}
style={{ width: '100%' }}
placeholder={'Saved & Suggested Values'}
size={size}
disabled={disabled}
icon='SaveFill'
/>
);
}
);
Loading
Loading