MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Index (Mishka CMS Migration v0.0.1)

Copy Markdown View Source

A run's Items page, /admin/dashboard/migration/runs/:run/items: the items the migration keeps of the run's source host on the run's site (MishkaCmsMigration.MigrationItem), as the Gervaz table that resource defines. It is every item of that host, whichever run met it last, each with what the last dry run would do with it and what the last import did, and its "Imported by this run" filter narrows them to the ones this run's import met last.

The run is read as the Migration page reads it (MishkaCmsMigration.MigrationRun.fetch/2): a master's on any site, a site admin's on their own. A run the signed-in admin may not read, such as another site's id typed in the address, sends them back to the Migration page with a flash, and a site admin's table never reads another site's items. The table is scoped to the run's site and host by the page, as path params no filter can clear.

An admin's choices

A row's Leave out and Bring back, and the same for the rows picked with the checkboxes, leave an item out of every later dry run and import, or bring it back (MishkaCmsMigration.MigrationItem's :leave_out and :bring_back); the bulk ones ask first how many they change. Picking every row picks what the filters find, of the run's site and source host alone. A choice is refused while a dry run or an import of the site is running, in Gervaz's words for a failed action. Each choice is broadcast, and this page hands the item's notifications on to the table, which draws the item again in its place, in every tab open on it.

Dry run this item and Import this item

A row's Dry run this item and Import this item (:event row actions), Import once the admin confirms, are offered only while the run still holds what its source connects with (MishkaCmsMigration.MigrationRun.connectable?/1, handed to the table as the path param connectable, as Import the picked items is), and reach this page as {:row_action, "dry_run_item" | "import_item", %{"id" => id}}, and Import the picked items, for the rows picked with the checkboxes, as {:bulk_action, :import_items, ids}. The page reads the run again, as the Migration page reads it (MishkaCmsMigration.MigrationRun.fetch/2), and runs MishkaCmsMigration.dry_run_items/3 or MishkaCmsMigration.import_items/3 as the signed-in admin, on the run's site: the run's own job, for those items alone (MishkaCmsMigration.MigrationRun's "Picked items"). It says so in a flash; a step the run refuses is said in Gervaz's words for a failed action, and nothing changes. A step refused only because a dry run or an import of the site is running now (MishkaCmsMigration.MigrationRun.refused_while_running?/1) is no failure: a notice says so, "Not started. An import of this run is running. Wait until it finishes, then try again.", and a second click while the first one's job runs says the same. Import the picked items takes up to 100 rows picked one by one; picking every row picks what the filters find, which it does not take, and the admin is asked to pick the rows. Once the job has settled the items, their rows are drawn again from their broadcasts.

Dry run this item and Import this item then say what came of the item, each time it is pressed, in the tab it was pressed in: the item's own broadcast from the job (MishkaCmsMigration.MigrationItem.picked?/1) carries its plan or its last import, said in a flash as its row says it, such as "Import of Our Crew: Skipped. Its parent Our Story (#125) needs your decision: decide it and import it, then this one again.", an error flash for a failure. The page keeps only the ids it waits on, and reads nothing for it.

Import the picked items, and Import the branch, say what came of all of them in one flash once the job has settled the last one, or once the run is back from its import, whichever is first (MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Summary): "Import of 3 items: About failed: …; Team and أميرة حداد skipped: their parent was not imported." Nothing is read for it either.

The page follows its run's broadcasts ("migration_run:<site_id>:updated"), keeping only its status: while the run's dry run or import runs, the Decisions panel and the expanded branch disable what would change an item or start a job, and say why; anything still refused, such as a row action pressed then, says what the run is doing in words (MishkaCmsMigration.Resources.Validations.Status).

Map to… and the Map view

A category's or a tag's Map to…, in the List and in the Map view, shows the page's modal on the client and opens the item in the Gervaz form inside it (MishkaCmsMigration.MigrationItem's form, through the table's :edit row action), whose choices are read from the item it loaded (MishkaCmsMigration.MigrationItem.map_options/1): the site's categories, or tags, in the language it leads with, and Import as its own. Save maps it (:choose), and the modal closes; the table draws the item again from its broadcast.

Decide…

An item the import cannot place safely on its own, whose plan reads Needs your decision, has Decide… instead of Map to…: the same modal and form, with the conflict's choices in words (MishkaCmsMigration.MigrationItem.decision_options/1) under why the item waits, such as "This tag was deleted in Mishka CMS after it was imported" (MishkaCmsMigration.MigrationItem.decision_reason/1). Save keeps the decision (:choose), closes the modal and says that the next dry run and import follow it.

A run that put every item with no language of the site in one language (one_language of its options) says so in one line there too (MishkaCmsMigration.MigrationRun.one_language_words/1), from the path param one_language.

A cancelled run's table shows an alert between the filters and the rows (MishkaCmsMigration.MigrationRun.cancelled_words/1), from the path params cancelled and file_source.

When the links an import writes may not match the site's language addresses, the head shows the warning that says so (MishkaCmsMigrationWeb.Live.Admin.Dashboard.LanguageNotice), above the table that holds the main menu's Needs your decision.

The table's template switcher moves between the List and the Map view (MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Tree), which draws the items as the source nests them, each with its plan and its row actions; the table keeps the view in the address (items_template), so a reload shows the same one. Map categories, in the head, opens the page in the Map view on the categories (items_template=item_tree and the kind filter).

An expanded row ({:expand_row, id}) shows, for an item with a parent, where it sits (MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Branch): the item under its parents, read with it in one more query (MishkaCmsMigration.MigrationItem's :ancestors), each with where it stands and what can be done on it there, and, for an item that waits for its parent, that it waits and for what. Then, for the item of a user an import created, the warning that their password cannot be carried over (PasswordNotice), and, folded under Technical details (a <details> closed until opened), what is kept of the item as JSON: its stored attributes and its extra, the source's fields the CMS has no home for, with the value of anything named like a secret hidden. The item's content and its other fields are not kept, and the row says so.

Where it sits

The branch's buttons reach this page as events, each run as the signed-in admin on the run's site, on an item of the run's site and source host alone, and each said in a flash:

  • decide_node answers the conflict an item waits on with a choice (:choose with its conflict), "Decided. The next dry run and import follow your decision.";
  • decide_branch answers the same conflict with one choice on the branch's items that wait for it (MishkaCmsMigration.MigrationItem.decide_waiting/5), "3 items decided.", and draws the rows, the branch and the Decisions panel again once;
  • import_node imports one item, as Import this item does, and import_branch the branch's items not imported yet, parents first, as Import the picked items does; each then says what came of its items once its job settles them, the branch in one flash;
  • import_anyway decides that the expanded item is imported without its parent ("parent_missing" answered with "import") and imports it.

One of them refused only because a dry run or an import of the site is running now says so in a notice, "Not decided. …" for a decision and "Not started. …" for the rest, as Import this item does.

While a row is expanded, the broadcast of any item of its branch draws the branch again, so it shows each item where it stands now, as each result of a job arrives, and so does a change of the run's status.

Decisions

Above the table, the Decisions panel (MishkaCmsMigrationWeb.Live.Admin.Dashboard.Item.Decisions) groups what waits for a decision and decides a group at once; the page tells it of every item's broadcast, so it reads the groups again. A group's decision is one update that broadcasts no item, so once it is done the panel tells the page (:items_decided), which reloads the table's rows once and draws the expanded branch again.

Who may open it is the sidebar's declaration (MishkaCmsMigrationWeb.SidebarMenu), the Migration page's permission, which MishkaCmsCore.Sidebar.PageGuard reads on every mount.

Summary

Functions

Callback implementation for Phoenix.LiveView.render/1.

Functions

render(assigns)

Callback implementation for Phoenix.LiveView.render/1.