Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const WSRequestPane = ({ item, collection, handleRun }) => {
currentMessages.push({
uid: uuid(),
name: `message ${currentMessages.length + 1}`,
content: '{}',
content: '',
type: 'json',
selected: true
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Wrapper = styled.div`
}

.selected-body-mode {
color: ${(props) => props.theme.primary.text};
color: ${(props) => props.theme.ws.activeMessage.label};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import styled from 'styled-components';
const StyledWrapper = styled.div`
border-bottom: 1px solid ${(props) => props.theme.border.border0};

/* No divider below the last message */
&:last-child {
border-bottom: none;
}

/* Dim the row content when disabled, but not the tooltip */
.accordion-left > :not(.toolhint),
.accordion-actions,
Expand All @@ -18,6 +23,13 @@ const StyledWrapper = styled.div`
}
}

&:not(.disabled) .accordion-header {
position: sticky;
top: 0;
z-index: 1;
background: ${(props) => props.theme.bg};
}

.accordion-header {
display: flex;
align-items: center;
Expand Down Expand Up @@ -102,7 +114,7 @@ const StyledWrapper = styled.div`
}

&:not(.disabled) .accordion-header .message-label {
color: ${(props) => props.theme.primary.text};
color: ${(props) => props.theme.ws.activeMessage.label};
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Wrapper = styled.div`
.messages-container {
flex: 1;
overflow-y: auto;
isolation: isolate;
}

.empty-state {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ export const newWsRequest = (params) => (dispatch, getState) => {
uid: uuid(),
name: 'message 1',
type: 'json',
content: '{}'
content: ''
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/catppuccin-frappe.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const catppuccinFrappeTheme = {
subtle: colors.MAUVE
},

ws: {
activeMessage: {
label: colors.MAUVE
}
},

accents: {
primary: colors.MAUVE
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/catppuccin-macchiato.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const catppuccinMacchiatoTheme = {
subtle: colors.MAUVE
},

ws: {
activeMessage: {
label: colors.MAUVE
}
},

accents: {
primary: colors.MAUVE
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/catppuccin-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const catppuccinMochaTheme = {
subtle: colors.MAUVE
},

ws: {
activeMessage: {
label: colors.MAUVE
}
},

accents: {
primary: colors.MAUVE
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/dark-monochrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ const darkMonochromeTheme = {
}
},

ws: {
activeMessage: {
label: colors.TEXT
}
},

request: {
methods: {
get: '#a3a3a3',
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/dark-pastel.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ const darkPastelTheme = {
subtle: colors.BRAND
},

ws: {
activeMessage: {
label: colors.BRAND
}
},

accents: {
primary: colors.BRAND
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/dark.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ const darkTheme = {
subtle: palette.primary.SUBTLE
},

ws: {
activeMessage: {
label: palette.primary.TEXT
}
},

accents: {
primary: palette.primary.SOLID
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/nord.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const nordTheme = {
subtle: colors.BRAND
},

ws: {
activeMessage: {
label: colors.BRAND
}
},

accents: {
primary: colors.BRAND
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/dark/vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ const vscodeDarkTheme = {
subtle: '#005a9e'
},

ws: {
activeMessage: {
label: colors.BRAND_TEXT
}
},

accents: {
primary: colors.BRAND
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/light/catppuccin-latte.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ const catppuccinLatteTheme = {
subtle: colors.MAUVE
},

ws: {
activeMessage: {
label: colors.MAUVE
}
},

accents: {
primary: colors.MAUVE
},
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/light/light-monochrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ const lightMonochromeTheme = {
}
},

ws: {
activeMessage: {
label: colors.BRAND
}
},

request: {
methods: {
get: '#525252',
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/light/light-pastel.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ const lightPastelTheme = {
}
},

ws: {
activeMessage: {
label: colors.BRAND
}
},

request: {
methods: {
get: '#3c9d7c', // Soft emerald - success
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/light/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ const lightTheme = {
}
},

ws: {
activeMessage: {
label: palette.primary.TEXT
}
},

request: {
methods: {
get: palette.hues.GREEN,
Expand Down
6 changes: 6 additions & 0 deletions packages/bruno-app/src/themes/light/vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ const vscodeLightTheme = {
}
},

ws: {
activeMessage: {
label: colors.TEXT_LINK
}
},

request: {
methods: {
get: colors.GREEN,
Expand Down
16 changes: 16 additions & 0 deletions packages/bruno-app/src/themes/schema/oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ export const ossSchema = {
additionalProperties: false
},

ws: {
type: 'object',
properties: {
activeMessage: {
type: 'object',
properties: {
label: { type: 'string' }
},
required: ['label'],
additionalProperties: false
}
},
required: ['activeMessage'],
additionalProperties: false
},

requestTabPanel: {
type: 'object',
properties: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta {
name: ws-default-body-request
type: ws
seq: 4
}

ws {
url: ws://localhost:8081/ws
auth: inherit
}

body:ws {
name: message 1
content: '''
{
"foo":"bar"
}
'''
}
34 changes: 34 additions & 0 deletions tests/websockets/message-body-default.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect, test } from '../../playwright';
import { closeAllCollections } from '../utils/page/actions';

const REQ_NAME = /^ws-default-body-request$/;

test.describe('websocket message default body', () => {
test.afterAll(async ({ pageWithUserData: page }) => {
await closeAllCollections(page);
});

test('a newly added message defaults to an empty body showing the placeholder', async ({
pageWithUserData: page
}) => {
// Open the preloaded websocket request
await page.getByTestId('sidebar-collection-row').click();
await page.getByTitle(REQ_NAME).click();

const headers = page.getByTestId(/^ws-message-header-/);
const beforeCount = await headers.count();

await page.getByTestId('ws-add-message').click();
await expect(headers).toHaveCount(beforeCount + 1);

// The newly added message is the last one and auto-expands.
const newBody = page.getByTestId(`ws-message-body-${beforeCount}`);
await expect(newBody).toBeVisible();

const editor = newBody.locator('.CodeMirror');
// Body should be empty (previously defaulted to '{}'); the editor should
// surface the '...' placeholder instead of any '{}' content.
await expect(editor.locator('.CodeMirror-placeholder')).toHaveText('...');
await expect(editor.locator('.CodeMirror-code')).not.toContainText('{}');
});
});
Loading