-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a cookie (UI-only) tab (needs impl)
- Loading branch information
1 parent
4d4a1e2
commit 75af7ca
Showing
5 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/bruno-app/src/components/CookieEditor/StyledWrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import styled from 'styled-components'; | ||
|
||
const StyledWrapper = styled.div` | ||
table { | ||
thead, | ||
td { | ||
border: 1px solid ${(props) => props.theme.table.border}; | ||
li { | ||
background-color: ${(props) => props.theme.bg} !important; | ||
} | ||
} | ||
} | ||
.muted { | ||
color: ${(props) => props.theme.colors.text.muted}; | ||
} | ||
`; | ||
|
||
export default StyledWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import get from 'lodash/get'; | ||
import filter from 'lodash/filter'; | ||
import { Inspector } from 'react-inspector'; | ||
import { useTheme } from 'providers/Theme'; | ||
import { findEnvironmentInCollection } from 'utils/collections'; | ||
import StyledWrapper from './StyledWrapper'; | ||
|
||
const KeyValueExplorer = ({ data, theme }) => { | ||
data = data || {}; | ||
|
||
return ( | ||
<div> | ||
<table className="border-collapse"> | ||
<tbody> | ||
{Object.entries(data).map(([key, value]) => ( | ||
<tr key={key}> | ||
<td className="px-2 py-1">{key}</td> | ||
<td className="px-2 py-1"> | ||
<Inspector data={value} theme={theme} /> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; | ||
|
||
const Cookies = ({ collection, theme }) => { | ||
// const collectionVariablesFound = Object.keys(collection.collectionVariables).length > 0; | ||
const collectionVariablesFound = true; | ||
|
||
const demo_data = { | ||
session_cookie: '1234567890', | ||
user_id: '1234', | ||
user_name: 'John Doe' | ||
}; | ||
|
||
return ( | ||
<> | ||
<h1 className="font-semibold mb-2">Current cookies</h1> | ||
{collectionVariablesFound ? ( | ||
// <KeyValueExplorer data={collection.collectionVariables} theme={theme} /> | ||
<KeyValueExplorer data={demo_data} theme={theme} /> | ||
) : ( | ||
<div className="muted text-xs">No cookies found</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const CookieEditor = ({ collection }) => { | ||
const { storedTheme } = useTheme(); | ||
|
||
const reactInspectorTheme = storedTheme === 'light' ? 'chromeLight' : 'chromeDark'; | ||
|
||
return ( | ||
<StyledWrapper className="px-4 py-4"> | ||
<Cookies collection={collection} theme={reactInspectorTheme} /> | ||
|
||
<div className="mt-8 muted text-xs"> | ||
Note: As of today, cookies are active WIP. <br /> | ||
It's done when it's done, thx. | ||
</div> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
export default CookieEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters