Skip to content

Commit

Permalink
TASK: Revert notes in the sites module and only allow create blank site
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jan 17, 2025
1 parent 93b7dc2 commit d55bb1d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class SitesController extends AbstractModuleController
* This is not 100% correct, but it is as good as we can get it to work right now
* It works when the created site's name will use the configuration "*" which by default uses the default preset.
*
* As proposed here https://github.com/neos/neos-development-collection/issues/4470#issuecomment-2432140074
* the site must have a field to define the contentRepositoryId to correctly create sites dynamically.
*
* @Flow\InjectConfiguration("sitePresets.default.contentRepository")
*/
protected $defaultContentRepositoryForNewSites;
Expand Down Expand Up @@ -268,56 +271,16 @@ public function newSiteAction(): void
}

$documentNodeTypes = $contentRepository->getNodeTypeManager()->getSubNodeTypes(NodeTypeNameFactory::forSite(), false);
$liveWorkspace = $contentRepository->findWorkspaceByName(WorkspaceName::forLive());

$sitePackages = $this->packageManager->getFilteredPackages('available', 'neos-site');

$this->view->assignMultiple([
'defaultContentRepositoryForNewSites' => $contentRepositoryId->value,
// The live workspace has to be empty prior to importing, that's why we disable the functionality
'canImportFromPackage' => $liveWorkspace === null,
'sitePackages' => $sitePackages,
'documentNodeTypes' => $documentNodeTypes
]);
}

/**
* Import a site from site package.
*
* @param string $packageKey Package from where the import will come
* @Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
* @return void
*/
public function importSiteAction($packageKey)
{
try {
$contentRepositoryId = ContentRepositoryId::fromString($this->defaultContentRepositoryForNewSites ?? '');
} catch (\InvalidArgumentException $e) {
throw new \RuntimeException('The default content repository for new sites configured in "Neos.Neos.sitePresets.default.contentRepository" is not valid.', 1736946907, $e);
}

$package = $this->packageManager->getPackage($packageKey);
$path = Files::concatenatePaths([$package->getPackagePath(), 'Resources/Private/Content']);

// CreateRootWorkspace was denied: Creation of root workspaces is currently only allowed with disabled authorization checks
$this->securityContext->withoutAuthorizationChecks(fn () => $this->siteImportService->importFromPath(
$contentRepositoryId,
$path,
fn () => null,
fn () => null
));

$this->addFlashMessage(
$this->getModuleLabel('sites.theSiteHasBeenImported.body'),
'',
Message::SEVERITY_OK,
[],
1412372266
);

$this->redirect('index');
}

/**
* Create a new empty site.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</tbody>
</table>
<div class="neos-footer">
<f:link.action action="newSite" class="neos-button neos-button-primary" title="{neos:backend.translate(id: 'clickToCreate', value: 'Click to create new')}">{neos:backend.translate(id: 'sites.add', value: 'Add new site', source: 'Modules')} <i>(Deprecated)</i></f:link.action>
<f:link.action action="newSite" class="neos-button neos-button-primary" title="{neos:backend.translate(id: 'clickToCreate', value: 'Click to create new')}">{neos:backend.translate(id: 'sites.add', value: 'Add new site', source: 'Modules')}</f:link.action>
</div>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,14 @@
<f:layout name="BackendSubModule" />

<f:section name="content">
<h2>{neos:backend.translate(id: 'sites.new', value: 'New site', source: 'Modules')} <i>(Deprecated)</i></h2>

<br>
Using the sites management module for creation sites is deprecated please consider using the command line instead.
<br>
For example <code>./flow site:importall</code> for importing from a package or <code>./flow site:create</code> to create a new site.
<br>
All site creations will target the content repository: "{defaultContentRepositoryForNewSites}"
<h2>{neos:backend.translate(id: 'sites.new', value: 'New site', source: 'Modules')}</h2>

<div class="neos-row-fluid">
<f:form action="importSite">
<fieldset class="neos-span3">
<legend>{neos:backend.translate(id: 'sites.import', value: 'Import a site', source: 'Modules')}</legend>
<f:if condition="{canImportFromPackage ? false : true}">
NOTE: Currently it's only possible to import once into a content repository from a site package.
To reimport please prune the sites first via <code>./flow site:pruneall</code>.
<br><br>
</f:if>
<f:if condition="{sitePackages -> f:count()} > 0">
<f:then>
<div class="neos-control-group">
<label class="neos-control-label" for="site">{neos:backend.translate(id: 'sites.select', value: 'Select a site package', source: 'Modules')}</label>
<div class="neos-controls neos-select">
<f:form.select disabled="{canImportFromPackage ? false : true}" name="packageKey" options="{sitePackages}" optionLabelField="packageKey" optionValueField="packageKey" id="site" class="neos-span12" />
</div>
</div>
<f:form.submit disabled="{canImportFromPackage ? false : true}" value="{neos:backend.translate(id: 'sites.import', value: 'Import Site', source: 'Modules')}" class="neos-button neos-button-primary" />
</f:then>
<f:else>
<p>{neos:backend.translate(id: 'sites.noPackackeInfo', value: 'No site packages are available. Make sure you have an active site package.', source: 'Modules')}
</p>
</f:else>
</f:if>
</fieldset>
</f:form>

<f:form action="createSiteNode">
<fieldset class="neos-span3 neos-offset1">
<fieldset class="neos-span3">
<legend>{neos:backend.translate(id: 'sites.createBlank', value: 'Create a blank site', source: 'Modules')}</legend>
In the content repository: "{defaultContentRepositoryForNewSites}"

<f:if condition="{sitePackages -> f:count()} > 0">
<f:then>
<div class="neos-control-group">
Expand Down Expand Up @@ -72,18 +41,6 @@ <h2>{neos:backend.translate(id: 'sites.new', value: 'New site', source: 'Modules
</fieldset>
</f:form>

<div class="neos neos-row-fluid neos-span3">
<legend>Create a new site-package</legend>
NOTE: The functionality to create site packages via this module was removed as being too fragile.
To get started with neos head over to the setup:
<br>
<br>
<a href="/setup" class="neos-button neos-button-primary">/setup</a>
<br>
<br>
To kickstart a new package use: <code>./flow kickstart:site</code>
</div>

</div>
<div class="neos-footer">
<f:link.action action="index" class="neos-button">{neos:backend.translate(id: 'cancel', value: 'Cancel')}</f:link.action>
Expand Down
6 changes: 0 additions & 6 deletions Neos.Neos/Resources/Private/Translations/en/Modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@
<trans-unit id="sites.confirmDelete" xml:space="preserve">
<source>Yes, delete the site</source>
</trans-unit>
<trans-unit id="sites.import" xml:space="preserve">
<source>Import a site</source>
</trans-unit>
<trans-unit id="sites.select" xml:space="preserve">
<source>Select a site package</source>
</trans-unit>
Expand Down Expand Up @@ -545,9 +542,6 @@ Click on one of the nodes to only see its fallbacks and variants. Click again to
<trans-unit id="sites.update.body" xml:space="preserve">
<source>The site "{0}" has been updated.</source>
</trans-unit>
<trans-unit id="sites.theSiteHasBeenImported.body" xml:space="preserve">
<source>The site has been imported.</source>
</trans-unit>
<trans-unit id="sites.siteCreationError.siteWithSiteNodeNameAlreadyExists.title" xml:space="preserve">
<source>Site creation error</source>
</trans-unit>
Expand Down

0 comments on commit d55bb1d

Please sign in to comment.