2020-03-27 09:02:11 +00:00
|
|
|
import {
|
|
|
|
|
all,
|
|
|
|
|
call,
|
2023-01-28 02:17:06 +00:00
|
|
|
delay,
|
2020-03-27 09:02:11 +00:00
|
|
|
put,
|
2023-01-28 02:17:06 +00:00
|
|
|
select,
|
2020-03-27 09:02:11 +00:00
|
|
|
takeEvery,
|
2023-01-28 02:17:06 +00:00
|
|
|
takeLatest,
|
2020-03-27 09:02:11 +00:00
|
|
|
} from "redux-saga/effects";
|
|
|
|
|
|
|
|
|
|
import { generateReactKey } from "utils/generators";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ModalWidgetResize, WidgetAddChild } from "actions/pageActions";
|
|
|
|
|
import { updateAndSaveLayout } from "actions/pageActions";
|
2021-09-20 17:06:13 +00:00
|
|
|
import {
|
|
|
|
|
GridDefaults,
|
|
|
|
|
MAIN_CONTAINER_WIDGET_ID,
|
|
|
|
|
} from "constants/WidgetConstants";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
2020-03-27 09:02:11 +00:00
|
|
|
import {
|
|
|
|
|
ReduxActionErrorTypes,
|
|
|
|
|
ReduxActionTypes,
|
2021-08-03 08:06:48 +00:00
|
|
|
WidgetReduxActionTypes,
|
2022-04-12 10:50:01 +00:00
|
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
2020-03-27 09:02:11 +00:00
|
|
|
|
|
|
|
|
import {
|
2021-09-20 17:06:13 +00:00
|
|
|
getWidget,
|
2020-03-27 09:02:11 +00:00
|
|
|
getWidgetByName,
|
|
|
|
|
getWidgetIdsByType,
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
getWidgetMetaProps,
|
2023-01-28 02:17:06 +00:00
|
|
|
getWidgets,
|
|
|
|
|
getWidgetsMeta,
|
2020-03-27 09:02:11 +00:00
|
|
|
} from "sagas/selectors";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type {
|
2021-09-20 17:06:13 +00:00
|
|
|
CanvasWidgetsReduxState,
|
|
|
|
|
FlattenedWidgetProps,
|
|
|
|
|
} from "reducers/entityReducers/canvasWidgetsReducer";
|
2022-05-25 09:46:14 +00:00
|
|
|
import { updateWidgetMetaPropAndEval } from "actions/metaActions";
|
2023-01-28 02:17:06 +00:00
|
|
|
import { focusWidget, showModal } from "actions/widgetActions";
|
2021-03-13 14:24:45 +00:00
|
|
|
import log from "loglevel";
|
2021-02-11 06:25:11 +00:00
|
|
|
import { flatten } from "lodash";
|
2023-09-06 12:15:04 +00:00
|
|
|
import WidgetFactory from "WidgetProvider/factory";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { WidgetProps } from "widgets/BaseWidget";
|
2023-01-28 02:17:06 +00:00
|
|
|
import { selectWidgetInitAction } from "actions/widgetSelectionActions";
|
|
|
|
|
import { SelectionRequestType } from "./WidgetSelectUtils";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { toast } from "design-system";
|
2023-04-07 13:51:35 +00:00
|
|
|
import { getIsAutoLayout } from "selectors/editorSelectors";
|
|
|
|
|
import { recalculateAutoLayoutColumnsAndSave } from "./AutoLayoutUpdateSagas";
|
|
|
|
|
import {
|
|
|
|
|
FlexLayerAlignment,
|
|
|
|
|
LayoutDirection,
|
2023-10-02 19:41:05 +00:00
|
|
|
} from "layoutSystems/common/utils/constants";
|
2021-09-09 15:10:22 +00:00
|
|
|
const WidgetTypes = WidgetFactory.widgetTypes;
|
|
|
|
|
|
2020-04-03 09:32:13 +00:00
|
|
|
export function* createModalSaga(action: ReduxAction<{ modalName: string }>) {
|
2020-03-27 09:02:11 +00:00
|
|
|
try {
|
|
|
|
|
const modalWidgetId = generateReactKey();
|
2023-04-07 13:51:35 +00:00
|
|
|
const isAutoLayout: boolean = yield select(getIsAutoLayout);
|
|
|
|
|
const newWidget: WidgetAddChild = {
|
2020-03-27 09:02:11 +00:00
|
|
|
widgetId: MAIN_CONTAINER_WIDGET_ID,
|
2020-04-03 09:32:13 +00:00
|
|
|
widgetName: action.payload.modalName,
|
2020-03-27 09:02:11 +00:00
|
|
|
type: WidgetTypes.MODAL_WIDGET,
|
|
|
|
|
newWidgetId: modalWidgetId,
|
|
|
|
|
parentRowSpace: 1,
|
|
|
|
|
parentColumnSpace: 1,
|
|
|
|
|
leftColumn: 0,
|
|
|
|
|
topRow: 0,
|
|
|
|
|
columns: 0,
|
|
|
|
|
rows: 0,
|
2020-04-15 11:42:11 +00:00
|
|
|
tabId: "",
|
2020-03-27 09:02:11 +00:00
|
|
|
};
|
2023-04-07 13:51:35 +00:00
|
|
|
|
|
|
|
|
if (isAutoLayout) {
|
|
|
|
|
const dropPayload = {
|
|
|
|
|
alignment: FlexLayerAlignment.Center,
|
|
|
|
|
index: 0,
|
|
|
|
|
isNewLayer: true,
|
|
|
|
|
layerIndex: 0,
|
|
|
|
|
rowIndex: 0,
|
|
|
|
|
};
|
|
|
|
|
newWidget.props = {
|
|
|
|
|
alignment: FlexLayerAlignment.Center,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.AUTOLAYOUT_ADD_NEW_WIDGETS,
|
|
|
|
|
payload: {
|
|
|
|
|
dropPayload,
|
|
|
|
|
newWidget,
|
|
|
|
|
parentId: MAIN_CONTAINER_WIDGET_ID,
|
|
|
|
|
direction: LayoutDirection.Vertical,
|
|
|
|
|
addToBottom: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
yield put({
|
|
|
|
|
type: WidgetReduxActionTypes.WIDGET_ADD_CHILD,
|
|
|
|
|
payload: newWidget,
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-03-27 09:02:11 +00:00
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2020-03-27 09:02:11 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.CREATE_MODAL_ERROR,
|
|
|
|
|
payload: { error },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function* showModalByNameSaga(
|
|
|
|
|
action: ReduxAction<{ modalName: string }>,
|
|
|
|
|
) {
|
2023-10-11 07:14:38 +00:00
|
|
|
const widgets: { [widgetId: string]: FlattenedWidgetProps } =
|
|
|
|
|
yield select(getWidgets);
|
2020-03-27 09:02:11 +00:00
|
|
|
const modal: FlattenedWidgetProps | undefined = Object.values(widgets).find(
|
|
|
|
|
(widget: FlattenedWidgetProps) =>
|
|
|
|
|
widget.widgetName === action.payload.modalName,
|
|
|
|
|
);
|
|
|
|
|
if (modal) {
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(showModal(modal.widgetId));
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-23 04:18:23 +00:00
|
|
|
export function* showIfModalSaga(
|
|
|
|
|
action: ReduxAction<{ widgetId: string; type: string }>,
|
|
|
|
|
) {
|
|
|
|
|
if (action.payload.type === "MODAL_WIDGET") {
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(showModal(action.payload.widgetId));
|
2021-02-23 04:18:23 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-28 02:17:06 +00:00
|
|
|
export function* showModalSaga(action: ReduxAction<{ modalId: string }>) {
|
2020-03-27 09:02:11 +00:00
|
|
|
// First we close the currently open modals (if any)
|
|
|
|
|
// Notice the empty payload.
|
|
|
|
|
yield call(closeModalSaga, {
|
|
|
|
|
type: ReduxActionTypes.CLOSE_MODAL,
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
payload: {
|
|
|
|
|
exclude: action.payload.modalId,
|
|
|
|
|
},
|
2020-03-27 09:02:11 +00:00
|
|
|
});
|
|
|
|
|
|
2020-04-13 08:24:13 +00:00
|
|
|
yield put(focusWidget(action.payload.modalId));
|
2020-03-27 09:02:11 +00:00
|
|
|
|
2023-02-14 16:07:31 +00:00
|
|
|
const widgetLikeProps = {
|
|
|
|
|
widgetId: action.payload.modalId,
|
|
|
|
|
} as WidgetProps;
|
2022-06-21 13:57:34 +00:00
|
|
|
const metaProps: Record<string, unknown> = yield select(
|
|
|
|
|
getWidgetMetaProps,
|
2023-02-14 16:07:31 +00:00
|
|
|
widgetLikeProps,
|
2022-06-21 13:57:34 +00:00
|
|
|
);
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
if (!metaProps || !metaProps.isVisible) {
|
|
|
|
|
// Then show the modal we would like to show.
|
|
|
|
|
yield put(
|
2022-05-25 09:46:14 +00:00
|
|
|
updateWidgetMetaPropAndEval(action.payload.modalId, "isVisible", true),
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
);
|
|
|
|
|
yield delay(1000);
|
|
|
|
|
}
|
2020-03-27 09:02:11 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SHOW_PROPERTY_PANE,
|
|
|
|
|
payload: {
|
|
|
|
|
widgetId: action.payload.modalId,
|
|
|
|
|
callForDragOrResize: undefined,
|
|
|
|
|
force: true,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
export function* closeModalSaga(
|
|
|
|
|
action: ReduxAction<{ modalName?: string; exclude?: string }>,
|
|
|
|
|
) {
|
2020-03-27 09:02:11 +00:00
|
|
|
try {
|
|
|
|
|
const { modalName } = action.payload;
|
|
|
|
|
let widgetIds: string[] = [];
|
|
|
|
|
// If modalName is provided, we just want to close this modal
|
|
|
|
|
if (modalName) {
|
2022-06-21 13:57:34 +00:00
|
|
|
const widget: FlattenedWidgetProps | undefined = yield select(
|
|
|
|
|
getWidgetByName,
|
|
|
|
|
modalName,
|
|
|
|
|
);
|
|
|
|
|
widgetIds = widget ? [widget.widgetId] : [];
|
2020-03-27 09:02:11 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.SHOW_PROPERTY_PANE,
|
|
|
|
|
payload: {},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// If modalName is not provided, find all open modals
|
|
|
|
|
// Get all meta prop records
|
|
|
|
|
const metaProps: Record<string, any> = yield select(getWidgetsMeta);
|
|
|
|
|
|
|
|
|
|
// Get widgetIds of all widgets of type MODAL_WIDGET
|
|
|
|
|
const modalWidgetIds: string[] = yield select(
|
|
|
|
|
getWidgetIdsByType,
|
|
|
|
|
WidgetTypes.MODAL_WIDGET,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Loop through all modal widgetIds
|
|
|
|
|
modalWidgetIds.forEach((widgetId: string) => {
|
|
|
|
|
// Check if modal is open
|
|
|
|
|
if (metaProps[widgetId] && metaProps[widgetId].isVisible) {
|
|
|
|
|
// Add to our list of widgetIds
|
|
|
|
|
widgetIds.push(widgetId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
Feature/entity browse (#220)
# New Feature: Entity Explorer
- Entities are actions (apis and queries), datasources, pages, and widgets
- With this new feature, all entities in the application will be available
to view in the new entity explorer sidebar
- All existing application features from the api sidebar, query sidebar, datasource sidebar and pages sidebar
now are avialable on the entity explorer sidebar
- Users are now able to quickly switch to any entity in the application from the entity explorer sidebar.
- Users can also search all entities in the application from the new sidebar. Use cmd + f or ctrl + f to focus on the search input
- Users can rename entities from the new sidebar
- Users can also perform contextual actions on these entities like set a page as home page, copy/move actions, delete entity, etc from the context menu available alongside the entities in the sidebar
- Users can view the properties of the entities in the sidebar, as well as copy bindings to use in the application.
2020-08-10 08:52:45 +00:00
|
|
|
widgetIds = action.payload.exclude
|
|
|
|
|
? widgetIds.filter((id: string) => id !== action.payload.exclude)
|
|
|
|
|
: widgetIds;
|
2020-03-27 09:02:11 +00:00
|
|
|
// If we have modals to close, set its isVisible to false to close.
|
|
|
|
|
if (widgetIds) {
|
|
|
|
|
yield all(
|
2021-02-11 06:25:11 +00:00
|
|
|
flatten(
|
|
|
|
|
widgetIds.map((widgetId: string) => {
|
|
|
|
|
return [
|
2022-05-25 09:46:14 +00:00
|
|
|
put(updateWidgetMetaPropAndEval(widgetId, "isVisible", false)),
|
2021-02-11 06:25:11 +00:00
|
|
|
];
|
|
|
|
|
}),
|
2020-03-27 09:02:11 +00:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-10-28 02:11:19 +00:00
|
|
|
if (modalName) {
|
2023-01-28 02:17:06 +00:00
|
|
|
yield put(selectWidgetInitAction(SelectionRequestType.Empty));
|
2021-10-28 02:11:19 +00:00
|
|
|
yield put(focusWidget(MAIN_CONTAINER_WIDGET_ID));
|
|
|
|
|
}
|
2020-03-27 09:02:11 +00:00
|
|
|
} catch (error) {
|
2021-03-13 14:24:45 +00:00
|
|
|
log.error(error);
|
2020-03-27 09:02:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-20 17:06:13 +00:00
|
|
|
export function* resizeModalSaga(resizeAction: ReduxAction<ModalWidgetResize>) {
|
|
|
|
|
try {
|
2023-05-19 18:37:06 +00:00
|
|
|
toast.dismiss();
|
2021-09-20 17:06:13 +00:00
|
|
|
const start = performance.now();
|
|
|
|
|
const { canvasWidgetId, height, widgetId, width } = resizeAction.payload;
|
|
|
|
|
|
|
|
|
|
const stateWidget: FlattenedWidgetProps = yield select(getWidget, widgetId);
|
2022-06-21 13:57:34 +00:00
|
|
|
const stateWidgets: CanvasWidgetsReduxState = yield select(getWidgets);
|
2023-04-07 13:51:35 +00:00
|
|
|
const isAutoLayout: boolean = yield select(getIsAutoLayout);
|
2021-09-20 17:06:13 +00:00
|
|
|
|
|
|
|
|
let widget = { ...stateWidget };
|
|
|
|
|
const widgets = { ...stateWidgets };
|
|
|
|
|
|
|
|
|
|
widget = { ...widget, height, width };
|
|
|
|
|
widgets[widgetId] = widget;
|
|
|
|
|
|
|
|
|
|
if (canvasWidgetId) {
|
|
|
|
|
const bottomRow = getModalCanvasBottomRow(
|
|
|
|
|
widgets,
|
|
|
|
|
canvasWidgetId,
|
|
|
|
|
height,
|
|
|
|
|
);
|
|
|
|
|
const stateModalContainerWidget: FlattenedWidgetProps = yield select(
|
|
|
|
|
getWidget,
|
|
|
|
|
canvasWidgetId,
|
|
|
|
|
);
|
|
|
|
|
let modalContainerWidget = { ...stateModalContainerWidget };
|
|
|
|
|
|
|
|
|
|
modalContainerWidget = {
|
|
|
|
|
...modalContainerWidget,
|
|
|
|
|
bottomRow,
|
|
|
|
|
minHeight: height,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
widgets[canvasWidgetId] = modalContainerWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.debug("resize computations took", performance.now() - start, "ms");
|
2022-08-19 10:10:36 +00:00
|
|
|
//TODO Identify the updated widgets and pass the values
|
2023-04-07 13:51:35 +00:00
|
|
|
if (isAutoLayout) {
|
|
|
|
|
yield call(recalculateAutoLayoutColumnsAndSave, widgets);
|
2023-06-01 03:39:23 +00:00
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionTypes.PROCESS_AUTO_LAYOUT_DIMENSION_UPDATES,
|
|
|
|
|
});
|
2023-04-07 13:51:35 +00:00
|
|
|
} else {
|
|
|
|
|
yield put(updateAndSaveLayout(widgets));
|
|
|
|
|
}
|
2021-09-20 17:06:13 +00:00
|
|
|
} catch (error) {
|
|
|
|
|
yield put({
|
|
|
|
|
type: ReduxActionErrorTypes.WIDGET_OPERATION_ERROR,
|
|
|
|
|
payload: {
|
|
|
|
|
action: WidgetReduxActionTypes.WIDGET_RESIZE,
|
|
|
|
|
error,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Note: returns bottomRow of the lowest widget on the canvas
|
|
|
|
|
* @param finalWidgets
|
|
|
|
|
* @param parentId
|
|
|
|
|
* @param height
|
|
|
|
|
*/
|
|
|
|
|
const getModalCanvasBottomRow = (
|
|
|
|
|
finalWidgets: CanvasWidgetsReduxState,
|
|
|
|
|
parentId: string,
|
|
|
|
|
height: number,
|
|
|
|
|
): number => {
|
|
|
|
|
if (
|
|
|
|
|
!finalWidgets[parentId] ||
|
|
|
|
|
finalWidgets[parentId].type !== WidgetTypes.CANVAS_WIDGET
|
|
|
|
|
) {
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
const lowestBottomRowHeight =
|
|
|
|
|
height -
|
|
|
|
|
GridDefaults.CANVAS_EXTENSION_OFFSET *
|
|
|
|
|
GridDefaults.DEFAULT_GRID_ROW_HEIGHT -
|
|
|
|
|
GridDefaults.DEFAULT_GRID_ROW_HEIGHT;
|
|
|
|
|
|
|
|
|
|
let lowestBottomRow = Math.ceil(
|
|
|
|
|
lowestBottomRowHeight / GridDefaults.DEFAULT_GRID_ROW_HEIGHT,
|
|
|
|
|
);
|
|
|
|
|
const childIds = finalWidgets[parentId].children || [];
|
|
|
|
|
|
|
|
|
|
// find lowest row
|
|
|
|
|
childIds.forEach((cId: string) => {
|
|
|
|
|
const child = finalWidgets[cId];
|
|
|
|
|
|
|
|
|
|
if (child.bottomRow > lowestBottomRow) {
|
|
|
|
|
lowestBottomRow = child.bottomRow;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
(lowestBottomRow + GridDefaults.CANVAS_EXTENSION_OFFSET) *
|
|
|
|
|
GridDefaults.DEFAULT_GRID_ROW_HEIGHT
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export default function* modalSagas() {
|
|
|
|
|
yield all([
|
|
|
|
|
takeEvery(ReduxActionTypes.CLOSE_MODAL, closeModalSaga),
|
|
|
|
|
takeLatest(ReduxActionTypes.CREATE_MODAL_INIT, createModalSaga),
|
|
|
|
|
takeLatest(ReduxActionTypes.SHOW_MODAL, showModalSaga),
|
|
|
|
|
takeLatest(ReduxActionTypes.SHOW_MODAL_BY_NAME, showModalByNameSaga),
|
2021-08-03 08:06:48 +00:00
|
|
|
takeLatest(WidgetReduxActionTypes.WIDGET_CHILD_ADDED, showIfModalSaga),
|
2021-09-20 17:06:13 +00:00
|
|
|
takeLatest(WidgetReduxActionTypes.WIDGET_MODAL_RESIZE, resizeModalSaga),
|
2020-03-27 09:02:11 +00:00
|
|
|
]);
|
|
|
|
|
}
|