Skip to content

Commit 24630bf

Browse files
authored
Merge pull request #12 from StackExchange/PS-425-question-modal
Huge enhancement to the Post Question modal component
2 parents 5804bf5 + 0443ff3 commit 24630bf

8 files changed

Lines changed: 1756 additions & 167 deletions

File tree

plugins/stack-overflow-teams-backend/src/router.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ export async function createRouter({
283283
.status(401)
284284
.json({ error: 'Missing Stack Overflow Teams Access Token' });
285285
}
286-
const tags = await stackOverflowService.getTags(authToken);
286+
const search = req.query.search as string | undefined;
287+
const tags = await stackOverflowService.getTags(authToken, search);
287288
return res.send(tags);
288289
} catch (error: any) {
289290
logger.error('Error fetching tags', { error });

plugins/stack-overflow-teams-backend/src/services/StackOverflowService/createStackOverflowService.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ export async function createStackOverflowService({
3636
// GET
3737
getQuestions: authToken =>
3838
api.GET<PaginatedResponse<Question>>('/questions', authToken, teamName, { sort: 'creation', order: 'desc' }),
39-
getTags: authToken =>
40-
api.GET<PaginatedResponse<Tag>>('/tags', authToken, teamName, { sort: 'creationDate', order: 'desc'}),
39+
getTags: (authToken, search?: string) => {
40+
const params: Record<string, string> = { sort: 'postCount', order: 'desc' };
41+
if (search) {
42+
params.partialName = search;
43+
}
44+
return api.GET<PaginatedResponse<Tag>>('/tags', authToken, teamName, params);
45+
},
4146
getUsers: authToken =>
4247
api.GET<PaginatedResponse<User>>('/users', authToken, teamName),
4348
getMe: authToken => api.GET<User>('/users/me', authToken, teamName),
@@ -63,4 +68,4 @@ export async function createStackOverflowService({
6368
teamName,
6469
),
6570
};
66-
}
71+
}

plugins/stack-overflow-teams-backend/src/services/StackOverflowService/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type StackOverflowConfig = {
6262

6363
export interface StackOverflowAPI {
6464
getQuestions(authToken: string): Promise<PaginatedResponse<Question>>;
65-
getTags(authToken: string): Promise<PaginatedResponse<Tag>>;
65+
getTags(authToken: string, search?: string): Promise<PaginatedResponse<Tag>>;
6666
getUsers(authToken: string): Promise<PaginatedResponse<User>>;
6767
getMe(authToken: string): Promise<User>;
6868
postQuestions(

plugins/stack-overflow-teams/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@
4040
"@backstage/plugin-search-react": "^1.8.6",
4141
"@backstage/theme": "^0.6.3",
4242
"@emotion/react": "^11.14.0",
43-
"@emotion/styled": "^11.14.0",
43+
"@emotion/styled": "^11.14.1",
4444
"@material-ui/core": "^4.9.13",
4545
"@material-ui/icons": "^4.9.1",
4646
"@material-ui/lab": "^4.0.0-alpha.61",
47-
"@mui/icons-material": "^7.1.0",
47+
"@mui/icons-material": "^7.2.0",
4848
"@mui/material": "5.16.14",
49+
"@tiptap/core": "^3.0.7",
50+
"@tiptap/extension-heading": "^3.0.7",
51+
"@tiptap/extension-image": "^3.0.7",
52+
"@tiptap/extension-table": "^3.0.7",
53+
"@tiptap/extensions": "^3.0.7",
54+
"@tiptap/pm": "^3.0.7",
55+
"@tiptap/react": "^3.0.7",
56+
"@tiptap/starter-kit": "^3.0.7",
4957
"react-use": "^17.2.4"
5058
},
5159
"peerDependencies": {

plugins/stack-overflow-teams/src/api/StackOverflowAPI.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface BaseUrlResponse {
1919
export interface StackOverflowAPI {
2020
search(query: string): Promise<any>;
2121
getQuestions(): Promise<ApiResponse<Question>>;
22-
getTags(): Promise<ApiResponse<Tag>>;
22+
getTags(search?: string): Promise<ApiResponse<Tag>>;
2323
getUsers(): Promise<ApiResponse<User>>;
2424
getMe(): Promise<User>;
2525
getBaseUrl(): Promise<string>;
@@ -66,7 +66,10 @@ export const createStackOverflowApi = (
6666
return {
6767
search: (query: string) => requestAPI<any>('search', 'POST', { query }),
6868
getQuestions: () => requestAPI<ApiResponse<Question>>('questions'),
69-
getTags: () => requestAPI<ApiResponse<Tag>>('tags'),
69+
getTags: (search?: string) => {
70+
const params = search ? [`search=${encodeURIComponent(search)}`] : undefined;
71+
return requestAPI<ApiResponse<Tag>>('tags', 'GET', undefined, params);
72+
},
7073
getUsers: () => requestAPI<ApiResponse<User>>('users'),
7174
getMe: () => requestAPI<User>('me'),
7275
getBaseUrl: async () => {

0 commit comments

Comments
 (0)