MM-54416: Channel Bookmarks Web UI (#25889)
Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com> Co-authored-by: Miguel de la Cruz <miguel@mcrx.me> Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
a5d263f26c
Коммит
f12eb75d25
@@ -10,6 +10,7 @@ import type {AppBinding, AppCallRequest, AppCallResponse} from '@mattermost/type
|
||||
import type {Audit} from '@mattermost/types/audits';
|
||||
import type {UserAutocomplete, AutocompleteSuggestion} from '@mattermost/types/autocomplete';
|
||||
import type {Bot, BotPatch} from '@mattermost/types/bots';
|
||||
import type {ChannelBookmark, ChannelBookmarkCreate, ChannelBookmarkPatch} from '@mattermost/types/channel_bookmarks';
|
||||
import type {ChannelCategory, OrderedChannelCategories} from '@mattermost/types/channel_categories';
|
||||
import type {
|
||||
Channel,
|
||||
@@ -314,6 +315,12 @@ export default class Client4 {
|
||||
getChannelSchemeRoute(channelId: string) {
|
||||
return `${this.getChannelRoute(channelId)}/scheme`;
|
||||
}
|
||||
getChannelBookmarksRoute(channelId: string) {
|
||||
return `${this.getChannelRoute(channelId)}/bookmarks`;
|
||||
}
|
||||
getChannelBookmarkRoute(channelId: string, bookmarkId: string) {
|
||||
return `${this.getChannelRoute(channelId)}/bookmarks/${bookmarkId}`;
|
||||
}
|
||||
|
||||
getChannelCategoriesRoute(userId: string, teamId: string) {
|
||||
return `${this.getBaseRoute()}/users/${userId}/teams/${teamId}/channels/categories`;
|
||||
@@ -1605,7 +1612,15 @@ export default class Client4 {
|
||||
includeDeleted: boolean | undefined,
|
||||
excludePolicyConstrained: boolean | undefined
|
||||
): Promise<ChannelsWithTotalCount>;
|
||||
getAllChannels(page = 0, perPage = PER_PAGE_DEFAULT, notAssociatedToGroup = '', excludeDefaultChannels = false, includeTotalCount = false, includeDeleted = false, excludePolicyConstrained = false) {
|
||||
getAllChannels(
|
||||
page = 0,
|
||||
perPage = PER_PAGE_DEFAULT,
|
||||
notAssociatedToGroup = '',
|
||||
excludeDefaultChannels = false,
|
||||
includeTotalCount = false,
|
||||
includeDeleted = false,
|
||||
excludePolicyConstrained = false,
|
||||
) {
|
||||
const queryData = {
|
||||
page,
|
||||
per_page: perPage,
|
||||
@@ -1961,7 +1976,44 @@ export default class Client4 {
|
||||
);
|
||||
};
|
||||
|
||||
// Channel Category Routes
|
||||
// Channel Bookmark Routes
|
||||
|
||||
getChannelBookmarks = (channelId: string, bookmarksSince?: number) => {
|
||||
return this.doFetch<ChannelBookmark[]>(
|
||||
`${this.getChannelBookmarksRoute(channelId)}${buildQueryString({bookmarks_since: bookmarksSince})}`,
|
||||
{method: 'get'},
|
||||
);
|
||||
};
|
||||
|
||||
createChannelBookmark = (channelId: string, channelBookmark: ChannelBookmarkCreate, connectionId: string) => {
|
||||
return this.doFetch<ChannelBookmark>(
|
||||
`${this.getChannelBookmarksRoute(channelId)}`,
|
||||
{method: 'post', body: JSON.stringify(channelBookmark), headers: {'Connection-Id': connectionId}},
|
||||
);
|
||||
};
|
||||
|
||||
deleteChannelBookmark = (channelId: string, channelBookmarkId: string, connectionId: string) => {
|
||||
return this.doFetch<ChannelBookmark>(
|
||||
`${this.getChannelBookmarkRoute(channelId, channelBookmarkId)}`,
|
||||
{method: 'delete', headers: {'Connection-Id': connectionId}},
|
||||
);
|
||||
};
|
||||
|
||||
updateChannelBookmark = (channelId: string, channelBookmarkId: string, patch: ChannelBookmarkPatch, connectionId: string) => {
|
||||
return this.doFetch<{updated: ChannelBookmark; deleted: ChannelBookmark}>(
|
||||
`${this.getChannelBookmarkRoute(channelId, channelBookmarkId)}`,
|
||||
{method: 'PATCH', body: JSON.stringify(patch), headers: {'Connection-Id': connectionId}},
|
||||
);
|
||||
};
|
||||
|
||||
updateChannelBookmarkSortOrder = (channelId: string, channelBookmarkId: string, newOrder: number, connectionId: string) => {
|
||||
return this.doFetch<ChannelBookmark[]>(
|
||||
`${this.getChannelBookmarksRoute(channelId)}/${channelBookmarkId}/sort_order`,
|
||||
{method: 'post', body: JSON.stringify(newOrder), headers: {'Connection-Id': connectionId}},
|
||||
);
|
||||
};
|
||||
|
||||
// Channel Category Routes
|
||||
|
||||
getChannelCategories = (userId: string, teamId: string) => {
|
||||
return this.doFetch<OrderedChannelCategories>(
|
||||
@@ -2383,7 +2435,7 @@ export default class Client4 {
|
||||
return url;
|
||||
}
|
||||
|
||||
uploadFile = (fileFormData: any) => {
|
||||
uploadFile = (fileFormData: any, isBookmark?: boolean) => {
|
||||
this.trackEvent('api', 'api_files_upload');
|
||||
const request: any = {
|
||||
method: 'post',
|
||||
@@ -2391,7 +2443,7 @@ export default class Client4 {
|
||||
};
|
||||
|
||||
return this.doFetch<FileUploadResponse>(
|
||||
`${this.getFilesRoute()}`,
|
||||
`${this.getFilesRoute()}${buildQueryString({bookmark: isBookmark})}`,
|
||||
request,
|
||||
);
|
||||
};
|
||||
|
||||
Ссылка в новой задаче
Block a user