@vtex/faststore-plugin-buyer-portal 2.0.36 → 2.0.38
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/src/features/org-units/components/OrgUnitDetailsNavbar/OrgUnitDetailsNavbar.tsx +7 -10
- package/src/features/shared/utils/constants.ts +1 -1
- package/src/features/users/layouts/UsersLayout/UsersLayout.tsx +40 -2
- package/src/features/users/layouts/UsersLayout/users-layout.scss +10 -0
- package/src/pages/users.tsx +22 -3
package/package.json
CHANGED
|
@@ -14,16 +14,6 @@ import {
|
|
|
14
14
|
Tooltip,
|
|
15
15
|
} from "@faststore/ui";
|
|
16
16
|
|
|
17
|
-
const LocalizationIconButtonTrigger = dynamic(
|
|
18
|
-
() =>
|
|
19
|
-
// @ts-expect-error TS2835: tsc (node16) wants a ".js" suffix, which the
|
|
20
|
-
// host store's bundler can't resolve.
|
|
21
|
-
import("./LocalizationIconButtonTrigger").then(
|
|
22
|
-
(m) => m.LocalizationIconButtonTrigger
|
|
23
|
-
),
|
|
24
|
-
{ ssr: false }
|
|
25
|
-
);
|
|
26
|
-
|
|
27
17
|
import { ProfileSummary } from "../../../profile/components";
|
|
28
18
|
import { BasicDropdownMenu, Icon } from "../../../shared/components";
|
|
29
19
|
import { useBuyerPortal, useDrawerProps } from "../../../shared/hooks";
|
|
@@ -40,8 +30,15 @@ import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
|
40
30
|
import { useOrgUnitByUser } from "../../hooks";
|
|
41
31
|
import { OrgUnitHeaderNav } from "../OrgUnitHeaderNav/OrgUnitHeaderNav";
|
|
42
32
|
|
|
33
|
+
import { LocalizationIconButtonTrigger as LocalizationIconButtonTriggerComponent } from "./LocalizationIconButtonTrigger";
|
|
34
|
+
|
|
43
35
|
import type { SumaSidebarVariant } from "../../../shared/layouts/SumaPageLayout/sumaSidebarConfig";
|
|
44
36
|
|
|
37
|
+
const LocalizationIconButtonTrigger = dynamic(
|
|
38
|
+
() => Promise.resolve(LocalizationIconButtonTriggerComponent),
|
|
39
|
+
{ ssr: false }
|
|
40
|
+
);
|
|
41
|
+
|
|
45
42
|
export type OrgUnitDetailsNavbarProps = {
|
|
46
43
|
orgId: string;
|
|
47
44
|
contractId?: string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { Tooltip } from "@faststore/ui";
|
|
3
|
+
import { IconButton, Tooltip } from "@faststore/ui";
|
|
4
4
|
|
|
5
|
+
import { AuthSetupDrawer } from "../../../org-units/components";
|
|
5
6
|
import { RoleData } from "../../../roles/types";
|
|
6
7
|
import {
|
|
7
8
|
InternalSearch,
|
|
8
9
|
HeaderInside,
|
|
10
|
+
Icon,
|
|
9
11
|
Tag,
|
|
10
12
|
Paginator,
|
|
11
13
|
} from "../../../shared/components";
|
|
@@ -24,8 +26,13 @@ import { buyerPortalRoutes } from "../../../shared/utils/buyerPortalRoutes";
|
|
|
24
26
|
import { CreateUserDrawerSelector } from "../../components";
|
|
25
27
|
import { UserDropdownMenu } from "../../components/UserDropdownMenu/UserDropdownMenu";
|
|
26
28
|
|
|
29
|
+
import type { OrgUnitSettings } from "../../../org-units/types";
|
|
27
30
|
import type { UserData } from "../../types";
|
|
28
31
|
|
|
32
|
+
// The Settings glyph spans 20 of its 24-unit viewBox, so 24px matches the
|
|
33
|
+
// 20px glyphs of the header's account and localization icons.
|
|
34
|
+
const SETTINGS_ICON_SIZE = 24;
|
|
35
|
+
|
|
29
36
|
export type UsersLayoutProps = {
|
|
30
37
|
data: {
|
|
31
38
|
users: UserData[];
|
|
@@ -33,11 +40,12 @@ export type UsersLayoutProps = {
|
|
|
33
40
|
search: string;
|
|
34
41
|
page: number;
|
|
35
42
|
rolesOptions: RoleData[];
|
|
43
|
+
settings?: OrgUnitSettings | null;
|
|
36
44
|
};
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
export const UsersLayout = ({
|
|
40
|
-
data: { users, search, total, page, rolesOptions },
|
|
48
|
+
data: { users, search, total, page, rolesOptions, settings },
|
|
41
49
|
}: UsersLayoutProps) => {
|
|
42
50
|
const [totalUsers, setTotalUsers] = useState(total);
|
|
43
51
|
const { isLoading, items, increasePage, searchTerm, setSearchTerm } =
|
|
@@ -55,6 +63,11 @@ export const UsersLayout = ({
|
|
|
55
63
|
isOpen: isCreateUserDrawerOpen,
|
|
56
64
|
...createUserDrawerProps
|
|
57
65
|
} = useDrawerProps();
|
|
66
|
+
const {
|
|
67
|
+
open: openAuthSetupDrawer,
|
|
68
|
+
isOpen: isAuthSetupDrawerOpen,
|
|
69
|
+
...authSetupDrawerProps
|
|
70
|
+
} = useDrawerProps();
|
|
58
71
|
|
|
59
72
|
const columns = getTableColumns({
|
|
60
73
|
actionsLength: 1,
|
|
@@ -119,6 +132,21 @@ export const UsersLayout = ({
|
|
|
119
132
|
const usersSection = (
|
|
120
133
|
<section data-fs-users-section>
|
|
121
134
|
<HeaderInside title={t("shared.labels.users")}>
|
|
135
|
+
{settings && (
|
|
136
|
+
<IconButton
|
|
137
|
+
data-fs-bp-users-auth-setup-button
|
|
138
|
+
aria-label={t("orgUnitDetails.dropdown.authentication")}
|
|
139
|
+
onClick={openAuthSetupDrawer}
|
|
140
|
+
icon={
|
|
141
|
+
<Icon
|
|
142
|
+
name="Settings"
|
|
143
|
+
width={SETTINGS_ICON_SIZE}
|
|
144
|
+
height={SETTINGS_ICON_SIZE}
|
|
145
|
+
weight="regular"
|
|
146
|
+
/>
|
|
147
|
+
}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
122
150
|
<HeaderInside.Button onClick={openCreateUserDrawer} />
|
|
123
151
|
</HeaderInside>
|
|
124
152
|
|
|
@@ -203,6 +231,16 @@ export const UsersLayout = ({
|
|
|
203
231
|
{...createUserDrawerProps}
|
|
204
232
|
/>
|
|
205
233
|
)}
|
|
234
|
+
|
|
235
|
+
{settings && currentOrgUnit && isAuthSetupDrawerOpen && (
|
|
236
|
+
<AuthSetupDrawer
|
|
237
|
+
id={currentOrgUnit.id}
|
|
238
|
+
name={currentOrgUnit.name}
|
|
239
|
+
settings={settings}
|
|
240
|
+
{...authSetupDrawerProps}
|
|
241
|
+
isOpen={isAuthSetupDrawerOpen}
|
|
242
|
+
/>
|
|
243
|
+
)}
|
|
206
244
|
</section>
|
|
207
245
|
);
|
|
208
246
|
|
|
@@ -20,6 +20,16 @@
|
|
|
20
20
|
|
|
21
21
|
--data-fs-users-table-width: 11.875rem;
|
|
22
22
|
|
|
23
|
+
// Same box and states as the header's account and localization triggers.
|
|
24
|
+
[data-fs-bp-users-auth-setup-button] {
|
|
25
|
+
--fs-button-height: var(--fs-bp-spacing-9);
|
|
26
|
+
--fs-button-border-radius: var(--fs-bp-border-radius-full);
|
|
27
|
+
--fs-button-tertiary-text-color: var(--fs-bp-color-neutral-8);
|
|
28
|
+
--fs-button-tertiary-text-color-active: var(--fs-bp-color-neutral-8);
|
|
29
|
+
--fs-button-tertiary-bkg-color-hover: var(--fs-bp-color-transparent-0);
|
|
30
|
+
--fs-button-tertiary-bkg-color-active: var(--fs-bp-color-transparent-1);
|
|
31
|
+
}
|
|
32
|
+
|
|
23
33
|
@include u.media("<=phonemid") {
|
|
24
34
|
padding-bottom: var(--fs-spacing-7);
|
|
25
35
|
|
package/src/pages/users.tsx
CHANGED
|
@@ -2,7 +2,10 @@ import {
|
|
|
2
2
|
getContractDetailsService,
|
|
3
3
|
resolveAttachedContractService,
|
|
4
4
|
} from "../features/contracts/services";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getOrgUnitBasicDataService,
|
|
7
|
+
getOrgUnitSettingsService,
|
|
8
|
+
} from "../features/org-units/services";
|
|
6
9
|
import { getRolesIdsService } from "../features/roles/services";
|
|
7
10
|
import { RoleData } from "../features/roles/types";
|
|
8
11
|
import { withErrorBoundary } from "../features/shared/components";
|
|
@@ -24,7 +27,10 @@ import {
|
|
|
24
27
|
} from "../features/users/services";
|
|
25
28
|
|
|
26
29
|
import type { ContractData } from "../features/contracts/types";
|
|
27
|
-
import type {
|
|
30
|
+
import type {
|
|
31
|
+
OrgUnitBasicData,
|
|
32
|
+
OrgUnitSettings,
|
|
33
|
+
} from "../features/org-units/types";
|
|
28
34
|
import type { LabelMap } from "../features/shared/localization/types";
|
|
29
35
|
import type { AuthRouteProps, LoaderData } from "../features/shared/types";
|
|
30
36
|
import type {
|
|
@@ -39,6 +45,7 @@ export type UsersPageData = {
|
|
|
39
45
|
search: string;
|
|
40
46
|
page: number;
|
|
41
47
|
rolesOptions: RoleData[];
|
|
48
|
+
settings: OrgUnitSettings | null;
|
|
42
49
|
};
|
|
43
50
|
context: {
|
|
44
51
|
clientContext: ClientContext;
|
|
@@ -76,7 +83,11 @@ const loaderFunction = async (
|
|
|
76
83
|
const validPage = getValidPage(page);
|
|
77
84
|
|
|
78
85
|
const localizationLabels = await getLocalizationLabelsService({
|
|
79
|
-
|
|
86
|
+
// The Authentication drawer's labels live in the orgUnits entry.
|
|
87
|
+
entryIds: [
|
|
88
|
+
LOCALIZATION_ENTRY_IDS.users,
|
|
89
|
+
LOCALIZATION_ENTRY_IDS.orgUnits,
|
|
90
|
+
],
|
|
80
91
|
locale: data.locale,
|
|
81
92
|
});
|
|
82
93
|
|
|
@@ -88,6 +99,7 @@ const loaderFunction = async (
|
|
|
88
99
|
search: "",
|
|
89
100
|
page: 1,
|
|
90
101
|
rolesOptions: [],
|
|
102
|
+
settings: null,
|
|
91
103
|
},
|
|
92
104
|
context: {
|
|
93
105
|
clientContext: { cookie, userId, customerId, ...clientContext },
|
|
@@ -128,6 +140,7 @@ const loaderFunction = async (
|
|
|
128
140
|
user,
|
|
129
141
|
rolesOptions,
|
|
130
142
|
currentContract,
|
|
143
|
+
settings,
|
|
131
144
|
] = await Promise.all([
|
|
132
145
|
getOrgUnitBasicDataService({
|
|
133
146
|
id: orgUnitId,
|
|
@@ -146,6 +159,11 @@ const loaderFunction = async (
|
|
|
146
159
|
customerId,
|
|
147
160
|
}),
|
|
148
161
|
contractDetailsPromise,
|
|
162
|
+
// Only feeds the Authentication drawer; a failure hides its button
|
|
163
|
+
// instead of failing the whole listing.
|
|
164
|
+
getOrgUnitSettingsService({ unitId: orgUnitId, cookie }).catch(
|
|
165
|
+
() => null
|
|
166
|
+
),
|
|
149
167
|
]);
|
|
150
168
|
|
|
151
169
|
const { users, total } = usersResponse;
|
|
@@ -164,6 +182,7 @@ const loaderFunction = async (
|
|
|
164
182
|
search: search,
|
|
165
183
|
page: validPage,
|
|
166
184
|
rolesOptions,
|
|
185
|
+
settings,
|
|
167
186
|
},
|
|
168
187
|
context: {
|
|
169
188
|
clientContext: { cookie, userId, customerId, ...clientContext },
|