@vtex/faststore-plugin-buyer-portal 2.0.48 → 2.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/buyer-portal-icons.svg +9 -0
- package/src/features/budgets/layouts/BudgetsDetailsLayout/BudgetsDetailsLayout.tsx +4 -9
- package/src/features/budgets/layouts/BudgetsLayout/BudgetsLayout.tsx +2 -9
- package/src/features/buying-policies/layouts/BuyingPoliciesLayout/BuyingPoliciesLayout.tsx +14 -31
- package/src/features/contracts/layouts/ContractListingLayout/ContractListingLayout.tsx +8 -1
- package/src/features/contracts/layouts/ContractListingLayout/ContractSettingsNav.tsx +39 -63
- package/src/features/contracts/layouts/ContractListingLayout/__tests__/utils.test.ts +51 -0
- package/src/features/contracts/layouts/ContractListingLayout/contract-listing-layout.scss +36 -9
- package/src/features/contracts/layouts/ContractListingLayout/utils.ts +53 -0
- package/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +4 -1
- package/src/features/org-units/layouts/OrgUnitsLayout/OrgUnitsLayout.tsx +2 -9
- package/src/features/roles/layout/RolesLayout/RolesLayout.tsx +2 -9
- package/src/features/shared/components/BasicDrawer/BasicDrawer.tsx +3 -2
- package/src/features/shared/components/BasicDrawer/BasicDrawerHeading.tsx +4 -1
- package/src/features/shared/hooks/index.ts +1 -0
- package/src/features/shared/hooks/useShellScrollReset.ts +27 -0
- package/src/features/shared/layouts/ContractTabsLayout/ContractTabsLayout.tsx +26 -65
- package/src/features/shared/layouts/FinanceTabsLayout/FinanceTabsLayout.tsx +4 -41
- package/src/features/shared/layouts/OrgUnitTabsLayout/OrgUnitTabLayout.tsx +4 -39
- package/src/features/shared/layouts/SumaPageLayout/SumaPageLayout.tsx +11 -5
- package/src/features/shared/layouts/SumaPageLayout/SumaSidebar.tsx +17 -8
- package/src/features/shared/layouts/SumaPageLayout/SumaSidebarDrawer.tsx +25 -1
- package/src/features/shared/layouts/SumaPageLayout/suma-sidebar-drawer.scss +133 -5
- package/src/features/shared/localization/__tests__/page-loader-entries.test.ts +2 -2
- package/src/features/shared/utils/__tests__/getSumaListingSidebarLinks.test.ts +30 -0
- package/src/features/shared/utils/__tests__/routeLayoutMapping.test.ts +21 -1
- package/src/features/shared/utils/constants.ts +1 -1
- package/src/features/shared/utils/getSumaListingSidebarLinks.ts +8 -1
- package/src/features/shared/utils/routeLayoutMapping.ts +17 -4
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +2 -9
- package/src/pages/contract-information.tsx +1 -1
- package/src/pages/contracts.tsx +30 -45
- package/src/pages/home.tsx +17 -25
- package/src/pages/org-unit-details.tsx +15 -102
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { useRouter } from "next/router";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The page shell scrolls its content section, not the window, so Next.js's
|
|
7
|
+
* scroll to the top on navigation doesn't reach it. Resets the section's
|
|
8
|
+
* scroll after every non-shallow route change, as Next.js does for the window.
|
|
9
|
+
*
|
|
10
|
+
* Returns a ref for the `[data-fs-bp-contract-listing-section]` element.
|
|
11
|
+
*/
|
|
12
|
+
export function useShellScrollReset<T extends HTMLElement = HTMLElement>() {
|
|
13
|
+
const sectionRef = useRef<T>(null);
|
|
14
|
+
const { events } = useRouter();
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const resetScroll = (_url: string, { shallow }: { shallow: boolean }) => {
|
|
18
|
+
if (!shallow) sectionRef.current?.scrollTo({ top: 0 });
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
events.on("routeChangeComplete", resetScroll);
|
|
22
|
+
|
|
23
|
+
return () => events.off("routeChangeComplete", resetScroll);
|
|
24
|
+
}, [events]);
|
|
25
|
+
|
|
26
|
+
return sectionRef;
|
|
27
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
import { DropdownItem } from "@faststore/ui";
|
|
4
|
-
|
|
5
3
|
import { OrgUnitDetailsNavbar } from "../../../org-units/components";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import {
|
|
5
|
+
useBuyerPortal,
|
|
6
|
+
useReloadOnBfcacheRestore,
|
|
7
|
+
useShellScrollReset,
|
|
8
|
+
} from "../../hooks";
|
|
11
9
|
import { SumaSidebar } from "../SumaPageLayout/SumaSidebar";
|
|
12
10
|
|
|
13
11
|
export type ContractTabsLayoutProps = {
|
|
@@ -21,15 +19,13 @@ export type ContractTabsLayoutProps = {
|
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
export const ContractTabsLayout = ({
|
|
24
|
-
pageName,
|
|
25
22
|
loading = false,
|
|
26
23
|
children,
|
|
27
24
|
orgUnitId,
|
|
28
25
|
contractId,
|
|
29
26
|
}: ContractTabsLayoutProps) => {
|
|
30
|
-
const { currentOrgUnit, currentUser, currentContract
|
|
31
|
-
|
|
32
|
-
const { t } = useLocalization();
|
|
27
|
+
const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
|
|
28
|
+
const sectionRef = useShellScrollReset();
|
|
33
29
|
|
|
34
30
|
useReloadOnBfcacheRestore();
|
|
35
31
|
|
|
@@ -40,70 +36,35 @@ export const ContractTabsLayout = ({
|
|
|
40
36
|
currentOrgUnit?.customerGroup.customerIds[0] ??
|
|
41
37
|
"";
|
|
42
38
|
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
<div data-fs-bp-contract-listing-page>
|
|
46
|
-
<OrgUnitDetailsNavbar
|
|
47
|
-
orgId={resolvedOrgUnitId}
|
|
48
|
-
contractId={resolvedContractId}
|
|
49
|
-
person={{
|
|
50
|
-
name: currentUser?.name ?? "",
|
|
51
|
-
email: currentUser?.email ?? "",
|
|
52
|
-
}}
|
|
53
|
-
loading={loading}
|
|
54
|
-
sidebarVariant="contract"
|
|
55
|
-
showBackLink
|
|
56
|
-
/>
|
|
57
|
-
<div data-fs-bp-contract-listing-body>
|
|
58
|
-
<SumaSidebar
|
|
59
|
-
orgUnitId={resolvedOrgUnitId}
|
|
60
|
-
contractId={resolvedContractId}
|
|
61
|
-
variant="contract"
|
|
62
|
-
showBackLink
|
|
63
|
-
loading={loading}
|
|
64
|
-
/>
|
|
65
|
-
<section data-fs-bp-contract-listing-section>{children}</section>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
39
|
+
if (!resolvedOrgUnitId) {
|
|
40
|
+
return <>{children}</>;
|
|
69
41
|
}
|
|
70
42
|
|
|
71
|
-
const verticalLinks = getContractSettingsLinks(
|
|
72
|
-
{
|
|
73
|
-
contractId: resolvedContractId,
|
|
74
|
-
orgUnitId: resolvedOrgUnitId,
|
|
75
|
-
},
|
|
76
|
-
t,
|
|
77
|
-
featureFlags
|
|
78
|
-
);
|
|
79
|
-
|
|
80
43
|
return (
|
|
81
|
-
<
|
|
82
|
-
<
|
|
44
|
+
<div data-fs-bp-contract-listing-page>
|
|
45
|
+
<OrgUnitDetailsNavbar
|
|
46
|
+
orgId={resolvedOrgUnitId}
|
|
83
47
|
contractId={resolvedContractId}
|
|
84
|
-
orgUnit={currentOrgUnit}
|
|
85
|
-
pageName={pageName}
|
|
86
48
|
person={{
|
|
87
49
|
name: currentUser?.name ?? "",
|
|
88
|
-
|
|
89
|
-
id: currentUser?.id ?? "",
|
|
50
|
+
email: currentUser?.email ?? "",
|
|
90
51
|
}}
|
|
91
52
|
loading={loading}
|
|
53
|
+
sidebarVariant="contract"
|
|
54
|
+
showBackLink
|
|
92
55
|
/>
|
|
93
|
-
<
|
|
94
|
-
<
|
|
56
|
+
<div data-fs-bp-contract-listing-body>
|
|
57
|
+
<SumaSidebar
|
|
58
|
+
orgUnitId={resolvedOrgUnitId}
|
|
59
|
+
contractId={resolvedContractId}
|
|
60
|
+
variant="contract"
|
|
61
|
+
showBackLink
|
|
95
62
|
loading={loading}
|
|
96
|
-
dropdownOptions={
|
|
97
|
-
<DropdownItem>
|
|
98
|
-
<Icon name="DoNotDisturbOn" width={20} height={20} />
|
|
99
|
-
{t("layouts.actions.removeFromUnit")}
|
|
100
|
-
</DropdownItem>
|
|
101
|
-
}
|
|
102
|
-
verticalLinks={verticalLinks}
|
|
103
|
-
name={currentContract?.name ?? ""}
|
|
104
63
|
/>
|
|
105
|
-
<
|
|
106
|
-
|
|
107
|
-
|
|
64
|
+
<section data-fs-bp-contract-listing-section ref={sectionRef}>
|
|
65
|
+
{children}
|
|
66
|
+
</section>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
108
69
|
);
|
|
109
70
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { useLocalization } from "../../localization/LocalizationContext";
|
|
5
|
-
import { getFinanceSettingsLinks } from "../../utils";
|
|
6
|
-
import { BaseTabsLayout } from "../BaseTabsLayout/BaseTabsLayout";
|
|
3
|
+
import { SumaPageLayout } from "../SumaPageLayout/SumaPageLayout";
|
|
7
4
|
|
|
8
5
|
export type FinanceTabsLayoutProps = {
|
|
9
6
|
pageName: string;
|
|
@@ -12,42 +9,8 @@ export type FinanceTabsLayoutProps = {
|
|
|
12
9
|
};
|
|
13
10
|
|
|
14
11
|
export const FinanceTabsLayout = ({
|
|
15
|
-
pageName,
|
|
16
12
|
children,
|
|
17
13
|
loading = false,
|
|
18
|
-
}: FinanceTabsLayoutProps) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const verticalLinks = getFinanceSettingsLinks(
|
|
23
|
-
{
|
|
24
|
-
contractId: currentContract?.id ?? "",
|
|
25
|
-
orgUnitId: currentOrgUnit?.id ?? "",
|
|
26
|
-
},
|
|
27
|
-
t
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<BaseTabsLayout data-fs-bp-finance-tabs-layout>
|
|
32
|
-
<BaseTabsLayout.Navbar
|
|
33
|
-
contractId={currentContract?.id ?? ""}
|
|
34
|
-
orgUnit={currentOrgUnit}
|
|
35
|
-
pageName={pageName}
|
|
36
|
-
person={{
|
|
37
|
-
name: currentUser?.name ?? "",
|
|
38
|
-
roles: currentUser?.roles ?? [],
|
|
39
|
-
id: currentUser?.id ?? "",
|
|
40
|
-
}}
|
|
41
|
-
loading={loading}
|
|
42
|
-
/>
|
|
43
|
-
<BaseTabsLayout.Container>
|
|
44
|
-
<BaseTabsLayout.SidebarMenu
|
|
45
|
-
verticalLinks={verticalLinks}
|
|
46
|
-
showLetterHighlight={false}
|
|
47
|
-
loading={loading}
|
|
48
|
-
/>
|
|
49
|
-
<BaseTabsLayout.Content>{children}</BaseTabsLayout.Content>
|
|
50
|
-
</BaseTabsLayout.Container>
|
|
51
|
-
</BaseTabsLayout>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
14
|
+
}: FinanceTabsLayoutProps) => (
|
|
15
|
+
<SumaPageLayout loading={loading}>{children}</SumaPageLayout>
|
|
16
|
+
);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { useLocalization } from "../../localization/LocalizationContext";
|
|
5
|
-
import { getOrganizationSettingsLinks } from "../../utils";
|
|
6
|
-
import { BaseTabsLayout } from "../BaseTabsLayout/BaseTabsLayout";
|
|
3
|
+
import { SumaPageLayout } from "../SumaPageLayout/SumaPageLayout";
|
|
7
4
|
|
|
8
5
|
export type OrgUnitTabsLayoutProps = {
|
|
9
6
|
pageName: string;
|
|
@@ -12,40 +9,8 @@ export type OrgUnitTabsLayoutProps = {
|
|
|
12
9
|
};
|
|
13
10
|
|
|
14
11
|
export const OrgUnitTabsLayout = ({
|
|
15
|
-
pageName,
|
|
16
12
|
children,
|
|
17
13
|
loading = false,
|
|
18
|
-
}: OrgUnitTabsLayoutProps) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const verticalLinks = getOrganizationSettingsLinks({
|
|
23
|
-
orgUnitId: currentOrgUnit?.id ?? "",
|
|
24
|
-
contractId: currentContract?.id ?? "",
|
|
25
|
-
t,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<BaseTabsLayout data-fs-bp-org-unit-tabs-layout>
|
|
30
|
-
<BaseTabsLayout.Navbar
|
|
31
|
-
contractId={currentContract?.id ?? ""}
|
|
32
|
-
orgUnit={currentOrgUnit}
|
|
33
|
-
pageName={pageName}
|
|
34
|
-
person={{
|
|
35
|
-
name: currentUser?.name ?? "",
|
|
36
|
-
roles: currentUser?.roles ?? [],
|
|
37
|
-
id: currentUser?.id ?? "",
|
|
38
|
-
}}
|
|
39
|
-
loading={loading}
|
|
40
|
-
/>
|
|
41
|
-
<BaseTabsLayout.Container>
|
|
42
|
-
<BaseTabsLayout.SidebarMenu
|
|
43
|
-
verticalLinks={verticalLinks}
|
|
44
|
-
showLetterHighlight={false}
|
|
45
|
-
loading={loading}
|
|
46
|
-
/>
|
|
47
|
-
<BaseTabsLayout.Content>{children}</BaseTabsLayout.Content>
|
|
48
|
-
</BaseTabsLayout.Container>
|
|
49
|
-
</BaseTabsLayout>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
14
|
+
}: OrgUnitTabsLayoutProps) => (
|
|
15
|
+
<SumaPageLayout loading={loading}>{children}</SumaPageLayout>
|
|
16
|
+
);
|
|
@@ -3,7 +3,11 @@ import type { ReactNode } from "react";
|
|
|
3
3
|
import { useRouter } from "next/router";
|
|
4
4
|
|
|
5
5
|
import { OrgUnitDetailsNavbar } from "../../../org-units/components";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useBuyerPortal,
|
|
8
|
+
useReloadOnBfcacheRestore,
|
|
9
|
+
useShellScrollReset,
|
|
10
|
+
} from "../../hooks";
|
|
7
11
|
import { resolveContractId } from "../../utils";
|
|
8
12
|
|
|
9
13
|
import { SumaSidebar } from "./SumaSidebar";
|
|
@@ -23,13 +27,13 @@ export const SumaPageLayout = ({
|
|
|
23
27
|
sidebarVariant = "unit",
|
|
24
28
|
showBackLink = true,
|
|
25
29
|
}: SumaPageLayoutProps) => {
|
|
26
|
-
const {
|
|
27
|
-
useBuyerPortal();
|
|
30
|
+
const { currentOrgUnit, currentUser, currentContract } = useBuyerPortal();
|
|
28
31
|
const router = useRouter();
|
|
32
|
+
const sectionRef = useShellScrollReset();
|
|
29
33
|
|
|
30
34
|
useReloadOnBfcacheRestore();
|
|
31
35
|
|
|
32
|
-
if (!
|
|
36
|
+
if (!currentOrgUnit?.id) {
|
|
33
37
|
return <>{children}</>;
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -60,7 +64,9 @@ export const SumaPageLayout = ({
|
|
|
60
64
|
showBackLink={showBackLink}
|
|
61
65
|
loading={loading}
|
|
62
66
|
/>
|
|
63
|
-
<section data-fs-bp-contract-listing-section
|
|
67
|
+
<section data-fs-bp-contract-listing-section ref={sectionRef}>
|
|
68
|
+
{children}
|
|
69
|
+
</section>
|
|
64
70
|
</div>
|
|
65
71
|
</div>
|
|
66
72
|
);
|
|
@@ -7,6 +7,7 @@ import { buyerPortalRoutes } from "../../utils/buyerPortalRoutes";
|
|
|
7
7
|
import { getSumaListingSidebarLinks } from "../../utils/getSumaListingSidebarLinks";
|
|
8
8
|
|
|
9
9
|
import { FullSidebarNav } from "./FullSidebarNav";
|
|
10
|
+
import { resolveOrgLinkContractId } from "./resolveOrgLinkContractId";
|
|
10
11
|
import { getSumaSidebarConfig } from "./sumaSidebarConfig";
|
|
11
12
|
|
|
12
13
|
import type { SumaSidebarVariant } from "./sumaSidebarConfig";
|
|
@@ -41,7 +42,7 @@ export const SumaSidebar = ({
|
|
|
41
42
|
data-fs-bp-contract-listing-sidebar
|
|
42
43
|
data-fs-bp-suma-sidebar-variant={variant}
|
|
43
44
|
>
|
|
44
|
-
{
|
|
45
|
+
{config.showBackLink && (
|
|
45
46
|
<Link
|
|
46
47
|
href={contractsUrl}
|
|
47
48
|
data-fs-bp-contract-listing-back-link
|
|
@@ -72,13 +73,21 @@ export const SumaSidebar = ({
|
|
|
72
73
|
|
|
73
74
|
{config.sections === null ? (
|
|
74
75
|
<VerticalNav.Menu>
|
|
75
|
-
{getSumaListingSidebarLinks(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
{getSumaListingSidebarLinks(
|
|
77
|
+
{
|
|
78
|
+
orgUnitId,
|
|
79
|
+
contractId,
|
|
80
|
+
organizationContractId: resolveOrgLinkContractId(
|
|
81
|
+
featureFlags?.suma,
|
|
82
|
+
contractId
|
|
83
|
+
),
|
|
84
|
+
},
|
|
85
|
+
t
|
|
86
|
+
).map((item) => (
|
|
87
|
+
<VerticalNav.Link key={item.link} link={item.link}>
|
|
88
|
+
{item.name}
|
|
89
|
+
</VerticalNav.Link>
|
|
90
|
+
))}
|
|
82
91
|
</VerticalNav.Menu>
|
|
83
92
|
) : (
|
|
84
93
|
<FullSidebarNav
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { TransitionEvent } from "react";
|
|
2
|
+
|
|
1
3
|
import storeConfig from "discovery.config";
|
|
2
4
|
|
|
3
5
|
import Link from "next/link";
|
|
4
6
|
|
|
5
|
-
import { BasicDrawer, type BasicDrawerProps } from "../../components";
|
|
7
|
+
import { BasicDrawer, Icon, type BasicDrawerProps } from "../../components";
|
|
8
|
+
import { useBuyerPortal } from "../../hooks";
|
|
6
9
|
|
|
7
10
|
import { SumaSidebar, type SumaSidebarProps } from "./SumaSidebar";
|
|
8
11
|
|
|
@@ -17,13 +20,25 @@ export const SumaSidebarDrawer = ({
|
|
|
17
20
|
variant,
|
|
18
21
|
showBackLink,
|
|
19
22
|
close,
|
|
23
|
+
onTransitionEnd,
|
|
20
24
|
...props
|
|
21
25
|
}: SumaSidebarDrawerProps) => {
|
|
26
|
+
const { currentOrgUnit } = useBuyerPortal();
|
|
27
|
+
|
|
28
|
+
// Only the drawer's own slide may unmount it. Transitions inside it, like
|
|
29
|
+
// the close button's hover, end first and would cut the slide short.
|
|
30
|
+
const handleTransitionEnd = (event: TransitionEvent<HTMLDivElement>) => {
|
|
31
|
+
if (event.target === event.currentTarget) {
|
|
32
|
+
onTransitionEnd(event);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
22
36
|
return (
|
|
23
37
|
<BasicDrawer
|
|
24
38
|
data-fs-bp-suma-sidebar-drawer
|
|
25
39
|
close={close}
|
|
26
40
|
{...props}
|
|
41
|
+
onTransitionEnd={handleTransitionEnd}
|
|
27
42
|
data-fs-slide-over-direction="leftSide"
|
|
28
43
|
data-fs-slide-over-sidebar
|
|
29
44
|
>
|
|
@@ -34,8 +49,17 @@ export const SumaSidebarDrawer = ({
|
|
|
34
49
|
</Link>
|
|
35
50
|
}
|
|
36
51
|
onClose={close}
|
|
52
|
+
closeIcon={<Icon name="CloseSymbol" width={20} height={20} />}
|
|
37
53
|
/>
|
|
38
54
|
<BasicDrawer.Body data-fs-bp-suma-sidebar-drawer-body>
|
|
55
|
+
{currentOrgUnit?.name && (
|
|
56
|
+
<div data-fs-bp-suma-sidebar-drawer-unit>
|
|
57
|
+
<Icon name="FilledFolder" width={20} height={20} />
|
|
58
|
+
<span data-fs-bp-suma-sidebar-drawer-unit-name>
|
|
59
|
+
{currentOrgUnit.name}
|
|
60
|
+
</span>
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
39
63
|
<SumaSidebar
|
|
40
64
|
orgUnitId={orgUnitId}
|
|
41
65
|
contractId={contractId}
|
|
@@ -1,17 +1,81 @@
|
|
|
1
1
|
@use "~@faststore/ui/src/styles/base/utilities" as u;
|
|
2
|
+
|
|
3
|
+
// Google Docs' side menu curve, with its 250ms made 30% longer for this wider
|
|
4
|
+
// drawer, as Material does for tablets. There are no motion tokens for it
|
|
5
|
+
// (`--fs-transition-timing` is 0.2s).
|
|
6
|
+
$suma-sidebar-drawer-duration: 325ms;
|
|
7
|
+
$suma-sidebar-drawer-easing: cubic-bezier(0.4, 0, 0.2, 1);
|
|
8
|
+
|
|
9
|
+
@keyframes suma-sidebar-drawer-in {
|
|
10
|
+
from {
|
|
11
|
+
transform: translateX(-100%);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The overlay's color fades with the drawer instead of popping in and out.
|
|
16
|
+
// The theme sets that color with `!important` inside this layer, so these
|
|
17
|
+
// rules join it with a higher specificity; transitions still run over
|
|
18
|
+
// `!important` values.
|
|
19
|
+
@layer theme {
|
|
20
|
+
[data-fs-overlay]:has([data-fs-bp-suma-sidebar-drawer][data-fs-slide-over]) {
|
|
21
|
+
transition: background-color $suma-sidebar-drawer-duration
|
|
22
|
+
$suma-sidebar-drawer-easing;
|
|
23
|
+
|
|
24
|
+
@starting-style {
|
|
25
|
+
background-color: transparent !important;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:has([data-fs-slide-over-state="out"]) {
|
|
29
|
+
background-color: transparent !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (prefers-reduced-motion: reduce) {
|
|
33
|
+
transition: none;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
2
38
|
[data-fs-bp-suma-sidebar-drawer] {
|
|
3
39
|
@import "../../components/BasicDrawer/basic-drawer.scss";
|
|
4
40
|
|
|
41
|
+
// Same height as the header that opens it; the padding stays at phone size
|
|
42
|
+
// because the drawer keeps its width at every breakpoint.
|
|
43
|
+
&[data-fs-bp-basic-drawer] [data-fs-bp-basic-drawer-heading] {
|
|
44
|
+
gap: var(--fs-bp-gap-1);
|
|
45
|
+
min-height: var(--fs-bp-spacing-12);
|
|
46
|
+
padding: var(--fs-bp-padding-0) var(--fs-bp-padding-5);
|
|
47
|
+
border-bottom-color: var(--fs-bp-color-neutral-2);
|
|
48
|
+
|
|
49
|
+
[data-fs-bp-basic-drawer-heading-title] {
|
|
50
|
+
&,
|
|
51
|
+
&:first-child {
|
|
52
|
+
padding-left: var(--fs-bp-padding-0);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Same box and states as the header's menu button.
|
|
57
|
+
[data-fs-bp-basic-drawer-heading-close-button] {
|
|
58
|
+
--fs-button-height: var(--fs-bp-spacing-9);
|
|
59
|
+
--fs-button-border-radius: var(--fs-bp-border-radius-full);
|
|
60
|
+
--fs-button-tertiary-text-color: var(--fs-bp-color-neutral-8);
|
|
61
|
+
--fs-button-tertiary-text-color-active: var(--fs-bp-color-neutral-8);
|
|
62
|
+
--fs-button-tertiary-bkg-color-hover: var(--fs-bp-color-transparent-0);
|
|
63
|
+
--fs-button-tertiary-bkg-color-active: var(--fs-bp-color-transparent-1);
|
|
64
|
+
|
|
65
|
+
svg {
|
|
66
|
+
color: var(--fs-bp-color-neutral-8);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
5
71
|
[data-fs-bp-org-unit-details-navbar-link] {
|
|
6
|
-
@include text-style('display-
|
|
72
|
+
@include text-style('display-6');
|
|
7
73
|
font-weight: var(--fs-bp-weight-bold);
|
|
74
|
+
letter-spacing: var(--fs-bp-letter-spacing-3);
|
|
8
75
|
color: var(--fs-bp-color-brand);
|
|
9
76
|
text-decoration: none;
|
|
77
|
+
// Lines the logo up with the menu items' text
|
|
10
78
|
margin-left: var(--fs-bp-margin-5);
|
|
11
|
-
|
|
12
|
-
@include u.media(">=tablet") {
|
|
13
|
-
margin: var(--fs-bp-margin-0);
|
|
14
|
-
}
|
|
15
79
|
}
|
|
16
80
|
|
|
17
81
|
&[data-fs-bp-basic-drawer][data-fs-slide-over-size] {
|
|
@@ -27,6 +91,70 @@
|
|
|
27
91
|
}
|
|
28
92
|
}
|
|
29
93
|
|
|
94
|
+
// The drawer mounts already "in", so it slides in with an animation and
|
|
95
|
+
// slides out with a transition, both with the same curve. The shadow
|
|
96
|
+
// separates it from the page and goes away as soon as it starts closing.
|
|
97
|
+
&[data-fs-bp-basic-drawer][data-fs-slide-over] {
|
|
98
|
+
--fs-slide-over-transition-timing: #{$suma-sidebar-drawer-duration};
|
|
99
|
+
|
|
100
|
+
box-shadow: 0 0 var(--fs-bp-spacing-4) var(--fs-bp-color-transparent-1);
|
|
101
|
+
animation: suma-sidebar-drawer-in var(--fs-slide-over-transition-timing)
|
|
102
|
+
$suma-sidebar-drawer-easing;
|
|
103
|
+
|
|
104
|
+
&[data-fs-slide-over-state="out"] {
|
|
105
|
+
box-shadow: none;
|
|
106
|
+
animation: none;
|
|
107
|
+
transform: translateX(-100%);
|
|
108
|
+
transition: transform var(--fs-slide-over-transition-timing)
|
|
109
|
+
$suma-sidebar-drawer-easing;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The exit still needs a transition: its end unmounts the drawer.
|
|
113
|
+
@media (prefers-reduced-motion: reduce) {
|
|
114
|
+
--fs-slide-over-transition-timing: 1ms;
|
|
115
|
+
|
|
116
|
+
animation: none;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Same padding as the desktop sidebar at every width, instead of the
|
|
121
|
+
// drawer body's form spacing.
|
|
122
|
+
&[data-fs-bp-basic-drawer]
|
|
123
|
+
[data-fs-bp-suma-sidebar-drawer-body]
|
|
124
|
+
[data-fs-bp-basic-drawer-body-wrapper] {
|
|
125
|
+
padding: var(--fs-bp-padding-5);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Mirrors the header's unit control, which the drawer covers.
|
|
129
|
+
[data-fs-bp-suma-sidebar-drawer-unit] {
|
|
130
|
+
display: flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
gap: var(--fs-bp-gap-2);
|
|
133
|
+
min-height: var(--fs-bp-spacing-9);
|
|
134
|
+
padding: var(--fs-bp-padding-0) var(--fs-bp-padding-5);
|
|
135
|
+
margin-bottom: var(--fs-bp-margin-5);
|
|
136
|
+
|
|
137
|
+
svg {
|
|
138
|
+
flex-shrink: 0;
|
|
139
|
+
color: var(--fs-bp-color-brand);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
[data-fs-bp-suma-sidebar-drawer-unit-name] {
|
|
144
|
+
@include text-style('action');
|
|
145
|
+
min-width: 0;
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
font-weight: var(--fs-bp-weight-medium);
|
|
148
|
+
color: var(--fs-bp-color-neutral-8);
|
|
149
|
+
text-overflow: ellipsis;
|
|
150
|
+
white-space: nowrap;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Phones need the vertical space; the contract name alone identifies it.
|
|
154
|
+
[data-fs-bp-suma-sidebar-identity] [data-fs-bp-letter-highlight] {
|
|
155
|
+
display: none;
|
|
156
|
+
}
|
|
157
|
+
|
|
30
158
|
// The sidebar is hidden below "notebook" so it can be toggled from the
|
|
31
159
|
// navbar; force it visible here since the drawer is only rendered while open.
|
|
32
160
|
[data-fs-bp-contract-listing-sidebar] {
|
|
@@ -31,13 +31,13 @@ const getRequestedEntries = (page: string): LocalizationFeature[] => {
|
|
|
31
31
|
// Components rendered by a page resolve `t("<feature>.…")` keys from the entries
|
|
32
32
|
// its loader requests. A shared component whose entry is not requested renders
|
|
33
33
|
// the raw key (B2BTEAM-4276, B2BTEAM-4277).
|
|
34
|
+
// `/org-unit/[orgUnitId]` only redirects to the contracts listing and renders
|
|
35
|
+
// nothing, so it no longer requests `users`. See specs/sidebar-unification.md.
|
|
34
36
|
const REQUIRED_ENTRIES: Record<string, LocalizationFeature[]> = {
|
|
35
37
|
// Sidebar → AccountingFieldDropdown, CreateAccountingFieldDrawer
|
|
36
38
|
profile: ["accountingFields"],
|
|
37
39
|
// OrgUnitsDropdownMenu → CreateUserDrawerSelector → CreateUserDrawer*
|
|
38
40
|
"org-units": ["users"],
|
|
39
|
-
// AddAllToOrgUnitDropdown → CreateUserDrawerSelector → CreateUserDrawer*
|
|
40
|
-
"org-unit-details": ["users"],
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
describe("page loaders request the localization entries their components use", () => {
|
|
@@ -41,3 +41,33 @@ describe("getSumaListingSidebarLinks (unit view)", () => {
|
|
|
41
41
|
).toBe("/pvt/organization-account/budgets/unit-1/contract-1");
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
|
+
|
|
45
|
+
describe("getSumaListingSidebarLinks (organizationContractId)", () => {
|
|
46
|
+
const links = getSumaListingSidebarLinks(
|
|
47
|
+
{
|
|
48
|
+
orgUnitId: "unit-1",
|
|
49
|
+
contractId: "contract-1",
|
|
50
|
+
organizationContractId: "contract-1",
|
|
51
|
+
},
|
|
52
|
+
t
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
it("adds the contractId to organization links when given", () => {
|
|
56
|
+
expect(links.find((l) => l.name === "layouts.navigation.users")?.link).toBe(
|
|
57
|
+
"/pvt/organization-account/users/unit-1?contractId=contract-1"
|
|
58
|
+
);
|
|
59
|
+
expect(
|
|
60
|
+
links.find((l) => l.name === "layouts.navigation.roles")?.link
|
|
61
|
+
).toContain("contractId=contract-1");
|
|
62
|
+
expect(
|
|
63
|
+
links.find((l) => l.name === "layouts.navigation.organizationalUnits")
|
|
64
|
+
?.link
|
|
65
|
+
).toContain("contractId=contract-1");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("keeps the Contracts link unit-scoped", () => {
|
|
69
|
+
expect(
|
|
70
|
+
links.find((l) => l.name === "layouts.navigation.contracts")?.link
|
|
71
|
+
).toBe("/pvt/organization-account/contracts/unit-1");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "../routeLayoutMapping";
|
|
7
7
|
|
|
8
8
|
describe("routeLayoutMapping", () => {
|
|
9
|
-
it("maps the
|
|
9
|
+
it("maps the contracts listing to its own loading layout", () => {
|
|
10
10
|
const config = getTabsLayoutConfigFromRoute(
|
|
11
11
|
"/pvt/organization-account/contracts/unit-1?removed=2"
|
|
12
12
|
);
|
|
@@ -17,6 +17,13 @@ describe("routeLayoutMapping", () => {
|
|
|
17
17
|
).toEqual({ orgUnitId: "unit-1" });
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
it("shows the contracts listing skeleton for a unit's home redirect", () => {
|
|
21
|
+
expect(
|
|
22
|
+
getTabsLayoutConfigFromRoute("/pvt/organization-account/org-unit/unit-1")
|
|
23
|
+
?.layout
|
|
24
|
+
).toBe("ContractListingLayout");
|
|
25
|
+
});
|
|
26
|
+
|
|
20
27
|
it("keeps contract pages on the contract tabs layout", () => {
|
|
21
28
|
expect(
|
|
22
29
|
getTabsLayoutConfigFromRoute(
|
|
@@ -25,6 +32,19 @@ describe("routeLayoutMapping", () => {
|
|
|
25
32
|
).toBe("ContractTabsLayout");
|
|
26
33
|
});
|
|
27
34
|
|
|
35
|
+
it.each([
|
|
36
|
+
["users/unit-1", "OrgUnitTabsLayout"],
|
|
37
|
+
["user/unit-1/user-1", "OrgUnitTabsLayout"],
|
|
38
|
+
["roles/unit-1/role-1", "OrgUnitTabsLayout"],
|
|
39
|
+
["budgets/unit-1/contract-1", "FinanceTabsLayout"],
|
|
40
|
+
["budgets/unit-1/contract-1/budget-1", "FinanceTabsLayout"],
|
|
41
|
+
["buying-policy/unit-1/contract-1/policy-1", "FinanceTabsLayout"],
|
|
42
|
+
])("keeps the unit page %s on a unit view layout", (path, layout) => {
|
|
43
|
+
expect(
|
|
44
|
+
getTabsLayoutConfigFromRoute(`/pvt/organization-account/${path}`)?.layout
|
|
45
|
+
).toBe(layout);
|
|
46
|
+
});
|
|
47
|
+
|
|
28
48
|
it("returns null for unmapped routes", () => {
|
|
29
49
|
expect(
|
|
30
50
|
getTabsLayoutConfigFromRoute("/pvt/organization-account/unknown")
|