Skip to content

Commit

Permalink
feat: adding a plugin for folder tree editable
Browse files Browse the repository at this point in the history
  • Loading branch information
julienfrcds committed Apr 9, 2021
1 parent 87bbf99 commit 37c4345
Show file tree
Hide file tree
Showing 40 changed files with 548 additions and 10 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
"@request/api": "0.6.0",
"knex": "0.95.4",
"pg": "8.5.1",
"react-sortable-tree": "2.7.1",
"sqlite3": "5.0.2",
"strapi": "3.5.4",
"strapi-admin": "3.5.4",
"strapi-connector-bookshelf": "3.5.4",
"strapi-helper-plugin": "^3.5.4",
"strapi-plugin-content-manager": "3.5.4",
"strapi-plugin-content-type-builder": "3.5.4",
"strapi-plugin-documentation": "3.5.4",
Expand All @@ -46,4 +48,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
7 changes: 7 additions & 0 deletions plugins/tree-view-bookmarks/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 2
103 changes: 103 additions & 0 deletions plugins/tree-view-bookmarks/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

#
# The above will handle all files NOT found below
#

#
## These files are text and should be normalized (Convert crlf => lf)
#

# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text eol=lf
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text

# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text

# git config
.gitattributes text
.gitignore text
.gitconfig text

# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text

# misc config
*.yaml text
*.yml text
.editorconfig text

# build config
*.npmignore text
*.bowerrc text

# Heroku
Procfile text
.slugignore text

# Documentation
*.md text
LICENSE text
AUTHORS text


#
## These files are binary and should be left untouched
#

# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary
10 changes: 10 additions & 0 deletions plugins/tree-view-bookmarks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Don't check auto-generated stuff into git
coverage
node_modules
stats.json
package-lock.json

# Cruft
.DS_Store
npm-debug.log
.idea
3 changes: 3 additions & 0 deletions plugins/tree-view-bookmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Strapi plugin tree-view-bookmarks

A quick description of tree-view-bookmarks.
27 changes: 27 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/containers/App/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*
*/

import React from 'react';
import { Switch, Route } from 'react-router-dom';
import { NotFound } from 'strapi-helper-plugin';
// Utils
import pluginId from '../../pluginId';
// Containers
import HomePage from '../HomePage';

const App = () => {
return (
<div>
<Switch>
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
<Route component={NotFound} />
</Switch>
</div>
);
};

export default App;
31 changes: 31 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/containers/HomePage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
*
* HomePage
*
*/
import SortableTree from "react-sortable-tree";
import "react-sortable-tree/style.css"; // This only needs to be imported once in your app
import * as strapiHelper from "strapi-helper-plugin";

import React, { memo, useState } from "react";
// import PropTypes from 'prop-types';

const HomePage = () => {
console.log(strapiHelper); // Is there an helper for getting Tree ?
const treeDataInit = [
{ title: "Chicken", children: [{ title: "Egg" }, { title: "dazdaz" }] },
{ title: "coucou" },
];
const [treeData, setTreeData] = useState(treeDataInit);
return (
<div style={{ height: 400 }}>
<h1>Tree modifier</h1>
<SortableTree
treeData={treeData}
onChange={(treeData) => setTreeData(treeData)}
/>
</div>
);
};

export default memo(HomePage);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
*
* Initializer
*
*/

import { useEffect, useRef } from 'react';
import PropTypes from 'prop-types';
import pluginId from '../../pluginId';

const Initializer = ({ updatePlugin }) => {
const ref = useRef();
ref.current = updatePlugin;

useEffect(() => {
ref.current(pluginId, 'isReady', true);
}, []);

return null;
};

Initializer.propTypes = {
updatePlugin: PropTypes.func.isRequired,
};

export default Initializer;
52 changes: 52 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pluginPkg from '../../package.json';
import pluginId from './pluginId';
import App from './containers/App';
import Initializer from './containers/Initializer';
import lifecycles from './lifecycles';
import trads from './translations';

export default strapi => {
const pluginDescription = pluginPkg.strapi.description || pluginPkg.description;
const icon = pluginPkg.strapi.icon;
const name = pluginPkg.strapi.name;

const plugin = {
blockerComponent: null,
blockerComponentProps: {},
description: pluginDescription,
icon,
id: pluginId,
initializer: Initializer,
injectedComponents: [],
isReady: false,
isRequired: pluginPkg.strapi.required || false,
layout: null,
lifecycles,
mainComponent: App,
name,
preventComponentRendering: false,
trads,
menu: {
pluginsSectionLinks: [
{
destination: `/plugins/${pluginId}`,
icon,
label: {
id: `${pluginId}.plugin.name`,
defaultMessage: name,
},
name,
permissions: [
// Uncomment to set the permissions of the plugin here
// {
// action: '', // the action name should be plugins::plugin-name.actionType
// subject: null,
// },
],
},
],
},
};

return strapi.registerPlugin(plugin);
};
3 changes: 3 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/lifecycles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function lifecycles() {}

export default lifecycles;
7 changes: 7 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/pluginId.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const pluginPkg = require('../../package.json');
const pluginId = pluginPkg.name.replace(
/^strapi-plugin-/i,
''
);

module.exports = pluginId;
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/id.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
49 changes: 49 additions & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import ar from './ar.json';
import cs from './cs.json';
import de from './de.json';
import en from './en.json';
import es from './es.json';
import fr from './fr.json';
import id from './id.json';
import it from './it.json';
import ko from './ko.json';
import ms from './ms.json';
import nl from './nl.json';
import pl from './pl.json';
import ptBR from './pt-BR.json';
import pt from './pt.json';
import ru from './ru.json';
import th from './th.json';
import tr from './tr.json';
import uk from './uk.json';
import vi from './vi.json';
import zhHans from './zh-Hans.json';
import zh from './zh.json';
import sk from './sk.json';

const trads = {
ar,
cs,
de,
en,
es,
fr,
id,
it,
ko,
ms,
nl,
pl,
'pt-BR': ptBR,
pt,
ru,
th,
tr,
uk,
vi,
'zh-Hans': zhHans,
zh,
sk,
};

export default trads;
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/ko.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/ms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/pl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/sk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/th.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions plugins/tree-view-bookmarks/admin/src/translations/tr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 37c4345

Please sign in to comment.