From f2653ad80810cac15782f3341b9cc1495c56ae9c Mon Sep 17 00:00:00 2001 From: Purvesh D M Date: Mon, 25 Nov 2024 11:46:18 +0530 Subject: [PATCH] refactor: [M3-8909] - Migrate `EditableText` to `ui` package (#11308) * Move EditableText to `ui` package * Added changeset: Migrate `EditableText` from `manager` to `ui` package * Added changeset: Migrate `EditableText` from `manager` to `ui` package --- .../manager/.changeset/pr-11308-removed-1732279956767.md | 5 +++++ .../src/components/Breadcrumb/FinalCrumb.styles.tsx | 4 +--- packages/ui/.changeset/pr-11308-added-1732280066633.md | 5 +++++ packages/ui/.eslintrc.json | 7 ++++++- .../src/components/EditableText/EditableText.stories.tsx | 0 .../src/components/EditableText/EditableText.test.tsx | 4 ++-- .../src/components/EditableText/EditableText.tsx | 8 ++++++-- packages/ui/src/components/EditableText/index.ts | 1 + packages/ui/src/components/index.ts | 1 + 9 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 packages/manager/.changeset/pr-11308-removed-1732279956767.md create mode 100644 packages/ui/.changeset/pr-11308-added-1732280066633.md rename packages/{manager => ui}/src/components/EditableText/EditableText.stories.tsx (100%) rename packages/{manager => ui}/src/components/EditableText/EditableText.test.tsx (97%) rename packages/{manager => ui}/src/components/EditableText/EditableText.tsx (96%) create mode 100644 packages/ui/src/components/EditableText/index.ts diff --git a/packages/manager/.changeset/pr-11308-removed-1732279956767.md b/packages/manager/.changeset/pr-11308-removed-1732279956767.md new file mode 100644 index 00000000000..8b2ade1119a --- /dev/null +++ b/packages/manager/.changeset/pr-11308-removed-1732279956767.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Removed +--- + +Migrate `EditableText` from `manager` to `ui` package ([#11308](https://github.com/linode/manager/pull/11308)) diff --git a/packages/manager/src/components/Breadcrumb/FinalCrumb.styles.tsx b/packages/manager/src/components/Breadcrumb/FinalCrumb.styles.tsx index c3f3b964420..57c84f428bb 100644 --- a/packages/manager/src/components/Breadcrumb/FinalCrumb.styles.tsx +++ b/packages/manager/src/components/Breadcrumb/FinalCrumb.styles.tsx @@ -1,8 +1,6 @@ -import { H1Header } from '@linode/ui'; +import { EditableText, H1Header } from '@linode/ui'; import { styled } from '@mui/material'; -import { EditableText } from 'src/components/EditableText/EditableText'; - export const StyledDiv = styled('div', { label: 'StyledDiv' })({ display: 'flex', flexDirection: 'column', diff --git a/packages/ui/.changeset/pr-11308-added-1732280066633.md b/packages/ui/.changeset/pr-11308-added-1732280066633.md new file mode 100644 index 00000000000..adb46e581c6 --- /dev/null +++ b/packages/ui/.changeset/pr-11308-added-1732280066633.md @@ -0,0 +1,5 @@ +--- +"@linode/ui": Added +--- + +Migrate `EditableText` from `manager` to `ui` package ([#11308](https://github.com/linode/manager/pull/11308)) diff --git a/packages/ui/.eslintrc.json b/packages/ui/.eslintrc.json index 6363fc14afc..58206a5a371 100644 --- a/packages/ui/.eslintrc.json +++ b/packages/ui/.eslintrc.json @@ -8,6 +8,7 @@ "plugins": [ "@typescript-eslint", "react", + "react-hooks", "sonarjs", "prettier", "@linode/eslint-plugin-cloud-manager" @@ -56,7 +57,7 @@ "no-trailing-spaces": "warn", "no-mixed-requires": "warn", "object-shorthand": "warn", - // Perfectionist + // perfectionist "perfectionist/sort-array-includes": "warn", "perfectionist/sort-classes": "warn", "perfectionist/sort-enums": "warn", @@ -100,6 +101,10 @@ "react/self-closing-comp": "warn", "react/jsx-no-useless-fragment": "warn", "react/no-unescaped-entities": "warn", + "react/jsx-no-script-url": "error", + "react/prop-types": "off", + "react-hooks/exhaustive-deps": "warn", + "react-hooks/rules-of-hooks": "error", // sonar "sonarjs/cognitive-complexity": "off", "sonarjs/no-duplicate-string": "warn", diff --git a/packages/manager/src/components/EditableText/EditableText.stories.tsx b/packages/ui/src/components/EditableText/EditableText.stories.tsx similarity index 100% rename from packages/manager/src/components/EditableText/EditableText.stories.tsx rename to packages/ui/src/components/EditableText/EditableText.stories.tsx diff --git a/packages/manager/src/components/EditableText/EditableText.test.tsx b/packages/ui/src/components/EditableText/EditableText.test.tsx similarity index 97% rename from packages/manager/src/components/EditableText/EditableText.test.tsx rename to packages/ui/src/components/EditableText/EditableText.test.tsx index 589ab3d4c0b..a3b7a8efb19 100644 --- a/packages/manager/src/components/EditableText/EditableText.test.tsx +++ b/packages/ui/src/components/EditableText/EditableText.test.tsx @@ -1,9 +1,9 @@ import { fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import * as React from 'react'; +import { describe, expect, it, vi } from 'vitest'; -import { renderWithTheme } from 'src/utilities/testHelpers'; - +import { renderWithTheme } from '../../utilities/testHelpers'; import { EditableText } from './EditableText'; const props = { diff --git a/packages/manager/src/components/EditableText/EditableText.tsx b/packages/ui/src/components/EditableText/EditableText.tsx similarity index 96% rename from packages/manager/src/components/EditableText/EditableText.tsx rename to packages/ui/src/components/EditableText/EditableText.tsx index 6332fde70db..b07374a8b4e 100644 --- a/packages/manager/src/components/EditableText/EditableText.tsx +++ b/packages/ui/src/components/EditableText/EditableText.tsx @@ -1,4 +1,3 @@ -import { Button, ClickAwayListener, H1Header, TextField } from '@linode/ui'; import Check from '@mui/icons-material/Check'; import Close from '@mui/icons-material/Close'; import Edit from '@mui/icons-material/Edit'; @@ -6,7 +5,12 @@ import * as React from 'react'; import { Link } from 'react-router-dom'; import { makeStyles } from 'tss-react/mui'; -import type { TextFieldProps } from '@linode/ui'; +import { Button } from '../Button'; +import { ClickAwayListener } from '../ClickAwayListener'; +import { H1Header } from '../H1Header'; +import { TextField } from '../TextField'; + +import type { TextFieldProps } from '../TextField'; import type { Theme } from '@mui/material/styles'; const useStyles = makeStyles()( diff --git a/packages/ui/src/components/EditableText/index.ts b/packages/ui/src/components/EditableText/index.ts new file mode 100644 index 00000000000..444881a7410 --- /dev/null +++ b/packages/ui/src/components/EditableText/index.ts @@ -0,0 +1 @@ +export * from './EditableText'; diff --git a/packages/ui/src/components/index.ts b/packages/ui/src/components/index.ts index 7c0075b13e9..e91c7cbce02 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/ui/src/components/index.ts @@ -6,6 +6,7 @@ export * from './Checkbox'; export * from './CircleProgress'; export * from './ClickAwayListener'; export * from './Divider'; +export * from './EditableText'; export * from './FormControl'; export * from './FormHelperText'; export * from './H1Header';