Add Leafcutter addon
This commit is contained in:
parent
4498cc95f6
commit
0190ccdfd3
8 changed files with 92 additions and 5207 deletions
15
packages/zammad-addon-leafcutter/package.json
Normal file
15
packages/zammad-addon-leafcutter/package.json
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "zammad-addon-leafcutter",
|
||||
"displayName": "Leafcutter",
|
||||
"version": "2.0.0",
|
||||
"description": "Adds a common set of tags for Leafcutter uses.",
|
||||
"scripts": {
|
||||
"build": "node ../../node_modules/zammad-addon-common/dist/build.js",
|
||||
"migrate": "node ../../node_modules/zammad-addon-common/dist/migrate.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"zammad-addon-common": "*"
|
||||
},
|
||||
"author": "",
|
||||
"license": "AGPL-3.0-or-later"
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# create core Leafcutter tags
|
||||
class LeafcutterTags1 < ActiveRecord::Migration[5.2]
|
||||
def self.up
|
||||
Tag::Item.create(name: 'example_group:example_tag')
|
||||
end
|
||||
|
||||
def self.down
|
||||
t = Tag::Item.find_by(name: 'example_group:example_tag')
|
||||
return if t.nil?
|
||||
|
||||
t.destroy
|
||||
end
|
||||
end
|
||||
56
packages/zammad-addon-leafcutter/tags.js
Normal file
56
packages/zammad-addon-leafcutter/tags.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
const R = require("ramda");
|
||||
const { TagsV1 } = require("@digiresilience/leafcutter-fields");
|
||||
const {
|
||||
indexOfField,
|
||||
getFieldById,
|
||||
getFieldIds,
|
||||
getOptionsForField,
|
||||
getOptionIdsForField,
|
||||
getSubmitterFields,
|
||||
getAnalystFields,
|
||||
} = require("@digiresilience/leafcutter-fields/src/fields");
|
||||
|
||||
const upTag = (name) => `Tag::Item.create(name: "${name}")`;
|
||||
|
||||
const downTag = (name) => `t = Tag::Item.find_by(name: "${name}")
|
||||
if !t.nil?
|
||||
t.destroy
|
||||
end
|
||||
`;
|
||||
|
||||
const upTagGroup = (field) =>
|
||||
R.map(upTag, getOptionIdsForField(TagsV1, field.id));
|
||||
const downTagGroup = (field) =>
|
||||
R.map(downTag, getOptionIdsForField(TagsV1, field.id));
|
||||
|
||||
const upSection = (children) => `def self.up
|
||||
${children.join("\n")}
|
||||
end`;
|
||||
|
||||
const downSection = (children) => `def self.down
|
||||
${children.join("\n")}
|
||||
end`;
|
||||
|
||||
const migration = (
|
||||
name,
|
||||
ups,
|
||||
downs
|
||||
) => `class ${name} < ActiveRecord::Migration[5.2]
|
||||
${upSection(ups)}
|
||||
|
||||
${downSection(downs)}
|
||||
end
|
||||
`;
|
||||
|
||||
const ups = R.flatten(R.map(upTagGroup, TagsV1));
|
||||
const downs = R.flatten(R.map(downTagGroup, TagsV1));
|
||||
|
||||
const name = process.argv[2];
|
||||
if (!name) throw new Error("Must pass name of migration");
|
||||
|
||||
const re = RegExp("^[a-zA-Z][a-zA-Z0-9]+$");
|
||||
if (!re.test(name))
|
||||
throw new Error("Name must be only alphanumeric and start with a letter");
|
||||
|
||||
const res = migration(name, ups, downs);
|
||||
console.log(res);
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "zammad-addon-pgp",
|
||||
"displayName": "PGP",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.2",
|
||||
"description": "Adds PGP integration into [Zammad](https://zammad.org) via [Sequoia](https://sequoia-pgp.org).",
|
||||
"scripts": {
|
||||
"build": "node ../../node_modules/zammad-addon-common/dist/build.js",
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ class App.UiElement.ApplicationAction
|
|||
options: {
|
||||
'no': __('Do not sign email')
|
||||
'discard': __('Sign email (if not possible, discard notification)')
|
||||
'always': __('Sign email (if not possible, send notification anyway)')
|
||||
'always': __('Sign daha email (if not possible, send notification anyway)')
|
||||
}
|
||||
value: meta.sign
|
||||
translate: true
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Set up PGP addon
|
||||
class PGP < ActiveRecord::Migration[5.2]
|
||||
def self.up
|
||||
# return if it's a new setup
|
||||
# return unless Setting.exists?(name: 'system_init_done')
|
||||
|
||||
Setting.create_if_not_exists(
|
||||
title: 'PGP integration',
|
||||
name: 'pgp_integration',
|
||||
|
|
@ -43,15 +43,6 @@ class PGP < ActiveRecord::Migration[5.2]
|
|||
},
|
||||
frontend: true
|
||||
)
|
||||
Setting.create_if_not_exists(
|
||||
title: 'Defines postmaster filter.',
|
||||
name: '0016_postmaster_filter_smime',
|
||||
area: 'Postmaster::PreFilter',
|
||||
description: 'Defines postmaster filter to handle secure mailing.',
|
||||
options: {},
|
||||
state: 'Channel::Filter::SecureMailing',
|
||||
frontend: false
|
||||
)
|
||||
|
||||
create_table :pgp_keypairs do |t|
|
||||
t.string :fingerprint, limit: 250, null: false
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue