Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into interactive-dialog-…
Browse files Browse the repository at this point in the history
…errors
  • Loading branch information
BenCookie95 committed Oct 10, 2024
2 parents 881ca7a + fea92cd commit 0096900
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Mattermost Google Drive Plugin

[![CircleCI branch](https://img.shields.io/circleci/project/github/darkLord19/mattermost-plugin-google-drive/master.svg)](https://circleci.com/gh/darkLord19/mattermost-plugin-google-drive)
[![Release](https://img.shields.io/github/v/release/darkLord19/mattermost-plugin-google-drive)](https://github.com/darkLord19/mattermost-plugin-google-drive/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/darkLord19/mattermost-plugin-google-drive)](https://goreportcard.com/report/github.com/darkLord19/mattermost-plugin-google-drive)
[![HW](https://img.shields.io/github/issues/darkLord19/mattermost-plugin-google-drive/Up%20For%20Grabs?color=dark%20green&label=Help%20Wanted)](https://github.com/darkLord19/mattermost-plugin-google-drive/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Up+For+Grabs%22+label%3A%22Help+Wanted%22)
[![CircleCI branch](https://img.shields.io/circleci/project/github/mattermost/mattermost-plugin-google-drive/master.svg)](https://circleci.com/gh/mattermost/mattermost-plugin-google-drive)
[![Release](https://img.shields.io/github/v/release/mattermost/mattermost-plugin-google-drive)](https://github.com/mattermost/mattermost-plugin-google-drive/releases/latest)
[![Go Report Card](https://goreportcard.com/badge/github.com/mattermost/mattermost-plugin-google-drive)](https://goreportcard.com/report/github.com/mattermost/mattermost-plugin-google-drive)
[![HW](https://img.shields.io/github/issues/mattermost/mattermost-plugin-google-drive/Up%20For%20Grabs?color=dark%20green&label=Help%20Wanted)](https://github.com/mattermost/mattermost-plugin-google-drive/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22Up+For+Grabs%22+label%3A%22Help+Wanted%22)
[![Mattermost Community Channel](https://img.shields.io/badge/Mattermost%20Community-~Plugin%3A%20GoogleDrive-blue)](https://community.mattermost.com/core/channels/plugin-googledrive)

**Help Wanted Tickets [here](https://github.com/darkLord19/mattermost-plugin-google-drive/issues)**
**Help Wanted Tickets [here](https://github.com/mattermost/mattermost-plugin-google-drive/issues)**

# Contents

Expand Down Expand Up @@ -69,7 +69,7 @@ After your System Admin has configured the Google Drive plugin, run `/google-dri

Wanting to share feedback on this plugin?

Feel free to create a [GitHub Issue](https://github.com/darkLord19/mattermost-plugin-google-drive/issues) or join the [Google Drive Plugin channel](https://community.mattermost.com/core/channels/plugin-googledrive) on the Mattermost Community server to discuss.
Feel free to create a [GitHub Issue](https://github.com/mattermost/mattermost-plugin-google-drive/issues) or join the [Google Drive Plugin channel](https://community.mattermost.com/core/channels/plugin-googledrive) on the Mattermost Community server to discuss.

## Contribute

Expand All @@ -95,4 +95,4 @@ Please report any security vulnerability to [https://mattermost.com/security-vul

## Get Help

For questions, suggestions, and help, visit the [Google Drive Plugin channel](https://community.mattermost.com/core/channels/plugin-googledrive) on our Community server.
For questions, suggestions, and help, visit the [Google Drive Plugin channel](https://community.mattermost.com/core/channels/plugin-googledrive) on our Community server.
2 changes: 1 addition & 1 deletion server/plugin/plugin_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p *Plugin) getAllChannelUsers(channelID string) []*model.User {
perPage := 100
allUsers := make([]*model.User, 0)
for {
users, appErr := p.API.GetUsers(&model.UserGetOptions{InChannelId: channelID, Page: page, PerPage: perPage})
users, appErr := p.API.GetUsersInChannel(channelID, "username", page, perPage)
if appErr != nil || len(users) == 0 {
break
}
Expand Down
41 changes: 34 additions & 7 deletions webapp/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Store, Action} from 'redux';
import {GlobalState} from '@mattermost/types/lib/store';
import {Client4} from 'mattermost-redux/client';
import {GlobalState} from 'mattermost-redux/types/store';
import {getPost} from 'mattermost-redux/selectors/entities/posts';
import {makeGetFilesForPost} from 'mattermost-redux/selectors/entities/files';

import manifest from '@/manifest';
import {PluginRegistry} from '@/types/mattermost-webapp';
Expand All @@ -12,10 +13,13 @@ export default class Plugin {
registry: PluginRegistry,
store: Store<GlobalState, Action<Record<string, unknown>>>,
) {
const getFilesForPost = makeGetFilesForPost();

registry.registerPostDropdownMenuAction(
'Upload file to Google Drive',
async (postID: string) => {
const fileInfos = await Client4.getFileInfosForPost(postID);
(postID: string) => {
const state = store.getState();
const fileInfos = getFilesForPost(state, postID);
if (fileInfos.length === 0) {
sendEphemeralPost(
'Selected post doesn\'t have any files to be uploaded',
Expand Down Expand Up @@ -48,13 +52,25 @@ export default class Plugin {
// Open the modal
window.openInteractiveDialog(modal);
},
(postID: string) => {
const state = store.getState();
const post = getPost(state, postID);
if (!post) {
return false;
}
if (!post.file_ids || post.file_ids.length === 0) {
return false;
}
return true;
},
);

registry.registerPostDropdownMenuAction(
'Upload all files to Google Drive',
async (postID: string) => {
const fileInfos = await Client4.getFileInfosForPost(postID);
if (fileInfos.length === 0) {
(postID: string) => {
const state = store.getState();
const post = getPost(state, postID);
if (post.file_ids && post.file_ids.length === 0) {
sendEphemeralPost(
'Selected post doesn\'t have any files to be uploaded',
)(store.dispatch, store.getState);
Expand All @@ -73,6 +89,17 @@ export default class Plugin {

window.openInteractiveDialog(modal);
},
(postID: string) => {
const state = store.getState();
const post = getPost(state, postID);
if (!post) {
return false;
}
if (!post.file_ids || post.file_ids.length < 2) {
return false;
}
return true;
},
);
}
}
Expand Down

0 comments on commit 0096900

Please sign in to comment.