summaryrefslogtreecommitdiffstats
path: root/src/models/constants.ts
blob: 3f5aed68712a9f75dccc996247f41d6947d975a1 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
 * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
 *
 * @author John Molakvoæ <skjnldsv@protonmail.com>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
/// <reference types="@nextcloud/typings" />

import { translate as t } from '@nextcloud/l10n'

interface OC extends 	Nextcloud.Common.OC {
	Share: any
}
declare const OC: OC

export type CircleConfig = number
export type MemberLevel = number
export type MemberType = number

// Global sizes
export const LIST_SIZE = 60

// Dynamic groups
export const GROUP_ALL_CONTACTS = t('contacts', 'All contacts')
export const GROUP_NO_GROUP_CONTACTS = t('contacts', 'Not grouped')
export const GROUP_RECENTLY_CONTACTED = t('contactsinteraction', 'Recently contacted')

// Circle route, see vue-router conf
export const ROUTE_CIRCLE = 'circle'

// Default max number of items to show in the navigation
export const ELLIPSIS_COUNT = 5

// Circles member levels
const MEMBER_LEVEL_NONE: MemberLevel = 0
const MEMBER_LEVEL_MEMBER: MemberLevel = 1
const MEMBER_LEVEL_MODERATOR: MemberLevel = 4
const MEMBER_LEVEL_ADMIN: MemberLevel = 8
const MEMBER_LEVEL_OWNER: MemberLevel = 9

// Circles member types
const MEMBER_TYPE_SINGLEID: MemberType = 0
const MEMBER_TYPE_USER: MemberType = 1
const MEMBER_TYPE_GROUP : MemberType= 2
const MEMBER_TYPE_MAIL: MemberType = 4
const MEMBER_TYPE_CONTACT: MemberType = 8
const MEMBER_TYPE_CIRCLE: MemberType = 16

// Circles config flags
const CIRCLE_CONFIG_SYSTEM: CircleConfig = 4				// System Circle (not managed by the official front-end). Meaning some config are limited
const CIRCLE_CONFIG_VISIBLE: CircleConfig = 8				// Visible to everyone, if not visible, people have to know its name to be able to find it
const CIRCLE_CONFIG_OPEN: CircleConfig = 16					// Circle is open, people can join
const CIRCLE_CONFIG_INVITE: CircleConfig = 32				// Adding a member generate an invitation that needs to be accepted
const CIRCLE_CONFIG_REQUEST: CircleConfig = 64				// Request to join Circles needs to be confirmed by a moderator
const CIRCLE_CONFIG_FRIEND: CircleConfig = 128				// Members of the circle can invite their friends
const CIRCLE_CONFIG_PROTECTED: CircleConfig = 256			// Password protected to join/request
const CIRCLE_CONFIG_NO_OWNER: CircleConfig = 512			// no owner, only members
const CIRCLE_CONFIG_HIDDEN: CircleConfig = 1024				// hidden from listing, but available as a share entity
const CIRCLE_CONFIG_BACKEND: CircleConfig = 2048			// Fully hidden, only backend Circles
const CIRCLE_CONFIG_ROOT: CircleConfig = 4096				// Circle cannot be inside another Circle
const CIRCLE_CONFIG_CIRCLE_INVITE: CircleConfig = 8192		// Circle must confirm when invited in another circle
const CIRCLE_CONFIG_FEDERATED: CircleConfig = 16384			// Federated

export const CIRCLES_MEMBER_TYPES = {
	[MEMBER_TYPE_CIRCLE]: t('circles', 'Circle'),
	[MEMBER_TYPE_USER]: t('circles', 'User'),
	[MEMBER_TYPE_GROUP]: t('circles', 'Group'),
	[MEMBER_TYPE_MAIL]: t('circles', 'Mail'),
	[MEMBER_TYPE_CONTACT]: t('circles', 'Contact'),
}

export const CIRCLES_MEMBER_LEVELS = {
	// [MEMBER_LEVEL_NONE]: t('circles', 'None'),
	[MEMBER_LEVEL_MEMBER]: t('circles', 'Member'),
	[MEMBER_LEVEL_MODERATOR]: t('circles', 'Moderator'),
	[MEMBER_LEVEL_ADMIN]: t('circles', 'Admin'),
	[MEMBER_LEVEL_OWNER]: t('circles', 'Owner'),
}

export const PUBLIC_CIRCLE_CONFIG = {
	[t('contacts', 'Invites')]: {
		[CIRCLE_CONFIG_OPEN]: t('contacts', 'Open, anyone can join'),
		[CIRCLE_CONFIG_INVITE]: t('contacts', 'Members need to accept invitation'),
		[CIRCLE_CONFIG_REQUEST]: t('contacts', 'Members need to be accepted by a moderator'),
		[CIRCLE_CONFIG_FRIEND]: t('contacts', 'Members can also invite'),
		// Let's manage password protection independently as we also need a password
		// [CIRCLE_CONFIG_PROTECTED]: t('contacts', 'Password protect'),
	},

	[t('contacts', 'Visibility')]: {
		[CIRCLE_CONFIG_VISIBLE]: t('contacts', 'Visible to everyone'),
		[CIRCLE_CONFIG_HIDDEN]: t('contacts', 'Hide this circle from listings'),
	},

	[t('contacts', 'Circle membership')]: {
		[CIRCLE_CONFIG_CIRCLE_INVITE]: t('contacts', 'Circle must confirm when invited in another circle'),
		[CIRCLE_CONFIG_ROOT]: t('contacts', 'Prevent circle from being a member of another circle'),
	},
}


// Represents the picker options but also the 
// sorting of the members list
export const CIRCLES_MEMBER_GROUPING = [{
	id: `picker-${OC.Share.SHARE_TYPE_USER}`,
	label: t('contacts', 'Users'),
	type: MEMBER_TYPE_USER
}, {
	id: `picker-${OC.Share.SHARE_TYPE_EMAIL}`,
	label: t('contacts', 'Emails'),
	type: MEMBER_TYPE_MAIL
}, {
	id: `picker-${OC.Share.SHARE_TYPE_GROUP}`,
	label: t('contacts', 'Groups'),
	type: MEMBER_TYPE_GROUP
}, {
	id: `picker-${OC.Share.SHARE_TYPE_CIRCLE}`,
	label: t('contacts', 'Circles'),
	type: MEMBER_TYPE_CIRCLE
}]

export const SHARES_TYPES_MEMBER_MAP = {
	[OC.Share.SHARE_TYPE_CIRCLE]: MEMBER_TYPE_SINGLEID,
	[OC.Share.SHARE_TYPE_USER]: MEMBER_TYPE_USER,
	[OC.Share.SHARE_TYPE_GROUP]: MEMBER_TYPE_GROUP,
	[OC.Share.SHARE_TYPE_EMAIL]: MEMBER_TYPE_MAIL,
	// []: MEMBER_TYPE_CONTACT,
}

export enum MemberLevels {
	NONE = MEMBER_LEVEL_NONE,
	MEMBER = MEMBER_LEVEL_MEMBER,
	MODERATOR = MEMBER_LEVEL_MODERATOR,
	ADMIN = MEMBER_LEVEL_ADMIN,
	OWNER = MEMBER_LEVEL_OWNER,
}

export enum MemberTypes {
	CIRCLE = MEMBER_TYPE_CIRCLE,
	USER = MEMBER_TYPE_USER,
	GROUP = MEMBER_TYPE_GROUP,
	MAIL = MEMBER_TYPE_MAIL,
	CONTACT = MEMBER_TYPE_CONTACT,
}

export enum CircleConfigs {
	SYSTEM = CIRCLE_CONFIG_SYSTEM,
	VISIBLE = CIRCLE_CONFIG_VISIBLE,
	OPEN = CIRCLE_CONFIG_OPEN,
	INVITE = CIRCLE_CONFIG_INVITE,
	REQUEST = CIRCLE_CONFIG_REQUEST,
	FRIEND = CIRCLE_CONFIG_FRIEND,
	PROTECTED = CIRCLE_CONFIG_PROTECTED,
	NO_OWNER = CIRCLE_CONFIG_NO_OWNER,
	HIDDEN = CIRCLE_CONFIG_HIDDEN,
	BACKEND = CIRCLE_CONFIG_BACKEND,
	ROOT = CIRCLE_CONFIG_ROOT,
	CIRCLE_INVITE = CIRCLE_CONFIG_CIRCLE_INVITE,
	FEDERATED = CIRCLE_CONFIG_FEDERATED,
}