Skip to content

Commit ba97db7

Browse files
authored
Merge pull request Expensify#67159 from software-mansion-labs/chore/regenerate-help-content
[SIDE PANEL] Update the logic and fix help panel appearing without NVP
2 parents 31ba35e + 652c0cc commit ba97db7

10 files changed

Lines changed: 619 additions & 296 deletions

File tree

help/_plugins/SitePostRender.rb

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def self.analyze_used_components(content)
107107
'View' => content.include?('<View'),
108108
'Text' => content.include?('<Text'),
109109
'TextLink' => content.include?('<TextLink'),
110-
'BulletList' => content.include?('<BulletList')
110+
'BulletList' => content.include?('<BulletList'),
111+
'NumberedList' => content.include?('<NumberedList')
111112
}
112113
components.select { |_, used| used }.keys
113114
end
@@ -126,6 +127,7 @@ def self.generate_imports(components)
126127
component_imports << "import BulletList from '@components/SidePanel/HelpComponents/HelpBulletList';" if components.include?('BulletList')
127128
component_imports << "import Text from '@components/Text';" if components.include?('Text')
128129
component_imports << "import TextLink from '@components/TextLink';" if components.include?('TextLink')
130+
component_imports << "import NumberedList from '@components/SidePanel/HelpComponents/HelpNumberedList';" if components.include?('NumberedList')
129131

130132
# Add style imports
131133
base_imports << "import type {ThemeStyles} from '@styles/index';"
@@ -135,6 +137,7 @@ def self.generate_imports(components)
135137

136138
def self.generate_ts_output(import_block, help_content_string)
137139
<<~TS
140+
/* eslint-disable react/jsx-key */
138141
/* eslint-disable react/no-unescaped-entities */
139142
/* eslint-disable @typescript-eslint/naming-convention */
140143
#{import_block}
@@ -199,6 +202,7 @@ def self.html_node_to_RN(node, indent_level = 0)
199202
'div' => method(:process_div),
200203
'p' => method(:process_paragraph),
201204
'ul' => method(:process_unordered_list),
205+
'ol' => method(:process_ordered_list),
202206
'li' => method(:process_list_item),
203207
'h1' => method(:process_heading),
204208
'h2' => method(:process_heading),
@@ -233,7 +237,18 @@ def self.process_div(node, indent_level)
233237
end
234238

235239
def self.process_heading(node, indent_level)
236-
return "#{' ' * indent_level}<Text style={[styles.textHeadline#{node.name.upcase}, styles.mv4]}>#{CGI.escapeHTML(node.text).strip}</Text>"
240+
classes = ["styles.textHeadline#{node.name.upcase}"]
241+
242+
# If a list follows immediately, don't add the normal bottom margin
243+
if %w[ul ol].include?(node.next_element&.name)
244+
classes << 'styles.mt4'
245+
classes << 'styles.mb1'
246+
else
247+
classes << 'styles.mv4'
248+
end
249+
250+
text = CGI.escapeHTML(node.text).strip
251+
"#{' ' * indent_level}<Text style={[#{classes.join(', ')}]}>#{text}</Text>"
237252
end
238253

239254
def self.process_unordered_list(node, indent_level)
@@ -264,6 +279,33 @@ def self.process_unordered_list(node, indent_level)
264279
TS
265280
end
266281

282+
def self.process_ordered_list(node, indent_level)
283+
items = node.xpath('./li').map do |li|
284+
contains_ol = li.xpath('.//ol').any?
285+
286+
li_parts = li.children.map { |child| html_node_to_RN(child, 0) }
287+
288+
if contains_ol
289+
indented_li_parts = li_parts.map do |part|
290+
part.lines.map { |line| "#{' ' * (indent_level + 3)}#{line.rstrip}" }.join("\n")
291+
end.join("\n")
292+
293+
"#{' ' * (indent_level + 2)}<>\n#{indented_li_parts}\n#{' ' * (indent_level + 2)}</>"
294+
else
295+
"#{' ' * (indent_level + 2)}<Text style={styles.textNormal}>#{li_parts.join.strip}</Text>"
296+
end
297+
end
298+
299+
<<~TS.chomp
300+
#{' ' * indent_level}<NumberedList
301+
#{' ' * indent_level} styles={styles}
302+
#{' ' * indent_level} items={[
303+
#{items.join(",\n")}
304+
#{' ' * indent_level} ]}
305+
#{' ' * indent_level}/>
306+
TS
307+
end
308+
267309
def self.process_list_item(node, indent_level)
268310
'' # handled in <ul>
269311
end
@@ -272,8 +314,16 @@ def self.process_paragraph(node, indent_level)
272314
inner = node.children.map { |c| html_node_to_RN(c, indent_level + 1) }.join
273315

274316
style_classes = ['styles.textNormal']
275-
style_classes << 'styles.mt4' if node.previous_element&.name == 'ul'
276-
style_classes << 'styles.mb4' if node.next_element&.name == 'p'
317+
318+
# Add spacing if previous sibling is a list (ul or ol)
319+
if %w[ul ol].include?(node.previous_element&.name)
320+
style_classes << 'styles.mt4'
321+
end
322+
323+
# Add spacing if the next element is another paragraph
324+
if node.next_element&.name == 'p'
325+
style_classes << 'styles.mb4'
326+
end
277327

278328
"#{' ' * indent_level}<Text style={[#{style_classes.join(', ')}]}>#{inner.strip}</Text>"
279329
end

help/ref/:action/:iouType/start/:transactionID/:reportID/distance/:backToReport/index.md renamed to help/ref/distance/index.md

File renamed without changes.

help/ref/r/:chat/index.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
layout: product
3+
title: Expensify Chat
4+
---
5+
6+
# Chat
7+
8+
Chat is the foundation of New Expensify. Every expense, expense report, workspace, or member has an associated "chat", which you can use to record additional details, or collaborate with others. Every chat has the following components:
9+
10+
## Header
11+
12+
This shows who you are chatting with (or what you are chatting about). You can press the header for more details on the chat, or additional actions to take upon it.
13+
14+
## Comments
15+
16+
The core of the chat are its comments, which come in many forms:
17+
18+
- **Text** – Rich text messages stored securely and delivered via web, app, email, or SMS.
19+
- **Images & Documents** – Insert photos, screenshots, movies, PDFs, or more, using copy/paste, drag/drop, or the attach button.
20+
- **Expenses** – Share an expense in the chat, either to simply track and document it, or to submit for reimbursement.
21+
- **Tasks** – Record a task, and optionally assign it to someone (or yourself!).
22+
23+
## Actions
24+
25+
Hover (or long press) on a comment to see additional options, including:
26+
27+
- **React** – Throw a ♥️😂🔥 like on anything!
28+
- **Reply in thread** – Go deeper by creating a new chat on any comment.
29+
- **Mark unread** – Flag it for reading later, at your convenience.
30+
31+
## Composer
32+
33+
Use the composer at the bottom to write new messages:
34+
35+
- **Markdown** – Format text using **bold**, *italics*, and [more](https://help.expensify.com/articles/new-expensify/chat/Send-and-format-chat-messages).
36+
- **Mention** – Invite or tag anyone in the world to any chat by putting an `@` in front of their email address or phone number (e.g., **@awong@marslink.web**, or **@415-867-5309**).

help/ref/r/index.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
---
22
layout: product
3-
title: Inbox Overview
3+
title: Expensify Inbox
44
---
5+
6+
# Inbox
7+
8+
The Inbox is a prioritized "to do" list, highlighting exactly what you need to do next. It consists of:
9+
10+
## Priorities
11+
12+
At the top of the Inbox are the most important tasks you should do first, which include:
13+
14+
- Expense reports waiting on you
15+
- Tasks assigned to you
16+
- Chats that have mentioned you
17+
- Anything you have pinned
18+
19+
## Chats
20+
21+
Beneath the priorities are a list of chats (with unread chats highlighted in bold), in one of two view modes:
22+
23+
- **Most Recent** – Lists every chat, ordered by whichever was most recently active.
24+
- **Focus** – Only lists chats with unread messages, sorted alphabetically.

help/ref/:action/:iouType/start/:transactionID/:reportID/scan/:backToReport/index.md renamed to help/ref/scan/index.md

File renamed without changes.

help/ref/workspaces/:policyID/members/index.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ Invite teammates to your workspace and assign roles to control their access and
2727
- Add comments, but cannot modify expenses
2828
- No approval or payment permissions
2929

30-
---
31-
3230
## Adding Members
3331

3432
1. Under **Workspaces > [Workspace Name] > Members**, click **Invite Member**
@@ -38,8 +36,6 @@ Invite teammates to your workspace and assign roles to control their access and
3836

3937
**Alternative:** Share the workspace URL or QR code from **Account > Profile > Share**
4038

41-
---
42-
4339
## Managing Members
4440

4541
**Change Role:**
@@ -54,17 +50,13 @@ Invite teammates to your workspace and assign roles to control their access and
5450
2. Click **Remove from Workspace**
5551
3. Confirm removal
5652

57-
---
58-
5953
## Transfer Ownership of a Workspace
6054

6155
1. Go to **Members** and click current **Owner**
6256
2. Click **Transfer Owner**
6357
3. Confirm transfer
6458
4. You become the new owner
6559

66-
---
67-
6860
## Learn More
6961

7062
- [Managing Workspace Members](https://help.expensify.com/articles/new-expensify/workspaces/Managing-Workspace-Members)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type {ReactNode} from 'react';
2+
import React from 'react';
3+
import {View} from 'react-native';
4+
import Text from '@components/Text';
5+
import type {ThemeStyles} from '@styles/index';
6+
7+
type HelpNumberedListProps = {
8+
styles: ThemeStyles;
9+
items: ReactNode[];
10+
};
11+
12+
function HelpNumberedList({items, styles}: HelpNumberedListProps) {
13+
return items.map((item, index) => (
14+
<View
15+
// eslint-disable-next-line react/no-array-index-key
16+
key={`numbered-list-item-${index}`}
17+
style={[styles.flexRow, styles.alignItemsStart, styles.mt3]}
18+
>
19+
<Text style={[styles.textNormal, styles.pr2, styles.userSelectNone]}>{`${index + 1}.`}</Text>
20+
<Text style={[styles.flex1]}>{item}</Text>
21+
</View>
22+
));
23+
}
24+
25+
export default HelpNumberedList;

0 commit comments

Comments
 (0)