Skip to content

Commit

Permalink
add remove all certificates action
Browse files Browse the repository at this point in the history
  • Loading branch information
algv committed Oct 13, 2017
1 parent f8aad80 commit df871d9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
8 changes: 7 additions & 1 deletion app/AC/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CHANGE_ENCRYPT_OUTFOLDER, CHANGE_LOCALE, CHANGE_SEARCH_VALUE,
CHANGE_SIGNATURE_DETACHED, CHANGE_SIGNATURE_ENCODING, CHANGE_SIGNATURE_OUTFOLDER,
CHANGE_SIGNATURE_TIMESTAMP, DELETE_FILE, DELETE_RECIPIENT_CERTIFICATE,
FAIL, LOAD_ALL_CERTIFICATES, SELECT_FILE,
FAIL, LOAD_ALL_CERTIFICATES, REMOVE_ALL_CERTIFICATES, SELECT_FILE,
SELECT_SIGNER_CERTIFICATE, START, SUCCESS,
VERIFY_CERTIFICATE, VERIFY_SIGNATURE,
} from "../constants";
Expand Down Expand Up @@ -50,6 +50,12 @@ export function loadAllCertificates() {
};
}

export function removeAllCertificates() {
return {
type: REMOVE_ALL_CERTIFICATES,
};
}

export function changeSearchValue(searchValue) {
return {
payload: { searchValue },
Expand Down
8 changes: 5 additions & 3 deletions app/components/CertWindow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as events from "events";
import * as React from "react";
import { connect } from "react-redux";
import { loadAllCertificates } from "../AC";
import { loadAllCertificates, removeAllCertificates } from "../AC";
import { PROVIDER_CRYPTOPRO, PROVIDER_MICROSOFT, PROVIDER_SYSTEM } from "../constants";
import * as native from "../native";
import { filteredCertificatesSelector } from "../selectors";
Expand Down Expand Up @@ -53,7 +53,7 @@ class CertWindow extends React.Component<any, any> {

handleCertificateImport = (event: any) => {
const { localize, locale } = this.context;
const { isLoading, loadAllCertificates } = this.props;
const { isLoading, loadAllCertificates, removeAllCertificates } = this.props;
const path = event[0].path;
const format: trusted.DataFormat = getFileCoding(path);
const OS_TYPE = native.os.type();
Expand All @@ -80,6 +80,8 @@ class CertWindow extends React.Component<any, any> {
if (err) {
Materialize.toast(localize("Certificate.cert_import_failed", locale), 2000, "toast-cert_import_error");
} else {
removeAllCertificates();

if (!isLoading) {
loadAllCertificates();
}
Expand Down Expand Up @@ -363,4 +365,4 @@ export default connect((state) => {
certificates: filteredCertificatesSelector(state, { operation: "certificate" }),
isLoading: state.certificates.loading,
};
}, { loadAllCertificates })(CertWindow);
}, { loadAllCertificates, removeAllCertificates })(CertWindow);
1 change: 1 addition & 0 deletions app/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const CHANGE_SEARCH_VALUE = "CHANGE_SEARCH_VALUE";

export const LOAD_ALL_CERTIFICATES = "LOAD_ALL_CERTIFICATES";
export const REMOVE_ALL_CERTIFICATES = "REMOVE_ALL_CERTIFICATES";
export const VERIFY_CERTIFICATE = "VERIFY_CERTIFICATE";
export const SELECT_SIGNER_CERTIFICATE = "SELECT_SIGNER_CERTIFICATE";

Expand Down
6 changes: 5 additions & 1 deletion app/reducer/certificates.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Map, OrderedMap, Record } from "immutable";
import { LOAD_ALL_CERTIFICATES, START, SUCCESS, VERIFY_CERTIFICATE } from "../constants";
import { LOAD_ALL_CERTIFICATES, REMOVE_ALL_CERTIFICATES,
START, SUCCESS, VERIFY_CERTIFICATE } from "../constants";
import { arrayToMap } from "../utils";

const CertificateModel = Record({
Expand Down Expand Up @@ -48,6 +49,9 @@ export default (certificates = new DefaultReducerState(), action) => {
return certificates
.setIn(["entities", payload.certificateId, "status"], payload.certificateStatus)
.setIn(["entities", payload.certificateId, "verified"], true);

case REMOVE_ALL_CERTIFICATES:
return certificates = new DefaultReducerState();
}

return certificates;
Expand Down

0 comments on commit df871d9

Please sign in to comment.