Skip to content

Commit df871d9

Browse files
committed
add remove all certificates action
1 parent f8aad80 commit df871d9

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

app/AC/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
CHANGE_ENCRYPT_OUTFOLDER, CHANGE_LOCALE, CHANGE_SEARCH_VALUE,
55
CHANGE_SIGNATURE_DETACHED, CHANGE_SIGNATURE_ENCODING, CHANGE_SIGNATURE_OUTFOLDER,
66
CHANGE_SIGNATURE_TIMESTAMP, DELETE_FILE, DELETE_RECIPIENT_CERTIFICATE,
7-
FAIL, LOAD_ALL_CERTIFICATES, SELECT_FILE,
7+
FAIL, LOAD_ALL_CERTIFICATES, REMOVE_ALL_CERTIFICATES, SELECT_FILE,
88
SELECT_SIGNER_CERTIFICATE, START, SUCCESS,
99
VERIFY_CERTIFICATE, VERIFY_SIGNATURE,
1010
} from "../constants";
@@ -50,6 +50,12 @@ export function loadAllCertificates() {
5050
};
5151
}
5252

53+
export function removeAllCertificates() {
54+
return {
55+
type: REMOVE_ALL_CERTIFICATES,
56+
};
57+
}
58+
5359
export function changeSearchValue(searchValue) {
5460
return {
5561
payload: { searchValue },

app/components/CertWindow.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as events from "events";
22
import * as React from "react";
33
import { connect } from "react-redux";
4-
import { loadAllCertificates } from "../AC";
4+
import { loadAllCertificates, removeAllCertificates } from "../AC";
55
import { PROVIDER_CRYPTOPRO, PROVIDER_MICROSOFT, PROVIDER_SYSTEM } from "../constants";
66
import * as native from "../native";
77
import { filteredCertificatesSelector } from "../selectors";
@@ -53,7 +53,7 @@ class CertWindow extends React.Component<any, any> {
5353

5454
handleCertificateImport = (event: any) => {
5555
const { localize, locale } = this.context;
56-
const { isLoading, loadAllCertificates } = this.props;
56+
const { isLoading, loadAllCertificates, removeAllCertificates } = this.props;
5757
const path = event[0].path;
5858
const format: trusted.DataFormat = getFileCoding(path);
5959
const OS_TYPE = native.os.type();
@@ -80,6 +80,8 @@ class CertWindow extends React.Component<any, any> {
8080
if (err) {
8181
Materialize.toast(localize("Certificate.cert_import_failed", locale), 2000, "toast-cert_import_error");
8282
} else {
83+
removeAllCertificates();
84+
8385
if (!isLoading) {
8486
loadAllCertificates();
8587
}
@@ -363,4 +365,4 @@ export default connect((state) => {
363365
certificates: filteredCertificatesSelector(state, { operation: "certificate" }),
364366
isLoading: state.certificates.loading,
365367
};
366-
}, { loadAllCertificates })(CertWindow);
368+
}, { loadAllCertificates, removeAllCertificates })(CertWindow);

app/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const CHANGE_SEARCH_VALUE = "CHANGE_SEARCH_VALUE";
22

33
export const LOAD_ALL_CERTIFICATES = "LOAD_ALL_CERTIFICATES";
4+
export const REMOVE_ALL_CERTIFICATES = "REMOVE_ALL_CERTIFICATES";
45
export const VERIFY_CERTIFICATE = "VERIFY_CERTIFICATE";
56
export const SELECT_SIGNER_CERTIFICATE = "SELECT_SIGNER_CERTIFICATE";
67

app/reducer/certificates.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Map, OrderedMap, Record } from "immutable";
2-
import { LOAD_ALL_CERTIFICATES, START, SUCCESS, VERIFY_CERTIFICATE } from "../constants";
2+
import { LOAD_ALL_CERTIFICATES, REMOVE_ALL_CERTIFICATES,
3+
START, SUCCESS, VERIFY_CERTIFICATE } from "../constants";
34
import { arrayToMap } from "../utils";
45

56
const CertificateModel = Record({
@@ -48,6 +49,9 @@ export default (certificates = new DefaultReducerState(), action) => {
4849
return certificates
4950
.setIn(["entities", payload.certificateId, "status"], payload.certificateStatus)
5051
.setIn(["entities", payload.certificateId, "verified"], true);
52+
53+
case REMOVE_ALL_CERTIFICATES:
54+
return certificates = new DefaultReducerState();
5155
}
5256

5357
return certificates;

0 commit comments

Comments
 (0)