Skip to content

Commit 6205d7b

Browse files
committed
Merge branch 'release-please--branches--main--components--toolbar' of github.com:launchdarkly/launchdarkly-toolbar into release-please--branches--main--components--toolbar
2 parents 7aad5ab + 3c5a62a commit 6205d7b

32 files changed

+1845
-1059
lines changed

.github/actions/ci/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ runs:
3838
VITE_LD_BASE_URL: https://app.launchdarkly.com
3939
VITE_LD_STREAM_URL: https://clientstream.launchdarkly.com
4040
VITE_LD_EVENTS_URL: https://events.launchdarkly.com
41+
VITE_LD_DEV_SERVER_URL: http://localhost:8765
42+
VITE_LD_DEV_SERVER_PROJECT_KEY: developer-toolbar-sandbox
4143

4244
- name: Run Unit Tests
4345
shell: bash
@@ -91,6 +93,8 @@ runs:
9193
VITE_LD_BASE_URL: https://app.launchdarkly.com
9294
VITE_LD_STREAM_URL: https://clientstream.launchdarkly.com
9395
VITE_LD_EVENTS_URL: https://events.launchdarkly.com
96+
VITE_LD_DEV_SERVER_URL: http://localhost:8765
97+
VITE_LD_DEV_SERVER_PROJECT_KEY: developer-toolbar-sandbox
9498

9599
- name: Upload Playwright Artifacts
96100
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"packages/toolbar": "1.0.3"
2+
"packages/toolbar": "1.1.0"
33
}

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ an easy and intuitive way to test local changes to the Developer Toolbar within
5757
application. To set up the Demo application + Developer Toolbar to use one of your LaunchDarkly projects, copy
5858
the values in `.env.example` into a `.env` (or `.env.local`) file, and replace `VITE_LD_CLIENT_SIDE_ID` with the
5959
LaunchDarkly Client-Side ID of the project/environment you would like to test against.
60-
The other values in `env.example` are most likely fine as-is.
60+
The other values in `env.example` are most likely fine as-is. If you are planning on developing features for/testing using
61+
a local dev-server, ensure you also update `VITE_LD_DEV_SERVER_URL` and `VITE_LD_DEV_SERVER_URL_PROJECT_KEY` to valid values.
6162

6263
## Toolbar Integration Modes
6364

@@ -196,7 +197,7 @@ The demo application is the best way to test your changes:
196197
**Testing Both Modes:**
197198

198199
- **SDK Mode**: Test flag overrides, event interception, and real-time updates
199-
- **Dev Server Mode**: Test dev server connection, flag browsing, and CLI integration
200+
- **Dev Server Mode**: Test dev server connection, flag browsing + overrides (via the dev server), and CLI integration
200201

201202
## Testing
202203

e2e/tests/sdk-mode.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ test.describe('LaunchDarkly Toolbar - SDK Mode', () => {
110110

111111
// JSON flag override
112112
await page.getByTestId('flag-control-json-object-flag').getByRole('button', { name: 'Edit' }).click();
113-
const jsonInput = page.getByTestId('flag-input-json-object-flag');
113+
const jsonInput = page.getByTestId('json-editor-json-object-flag').getByRole('textbox');
114114
const customJson = '{"environment": "test", "feature": "enabled", "count": 42}';
115115
await jsonInput.fill(customJson);
116-
await page.getByRole('button', { name: 'Confirm' }).click();
116+
await page.getByTestId('flag-confirm-json-object-flag').click();
117117
await expect(page.getByTestId('flag-row-json-object-flag').getByTestId('override-indicator')).toBeVisible();
118118
await expect(page.getByText('Clear all overrides (4)')).toBeVisible();
119119

@@ -192,13 +192,12 @@ test.describe('LaunchDarkly Toolbar - SDK Mode', () => {
192192
.getByRole('button', { name: 'Edit' });
193193

194194
await jsonFlagEditButton.click();
195-
const jsonInput = page.getByTestId('flag-input-json-object-flag');
195+
const jsonInput = page.getByTestId('json-editor-json-object-flag').getByRole('textbox');
196196

197197
const validJson = '{"environment": "test", "enabled": true}';
198198
await jsonInput.fill(validJson);
199199

200-
const confirmButton = page.getByRole('button', { name: 'Confirm' });
201-
await confirmButton.click();
200+
await page.getByTestId('flag-confirm-json-object-flag').click();
202201

203202
// Verify override was created
204203
await expect(jsonFlagRow.getByTestId('override-indicator')).toBeVisible();

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
"test:e2e:local:ui": "TEST_ENV=local playwright test --ui --config=./e2e/playwright.config.ts"
2828
},
2929
"devDependencies": {
30-
"@playwright/test": "^1.53.1",
30+
"@playwright/test": "^1.56.1",
3131
"@types/node": "^24.9.1",
3232
"http-server": "^14.1.1",
3333
"prettier": "^3.5.3",
34-
"storybook": "^9.1.13",
34+
"storybook": "^9.1.16",
3535
"storybook-addon-rslib": "^2.1.2",
36-
"storybook-react-rsbuild": "^2.0.0",
36+
"storybook-react-rsbuild": "^2.1.2",
3737
"tsx": "^4.20.6"
3838
},
3939
"packageManager": "[email protected]"

packages/demo/.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ VITE_LD_CLIENT_SIDE_ID=your-client-side-id
22
VITE_LD_BASE_URL=https://app.launchdarkly.com
33
VITE_LD_STREAM_URL=https://clientstream.launchdarkly.com
44
VITE_LD_EVENTS_URL=https://events.launchdarkly.com
5+
VITE_LD_DEV_SERVER_URL=http://localhost:8765
6+
7+
# This is used as the client-side ID for the LD Client when connecting
8+
# to the dev server. If you intend to use DevServerMode, configure this
9+
# to the project key in your dev-server that you want to connect to
10+
VITE_LD_DEV_SERVER_PROJECT_KEY=your-dev-server-url-project-key

packages/demo/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ This demo is part of a pnpm monorepo workspace and automatically uses the local
101101
1. **Toolbar not appearing**: Check if the dev server URL is correct and accessible
102102
2. **Connection issues**: Verify your LaunchDarkly dev server is running with CORS enabled
103103
3. **No flags showing**: Ensure the project key is correct and flags exist in the environment
104+
4. **Flags are showing, but values are not the same between the toolbar and the app**: Ensure the toolbar is not using the `FlagOverridePlugin` in dev server mode
104105

105106
### SDK Mode Issues
106107

packages/demo/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
},
1616
"dependencies": {
1717
"@launchdarkly/toolbar": "workspace:*",
18-
"launchdarkly-js-client-sdk": "^3.8.1",
18+
"launchdarkly-js-client-sdk": "^3.9.0",
1919
"launchdarkly-react-client-sdk": "^3.9.0",
20-
"msw": "^2.11.5",
20+
"msw": "^2.11.6",
2121
"react": "^19.1.1",
2222
"react-dom": "^19.1.1",
2323
"react-router-dom": "^7.9.4"
2424
},
2525
"devDependencies": {
26-
"@eslint/js": "^9.37.0",
26+
"@eslint/js": "^9.38.0",
2727
"@types/react": "^19.2.2",
2828
"@types/react-dom": "^19.2.2",
2929
"@vanilla-extract/vite-plugin": "^5.1.1",
30-
"@vitejs/plugin-react": "^5.0.4",
30+
"@vitejs/plugin-react": "^5.1.0",
3131
"eslint": "^9.30.1",
32-
"eslint-plugin-react-hooks": "^7.0.0",
32+
"eslint-plugin-react-hooks": "^7.0.1",
3333
"eslint-plugin-react-refresh": "^0.4.24",
3434
"globals": "^16.3.0",
3535
"typescript": "~5.9.3",
3636
"typescript-eslint": "^8.46.2",
37-
"vite": "^7.1.11"
37+
"vite": "^7.1.12"
3838
},
3939
"msw": {
4040
"workerDirectory": [

packages/demo/src/App.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,16 @@ import './App.css';
44
import { Home } from './pages/Home';
55
import { DevServerMode } from './pages/DevServerMode';
66
import { SDKMode } from './pages/SDKMode';
7-
import { useLaunchDarklyProvider } from './hooks/useLaunchDarklyProvider';
8-
import { LoadingScreen } from './components/LoadingScreen';
9-
import { MockModeIndicator } from './components/MockModeIndicator';
107

118
function App() {
12-
const { LDProvider, isLoading, isUsingMocks } = useLaunchDarklyProvider();
13-
14-
if (!LDProvider) {
15-
return <LoadingScreen isLoading={isLoading} />;
16-
}
17-
189
return (
19-
<LDProvider>
20-
{isUsingMocks && <MockModeIndicator />}
21-
<Router>
22-
<Routes>
23-
<Route path="/" element={<Home />} />
24-
<Route path="/dev-server" element={<DevServerMode />} />
25-
<Route path="/sdk" element={<SDKMode />} />
26-
</Routes>
27-
</Router>
28-
</LDProvider>
10+
<Router>
11+
<Routes>
12+
<Route path="/" element={<Home />} />
13+
<Route path="/dev-server" element={<DevServerMode />} />
14+
<Route path="/sdk" element={<SDKMode />} />
15+
</Routes>
16+
</Router>
2917
);
3018
}
3119

packages/demo/src/hooks/useLaunchDarklyProvider.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import { useState, useEffect, useRef } from 'react';
2-
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
2+
import { asyncWithLDProvider, type LDPlugin } from 'launchdarkly-react-client-sdk';
33
import { DEMO_CONFIG, demoLog } from '../config/demo';
44
import { startMockWorker, stopMockWorker } from '../mocks';
5-
import { flagOverridePlugin, eventInterceptionPlugin } from '../plugins';
65

76
export interface UseLaunchDarklyProviderReturn {
87
LDProvider: React.FC<{ children: React.ReactNode }> | null;
98
isUsingMocks: boolean;
109
isLoading: boolean;
1110
}
1211

13-
export function useLaunchDarklyProvider(): UseLaunchDarklyProviderReturn {
12+
interface UseLaunchDarklyProviderProps {
13+
clientSideID: string;
14+
baseUrl: string;
15+
streamUrl: string;
16+
eventsUrl: string;
17+
plugins: LDPlugin[];
18+
}
19+
20+
export function useLaunchDarklyProvider(props: UseLaunchDarklyProviderProps): UseLaunchDarklyProviderReturn {
21+
const { clientSideID, baseUrl, streamUrl, eventsUrl, plugins } = props;
22+
1423
const [LDProvider, setLDProvider] = useState<React.FC<{ children: React.ReactNode }> | null>(null);
1524
const [isUsingMocks, setIsUsingMocks] = useState(false);
1625
const [isLoading, setIsLoading] = useState(true);
@@ -29,12 +38,12 @@ export function useLaunchDarklyProvider(): UseLaunchDarklyProviderReturn {
2938

3039
// Initialize LaunchDarkly provider
3140
const Provider = await asyncWithLDProvider({
32-
clientSideID: import.meta.env.VITE_LD_CLIENT_SIDE_ID,
41+
clientSideID,
3342
options: {
34-
baseUrl: import.meta.env.VITE_LD_BASE_URL,
35-
streamUrl: import.meta.env.VITE_LD_STREAM_URL,
36-
eventsUrl: import.meta.env.VITE_LD_EVENTS_URL,
37-
plugins: [flagOverridePlugin, eventInterceptionPlugin],
43+
baseUrl,
44+
streamUrl,
45+
eventsUrl,
46+
plugins,
3847
},
3948
});
4049

0 commit comments

Comments
 (0)