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 { RefObject } from "react";
|
|
|
|
|
import React, { createRef } from "react";
|
2022-03-28 07:14:40 +00:00
|
|
|
import { sortBy } from "lodash";
|
2021-12-08 13:11:13 +00:00
|
|
|
import {
|
|
|
|
|
Alignment,
|
|
|
|
|
Icon,
|
|
|
|
|
Menu,
|
|
|
|
|
MenuItem,
|
|
|
|
|
Classes as CoreClass,
|
2022-07-20 08:51:54 +00:00
|
|
|
Spinner,
|
2021-12-08 13:11:13 +00:00
|
|
|
} from "@blueprintjs/core";
|
2021-11-11 06:41:05 +00:00
|
|
|
import { Classes, Popover2 } from "@blueprintjs/popover2";
|
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 { IconName } from "@blueprintjs/icons";
|
2021-11-11 06:41:05 +00:00
|
|
|
import tinycolor from "tinycolor2";
|
|
|
|
|
import { darkenActive, darkenHover } from "constants/DefaultTheme";
|
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-11-11 06:41:05 +00:00
|
|
|
ButtonStyleType,
|
|
|
|
|
ButtonVariant,
|
2021-12-08 13:11:13 +00:00
|
|
|
ButtonPlacement,
|
2021-11-11 06:41:05 +00:00
|
|
|
} from "components/constants";
|
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 { ButtonVariantTypes } from "components/constants";
|
2021-11-11 06:41:05 +00:00
|
|
|
import styled, { createGlobalStyle } from "styled-components";
|
|
|
|
|
import {
|
|
|
|
|
getCustomBackgroundColor,
|
|
|
|
|
getCustomBorderColor,
|
2021-12-08 13:11:13 +00:00
|
|
|
getCustomJustifyContent,
|
2022-05-04 09:45:57 +00:00
|
|
|
getComplementaryGrayscaleColor,
|
2021-11-11 06:41:05 +00:00
|
|
|
} from "widgets/WidgetUtils";
|
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 { RenderMode } from "constants/WidgetConstants";
|
|
|
|
|
import { RenderModes } from "constants/WidgetConstants";
|
2022-03-13 17:21:04 +00:00
|
|
|
import { DragContainer } from "widgets/ButtonWidget/component/DragContainer";
|
|
|
|
|
import { buttonHoverActiveStyles } from "../../ButtonWidget/component/utils";
|
2022-05-04 09:45:57 +00:00
|
|
|
import { THEMEING_TEXT_SIZES } from "constants/ThemeConstants";
|
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 { ThemeProp } from "widgets/constants";
|
2021-11-11 06:41:05 +00:00
|
|
|
|
2022-03-28 07:14:40 +00:00
|
|
|
// Utility functions
|
|
|
|
|
interface ButtonData {
|
|
|
|
|
id?: string;
|
|
|
|
|
type?: string;
|
|
|
|
|
label?: string;
|
|
|
|
|
iconName?: string;
|
|
|
|
|
}
|
|
|
|
|
// Extract props influencing to width change
|
|
|
|
|
const getButtonData = (
|
|
|
|
|
groupButtons: Record<string, GroupButtonProps>,
|
|
|
|
|
): ButtonData[] => {
|
|
|
|
|
const buttonData = Object.keys(groupButtons).reduce(
|
|
|
|
|
(acc: ButtonData[], id) => {
|
|
|
|
|
return [
|
|
|
|
|
...acc,
|
|
|
|
|
{
|
|
|
|
|
id,
|
|
|
|
|
type: groupButtons[id].buttonType,
|
|
|
|
|
label: groupButtons[id].label,
|
|
|
|
|
iconName: groupButtons[id].iconName,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
[],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return buttonData as ButtonData[];
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
interface WrapperStyleProps {
|
|
|
|
|
isHorizontal: boolean;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
|
|
|
|
boxShadow?: string;
|
|
|
|
|
buttonVariant: ButtonVariant;
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ButtonGroupWrapper = styled.div<ThemeProp & WrapperStyleProps>`
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: stretch;
|
|
|
|
|
align-items: stretch;
|
|
|
|
|
overflow: hidden;
|
2022-05-04 09:45:57 +00:00
|
|
|
cursor: not-allowed;
|
|
|
|
|
gap: ${({ buttonVariant }) =>
|
|
|
|
|
`${buttonVariant === ButtonVariantTypes.PRIMARY ? "1px" : "0px"}`};
|
2021-12-02 08:45:46 +00:00
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
${(props) =>
|
|
|
|
|
props.isHorizontal ? "flex-direction: row" : "flex-direction: column"};
|
2022-05-04 09:45:57 +00:00
|
|
|
box-shadow: ${({ boxShadow }) => boxShadow};
|
|
|
|
|
border-radius: ${({ borderRadius }) => borderRadius};
|
2021-11-11 06:41:05 +00:00
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
& > *:first-child,
|
|
|
|
|
& > *:first-child button {
|
|
|
|
|
border-radius: ${({ borderRadius, isHorizontal }) =>
|
|
|
|
|
isHorizontal
|
|
|
|
|
? `${borderRadius} 0px 0px ${borderRadius}`
|
|
|
|
|
: `${borderRadius} ${borderRadius} 0px 0px`};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& > *:last-child,
|
|
|
|
|
& > *:last-child button {
|
|
|
|
|
border-radius: ${({ borderRadius, isHorizontal }) =>
|
|
|
|
|
isHorizontal
|
|
|
|
|
? `0px ${borderRadius} ${borderRadius} 0`
|
|
|
|
|
: `0px 0px ${borderRadius} ${borderRadius}`};
|
|
|
|
|
}
|
2021-11-11 06:41:05 +00:00
|
|
|
`;
|
|
|
|
|
|
2022-03-22 11:17:06 +00:00
|
|
|
const MenuButtonWrapper = styled.div<{ renderMode: RenderMode }>`
|
2021-11-11 06:41:05 +00:00
|
|
|
flex: 1 1 auto;
|
2022-05-04 09:45:57 +00:00
|
|
|
cursor: pointer;
|
|
|
|
|
position: relative;
|
2021-11-11 06:41:05 +00:00
|
|
|
|
2022-03-22 11:36:49 +00:00
|
|
|
${({ renderMode }) => renderMode === RenderModes.CANVAS && `height: 100%`};
|
2022-03-22 11:17:06 +00:00
|
|
|
|
2022-03-13 17:21:04 +00:00
|
|
|
& > .${Classes.POPOVER2_TARGET} > button {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
& > .${Classes.POPOVER2_TARGET} {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2022-02-24 08:21:45 +00:00
|
|
|
const PopoverStyles = createGlobalStyle<{
|
2022-03-28 07:14:40 +00:00
|
|
|
minPopoverWidth: number;
|
|
|
|
|
popoverTargetWidth?: number;
|
2022-02-24 08:21:45 +00:00
|
|
|
id: string;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
2022-02-24 08:21:45 +00:00
|
|
|
}>`
|
2022-05-04 09:45:57 +00:00
|
|
|
${({ borderRadius, id, minPopoverWidth, popoverTargetWidth }) => `
|
|
|
|
|
.${id}.${Classes.POPOVER2} {
|
|
|
|
|
background: none;
|
|
|
|
|
box-shadow: 0 6px 20px 0px rgba(0, 0, 0, 0.15) !important;
|
|
|
|
|
margin-top: 8px !important;
|
|
|
|
|
margin-bottom: 8px !important;
|
|
|
|
|
border-radius: ${
|
|
|
|
|
borderRadius === THEMEING_TEXT_SIZES.lg ? `0.375rem` : borderRadius
|
|
|
|
|
};
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
overflow: hidden;
|
2022-03-28 07:14:40 +00:00
|
|
|
${popoverTargetWidth && `width: ${popoverTargetWidth}px`};
|
|
|
|
|
min-width: ${minPopoverWidth}px;
|
|
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
.button-group-menu-popover > .${Classes.POPOVER2_CONTENT} {
|
|
|
|
|
background: none;
|
|
|
|
|
}
|
2022-03-28 07:14:40 +00:00
|
|
|
`}
|
2021-11-11 06:41:05 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
interface ButtonStyleProps {
|
|
|
|
|
isHorizontal: boolean;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
2021-11-11 06:41:05 +00:00
|
|
|
buttonVariant?: ButtonVariant; // solid | outline | ghost
|
|
|
|
|
buttonColor?: string;
|
|
|
|
|
iconAlign?: string;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2022-03-17 05:12:35 +00:00
|
|
|
isLabel: boolean;
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-13 17:21:04 +00:00
|
|
|
/*
|
2022-05-04 09:45:57 +00:00
|
|
|
Don't use buttonHoverActiveStyles in a nested function it won't work -
|
2022-03-13 17:21:04 +00:00
|
|
|
|
|
|
|
|
const buttonHoverActiveStyles = css ``
|
|
|
|
|
|
|
|
|
|
const Button = styled.button`
|
|
|
|
|
// won't work
|
|
|
|
|
${({ buttonColor, theme }) => {
|
|
|
|
|
&:hover, &:active {
|
|
|
|
|
${buttonHoverActiveStyles}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
// will work
|
|
|
|
|
&:hover, &:active {
|
|
|
|
|
${buttonHoverActiveStyles}
|
|
|
|
|
}`
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
const StyledButton = styled.button<ThemeProp & ButtonStyleProps>`
|
|
|
|
|
flex: 1 1 auto;
|
|
|
|
|
display: flex;
|
2021-12-08 13:11:13 +00:00
|
|
|
justify-content: stretch;
|
2021-11-11 06:41:05 +00:00
|
|
|
align-items: center;
|
2021-12-08 13:11:13 +00:00
|
|
|
padding: 0px 10px;
|
2021-11-11 06:41:05 +00:00
|
|
|
|
2023-04-07 13:51:35 +00:00
|
|
|
.auto-layout & {
|
|
|
|
|
min-height: 32px;
|
|
|
|
|
min-width: 120px;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-13 17:21:04 +00:00
|
|
|
&:hover,
|
2022-12-30 14:52:11 +00:00
|
|
|
&:active,
|
|
|
|
|
&:focus {
|
2022-03-13 17:21:04 +00:00
|
|
|
${buttonHoverActiveStyles}
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
${({ buttonColor, buttonVariant, iconAlign, isLabel, theme }) => `
|
2021-11-11 06:41:05 +00:00
|
|
|
& {
|
|
|
|
|
background: ${
|
|
|
|
|
getCustomBackgroundColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? getCustomBackgroundColor(buttonVariant, buttonColor)
|
|
|
|
|
: buttonVariant === ButtonVariantTypes.PRIMARY
|
|
|
|
|
? theme.colors.button.primary.primary.bgColor
|
|
|
|
|
: "none"
|
|
|
|
|
} !important;
|
2021-12-14 07:55:30 +00:00
|
|
|
flex-direction : ${iconAlign === "right" ? "row-reverse" : "row"};
|
|
|
|
|
.bp3-icon {
|
2022-03-17 05:12:35 +00:00
|
|
|
${
|
|
|
|
|
isLabel
|
|
|
|
|
? iconAlign === "right"
|
|
|
|
|
? "margin-left: 10px"
|
|
|
|
|
: "margin-right: 10px"
|
|
|
|
|
: ""
|
|
|
|
|
};
|
2021-12-14 07:55:30 +00:00
|
|
|
}
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
border: ${
|
|
|
|
|
getCustomBorderColor(buttonVariant, buttonColor) !== "none"
|
|
|
|
|
? `1px solid ${getCustomBorderColor(buttonVariant, buttonColor)}`
|
|
|
|
|
: buttonVariant === ButtonVariantTypes.SECONDARY
|
|
|
|
|
? `1px solid ${theme.colors.button.primary.secondary.borderColor}`
|
|
|
|
|
: "none"
|
|
|
|
|
} ${buttonVariant === ButtonVariantTypes.PRIMARY ? "" : "!important"};
|
|
|
|
|
|
|
|
|
|
& span {
|
|
|
|
|
color: ${
|
|
|
|
|
buttonVariant === ButtonVariantTypes.PRIMARY
|
2022-05-04 09:45:57 +00:00
|
|
|
? getComplementaryGrayscaleColor(buttonColor)
|
2021-11-11 06:41:05 +00:00
|
|
|
: getCustomBackgroundColor(ButtonVariantTypes.PRIMARY, buttonColor)
|
|
|
|
|
} !important;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 09:45:57 +00:00
|
|
|
|
|
|
|
|
&:disabled {
|
2022-03-13 17:21:04 +00:00
|
|
|
cursor: not-allowed;
|
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
|
|
|
border: ${
|
|
|
|
|
buttonVariant === ButtonVariantTypes.SECONDARY &&
|
|
|
|
|
"1px solid var(--wds-color-border-disabled)"
|
|
|
|
|
} !important;
|
|
|
|
|
background: ${
|
|
|
|
|
buttonVariant !== ButtonVariantTypes.TERTIARY &&
|
|
|
|
|
"var(--wds-color-bg-disabled)"
|
|
|
|
|
} !important;
|
chore: import common variables from design system (#17600)
* Delete CommonComponentProps, Classes, import them from design-system
* Delete Icon.test.tsx
* Remove color utils, add import from design-system
* Remove Variant, add import from design-system
* Remove unused toast parameters from common
* use design-system version 28-alpha-7
* Move ThemeProp from ads/common to widgets/constants
* fix import
* Delete index.ts
* feat: migrated form group from ads folder to design system repository (#17400)
* feat: migrated form group from ads folder to design system repo
* fix: formGroup label color fix
* DS version updated
* Updated Label Config
* chore: Flapdoodle version upgrade to 3.5.0 (#17609)
* chore: code split tenant API CE (#17596)
## Description
We shouldn't expose tenant config on CE , so on CE, we should only return the necessary user permissions hard coded on the saga.
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manual
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] 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
- [x] New and existing unit tests pass locally with my changes
* chore: BaseAppsmithRepo code split (#17614)
* chore: Updating the tenant API to return the complete object instead of just the configuration (#17615)
* Fix sandbox iframe default setting (#17618)
* feat: upgrade hooks | audit logs (#17525)
* feat: Text Widget Reskinning (#17298)
* feat: Use truncate button color from theme
* fix: Update Truncate Button Color validation regex
* feat: Maintain Focus and Context Phase 1 (#16317)
* fix: update regex and test case for organisation website (#17612)
* chore: Add properties to analytics event (#17621)
* feat: enabled setTimeout/clearTimeout APIs (#17445)
* Update top contributors
* fix: ms sql default port updated to 1433 (#17342)
* fix: removed global style from design system dropdown component (#17392)
* bug: removed global style from design system dropdown component
* changed design system package version
* fix: Dropdown background fix - design system
* design-system - dropdown background color fix
* DS version updated
* chore: Fixing broken client build (#17634)
## Description
EE client build is broken due to not following proper code splitting strategy; one file in particularly didn't get split earlier and changes to that file broke the client build on EE.
This PR fixes the issues.
* Fix/16994 refactor common datatype handling (#17429)
* fix:Add array datatype to execute request
* feat: Consume and store type of array elements in Param class (#16994)
* Append param instead of clientDataType in varargs (#16994)
* Refactor common data type handling w.r.t newer structure (#16994)
This commit takes care of the following items:
- It minimizes the number of usage to the older stringToKnownDataTypeConverter method
- Modifies the existing test cases to conform to the newer structure
- Marks stringToKnownDataTypeConverter method as deprecated to discourage further use
* Remove comma delimited numbers from valid test cases (#16994)
* Fix extracting clientDataType from varargs in MySQL (#16994)
* Pass param as a dedicated parameter in json smart replacement (#16994)
* Remove varargs from json smart replacement method (#16994)
* Move BsonType to mongoplugin module (#16994)
* Introduce NullArrayType and refactor BsonType test cases (#16994)
* Add new test cases on numeric string with leading zero (#16994)
* Refactor test case name (#16994)
* Add comment on the ordering of Json and Bson types (#16994)
* Add comment on the ordering of Json and Bson types (#16994)
* Add NullArrayType in Postgres and introduce postgres-specific types (#16994)
* Add data type test cases for Postgres and change as per review comments (#16994)
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
* feat: Update invite modal submit when we have tabs in modal (#17608)
## Description
> Update invite modal submit when we have tabs in modal.
Fixes [#16741](https://github.com/appsmithorg/appsmith/issues/16741)
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
> Tested it locally.
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] 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
- [x] New and existing unit tests pass locally with my changes
* feat: AST based entity refactor (#17434)
* task: AST based entity refactor
* implemented refactor logic
* jest cases with string manipulation using AST logic
* comments and indentation
* added evalVersion to request
* chore: Added feature flag for datasource environments (#17657)
chore: Added Feature flag for datasource environments
* chore: Corrected analytics event for instance setting events (#17622)
* Update top contributors
* Fix typo in cloud-hosting check and NPE from Segment (#17692)
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
* fix: remove file references on click of cancel button (#17664)
* fix: table does not show data issue fixed (#17459)
* chore: Add recommended indexes (#17704)
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
* chore: Added workspace details to user invite analytic event (#17644)
## Description
This PR adds the workspace details to user invite analytics event
## Type of change
- New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
- Manually on local
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] 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
- [x] New and existing unit tests pass locally with my changes
* chore: Correct the toast font on windows (#17671)
* fix: JS option missing for Label Font Style in Input widget (#17631)
* fix: replace time based action to event based (#17586)
* fix: replace time based action to event based
- The delete datasource button was getting reset to it's original state after a static time of 2200ms
- Replaced this to reset on completion of deletion instead
* fix: removed unused functions
* fix: updated the condition to show confirm delete icon
* Updated Label Config
* test: Add cypress tests for template phase 2 (#17036)
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
* Change Segment CDN to our proxy (#17714)
* chore: Fixing prettier formatting for AnalyticsUtil.tsx
* chore: Adding base repository function to add user permissions to generic domain object (#17733)
## Description
Adding base function to set the user permissions for a user in any domain object.
As part of this, we also add default permission group to the `SeedMongoData`. Without this fix, the JUnit tests go into an infinite loop. Also fixing the `ExampleWorkspaceClonerTest` file.
## Type of change
- Bug fix (non-breaking change which fixes an issue)
## How Has This Been Tested?
- JUnit
## Checklist:
- [ ] 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
- [ ] 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
* Update top contributors
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: Nikhil Nandagopal <nikhil.nandagopal@gmail.com>
Co-authored-by: Nidhi <nidhi@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Trisha Anand <trisha@appsmith.com>
Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: f0c1s <anubhav@appsmith.com>
Co-authored-by: Dhruvik Neharia <dhruvik@appsmith.com>
Co-authored-by: Hetu Nandu <hetu@appsmith.com>
Co-authored-by: Nilesh Sarupriya <nilesh@appsmith.com>
Co-authored-by: Anagh Hegde <anagh@appsmith.com>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Appsmith Bot <74705725+appsmith-bot@users.noreply.github.com>
Co-authored-by: Vaibhav Tanwar <40293928+vaibh1297@users.noreply.github.com>
Co-authored-by: subratadeypappu <subrata@appsmith.com>
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: ChandanBalajiBP <104058110+ChandanBalajiBP@users.noreply.github.com>
Co-authored-by: Vishnu Gp <vishnu@appsmith.com>
Co-authored-by: Keyur Paralkar <keyur@appsmith.com>
Co-authored-by: sneha122 <sneha@appsmith.com>
Co-authored-by: Tanvi Bhakta <tanvibhakta@gmail.com>
Co-authored-by: sanjus-robotic-studio <58104863+sanjus-robotic-studio@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayush@appsmith.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: Arpit Mohan <arpit@appsmith.com>
Signed-off-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com>
Co-authored-by: Nikhil Nandagopal <nikhil.nandagopal@gmail.com>
Co-authored-by: Nidhi <nidhi@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Trisha Anand <trisha@appsmith.com>
Co-authored-by: Arpit Mohan <mohanarpit@users.noreply.github.com>
Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
Co-authored-by: f0c1s <anubhav@appsmith.com>
Co-authored-by: Dhruvik Neharia <dhruvik@appsmith.com>
Co-authored-by: Hetu Nandu <hetu@appsmith.com>
Co-authored-by: Nilesh Sarupriya <nilesh@appsmith.com>
Co-authored-by: Anagh Hegde <anagh@appsmith.com>
Co-authored-by: arunvjn <32433245+arunvjn@users.noreply.github.com>
Co-authored-by: Appsmith Bot <74705725+appsmith-bot@users.noreply.github.com>
Co-authored-by: Vaibhav Tanwar <40293928+vaibh1297@users.noreply.github.com>
Co-authored-by: subratadeypappu <subrata@appsmith.com>
Co-authored-by: ChandanBalajiBP <chandan@appsmith.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: ChandanBalajiBP <104058110+ChandanBalajiBP@users.noreply.github.com>
Co-authored-by: Vishnu Gp <vishnu@appsmith.com>
Co-authored-by: Keyur Paralkar <keyur@appsmith.com>
Co-authored-by: sneha122 <sneha@appsmith.com>
Co-authored-by: sanjus-robotic-studio <58104863+sanjus-robotic-studio@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayush@appsmith.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2022-10-31 01:24:47 +00:00
|
|
|
|
2022-03-13 17:21:04 +00:00
|
|
|
span {
|
2022-09-30 11:24:21 +00:00
|
|
|
color: var(--wds-color-text-disabled) !important;
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
2022-03-13 17:21:04 +00:00
|
|
|
}
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
`}
|
|
|
|
|
`;
|
|
|
|
|
|
2021-12-08 13:11:13 +00:00
|
|
|
const StyledButtonContent = styled.div<{
|
|
|
|
|
iconAlign: string;
|
|
|
|
|
placement?: ButtonPlacement;
|
|
|
|
|
}>`
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: ${({ placement }) => getCustomJustifyContent(placement)};
|
|
|
|
|
flex-direction: ${({ iconAlign }) =>
|
|
|
|
|
iconAlign === Alignment.RIGHT ? "row-reverse" : "row"};
|
2021-11-11 06:41:05 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export interface BaseStyleProps {
|
|
|
|
|
backgroundColor?: string;
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
|
|
|
|
boxShadow?: string;
|
2021-11-11 06:41:05 +00:00
|
|
|
buttonColor?: string;
|
|
|
|
|
buttonStyle?: ButtonStyleType;
|
|
|
|
|
buttonVariant?: ButtonVariant;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BaseMenuItem = styled(MenuItem)<ThemeProp & BaseStyleProps>`
|
|
|
|
|
padding: 8px 10px !important;
|
2022-05-04 09:45:57 +00:00
|
|
|
border-radius: 0px;
|
2021-11-11 06:41:05 +00:00
|
|
|
${({ backgroundColor, theme }) =>
|
|
|
|
|
backgroundColor
|
|
|
|
|
? `
|
|
|
|
|
background-color: ${backgroundColor} !important;
|
2022-12-30 14:52:11 +00:00
|
|
|
&:hover, &:focus {
|
2021-11-11 06:41:05 +00:00
|
|
|
background-color: ${darkenHover(backgroundColor)} !important;
|
|
|
|
|
}
|
|
|
|
|
&:active {
|
|
|
|
|
background-color: ${darkenActive(backgroundColor)} !important;
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
: `
|
|
|
|
|
background: none !important
|
2022-12-30 14:52:11 +00:00
|
|
|
&:hover, &:focus {
|
2021-11-11 06:41:05 +00:00
|
|
|
background-color: ${tinycolor(
|
|
|
|
|
theme.colors.button.primary.primary.textColor,
|
|
|
|
|
)
|
|
|
|
|
.darken()
|
|
|
|
|
.toString()} !important;
|
|
|
|
|
}
|
|
|
|
|
&:active {
|
|
|
|
|
background-color: ${tinycolor(
|
|
|
|
|
theme.colors.button.primary.primary.textColor,
|
|
|
|
|
)
|
|
|
|
|
.darken()
|
|
|
|
|
.toString()} !important;
|
|
|
|
|
}
|
|
|
|
|
`}
|
|
|
|
|
${({ textColor }) =>
|
|
|
|
|
textColor &&
|
|
|
|
|
`
|
|
|
|
|
color: ${textColor} !important;
|
|
|
|
|
`}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledMenu = styled(Menu)`
|
|
|
|
|
padding: 0;
|
2022-02-24 08:21:45 +00:00
|
|
|
min-width: 0px;
|
2021-11-11 06:41:05 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
interface PopoverContentProps {
|
2022-07-20 08:51:54 +00:00
|
|
|
buttonId: string;
|
2021-11-11 06:41:05 +00:00
|
|
|
menuItems: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
widgetId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
index: number;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconColor?: string;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
onClick?: string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
2022-07-20 08:51:54 +00:00
|
|
|
onItemClicked: (onClick: string | undefined, buttonId: string) => void;
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function PopoverContent(props: PopoverContentProps) {
|
2022-07-20 08:51:54 +00:00
|
|
|
const { buttonId, menuItems, onItemClicked } = props;
|
2021-11-11 06:41:05 +00:00
|
|
|
|
|
|
|
|
let items = Object.keys(menuItems)
|
|
|
|
|
.map((itemKey) => menuItems[itemKey])
|
|
|
|
|
.filter((item) => item.isVisible === true);
|
|
|
|
|
// sort btns by index
|
|
|
|
|
items = sortBy(items, ["index"]);
|
|
|
|
|
|
|
|
|
|
const listItems = items.map((menuItem) => {
|
|
|
|
|
const {
|
|
|
|
|
backgroundColor,
|
|
|
|
|
iconAlign,
|
|
|
|
|
iconColor,
|
|
|
|
|
iconName,
|
|
|
|
|
id,
|
|
|
|
|
isDisabled,
|
|
|
|
|
label,
|
|
|
|
|
onClick,
|
|
|
|
|
textColor,
|
|
|
|
|
} = menuItem;
|
2022-12-16 06:36:55 +00:00
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
return (
|
|
|
|
|
<BaseMenuItem
|
|
|
|
|
backgroundColor={backgroundColor}
|
|
|
|
|
disabled={isDisabled}
|
2022-12-16 06:36:55 +00:00
|
|
|
icon={
|
|
|
|
|
iconAlign !== Alignment.RIGHT && iconName ? (
|
|
|
|
|
<Icon color={iconColor} icon={iconName} />
|
|
|
|
|
) : null
|
|
|
|
|
}
|
2021-11-11 06:41:05 +00:00
|
|
|
key={id}
|
2022-12-16 06:36:55 +00:00
|
|
|
labelElement={
|
|
|
|
|
iconAlign === Alignment.RIGHT && iconName ? (
|
|
|
|
|
<Icon color={iconColor} icon={iconName} />
|
|
|
|
|
) : null
|
|
|
|
|
}
|
2022-07-20 08:51:54 +00:00
|
|
|
onClick={() => onItemClicked(onClick, buttonId)}
|
2021-11-11 06:41:05 +00:00
|
|
|
text={label}
|
|
|
|
|
textColor={textColor}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return <StyledMenu>{listItems}</StyledMenu>;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 07:14:40 +00:00
|
|
|
class ButtonGroupComponent extends React.Component<
|
|
|
|
|
ButtonGroupComponentProps,
|
|
|
|
|
ButtonGroupComponentState
|
|
|
|
|
> {
|
|
|
|
|
private timer?: number;
|
|
|
|
|
|
|
|
|
|
constructor(props: ButtonGroupComponentProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
itemRefs: {},
|
|
|
|
|
itemWidths: {},
|
2022-07-20 08:51:54 +00:00
|
|
|
loadedBtnId: "",
|
2022-03-28 07:14:40 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
this.setState(() => {
|
|
|
|
|
return {
|
|
|
|
|
...this.state,
|
|
|
|
|
itemRefs: this.createMenuButtonRefs(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.timer = setTimeout(() => {
|
|
|
|
|
this.setState(() => {
|
|
|
|
|
return {
|
|
|
|
|
...this.state,
|
|
|
|
|
itemWidths: this.getMenuButtonWidths(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(
|
|
|
|
|
prevProps: ButtonGroupComponentProps,
|
|
|
|
|
prevState: ButtonGroupComponentState,
|
|
|
|
|
) {
|
|
|
|
|
if (
|
|
|
|
|
this.state.itemRefs !== prevState.itemRefs ||
|
|
|
|
|
this.props.width !== prevProps.width ||
|
|
|
|
|
this.props.orientation !== prevProps.orientation
|
|
|
|
|
) {
|
|
|
|
|
if (this.timer) {
|
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
|
}
|
|
|
|
|
this.timer = setTimeout(() => {
|
|
|
|
|
this.setState(() => {
|
|
|
|
|
return {
|
|
|
|
|
...this.state,
|
|
|
|
|
itemWidths: this.getMenuButtonWidths(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// Reset refs array if
|
|
|
|
|
// * A button is added/removed or changed into a menu button
|
|
|
|
|
// * A label is changed or icon is newly added or removed
|
|
|
|
|
let isWidthChanged = false;
|
|
|
|
|
const buttons = getButtonData(this.props.groupButtons);
|
|
|
|
|
const menuButtons = buttons.filter((button) => button.type === "MENU");
|
|
|
|
|
const prevButtons = getButtonData(prevProps.groupButtons);
|
|
|
|
|
const prevMenuButtons = prevButtons.filter(
|
|
|
|
|
(button) => button.type === "MENU",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (buttons.length !== prevButtons.length) {
|
|
|
|
|
isWidthChanged = true;
|
|
|
|
|
} else if (menuButtons.length > prevMenuButtons.length) {
|
|
|
|
|
isWidthChanged = true;
|
|
|
|
|
} else {
|
|
|
|
|
isWidthChanged = buttons.some((button) => {
|
|
|
|
|
const prevButton = prevButtons.find((btn) => btn.id === button.id);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
button.label !== prevButton?.label ||
|
|
|
|
|
(button.iconName && !prevButton?.iconName) ||
|
|
|
|
|
(!button.iconName && prevButton?.iconName)
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isWidthChanged) {
|
|
|
|
|
this.setState(() => {
|
|
|
|
|
return {
|
|
|
|
|
...this.state,
|
|
|
|
|
itemRefs: this.createMenuButtonRefs(),
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
|
if (this.timer) {
|
|
|
|
|
clearTimeout(this.timer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get widths of menu buttons
|
|
|
|
|
getMenuButtonWidths = () =>
|
|
|
|
|
Object.keys(this.props.groupButtons).reduce((acc, id) => {
|
|
|
|
|
if (this.props.groupButtons[id].buttonType === "MENU") {
|
|
|
|
|
return {
|
|
|
|
|
...acc,
|
|
|
|
|
[id]: this.state.itemRefs[id].current?.getBoundingClientRect().width,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
// Create refs of menu buttons
|
|
|
|
|
createMenuButtonRefs = () =>
|
|
|
|
|
Object.keys(this.props.groupButtons).reduce((acc, id) => {
|
|
|
|
|
if (this.props.groupButtons[id].buttonType === "MENU") {
|
|
|
|
|
return {
|
|
|
|
|
...acc,
|
|
|
|
|
[id]: createRef(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
2022-07-20 08:51:54 +00:00
|
|
|
// Start Loading
|
|
|
|
|
handleActionStart = (id: string) => {
|
|
|
|
|
this.setState({
|
|
|
|
|
loadedBtnId: id,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Stop Loading
|
|
|
|
|
handleActionComplete = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
loadedBtnId: "",
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onButtonClick = (onClick: string | undefined, buttonId: string) => {
|
|
|
|
|
if (onClick) {
|
|
|
|
|
this.handleActionStart(buttonId);
|
|
|
|
|
this.props.buttonClickHandler(onClick, () => this.handleActionComplete());
|
|
|
|
|
}
|
2021-11-11 06:41:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render = () => {
|
2022-02-24 08:21:45 +00:00
|
|
|
const {
|
|
|
|
|
buttonVariant,
|
|
|
|
|
groupButtons,
|
|
|
|
|
isDisabled,
|
2022-03-28 07:14:40 +00:00
|
|
|
minPopoverWidth,
|
2022-02-24 08:21:45 +00:00
|
|
|
orientation,
|
2022-03-28 07:14:40 +00:00
|
|
|
widgetId,
|
2022-02-24 08:21:45 +00:00
|
|
|
} = this.props;
|
2022-07-20 08:51:54 +00:00
|
|
|
const { loadedBtnId } = this.state;
|
2021-11-11 06:41:05 +00:00
|
|
|
const isHorizontal = orientation === "horizontal";
|
|
|
|
|
|
|
|
|
|
let items = Object.keys(groupButtons)
|
|
|
|
|
.map((itemKey) => groupButtons[itemKey])
|
|
|
|
|
.filter((item) => item.isVisible === true);
|
|
|
|
|
// sort btns by index
|
|
|
|
|
items = sortBy(items, ["index"]);
|
2022-05-04 09:45:57 +00:00
|
|
|
const popoverId = `button-group-${widgetId}`;
|
2021-11-11 06:41:05 +00:00
|
|
|
|
2023-04-14 13:55:44 +00:00
|
|
|
const getOnClick = (button: GroupButtonProps) => {
|
|
|
|
|
if (!button.onClick) return;
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
this.onButtonClick(button.onClick, button.id);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
return (
|
|
|
|
|
<ButtonGroupWrapper
|
|
|
|
|
borderRadius={this.props.borderRadius}
|
|
|
|
|
boxShadow={this.props.boxShadow}
|
2022-05-04 09:45:57 +00:00
|
|
|
buttonVariant={this.props.buttonVariant}
|
2021-11-11 06:41:05 +00:00
|
|
|
className="t--buttongroup-widget"
|
|
|
|
|
isHorizontal={isHorizontal}
|
|
|
|
|
>
|
|
|
|
|
{items.map((button) => {
|
2022-07-20 08:51:54 +00:00
|
|
|
const isLoading = button.id === loadedBtnId;
|
|
|
|
|
const isButtonDisabled =
|
2022-09-30 11:24:21 +00:00
|
|
|
button.isDisabled || isDisabled || !!loadedBtnId || isLoading;
|
2021-11-11 06:41:05 +00:00
|
|
|
if (button.buttonType === "MENU" && !isButtonDisabled) {
|
|
|
|
|
const { menuItems } = button;
|
2022-05-04 09:45:57 +00:00
|
|
|
|
2021-11-11 06:41:05 +00:00
|
|
|
return (
|
2022-03-22 11:17:06 +00:00
|
|
|
<MenuButtonWrapper
|
|
|
|
|
key={button.id}
|
|
|
|
|
renderMode={this.props.renderMode}
|
|
|
|
|
>
|
2022-02-24 08:21:45 +00:00
|
|
|
<PopoverStyles
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius={this.props.borderRadius}
|
2022-03-28 07:14:40 +00:00
|
|
|
id={popoverId}
|
|
|
|
|
minPopoverWidth={minPopoverWidth}
|
|
|
|
|
popoverTargetWidth={this.state.itemWidths[button.id]}
|
2022-02-24 08:21:45 +00:00
|
|
|
/>
|
2021-11-11 06:41:05 +00:00
|
|
|
<Popover2
|
|
|
|
|
content={
|
|
|
|
|
<PopoverContent
|
2022-07-20 08:51:54 +00:00
|
|
|
buttonId={button.id}
|
2021-11-11 06:41:05 +00:00
|
|
|
menuItems={menuItems || {}}
|
|
|
|
|
onItemClicked={this.onButtonClick}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
disabled={button.isDisabled}
|
|
|
|
|
fill
|
|
|
|
|
minimal
|
|
|
|
|
placement="bottom-end"
|
2022-05-04 09:45:57 +00:00
|
|
|
popoverClassName={popoverId}
|
2021-11-11 06:41:05 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<DragContainer
|
2021-11-11 06:41:05 +00:00
|
|
|
buttonColor={button.buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
2022-03-13 17:21:04 +00:00
|
|
|
disabled={isButtonDisabled}
|
2022-07-20 08:51:54 +00:00
|
|
|
loading={!!loadedBtnId}
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode={this.props.renderMode}
|
2021-11-11 06:41:05 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<StyledButton
|
|
|
|
|
borderRadius={this.props.borderRadius}
|
|
|
|
|
buttonColor={button.buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
|
disabled={isButtonDisabled}
|
|
|
|
|
iconAlign={button.iconAlign}
|
|
|
|
|
isHorizontal={isHorizontal}
|
2022-03-17 05:12:35 +00:00
|
|
|
isLabel={!!button.label}
|
2022-03-13 17:21:04 +00:00
|
|
|
key={button.id}
|
2022-03-28 07:14:40 +00:00
|
|
|
ref={this.state.itemRefs[button.id]}
|
2021-12-08 13:11:13 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<StyledButtonContent
|
|
|
|
|
iconAlign={button.iconAlign || "left"}
|
|
|
|
|
placement={button.placement}
|
|
|
|
|
>
|
2022-07-20 08:51:54 +00:00
|
|
|
{isLoading ? (
|
2022-09-30 11:24:21 +00:00
|
|
|
<Spinner size={18} />
|
2022-07-20 08:51:54 +00:00
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{button.iconName && <Icon icon={button.iconName} />}
|
|
|
|
|
{!!button.label && (
|
|
|
|
|
<span className={CoreClass.BUTTON_TEXT}>
|
|
|
|
|
{button.label}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2022-03-13 17:21:04 +00:00
|
|
|
)}
|
|
|
|
|
</StyledButtonContent>
|
|
|
|
|
</StyledButton>
|
|
|
|
|
</DragContainer>
|
2021-11-11 06:41:05 +00:00
|
|
|
</Popover2>
|
|
|
|
|
</MenuButtonWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
2022-03-13 17:21:04 +00:00
|
|
|
<DragContainer
|
2021-11-11 06:41:05 +00:00
|
|
|
buttonColor={button.buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
2022-03-13 17:21:04 +00:00
|
|
|
disabled={isButtonDisabled}
|
2021-11-11 06:41:05 +00:00
|
|
|
key={button.id}
|
2022-07-20 08:51:54 +00:00
|
|
|
loading={!!loadedBtnId}
|
2023-04-14 13:55:44 +00:00
|
|
|
onClick={getOnClick(button)}
|
2022-03-13 17:21:04 +00:00
|
|
|
renderMode={this.props.renderMode}
|
|
|
|
|
style={{ flex: "1 1 auto" }}
|
2021-11-11 06:41:05 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<StyledButton
|
|
|
|
|
borderRadius={this.props.borderRadius}
|
|
|
|
|
buttonColor={button.buttonColor}
|
|
|
|
|
buttonVariant={buttonVariant}
|
|
|
|
|
disabled={isButtonDisabled}
|
|
|
|
|
iconAlign={button.iconAlign}
|
|
|
|
|
isHorizontal={isHorizontal}
|
2022-03-17 05:12:35 +00:00
|
|
|
isLabel={!!button.label}
|
2023-04-14 13:55:44 +00:00
|
|
|
onClick={getOnClick(button)}
|
2021-12-08 13:11:13 +00:00
|
|
|
>
|
2022-03-13 17:21:04 +00:00
|
|
|
<StyledButtonContent
|
|
|
|
|
iconAlign={button.iconAlign || "left"}
|
|
|
|
|
placement={button.placement}
|
|
|
|
|
>
|
2022-07-20 08:51:54 +00:00
|
|
|
{isLoading ? (
|
2022-09-30 11:24:21 +00:00
|
|
|
<Spinner size={18} />
|
2022-07-20 08:51:54 +00:00
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
{button.iconName && <Icon icon={button.iconName} />}
|
|
|
|
|
{!!button.label && (
|
|
|
|
|
<span className={CoreClass.BUTTON_TEXT}>
|
|
|
|
|
{button.label}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
2022-03-13 17:21:04 +00:00
|
|
|
)}
|
|
|
|
|
</StyledButtonContent>
|
|
|
|
|
</StyledButton>
|
|
|
|
|
</DragContainer>
|
2021-11-11 06:41:05 +00:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</ButtonGroupWrapper>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GroupButtonProps {
|
|
|
|
|
widgetId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
index: number;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
buttonType?: string;
|
|
|
|
|
buttonColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconAlign?: Alignment;
|
2021-12-08 13:11:13 +00:00
|
|
|
placement?: ButtonPlacement;
|
2021-11-11 06:41:05 +00:00
|
|
|
onClick?: string;
|
|
|
|
|
menuItems: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
widgetId: string;
|
|
|
|
|
id: string;
|
|
|
|
|
index: number;
|
|
|
|
|
isVisible?: boolean;
|
|
|
|
|
isDisabled?: boolean;
|
|
|
|
|
label?: string;
|
|
|
|
|
backgroundColor?: string;
|
|
|
|
|
textColor?: string;
|
|
|
|
|
iconName?: IconName;
|
|
|
|
|
iconColor?: string;
|
|
|
|
|
iconAlign?: Alignment;
|
|
|
|
|
onClick?: string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ButtonGroupComponentProps {
|
2022-05-04 09:45:57 +00:00
|
|
|
borderRadius?: string;
|
|
|
|
|
boxShadow?: string;
|
2021-11-11 06:41:05 +00:00
|
|
|
buttonVariant: ButtonVariant;
|
2022-07-20 08:51:54 +00:00
|
|
|
buttonClickHandler: (
|
|
|
|
|
onClick: string | undefined,
|
|
|
|
|
callback: () => void,
|
|
|
|
|
) => void;
|
2021-11-11 06:41:05 +00:00
|
|
|
groupButtons: Record<string, GroupButtonProps>;
|
2022-03-13 17:21:04 +00:00
|
|
|
isDisabled: boolean;
|
|
|
|
|
orientation: string;
|
|
|
|
|
renderMode: RenderMode;
|
|
|
|
|
width: number;
|
2022-03-28 07:14:40 +00:00
|
|
|
minPopoverWidth: number;
|
|
|
|
|
widgetId: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ButtonGroupComponentState {
|
|
|
|
|
itemRefs: Record<string, RefObject<HTMLButtonElement>>;
|
|
|
|
|
itemWidths: Record<string, number>;
|
2022-07-20 08:51:54 +00:00
|
|
|
loadedBtnId: string;
|
2021-11-11 06:41:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ButtonGroupComponent;
|