-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51646b2
commit 697dc66
Showing
8 changed files
with
174 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React, { useMemo } from "react"; | ||
import { Button, Classes, Dialog, DialogBody } from "@blueprintjs/core"; | ||
import { SearchResult } from "buttercup"; | ||
import cn from "classnames"; | ||
import styled from "styled-components"; | ||
|
||
interface EntryInfoDialogProps { | ||
entry: SearchResult | null; | ||
onClose: () => void; | ||
} | ||
|
||
interface EntryProperty { | ||
key: string; | ||
sensitive: boolean; | ||
title: string; | ||
value: string; | ||
} | ||
|
||
const InfoDialog = styled(Dialog)` | ||
max-width: 90%; | ||
`; | ||
const InfoDialogBody = styled(DialogBody)` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: stretch; | ||
align-items: flex-start; | ||
overflow-x: hidden; | ||
`; | ||
const InfoTable = styled.table` | ||
table-layout: fixed; | ||
width: 100%; | ||
`; | ||
const ValueInput = styled.input` | ||
width: 100%; | ||
`; | ||
|
||
export function EntryInfoDialog(props: EntryInfoDialogProps) { | ||
const { entry, onClose } = props; | ||
const properties = useMemo(() => entry ? orderProperties(entry.properties) : [], [entry]); | ||
return ( | ||
<InfoDialog | ||
icon="info-sign" | ||
isCloseButtonShown | ||
isOpen={!!entry} | ||
onClose={onClose} | ||
title={entry?.properties.title ?? "Untitled Entry"} | ||
> | ||
<InfoDialogBody> | ||
<InfoTable className={cn(Classes.HTML_TABLE, Classes.COMPACT, Classes.HTML_TABLE_STRIPED)}> | ||
<tbody> | ||
{properties.map(property => ( | ||
<tr key={property.key}> | ||
<td style={{ width: "100%" }}> | ||
{property.title}<br /> | ||
<ValueInput className={Classes.INPUT} type={property.sensitive ? "password" : "text"} value={property.value} readOnly /> | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</InfoTable> | ||
</InfoDialogBody> | ||
</InfoDialog> | ||
); | ||
} | ||
|
||
function orderProperties(properties: Record<string, string>): Array<EntryProperty> { | ||
const working = { ...properties }; | ||
delete working["title"]; | ||
const output: Array<EntryProperty> = []; | ||
if (working["username"]) { | ||
output.push({ | ||
key: "username", | ||
sensitive: false, | ||
title: "Username", | ||
value: properties["username"] | ||
}); | ||
delete working["username"]; | ||
} | ||
if (working["password"]) { | ||
output.push({ | ||
key: "password", | ||
sensitive: true, | ||
title: "Password", | ||
value: properties["password"] | ||
}); | ||
delete working["password"]; | ||
} | ||
for (const prop in working) { | ||
output.push({ | ||
key: prop, | ||
sensitive: false, | ||
title: prop, | ||
value: working[prop] | ||
}); | ||
} | ||
return output; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Do not edit this file - it is generated automatically at build time | ||
|
||
export const BUILD_DATE = "2024-03-26"; | ||
export const BUILD_DATE = "2024-03-27"; | ||
export const VERSION = "3.0.0"; |