From 4fb0be37103bec2e728a0d9f389eaf77cd92992e Mon Sep 17 00:00:00 2001 From: olav Date: Tue, 14 Jun 2022 15:41:28 +0200 Subject: [PATCH 01/36] fix: show previous invoices page if UNLEASH_CLOUD is falsy (#1094) * fix: restore previous invoices page * fix: show previous invoices page if UNLEASH_CLOUD is falsy * fix: use correct amountFormatted invoice field name --- .../FlaggedBillingRedirect.tsx | 19 +++ .../RedirectAdminInvoices.tsx | 7 - .../admin/invoice/InvoiceAdminPage.tsx | 25 ++++ .../component/admin/invoice/InvoiceList.tsx | 122 ++++++++++++++++++ frontend/src/component/menu/Header/Header.tsx | 12 +- .../__snapshots__/routes.test.tsx.snap | 10 +- frontend/src/component/menu/routes.ts | 10 +- frontend/src/interfaces/invoice.ts | 8 ++ frontend/src/interfaces/route.ts | 2 +- 9 files changed, 191 insertions(+), 24 deletions(-) create mode 100644 frontend/src/component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect.tsx delete mode 100644 frontend/src/component/admin/billing/RedirectAdminInvoices/RedirectAdminInvoices.tsx create mode 100644 frontend/src/component/admin/invoice/InvoiceAdminPage.tsx create mode 100644 frontend/src/component/admin/invoice/InvoiceList.tsx create mode 100644 frontend/src/interfaces/invoice.ts diff --git a/frontend/src/component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect.tsx b/frontend/src/component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect.tsx new file mode 100644 index 0000000000..0a9d17683e --- /dev/null +++ b/frontend/src/component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect.tsx @@ -0,0 +1,19 @@ +import { Navigate } from 'react-router-dom'; +import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; +import InvoiceAdminPage from 'component/admin/invoice/InvoiceAdminPage'; + +const FlaggedBillingRedirect = () => { + const { uiConfig, loading } = useUiConfig(); + + if (loading) { + return null; + } + + if (!uiConfig.flags.UNLEASH_CLOUD) { + return ; + } + + return ; +}; + +export default FlaggedBillingRedirect; diff --git a/frontend/src/component/admin/billing/RedirectAdminInvoices/RedirectAdminInvoices.tsx b/frontend/src/component/admin/billing/RedirectAdminInvoices/RedirectAdminInvoices.tsx deleted file mode 100644 index 07111c962e..0000000000 --- a/frontend/src/component/admin/billing/RedirectAdminInvoices/RedirectAdminInvoices.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { Navigate } from 'react-router-dom'; - -const RedirectAdminInvoices = () => { - return ; -}; - -export default RedirectAdminInvoices; diff --git a/frontend/src/component/admin/invoice/InvoiceAdminPage.tsx b/frontend/src/component/admin/invoice/InvoiceAdminPage.tsx new file mode 100644 index 0000000000..f9197c0df6 --- /dev/null +++ b/frontend/src/component/admin/invoice/InvoiceAdminPage.tsx @@ -0,0 +1,25 @@ +import { useContext } from 'react'; +import InvoiceList from './InvoiceList'; +import AccessContext from 'contexts/AccessContext'; +import { ADMIN } from 'component/providers/AccessProvider/permissions'; +import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; +import { Alert } from '@mui/material'; + +const InvoiceAdminPage = () => { + const { hasAccess } = useContext(AccessContext); + return ( +
+ } + elseShow={ + + You need to be instance admin to access this section. + + } + /> +
+ ); +}; + +export default InvoiceAdminPage; diff --git a/frontend/src/component/admin/invoice/InvoiceList.tsx b/frontend/src/component/admin/invoice/InvoiceList.tsx new file mode 100644 index 0000000000..136706ca32 --- /dev/null +++ b/frontend/src/component/admin/invoice/InvoiceList.tsx @@ -0,0 +1,122 @@ +import { useEffect, useState } from 'react'; +import { + Table, + TableHead, + TableBody, + TableRow, + TableCell, + Button, +} from '@mui/material'; +import OpenInNew from '@mui/icons-material/OpenInNew'; +import { PageContent } from 'component/common/PageContent/PageContent'; +import { PageHeader } from 'component/common/PageHeader/PageHeader'; +import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; +import { formatApiPath } from 'utils/formatPath'; +import useInvoices from 'hooks/api/getters/useInvoices/useInvoices'; +import { IInvoice } from 'interfaces/invoice'; +import { useLocationSettings } from 'hooks/useLocationSettings'; +import { formatDateYMD } from 'utils/formatDate'; + +const PORTAL_URL = formatApiPath('api/admin/invoices/portal'); + +const InvoiceList = () => { + const { refetchInvoices, invoices } = useInvoices(); + const [isLoaded, setLoaded] = useState(false); + const { locationSettings } = useLocationSettings(); + + useEffect(() => { + refetchInvoices(); + setLoaded(true); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return ( + 0} + show={ + } + > + Billing portal + + } + /> + } + > +
+ + + + Amount + Status + Due date + PDF + Link + + + + {invoices.map((item: IInvoice) => ( + + + {item.amountFormatted} + + + {item.status} + + + {item.dueDate && + formatDateYMD( + item.dueDate, + locationSettings.locale + )} + + + PDF + + + + Payment link + + + + ))} + +
+
+
+ } + elseShow={
{isLoaded && 'No invoices to show.'}
} + /> + ); +}; +export default InvoiceList; diff --git a/frontend/src/component/menu/Header/Header.tsx b/frontend/src/component/menu/Header/Header.tsx index 00f6da9574..facdb236ce 100644 --- a/frontend/src/component/menu/Header/Header.tsx +++ b/frontend/src/component/menu/Header/Header.tsx @@ -23,7 +23,6 @@ import { useAuthPermissions } from 'hooks/api/getters/useAuth/useAuthPermissions import { useStyles } from './Header.styles'; import classNames from 'classnames'; import { useId } from 'hooks/useId'; -import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus'; import { IRoute } from 'interfaces/route'; const Header: VFC = () => { @@ -37,6 +36,7 @@ const Header: VFC = () => { const { permissions } = useAuthPermissions(); const { uiConfig: { links, name, flags }, + isOss, } = useUiConfig(); const smallScreen = useMediaQuery(theme.breakpoints.down('md')); const { classes: styles } = useStyles(); @@ -57,15 +57,18 @@ const Header: VFC = () => { } }, [permissions]); - const { isBilling } = useInstanceStatus(); const routes = getRoutes(); + const filterByEnterprise = (route: IRoute): boolean => { + return !route.menu.isEnterprise || !isOss(); + }; + const filteredMainRoutes = { mainNavRoutes: routes.mainNavRoutes.filter(filterByFlags(flags)), mobileRoutes: routes.mobileRoutes.filter(filterByFlags(flags)), adminRoutes: routes.adminRoutes .filter(filterByFlags(flags)) - .filter(filterByBilling(isBilling)), + .filter(filterByEnterprise), }; if (smallScreen) { @@ -196,7 +199,4 @@ const Header: VFC = () => { ); }; -export const filterByBilling = (isBilling?: boolean) => (route: IRoute) => - !route.menu.isBilling || isBilling; - export default Header; diff --git a/frontend/src/component/menu/__tests__/__snapshots__/routes.test.tsx.snap b/frontend/src/component/menu/__tests__/__snapshots__/routes.test.tsx.snap index 6c49570e44..6b5c45ae25 100644 --- a/frontend/src/component/menu/__tests__/__snapshots__/routes.test.tsx.snap +++ b/frontend/src/component/menu/__tests__/__snapshots__/routes.test.tsx.snap @@ -411,10 +411,7 @@ exports[`returns all baseRoutes 1`] = ` }, { "component": [Function], - "menu": { - "adminSettings": true, - "isBilling": true, - }, + "menu": {}, "parent": "/admin", "path": "/admin/billing", "title": "Billing", @@ -422,7 +419,10 @@ exports[`returns all baseRoutes 1`] = ` }, { "component": [Function], - "menu": {}, + "menu": { + "adminSettings": true, + "isEnterprise": true, + }, "parent": "/admin", "path": "/admin-invoices", "title": "Invoices", diff --git a/frontend/src/component/menu/routes.ts b/frontend/src/component/menu/routes.ts index 1e51189519..3189b20848 100644 --- a/frontend/src/component/menu/routes.ts +++ b/frontend/src/component/menu/routes.ts @@ -7,7 +7,6 @@ import Admin from 'component/admin'; import AdminApi from 'component/admin/api'; import AdminUsers from 'component/admin/users/UsersAdmin'; import { AuthSettings } from 'component/admin/auth/AuthSettings'; -import { Billing } from 'component/admin/billing/Billing'; import Login from 'component/user/Login/Login'; import { C, EEA, P, RE, SE } from 'component/common/flags'; import { NewUser } from 'component/user/NewUser/NewUser'; @@ -50,8 +49,9 @@ import { EditSegment } from 'component/segments/EditSegment/EditSegment'; import { IRoute } from 'interfaces/route'; import { EnvironmentTable } from 'component/environments/EnvironmentTable/EnvironmentTable'; import { SegmentTable } from 'component/segments/SegmentTable/SegmentTable'; -import RedirectAdminInvoices from 'component/admin/billing/RedirectAdminInvoices/RedirectAdminInvoices'; +import FlaggedBillingRedirect from 'component/admin/billing/FlaggedBillingRedirect/FlaggedBillingRedirect'; import { FeaturesArchiveTable } from '../archive/FeaturesArchiveTable'; +import { Billing } from 'component/admin/billing/Billing'; export const routes: IRoute[] = [ // Splash @@ -462,15 +462,15 @@ export const routes: IRoute[] = [ title: 'Billing', component: Billing, type: 'protected', - menu: { adminSettings: true, isBilling: true }, + menu: {}, }, { path: '/admin-invoices', parent: '/admin', title: 'Invoices', - component: RedirectAdminInvoices, + component: FlaggedBillingRedirect, type: 'protected', - menu: {}, + menu: { adminSettings: true, isEnterprise: true }, }, { path: '/admin', diff --git a/frontend/src/interfaces/invoice.ts b/frontend/src/interfaces/invoice.ts new file mode 100644 index 0000000000..82790c14cd --- /dev/null +++ b/frontend/src/interfaces/invoice.ts @@ -0,0 +1,8 @@ +export interface IInvoice { + amountFormatted: string; + invoicePDF: string; + invoiceURL: string; + paid: boolean; + status: string; + dueDate?: Date; +} diff --git a/frontend/src/interfaces/route.ts b/frontend/src/interfaces/route.ts index 213bec4a51..6c94cb1a80 100644 --- a/frontend/src/interfaces/route.ts +++ b/frontend/src/interfaces/route.ts @@ -17,5 +17,5 @@ interface IRouteMenu { mobile?: boolean; advanced?: boolean; adminSettings?: boolean; - isBilling?: boolean; + isEnterprise?: boolean; } From bb22a1fe246771ec66ce1a1d14f2990b243f46eb Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 14 Jun 2022 15:45:30 +0000 Subject: [PATCH 02/36] chore(deps): update dependency prettier to v2.7.0 --- frontend/package.json | 2 +- frontend/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 527045faa8..a10765a498 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -79,7 +79,7 @@ "msw": "0.42.1", "pkginfo": "^0.4.1", "plausible-tracker": "0.3.8", - "prettier": "2.6.2", + "prettier": "2.7.0", "prop-types": "15.8.1", "react": "17.0.2", "react-chartjs-2": "4.2.0", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index fe2af55c1a..754591d6b9 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -5099,10 +5099,10 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prettier@2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032" - integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew== +prettier@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.0.tgz#a4fdae07e5596c51c9857ea676cd41a0163879d6" + integrity sha512-nwoX4GMFgxoPC6diHvSwmK/4yU8FFH3V8XWtLQrbj4IBsK2pkYhG4kf/ljF/haaZ/aii+wNJqISrCDPgxGWDVQ== pretty-bytes@^5.6.0: version "5.6.0" From dffb4e15141e057f6892e2fd189886f1376c88e2 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 14 Jun 2022 18:41:30 +0000 Subject: [PATCH 03/36] chore(deps): update material-ui monorepo --- frontend/package.json | 6 +-- frontend/yarn.lock | 98 ++++++++++++++++++++++++------------------- 2 files changed, 57 insertions(+), 47 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index a10765a498..7e9d6facaf 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -39,9 +39,9 @@ "devDependencies": { "@emotion/react": "11.9.3", "@emotion/styled": "11.9.3", - "@mui/icons-material": "5.8.3", - "@mui/lab": "5.0.0-alpha.85", - "@mui/material": "5.8.3", + "@mui/icons-material": "5.8.4", + "@mui/lab": "5.0.0-alpha.86", + "@mui/material": "5.8.4", "@openapitools/openapi-generator-cli": "2.5.1", "@testing-library/dom": "8.13.0", "@testing-library/jest-dom": "5.16.4", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 754591d6b9..5ac76939f5 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1370,36 +1370,36 @@ outvariant "^1.2.1" strict-event-emitter "^0.2.4" -"@mui/base@5.0.0-alpha.84": - version "5.0.0-alpha.84" - resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.84.tgz#83c580c9b04b4e4efe3fb39572720470b0d7cc29" - integrity sha512-uDx+wGVytS+ZHiWHyzUyijY83GSIXJpzSJ0PGc/8/s+8nBzeHvaPKrAyJz15ASLr52hYRA6PQGqn0eRAsB7syQ== +"@mui/base@5.0.0-alpha.85": + version "5.0.0-alpha.85" + resolved "https://registry.yarnpkg.com/@mui/base/-/base-5.0.0-alpha.85.tgz#e9e19678bf72dae228d0f25d33dfe20462aac833" + integrity sha512-ONlQJOmQrxmR+pYF9AqH69FOG4ofwzVzNltwb2xKAQIW3VbsNZahcHIpzhFd70W6EIU+QHzB9TzamSM+Fg/U7w== dependencies: "@babel/runtime" "^7.17.2" "@emotion/is-prop-valid" "^1.1.2" - "@mui/types" "^7.1.3" - "@mui/utils" "^5.8.0" + "@mui/types" "^7.1.4" + "@mui/utils" "^5.8.4" "@popperjs/core" "^2.11.5" clsx "^1.1.1" prop-types "^15.8.1" react-is "^17.0.2" -"@mui/icons-material@5.8.3": - version "5.8.3" - resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.8.3.tgz#75c8bde42e6ba71e3871439a2b751be987343493" - integrity sha512-dAdhimSLKOV0Q8FR7AYGEaCrTUh9OV7zU4Ueo5REoUt4cC3Vy+UBKDjZk66x5ezaYb63AFgQIFwtnZj3B/QDbQ== +"@mui/icons-material@5.8.4": + version "5.8.4" + resolved "https://registry.yarnpkg.com/@mui/icons-material/-/icons-material-5.8.4.tgz#3f2907c9f8f5ce4d754cb8fb4b68b5a1abf4d095" + integrity sha512-9Z/vyj2szvEhGWDvb+gG875bOGm8b8rlHBKOD1+nA3PcgC3fV6W1AU6pfOorPeBfH2X4mb9Boe97vHvaSndQvA== dependencies: "@babel/runtime" "^7.17.2" -"@mui/lab@5.0.0-alpha.85": - version "5.0.0-alpha.85" - resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.85.tgz#e7f5f2530b66151d508dc23d4d9848953e6e5b1b" - integrity sha512-GaPl5azVXr9dbwZe1DiKr3GO9Bg3nbZ48oRTDZoMxWYMB8dm4f73GrY2Sv1Sf03z19YzlD7Ixskr6rGcKGPWlw== +"@mui/lab@5.0.0-alpha.86": + version "5.0.0-alpha.86" + resolved "https://registry.yarnpkg.com/@mui/lab/-/lab-5.0.0-alpha.86.tgz#83323e0ff17fdea641fa1d93be024413bf407ec3" + integrity sha512-5dx9/vHldiE5KFu99YUtEGKyUgwTiq8wM+IhEnNKkU+YjEMULVYV+mgS9nvnf6laKtgqy2hOE4JivqRPIuOGdA== dependencies: "@babel/runtime" "^7.17.2" - "@mui/base" "5.0.0-alpha.84" - "@mui/system" "^5.8.3" - "@mui/utils" "^5.8.0" + "@mui/base" "5.0.0-alpha.85" + "@mui/system" "^5.8.4" + "@mui/utils" "^5.8.4" "@mui/x-date-pickers" "5.0.0-alpha.1" clsx "^1.1.1" prop-types "^15.8.1" @@ -1407,31 +1407,30 @@ react-transition-group "^4.4.2" rifm "^0.12.1" -"@mui/material@5.8.3": - version "5.8.3" - resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.8.3.tgz#86681d14c1a119d1d9b6b981c864736d075d095f" - integrity sha512-8UecY/W9SMtEZm5PMCUcMbujajVP6fobu0BgBPiIWwwWRblZVEzqprY6v1P2me7qCyrve4L4V/rqAKPKhVHOSg== +"@mui/material@5.8.4": + version "5.8.4" + resolved "https://registry.yarnpkg.com/@mui/material/-/material-5.8.4.tgz#b9cdae0c79ea770bc9cc3aafb7f750ed8ebe1b5d" + integrity sha512-KlOJS1JGhwuhdoF4fulmz41h/YxyMdZSc+ncz+HAah0GKn8ovAs5774f1w0lIasxbtI1Ziunwvmnu9PvvUKdMw== dependencies: "@babel/runtime" "^7.17.2" - "@mui/base" "5.0.0-alpha.84" - "@mui/system" "^5.8.3" - "@mui/types" "^7.1.3" - "@mui/utils" "^5.8.0" + "@mui/base" "5.0.0-alpha.85" + "@mui/system" "^5.8.4" + "@mui/types" "^7.1.4" + "@mui/utils" "^5.8.4" "@types/react-transition-group" "^4.4.4" clsx "^1.1.1" csstype "^3.1.0" - hoist-non-react-statics "^3.3.2" prop-types "^15.8.1" react-is "^17.0.2" react-transition-group "^4.4.2" -"@mui/private-theming@^5.8.0": - version "5.8.0" - resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.8.0.tgz#7d927e7e12616dc10b0dcbe665df2c00ed859796" - integrity sha512-MjRAneTmCKLR9u2S4jtjLUe6gpHxlbb4g2bqpDJ2PdwlvwsWIUzbc/gVB4dvccljXeWxr5G2M/Co2blXisvFIw== +"@mui/private-theming@^5.8.4": + version "5.8.4" + resolved "https://registry.yarnpkg.com/@mui/private-theming/-/private-theming-5.8.4.tgz#8ff896601cf84eb9f8394db7674ee4dd2a3343f7" + integrity sha512-3Lp0VAEjtQygJ70MWEyHkKvg327O6YoBH6ZNEy6fIsrK6gmRIj+YrlvJ7LQCbowY+qDGnbdMrTBd1hfThlI8lg== dependencies: "@babel/runtime" "^7.17.2" - "@mui/utils" "^5.8.0" + "@mui/utils" "^5.8.4" prop-types "^15.8.1" "@mui/styled-engine@^5.8.0": @@ -1443,26 +1442,26 @@ "@emotion/cache" "^11.7.1" prop-types "^15.8.1" -"@mui/system@^5.8.3": - version "5.8.3" - resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.8.3.tgz#66db174f1b5c244eb73dbc48527509782a22ec0a" - integrity sha512-/tyGQcYqZT0nl98qV9XnGiedTO+V7VHc28k4POfhMJNedB1CRrwWRm767DeEdc5f/8CU2See3WD16ikP6pYiOA== +"@mui/system@^5.8.4": + version "5.8.4" + resolved "https://registry.yarnpkg.com/@mui/system/-/system-5.8.4.tgz#88306aefcc3a60528f69dcd2d66516831859c328" + integrity sha512-eeYZXlOn4p+tYwqqDlci6wW4knJ68aGx5A24YU9ubYZ5o0IwveoNP3LC9sHAMxigk/mUTqL4bpSMJ2HbTn2aQg== dependencies: "@babel/runtime" "^7.17.2" - "@mui/private-theming" "^5.8.0" + "@mui/private-theming" "^5.8.4" "@mui/styled-engine" "^5.8.0" - "@mui/types" "^7.1.3" - "@mui/utils" "^5.8.0" + "@mui/types" "^7.1.4" + "@mui/utils" "^5.8.4" clsx "^1.1.1" csstype "^3.1.0" prop-types "^15.8.1" -"@mui/types@^7.1.3": - version "7.1.3" - resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.1.3.tgz#d7636f3046110bcccc63e6acfd100e2ad9ca712a" - integrity sha512-DDF0UhMBo4Uezlk+6QxrlDbchF79XG6Zs0zIewlR4c0Dt6GKVFfUtzPtHCH1tTbcSlq/L2bGEdiaoHBJ9Y1gSA== +"@mui/types@^7.1.4": + version "7.1.4" + resolved "https://registry.yarnpkg.com/@mui/types/-/types-7.1.4.tgz#4185c05d6df63ec673cda15feab80440abadc764" + integrity sha512-uveM3byMbthO+6tXZ1n2zm0W3uJCQYtwt/v5zV5I77v2v18u0ITkb8xwhsDD2i3V2Kye7SaNR6FFJ6lMuY/WqQ== -"@mui/utils@^5.6.0", "@mui/utils@^5.8.0": +"@mui/utils@^5.6.0": version "5.8.0" resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.8.0.tgz#4b1d19cbcf70773283375e763b7b3552b84cb58f" integrity sha512-7LgUtCvz78676iC0wpTH7HizMdCrTphhBmRWimIMFrp5Ph6JbDFVuKS1CwYnWWxRyYKL0QzXrDL0lptAU90EXg== @@ -1473,6 +1472,17 @@ prop-types "^15.8.1" react-is "^17.0.2" +"@mui/utils@^5.8.4": + version "5.8.4" + resolved "https://registry.yarnpkg.com/@mui/utils/-/utils-5.8.4.tgz#5c46b5900bd2452b3ce54a7a1c94a3e2a8a75c34" + integrity sha512-BHYErfrjqqh76KaDAm8wZlhEip1Uj7Cmco65NcsF3BWrAl3FWngACpaPZeEbTgmaEwyWAQEE6LZhsmy43hfyqQ== + dependencies: + "@babel/runtime" "^7.17.2" + "@types/prop-types" "^15.7.5" + "@types/react-is" "^16.7.1 || ^17.0.0" + prop-types "^15.8.1" + react-is "^17.0.2" + "@mui/x-date-pickers@5.0.0-alpha.1": version "5.0.0-alpha.1" resolved "https://registry.yarnpkg.com/@mui/x-date-pickers/-/x-date-pickers-5.0.0-alpha.1.tgz#7450b5544b9ed655db41891c74e2c5f652fbedb7" @@ -4032,7 +4042,7 @@ history@^5.2.0: dependencies: "@babel/runtime" "^7.7.6" -hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2: +hoist-non-react-statics@^3.3.1: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== From 522f4aed415e8be674b2d22e64637f49691b3642 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 14 Jun 2022 22:04:09 +0000 Subject: [PATCH 04/36] chore(deps): update dependency vitest to v0.15.0 --- frontend/package.json | 2 +- frontend/yarn.lock | 25 +++++++------------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 7e9d6facaf..229213feb1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -98,7 +98,7 @@ "vite-plugin-env-compatible": "^1.1.1", "vite-plugin-svgr": "2.1.0", "vite-tsconfig-paths": "3.5.0", - "vitest": "0.14.2", + "vitest": "0.15.0", "whatwg-fetch": "^3.6.2" }, "jest": { diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 5ac76939f5..da5ab97b4b 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -6072,7 +6072,7 @@ vite-tsconfig-paths@3.5.0: recrawl-sync "^2.0.3" tsconfig-paths "^4.0.0" -vite@2.9.12: +vite@2.9.12, vite@^2.9.12: version "2.9.12" resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.12.tgz#b1d636b0a8ac636afe9d83e3792d4895509a941b" integrity sha512-suxC36dQo9Rq1qMB2qiRorNJtJAdxguu5TMvBHOc/F370KvqAe9t48vYp+/TbPKRNrMh/J55tOUmkuIqstZaew== @@ -6084,31 +6084,20 @@ vite@2.9.12: optionalDependencies: fsevents "~2.3.2" -vite@^2.9.9: - version "2.9.9" - resolved "https://registry.yarnpkg.com/vite/-/vite-2.9.9.tgz#8b558987db5e60fedec2f4b003b73164cb081c5e" - integrity sha512-ffaam+NgHfbEmfw/Vuh6BHKKlI/XIAhxE5QSS7gFLIngxg171mg1P3a4LSRME0z2ZU1ScxoKzphkipcYwSD5Ew== - dependencies: - esbuild "^0.14.27" - postcss "^8.4.13" - resolve "^1.22.0" - rollup "^2.59.0" - optionalDependencies: - fsevents "~2.3.2" - -vitest@0.14.2: - version "0.14.2" - resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.14.2.tgz#ac07b46d3cd3b5667d2bb803962f759a1b8f3f89" - integrity sha512-vXQUl8OUCqHmxKWscMGL+6Xl1pBJmYHZ8N85iNpLGrirAC2vhspu7b73ShRcLonmZT44BYZW+LBAVvn0L4jyVA== +vitest@0.15.0: + version "0.15.0" + resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.15.0.tgz#c59d5283bc34a7780ba8eccd230edaa1ebaf04ef" + integrity sha512-ofXZ8tBYAkVJpTpkaGruBh9nG6lO9cs04IdFpneDblCwBpncnlpEgZvlF3XWF4lSsklPe9le4MO8+j90DnsX+g== dependencies: "@types/chai" "^4.3.1" "@types/chai-subset" "^1.3.3" + "@types/node" "*" chai "^4.3.6" debug "^4.3.4" local-pkg "^0.4.1" tinypool "^0.1.3" tinyspy "^0.3.2" - vite "^2.9.9" + vite "^2.9.12" w3c-hr-time@^1.0.2: version "1.0.2" From 37fa469faf3a6be5573dbfb200d5afdc15c056cf Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Wed, 15 Jun 2022 15:16:42 +0200 Subject: [PATCH 05/36] Archive table updates (#1097) * minor archive table updates * archived date cell * archive import paths --- .../Reporting/ReportTable/ReportTable.tsx | 8 +++- .../apiToken/ApiTokenTable/ApiTokenTable.tsx | 23 ++++----- .../archive/ArchiveTable/ArchiveTable.tsx | 47 ++++++++++--------- .../FeatureArchivedCell.tsx | 43 +++++++++++------ .../ReviveArchivedFeatureCell.tsx | 2 +- .../archive/FeaturesArchiveTable.tsx | 9 ++-- .../archive/ProjectFeaturesArchiveTable.tsx | 4 +- .../FeatureStaleDialog/FeatureStaleDialog.tsx | 14 +++--- .../FeatureToggleListItem.tsx | 2 +- .../feature/FeatureView/FeatureView.tsx | 2 +- 10 files changed, 85 insertions(+), 69 deletions(-) diff --git a/frontend/src/component/Reporting/ReportTable/ReportTable.tsx b/frontend/src/component/Reporting/ReportTable/ReportTable.tsx index ab35369951..a64756cab9 100644 --- a/frontend/src/component/Reporting/ReportTable/ReportTable.tsx +++ b/frontend/src/component/Reporting/ReportTable/ReportTable.tsx @@ -173,6 +173,7 @@ const COLUMNS = [ align: 'center', Cell: FeatureSeenCell, disableGlobalFilter: true, + minWidth: 85, }, { Header: 'Type', @@ -180,6 +181,7 @@ const COLUMNS = [ align: 'center', Cell: FeatureTypeCell, disableGlobalFilter: true, + minWidth: 85, }, { Header: 'Name', @@ -194,18 +196,21 @@ const COLUMNS = [ sortType: 'date', Cell: DateCell, disableGlobalFilter: true, + minWidth: 150, }, { Header: 'Expired', accessor: 'expiredAt', Cell: ReportExpiredCell, disableGlobalFilter: true, + minWidth: 150, }, { Header: 'Status', - accessor: 'status', + id: 'status', Cell: ReportStatusCell, disableGlobalFilter: true, + minWidth: 200, }, { Header: 'State', @@ -213,5 +218,6 @@ const COLUMNS = [ sortType: 'boolean', Cell: FeatureStaleCell, disableGlobalFilter: true, + minWidth: 120, }, ]; diff --git a/frontend/src/component/admin/apiToken/ApiTokenTable/ApiTokenTable.tsx b/frontend/src/component/admin/apiToken/ApiTokenTable/ApiTokenTable.tsx index 90801c8197..273ca43376 100644 --- a/frontend/src/component/admin/apiToken/ApiTokenTable/ApiTokenTable.tsx +++ b/frontend/src/component/admin/apiToken/ApiTokenTable/ApiTokenTable.tsx @@ -56,24 +56,21 @@ export const ApiTokenTable = () => { setHiddenColumns(hiddenColumns); }, [setHiddenColumns, hiddenColumns]); - const headerSearch = ( - - ); - - const headerActions = ( - <> - {headerSearch} - - - - ); - return ( + + + + + } /> } > diff --git a/frontend/src/component/archive/ArchiveTable/ArchiveTable.tsx b/frontend/src/component/archive/ArchiveTable/ArchiveTable.tsx index 1978526139..b0f94005a0 100644 --- a/frontend/src/component/archive/ArchiveTable/ArchiveTable.tsx +++ b/frontend/src/component/archive/ArchiveTable/ArchiveTable.tsx @@ -17,13 +17,13 @@ import { HighlightCell } from 'component/common/Table/cells/HighlightCell/Highli import { DateCell } from 'component/common/Table/cells/DateCell/DateCell'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { Search } from 'component/common/Search/Search'; -import { FeatureTypeCell } from '../../common/Table/cells/FeatureTypeCell/FeatureTypeCell'; -import { FeatureSeenCell } from '../../common/Table/cells/FeatureSeenCell/FeatureSeenCell'; -import { LinkCell } from '../../common/Table/cells/LinkCell/LinkCell'; -import { FeatureStaleCell } from '../../feature/FeatureToggleList/FeatureStaleCell/FeatureStaleCell'; +import { FeatureTypeCell } from 'component/common/Table/cells/FeatureTypeCell/FeatureTypeCell'; +import { FeatureSeenCell } from 'component/common/Table/cells/FeatureSeenCell/FeatureSeenCell'; +import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell'; +import { FeatureStaleCell } from 'component/feature/FeatureToggleList/FeatureStaleCell/FeatureStaleCell'; import { ReviveArchivedFeatureCell } from 'component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell'; -import { useStyles } from '../../feature/FeatureToggleList/styles'; -import { featuresPlaceholder } from '../../feature/FeatureToggleList/FeatureToggleListTable'; +import { useStyles } from 'component/feature/FeatureToggleList/styles'; +import { featuresPlaceholder } from 'component/feature/FeatureToggleList/FeatureToggleListTable'; import theme from 'themes/theme'; import { FeatureSchema } from 'openapi'; import { useFeatureArchiveApi } from 'hooks/api/actions/useFeatureArchiveApi/useReviveFeatureApi'; @@ -152,7 +152,7 @@ export const ArchiveTable = ({ ] : []), { - Header: 'Status', + Header: 'State', accessor: 'stale', Cell: FeatureStaleCell, sortType: 'boolean', @@ -166,7 +166,6 @@ export const ArchiveTable = ({ align: 'center', maxWidth: 85, canSort: false, - disableGlobalFilter: true, Cell: ({ row: { original } }: any) => ( 0} - show={ - - No feature toggles found matching “ - {searchValue}” - - } - /> - - None of the feature toggles where archived yet. - - } + condition={rows.length === 0} + show={() => ( + 0} + show={ + + No feature toggles found matching “ + {searchValue}” + + } + elseShow={ + + None of the feature toggles were archived yet. + + } + /> + )} /> ); diff --git a/frontend/src/component/archive/ArchiveTable/FeatureArchivedCell/FeatureArchivedCell.tsx b/frontend/src/component/archive/ArchiveTable/FeatureArchivedCell/FeatureArchivedCell.tsx index 75c94812f0..7cd1177199 100644 --- a/frontend/src/component/archive/ArchiveTable/FeatureArchivedCell/FeatureArchivedCell.tsx +++ b/frontend/src/component/archive/ArchiveTable/FeatureArchivedCell/FeatureArchivedCell.tsx @@ -1,6 +1,6 @@ import { VFC } from 'react'; import TimeAgo from 'react-timeago'; -import { Tooltip, Typography } from '@mui/material'; +import { Tooltip, Typography, useTheme } from '@mui/material'; import { formatDateYMD } from 'utils/formatDate'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import { useLocationSettings } from 'hooks/useLocationSettings'; @@ -13,24 +13,37 @@ export const FeatureArchivedCell: VFC = ({ value: archivedAt, }) => { const { locationSettings } = useLocationSettings(); + const theme = useTheme(); - if (!archivedAt) return ; + if (!archivedAt) + return ( + + + not available + + + ); return ( - {archivedAt && ( - - - - - - )} + + + + + ); }; diff --git a/frontend/src/component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell.tsx b/frontend/src/component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell.tsx index 995810c38c..8a9b7c5029 100644 --- a/frontend/src/component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell.tsx +++ b/frontend/src/component/archive/ArchiveTable/ReviveArchivedFeatureCell/ReviveArchivedFeatureCell.tsx @@ -19,7 +19,7 @@ export const ReviveArchivedFeatureCell: VFC = ({ onClick={onRevive} projectId={project} permission={UPDATE_FEATURE} - tooltipProps={{ title: 'Revive feature' }} + tooltipProps={{ title: 'Revive feature toggle' }} > diff --git a/frontend/src/component/archive/FeaturesArchiveTable.tsx b/frontend/src/component/archive/FeaturesArchiveTable.tsx index 23e57da625..1fde18d557 100644 --- a/frontend/src/component/archive/FeaturesArchiveTable.tsx +++ b/frontend/src/component/archive/FeaturesArchiveTable.tsx @@ -1,17 +1,18 @@ -import { useFeaturesArchive } from '../../hooks/api/getters/useFeaturesArchive/useFeaturesArchive'; +import { useFeaturesArchive } from 'hooks/api/getters/useFeaturesArchive/useFeaturesArchive'; import { ArchiveTable } from './ArchiveTable/ArchiveTable'; import { SortingRule } from 'react-table'; import { usePageTitle } from 'hooks/usePageTitle'; import { createLocalStorage } from 'utils/createLocalStorage'; -const defaultSort: SortingRule = { id: 'createdAt', desc: true }; +const defaultSort: SortingRule = { id: 'createdAt' }; const { value, setValue } = createLocalStorage( 'FeaturesArchiveTable:v1', defaultSort ); export const FeaturesArchiveTable = () => { - usePageTitle('Archived'); + usePageTitle('Archive'); + const { archivedFeatures = [], loading, @@ -20,7 +21,7 @@ export const FeaturesArchiveTable = () => { return ( = { id: 'archivedAt', desc: true }; +const defaultSort: SortingRule = { id: 'archivedAt' }; interface IProjectFeaturesTable { projectId: string; diff --git a/frontend/src/component/common/FeatureStaleDialog/FeatureStaleDialog.tsx b/frontend/src/component/common/FeatureStaleDialog/FeatureStaleDialog.tsx index 1897eacf57..eeef302ec3 100644 --- a/frontend/src/component/common/FeatureStaleDialog/FeatureStaleDialog.tsx +++ b/frontend/src/component/common/FeatureStaleDialog/FeatureStaleDialog.tsx @@ -68,17 +68,15 @@ export const FeatureStaleDialog = ({ open={isOpen} secondaryButtonText={'Cancel'} primaryButtonText={`Flip to ${toggleActionText}`} - title={`Set feature status to ${toggleActionText}`} + title={`Set feature state to ${toggleActionText}`} onClick={onSubmit} onClose={onClose} > - <> - - + ); }; diff --git a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.tsx b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.tsx index 1733d5c274..b2e6bbf20d 100644 --- a/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.tsx +++ b/frontend/src/component/feature/FeatureToggleList/FeatureToggleListItem/FeatureToggleListItem.tsx @@ -196,7 +196,7 @@ export const FeatureToggleListItem = memo( !projectExists() } onClick={reviveFeature} - tooltipProps={{ title: 'Revive feature' }} + tooltipProps={{ title: 'Revive feature toggle' }} > diff --git a/frontend/src/component/feature/FeatureView/FeatureView.tsx b/frontend/src/component/feature/FeatureView/FeatureView.tsx index a1da3d7c56..2d66d81db2 100644 --- a/frontend/src/component/feature/FeatureView/FeatureView.tsx +++ b/frontend/src/component/feature/FeatureView/FeatureView.tsx @@ -144,7 +144,7 @@ export const FeatureView = () => { permission={UPDATE_FEATURE} projectId={projectId} tooltipProps={{ - title: 'Toggle stale status', + title: 'Toggle stale state', }} data-loading > From b38f5e21f1c80cb35c1ce7180d5a84baedb86469 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 15 Jun 2022 13:20:37 +0000 Subject: [PATCH 06/36] chore(deps): update dependency vitest to v0.15.1 --- frontend/package.json | 2 +- frontend/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 229213feb1..56cd699312 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -98,7 +98,7 @@ "vite-plugin-env-compatible": "^1.1.1", "vite-plugin-svgr": "2.1.0", "vite-tsconfig-paths": "3.5.0", - "vitest": "0.15.0", + "vitest": "0.15.1", "whatwg-fetch": "^3.6.2" }, "jest": { diff --git a/frontend/yarn.lock b/frontend/yarn.lock index da5ab97b4b..fd77c986ba 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -6084,10 +6084,10 @@ vite@2.9.12, vite@^2.9.12: optionalDependencies: fsevents "~2.3.2" -vitest@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.15.0.tgz#c59d5283bc34a7780ba8eccd230edaa1ebaf04ef" - integrity sha512-ofXZ8tBYAkVJpTpkaGruBh9nG6lO9cs04IdFpneDblCwBpncnlpEgZvlF3XWF4lSsklPe9le4MO8+j90DnsX+g== +vitest@0.15.1: + version "0.15.1" + resolved "https://registry.yarnpkg.com/vitest/-/vitest-0.15.1.tgz#8bdb42544261fa95afe8ea10bae3f315ca7e4c74" + integrity sha512-NaNFi93JKSuvV4YGnfQ0l0GKYxH0EsLcTrrXaCzd6qfVEZM/RJpjwSevg6waNFqu2DyN6e0aHHdrCZW5/vh5NA== dependencies: "@types/chai" "^4.3.1" "@types/chai-subset" "^1.3.3" From accf9294c86569f71e71718bdb41f9ebf2747c76 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 15 Jun 2022 17:13:32 +0000 Subject: [PATCH 07/36] chore(deps): update dependency @types/semver to v7.3.10 --- frontend/package.json | 2 +- frontend/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 56cd699312..d9eb79ca4b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -59,7 +59,7 @@ "@types/react-table": "7.7.12", "@types/react-test-renderer": "17.0.2", "@types/react-timeago": "4.1.3", - "@types/semver": "^7.3.9", + "@types/semver": "7.3.10", "@vitejs/plugin-react": "1.3.2", "chart.js": "3.8.0", "chartjs-adapter-date-fns": "2.0.0", diff --git a/frontend/yarn.lock b/frontend/yarn.lock index fd77c986ba..4bd4d5059a 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1955,10 +1955,10 @@ resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== -"@types/semver@^7.3.9": - version "7.3.9" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.9.tgz#152c6c20a7688c30b967ec1841d31ace569863fc" - integrity sha512-L/TMpyURfBkf+o/526Zb6kd/tchUP3iBDEPjqjb+U2MAJhVRxxrmr2fwpe08E7QsV7YLcpq0tUaQ9O9x97ZIxQ== +"@types/semver@7.3.10": + version "7.3.10" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.10.tgz#5f19ee40cbeff87d916eedc8c2bfe2305d957f73" + integrity sha512-zsv3fsC7S84NN6nPK06u79oWgrPVd0NvOyqgghV1haPaFcVxIrP4DLomRwGAXk0ui4HZA7mOcSFL98sMVW9viw== "@types/set-cookie-parser@^2.4.0": version "2.4.2" From 69171a75a74f150408485cc35a90d38b1fce79ba Mon Sep 17 00:00:00 2001 From: olav Date: Fri, 17 Jun 2022 11:27:54 +0200 Subject: [PATCH 08/36] refactor: improve button label markup (#1091) * refactor: improve button label markup * refactor: remove misused tooltip roles * refactor: simplify FeatureStrategyIcon labelling * refactor: simplify labels for disabled buttons * refactor: add missing switch input labels --- .../component/common/HelpIcon/HelpIcon.tsx | 1 - .../PermissionButton/PermissionButton.tsx | 2 +- .../PermissionIconButton.tsx | 2 +- .../cells/FeatureSeenCell/FeatureSeenCell.tsx | 1 - .../EnvironmentActionCell.tsx | 22 ++++---- .../FeatureStrategyIcon.tsx | 6 +-- .../FeatureStrategyMenu.tsx | 2 +- .../StrategyDeleteButton.tsx | 7 ++- .../StrategyEditButton/StrategyEditButton.tsx | 51 ++++++++++--------- .../StrategySwitch/StrategySwitch.tsx | 3 +- .../__snapshots__/TagTypeList.test.tsx.snap | 12 +---- 11 files changed, 53 insertions(+), 56 deletions(-) diff --git a/frontend/src/component/common/HelpIcon/HelpIcon.tsx b/frontend/src/component/common/HelpIcon/HelpIcon.tsx index a3da995f80..502be077c5 100644 --- a/frontend/src/component/common/HelpIcon/HelpIcon.tsx +++ b/frontend/src/component/common/HelpIcon/HelpIcon.tsx @@ -17,7 +17,6 @@ export const HelpIcon = ({ tooltip, style }: IHelpIconProps) => { className={styles.container} style={style} tabIndex={0} - role="tooltip" aria-label="Help" > diff --git a/frontend/src/component/common/PermissionButton/PermissionButton.tsx b/frontend/src/component/common/PermissionButton/PermissionButton.tsx index 4e2b03ddb5..0882d40a7b 100644 --- a/frontend/src/component/common/PermissionButton/PermissionButton.tsx +++ b/frontend/src/component/common/PermissionButton/PermissionButton.tsx @@ -72,7 +72,7 @@ const PermissionButton: React.FC = ({