Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-infra] Split feedback channels per product #42413

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/src/modules/components/AppLayoutDocsFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function postFeedback(data) {
}

async function postFeedbackOnSlack(data) {
const { rating, comment, commentedSection } = data;
const { rating, comment, commentedSection, productId } = data;

const sentData = {
callback_id: 'send_feedback',
Expand All @@ -106,6 +106,7 @@ async function postFeedbackOnSlack(data) {
commmentSectionURL: `${window.location.origin}${window.location.pathname}#${commentedSection.hash}`,
commmentSectionTitle: commentedSection.text,
githubRepo: process.env.SOURCE_CODE_REPO,
productId,
};
if (!comment || comment.length < 10) {
return 'ignored';
Expand Down Expand Up @@ -187,7 +188,7 @@ async function getUserFeedback(id) {
}
}

async function submitFeedback(page, rating, comment, language, commentedSection) {
async function submitFeedback(page, rating, comment, language, commentedSection, productId) {
const data = {
id: getCookie('feedbackId'),
page,
Expand All @@ -197,7 +198,7 @@ async function submitFeedback(page, rating, comment, language, commentedSection)
language,
};

const resultSlack = await postFeedbackOnSlack({ ...data, commentedSection });
const resultSlack = await postFeedbackOnSlack({ ...data, productId, commentedSection });
if (rating !== undefined) {
const resultVote = await postFeedback(data);
if (resultVote) {
Expand Down Expand Up @@ -259,7 +260,7 @@ export default function AppLayoutDocsFooter(props) {
const theme = useTheme();
const t = useTranslate();
const userLanguage = useUserLanguage();
const { activePage } = React.useContext(PageContext);
const { activePage, productId } = React.useContext(PageContext);
const [rating, setRating] = React.useState();
const [comment, setComment] = React.useState('');
const [snackbarOpen, setSnackbarOpen] = React.useState(false);
Expand Down Expand Up @@ -303,6 +304,7 @@ export default function AppLayoutDocsFooter(props) {
comment,
userLanguage,
commentedSection,
productId,
);
if (result) {
setSnackbarMessage(t('feedbackSubmitted'));
Expand Down
5 changes: 4 additions & 1 deletion docs/src/modules/utils/getProductInfoFromUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export type MuiProductId =
| 'docs'
| 'x-data-grid'
| 'x-date-pickers'
| 'x-charts';
| 'x-charts'
| 'x-tree-view'
| 'toolpad-studio'
| 'toolpad-core';

Comment on lines 12 to 17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it's in master but not in next

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

Expand Down
63 changes: 55 additions & 8 deletions netlify/functions/feedback-management.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,71 @@ const X_FEEBACKS_CHANNEL_ID = 'C04U3R2V9UK';
const JOY_FEEBACKS_CHANNEL_ID = 'C050VE13HDL';
const TOOLPAD_FEEBACKS_CHANNEL_ID = 'C050MHU703Z';
const CORE_FEEBACKS_CHANNEL_ID = 'C041SDSF32L';

const BASE_UI_FEEBACKS_CHANNEL_ID = 'C075LJG1LMP';
const MATERIAL_UI_FEEBACKS_CHANNEL_ID = 'C0757QYLK7V';
// const PIGMENT_CSS_FEEBACKS_CHANNEL_ID = 'C074TBW0JKZ';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brijeshb42 I assume we don't have pages for now

Copy link
Contributor

@brijeshb42 brijeshb42 May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. No pages yet.

const X_GRID_FEEBACKS_CHANNEL_ID = 'C0757R0KW67';
const X_CHARTS_FEEBACKS_CHANNEL_ID = 'C0757UBND98';
const X_EXPLORE_FEEBACKS_CHANNEL_ID = 'C074TBYQK2T';
// const DESIGN_KITS_FEEBACKS_CHANNEL_ID = 'C075ADGN0UU';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliviertassinari Do you have a specific page in mind, or is it just an idea for latter for the design kits? Because for now, they don't have pages with feedback input. Or at least I did not find them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// The design feedback alert was removed in https://github.com/mui/material-ui/pull/39691
// This dead code is here to simplify the creation of special feedback channel
const DESIGN_FEEDBACKS_CHANNEL_ID = 'C05HHSFH2QJ';

const getSlackChannelId = (url, specialCases) => {
export type MuiProductId =
| 'null'
| 'base-ui'
| 'material-ui'
| 'joy-ui'
| 'system'
| 'docs-infra'
| 'docs'
| 'x-data-grid'
| 'x-date-pickers'
| 'x-charts'
| 'x-tree-view'
| 'toolpad-studio'
| 'toolpad-core';

const getSlackChannelId = (
url: string,
productId: MuiProductId,
specialCases: { isDesignFeedback?: boolean },
) => {
const { isDesignFeedback } = specialCases;

if (isDesignFeedback) {
return DESIGN_FEEDBACKS_CHANNEL_ID;
}

switch (productId) {
case 'base-ui':
return BASE_UI_FEEBACKS_CHANNEL_ID;
case 'material-ui':
alexfauquette marked this conversation as resolved.
Show resolved Hide resolved
return MATERIAL_UI_FEEBACKS_CHANNEL_ID;
case 'joy-ui':
return JOY_FEEBACKS_CHANNEL_ID;
case 'x-data-grid':
return X_GRID_FEEBACKS_CHANNEL_ID;
case 'x-date-pickers':
case 'x-tree-view':
return X_EXPLORE_FEEBACKS_CHANNEL_ID;
case 'x-charts':
return X_CHARTS_FEEBACKS_CHANNEL_ID;
case 'toolpad-studio':
case 'toolpad-core':
return TOOLPAD_FEEBACKS_CHANNEL_ID;
default:
break;
}

// Fallback

if (url.includes('/x/')) {
return X_FEEBACKS_CHANNEL_ID;
}
if (url.includes('/joy-ui/')) {
return JOY_FEEBACKS_CHANNEL_ID;
}
if (url.includes('/toolpad/')) {
return TOOLPAD_FEEBACKS_CHANNEL_ID;
}
return CORE_FEEBACKS_CHANNEL_ID;
};

Expand Down Expand Up @@ -154,6 +200,7 @@ export const handler: Handler = async (event, context, callback) => {
commmentSectionURL: inCommmentSectionURL,
commmentSectionTitle,
githubRepo,
productId,
} = data;

// The design feedback alert was removed in https://github.com/mui/material-ui/pull/39691
Expand Down Expand Up @@ -181,7 +228,7 @@ from ${commmentSectionURL}
});

await app.client.chat.postMessage({
channel: getSlackChannelId(currentLocationURL, { isDesignFeedback }),
channel: getSlackChannelId(currentLocationURL, productId, { isDesignFeedback }),
text: simpleSlackMessage, // Fallback for notification
blocks: [
{
Expand Down