{{define "head"}}{{with .Data.Run}}{{if .Refresh}}{{end}}{{end}}{{end}} {{define "content"}}{{$d := .Data}} {{template "page-header" dict "Title" "Import from Notion" "Sub" "Copy pages from a Notion workspace into this team's Mapa."}} {{template "notice" $d.Notice}} {{template "form-error" $d.Error}} {{with $d.Run}}

{{if eq .State "surveying"}}Reading Notion{{else if eq .State "writing"}}Writing pages{{else if eq .State "done"}}Run complete{{else if eq .State "interrupted"}}Interrupted{{else if eq .State "stopped"}}Stopped{{else}}The import failed{{end}}

{{if eq .State "surveying"}}

Pages read so far: {{number L .Surveyed}}. The total isn't known until every shared page has been read.

{{else if eq .State "writing"}}

{{number L .Written}} of {{number L .Total}} so far.

{{else if or (eq .State "interrupted") (eq .State "stopped")}}

{{if eq .State "interrupted"}}Mapa restarted during the import.{{else}}You stopped the import.{{end}} It had {{if .Total}}written {{number L .Written}} of {{number L .Total}} pages{{else}}read {{number L .Surveyed}} pages{{end}}. Resume carries on from there.

{{else if eq .State "done"}}

The report below shows how many pages were created, updated, kept, failed, and not imported.

{{else if eq .State "failed"}}

{{importFailure .Code}}

{{end}} {{if .Active}}

This page refreshes itself every five seconds. Closing it doesn't stop the import.

{{else if or (eq .State "surveying") (eq .State "writing")}}

Nothing has happened for a while. Stop it, then resume.

{{end}}
{{template "import-start" $d}}
{{else}}{{template "import-start" $d}}{{end}} {{with $d.Report}}{{template "import-report" .}}{{end}} {{if not $d.CanStop}}{{template "import-connection" $d}}{{end}} {{end}} {{define "import-start"}}{{if and .NoImages .CanStart}}

Images aren't set up in Mapa yet, so each image from Notion comes in as a line saying it wasn't imported. Run the import again once images are set up, and the pages nobody has edited get their pictures.

{{end}} {{with .Images}}{{if $.CanStart}}

Imported images count against the team's image allowance, now {{.Team}} used, and, until each page is written, against yours, now {{.Own}}. If either fills, the run stops fetching images and says so; raise it, or free some, and run again.

{{end}}{{end}} {{if or .CanStop .CanResume .CanStart .CanStartOver}}
{{if .CanStop}}
{{end}} {{if .CanResume}}
{{end}} {{if .CanStartOver}}
{{end}} {{if .CanStart}}
{{end}}
{{end}}{{end}} {{define "import-connection"}}

Connection

{{if .Connected}}

Connected to {{if .Workspace}}the Notion workspace “{{.Workspace}}”{{else}}a Notion workspace{{end}}. Mapa holds its secret, sealed, and never shows it.

Finish import…Disconnect…
Replace the secret{{template "import-token-form" .}}
{{else}}{{if .Finished}}

The previous import was ended. Connecting again starts a new import. It has no record of what the last one wrote, so it would create a second copy of every page it finds.

{{end}}

Everything you share with this integration becomes a team page that every member of this team can read. Share only what the whole team should have.

  1. In Notion, open the settings for connections and create a new internal integration called “Oficina import”.
  2. Under Capabilities, choose Read content only: no update, no insert, no comments. For user information, choose “Read user information without email addresses”.
  3. Share each top-level page you want with it. Pages inside them come too.
  4. Copy the integration's secret from Notion and paste it here.
{{template "import-token-form" .}}{{end}} {{if .Report}}

Forget the import…

{{end}}
{{end}} {{define "import-token-form"}}
{{template "field-text" dict "Name" "token" "Label" "Integration secret" "Type" "password" "Autocomplete" "off" "Required" true "Hint" "Mapa checks it with Notion once, then seals it. It reads; it never writes to Notion."}} {{template "form-foot" dict "Submit" "Connect"}}
{{end}} {{define "import-report"}}

Report

{{range .ImageFailures}}{{if eq .Label "images aren't set up in Mapa yet"}}

No images were imported: images aren't set up in Mapa yet. Each one is a line in its page. Run the import again once images are set up.

{{end}}{{if hasSuffix .Label "allowance is full"}}

Images stopped: {{.Label}}. Raise that allowance, or free some, and run the import again: the pages waiting for images are filled in.

{{end}}{{end}} {{with .Roots}}

Started from: {{range $i, $r := .}}{{if $i}}, {{end}}“{{$r}}”{{end}}.

{{end}} {{if or .Pinned .Unpinned}}

{{if not .Unpinned}}{{if eq .Pinned 1}}Pinned your top-level team page to your sidebar.{{else}}Pinned your {{number L .Pinned}} top-level team pages to your sidebar.{{end}}{{else if .Pinned}}Pinned {{number L .Pinned}} of your {{number L .Offered}} top-level team pages to your sidebar. Your sidebar holds {{number L .PinLimit}} pins.{{else if eq .Offered 1}}Your sidebar already holds {{number L .PinLimit}} pins, so your top-level team page wasn’t pinned. Unpin a page from sidebar first, then choose Pin to sidebar.{{else}}Your sidebar already holds {{number L .PinLimit}} pins, so your {{number L .Offered}} top-level team pages weren’t pinned. Unpin pages from sidebar first, then choose Pin to sidebar for each page.{{end}}

{{with .Unpinned}}{{end}}{{end}}
Pages seen
{{number L .Seen}}
Created
{{number L .Created}}
Updated
{{number L .Updated}}{{if .Renamed}}, {{number L .Renamed}} renamed{{end}}
Unchanged
{{number L .Unchanged}}
Kept, because they were edited in Mapa
{{number L .KeptEdited}}
Kept, because only their links were updated in Mapa
{{number L .KeptLinks}}
Deleted in Mapa, not created again
{{number L .Gone}}
Not found in Notion this time
{{if .SurveyDone}}{{number L .NotFound}}{{else}}Not known: reading Notion didn't finish{{end}}
Could not be determined
{{number L .Undetermined}}
Failed
{{number L .Failed}}{{range .FailedCodes}} ({{importFailure .Label}} {{number L .Count}}){{end}}
Databases found
{{number L (len .Databases)}}{{with .Databases}}: {{range $i, $n := .}}{{if $i}}, {{end}}“{{$n}}”{{end}}. They move to Fichas later{{end}}
Database rows shared directly
{{number L .Rows}}. Rows inside databases aren't counted until the databases move
Images imported
{{number L .Images.Imported}}
Images left as links
{{number L .Images.Links}}
Images not imported
{{range $i, $c := .ImageFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}
Icons imported
{{number L .Icons}}
Icons not imported
{{range $i, $c := .IconFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}
Banners imported
{{number L .Covers}}
Banners not imported
{{range $i, $c := .CoverFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}
Links to pages not shared with the import
{{number L .Unshared}}
Links still pointing at Notion
{{number L .Notion}}
Text adjusted so Mapa reads it literally
{{number L .Neutralised}}
Blocks written as a plain copy
{{number L .Fallbacks}}
{{range .Losses}}
{{.Label}}
{{number L .Count}}
{{end}}
{{template "import-list" dict "Title" "Titles changed to fit Mapa" "Pages" .Fitted}} {{template "import-list" dict "Title" "Pages kept" "Pages" .Kept}} {{template "import-list" dict "Title" "Pages that failed" "Pages" .FailedPages}} {{template "import-list" dict "Title" "Pages not found in Notion this time" "Pages" .NotFoundPages}} {{template "import-list" dict "Title" "Pages holding a note about something not imported" "Pages" .Placeholders}} {{template "import-list" dict "Title" "Pages from inside a database row, imported without the row" "Pages" .UnderRow}}
{{end}} {{define "import-list"}}{{with .Pages}}

{{$.Title}}

{{end}}{{end}}