2019-10-18 08:16:26 +00:00
|
|
|
import React from "react";
|
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 { IconProps } from "constants/IconConstants";
|
|
|
|
|
import { IconWrapper } from "constants/IconConstants";
|
2020-05-28 18:10:26 +00:00
|
|
|
import { Icon } from "@blueprintjs/core";
|
2021-10-04 15:34:37 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
2024-08-09 14:20:29 +00:00
|
|
|
import { Icon as DSIcon } from "@appsmith/ads";
|
2024-08-08 12:55:00 +00:00
|
|
|
import { importRemixIcon, importSvg } from "@appsmith/ads-old";
|
2023-05-11 05:26:03 +00:00
|
|
|
|
2023-10-09 13:54:06 +00:00
|
|
|
const ApisIcon = importSvg(async () => import("assets/icons/menu/api.svg"));
|
2023-05-11 05:26:03 +00:00
|
|
|
const WorkspaceIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/workspace.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const DataSourcesIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/data-sources.svg"),
|
|
|
|
|
);
|
|
|
|
|
const QueriesIcon = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/queries.svg"),
|
|
|
|
|
);
|
|
|
|
|
const HomepageIcon = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/homepage.svg"),
|
|
|
|
|
);
|
|
|
|
|
const ExplorerIcon = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/explorer.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const ApisColoredIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/api-colored.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const DataSourcesColoredIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/datasource-colored.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const DatasourceTableIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/datasource-table.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const PrimaryKeyIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/primary-key.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const ForeignKeyIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/foreign-key.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const DatasourceColumnIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/datasource-column.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const WidgetsColoredIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/widgets-colored.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
2023-10-09 13:54:06 +00:00
|
|
|
const JSIcon = importSvg(async () => import("assets/icons/menu/js-group.svg"));
|
2023-05-11 05:26:03 +00:00
|
|
|
const JSFileIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/js-file-icon.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
2023-10-09 13:54:06 +00:00
|
|
|
const LinkIcon = importSvg(async () => import("assets/icons/menu/link.svg"));
|
2023-05-11 05:26:03 +00:00
|
|
|
const JSFunctionIcon = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/js-function.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const DataSourcesIconV2 = importSvg(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("assets/icons/menu/datasources-2.svg"),
|
|
|
|
|
);
|
|
|
|
|
const CurlIcon = importSvg(async () => import("assets/images/Curl-logo.svg"));
|
|
|
|
|
const JSIconV2 = importSvg(async () => import("assets/icons/menu/js-icon.svg"));
|
|
|
|
|
const QueryMain = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/query-main.svg"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
|
|
|
|
const SortIcon = importRemixIcon(
|
2023-10-09 13:54:06 +00:00
|
|
|
async () => import("remixicon-react/ArrowUpDownLineIcon"),
|
2023-05-11 05:26:03 +00:00
|
|
|
);
|
2023-11-17 07:16:18 +00:00
|
|
|
const GroupQueryIcon = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/query-group.svg"),
|
|
|
|
|
);
|
|
|
|
|
const LibraryIcon = importSvg(
|
|
|
|
|
async () => import("assets/icons/menu/library.svg"),
|
|
|
|
|
);
|
2023-05-11 05:26:03 +00:00
|
|
|
|
2019-10-18 08:16:26 +00:00
|
|
|
/* eslint-disable react/display-name */
|
|
|
|
|
|
2021-10-04 15:34:37 +00:00
|
|
|
const StyledDataSourcesIconV2 = styled(DataSourcesIconV2)`
|
|
|
|
|
g {
|
|
|
|
|
stroke: ${Colors.CHARCOAL};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledJSIconV2 = styled(JSIconV2)`
|
|
|
|
|
path {
|
|
|
|
|
fill: ${Colors.CHARCOAL};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledQueryMain = styled(QueryMain)`
|
|
|
|
|
path {
|
|
|
|
|
fill: ${Colors.CHARCOAL};
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2019-10-18 08:16:26 +00:00
|
|
|
export const MenuIcons: {
|
2020-11-03 13:05:40 +00:00
|
|
|
//TODO(abhinav): Fix this type to JSXElementConstructor<IconProps>
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
2019-10-18 08:16:26 +00:00
|
|
|
[id: string]: Function;
|
|
|
|
|
} = {
|
|
|
|
|
WIDGETS_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="widget" size="md" />
|
2019-10-18 08:16:26 +00:00
|
|
|
</IconWrapper>
|
2021-09-08 17:32:22 +00:00
|
|
|
),
|
|
|
|
|
JS_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<JSIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
JS_FILE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<JSFileIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
JS_FUNCTION_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<JSFunctionIcon />
|
|
|
|
|
</IconWrapper>
|
2019-10-18 08:16:26 +00:00
|
|
|
),
|
|
|
|
|
APIS_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<ApisIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2022-06-15 15:37:41 +00:00
|
|
|
WORKSPACE_ICON: (props: IconProps) => (
|
2019-12-23 12:16:33 +00:00
|
|
|
<IconWrapper {...props}>
|
2022-06-15 15:37:41 +00:00
|
|
|
<WorkspaceIcon />
|
2019-12-23 12:16:33 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-01-27 08:24:58 +00:00
|
|
|
PAGES_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="page-line" size="md" />
|
2020-01-27 08:24:58 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
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
|
|
|
PAGE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="page-line" size="md" />
|
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
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-04-28 06:52:53 +00:00
|
|
|
DATASOURCES_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<DataSourcesIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-05-05 07:50:30 +00:00
|
|
|
QUERIES_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<QueriesIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-01-27 08:24:58 +00:00
|
|
|
HOMEPAGE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<HomepageIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
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
|
|
|
EXPLORER_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<ExplorerIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-05-28 18:10:26 +00:00
|
|
|
DOCS_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2021-04-28 10:28:39 +00:00
|
|
|
<Icon icon="help" />
|
2020-05-28 18:10:26 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
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
|
|
|
WIDGETS_COLORED_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<WidgetsColoredIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
APIS_COLORED_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<ApisColoredIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
DATASOURCES_COLORED_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<DataSourcesColoredIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2020-09-21 09:11:42 +00:00
|
|
|
DATASOURCES_TABLE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<DatasourceTableIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
PRIMARY_KEY_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<PrimaryKeyIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
FOREIGN_KEY_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<ForeignKeyIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
DATASOURCE_COLUMN_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<DatasourceColumnIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2021-08-13 11:38:26 +00:00
|
|
|
LINK_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<LinkIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2021-10-04 15:34:37 +00:00
|
|
|
DATASOURCE_ICON_v2: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<StyledDataSourcesIconV2 />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
JS_ICON_V2: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<StyledJSIconV2 />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
DEFAULT_HOMEPAGE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="home-3-line" />
|
2021-10-04 15:34:37 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
EYES_OFF_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="eye-off" size="md" />
|
2021-10-04 15:34:37 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
QUERY_MAIN: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<StyledQueryMain />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2022-01-29 07:26:19 +00:00
|
|
|
CURRENT_PAGE_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
2023-05-19 18:37:06 +00:00
|
|
|
<DSIcon name="check-line" size="md" />
|
2022-01-29 07:26:19 +00:00
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
SORT_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<SortIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
CURL_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<CurlIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2023-11-17 07:16:18 +00:00
|
|
|
GROUP_QUERY_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<GroupQueryIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
|
|
|
|
LIBRARY_ICON: (props: IconProps) => (
|
|
|
|
|
<IconWrapper {...props}>
|
|
|
|
|
<LibraryIcon />
|
|
|
|
|
</IconWrapper>
|
|
|
|
|
),
|
2019-10-18 08:16:26 +00:00
|
|
|
};
|