* Show the view to start a new import, and also list out the existing
* in progress imports that are visible to the user.
*/
- public function start(Request $request)
+ public function start()
{
- // TODO - Test visibility access for listed items
$imports = $this->imports->getVisibleImports();
$this->setPageTitle(trans('entities.import'));
*/
public function show(int $id)
{
- // TODO - Test visibility access
$import = $this->imports->findVisible($id);
$this->setPageTitle(trans('entities.import_continue'));
return view('exports.import-show', [
'import' => $import,
+ 'data' => $import->decodeMetadata(),
]);
}
+ public function run(int $id, Request $request)
+ {
+ // TODO - Test access/visibility
+ $import = $this->imports->findVisible($id);
+ $parent = null;
+
+ if ($import->type === 'page' || $import->type === 'chapter') {
+ $data = $this->validate($request, [
+ 'parent' => ['required', 'string']
+ ]);
+ $parent = $data['parent'];
+ }
+
+ $entity = $this->imports->runImport($import, $parent);
+ if ($entity) {
+ $this->logActivity(ActivityType::IMPORT_RUN, $import);
+ return redirect($entity->getUrl());
+ }
+ // TODO - Redirect to result
+ // TODO - Or redirect back with errors
+ return 'failed';
+ }
+
/**
* Delete an active pending import from the filesystem and database.
*/
public function delete(int $id)
{
- // TODO - Test visibility access
$import = $this->imports->findVisible($id);
$this->imports->deleteImport($import);