Skip to content

Commit 915bd58

Browse files
chore(vendor): update @lightbase/internal-management
_This PR is created by sync and will be force-pushed daily. Overwriting any manual changes done to this PR._ - chore: migrate to NPM (lightbasenl/frontend-components#94) (lightbasenl/frontend-components@b363957) - chore(deps): bump the minor-prod group with 7 updates (lightbasenl/frontend-components#88) (lightbasenl/frontend-components@14e2493) - feat(internal-management): FF support tenant specific settings (lightbasenl/frontend-components#82) (lightbasenl/frontend-components@adf918c) - chore(deps): bump the minor-prod group with 5 updates (lightbasenl/frontend-components#81) (lightbasenl/frontend-components@69e5fe9) - chore(deps): bump the minor-prod group with 9 updates (lightbasenl/frontend-components#71) (lightbasenl/frontend-components@7eb3791) - chore(deps): update dependencies (lightbasenl/frontend-components#57) (lightbasenl/frontend-components@0e10900) - chore(deps): update dependencies (lightbasenl/frontend-components#54) (lightbasenl/frontend-components@090296e) - chore(deps): update dependencies (lightbasenl/frontend-components#52) (lightbasenl/frontend-components@d4ae062) - chore(deps): update dependencies (lightbasenl/frontend-components#51) (lightbasenl/frontend-components@b4b0600) - chore(deps): update dependencies (lightbasenl/frontend-components#48) (lightbasenl/frontend-components@19c4df1) - chore: test internal-management against the app router (lightbasenl/frontend-components#50) (lightbasenl/frontend-components@290efe6) - chore(internal-management): make RQ5 compatible (lightbasenl/frontend-components#49) (lightbasenl/frontend-components@1998c93) - chore(deps): update dependencies (lightbasenl/frontend-components#46) (lightbasenl/frontend-components@29ce2d6) - chore(deps): update dependencies (lightbasenl/frontend-components#44) (lightbasenl/frontend-components@4c3e680) - chore(deps): update dependencies (lightbasenl/frontend-components#35) (lightbasenl/frontend-components@d3f1651) - chore(deps): update dependencies (lightbasenl/frontend-components#34) (lightbasenl/frontend-components@ae456c4) - chore(deps): update dependencies (lightbasenl/frontend-components#32) (lightbasenl/frontend-components@c7b2f12) - chore(deps): update dependencies (lightbasenl/frontend-components#31) (lightbasenl/frontend-components@3ede89c) - chore(deps): update dependencies (lightbasenl/frontend-components#29) (lightbasenl/frontend-components@3e756c8) - chore(deps): update dependencies (lightbasenl/frontend-components#28) (lightbasenl/frontend-components@15a6b9b) - chore: update api spec & regenerate (lightbasenl/frontend-components#26) (lightbasenl/frontend-components@eb1193e) - chore(deps): update dependencies (lightbasenl/frontend-components#25) (lightbasenl/frontend-components@57ebe6b)- Failed to execute `npm run format`. Sync is not able to correct this, so human checks and fixes are necessary for this PR.
1 parent 039d225 commit 915bd58

18 files changed

+718
-245
lines changed

vendor/internal-management/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ Props:
1616
- `tenantOrigin`: optional tenant origin, to send to tenant aware backends.
1717

1818
```tsx
19-
// In pages/_tenants/[tenant]/_lightbase/[...management].tsx
19+
// In pages/_tenants/[tenant]/_lightbase/[[...management]].tsx
20+
// Or in app/%5Flightbase/[[...management]]/page.tsx
21+
// ^ _ directories are not turned in to routes by default
22+
23+
"use client";
2024

2125
import { InternalManagement } from "@lightbase/internal-management";
2226

vendor/internal-management/package.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
"main": "./src/index.tsx",
66
"dependencies": {
77
"@emotion/hash": "^0.9.1",
8-
"@emotion/react": "11.11.0",
9-
"@headlessui/react": "1.7.14",
10-
"@tanstack/react-query": "4.29.5",
11-
"axios": "1.4.0",
12-
"jwt-decode": "3.1.2",
8+
"@emotion/react": "11.11.3",
9+
"@headlessui/react": "1.7.17",
10+
"axios": "1.6.5",
11+
"jwt-decode": "4.0.0",
1312
"nookies": "^2.5.2",
14-
"react-hook-form": "7.43.9",
15-
"react-router-dom": "6.11.1",
13+
"react-hook-form": "7.49.2",
14+
"react-router-dom": "6.21.1",
1615
"twind": "0.16.19"
1716
},
17+
"peerDependencies": {
18+
"@tanstack/react-query": "*"
19+
},
1820
"files": [
1921
"README.md",
2022
"src"
2123
],
22-
"gitHead": "4dcfe0922a124f2c944f6dc24411c73dcdc2819b"
24+
"gitHead": "4410a3e0201f455092576429e5e95e6ae20990b6"
2325
}

vendor/internal-management/src/auth/cookies.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import jwtDecode from "jwt-decode";
1+
import { jwtDecode } from "jwt-decode";
22
import { destroyCookie, parseCookies, setCookie } from "nookies";
33
import type { AuthTokenPair } from "../generated/common/types";
44

vendor/internal-management/src/components/Button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const sizes = {
99

1010
const variants = {
1111
primary: "border-transparent text-white bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",
12-
default: "bg-gray-50",
12+
default: "bg-gray-50 hover:bg-gray-100",
1313
};
1414

1515
export type ButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {

vendor/internal-management/src/components/EditFeatureFlagModal.tsx vendor/internal-management/src/components/EditDescriptionFFModal.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Transition, Dialog, Portal } from "@headlessui/react";
1+
import { Dialog, Portal, Transition } from "@headlessui/react";
22
import { Fragment } from "react";
33
import { useForm } from "react-hook-form";
44
import { tw } from "twind";
55
import Button from "../components/Button";
66
import type { ManagementFeatureFlagItem } from "../generated/common/types";
77
import { useManagementFeatureFlagUpdate } from "../generated/managementFeatureFlag/reactQueries";
88

9-
export default function EditFeatureFlagModal({
9+
export default function EditDescriptionFFModal({
1010
show,
1111
onClose,
1212
flag,
@@ -15,7 +15,7 @@ export default function EditFeatureFlagModal({
1515
onClose: () => void;
1616
flag: ManagementFeatureFlagItem;
1717
}) {
18-
const { mutate, isLoading, error } = useManagementFeatureFlagUpdate(
18+
const { mutate, status, error } = useManagementFeatureFlagUpdate(
1919
{
2020
onSuccess: () => {
2121
onClose();
@@ -61,12 +61,13 @@ export default function EditFeatureFlagModal({
6161
>
6262
<Dialog.Panel
6363
as="form"
64-
data-testid="FeatureFlag.modal"
64+
data-testid="DescriptionFeatureFlag.modal"
6565
onSubmit={handleSubmit(({ description }) => {
6666
mutate({
6767
featureFlagId: flag.id,
6868
description,
6969
globalValue: flag.globalValue,
70+
tenantValues: flag.tenantValues,
7071
});
7172
})}
7273
className={tw`relative w-full transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:max-w-lg`}
@@ -111,10 +112,17 @@ export default function EditFeatureFlagModal({
111112
</div>
112113
</div>
113114
<div className={tw`border-t px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6`}>
114-
<Button data-testid="FeatureFlag.modal.submit" type="submit" isLoading={isLoading}>
115+
<Button
116+
data-testid="DescriptionFeatureFlag.modal.submit"
117+
type="submit"
118+
isLoading={
119+
// Compatible between RQ4 & RQ5
120+
["loading", "pending"].includes(status as string)
121+
}
122+
>
115123
Save
116124
</Button>
117-
<Button variant="default" className="ml-2 lg:ml-0 lg:mr-2" onClick={onClose}>
125+
<Button variant="default" className={tw`ml-2 lg:ml-0 lg:mr-2`} onClick={onClose}>
118126
Cancel
119127
</Button>
120128
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
import { Dialog, Portal, Transition } from "@headlessui/react";
2+
import { Fragment, useState } from "react";
3+
import { tw } from "twind";
4+
import Button from "../components/Button";
5+
import type { ManagementFeatureFlagItem } from "../generated/common/types";
6+
import { useManagementFeatureFlagUpdate } from "../generated/managementFeatureFlag/reactQueries";
7+
8+
export default function EditTenantSettingsFFModal({
9+
show,
10+
onClose,
11+
flag,
12+
tenants,
13+
}: {
14+
show: boolean;
15+
onClose: () => void;
16+
flag: ManagementFeatureFlagItem;
17+
tenants: string[];
18+
}) {
19+
const { mutate, status, error } = useManagementFeatureFlagUpdate(
20+
{
21+
onSuccess: () => {
22+
onClose();
23+
},
24+
},
25+
{ invalidateQueries: true },
26+
);
27+
28+
const [tenantValues, setTenantValues] = useState({
29+
...(flag.tenantValues ?? {}),
30+
});
31+
32+
return (
33+
<Portal>
34+
<Transition.Root show={show} as={Fragment}>
35+
<Dialog as="div" className={tw`relative z-10`} onClose={onClose}>
36+
<Transition.Child
37+
as={Fragment}
38+
enter={tw`ease-out duration-300`}
39+
enterFrom={tw`opacity-0`}
40+
enterTo={tw`opacity-100`}
41+
leave={tw`ease-in duration-200`}
42+
leaveFrom={tw`opacity-100`}
43+
leaveTo={tw`opacity-0`}
44+
>
45+
<div className={tw`fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity`} />
46+
</Transition.Child>
47+
48+
<div className={tw`fixed inset-0 z-10 overflow-y-auto`}>
49+
<div
50+
className={tw`flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0`}
51+
>
52+
<Transition.Child
53+
as={Fragment}
54+
enter={tw`ease-out duration-300`}
55+
enterFrom={tw`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`}
56+
enterTo={tw`opacity-100 translate-y-0 sm:scale-100`}
57+
leave={tw`ease-in duration-200`}
58+
leaveFrom={tw`opacity-100 translate-y-0 sm:scale-100`}
59+
leaveTo={tw`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`}
60+
>
61+
<Dialog.Panel
62+
as="form"
63+
data-testid="TenantSettingsFeatureFlag.modal"
64+
onSubmit={e => {
65+
e.preventDefault();
66+
mutate({
67+
featureFlagId: flag.id,
68+
tenantValues,
69+
globalValue: flag.globalValue,
70+
description: flag.description,
71+
});
72+
}}
73+
className={tw`relative w-full transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 sm:max-w-lg`}
74+
>
75+
<div className={tw`bg-white`}>
76+
<div className={tw`border-b bg-white p-4 shadow-sm`}>
77+
<Dialog.Title className={tw`font-medium`}>Edit feature flag</Dialog.Title>
78+
</div>
79+
<div className={tw`p-4 sm:p-6`}>
80+
<div className={tw`space-y-4`}>
81+
{tenants.map((tenant, index) => (
82+
<div key={`${flag.name}-${index}`} className={tw`group space-y-1`}>
83+
<h3 className={tw`mb-2 font-semibold text-sm text-gray-900`}>{tenant}</h3>
84+
<ul
85+
className={tw`items-center w-full text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg sm:flex`}
86+
>
87+
<li className={tw`w-full border-b border-gray-200 sm:border-b-0 sm:border-r`}>
88+
<div className={tw`flex items-center pl-3`}>
89+
<input
90+
id={`list-radio-${tenant}-${index}-global-value`}
91+
type="radio"
92+
name={`list-radio-${tenant}-${index}-global-value`}
93+
checked={!tenantValues.hasOwnProperty(tenant)}
94+
onClick={() => {
95+
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
96+
const { [tenant]: remove, ...rest } = tenantValues;
97+
setTenantValues(rest);
98+
}}
99+
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300`}
100+
/>
101+
<label
102+
htmlFor={`list-radio-${tenant}-${index}-global-value`}
103+
className={tw`w-full py-3 ml-2 text-sm font-medium text-gray-900 select-none`}
104+
>
105+
Global value
106+
</label>
107+
</div>
108+
</li>
109+
<li className={tw`w-full border-b border-gray-200 sm:border-b-0 sm:border-r`}>
110+
<div className={tw`flex items-center pl-3`}>
111+
<input
112+
id={`list-radio-${tenant}-${index}-enabled`}
113+
type="radio"
114+
name={`list-radio-${tenant}-${index}-enabled`}
115+
checked={tenantValues.hasOwnProperty(tenant) && tenantValues[tenant]}
116+
onClick={() => setTenantValues({ ...tenantValues, [tenant]: true })}
117+
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300`}
118+
/>
119+
<label
120+
htmlFor={`list-radio-${tenant}-${index}-enabled`}
121+
className={tw`w-full py-3 ml-2 text-sm font-medium text-gray-900 select-none`}
122+
>
123+
Enabled
124+
</label>
125+
</div>
126+
</li>
127+
<li className={tw`w-full border-b border-gray-200 sm:border-b-0`}>
128+
<div className={tw`flex items-center pl-3`}>
129+
<input
130+
id={`list-radio-${tenant}-${index}-disabled`}
131+
type="radio"
132+
name={`list-radio-${tenant}-${index}-disabled`}
133+
checked={tenantValues.hasOwnProperty(tenant) && !tenantValues[tenant]}
134+
onClick={() => setTenantValues({ ...tenantValues, [tenant]: false })}
135+
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300`}
136+
/>
137+
<label
138+
htmlFor={`list-radio-${tenant}-${index}-disabled`}
139+
className={tw`w-full py-3 ml-2 text-sm font-medium text-gray-900 select-none`}
140+
>
141+
Disabled
142+
</label>
143+
</div>
144+
</li>
145+
</ul>
146+
</div>
147+
))}
148+
{!!error && (
149+
<div className={tw`rounded-md bg-red-50`}>
150+
<p className={tw`p-4 text-sm font-medium text-red-800`} role="alert">
151+
Something went wrong
152+
</p>
153+
{!!error.response?.data && (
154+
<div
155+
className={tw`max-h-[100px] overflow-y-auto p-4 shadow-inner`}
156+
aria-hidden="true"
157+
>
158+
<pre className={tw`whitespace-pre-line text-sm text-red-800`}>
159+
{JSON.stringify(error.response.data)}
160+
</pre>
161+
</div>
162+
)}
163+
</div>
164+
)}
165+
</div>
166+
</div>
167+
</div>
168+
<div className={tw`border-t px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6`}>
169+
<Button
170+
data-testid="TenantSettingsFeatureFlag.modal.submit"
171+
type="submit"
172+
isLoading={
173+
// Compatible between RQ4 & RQ5
174+
["loading", "pending"].includes(status as string)
175+
}
176+
>
177+
Save
178+
</Button>
179+
<Button
180+
variant="default"
181+
className={tw`ml-2 lg:ml-0 lg:mr-2`}
182+
onClick={() => {
183+
onClose();
184+
}}
185+
>
186+
Cancel
187+
</Button>
188+
</div>
189+
</Dialog.Panel>
190+
</Transition.Child>
191+
</div>
192+
</div>
193+
</Dialog>
194+
</Transition.Root>
195+
</Portal>
196+
);
197+
}

vendor/internal-management/src/components/Router.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FeatureFlags } from "../pages/FeatureFlags";
44
import { Login } from "../pages/Login";
55
import { TokenAuth } from "../pages/TokenAuth";
66

7-
export function Router() {
7+
export function Router({ tenants }: { tenants?: string[] }) {
88
const [isMounted, setIsMounted] = useState(false);
99

1010
useEffect(() => {
@@ -19,7 +19,7 @@ export function Router() {
1919
[
2020
{
2121
path: "/",
22-
element: <FeatureFlags />,
22+
element: <FeatureFlags tenants={tenants} />,
2323
errorElement: <ErrorBoundary />,
2424
},
2525
{

vendor/internal-management/src/components/SideBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export default function SideBar() {
1010
to="/"
1111
className={({ isActive }) =>
1212
isActive
13-
? tw`block bg-[#f1f1f1] py-3 px-6 text-sm font-medium text-gray-800`
14-
: tw`block py-3 px-6 text-sm font-medium text-gray-600 hover:text-gray-800`
13+
? tw`block bg-[#f1f1f1] px-6 py-3 text-sm font-medium text-gray-800`
14+
: tw`block px-6 py-3 text-sm font-medium text-gray-600 hover:text-gray-800`
1515
}
1616
>
1717
Feature flags

vendor/internal-management/src/generated/auth/apiClient.ts

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)