Add Leafcutter addon
This commit is contained in:
parent
4498cc95f6
commit
0190ccdfd3
8 changed files with 92 additions and 5207 deletions
|
|
@ -5,7 +5,7 @@ base_path = '/opt/zammad/contrib/link/addons'
|
||||||
packages = Dir.glob("#{base_path}/*")
|
packages = Dir.glob("#{base_path}/*")
|
||||||
|
|
||||||
puts "Available packages: #{packages}"
|
puts "Available packages: #{packages}"
|
||||||
puts "Installed packages: #{Package.all}"
|
puts "Installed packages: #{Package.all.map(&:version)}"
|
||||||
|
|
||||||
packages.each do |package|
|
packages.each do |package|
|
||||||
puts "Installing #{package} package..."
|
puts "Installing #{package} package..."
|
||||||
|
|
@ -13,4 +13,3 @@ packages.each do |package|
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
puts "Error #{e.message}"
|
puts "Error #{e.message}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
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",
|
"name": "zammad-addon-pgp",
|
||||||
"displayName": "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).",
|
"description": "Adds PGP integration into [Zammad](https://zammad.org) via [Sequoia](https://sequoia-pgp.org).",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node ../../node_modules/zammad-addon-common/dist/build.js",
|
"build": "node ../../node_modules/zammad-addon-common/dist/build.js",
|
||||||
|
|
|
||||||
|
|
@ -584,7 +584,7 @@ class App.UiElement.ApplicationAction
|
||||||
options: {
|
options: {
|
||||||
'no': __('Do not sign email')
|
'no': __('Do not sign email')
|
||||||
'discard': __('Sign email (if not possible, discard notification)')
|
'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
|
value: meta.sign
|
||||||
translate: true
|
translate: true
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Set up PGP addon
|
||||||
class PGP < ActiveRecord::Migration[5.2]
|
class PGP < ActiveRecord::Migration[5.2]
|
||||||
def self.up
|
def self.up
|
||||||
# return if it's a new setup
|
|
||||||
# return unless Setting.exists?(name: 'system_init_done')
|
|
||||||
|
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
title: 'PGP integration',
|
title: 'PGP integration',
|
||||||
name: 'pgp_integration',
|
name: 'pgp_integration',
|
||||||
|
|
@ -43,15 +43,6 @@ class PGP < ActiveRecord::Migration[5.2]
|
||||||
},
|
},
|
||||||
frontend: true
|
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|
|
create_table :pgp_keypairs do |t|
|
||||||
t.string :fingerprint, limit: 250, null: false
|
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