Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop' into webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkvanzanten committed Nov 12, 2019
2 parents 667d960 + e0630e8 commit ce6ffac
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 42 deletions.
4 changes: 4 additions & 0 deletions migrations/db/schemas/20180220023217_create_roles_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public function change()
'null' => true,
'default' => null
]);
$table->addColumn('enforce_2fa', 'boolean', [
'null' => true,
'default' => false
]);

$table->addIndex('name', [
'unique' => true,
Expand Down
119 changes: 81 additions & 38 deletions migrations/db/seeds/FieldsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ public function run()
'field' => 'action',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'activity-icon',
'options' => json_encode([
'iconRight' => 'change_history'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 1
'sort' => 1,
'width' => 'full'
],
[
'collection' => 'directus_activity',
'field' => 'collection',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'collections',
'options' => json_encode([
'iconRight' => 'list_alt'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 2,
Expand All @@ -52,6 +59,9 @@ public function run()
'field' => 'item',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'options' => json_encode([
'iconRight' => 'link'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 3,
Expand All @@ -62,6 +72,9 @@ public function run()
'field' => 'action_by',
'type' => \Directus\Database\Schema\DataTypes::TYPE_INTEGER,
'interface' => 'user',
'options' => json_encode([
'iconRight' => 'account_circle'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 4,
Expand All @@ -73,7 +86,8 @@ public function run()
'type' => \Directus\Database\Schema\DataTypes::TYPE_DATETIME,
'interface' => 'datetime',
'options' => json_encode([
'showRelative' => true
'showRelative' => true,
'iconRight' => 'calendar_today'
]),
'locked' => 1,
'readonly' => 1,
Expand All @@ -86,7 +100,8 @@ public function run()
'type' => \Directus\Database\Schema\DataTypes::TYPE_DATETIME,
'interface' => 'datetime',
'options' => json_encode([
'showRelative' => true
'showRelative' => true,
'iconRight' => 'edit'
]),
'locked' => 1,
'readonly' => 1,
Expand All @@ -99,7 +114,8 @@ public function run()
'type' => \Directus\Database\Schema\DataTypes::TYPE_DATETIME,
'interface' => 'datetime',
'options' => json_encode([
'showRelative' => true
'showRelative' => true,
'iconRight' => 'delete_outline'
]),
'locked' => 1,
'readonly' => 1,
Expand All @@ -111,6 +127,9 @@ public function run()
'field' => 'ip',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'options' => json_encode([
'iconRight' => 'my_location'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 8,
Expand All @@ -121,6 +140,9 @@ public function run()
'field' => 'user_agent',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'options' => json_encode([
'iconRight' => 'devices_other'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 9,
Expand All @@ -133,7 +155,8 @@ public function run()
'interface' => 'textarea',
'locked' => 1,
'readonly' => 1,
'sort' => 10
'sort' => 10,
'width' => 'full'
],


Expand Down Expand Up @@ -427,8 +450,7 @@ public function run()
'type' => \Directus\Database\Schema\DataTypes::TYPE_ALIAS,
'interface' => 'file',
'locked' => 1,
'hidden_detail' => 1,
'sort' => 0
'hidden_detail' => 1
],
[
'collection' => 'directus_files',
Expand All @@ -437,16 +459,16 @@ public function run()
'interface' => 'primary-key',
'locked' => 1,
'required' => 1,
'hidden_detail' => 1,
'sort' => 1
'hidden_detail' => 1
],
[
'collection' => 'directus_files',
'field' => 'preview',
'type' => \Directus\Database\Schema\DataTypes::TYPE_ALIAS,
'interface' => 'file-preview',
'locked' => 1,
'sort' => 2
'sort' => 1,
'width' => 'full'
],
[
'collection' => 'directus_files',
Expand Down Expand Up @@ -481,6 +503,9 @@ public function run()
'field' => 'tags',
'type' => \Directus\Database\Schema\DataTypes::TYPE_ARRAY,
'interface' => 'tags',
'options' => json_encode([
'placeholder' => 'Enter a keyword then hit enter...'
]),
'sort' => 5,
'width' => 'half'
],
Expand All @@ -502,9 +527,35 @@ public function run()
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'wysiwyg',
'options' => json_encode([
'placeholder' => 'Enter a caption or description...'
'toolbar' => ['bold','italic','underline','link','code']
]),
'sort' => 7
'sort' => 7,
'width' => 'full'
],
[
'collection' => 'directus_files',
'field' => 'uploaded_on',
'type' => \Directus\Database\Schema\DataTypes::TYPE_DATETIME,
'interface' => 'datetime',
'options' => json_encode([
'iconRight' => 'today'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 8,
'width' => 'half',
'required' => 1
],
[
'collection' => 'directus_files',
'field' => 'uploaded_by',
'type' => \Directus\Database\Schema\DataTypes::TYPE_USER_CREATED,
'interface' => 'user-created',
'locked' => 1,
'readonly' => 1,
'sort' => 9,
'width' => 'half',
'required' => 1
],
[
'collection' => 'directus_files',
Expand Down Expand Up @@ -558,38 +609,14 @@ public function run()
'sort' => 13,
'width' => 'half'
],
[
'collection' => 'directus_files',
'field' => 'uploaded_on',
'type' => \Directus\Database\Schema\DataTypes::TYPE_DATETIME,
'interface' => 'datetime',
'options' => json_encode([
'iconRight' => 'today'
]),
'locked' => 1,
'readonly' => 1,
'sort' => 8,
'width' => 'half',
'required' => 1
],
[
'collection' => 'directus_files',
'field' => 'uploaded_by',
'type' => \Directus\Database\Schema\DataTypes::TYPE_USER_CREATED,
'interface' => 'user-created',
'locked' => 1,
'readonly' => 1,
'sort' => 9,
'width' => 'half',
'required' => 1
],
[
'collection' => 'directus_files',
'field' => 'metadata',
'type' => \Directus\Database\Schema\DataTypes::TYPE_JSON,
'interface' => 'json',
'locked' => 1,
'sort' => 14
'sort' => 14,
'width' => 'full'
],
[
'collection' => 'directus_files',
Expand Down Expand Up @@ -1152,6 +1179,22 @@ public function run()
'locked' => 1,
'width' => 'half'
],

[
'collection' => 'directus_settings',
'field' => 'default_locale',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'language',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'telemetry',
'type' => \Directus\Database\Schema\DataTypes::TYPE_BOOLEAN,
'interface' => 'toggle',
'locked' => 1
],

// Users
// -----------------------------------------------------------------
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
use Phinx\Migration\AbstractMigration;
class AddLocaleAndTelemetryToSettingsTable extends AbstractMigration
{
public function up()
{
$settings = [
'default_locale' => [
'type' => 'string',
'interface' => 'language'
],
'telemetry' => [
'type' => 'boolean',
'interface' => 'toggle'
]
];
foreach ($settings as $field => $options) {
$this->addField($field, $options['type'], $options['interface']);
}
}
protected function addField($field, $type, $interface)
{
$collection = 'directus_settings';
$checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field);
$result = $this->query($checkSql)->fetch();
if (!$result) {
$insertSqlFormat = 'INSERT INTO `directus_fields` (`collection`, `field`, `type`, `interface`) VALUES ("%s", "%s", "%s", "%s");';
$insertSql = sprintf($insertSqlFormat, $collection, $field, $type, $interface);
$this->execute($insertSql);
}
}
}
4 changes: 2 additions & 2 deletions src/core/Directus/GraphQL/FieldsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function getFields()
$relation = $this->getRelation('o2m', $v['collection'], $v['field']);
$temp = [];
$temp['type'] = Types::listOf(Types::userCollection($relation['collection_one']));
$temp['resolve'] = function ($value) use ($relation) {
$temp['resolve'] = function ($value, $args, $context, $info) use ($relation) {
$data = [];
foreach ($value[$relation['collection_one']] as $v) {
foreach ($value[$info->fieldName] as $v) {
$data[] = $v[$relation['field_many']];
}
return $data;
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ function get_trusted_proxies()
*/
function get_project_info()
{
$settings = get_directus_settings_by_keys(['project_name', 'project_logo','project_color','project_foreground','project_background']);
$settings = get_directus_settings_by_keys(['project_name', 'project_logo','project_color','project_foreground','project_background','default_locale', 'telemetry']);
$settings['project_logo'] = array_get($settings, 'project_logo') ? get_project_logo_data(array_get($settings, 'project_logo')) : null;
$settings['project_foreground'] = array_get($settings, 'project_foreground') ? get_project_logo_data(array_get($settings, 'project_foreground')) : null;
$settings['project_background'] = array_get($settings, 'project_background') ? get_project_logo_data(array_get($settings, 'project_background')) : null;

$settings['telemetry'] = array_get($settings, 'telemetry') && $settings['telemetry'] ? true : false;
return $settings;
}
}
Expand Down

0 comments on commit ce6ffac

Please sign in to comment.