Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to normalize the slate-editor's nested node #641

Closed
3 tasks done
gabrielrtakeda opened this issue May 31, 2017 · 3 comments
Closed
3 tasks done

Script to normalize the slate-editor's nested node #641

gabrielrtakeda opened this issue May 31, 2017 · 3 comments

Comments

@gabrielrtakeda
Copy link
Contributor

gabrielrtakeda commented May 31, 2017

Description

It needs to create a script that normalizes the slate-editor's nested node-image on node-link state object to imageLink node

e.g.
Current nested nodes object

{
  "data": {
    "href": "http://www.wishlist.minhasampa.org.br/#block-4572",
    "title": null,
    "target": "_top"
  },
  "kind": "inline",
  "isVoid": false,
  "type": "link",
  "nodes": [
    { "kind": "text", "ranges": [{ "kind": "range", "text": "", "marks": [] }] },
    {
      "data": { "src": "https://s3.amazonaws.com/hub-central/uploads/1492722395_Ativo37.png" },
      "kind": "inline",
      "isVoid": true,
      "type": "image",
      "nodes": [{ "kind": "text", "ranges": [{ "kind": "range", "text": " ", "marks": [] }] }]
    },
    {
      "kind": "text",
      "ranges": [{ "kind": "range", "text": "", "marks": [] }]
    }
  ]
},

Target normalized imageLink object

{
  "data": {
    "src": "https://s3.amazonaws.com/hub-central/uploads/1492722395_Ativo37.png",
    "title": null,
    "href": "http://www.wishlist.minhasampa.org.br/#block-4572",
    "openExternal": true
  },
  "kind": "inline",
  "isVoid": true,
  "type": "imageLink",
  "nodes": [
    {
      "kind": "text",
      "ranges": [{ "kind": "range", "text": " ", "marks": [] }]
    }
  ]
},

Tasks

  • Create a function basing on a simple nested nodes case object and normalize it.
    TIP: To handle the object and make a deep find, may is a good idea to use libs like keyfinder or deep-filter-object
  • Get all the content widget objects that uses slate-editor and normalize it with function

Query to get all content widgets that uses slate-editor

SELECT id,
       (settings -> 'content')::json AS content
FROM widgets
WHERE settings -> 'content' ~ '^{"document';
  • Identify other nested objects cases and cover it
@gabrielrtakeda gabrielrtakeda created this issue from a note in Mobilization and Community better integration - Q2 (in-progress) May 31, 2017
@gabrielrtakeda gabrielrtakeda self-assigned this May 31, 2017
@gabrielrtakeda gabrielrtakeda added this to the v0.5.5 milestone May 31, 2017
@gabrielrtakeda
Copy link
Contributor Author

Solution

To solve this, follow the steps described in Migrate slate object from v2.4 to v2.6
from nossas/slate-editor repository.

@gabrielrtakeda
Copy link
Contributor Author

The migration has already been executed on production database. The affected mobilizations was described in the list below:

slug

157-mpoa-faca-acontecer
335-minha-casa-sem-policia
342-cpi-da-violencia-contra-a-mulher
344-site-2
353-pela-criacao-da-cpi-das-isencoes-fiscais
358-lista-fechada-nao
359-bike-no-metro
363-participe-do-mandato-marcelo-freixo
364-votacao-do-plano-municipal-de-educacao
365-pela-limpeza-do-canal-do-fragoso
367-instinto-de-vida
368-wishlist
374-culturapresente
376-mapa-moradores-de-rua
377-igualdade-na-escola
382-metas-de-sp-o-que-queremos
385-plano-diretor
387-retira-vinicius
388-merenda-saudavel
389-fora-vidigal
391-cade-o-cache
394-bonde
395-mais-lei-menos-lanche
396-nao-ao-corte-da-gratuidade
397-temer-uniu-o-brasil
399-queremos-conselho-lgbt
400-ruas-abertas
401-pela-aprovacao-da-lei-hip-hop-e-rua
403-so-recebe-quem-vota
412-reducao-de-danos
416-tessssssss
58-institucional-minha-campinas-teste1
85-transporte-publico-campinas
97-meu-recife
99-precisamos-falar-sobre-transporte-publico-em-porto-alegre

@gabrielrtakeda
Copy link
Contributor Author

I will check those mobs and, if it is all ok, I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

1 participant