fix: add deprecated file-safe component (#1141)

* fix: add deprecated file-safe component

* chore: add file-safe source

* fix: file-safe build script

* chore: run package script

* fix: use root node-sass

* chore: remove zip so CI generates it

* chore: commit dist files

* chore: remove dist/assets/org.standardnotes.file-safe files

* chore: remove changelog script

Co-authored-by: Johnny Almonte <johnny243@users.noreply.github.com>
This commit is contained in:
Johnny A
2022-06-23 18:12:16 -04:00
committed by GitHub
parent 3cece858b1
commit a3a0952e68
146 changed files with 18755 additions and 78 deletions

View File

@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}

View File

@@ -0,0 +1 @@
node_modules

View File

@@ -0,0 +1,3 @@
# FileSafe Bar
Embeddable FileSafe Bar component

View File

@@ -0,0 +1,111 @@
import React from 'react';
import FilesafeEmbed from "filesafe-embed";
import Filesafe from "filesafe-js";
import ComponentManager from 'sn-components-api';
const BaseHeight = 53;
const MessageHavingHeight = 28;
const PerMessageHeight = 22;
const ExpandedHeight = 305;
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {expanded: false};
}
componentDidMount() {
this.componentManager = new ComponentManager(null, () => {
// On ready and permissions authorization
document.documentElement.classList.add(this.componentManager.platform);
});
this.filesafe = new Filesafe({componentManager: this.componentManager});
this.fsObserver = this.filesafe.addDataChangeObserver(() => {
this.recomputeHeight();
})
this.componentManager.streamContextItem((incomingNote) => {
let itemClass = Filesafe.getSFItemClass();
let noteModel = new itemClass(incomingNote);
this.filesafe.setCurrentNote(noteModel);
});
let delegate = {
onSelectFile: (fileDescriptor) => {
if(fileDescriptor) {
if(!this.state.expanded) {
this.expandedFromSelection = true;
this.expandForFileSelection();
}
} else {
if(this.expandedFromSelection) {
this.collapse();
this.expandedFromSelection = false;
}
}
}
}
let mountPoint = document.getElementById("embed");
FilesafeEmbed.FilesafeEmbed.renderInElement(mountPoint, this.filesafe, delegate);
this.recomputeHeight();
}
recomputeHeight() {
var totalHeight = BaseHeight;
var credentials = this.filesafe.getAllCredentials();
if(credentials.length == 0) {
totalHeight += PerMessageHeight;
}
var integrations = this.filesafe.getAllIntegrations();
if(integrations.length == 0) {
totalHeight += PerMessageHeight;
}
if(integrations.length == 0 || credentials.length == 0) {
totalHeight += MessageHavingHeight;
}
if(this.state.expanded) {
totalHeight = ExpandedHeight;
}
this.componentManager.setSize("container", "100%", totalHeight);
}
toggleHeight() {
if(this.state.expanded) {
this.collapse();
} else {
this.expand();
}
}
expandForFileSelection() {
this.componentManager.setSize("container", "100%", 130);
}
expand() {
this.setState({expanded: true}, this.recomputeHeight)
}
collapse() {
this.setState({expanded: false}, this.recomputeHeight);
}
render() {
return (
<div id="root">
<div id="embed">
</div>
<div id="expand-button" className="sk-button contrast no-border" onClick={this.toggleHeight.bind(this)}>
<div className="sk-label">{this.state.expanded ? "▲" : "▼"}</div>
</div>
</div>
);
}
}

View File

@@ -0,0 +1,11 @@
<html>
<link rel="stylesheet" type="text/css" href="dist.css">
<title>FileSafe</title>
<body class="sn-component">
<script>
// In the desktop version, it will use this default value:
window.default_fs_relay_server_url = window.default_fs_relay_server_url || "https://filesafe.standardnotes.org";
</script>
<script type="text/javascript" src="dist.js"></script>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<html>
<link rel="stylesheet" type="text/css" href="dist.css">
<title>FileSafe</title>
<body class="sn-component">
<script>
window.default_fs_relay_server_url = window.default_fs_relay_server_url || "https://filesafe.standardnotes.org";
</script>
<script type="text/javascript" src="dist.min.js"></script>
</body>
</html>

View File

@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.body.appendChild(document.createElement('div'))
);

View File

@@ -0,0 +1,25 @@
@import '~filesafe_embed';
html, body {
font-size: var(--sn-stylekit-base-font-size);
margin: 0;
padding: 0;
height: 100%;
line-height: 1;
background-color: transparent;
}
#root {
position: relative;
}
#embed {
position: relative;
}
#expand-button {
position: fixed;
top: 1.1rem;
right: 2rem;
box-shadow: var(--sn-stylekit-border-color) 0 1px 2px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,11 @@
<html>
<link rel="stylesheet" type="text/css" href="dist.css">
<title>FileSafe</title>
<body class="sn-component">
<script>
// In the desktop version, it will use this default value:
window.default_fs_relay_server_url = window.default_fs_relay_server_url || "https://filesafe.standardnotes.org";
</script>
<script type="text/javascript" src="dist.js"></script>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<html>
<link rel="stylesheet" type="text/css" href="dist.css">
<title>FileSafe</title>
<body class="sn-component">
<script>
window.default_fs_relay_server_url = window.default_fs_relay_server_url || "https://filesafe.standardnotes.org";
</script>
<script type="text/javascript" src="dist.min.js"></script>
</body>
</html>

View File

@@ -0,0 +1,46 @@
{
"name": "@standardnotes/filesafe-bar",
"version": "2.0.15",
"main": "dist/dist.js",
"private": true,
"files": [
"dist"
],
"scripts": {
"skip:lint": "eslint --cache --ignore-path .gitignore --ext .jsx,.js --format=node_modules/eslint-formatter-pretty .",
"test": "echo \"Error: no test specified\" && exit 0",
"deprecated:compile": "webpack",
"start": "webpack-dev-server --devtool eval --progress --hot --content-base app"
},
"sn": {
"main": "dist/index.html"
},
"devDependencies": {
"@babel/core": "^7.7.0",
"@babel/preset-env": "^7.7.1",
"@babel/preset-react": "^7.7.0",
"@babel/preset-stage-0": "^7.0.0",
"@babel/runtime": "^7.7.1",
"babel-cli": "^6.26.0",
"babel-loader": "^8.0.6",
"babel-register": "^6.26.0",
"compare-versions": "^3.5.1",
"copy-webpack-plugin": "5.0.5",
"css-loader": "~3.2.0",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"filesafe-embed": "1.0.9",
"filesafe-js": "1.0.4",
"husky": "^3.0.9",
"node-sass": "*",
"open-browser-webpack-plugin": "0.0.5",
"react": "16.11.x",
"react-dom": "16.11.x",
"sass-loader": "^8.0.0",
"sn-components-api": "1.2.8",
"style-loader": "~1.0.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0",
"worker-loader": "^2.0.0"
}
}

View File

@@ -0,0 +1,81 @@
const webpack = require('webpack');
const path = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
"dist.js" : path.resolve(__dirname, 'app/main.js'),
"dist.min.js" : path.resolve(__dirname, 'app/main.js'),
"dist.css" : path.resolve(__dirname, 'app/stylesheets/main.scss'),
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: './[name]'
},
optimization: {
minimize: true
},
devServer: {
historyApiFallback: true,
watchOptions: { aggregateTimeout: 300, poll: 1000 },
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
},
module: {
rules: [
{ test: /\.css$/, include: path.resolve(__dirname, 'app'), loader: 'style-loader!css-loader' },
{
test: /\.scss$/,
exclude: /node_modules/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
'css-loader',
{ loader: 'sass-loader', query: { sourceMap: false } },
],
publicPath: '../'
}),
},
{
test: /\.js[x]?$/, include: [
path.resolve(__dirname, 'app'),
], exclude: /node_modules/, loader: 'babel-loader'
}
]
},
resolve: {
extensions: ['.js', '.jsx', '.css', '.scss'],
alias: {
filesafe_embed: path.join(__dirname, 'node_modules/filesafe-embed/dist/dist.css'),
}
},
plugins: [
function() {
this.plugin("done", function(stats) {
// console.log("done", stats);
if (stats.compilation.errors && stats.compilation.errors.length &&
process.argv.indexOf("--watch") == -1) {
console.log(stats.compilation.errors);
process.exit(1);
}
});
},
new ExtractTextPlugin({ filename: './dist.css', disable: false, allChunks: true}),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new CopyWebpackPlugin([
{ from: './app/index.html', to: 'index.html' },
{ from: './app/index.min.html', to: 'index.min.html' },
{ from: './node_modules/filesafe-js/dist/filesafe-js/EncryptionWorker.js', to: 'filesafe-js/EncryptionWorker.js' },
])
]
};