Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72896a66b3 | ||
|
|
4be4783251 | ||
|
|
5c6c6a0bcf | ||
|
|
ba178d66fa | ||
|
|
270ce29f87 | ||
|
|
de1ed3c784 | ||
|
|
caf8790f28 | ||
|
|
81436b373d | ||
|
|
cc1e886a31 | ||
|
|
f0e9fe7904 | ||
|
|
5fcea5d651 | ||
|
|
a963d85a66 | ||
|
|
04b42decef | ||
|
|
c065566c15 | ||
|
|
3779bdb053 | ||
|
|
4124ab17d2 |
@@ -0,0 +1,53 @@
|
||||
name: "🐛 Bug Report"
|
||||
description: Report a bug found while using Planka
|
||||
title: "[Bug]: "
|
||||
labels: ["Type: Bug", "Status: Triage"]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: issue-type
|
||||
attributes:
|
||||
label: Where is the problem occurring?
|
||||
description: Select the part of the application where you encountered the issue.
|
||||
options:
|
||||
- "I encountered the problem while using the application (Frontend)"
|
||||
- "I encountered the problem while interacting with the server (Backend)"
|
||||
- "I'm not sure"
|
||||
- type: dropdown
|
||||
id: browsers
|
||||
attributes:
|
||||
label: What browsers are you seeing the problem on?
|
||||
multiple: true
|
||||
options:
|
||||
- Brave
|
||||
- Chrome
|
||||
- Firefox
|
||||
- Microsoft Edge
|
||||
- Safari
|
||||
- Other
|
||||
- type: textarea
|
||||
id: current-behavior
|
||||
attributes:
|
||||
label: Current behaviour
|
||||
description: A description of what is currently happening, including screenshots and other useful information (**DO NOT INCLUDE PRIVATE INFORMATION**).
|
||||
placeholder: Currently...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: desired-behavior
|
||||
attributes:
|
||||
label: Desired behaviour
|
||||
description: A clear description of what you think should happen.
|
||||
placeholder: In this situation, I expected ...
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Clearly describe which steps or actions you have taken to arrive at the problem. If you have some experience with the code, please link to the specific pieces of code.
|
||||
placeholder: I did X, then Y, before arriving at Z, when ERROR ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: other
|
||||
attributes:
|
||||
label: Other information
|
||||
description: Any other details?
|
||||
@@ -0,0 +1,33 @@
|
||||
name: "✨ Feature Request"
|
||||
description: Suggest a feature or enhancement to improve Planka.
|
||||
labels: ["Type: Idea"]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: idea-type
|
||||
attributes:
|
||||
label: Is this a feature for the backend or frontend?
|
||||
multiple: true
|
||||
options:
|
||||
- Backend
|
||||
- Frontend
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: feature
|
||||
attributes:
|
||||
label: What would you like?
|
||||
description: A clear description of the feature or enhancement wanted.
|
||||
placeholder: I'd like to be able to...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reason
|
||||
attributes:
|
||||
label: Why is this needed?
|
||||
description: A clear description of why this would be useful to have.
|
||||
placeholder: I want this because...
|
||||
- type: textarea
|
||||
id: other
|
||||
attributes:
|
||||
label: Other information
|
||||
placeholder: Any other details?
|
||||
@@ -15,13 +15,13 @@ type: application
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.33
|
||||
version: 0.2.2
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "1.17.5"
|
||||
appVersion: "1.19.1"
|
||||
|
||||
dependencies:
|
||||
- alias: postgresql
|
||||
|
||||
@@ -90,17 +90,37 @@ spec:
|
||||
value: http://localhost:3000
|
||||
{{- end }}
|
||||
- name: SECRET_KEY
|
||||
{{- if .Values.existingSecretkeySecret }}
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.existingSecretkeySecret }}
|
||||
key: key
|
||||
{{- else }}
|
||||
value: {{ required "A secret key needs to be generated using 'openssl rand -hex 64' and assigned to secretkey." .Values.secretkey }}
|
||||
{{- end }}
|
||||
- name: TRUST_PROXY
|
||||
value: "0"
|
||||
- name: DEFAULT_ADMIN_EMAIL
|
||||
value: {{ .Values.admin_email }}
|
||||
- name: DEFAULT_ADMIN_PASSWORD
|
||||
value: {{ .Values.admin_password }}
|
||||
- name: DEFAULT_ADMIN_NAME
|
||||
value: {{ .Values.admin_name }}
|
||||
{{- if .Values.existingAdminCredsSecret }}
|
||||
- name: DEFAULT_ADMIN_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.existingAdminCredsSecret }}
|
||||
key: username
|
||||
- name: DEFAULT_ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ .Values.existingAdminCredsSecret }}
|
||||
key: password
|
||||
{{- else }}
|
||||
- name: DEFAULT_ADMIN_USERNAME
|
||||
value: {{ .Values.admin_username }}
|
||||
- name: DEFAULT_ADMIN_PASSWORD
|
||||
value: {{ .Values.admin_password }}
|
||||
{{- end }}
|
||||
{{ range $k, $v := .Values.env }}
|
||||
- name: {{ $k | quote }}
|
||||
value: {{ $v | quote }}
|
||||
|
||||
@@ -17,6 +17,16 @@ fullnameOverride: ""
|
||||
# Generate a secret using openssl rand -base64 45
|
||||
secretkey: ""
|
||||
|
||||
## @param existingSecretkeySecret Name of an existing secret containing the session key string
|
||||
## NOTE: Must contain key `key`
|
||||
## NOTE: When it's set, the secretkey parameter is ignored
|
||||
existingSecretkeySecret: ""
|
||||
|
||||
## @param existingAdminCredsSecret Name of an existing secret containing the admin username and password
|
||||
## NOTE: Must contain keys `username` and `password`
|
||||
## NOTE: When it's set, the `admin_username` and `admin_password` parameters are ignored
|
||||
existingAdminCredsSecret: ""
|
||||
|
||||
# Base url for Planka. Will override `ingress.hosts[0].host`
|
||||
# Defaults to `http://localhost:3000` if ingress is disabled.
|
||||
baseUrl: ""
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
REACT_APP_VERSION=1.17.5
|
||||
REACT_APP_VERSION=1.19.1
|
||||
|
||||
@@ -5,6 +5,7 @@ import TextareaAutosize from 'react-textarea-autosize';
|
||||
import { Button, Form, TextArea } from 'semantic-ui-react';
|
||||
|
||||
import { useClosableForm, useField } from '../../hooks';
|
||||
import { focusEnd } from '../../utils/element-helpers';
|
||||
|
||||
import styles from './NameEdit.module.scss';
|
||||
|
||||
@@ -79,7 +80,7 @@ const NameEdit = React.forwardRef(({ children, defaultValue, onUpdate }, ref) =>
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpened) {
|
||||
field.current.ref.current.focus();
|
||||
focusEnd(field.current.ref.current);
|
||||
}
|
||||
}, [isOpened]);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import TextareaAutosize from 'react-textarea-autosize';
|
||||
import { Button, Form, TextArea } from 'semantic-ui-react';
|
||||
|
||||
import { useForm } from '../../../hooks';
|
||||
import { focusEnd } from '../../../utils/element-helpers';
|
||||
|
||||
import styles from './CommentEdit.module.scss';
|
||||
|
||||
@@ -70,7 +71,7 @@ const CommentEdit = React.forwardRef(({ children, defaultData, onUpdate }, ref)
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpened) {
|
||||
textField.current.ref.current.focus();
|
||||
focusEnd(textField.current.ref.current);
|
||||
}
|
||||
}, [isOpened]);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import React, { useCallback, useRef, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -81,6 +81,7 @@ const CardModal = React.memo(
|
||||
onClose,
|
||||
}) => {
|
||||
const [t] = useTranslation();
|
||||
const [isLinkCopied, setIsLinkCopied] = useState(false);
|
||||
|
||||
const isGalleryOpened = useRef(false);
|
||||
|
||||
@@ -146,6 +147,14 @@ const CardModal = React.memo(
|
||||
onClose();
|
||||
}, [onDuplicate, onClose]);
|
||||
|
||||
const handleCopyLinkClick = useCallback(() => {
|
||||
navigator.clipboard.writeText(window.location.href);
|
||||
setIsLinkCopied(true);
|
||||
setTimeout(() => {
|
||||
setIsLinkCopied(false);
|
||||
}, 5000);
|
||||
}, []);
|
||||
|
||||
const handleGalleryOpen = useCallback(() => {
|
||||
isGalleryOpened.current = true;
|
||||
}, []);
|
||||
@@ -506,6 +515,14 @@ const CardModal = React.memo(
|
||||
<Icon name="copy outline" className={styles.actionIcon} />
|
||||
{t('action.duplicate')}
|
||||
</Button>
|
||||
<Button fluid className={styles.actionButton} onClick={handleCopyLinkClick}>
|
||||
<Icon name={isLinkCopied ? 'linkify' : 'unlink'} className={styles.actionIcon} />
|
||||
{isLinkCopied
|
||||
? t('common.linkIsCopied')
|
||||
: t('action.copyLink', {
|
||||
context: 'title',
|
||||
})}
|
||||
</Button>
|
||||
<DeletePopup
|
||||
title="common.deleteCard"
|
||||
content="common.areYouSureYouWantToDeleteThisCard"
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
.actionIcon {
|
||||
color: #17394d;
|
||||
display: inline;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import TextareaAutosize from 'react-textarea-autosize';
|
||||
import { Button, Form, TextArea } from 'semantic-ui-react';
|
||||
|
||||
import { useField } from '../../../hooks';
|
||||
import { focusEnd } from '../../../utils/element-helpers';
|
||||
|
||||
import styles from './NameEdit.module.scss';
|
||||
|
||||
@@ -65,7 +66,7 @@ const NameEdit = React.forwardRef(({ children, defaultValue, onUpdate }, ref) =>
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpened) {
|
||||
field.current.ref.current.focus();
|
||||
focusEnd(field.current.ref.current);
|
||||
}
|
||||
}, [isOpened]);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import TextareaAutosize from 'react-textarea-autosize';
|
||||
import { TextArea } from 'semantic-ui-react';
|
||||
|
||||
import { useField } from '../../hooks';
|
||||
import { focusEnd } from '../../utils/element-helpers';
|
||||
|
||||
import styles from './NameEdit.module.scss';
|
||||
|
||||
@@ -71,7 +72,7 @@ const NameEdit = React.forwardRef(({ children, defaultValue, onUpdate }, ref) =>
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpened) {
|
||||
field.current.ref.current.select();
|
||||
focusEnd(field.current.ref.current);
|
||||
}
|
||||
}, [isOpened]);
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@ import entryActions from '../entry-actions';
|
||||
import Projects from '../components/Projects';
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const { allowAllToCreateProjects } = selectors.selectConfig(state);
|
||||
const { isAdmin } = selectors.selectCurrentUser(state);
|
||||
const projects = selectors.selectProjectsForCurrentUser(state);
|
||||
|
||||
return {
|
||||
items: projects,
|
||||
canAdd: isAdmin,
|
||||
canAdd: allowAllToCreateProjects || isAdmin,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ export default {
|
||||
language: 'Sprache',
|
||||
leaveBoard_title: 'Board verlassen',
|
||||
leaveProject_title: 'Projekt verlassen',
|
||||
linkIsCopied: 'Link kopiert',
|
||||
list: 'Listen',
|
||||
listActions_title: 'Aufgaben auflisten',
|
||||
managers: 'Manager',
|
||||
@@ -169,6 +170,7 @@ export default {
|
||||
addTask: 'Aufgabe hinzufügen',
|
||||
addToCard: 'Zu Karte hinzufügen',
|
||||
addUser: 'Benutzer hinzufügen',
|
||||
copyLink_title: 'Link kopieren',
|
||||
createBoard: 'Board erstellen',
|
||||
createFile: 'Datei erstellen',
|
||||
createLabel: 'Label erstellen',
|
||||
|
||||
@@ -106,6 +106,7 @@ export default {
|
||||
language: 'Language',
|
||||
leaveBoard_title: 'Leave Board',
|
||||
leaveProject_title: 'Leave Project',
|
||||
linkIsCopied: 'Link is copied',
|
||||
list: 'List',
|
||||
listActions_title: 'List Actions',
|
||||
managers: 'Managers',
|
||||
@@ -183,6 +184,7 @@ export default {
|
||||
addTask: 'Add task',
|
||||
addToCard: 'Add to card',
|
||||
addUser: 'Add user',
|
||||
copyLink_title: 'Copy Link',
|
||||
createBoard: 'Create board',
|
||||
createFile: 'Create file',
|
||||
createLabel: 'Create label',
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const focusEnd = (element) => {
|
||||
element.focus();
|
||||
element.setSelectionRange(element.value.length + 1, element.value.length + 1);
|
||||
};
|
||||
+14
-4
@@ -1,7 +1,6 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
||||
server:
|
||||
build:
|
||||
context: ./server
|
||||
@@ -13,6 +12,7 @@ services:
|
||||
- NODE_ENV=development
|
||||
- DATABASE_URL=postgresql://user:password@postgres:5432/planka_db
|
||||
- SECRET_KEY=notsecretkey
|
||||
|
||||
# - TRUST_PROXY=0
|
||||
# - TOKEN_EXPIRES_IN=365 # In days
|
||||
|
||||
@@ -23,6 +23,9 @@ services:
|
||||
|
||||
# Configure knex to accept SSL certificates
|
||||
# - KNEX_REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false
|
||||
|
||||
# - ALLOW_ALL_TO_CREATE_PROJECTS=true
|
||||
|
||||
# - OIDC_ISSUER=
|
||||
# - OIDC_CLIENT_ID=
|
||||
# - OIDC_CLIENT_SECRET=
|
||||
@@ -45,9 +48,17 @@ services:
|
||||
# - SMTP_PASSWORD=
|
||||
# - SMTP_FROM="Demo Demo" <demo@demo.demo>
|
||||
|
||||
# Optional fields: accessToken, events, excludedEvents
|
||||
# - |
|
||||
# WEBHOOKS=[{
|
||||
# "url": "http://localhost:3001",
|
||||
# "accessToken": "notaccesstoken",
|
||||
# "events": ["cardCreate", "cardUpdate", "cardDelete"],
|
||||
# "excludedEvents": ["notificationCreate", "notificationUpdate"]
|
||||
# }]
|
||||
|
||||
# - SLACK_BOT_TOKEN=
|
||||
# - SLACK_CHANNEL_ID=
|
||||
|
||||
working_dir: /app
|
||||
command: ["sh", "-c", "npm run start"]
|
||||
depends_on:
|
||||
@@ -76,11 +87,11 @@ services:
|
||||
dockerfile: ../config/development/Dockerfile.server
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://user:password@postgres:5432/planka_db
|
||||
|
||||
# - DEFAULT_ADMIN_EMAIL=demo@demo.demo # Do not remove if you want to prevent this user from being edited/deleted
|
||||
# - DEFAULT_ADMIN_PASSWORD=demo
|
||||
# - DEFAULT_ADMIN_NAME=Demo Demo
|
||||
# - DEFAULT_ADMIN_USERNAME=demo
|
||||
|
||||
working_dir: /app
|
||||
command: ["sh", "-c", "npm run db:init"]
|
||||
volumes:
|
||||
@@ -117,6 +128,5 @@ services:
|
||||
- server
|
||||
- client
|
||||
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
|
||||
@@ -31,6 +31,8 @@ services:
|
||||
# - DEFAULT_ADMIN_NAME=Demo Demo
|
||||
# - DEFAULT_ADMIN_USERNAME=demo
|
||||
|
||||
# - ALLOW_ALL_TO_CREATE_PROJECTS=true
|
||||
|
||||
# - OIDC_ISSUER=
|
||||
# - OIDC_CLIENT_ID=
|
||||
# - OIDC_CLIENT_SECRET=
|
||||
@@ -53,6 +55,15 @@ services:
|
||||
# - SMTP_PASSWORD=
|
||||
# - SMTP_FROM="Demo Demo" <demo@demo.demo>
|
||||
|
||||
# Optional fields: accessToken, events, excludedEvents
|
||||
# - |
|
||||
# WEBHOOKS=[{
|
||||
# "url": "http://localhost:3001",
|
||||
# "accessToken": "notaccesstoken",
|
||||
# "events": ["cardCreate", "cardUpdate", "cardDelete"],
|
||||
# "excludedEvents": ["notificationCreate", "notificationUpdate"]
|
||||
# }]
|
||||
|
||||
# - SLACK_BOT_TOKEN=
|
||||
# - SLACK_CHANNEL_ID=
|
||||
depends_on:
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "planka",
|
||||
"version": "1.17.5",
|
||||
"version": "1.19.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "planka",
|
||||
"version": "1.17.5",
|
||||
"version": "1.19.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "planka",
|
||||
"version": "1.17.5",
|
||||
"version": "1.19.1",
|
||||
"private": true,
|
||||
"homepage": "https://plankanban.github.io/planka",
|
||||
"repository": {
|
||||
|
||||
@@ -22,6 +22,8 @@ SECRET_KEY=notsecretkey
|
||||
# DEFAULT_ADMIN_NAME=Demo Demo
|
||||
# DEFAULT_ADMIN_USERNAME=demo
|
||||
|
||||
# ALLOW_ALL_TO_CREATE_PROJECTS=true
|
||||
|
||||
# OIDC_ISSUER=
|
||||
# OIDC_CLIENT_ID=
|
||||
# OIDC_CLIENT_SECRET=
|
||||
@@ -43,6 +45,14 @@ SECRET_KEY=notsecretkey
|
||||
# SMTP_PASSWORD=
|
||||
# SMTP_FROM="Demo Demo" <demo@demo.demo>
|
||||
|
||||
# Optional fields: accessToken, events, excludedEvents
|
||||
# WEBHOOKS='[{
|
||||
# "url": "http://localhost:3001",
|
||||
# "accessToken": "notaccesstoken",
|
||||
# "events": ["cardCreate", "cardUpdate", "cardDelete"],
|
||||
# "excludedEvents": ["notificationCreate", "notificationUpdate"]
|
||||
# }]'
|
||||
|
||||
# SLACK_BOT_TOKEN=
|
||||
# SLACK_CHANNEL_ID=
|
||||
|
||||
|
||||
@@ -44,12 +44,12 @@ module.exports = {
|
||||
async fn(inputs, exits) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { card } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -83,6 +83,9 @@ module.exports = {
|
||||
const fileData = await sails.helpers.attachments.processUploadedFile(file);
|
||||
|
||||
const attachment = await sails.helpers.attachments.createOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
...fileData,
|
||||
card,
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.ATTACHMENT_NOT_FOUND);
|
||||
|
||||
let { attachment } = path;
|
||||
const { card, board } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
@@ -49,9 +49,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
attachment = await sails.helpers.attachments.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: attachment,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.ATTACHMENT_NOT_FOUND);
|
||||
|
||||
let { attachment } = path;
|
||||
const { board } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
@@ -56,8 +56,12 @@ module.exports = {
|
||||
|
||||
attachment = await sails.helpers.attachments.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: attachment,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -48,14 +48,11 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.boards
|
||||
const { board, project } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(
|
||||
currentUser.id,
|
||||
board.projectId,
|
||||
);
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
if (!isProjectManager) {
|
||||
throw Errors.BOARD_NOT_FOUND; // Forbidden
|
||||
@@ -71,11 +68,13 @@ module.exports = {
|
||||
|
||||
const boardMembership = await sails.helpers.boardMemberships.createOne
|
||||
.with({
|
||||
project,
|
||||
values: {
|
||||
...values,
|
||||
board,
|
||||
user,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('userAlreadyBoardMember', () => Errors.USER_ALREADY_BOARD_MEMBER);
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.BOARD_MEMBERSHIP_NOT_FOUND);
|
||||
|
||||
let { boardMembership } = path;
|
||||
const { project } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
if (boardMembership.userId !== currentUser.id) {
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(
|
||||
@@ -42,7 +42,9 @@ module.exports = {
|
||||
|
||||
boardMembership = await sails.helpers.boardMemberships.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
record: boardMembership,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.BOARD_MEMBERSHIP_NOT_FOUND);
|
||||
|
||||
let { boardMembership } = path;
|
||||
const { project } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
@@ -47,7 +47,10 @@ module.exports = {
|
||||
|
||||
boardMembership = await sails.helpers.boardMemberships.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
record: boardMembership,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ module.exports = {
|
||||
project,
|
||||
},
|
||||
import: boardImport,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
requestId: inputs.requestId,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
@@ -22,25 +22,27 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { board } = await sails.helpers.boards
|
||||
const path = await sails.helpers.boards
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
let { board } = path;
|
||||
const { project } = path;
|
||||
|
||||
if (!board) {
|
||||
throw Errors.BOARD_NOT_FOUND;
|
||||
}
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(
|
||||
currentUser.id,
|
||||
board.projectId,
|
||||
);
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
if (!isProjectManager) {
|
||||
throw Errors.BOARD_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
board = await sails.helpers.boards.deleteOne.with({
|
||||
project,
|
||||
record: board,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -29,18 +29,18 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { board } = await sails.helpers.boards
|
||||
const path = await sails.helpers.boards
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
let { board } = path;
|
||||
const { project } = path;
|
||||
|
||||
if (!board) {
|
||||
throw Errors.BOARD_NOT_FOUND;
|
||||
}
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(
|
||||
currentUser.id,
|
||||
board.projectId,
|
||||
);
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
if (!isProjectManager) {
|
||||
throw Errors.BOARD_NOT_FOUND; // Forbidden
|
||||
@@ -50,7 +50,9 @@ module.exports = {
|
||||
|
||||
board = await sails.helpers.boards.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
record: board,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { card } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ module.exports = {
|
||||
|
||||
const label = await Label.findOne({
|
||||
id: inputs.labelId,
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
});
|
||||
|
||||
if (!label) {
|
||||
@@ -73,10 +73,14 @@ module.exports = {
|
||||
|
||||
const cardLabel = await sails.helpers.cardLabels.createOne
|
||||
.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
card,
|
||||
label,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('labelAlreadyInCard', () => Errors.LABEL_ALREADY_IN_CARD);
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
@@ -66,8 +66,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
cardLabel = await sails.helpers.cardLabels.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: cardLabel,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -45,12 +45,12 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { card } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -62,7 +62,7 @@ module.exports = {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(inputs.userId, card.boardId);
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(inputs.userId, board.id);
|
||||
|
||||
if (!isBoardMember) {
|
||||
throw Errors.USER_NOT_FOUND;
|
||||
@@ -70,10 +70,14 @@ module.exports = {
|
||||
|
||||
const cardMembership = await sails.helpers.cardMemberships.createOne
|
||||
.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
card,
|
||||
userId: inputs.userId,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('userAlreadyCardMember', () => Errors.USER_ALREADY_CARD_MEMBER);
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
@@ -66,8 +66,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
cardMembership = await sails.helpers.cardMemberships.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: cardMembership,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board, list } = await sails.helpers.lists
|
||||
const { list, board, project } = await sails.helpers.lists
|
||||
.getProjectPath(inputs.listId)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
|
||||
|
||||
@@ -99,6 +99,7 @@ module.exports = {
|
||||
|
||||
const card = await sails.helpers.cards.createOne
|
||||
.with({
|
||||
project,
|
||||
board,
|
||||
values: {
|
||||
...values,
|
||||
|
||||
@@ -28,12 +28,15 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { card } = await sails.helpers.cards
|
||||
const path = await sails.helpers.cards
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
let { card } = path;
|
||||
const { list, board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -46,8 +49,11 @@ module.exports = {
|
||||
}
|
||||
|
||||
card = await sails.helpers.cards.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
record: card,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { card, list, board } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -60,6 +60,7 @@ module.exports = {
|
||||
cardLabels,
|
||||
tasks,
|
||||
} = await sails.helpers.cards.duplicateOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
record: card,
|
||||
|
||||
@@ -118,7 +118,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
let { card } = path;
|
||||
const { list, board } = path;
|
||||
const { list, board, project } = path;
|
||||
|
||||
let boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
@@ -133,9 +133,11 @@ module.exports = {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
|
||||
let nextProject;
|
||||
let nextBoard;
|
||||
|
||||
if (!_.isUndefined(inputs.boardId)) {
|
||||
({ board: nextBoard } = await sails.helpers.boards
|
||||
({ board: nextBoard, project: nextProject } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND));
|
||||
|
||||
@@ -177,15 +179,17 @@ module.exports = {
|
||||
|
||||
card = await sails.helpers.cards.updateOne
|
||||
.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
record: card,
|
||||
values: {
|
||||
...values,
|
||||
project: nextProject,
|
||||
board: nextBoard,
|
||||
list: nextList,
|
||||
},
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('positionMustBeInValues', () => Errors.POSITION_MUST_BE_PRESENT)
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board, card } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
@@ -55,7 +55,9 @@ module.exports = {
|
||||
};
|
||||
|
||||
const action = await sails.helpers.actions.createOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
...values,
|
||||
card,
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.COMMENT_ACTION_NOT_FOUND);
|
||||
|
||||
let { action } = path;
|
||||
const { board, project } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
@@ -60,8 +60,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
action = await sails.helpers.actions.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: action,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.COMMENT_ACTION_NOT_FOUND);
|
||||
|
||||
let { action } = path;
|
||||
const { board, project } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const isProjectManager = await sails.helpers.users.isProjectManager(currentUser.id, project.id);
|
||||
|
||||
@@ -69,8 +69,12 @@ module.exports = {
|
||||
|
||||
action = await sails.helpers.actions.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: action,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.boards
|
||||
const { board, project } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
@@ -62,10 +62,12 @@ module.exports = {
|
||||
const values = _.pick(inputs, ['position', 'name', 'color']);
|
||||
|
||||
const label = await sails.helpers.labels.createOne.with({
|
||||
project,
|
||||
values: {
|
||||
...values,
|
||||
board,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -28,12 +28,15 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { label } = await sails.helpers.labels
|
||||
const path = await sails.helpers.labels
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LABEL_NOT_FOUND);
|
||||
|
||||
let { label } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: label.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -46,7 +49,10 @@ module.exports = {
|
||||
}
|
||||
|
||||
label = await sails.helpers.labels.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
record: label,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -40,12 +40,15 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { label } = await sails.helpers.labels
|
||||
const path = await sails.helpers.labels
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LABEL_NOT_FOUND);
|
||||
|
||||
let { label } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: label.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -61,7 +64,10 @@ module.exports = {
|
||||
|
||||
label = await sails.helpers.labels.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
record: label,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board } = await sails.helpers.boards
|
||||
const { board, project } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
@@ -56,10 +56,12 @@ module.exports = {
|
||||
const values = _.pick(inputs, ['position', 'name']);
|
||||
|
||||
const list = await sails.helpers.lists.createOne.with({
|
||||
project,
|
||||
values: {
|
||||
...values,
|
||||
board,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -28,12 +28,15 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { list } = await sails.helpers.lists
|
||||
const path = await sails.helpers.lists
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
|
||||
|
||||
let { list } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: list.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -46,7 +49,10 @@ module.exports = {
|
||||
}
|
||||
|
||||
list = await sails.helpers.lists.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
record: list,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { list } = await sails.helpers.lists
|
||||
const { list, board, project } = await sails.helpers.lists
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: list.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -50,8 +50,11 @@ module.exports = {
|
||||
}
|
||||
|
||||
const cards = await sails.helpers.lists.sortOne.with({
|
||||
project,
|
||||
board,
|
||||
record: list,
|
||||
type: inputs.type,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -35,12 +35,15 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let { list } = await sails.helpers.lists
|
||||
const path = await sails.helpers.lists
|
||||
.getProjectPath(inputs.id)
|
||||
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
|
||||
|
||||
let { list } = path;
|
||||
const { board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: list.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -56,7 +59,10 @@ module.exports = {
|
||||
|
||||
list = await sails.helpers.lists.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
record: list,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
const notifications = await sails.helpers.notifications.updateMany.with({
|
||||
values,
|
||||
recordsOrIds: inputs.ids.split(','),
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ module.exports = {
|
||||
project,
|
||||
user,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('userAlreadyProjectManager', () => Errors.USER_ALREADY_PROJECT_MANAGER);
|
||||
|
||||
@@ -40,6 +40,7 @@ module.exports = {
|
||||
// TODO: check if the last one
|
||||
projectManager = await sails.helpers.projectManagers.deleteOne.with({
|
||||
record: projectManager,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
const Errors = {
|
||||
NOT_ENOUGH_RIGHTS: {
|
||||
notEnoughRights: 'Not enough rights',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
name: {
|
||||
@@ -6,14 +12,24 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
notEnoughRights: {
|
||||
responseType: 'forbidden',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
if (!currentUser.isAdmin && !sails.config.custom.allowAllToCreateProjects) {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
|
||||
const values = _.pick(inputs, ['name']);
|
||||
|
||||
const { project, projectManager } = await sails.helpers.projects.createOne.with({
|
||||
values,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ module.exports = {
|
||||
|
||||
project = await sails.helpers.projects.deleteOne.with({
|
||||
record: project,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ module.exports = {
|
||||
values: {
|
||||
backgroundImage: fileData,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ module.exports = {
|
||||
project = await sails.helpers.projects.updateOne.with({
|
||||
values,
|
||||
record: project,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ module.exports = {
|
||||
return {
|
||||
item: {
|
||||
oidc,
|
||||
allowAllToCreateProjects: sails.config.custom.allowAllToCreateProjects,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -39,12 +39,12 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { card } = await sails.helpers.cards
|
||||
const { card, list, board, project } = await sails.helpers.cards
|
||||
.getProjectPath(inputs.cardId)
|
||||
.intercept('pathNotFound', () => Errors.CARD_NOT_FOUND);
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: card.boardId,
|
||||
boardId: board.id,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
@@ -59,10 +59,14 @@ module.exports = {
|
||||
const values = _.pick(inputs, ['position', 'name', 'isCompleted']);
|
||||
|
||||
const task = await sails.helpers.tasks.createOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
...values,
|
||||
card,
|
||||
},
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.TASK_NOT_FOUND);
|
||||
|
||||
let { task } = path;
|
||||
const { board } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
@@ -49,8 +49,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
task = await sails.helpers.tasks.deleteOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: task,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ module.exports = {
|
||||
.intercept('pathNotFound', () => Errors.TASK_NOT_FOUND);
|
||||
|
||||
let { task } = path;
|
||||
const { board } = path;
|
||||
const { card, list, board, project } = path;
|
||||
|
||||
const boardMembership = await BoardMembership.findOne({
|
||||
boardId: board.id,
|
||||
@@ -62,8 +62,12 @@ module.exports = {
|
||||
|
||||
task = await sails.helpers.tasks.updateOne.with({
|
||||
values,
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
card,
|
||||
record: task,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
if (sails.config.custom.oidcEnforced) {
|
||||
throw Errors.NOT_ENOUGH_RIGHTS;
|
||||
}
|
||||
@@ -89,6 +91,7 @@ module.exports = {
|
||||
const user = await sails.helpers.users.createOne
|
||||
.with({
|
||||
values,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('emailAlreadyInUse', () => Errors.EMAIL_ALREADY_IN_USE)
|
||||
|
||||
@@ -26,6 +26,8 @@ module.exports = {
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
let user = await sails.helpers.users.getOne(inputs.id);
|
||||
|
||||
if (!user) {
|
||||
@@ -38,6 +40,7 @@ module.exports = {
|
||||
|
||||
user = await sails.helpers.users.deleteOne.with({
|
||||
record: user,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ module.exports = {
|
||||
values: {
|
||||
avatar: fileData,
|
||||
},
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ module.exports = {
|
||||
.with({
|
||||
values,
|
||||
record: user,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('emailAlreadyInUse', () => Errors.EMAIL_ALREADY_IN_USE);
|
||||
|
||||
@@ -80,7 +80,7 @@ module.exports = {
|
||||
user = await sails.helpers.users.updateOne.with({
|
||||
values,
|
||||
record: user,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ module.exports = {
|
||||
.with({
|
||||
values,
|
||||
record: user,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
})
|
||||
.intercept('usernameAlreadyInUse', () => Errors.USERNAME_ALREADY_IN_USE);
|
||||
|
||||
@@ -95,7 +95,7 @@ module.exports = {
|
||||
user = await sails.helpers.users.updateOne.with({
|
||||
values,
|
||||
record: user,
|
||||
user: currentUser,
|
||||
actorUser: currentUser,
|
||||
request: this.req,
|
||||
});
|
||||
|
||||
|
||||
@@ -14,21 +14,21 @@ const valuesValidator = (value) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const buildAndSendSlackMessage = async (user, card, action) => {
|
||||
const buildAndSendSlackMessage = async (card, action, actorUser) => {
|
||||
const cardLink = `<${sails.config.custom.baseUrl}/cards/${card.id}|${card.name}>`;
|
||||
|
||||
let markdown;
|
||||
switch (action.type) {
|
||||
case Action.Types.CREATE_CARD:
|
||||
markdown = `${cardLink} was created by ${user.name} in *${action.data.list.name}*`;
|
||||
markdown = `${cardLink} was created by ${actorUser.name} in *${action.data.list.name}*`;
|
||||
|
||||
break;
|
||||
case Action.Types.MOVE_CARD:
|
||||
markdown = `${cardLink} was moved by ${user.name} to *${action.data.toList.name}*`;
|
||||
markdown = `${cardLink} was moved by ${actorUser.name} to *${action.data.toList.name}*`;
|
||||
|
||||
break;
|
||||
case Action.Types.COMMENT_CARD:
|
||||
markdown = `*${user.name}* commented on ${cardLink}:\n>${action.data.text}`;
|
||||
markdown = `*${actorUser.name}* commented on ${cardLink}:\n>${action.data.text}`;
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -45,10 +45,18 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -72,6 +80,24 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'actionCreate',
|
||||
data: {
|
||||
item: action,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
},
|
||||
user: values.user,
|
||||
});
|
||||
|
||||
if (sails.config.custom.slackBotToken) {
|
||||
buildAndSendSlackMessage(values.card, action, values.user);
|
||||
}
|
||||
|
||||
const subscriptionUserIds = await sails.helpers.cards.getSubscriptionUserIds(
|
||||
action.cardId,
|
||||
action.userId,
|
||||
@@ -84,17 +110,15 @@ module.exports = {
|
||||
userId,
|
||||
action,
|
||||
},
|
||||
user: values.user,
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: inputs.list,
|
||||
card: values.card,
|
||||
actorUser: values.user,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
if (sails.config.custom.slackBotToken) {
|
||||
buildAndSendSlackMessage(values.user, values.card, action);
|
||||
}
|
||||
|
||||
return action;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,10 +4,26 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -25,6 +41,20 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'actionDelete',
|
||||
data: {
|
||||
item: action,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return action;
|
||||
|
||||
@@ -8,10 +8,26 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -31,6 +47,20 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'actionUpdate',
|
||||
data: {
|
||||
item: action,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return action;
|
||||
|
||||
@@ -21,6 +21,18 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
requestId: {
|
||||
type: 'string',
|
||||
isNotEmptyString: true,
|
||||
@@ -49,12 +61,30 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'attachmentCreate',
|
||||
data: {
|
||||
item: attachment,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
},
|
||||
user: values.creatorUser,
|
||||
});
|
||||
|
||||
if (!values.card.coverAttachmentId && attachment.image) {
|
||||
await sails.helpers.cards.updateOne.with({
|
||||
record: values.card,
|
||||
values: {
|
||||
coverAttachmentId: attachment.id,
|
||||
},
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: inputs.list,
|
||||
actorUser: values.creatorUser,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,14 +7,26 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -27,6 +39,10 @@ module.exports = {
|
||||
values: {
|
||||
coverAttachmentId: null,
|
||||
},
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: inputs.list,
|
||||
actorUser: inputs.actorUser,
|
||||
request: inputs.request,
|
||||
});
|
||||
}
|
||||
@@ -48,6 +64,20 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'attachmentDelete',
|
||||
data: {
|
||||
item: attachment,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return attachment;
|
||||
|
||||
@@ -8,10 +8,26 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -31,6 +47,20 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'attachmentUpdate',
|
||||
data: {
|
||||
item: attachment,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return attachment;
|
||||
|
||||
@@ -21,6 +21,14 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -67,6 +75,19 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardMembershipCreate',
|
||||
data: {
|
||||
item: boardMembership,
|
||||
included: {
|
||||
users: [values.user],
|
||||
projects: [inputs.project],
|
||||
boards: [values.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return boardMembership;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -10,6 +10,14 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -73,6 +81,18 @@ module.exports = {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardMembershipDelete',
|
||||
data: {
|
||||
item: boardMembership,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return boardMembership;
|
||||
|
||||
@@ -8,6 +8,18 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -40,6 +52,18 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardMembershipUpdate',
|
||||
data: {
|
||||
item: boardMembership,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return boardMembership;
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
type: 'json',
|
||||
custom: importValidator,
|
||||
},
|
||||
user: {
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
@@ -80,6 +80,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,12 +92,12 @@ module.exports = {
|
||||
}).fetch();
|
||||
|
||||
if (inputs.import && inputs.import.type === Board.ImportTypes.TRELLO) {
|
||||
await sails.helpers.boards.importFromTrello(inputs.user, board, inputs.import.board);
|
||||
await sails.helpers.boards.importFromTrello(board, inputs.import.board, inputs.actorUser);
|
||||
}
|
||||
|
||||
const boardMembership = await BoardMembership.create({
|
||||
boardId: board.id,
|
||||
userId: inputs.user.id,
|
||||
userId: inputs.actorUser.id,
|
||||
role: BoardMembership.Roles.EDITOR,
|
||||
}).fetch();
|
||||
|
||||
@@ -111,6 +113,17 @@ module.exports = {
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardCreate',
|
||||
data: {
|
||||
item: board,
|
||||
included: {
|
||||
projects: [values.project],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return {
|
||||
board,
|
||||
boardMembership,
|
||||
|
||||
@@ -4,6 +4,14 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -33,6 +41,17 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardDelete',
|
||||
data: {
|
||||
item: board,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return board;
|
||||
|
||||
@@ -2,10 +2,6 @@ const POSITION_GAP = 65535; // TODO: move to config
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
user: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
@@ -14,6 +10,10 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
@@ -87,7 +87,7 @@ module.exports = {
|
||||
trelloComments.map(async (trelloComment) => {
|
||||
return Action.create({
|
||||
cardId: plankaCard.id,
|
||||
userId: inputs.user.id,
|
||||
userId: inputs.actorUser.id,
|
||||
type: 'commentCard',
|
||||
data: {
|
||||
text:
|
||||
@@ -105,7 +105,7 @@ module.exports = {
|
||||
const plankaCard = await Card.create({
|
||||
boardId: inputs.board.id,
|
||||
listId: plankaList.id,
|
||||
creatorUserId: inputs.user.id,
|
||||
creatorUserId: inputs.actorUser.id,
|
||||
position: trelloCard.pos,
|
||||
name: trelloCard.name,
|
||||
description: trelloCard.desc || null,
|
||||
|
||||
@@ -21,6 +21,14 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -64,6 +72,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -81,6 +91,17 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'boardUpdate',
|
||||
data: {
|
||||
item: board,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return board;
|
||||
|
||||
@@ -21,6 +21,22 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -50,6 +66,21 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardLabelCreate',
|
||||
data: {
|
||||
item: cardLabel,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
labels: [values.label],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return cardLabel;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,10 +4,26 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -25,6 +41,20 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardLabelDelete',
|
||||
data: {
|
||||
item: cardLabel,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return cardLabel;
|
||||
|
||||
@@ -21,6 +21,22 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -53,6 +69,20 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardMembershipCreate',
|
||||
data: {
|
||||
item: cardMembership,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
const cardSubscription = await CardSubscription.create({
|
||||
cardId: cardMembership.cardId,
|
||||
userId: cardMembership.userId,
|
||||
@@ -73,6 +103,8 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
|
||||
return cardMembership;
|
||||
|
||||
@@ -4,10 +4,26 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -26,6 +42,20 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardMembershipDelete',
|
||||
data: {
|
||||
item: cardMembership,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
const cardSubscription = await CardSubscription.destroyOne({
|
||||
cardId: cardMembership.cardId,
|
||||
userId: cardMembership.userId,
|
||||
@@ -39,6 +69,8 @@ module.exports = {
|
||||
isSubscribed: false,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhook
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
@@ -66,6 +70,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
|
||||
const card = await Card.create({
|
||||
@@ -85,6 +91,19 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardCreate',
|
||||
data: {
|
||||
item: card,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [values.list],
|
||||
},
|
||||
},
|
||||
user: values.creatorUser,
|
||||
});
|
||||
|
||||
if (values.creatorUser.subscribeToOwnCards) {
|
||||
await CardSubscription.create({
|
||||
cardId: card.id,
|
||||
@@ -97,6 +116,8 @@ module.exports = {
|
||||
isSubscribed: true,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
|
||||
await sails.helpers.actions.createOne.with({
|
||||
@@ -108,7 +129,10 @@ module.exports = {
|
||||
},
|
||||
user: values.creatorUser,
|
||||
},
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: values.list,
|
||||
request: inputs.request,
|
||||
});
|
||||
|
||||
return card;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const buildAndSendSlackMessage = async (user, card) => {
|
||||
await sails.helpers.utils.sendSlackMessage(`*${card.name}* was deleted by ${user.name}`);
|
||||
const buildAndSendSlackMessage = async (card, actorUser) => {
|
||||
await sails.helpers.utils.sendSlackMessage(`*${card.name}* was deleted by ${actorUser.name}`);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@@ -8,7 +8,19 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
@@ -30,8 +42,21 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardDelete',
|
||||
data: {
|
||||
item: card,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
if (sails.config.custom.slackBotToken) {
|
||||
buildAndSendSlackMessage(inputs.user, card);
|
||||
buildAndSendSlackMessage(card, inputs.actorUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
@@ -62,6 +66,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
|
||||
const card = await Card.create({
|
||||
@@ -108,6 +114,19 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardCreate',
|
||||
data: {
|
||||
item: card,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
},
|
||||
},
|
||||
user: values.creatorUser,
|
||||
});
|
||||
|
||||
if (values.creatorUser.subscribeToOwnCards) {
|
||||
await CardSubscription.create({
|
||||
cardId: card.id,
|
||||
@@ -120,6 +139,8 @@ module.exports = {
|
||||
isSubscribed: true,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
|
||||
await sails.helpers.actions.createOne.with({
|
||||
@@ -131,7 +152,10 @@ module.exports = {
|
||||
},
|
||||
user: values.creatorUser,
|
||||
},
|
||||
project: inputs.project,
|
||||
board: inputs.board,
|
||||
list: inputs.list,
|
||||
request: inputs.request,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -7,8 +7,14 @@ const valuesValidator = (value) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.board) && !_.isPlainObject(value.board)) {
|
||||
return false;
|
||||
if (!_.isUndefined(value.board)) {
|
||||
if (!_.isPlainObject(value.project)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isPlainObject(value.board)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.list) && !_.isPlainObject(value.list)) {
|
||||
@@ -29,14 +35,21 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
@@ -45,65 +58,56 @@ module.exports = {
|
||||
|
||||
exits: {
|
||||
positionMustBeInValues: {},
|
||||
boardInValuesMustBelongToProject: {},
|
||||
listMustBeInValues: {},
|
||||
listInValuesMustBelongToBoard: {},
|
||||
userMustBePresent: {},
|
||||
boardMustBePresent: {},
|
||||
listMustBePresent: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { isSubscribed, ...values } = inputs.values;
|
||||
|
||||
if (values.board || values.list || !_.isUndefined(values.position)) {
|
||||
if (!inputs.board) {
|
||||
throw 'boardMustBePresent';
|
||||
if (values.project && values.project.id === inputs.project.id) {
|
||||
delete values.project;
|
||||
}
|
||||
|
||||
const project = values.project || inputs.project;
|
||||
|
||||
if (values.board) {
|
||||
if (values.board.projectId !== project.id) {
|
||||
throw 'boardInValuesMustBelongToProject';
|
||||
}
|
||||
|
||||
if (values.board) {
|
||||
if (values.board.id === inputs.board.id) {
|
||||
delete values.board;
|
||||
} else {
|
||||
values.boardId = values.board.id;
|
||||
}
|
||||
}
|
||||
|
||||
const board = values.board || inputs.board;
|
||||
|
||||
if (values.list) {
|
||||
if (!inputs.list) {
|
||||
throw 'listMustBePresent';
|
||||
}
|
||||
|
||||
if (values.list.boardId !== board.id) {
|
||||
throw 'listInValuesMustBelongToBoard';
|
||||
}
|
||||
|
||||
if (values.list.id === inputs.list.id) {
|
||||
delete values.list;
|
||||
} else {
|
||||
values.listId = values.list.id;
|
||||
}
|
||||
}
|
||||
|
||||
if (values.list) {
|
||||
if (_.isUndefined(values.position)) {
|
||||
throw 'positionMustBeInValues';
|
||||
}
|
||||
} else if (values.board) {
|
||||
throw 'listMustBeInValues';
|
||||
if (values.board.id === inputs.board.id) {
|
||||
delete values.board;
|
||||
} else {
|
||||
values.boardId = values.board.id;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!_.isUndefined(isSubscribed) || values.board || values.list) && !inputs.user) {
|
||||
throw 'userMustBePresent';
|
||||
const board = values.board || inputs.board;
|
||||
|
||||
if (values.list) {
|
||||
if (values.list.boardId !== board.id) {
|
||||
throw 'listInValuesMustBelongToBoard';
|
||||
}
|
||||
|
||||
if (values.list.id === inputs.list.id) {
|
||||
delete values.list;
|
||||
} else {
|
||||
values.listId = values.list.id;
|
||||
}
|
||||
} else if (values.board) {
|
||||
throw 'listMustBeInValues';
|
||||
}
|
||||
|
||||
const list = values.list || inputs.list;
|
||||
|
||||
if (values.list && _.isUndefined(values.position)) {
|
||||
throw 'positionMustBeInValues';
|
||||
}
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const boardId = values.boardId || inputs.record.boardId;
|
||||
const listId = values.listId || inputs.record.listId;
|
||||
|
||||
const cards = await sails.helpers.lists.getCards(listId, inputs.record.id);
|
||||
const cards = await sails.helpers.lists.getCards(list.id, inputs.record.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
@@ -115,17 +119,19 @@ module.exports = {
|
||||
repositions.forEach(async ({ id, position: nextPosition }) => {
|
||||
await Card.update({
|
||||
id,
|
||||
listId,
|
||||
listId: list.id,
|
||||
}).set({
|
||||
position: nextPosition,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(`board:${boardId}`, 'cardUpdate', {
|
||||
sails.sockets.broadcast(`board:${board.id}`, 'cardUpdate', {
|
||||
item: {
|
||||
id,
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
}
|
||||
|
||||
@@ -175,10 +181,12 @@ module.exports = {
|
||||
}
|
||||
|
||||
const { id } = await sails.helpers.labels.createOne.with({
|
||||
project,
|
||||
values: {
|
||||
..._.omit(label, ['id', 'boardId']),
|
||||
board: values.board,
|
||||
},
|
||||
actorUser: inputs.actorUser,
|
||||
});
|
||||
|
||||
return id;
|
||||
@@ -209,6 +217,8 @@ module.exports = {
|
||||
isSubscribed: true,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
} else {
|
||||
sails.sockets.broadcast(
|
||||
@@ -221,18 +231,34 @@ module.exports = {
|
||||
);
|
||||
}
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'cardUpdate',
|
||||
data: {
|
||||
item: card,
|
||||
included: {
|
||||
projects: [project],
|
||||
boards: [board],
|
||||
lists: [list],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
if (!values.board && values.list) {
|
||||
await sails.helpers.actions.createOne.with({
|
||||
project,
|
||||
board,
|
||||
list,
|
||||
values: {
|
||||
card,
|
||||
user: inputs.user,
|
||||
user: inputs.actorUser,
|
||||
type: Action.Types.MOVE_CARD,
|
||||
data: {
|
||||
fromList: _.pick(inputs.list, ['id', 'name']),
|
||||
toList: _.pick(values.list, ['id', 'name']),
|
||||
},
|
||||
},
|
||||
board: inputs.board,
|
||||
request: inputs.request,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -240,23 +266,26 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (!_.isUndefined(isSubscribed)) {
|
||||
const prevIsSubscribed = await sails.helpers.users.isCardSubscriber(inputs.user.id, card.id);
|
||||
const prevIsSubscribed = await sails.helpers.users.isCardSubscriber(
|
||||
inputs.actorUser.id,
|
||||
card.id,
|
||||
);
|
||||
|
||||
if (isSubscribed !== prevIsSubscribed) {
|
||||
if (isSubscribed) {
|
||||
await CardSubscription.create({
|
||||
cardId: card.id,
|
||||
userId: inputs.user.id,
|
||||
userId: inputs.actorUser.id,
|
||||
}).tolerate('E_UNIQUE');
|
||||
} else {
|
||||
await CardSubscription.destroyOne({
|
||||
cardId: card.id,
|
||||
userId: inputs.user.id,
|
||||
userId: inputs.actorUser.id,
|
||||
});
|
||||
}
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`user:${inputs.user.id}`,
|
||||
`user:${inputs.actorUser.id}`,
|
||||
'cardUpdate',
|
||||
{
|
||||
item: {
|
||||
@@ -266,6 +295,8 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,14 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -50,6 +58,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
|
||||
const label = await Label.create({
|
||||
@@ -67,6 +77,18 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'labelCreate',
|
||||
data: {
|
||||
item: label,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [values.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return label;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,6 +4,18 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -25,6 +37,18 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'labelDelete',
|
||||
data: {
|
||||
item: label,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return label;
|
||||
|
||||
@@ -21,6 +21,18 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -53,6 +65,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,6 +81,18 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'labelUpdate',
|
||||
data: {
|
||||
item: label,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return label;
|
||||
|
||||
@@ -21,6 +21,14 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -50,6 +58,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
|
||||
const list = await List.create({
|
||||
@@ -67,6 +77,18 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'listCreate',
|
||||
data: {
|
||||
item: list,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [values.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return list;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,6 +4,18 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -21,6 +33,18 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'listDelete',
|
||||
data: {
|
||||
item: list,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -11,6 +11,18 @@ module.exports = {
|
||||
isIn: Object.values(List.SortTypes),
|
||||
defaultsTo: List.SortTypes.NAME_ASC,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -65,6 +77,19 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'listSort',
|
||||
data: {
|
||||
item: inputs.record,
|
||||
included: {
|
||||
cards,
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return cards;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,6 +21,18 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -53,6 +65,8 @@ module.exports = {
|
||||
position: nextPosition,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,6 +81,18 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'listUpdate',
|
||||
data: {
|
||||
item: list,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -15,14 +15,14 @@ const valuesValidator = (value) => {
|
||||
};
|
||||
|
||||
// TODO: use templates (views) to build html
|
||||
const buildAndSendEmail = async (user, board, card, action, notifiableUser) => {
|
||||
const buildAndSendEmail = async (board, card, action, actorUser, notifiableUser) => {
|
||||
let emailData;
|
||||
switch (action.type) {
|
||||
case Action.Types.MOVE_CARD:
|
||||
emailData = {
|
||||
subject: `${user.name} moved ${card.name} from ${action.data.fromList.name} to ${action.data.toList.name} on ${board.name}`,
|
||||
subject: `${actorUser.name} moved ${card.name} from ${action.data.fromList.name} to ${action.data.toList.name} on ${board.name}`,
|
||||
html:
|
||||
`<p>${user.name} moved ` +
|
||||
`<p>${actorUser.name} moved ` +
|
||||
`<a href="${process.env.BASE_URL}/cards/${card.id}">${card.name}</a> ` +
|
||||
`from ${action.data.fromList.name} to ${action.data.toList.name} ` +
|
||||
`on <a href="${process.env.BASE_URL}/boards/${board.id}">${board.name}</a></p>`,
|
||||
@@ -31,9 +31,9 @@ const buildAndSendEmail = async (user, board, card, action, notifiableUser) => {
|
||||
break;
|
||||
case Action.Types.COMMENT_CARD:
|
||||
emailData = {
|
||||
subject: `${user.name} left a new comment to ${card.name} on ${board.name}`,
|
||||
subject: `${actorUser.name} left a new comment to ${card.name} on ${board.name}`,
|
||||
html:
|
||||
`<p>${user.name} left a new comment to ` +
|
||||
`<p>${actorUser.name} left a new comment to ` +
|
||||
`<a href="${process.env.BASE_URL}/cards/${card.id}">${card.name}</a> ` +
|
||||
`on <a href="${process.env.BASE_URL}/boards/${board.id}">${board.name}</a></p>` +
|
||||
`<p>${action.data.text}</p>`,
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
@@ -65,10 +65,18 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
@@ -96,9 +104,24 @@ module.exports = {
|
||||
notifiableUser = await sails.helpers.users.getOne(notification.userId);
|
||||
}
|
||||
|
||||
buildAndSendEmail(inputs.user, inputs.board, inputs.card, values.action, notifiableUser);
|
||||
buildAndSendEmail(inputs.board, inputs.card, values.action, inputs.actorUser, notifiableUser);
|
||||
}
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationCreate',
|
||||
data: {
|
||||
item: notification,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
actions: [values.action],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return notification;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,8 +12,9 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
@@ -23,7 +24,9 @@ module.exports = {
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
const criteria = {};
|
||||
const criteria = {
|
||||
userId: inputs.actorUser.id,
|
||||
};
|
||||
|
||||
if (_.every(inputs.recordsOrIds, _.isPlainObject)) {
|
||||
criteria.id = sails.helpers.utils.mapRecords(inputs.recordsOrIds);
|
||||
@@ -31,10 +34,6 @@ module.exports = {
|
||||
criteria.id = inputs.recordsOrIds;
|
||||
}
|
||||
|
||||
if (inputs.user) {
|
||||
criteria.userId = inputs.user.id;
|
||||
}
|
||||
|
||||
const notifications = await Notification.update(criteria)
|
||||
.set({ ...values })
|
||||
.fetch();
|
||||
@@ -48,6 +47,14 @@ module.exports = {
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'notificationUpdate',
|
||||
data: {
|
||||
item: notification,
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
});
|
||||
|
||||
return notifications;
|
||||
|
||||
@@ -21,6 +21,10 @@ module.exports = {
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -55,6 +59,18 @@ module.exports = {
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'projectManagerCreate',
|
||||
data: {
|
||||
item: projectManager,
|
||||
included: {
|
||||
users: [values.user],
|
||||
projects: [values.project],
|
||||
},
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return projectManager;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,6 +4,10 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -27,6 +31,14 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'projectManagerDelete',
|
||||
data: {
|
||||
item: projectManager,
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return projectManager;
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
user: {
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
@@ -20,7 +20,7 @@ module.exports = {
|
||||
|
||||
const projectManager = await ProjectManager.create({
|
||||
projectId: project.id,
|
||||
userId: inputs.user.id,
|
||||
userId: inputs.actorUser.id,
|
||||
}).fetch();
|
||||
|
||||
sails.sockets.broadcast(
|
||||
@@ -32,6 +32,14 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'projectCreate',
|
||||
data: {
|
||||
item: project,
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return {
|
||||
project,
|
||||
projectManager,
|
||||
|
||||
@@ -4,6 +4,10 @@ module.exports = {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
@@ -37,6 +41,14 @@ module.exports = {
|
||||
inputs.request,
|
||||
);
|
||||
});
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'projectDelete',
|
||||
data: {
|
||||
item: project,
|
||||
},
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return project;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user