Skip to content

Commit

Permalink
Merge pull request #586 from cboard-org/fix-obf-import
Browse files Browse the repository at this point in the history
Fix obf /obz import/export
  • Loading branch information
martinbedouret authored Dec 7, 2019
2 parents ca80a76 + 32c13af commit 6790edc
Show file tree
Hide file tree
Showing 59 changed files with 785 additions and 488 deletions.
376 changes: 188 additions & 188 deletions src/api/boards.obf.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion src/components/Settings/Export/Export.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import CircularProgress from '@material-ui/core/CircularProgress';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';

import FullScreenDialog from '../../UI/FullScreenDialog';
import messages from './Export.messages';

Expand Down Expand Up @@ -67,13 +69,19 @@ class Export extends React.Component {
<List>
<ListItem>
<ListItemText
className="Export__ListItemText"
primary={<FormattedMessage {...messages.export} />}
secondary={
<FormattedMessage
{...messages.exportSecondary}
values={{
cboardLink: (
<a href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard">
Cboard
</a>
),
link: (
<a href="http://www.openboardformat.org/">
<a href="https://www.openboardformat.org/">
OpenBoard
</a>
)
Expand All @@ -92,9 +100,11 @@ class Export extends React.Component {
)}
<Button
id="export-button"
color="primary"
disabled={this.state.loading}
onClick={this.openMenu.bind(this)}
>
<ArrowDropDownIcon />
<FormattedMessage {...messages.export} />
</Button>
<Menu
Expand Down
14 changes: 7 additions & 7 deletions src/components/Settings/Export/Export.constants.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const CBOARD_OBF_CONSTANTS = {
DATA_URL: 'http://myboards.net/api/v1/boards/',
URL: 'http://myboards.net/boards/',
DATA_URL: 'http://app.cboard.io/api/v1/boards/',
URL: 'http://app.cboard.io/boards/',
LICENSE: {
type: 'CC-By',
copyright_notice_url: 'http://creativecommons.org/licenses/by',
source_url: 'https://github.com/shayc/cboard',
author_name: 'Shay Cojocaru',
author_url: 'https://github.com/shayc',
author_email: 'shayc@outlook.com'
source_url: 'https://github.com/cboard-org',
author_name: 'Cboard',
author_url: 'https://www.cboard.io',
author_email: 'support@cboard.io'
}
};

Expand All @@ -19,7 +19,7 @@ export const CBOARD_ZIP_OPTIONS = {

export const CBOARD_COLUMNS = 6;
export const CBOARD_EXT_PREFIX = 'ext_cboard_';
export const CBOARD_EXT_PROPERTIES = ['labelKey', 'nameKey'];
export const CBOARD_EXT_PROPERTIES = ['labelKey', 'nameKey', 'hidden'];

export const EXPORT_CONFIG_BY_TYPE = {
cboard: {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Settings/Export/Export.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
position: relative;
}

.Export__ListItemText {
max-width: 80%;
}

.Export__ButtonContainer--spinner {
vertical-align: middle;
}
11 changes: 7 additions & 4 deletions src/components/Settings/Export/Export.helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async function boardToOBF(boardsMap, board = {}, intl) {
button['image_id'] = imageID;
images[imageID] = {
id: imageID,
path: `images${url}`,
path: `${url}`,
content_type: contentType,
width: 300,
height: 300
Expand All @@ -166,7 +166,8 @@ async function boardToOBF(boardsMap, board = {}, intl) {
}
})
);
if (grid.length > 1) {

if (grid.length >= 1) {
const lastGridRowDiff = CBOARD_COLUMNS - grid[grid.length - 1].length;
if (lastGridRowDiff > 0) {
const emptyButtons = new Array(lastGridRowDiff).map(() => null);
Expand All @@ -177,7 +178,7 @@ async function boardToOBF(boardsMap, board = {}, intl) {
format: 'open-board-0.1',
id: board.id,
locale: intl.locale,
name: intl.formatMessage({ id: board.nameKey || board.id }),
name: board.name,
url: `${CBOARD_OBF_CONSTANTS.URL}${board.id}`,
license: CBOARD_OBF_CONSTANTS.LICENSE,
images: Object.values(images),
Expand All @@ -193,7 +194,9 @@ async function boardToOBF(boardsMap, board = {}, intl) {
: ''
};

const boardExtProps = CBOARD_EXT_PROPERTIES.filter(key => !!board[key]);
const boardExtProps = CBOARD_EXT_PROPERTIES.filter(
key => typeof board[key] !== 'undefined'
);
boardExtProps.forEach(key => {
const keyWithPrefix = `${CBOARD_EXT_PREFIX}${toSnakeCase(key)}`;
obf[keyWithPrefix] = board[key];
Expand Down
5 changes: 3 additions & 2 deletions src/components/Settings/Export/Export.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ export default defineMessages({
},
exportSecondary: {
id: 'cboard.components.Settings.Export.exportSecondary',
defaultMessage: 'Export your board to Cboard format or {link} format'
defaultMessage:
'This option will export ALL the boards you have if you choose {cboardLink} format or {link} format. It will export JUST the current board if you choose PDF format.'
},
boardDownloaded: {
id: 'cboard.components.Settings.Export.boardDownloaded',
defaultMessage: 'Your board was downloaded'
defaultMessage: 'Your board(s) was downloaded'
},
boardDownloadedCva: {
id: 'cboard.components.Settings.Export.boardDownloadedCva',
Expand Down
60 changes: 54 additions & 6 deletions src/components/Settings/Export/__snapshots__/Export.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports[`Export tests default renderer 1`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -32,8 +33,13 @@ exports[`Export tests default renderer 1`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -47,10 +53,12 @@ exports[`Export tests default renderer 1`] = `
className="Export__ButtonContainer"
>
<WithStyles(Button)
color="primary"
disabled={false}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down Expand Up @@ -107,6 +115,7 @@ exports[`Export tests loading behavior 1`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -120,8 +129,13 @@ exports[`Export tests loading behavior 1`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -135,10 +149,12 @@ exports[`Export tests loading behavior 1`] = `
className="Export__ButtonContainer"
>
<WithStyles(Button)
color="primary"
disabled={false}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down Expand Up @@ -195,6 +211,7 @@ exports[`Export tests loading behavior 2`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -208,8 +225,13 @@ exports[`Export tests loading behavior 2`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -223,10 +245,12 @@ exports[`Export tests loading behavior 2`] = `
className="Export__ButtonContainer"
>
<WithStyles(Button)
color="primary"
disabled={false}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down Expand Up @@ -283,6 +307,7 @@ exports[`Export tests loading behavior 3`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -296,8 +321,13 @@ exports[`Export tests loading behavior 3`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -316,10 +346,12 @@ exports[`Export tests loading behavior 3`] = `
thickness={7}
/>
<WithStyles(Button)
color="primary"
disabled={true}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down Expand Up @@ -376,6 +408,7 @@ exports[`Export tests menu behavior 1`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -389,8 +422,13 @@ exports[`Export tests menu behavior 1`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -404,10 +442,12 @@ exports[`Export tests menu behavior 1`] = `
className="Export__ButtonContainer"
>
<WithStyles(Button)
color="primary"
disabled={false}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down Expand Up @@ -464,6 +504,7 @@ exports[`Export tests menu behavior 2`] = `
<WithStyles(List)>
<WithStyles(ListItem)>
<WithStyles(ListItemText)
className="Export__ListItemText"
primary={
<FormattedMessage
defaultMessage="Export"
Expand All @@ -477,8 +518,13 @@ exports[`Export tests menu behavior 2`] = `
id="cboard.components.Settings.Export.exportSecondary"
values={
Object {
"cboardLink": <a
href="https://www.cboard.io/help/#HowdoIimportaboardintoCboard"
>
Cboard
</a>,
"link": <a
href="http://www.openboardformat.org/"
href="https://www.openboardformat.org/"
>
OpenBoard
</a>,
Expand All @@ -492,10 +538,12 @@ exports[`Export tests menu behavior 2`] = `
className="Export__ButtonContainer"
>
<WithStyles(Button)
color="primary"
disabled={false}
id="export-button"
onClick={[Function]}
>
<pure(ArrowDropDownIcon) />
<FormattedMessage
defaultMessage="Export"
id="cboard.components.Settings.Export.export"
Expand Down
Loading

0 comments on commit 6790edc

Please sign in to comment.