Skip to content

Commit 79bad36

Browse files
[docs-infra] Split feedback channels per product (#42413)
Signed-off-by: Alexandre Fauquette <[email protected]>
1 parent f153423 commit 79bad36

File tree

3 files changed

+66
-13
lines changed

3 files changed

+66
-13
lines changed

docs/src/modules/components/AppLayoutDocsFooter.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function postFeedback(data) {
9696
}
9797

9898
async function postFeedbackOnSlack(data) {
99-
const { rating, comment, commentedSection } = data;
99+
const { rating, comment, commentedSection, productId } = data;
100100

101101
const sentData = {
102102
callback_id: 'send_feedback',
@@ -106,6 +106,7 @@ async function postFeedbackOnSlack(data) {
106106
commmentSectionURL: `${window.location.origin}${window.location.pathname}#${commentedSection.hash}`,
107107
commmentSectionTitle: commentedSection.text,
108108
githubRepo: process.env.SOURCE_CODE_REPO,
109+
productId,
109110
};
110111
if (!comment || comment.length < 10) {
111112
return 'ignored';
@@ -187,7 +188,7 @@ async function getUserFeedback(id) {
187188
}
188189
}
189190

190-
async function submitFeedback(page, rating, comment, language, commentedSection) {
191+
async function submitFeedback(page, rating, comment, language, commentedSection, productId) {
191192
const data = {
192193
id: getCookie('feedbackId'),
193194
page,
@@ -197,7 +198,7 @@ async function submitFeedback(page, rating, comment, language, commentedSection)
197198
language,
198199
};
199200

200-
const resultSlack = await postFeedbackOnSlack({ ...data, commentedSection });
201+
const resultSlack = await postFeedbackOnSlack({ ...data, productId, commentedSection });
201202
if (rating !== undefined) {
202203
const resultVote = await postFeedback(data);
203204
if (resultVote) {
@@ -259,7 +260,7 @@ export default function AppLayoutDocsFooter(props) {
259260
const theme = useTheme();
260261
const t = useTranslate();
261262
const userLanguage = useUserLanguage();
262-
const { activePage } = React.useContext(PageContext);
263+
const { activePage, productId } = React.useContext(PageContext);
263264
const [rating, setRating] = React.useState();
264265
const [comment, setComment] = React.useState('');
265266
const [snackbarOpen, setSnackbarOpen] = React.useState(false);
@@ -303,6 +304,7 @@ export default function AppLayoutDocsFooter(props) {
303304
comment,
304305
userLanguage,
305306
commentedSection,
307+
productId,
306308
);
307309
if (result) {
308310
setSnackbarMessage(t('feedbackSubmitted'));

docs/src/modules/utils/getProductInfoFromUrl.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export type MuiProductId =
1010
| 'docs'
1111
| 'x-data-grid'
1212
| 'x-date-pickers'
13-
| 'x-charts';
13+
| 'x-charts'
14+
| 'x-tree-view'
15+
| 'toolpad-studio'
16+
| 'toolpad-core';
1417

1518
type MuiProductCategoryId = 'null' | 'core' | 'x';
1619

netlify/functions/feedback-management.mts

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,72 @@ const X_FEEBACKS_CHANNEL_ID = 'C04U3R2V9UK';
88
const JOY_FEEBACKS_CHANNEL_ID = 'C050VE13HDL';
99
const TOOLPAD_FEEBACKS_CHANNEL_ID = 'C050MHU703Z';
1010
const CORE_FEEBACKS_CHANNEL_ID = 'C041SDSF32L';
11+
12+
const BASE_UI_FEEBACKS_CHANNEL_ID = 'C075LJG1LMP';
13+
const MATERIAL_UI_FEEBACKS_CHANNEL_ID = 'C0757QYLK7V';
14+
// const PIGMENT_CSS_FEEBACKS_CHANNEL_ID = 'C074TBW0JKZ';
15+
const X_GRID_FEEBACKS_CHANNEL_ID = 'C0757R0KW67';
16+
const X_CHARTS_FEEBACKS_CHANNEL_ID = 'C0757UBND98';
17+
const X_EXPLORE_FEEBACKS_CHANNEL_ID = 'C074TBYQK2T';
18+
// const DESIGN_KITS_FEEBACKS_CHANNEL_ID = 'C075ADGN0UU';
19+
1120
// The design feedback alert was removed in https://github.com/mui/material-ui/pull/39691
1221
// This dead code is here to simplify the creation of special feedback channel
1322
const DESIGN_FEEDBACKS_CHANNEL_ID = 'C05HHSFH2QJ';
1423

15-
const getSlackChannelId = (url, specialCases) => {
24+
export type MuiProductId =
25+
| 'null'
26+
| 'base-ui'
27+
| 'material-ui'
28+
| 'joy-ui'
29+
| 'system'
30+
| 'docs-infra'
31+
| 'docs'
32+
| 'x-data-grid'
33+
| 'x-date-pickers'
34+
| 'x-charts'
35+
| 'x-tree-view'
36+
| 'toolpad-studio'
37+
| 'toolpad-core';
38+
39+
const getSlackChannelId = (
40+
url: string,
41+
productId: MuiProductId,
42+
specialCases: { isDesignFeedback?: boolean },
43+
) => {
1644
const { isDesignFeedback } = specialCases;
1745

1846
if (isDesignFeedback) {
1947
return DESIGN_FEEDBACKS_CHANNEL_ID;
2048
}
49+
50+
switch (productId) {
51+
case 'base-ui':
52+
return BASE_UI_FEEBACKS_CHANNEL_ID;
53+
case 'material-ui':
54+
case 'system':
55+
return MATERIAL_UI_FEEBACKS_CHANNEL_ID;
56+
case 'joy-ui':
57+
return JOY_FEEBACKS_CHANNEL_ID;
58+
case 'x-data-grid':
59+
return X_GRID_FEEBACKS_CHANNEL_ID;
60+
case 'x-date-pickers':
61+
case 'x-tree-view':
62+
return X_EXPLORE_FEEBACKS_CHANNEL_ID;
63+
case 'x-charts':
64+
return X_CHARTS_FEEBACKS_CHANNEL_ID;
65+
case 'toolpad-studio':
66+
case 'toolpad-core':
67+
return TOOLPAD_FEEBACKS_CHANNEL_ID;
68+
default:
69+
break;
70+
}
71+
72+
// Fallback
73+
2174
if (url.includes('/x/')) {
2275
return X_FEEBACKS_CHANNEL_ID;
2376
}
24-
if (url.includes('/joy-ui/')) {
25-
return JOY_FEEBACKS_CHANNEL_ID;
26-
}
27-
if (url.includes('/toolpad/')) {
28-
return TOOLPAD_FEEBACKS_CHANNEL_ID;
29-
}
3077
return CORE_FEEBACKS_CHANNEL_ID;
3178
};
3279

@@ -154,6 +201,7 @@ export const handler: Handler = async (event, context, callback) => {
154201
commmentSectionURL: inCommmentSectionURL,
155202
commmentSectionTitle,
156203
githubRepo,
204+
productId,
157205
} = data;
158206

159207
// The design feedback alert was removed in https://github.com/mui/material-ui/pull/39691
@@ -181,7 +229,7 @@ from ${commmentSectionURL}
181229
});
182230

183231
await app.client.chat.postMessage({
184-
channel: getSlackChannelId(currentLocationURL, { isDesignFeedback }),
232+
channel: getSlackChannelId(currentLocationURL, productId, { isDesignFeedback }),
185233
text: simpleSlackMessage, // Fallback for notification
186234
blocks: [
187235
{

0 commit comments

Comments
 (0)