Skip to content

Commit 236fad2

Browse files
authored
feat: update the publish design and add some guardrails (#4073)
1 parent dadb681 commit 236fad2

File tree

7 files changed

+345
-338
lines changed

7 files changed

+345
-338
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
},
158158
"dependencies": {
159159
"@docsearch/react": "^3.0.0-alpha.37",
160-
"@influxdata/clockface": "^3.3.3",
160+
"@influxdata/clockface": "^3.4.1",
161161
"@influxdata/flux-lsp-browser": "^0.8.5",
162162
"@influxdata/giraffe": "^2.24.3",
163163
"@influxdata/influxdb-templates": "0.9.0",

src/flows/components/VersionSidebar.scss

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
line-height: 1.2;
1111
}
1212

13-
.current-version--text {
14-
font-style: italic;
15-
font-weight: normal;
16-
line-height: 1.6;
17-
color: $c-pool;
18-
flex: none;
19-
margin: 0px 0px;
20-
}
21-
2213
.published-date--text {
2314
font-weight: normal;
2415
font-size: 15.75px;
@@ -93,3 +84,7 @@
9384
line-height: 1.2;
9485
margin-right: $cf-marg-c;
9586
}
87+
88+
.version-sidebar--back-btn {
89+
margin: 0px 10px 12px;
90+
}

src/flows/components/VersionSidebar.tsx

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,12 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
5050
const {flow} = useContext(FlowContext)
5151
const {id: orgID} = useSelector(getOrg)
5252

53-
const isDraft = version.id === 'draft'
54-
5553
const handleClick = () => {
56-
let route = `/orgs/${orgID}/${PROJECT_NAME_PLURAL.toLowerCase()}/${flow.id}`
57-
58-
if (!isDraft) {
59-
route = `${route}/versions/${version.id}`
60-
}
61-
62-
history.push(route)
54+
history.push(
55+
`/orgs/${orgID}/${PROJECT_NAME_PLURAL.toLowerCase()}/${
56+
flow.id
57+
}/versions/${version.id}`
58+
)
6359
}
6460

6561
const handleRevert = async () => {
@@ -121,7 +117,7 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
121117

122118
return (
123119
<List.Item
124-
selected={!isDraft && id === version.id}
120+
selected={id === version.id}
125121
onClick={handleClick}
126122
backgroundColor={InfluxColors.Grey15}
127123
className="version-sidebar--listitem"
@@ -133,43 +129,36 @@ const VersionSidebarListItem: FC<Props> = ({version}) => {
133129
<h6 className="published-date--text">
134130
{new Date(version.publishedAt).toLocaleString()}
135131
</h6>
136-
{isDraft && <h6 className="current-version--text">Current version</h6>}
137-
{!isDraft && (
138-
<h6 className="published-by--text">{version.publishedBy}</h6>
139-
)}
132+
<h6 className="published-by--text">{version.publishedBy}</h6>
140133
</FlexBox>
141-
{isDraft === false && (
142-
<>
143-
<Icon
144-
glyph={IconFont.More}
145-
ref={triggerRef}
146-
style={{color: InfluxColors.White}}
147-
/>
148-
<Popover
149-
triggerRef={triggerRef}
150-
enableDefaultStyles={false}
151-
style={{minWidth: 209}}
152-
showEvent={PopoverInteraction.Click}
153-
hideEvent={PopoverInteraction.Click}
154-
contents={onHide => (
155-
<List>
156-
{menuItems.map(item => (
157-
<List.Item
158-
key={item.title}
159-
onClick={() => {
160-
item?.onClick()
161-
onHide()
162-
}}
163-
>
164-
<Icon glyph={item?.icon} />
165-
<span style={{paddingLeft: '10px'}}>{item?.title}</span>
166-
</List.Item>
167-
))}
168-
</List>
169-
)}
170-
/>
171-
</>
172-
)}
134+
<Icon
135+
glyph={IconFont.More}
136+
ref={triggerRef}
137+
style={{color: InfluxColors.White}}
138+
/>
139+
<Popover
140+
triggerRef={triggerRef}
141+
enableDefaultStyles={false}
142+
style={{minWidth: 209}}
143+
showEvent={PopoverInteraction.Click}
144+
hideEvent={PopoverInteraction.Click}
145+
contents={onHide => (
146+
<List>
147+
{menuItems.map(item => (
148+
<List.Item
149+
key={item.title}
150+
onClick={() => {
151+
item?.onClick()
152+
onHide()
153+
}}
154+
>
155+
<Icon glyph={item?.icon} />
156+
<span style={{paddingLeft: '10px'}}>{item?.title}</span>
157+
</List.Item>
158+
))}
159+
</List>
160+
)}
161+
/>
173162
</List.Item>
174163
)
175164
}
@@ -188,6 +177,14 @@ export const VersionSidebar: FC = () => {
188177
)
189178
}
190179

180+
const hasDraft = versions[0]?.id === 'draft'
181+
182+
const trimmedVersions = versions.slice()
183+
184+
if (hasDraft) {
185+
trimmedVersions.splice(0, 1)
186+
}
187+
191188
return (
192189
<div className="version-sidebar">
193190
<div className="version-sidebar--buttons">
@@ -206,8 +203,16 @@ export const VersionSidebar: FC = () => {
206203
thumbStartColor="gray"
207204
>
208205
<div className="version-sidebar--submenu-wrapper">
206+
{hasDraft && (
207+
<Button
208+
icon={IconFont.ArrowLeft_New}
209+
text="Back to Current Version"
210+
onClick={handleClose}
211+
className="version-sidebar--back-btn"
212+
/>
213+
)}
209214
<List>
210-
{versions.map(version => (
215+
{trimmedVersions.map(version => (
211216
<React.Fragment key={version.id}>
212217
<VersionSidebarListItem version={version} />
213218
<List.Divider style={{margin: 0}} />

0 commit comments

Comments
 (0)