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

Commit

Permalink
add missing global settings fields
Browse files Browse the repository at this point in the history
Closes #676
  • Loading branch information
wellingguzman committed Jan 11, 2019
1 parent 4cad47f commit fa76c9b
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 13 deletions.
66 changes: 61 additions & 5 deletions migrations/db/seeds/FieldsSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,23 @@ public function run()
// -----------------------------------------------------------------
[
'collection' => 'directus_settings',
'field' => 'auto_sign_out',
'type' => \Directus\Database\Schema\DataTypes::TYPE_INTEGER,
'interface' => 'numeric',
'field' => 'project_name',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'project_url',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'app_url',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'locked' => 1
],
[
Expand All @@ -947,6 +961,20 @@ public function run()
'interface' => 'color-palette',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'default_limit',
'type' => \Directus\Database\Schema\DataTypes::TYPE_INTEGER,
'interface' => 'numeric',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'auto_sign_out',
'type' => \Directus\Database\Schema\DataTypes::TYPE_INTEGER,
'interface' => 'numeric',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'trusted_proxies',
Expand All @@ -956,14 +984,42 @@ public function run()
],
[
'collection' => 'directus_settings',
'field' => 'project_url',
'field' => 'youtube_api',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'app_url',
'field' => 'thumbnail_dimensions',
'type' => \Directus\Database\Schema\DataTypes::TYPE_ARRAY,
'interface' => 'tags',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'thumbnail_quality_tags',
'type' => \Directus\Database\Schema\DataTypes::TYPE_JSON,
'interface' => 'code',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'thumbnail_actions',
'type' => \Directus\Database\Schema\DataTypes::TYPE_JSON,
'interface' => 'code',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'thumbnail_cache_ttl',
'type' => \Directus\Database\Schema\DataTypes::TYPE_INTEGER,
'interface' => 'numeric',
'locked' => 1
],
[
'collection' => 'directus_settings',
'field' => 'thumbnail_not_found_location',
'type' => \Directus\Database\Schema\DataTypes::TYPE_STRING,
'interface' => 'text-input',
'locked' => 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

use Phinx\Migration\AbstractMigration;

class AddMissingSettingsField extends AbstractMigration
{
public function up()
{
$settings = [
'project_name' => [
'type' => 'string',
'interface' => 'text-input',
],
'default_limit' => [
'type' => 'integer',
'interface' => 'numeric',
],
'auto_sign_out' => [
'type' => 'integer',
'interface' => 'numeric',
],
'youtube_api' => [
'type' => 'string',
'interface' => 'text-input',
],
'thumbnail_dimensions' => [
'type' => 'array',
'interface' => 'tags',
],
'thumbnail_quality_tags' => [
'type' => 'json',
'interface' => 'code',
],
'thumbnail_actions' => [
'type' => 'json',
'interface' => 'code',
],
'thumbnail_cache_ttl' => [
'type' => 'integer',
'interface' => 'numeric',
],
'thumbnail_not_found_location' => [
'type' => 'string',
'interface' => 'text-input',
],
];

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);
}
}
}
16 changes: 8 additions & 8 deletions src/core/Directus/Util/Installation/InstallerUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,6 @@ private static function getMigrationConfig($basePath, $projectName = null, $migr
private static function getDefaultSettings($data)
{
return [
[
'key' => 'auto_sign_out',
'value' => '60'
],
[
'key' => 'project_name',
'value' => isset($data['project_name']) ? $data['project_name'] : 'Directus'
Expand All @@ -648,10 +644,6 @@ private static function getDefaultSettings($data)
'key' => 'app_url',
'value' => isset($data['app_url']) ? $data['app_url'] : ''
],
[
'key' => 'default_limit',
'value' => '200'
],
[
'key' => 'logo',
'value' => ''
Expand All @@ -660,6 +652,14 @@ private static function getDefaultSettings($data)
'key' => 'color',
'value' => 'light-blue-600'
],
[
'key' => 'default_limit',
'value' => '200'
],
[
'key' => 'auto_sign_out',
'value' => '60'
],
[
'key' => 'youtube_api_key',
'value' => ''
Expand Down

0 comments on commit fa76c9b

Please sign in to comment.