Skip to content

Commit

Permalink
Add ephemeral peers views and subviews (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlsmaycon authored Sep 6, 2023
1 parent a44a1c5 commit cfea3bd
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 51 deletions.
119 changes: 80 additions & 39 deletions src/components/SetupKeyEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const SetupKeyNew = (props: any) => {
groupsToCreate: groupsToCreate,
expires_in: expiresIn,
usage_limit: formSetupKey.usage_limit,
ephemeral: formSetupKey.ephemeral,
} as SetupKeyToSave;
};

Expand Down Expand Up @@ -378,50 +379,41 @@ const SetupKeyNew = (props: any) => {
)}
<Row style={{ marginTop: `${isGroupUpdateView ? "0" : "39px"}` }}>
<Col
xs={24}
sm={24}
md={!isGroupUpdateView ? 11 : 24}
lg={!isGroupUpdateView ? 11 : 24}
xl={!isGroupUpdateView ? 11 : 24}
xxl={!isGroupUpdateView ? 11 : 24}
span={!isGroupUpdateView ? 11 : 24}
style={{
paddingRight: `${!isGroupUpdateView ? "70px" : "0"}`,
}}
>
<Paragraph
xs={24}
sm={24}
md={11}
lg={11}
xl={11}
xxl={11}
span={11}
style={{
whiteSpace: "pre-line",
margin: 0,
fontWeight: "500",
paddingRight: "70px",
}}
>
<Paragraph
style={{
whiteSpace: "pre-line",
margin: 0,
fontWeight: "500",
}}
>
Auto-assigned groups
<Paragraph
style={{
whiteSpace: "pre-line",
margin: 0,
fontWeight: "500",
}}
></Paragraph>
Ephemeral peers enabled?
</Paragraph>
<Col>
<Input
disabled
value={formSetupKey.ephemeral? "yes" : "no"}
suffix={<LockOutlined style={{ color: "#BFBFBF" }} />}
style={{ marginTop: "8px" }}
/>

<Col span={24}>
<Form.Item
style={{ marginTop: "8px", marginBottom: 0 }}
name="autoGroupNames"
rules={[{ validator: selectValidator }]}
>
<Select
mode="tags"
style={{ width: "100%" }}
placeholder="Associate groups with the key"
tagRender={blueTagRender}
dropdownRender={dropDownRender}
// enabled only when we have a new key !setupkey.id or when the key is valid
disabled={!(!setupKey.id || setupKey.valid)}
optionFilterProp="serchValue"
>
{tagGroups.map((m, index) => (
<Option key={index} value={m.id} serchValue={m.name}>
{optionRender(m.name, m.id)}
</Option>
))}
</Select>
</Form.Item>
</Col>
</Col>
{!isGroupUpdateView && (
Expand All @@ -442,6 +434,55 @@ const SetupKeyNew = (props: any) => {
</Col>
)}
</Row>
<Row style={{ marginTop: `${isGroupUpdateView ? "0" : "39px"}` }}>
<Col
xs={24}
sm={24}
md={!isGroupUpdateView ? 11 : 24}
lg={!isGroupUpdateView ? 11 : 24}
xl={!isGroupUpdateView ? 11 : 24}
xxl={!isGroupUpdateView ? 11 : 24}
span={!isGroupUpdateView ? 11 : 24}
style={{
paddingRight: `${!isGroupUpdateView ? "70px" : "0"}`,
}}
>
<Paragraph
style={{
whiteSpace: "pre-line",
margin: 0,
fontWeight: "500",
}}
>
Auto-assigned groups
</Paragraph>

<Col span={24}>
<Form.Item
style={{ marginTop: "8px", marginBottom: 0 }}
name="autoGroupNames"
rules={[{ validator: selectValidator }]}
>
<Select
mode="tags"
style={{ width: "100%" }}
placeholder="Associate groups with the key"
tagRender={blueTagRender}
dropdownRender={dropDownRender}
// enabled only when we have a new key !setupkey.id or when the key is valid
disabled={!(!setupKey.id || setupKey.valid)}
optionFilterProp="searchValue"
>
{tagGroups.map((m, index) => (
<Option key={index} value={m.id} serchValue={m.name}>
{optionRender(m.name, m.id)}
</Option>
))}
</Select>
</Form.Item>
</Col>
</Col>
</Row>
</Form>
</div>
<Container
Expand Down
39 changes: 27 additions & 12 deletions src/views/SetupKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ export const SetupKeys = () => {
(a as any).name.localeCompare((b as any).name)
}
render={(text, record: any, index) => {
let sk = record as SetupKeyDataTable;
let expiry = sk.ephemeral ? (
<Tag>
<Text type="secondary" style={{ fontSize: 10 }}>
ephemeral peers enabled
</Text>
</Tag>
) : null;
return (
<Button
type="text"
Expand All @@ -584,18 +592,25 @@ export const SetupKeys = () => {
}
className="tooltip-label"
>
{" "}
<Text className="font-500">
<Badge
size={"small"}
status={
record.state === "valid"
? "success"
: "error"
}
text={text}
></Badge>
</Text>
<span style={{ textAlign: "left" }}>
<Row>
{" "}
<Text className="font-500">
<Badge
size={"small"}
status={
record.state === "valid"
? "success"
: "error"
}
text={text}
></Badge>
</Text>
</Row>
<Row >
{expiry}
</Row>
</span>
</Button>
);
}}
Expand Down

0 comments on commit cfea3bd

Please sign in to comment.