-
Notifications
You must be signed in to change notification settings - Fork 126
/
index.js
62 lines (40 loc) 路 2.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createSelector} from 'reselect';
import {getConfig} from 'mattermost-redux/selectors/entities/general';
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import PluginId from 'plugin_id';
const getPluginState = (state) => state['plugins-' + PluginId] || {};
export const getPluginServerRoute = (state) => {
const config = getConfig(state);
let basePath = '';
if (config && config.SiteURL) {
basePath = new URL(config.SiteURL).pathname;
if (basePath && basePath[basePath.length - 1] === '/') {
basePath = basePath.substr(0, basePath.length - 1);
}
}
return basePath + '/plugins/' + PluginId;
};
export const getCurrentUserLocale = createSelector(
getCurrentUser,
(user) => {
let locale = 'en';
if (user && user.locale) {
locale = user.locale;
}
return locale;
}
);
export const isCreateModalVisible = (state) => getPluginState(state).createModalVisible;
export const getCreateModal = (state) => getPluginState(state).createModal;
export const isAttachCommentToIssueModalVisible = (state) => getPluginState(state).attachCommentToIssueModalVisible;
export const getAttachCommentToIssueModalForPostId = (state) => getPluginState(state).attachCommentToIssueModalForPostId;
export const getJiraIssueMetadata = (state) => getPluginState(state).jiraIssueMetadata;
export const getJiraProjectMetadata = (state) => getPluginState(state).jiraProjectMetadata;
export const getChannelIdWithSettingsOpen = (state) => getPluginState(state).channelIdWithSettingsOpen;
export const getChannelSubscriptions = (state) => getPluginState(state).channelSubscriptions;
export const isUserConnected = (state) => getPluginState(state).userConnected;
export const isInstanceInstalled = (state) => getPluginState(state).instanceInstalled;
export const getPluginSettings = (state) => getPluginState(state).pluginSettings;
export const getInstalledInstanceType = (state) => getPluginState(state).instanceType;