Skip to content

Commit

Permalink
Add auto close
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-zatloukal-tfs committed Oct 7, 2021
1 parent 57a7a18 commit b736b32
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 27 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

A free and open source command snippets manager for organize and copy fast.

Forked from [gurayyarar/SnipCommand](https://github.com/gurayyarar/SnipCommand).
Forked from [gurayyarar/SnipCommand](https://github.com/gurayyarar/SnipCommand) and added some new features.


## Releases

Visit the [this link](https://github.com/rotten77/SnipCommand/releases)
* [rotten77 / SnipCommand 0.1.3](https://github.com/rotten77/SnipCommand/releases/tag/v0.1.3)
* New: Autoclose (File > Preferences > Settings)

* [rotten77 / SnipCommand 0.1.2](https://github.com/rotten77/SnipCommand/releases/tag/v0.1.2)
* New: Autocopy settings (File > Preferences >Settings)
* New: Autocopy settings (File > Preferences > Settings)
* Fix: Long string breaks design


Expand Down
6 changes: 6 additions & 0 deletions documentation/CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOGS

### v0.1.3
**October 7, 2021**

- New: Autoclose (File > Preferences >Settings)


### v0.1.2
**October 5, 2021**

Expand Down
40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snipcommand",
"version": "0.1.2",
"version": "0.1.3",
"description": "A free and open source command snippets manager for organize and copy fast.",
"private": true,
"main": "public/electron.js",
Expand All @@ -11,23 +11,23 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"electron-is-dev": "^1.2.0",
"electron-store": "^6.0.0",
"generate-password": "^1.5.1",
"electron-store": "^6.0.1",
"generate-password": "^1.6.1",
"lodash": "^4.17.19",
"lowdb": "^1.0.0",
"markdown-it": "^11.0.0",
"moment": "^2.27.0",
"markdown-it": "^11.0.1",
"moment": "^2.29.1",
"node-sass": "^4.14.1",
"noty": "^3.2.0-beta",
"noty": "^3.2.0-beta-deprecated",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-markdown-editor-lite": "^1.2.2",
"react-redux": "^7.2.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-markdown-editor-lite": "^1.3.1",
"react-redux": "^7.2.5",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux": "^4.1.1",
"redux-thunk": "^2.3.0",
"shortid": "^2.2.15"
"shortid": "^2.2.16"
},
"scripts": {
"start": "rescripts start",
Expand Down Expand Up @@ -56,11 +56,11 @@
"@rescripts/cli": "^0.0.14",
"@rescripts/rescript-env": "^0.0.12",
"concurrently": "^5.2.0",
"cross-env": "^7.0.2",
"electron": "^9.1.0",
"electron-builder": "^22.7.0",
"typescript": "^3.9.7",
"wait-on": "^5.1.0"
"cross-env": "^7.0.3",
"electron": "^9.4.4",
"electron-builder": "^22.11.7",
"typescript": "^3.9.10",
"wait-on": "^5.3.0"
},
"keywords": [
"command",
Expand Down Expand Up @@ -124,7 +124,9 @@
},
"linux": {
"icon": "public/images/logo/snip_command.png",
"target": ["AppImage"]
"target": [
"AppImage"
]
}
}
}
}
6 changes: 6 additions & 0 deletions src/components/CommandListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CommandListItem extends Component {
const {item} = this.props;
const {formValues} = this.state;
let onClickAction = StorageHelpers.preference.get('onClickAction');
let autoClose = StorageHelpers.preference.get('autoClose');

if(item.command.match(new RegExp(`\\[s\\s*(.*?)\\s*\\/]`, 'g'))) {
onClickAction = 'open';
Expand All @@ -35,6 +36,11 @@ class CommandListItem extends Component {
const willCopyVal = CommandHelpers.replacedCommand(item.command, formValues);
clipboard.writeText(willCopyVal);
NotyHelpers.open('The command copied your clipboard!', 'info', 3000);

if(autoClose === true) {
const { remote } = require('electron')
remote.BrowserWindow.getFocusedWindow().minimize();
}
} else {
this.setState({showGeneratorModal: true});
}
Expand Down
34 changes: 30 additions & 4 deletions src/components/SettingsModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ class SettingsModal extends React.Component {
backupDirectory: '',
backupFiles: [],
appTheme: 'light',
onClickAction: 'open'
onClickAction: 'open',
autoClose: false
}

componentDidMount() {
const dbDirectory = StorageHelpers.preference.get('storagePath');
const backupDirectory = StorageHelpers.preference.get('backupPath');
const appTheme = StorageHelpers.preference.get('appTheme') || 'light';
const onClickAction = StorageHelpers.preference.get('onClickAction') || 'open';
this.setState({dbDirectory, backupDirectory, appTheme, onClickAction});
const autoClose = StorageHelpers.preference.get('autoClose') || false;
this.setState({dbDirectory, backupDirectory, appTheme, onClickAction, autoClose});

this.listBackupFiles();
}
Expand Down Expand Up @@ -121,8 +123,13 @@ class SettingsModal extends React.Component {
this.setState({onClickAction});
}

changeAutoClose = autoClose => {
StorageHelpers.preference.set('autoClose', autoClose);
this.setState({autoClose});
}

render() {
const {dbDirectory, backupDirectory, backupFiles, appTheme, onClickAction} = this.state;
const {dbDirectory, backupDirectory, backupFiles, appTheme, onClickAction, autoClose} = this.state;
const {show, onClose, selectedTab} = this.props;

return (
Expand Down Expand Up @@ -273,7 +280,7 @@ class SettingsModal extends React.Component {
</div>
<div className={`content${selectedTab === 'settings' ? ' active' : ''}`}>
<div className="settings-section">
<div className="info">On click action:</div>
<div className="settings-section-title">On click action:</div>
<Button
text="Open"
styleType={onClickAction === 'open' ? 'success' : 'default'}
Expand All @@ -289,6 +296,25 @@ class SettingsModal extends React.Component {
? <div className="info">Only commands without dynamic parameters will be copied directly.</div>
: null
}

<div className="settings-section">

<div className="settings-section-title">Auto close:</div>
<Button
text="Yes"
styleType={autoClose === true ? 'success' : 'default'}
onClick={() => this.changeAutoClose(true)}
disabled="disabled"
/>
<Button
text="No"
styleType={autoClose !== true ? 'success' : 'default'}
onClick={() => this.changeAutoClose(false)}
disabled="disabled"
/>
<div className="info">Minimize window after snippet is copied.</div>
</div>

</div>
<div className={`content${selectedTab === 'update' ? ' active' : ''}`}>
<div className="update-section">
Expand Down
11 changes: 11 additions & 0 deletions src/components/SettingsModal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,20 @@
}

.settings-section {
&:not(:first-child) {
margin-top:8px;
padding-top:8px;
border-top-style: solid;
border-top-width: 1px;
}
button {
margin-right: 8px;
}
.settings-section-title {
font-size: 12px;
font-weight: bold;
margin-bottom: 4px;
}
}
}
}
8 changes: 7 additions & 1 deletion src/components/SnippetGeneratorModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {clipboard} from 'electron';

import Modal from '../Modal';
import {TextField, Button} from "../FormElements";
import {CommandHelpers, NotyHelpers} from "../../core/Helpers";
import {CommandHelpers, NotyHelpers, StorageHelpers} from "../../core/Helpers";
import ChoiceField from "../FormElements/ChoiceField";
import PasswordGeneratorField from "../FormElements/PasswordGeneratorField";

Expand Down Expand Up @@ -59,11 +59,17 @@ class SnippetGeneratorModal extends React.Component {
copyCommand = () => {
const {item} = this.props;
const {formValues} = this.state;
let autoClose = StorageHelpers.preference.get('autoClose');
const willCopyVal = CommandHelpers.replacedCommand(item?.command, formValues);

clipboard.writeText(willCopyVal);
NotyHelpers.open('The command copied your clipboard!', 'info', 3000);
this.onClose();

if(autoClose === true) {
const { remote } = require('electron')
remote.BrowserWindow.getFocusedWindow().minimize();
}
}

_footer = () => {
Expand Down
7 changes: 7 additions & 0 deletions src/themes/_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ body {
}
}

.settings-section {
border-color: #333842;
.settings-section-title {
color: #dddddd;
}
}

.about-section {
* {
color: #dddddd;
Expand Down
7 changes: 7 additions & 0 deletions src/themes/_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ body {
}
}

.settings-section {
border-color: #ededee;
.settings-section-title {
color: #444444;
}
}

.about-section {
* {
color: #444444;
Expand Down

0 comments on commit b736b32

Please sign in to comment.