Loading modules/cloud_dashboard/cloud_dashboard/src/pages/EntityInfoPage.tsx +3 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/pages/EntityInfoPage.tsx: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import EntityInfoTemplate from 'model/EntityInfoTemplate'; import EntityInfoPanel from 'organisms/EntityInfoPanel'; import MenuBar from 'organisms/MenuBar'; import K8sDeploymentScalePage from 'pages/k8s/K8sDeploymentScalePage'; import K8sEntityDeletePage from 'pages/k8s/K8sEntityDeletePage'; import K8sEntityEditPage from 'pages/k8s/K8sEntityEditPage'; import K8sNamespaceDeletePage from 'pages/k8s/K8sNamespaceDeletePage'; import K8sNamespaceEditPage from 'pages/k8s/K8sNamespaceEditPage'; Loading Loading @@ -206,6 +207,8 @@ const EntityInfoPage = ({ entityInfoTemplate }: { switch (entityInfoTemplate.entityName) { case 'namespace': return <K8sNamespaceDeletePage entityInfoTemplate={entityInfoTemplate} />; default: return <K8sEntityDeletePage entityInfoTemplate={entityInfoTemplate} />; } } Loading modules/cloud_dashboard/cloud_dashboard/src/pages/k8s/K8sEntityDeletePage.tsx 0 → 100644 +53 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/pages/k8s/K8sEntityDeletePage.tsx: 53 added lines, 0 removed lines. Original line number Diff line number Diff line import Button from 'bootstrap3-components/Button'; import Col from 'bootstrap3-components/Col'; import FluidContainer from 'bootstrap3-components/FluidContainer'; import Form from 'bootstrap3-components/Form'; import GlyphIcon from 'bootstrap3-components/GlyphIcon'; import Row from 'bootstrap3-components/Row'; import EntityInfoTemplate from 'model/EntityInfoTemplate'; import MenuBar from 'organisms/MenuBar'; import LoadingEntityDataPage from 'pages/LoadingEntityDataPage'; import { useTranslation } from 'react-i18next'; import { useEntityData } from 'service/state'; /** * Page of entity info editor. * * @param entityInfoTemplate Template for viewing this entity data. */ const K8sEntityDeletePage = ({ entityInfoTemplate }: { entityInfoTemplate: EntityInfoTemplate }) => { const { entityData, cxud } = useEntityData(entityInfoTemplate); const { t } = useTranslation(); return entityData === null ? <LoadingEntityDataPage /> : <> <MenuBar /> <FluidContainer className="px-0"> <Row className="mx-0"> <Col> <Form> <Form.Group> <Form.Label>Are you sure you want to delete the "{entityData.attributes['name']}" {entityInfoTemplate.entityName}?</Form.Label> </Form.Group> <Button className="icon-before btn-success" onClick={() => { cxud({ 'k8s_entity': entityData.attributes['drupal_internal__id'], }, 'delete'); }}> <GlyphIcon iconName="trash" />{' ' + t('Delete')} </Button> {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} <a href="#" className="button button--danger">{t('Cancel')}</a> </Form> </Col> </Row> </FluidContainer> </>; } export default K8sEntityDeletePage; modules/cloud_service_providers/k8s/k8s.routing.yml +24 −0 Changes for modules/cloud_service_providers/k8s/k8s.routing.yml: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -924,3 +924,27 @@ entity.k8s_deployment.scale: methods: [POST] requirements: _entity_access: 'k8s_deployment.edit' entity.k8s_namespace.delete: path: '/cloud_dashboard/k8s/{cloud_context}/namespace/{k8s_namespace}/delete' defaults: _controller: '\Drupal\k8s\Controller\ApiController::deleteNamespace' methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any namespace+delete own namespace' entity.k8s_entity.delete: path: '/cloud_dashboard/k8s/{cloud_context}/{entity_type_id}/delete' defaults: _controller: '\Drupal\k8s\Controller\ApiController::deleteK8sEntity' methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any {entity_type_id}+delete own {entity_type_id}' modules/cloud_service_providers/k8s/src/Controller/ApiController.php +33 −4 Changes for modules/cloud_service_providers/k8s/src/Controller/ApiController.php: 33 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { * * @var \Drupal\cloud\Service\CloudServiceInterface */ protected $cloudService; private $cloudService; /** * The current user. Loading @@ -112,7 +112,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { * * @var array */ protected $configuration; private $configuration; /** * The cloud service provider plugin manager (CloudConfigPluginManager). Loading Loading @@ -1008,7 +1008,8 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->scaleDeployment($entity, (int) $podNumber); Loading @@ -1034,7 +1035,8 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->deleteNamespace($entity); Loading @@ -1049,4 +1051,31 @@ class ApiController extends ControllerBase implements ApiControllerInterface { ], 500); } /** * {@inheritdoc} */ public function deleteK8sEntity(Request $request, string $cloud_context, string $entity_type_id): JsonResponse { $k8s_entity = $request->get('k8s_entity', 0); $entity = $this->entityTypeManager ->getStorage('k8s_' . $entity_type_id) ->load($k8s_entity); $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->deleteK8sEntity($entity); return !empty($result) ? new JsonResponse([ 'result' => 'OK', ], 200) : new JsonResponse([ 'result' => 'NG', 'reason' => 'Internal Server Error', ], 500); } } modules/cloud_service_providers/k8s/src/Controller/ApiControllerInterface.php +15 −0 Changes for modules/cloud_service_providers/k8s/src/Controller/ApiControllerInterface.php: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -570,4 +570,19 @@ interface ApiControllerInterface { */ public function deleteNamespace(Request $request, string $cloud_context, string $k8s_namespace): JsonResponse; /** * Delete K8s other entity. * * @param \Symfony\Component\HttpFoundation\Request $request * Request. * @param string $cloud_context * Cloud context string. * @param string $entity_type_id * Entity type id. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function deleteK8sEntity(Request $request, string $cloud_context, string $entity_type_id): JsonResponse; } Loading
modules/cloud_dashboard/cloud_dashboard/src/pages/EntityInfoPage.tsx +3 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/pages/EntityInfoPage.tsx: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import EntityInfoTemplate from 'model/EntityInfoTemplate'; import EntityInfoPanel from 'organisms/EntityInfoPanel'; import MenuBar from 'organisms/MenuBar'; import K8sDeploymentScalePage from 'pages/k8s/K8sDeploymentScalePage'; import K8sEntityDeletePage from 'pages/k8s/K8sEntityDeletePage'; import K8sEntityEditPage from 'pages/k8s/K8sEntityEditPage'; import K8sNamespaceDeletePage from 'pages/k8s/K8sNamespaceDeletePage'; import K8sNamespaceEditPage from 'pages/k8s/K8sNamespaceEditPage'; Loading Loading @@ -206,6 +207,8 @@ const EntityInfoPage = ({ entityInfoTemplate }: { switch (entityInfoTemplate.entityName) { case 'namespace': return <K8sNamespaceDeletePage entityInfoTemplate={entityInfoTemplate} />; default: return <K8sEntityDeletePage entityInfoTemplate={entityInfoTemplate} />; } } Loading
modules/cloud_dashboard/cloud_dashboard/src/pages/k8s/K8sEntityDeletePage.tsx 0 → 100644 +53 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/pages/k8s/K8sEntityDeletePage.tsx: 53 added lines, 0 removed lines. Original line number Diff line number Diff line import Button from 'bootstrap3-components/Button'; import Col from 'bootstrap3-components/Col'; import FluidContainer from 'bootstrap3-components/FluidContainer'; import Form from 'bootstrap3-components/Form'; import GlyphIcon from 'bootstrap3-components/GlyphIcon'; import Row from 'bootstrap3-components/Row'; import EntityInfoTemplate from 'model/EntityInfoTemplate'; import MenuBar from 'organisms/MenuBar'; import LoadingEntityDataPage from 'pages/LoadingEntityDataPage'; import { useTranslation } from 'react-i18next'; import { useEntityData } from 'service/state'; /** * Page of entity info editor. * * @param entityInfoTemplate Template for viewing this entity data. */ const K8sEntityDeletePage = ({ entityInfoTemplate }: { entityInfoTemplate: EntityInfoTemplate }) => { const { entityData, cxud } = useEntityData(entityInfoTemplate); const { t } = useTranslation(); return entityData === null ? <LoadingEntityDataPage /> : <> <MenuBar /> <FluidContainer className="px-0"> <Row className="mx-0"> <Col> <Form> <Form.Group> <Form.Label>Are you sure you want to delete the "{entityData.attributes['name']}" {entityInfoTemplate.entityName}?</Form.Label> </Form.Group> <Button className="icon-before btn-success" onClick={() => { cxud({ 'k8s_entity': entityData.attributes['drupal_internal__id'], }, 'delete'); }}> <GlyphIcon iconName="trash" />{' ' + t('Delete')} </Button> {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} <a href="#" className="button button--danger">{t('Cancel')}</a> </Form> </Col> </Row> </FluidContainer> </>; } export default K8sEntityDeletePage;
modules/cloud_service_providers/k8s/k8s.routing.yml +24 −0 Changes for modules/cloud_service_providers/k8s/k8s.routing.yml: 24 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -924,3 +924,27 @@ entity.k8s_deployment.scale: methods: [POST] requirements: _entity_access: 'k8s_deployment.edit' entity.k8s_namespace.delete: path: '/cloud_dashboard/k8s/{cloud_context}/namespace/{k8s_namespace}/delete' defaults: _controller: '\Drupal\k8s\Controller\ApiController::deleteNamespace' methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any namespace+delete own namespace' entity.k8s_entity.delete: path: '/cloud_dashboard/k8s/{cloud_context}/{entity_type_id}/delete' defaults: _controller: '\Drupal\k8s\Controller\ApiController::deleteK8sEntity' methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any {entity_type_id}+delete own {entity_type_id}'
modules/cloud_service_providers/k8s/src/Controller/ApiController.php +33 −4 Changes for modules/cloud_service_providers/k8s/src/Controller/ApiController.php: 33 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -98,7 +98,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { * * @var \Drupal\cloud\Service\CloudServiceInterface */ protected $cloudService; private $cloudService; /** * The current user. Loading @@ -112,7 +112,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { * * @var array */ protected $configuration; private $configuration; /** * The cloud service provider plugin manager (CloudConfigPluginManager). Loading Loading @@ -1008,7 +1008,8 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->scaleDeployment($entity, (int) $podNumber); Loading @@ -1034,7 +1035,8 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->deleteNamespace($entity); Loading @@ -1049,4 +1051,31 @@ class ApiController extends ControllerBase implements ApiControllerInterface { ], 500); } /** * {@inheritdoc} */ public function deleteK8sEntity(Request $request, string $cloud_context, string $entity_type_id): JsonResponse { $k8s_entity = $request->get('k8s_entity', 0); $entity = $this->entityTypeManager ->getStorage('k8s_' . $entity_type_id) ->load($k8s_entity); $service = new K8sOperationsService( $this->k8sService, $this->cloudService, $this->cloudConfigPluginManager, $this->entityTypeManager ); $result = $service->deleteK8sEntity($entity); return !empty($result) ? new JsonResponse([ 'result' => 'OK', ], 200) : new JsonResponse([ 'result' => 'NG', 'reason' => 'Internal Server Error', ], 500); } }
modules/cloud_service_providers/k8s/src/Controller/ApiControllerInterface.php +15 −0 Changes for modules/cloud_service_providers/k8s/src/Controller/ApiControllerInterface.php: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -570,4 +570,19 @@ interface ApiControllerInterface { */ public function deleteNamespace(Request $request, string $cloud_context, string $k8s_namespace): JsonResponse; /** * Delete K8s other entity. * * @param \Symfony\Component\HttpFoundation\Request $request * Request. * @param string $cloud_context * Cloud context string. * @param string $entity_type_id * Entity type id. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function deleteK8sEntity(Request $request, string $cloud_context, string $entity_type_id): JsonResponse; }