Skip to content

Commit 438a1f8

Browse files
[spalenque] - #13550 * Project Navigator Revamp (#122)
component category cms WIP migration and tags bug fix migration bugfix rollback injest task and fix cms grids changes on admin
1 parent fd3a67d commit 438a1f8

24 files changed

Lines changed: 1071 additions & 292 deletions

migrations/migrations.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ migrations:
9999
- AddOnDeleteCascadeForEventsAndPresentationMaterials
100100
- AddSummitCalendarSyncErrorEmailMigration
101101
- RefactorDefaultEventTypesMigration
102-
102+
- PopulateComponentCategoriesMigration
103+
- PopulateSubCategoriesAndTagsMigration

openstack/code/CommunityPageBis.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,6 @@ function init()
7171
Requirements::javascript('themes/openstack/javascript/community-bis.js');
7272
}
7373

74-
function getProjectGroups() {
75-
$groups = OpenStackComponent::$categories;
76-
$list = new ArrayList();
77-
foreach ($groups as $key => $group) {
78-
$list->push(new ArrayData([
79-
'Name' => $group,
80-
'Key' => $key
81-
]));
82-
}
83-
84-
return $list;
85-
}
86-
8774
function getComponentsByGroup($group) {
8875
return OpenStackComponent::get()->filter('Use', $group);
8976
}

software/_config.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818

1919
Object::add_extension('OpenStackComponent', 'OpenStackComponentAdminUI');
20+
Object::add_extension('OpenStackComponentCategory', 'OpenStackComponentCategoryAdminUI');
21+
Object::add_extension('OpenStackComponentSubCategory', 'OpenStackComponentSubCategoryAdminUI');
22+
Object::add_extension('OpenStackComponentTag', 'OpenStackComponentTagAdminUI');
2023
Object::add_extension('OpenStackApiVersion', 'OpenStackApiVersionAdminUI');
2124
Object::add_extension('OpenStackRelease', 'OpenStackReleaseAdminUI');
2225
Object::add_extension('OpenStackReleaseSupportedApiVersion', 'OpenStackReleaseSupportedApiVersionAdminUI');

software/code/infrastructure/active_records/OpenStackComponent.php

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,6 @@ class OpenStackComponent extends DataObject implements IOpenStackComponent
2020

2121
use SluggableEntity;
2222

23-
// IMPORTANT : this fixes the order for categories on software page
24-
public static $categories = array(
25-
"Compute",
26-
"Storage, Backup & Recovery",
27-
"Networking & Content Delivery",
28-
"Data & Analytics",
29-
"Security, Identity & Compliance",
30-
"Management Tools",
31-
"Deployment Tools",
32-
"Application Services",
33-
"None"
34-
);
35-
3623
static $db = array
3724
(
3825
'Name' => 'Varchar(255)',
@@ -41,37 +28,38 @@ class OpenStackComponent extends DataObject implements IOpenStackComponent
4128
'SupportsVersioning' => 'Boolean',
4229
'SupportsExtensions' => 'Boolean',
4330
'IsCoreService' => 'Boolean',
44-
'Use' => 'Enum(array("Application Services","Compute","Data & Analytics","Deployment Tools","Management Tools","Monitoring & Metering","Networking & Content Delivery","Security, Identity & Compliance","Storage, Backup & Recovery","None"), "None")',
45-
'HasStableBranches' => 'Boolean',
4631
'WikiUrl' => 'Text',
47-
'TCApprovedRelease' => 'Boolean',
48-
'HasTeamDiversity' => 'Boolean',
49-
'IncludedComputeStarterKit' => 'Boolean',
50-
'VulnerabilityManaged' => 'Boolean',
5132
'Order' => 'Int',
5233
'YouTubeID' => 'Varchar',
5334
'VideoDescription' => 'Text',
5435
'VideoTitle' => 'Varchar',
55-
'FollowsStandardDeprecation' => 'Boolean',
56-
'SupportsUpgrade' => 'Boolean',
57-
'SupportsRollingUpgrade' => 'Boolean',
5836
'ShowOnMarketplace' => 'Boolean(1)',
5937
'Slug' => 'Varchar(255)'
6038
);
6139

6240
static $has_one = array
6341
(
64-
"LatestReleasePTL" => "Member",
65-
"Mascot" => "Mascot"
42+
"LatestReleasePTL" => "Member",
43+
"Mascot" => "Mascot",
44+
"SubCategory" => "OpenStackComponentSubCategory"
6645
);
6746

6847
static $has_many = array
6948
(
70-
'Versions' => 'OpenStackApiVersion',
71-
'RelatedContent' => 'OpenStackComponentRelatedContent',
72-
'Caveats' => 'OpenStackComponentReleaseCaveat',
49+
'Versions' => 'OpenStackApiVersion',
50+
'RelatedContent' => 'OpenStackComponentRelatedContent',
51+
'Caveats' => 'OpenStackComponentReleaseCaveat'
52+
);
53+
54+
static $many_many = array
55+
(
56+
'Tags' => 'OpenStackComponentTag'
7357
);
7458

59+
private static $many_many_extraFields = array
60+
(
61+
'Tags' => array( 'SortOrder' => 'Int' )
62+
);
7563

7664
static $belongs_many_many = array
7765
(
@@ -299,4 +287,29 @@ public function getCaveatsForReleaseType($release_id, $type)
299287
)
300288
);
301289
}
290+
291+
/**
292+
* @param IOpenStackComponentTag $new_tag
293+
* @return void
294+
*/
295+
public function addTag(IOpenStackComponentTag $new_tag)
296+
{
297+
AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'Tags')->add($new_tag);
298+
}
299+
300+
/**
301+
* @return IOpenStackComponentTag[]
302+
*/
303+
public function getMaturityTags()
304+
{
305+
return $this->Tags()->filter('Type', 'maturity');
306+
}
307+
308+
/**
309+
* @return IOpenStackComponentTag[]
310+
*/
311+
public function getInfoTags()
312+
{
313+
return $this->Tags()->filter('Type', 'info');
314+
}
302315
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright 2017 Openstack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
/**
16+
* Class OpenStackComponentCategory
17+
*/
18+
class OpenStackComponentCategory extends DataObject implements IOpenStackComponentCategory
19+
{
20+
21+
static $db = array
22+
(
23+
'Name' => 'Varchar(255)',
24+
'Description' => 'Text',
25+
'Order' => 'Int'
26+
);
27+
28+
static $many_many = array
29+
(
30+
'SubCategories' => 'OpenStackComponentSubCategory'
31+
);
32+
33+
static $many_many_extraFields = array(
34+
'SubCategories' => array(
35+
'SubCatOrder' => 'Int'
36+
)
37+
);
38+
39+
/**
40+
* @return int
41+
*/
42+
public function getIdentifier()
43+
{
44+
return (int)$this->getField('ID');
45+
}
46+
47+
public function getName()
48+
{
49+
return $this->getField('Name');
50+
}
51+
52+
public function setName($name)
53+
{
54+
$this->setField('Name', $name);
55+
}
56+
57+
public function getDescription()
58+
{
59+
return $this->getField('Description');
60+
}
61+
62+
public function setDescription($description)
63+
{
64+
$this->setField('Description', $description);
65+
}
66+
67+
public function getOrder()
68+
{
69+
return $this->getField('Order');
70+
}
71+
72+
public function setOrder($order)
73+
{
74+
$this->setField('Order', $order);
75+
}
76+
77+
/**
78+
* @return array
79+
* @throws Exception
80+
*/
81+
public function getSubCategories()
82+
{
83+
return AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'SubCategories')->toArray();
84+
}
85+
86+
/**
87+
* @param IOpenStackComponentSubCategory $new_sub_category
88+
* @throws Exception
89+
*/
90+
public function addSubCategory(IOpenStackComponentSubCategory $new_sub_category)
91+
{
92+
AssociationFactory::getInstance()->getMany2ManyAssociation($this, 'SubCategories')->add($new_sub_category);
93+
}
94+
95+
/**
96+
* @param int $component_id
97+
* @return bool
98+
*/
99+
public function hasOpenStackComponent($component_id)
100+
{
101+
foreach ($this->getSubCategories() as $subCategory) {
102+
if ($subCategory->hasOpenStackComponent($component_id)) {
103+
return true;
104+
}
105+
}
106+
107+
return false;
108+
}
109+
110+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
/**
3+
* Copyright 2017 Openstack Foundation
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
**/
14+
15+
/**
16+
* Class OpenStackComponentSubCategory
17+
*/
18+
class OpenStackComponentSubCategory extends DataObject implements IOpenStackComponentSubCategory
19+
{
20+
21+
static $db = array
22+
(
23+
'Name' => 'Varchar(255)',
24+
'Description' => 'Text'
25+
);
26+
27+
static $has_many = array
28+
(
29+
'OpenStackComponents' => 'OpenStackComponent'
30+
);
31+
32+
static $belongs_many_many = array
33+
(
34+
'Categories' => 'OpenStackComponentCategory'
35+
);
36+
37+
/**
38+
* @return int
39+
*/
40+
public function getIdentifier()
41+
{
42+
return (int)$this->getField('ID');
43+
}
44+
45+
public function getName()
46+
{
47+
return $this->getField('Name');
48+
}
49+
50+
public function setName($name)
51+
{
52+
$this->setField('Name', $name);
53+
}
54+
55+
public function getDescription()
56+
{
57+
return $this->getField('Description');
58+
}
59+
60+
public function setDescription($description)
61+
{
62+
$this->setField('Description', $description);
63+
}
64+
65+
public function getOrder()
66+
{
67+
return $this->getField('Order');
68+
}
69+
70+
public function setOrder($order)
71+
{
72+
$this->setField('Order', $order);
73+
}
74+
75+
/**
76+
* @return array
77+
* @throws Exception
78+
*/
79+
public function getOpenStackComponents()
80+
{
81+
return AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'OpenStackComponents')->toArray();
82+
}
83+
84+
/**
85+
* @param IOpenStackComponent $new_component
86+
* @throws Exception
87+
*/
88+
public function addOpenStackComponent(IOpenStackComponent $new_component)
89+
{
90+
AssociationFactory::getInstance()->getOne2ManyAssociation($this, 'OpenStackComponents')->add($new_component);
91+
}
92+
93+
/**
94+
* @param int $component_id
95+
* @return bool
96+
*/
97+
public function hasOpenStackComponent($component_id)
98+
{
99+
foreach ($this->getOpenStackComponents() as $component) {
100+
if ($component->getIdentifier() == $component_id) {
101+
return true;
102+
}
103+
}
104+
105+
return false;
106+
}
107+
108+
}

0 commit comments

Comments
 (0)