File size: 2,562 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import {
ATOMIC_SOFTWARE_INITIATE_INSTALL,
ATOMIC_SOFTWARE_REQUEST_STATUS,
ATOMIC_SOFTWARE_SET_STATUS,
} from 'calypso/state/action-types';
import 'calypso/state/data-layer/wpcom/sites/atomic/software';
import 'calypso/state/atomic/init';
export interface AtomicSoftwareStatus {
blog_id: number;
software_set: Record< string, { path: string; state: string } >;
applied: boolean;
}
export interface AtomicSoftwareError {
name: string; // "NotFoundError"
status: number; // 404
message: string; // "Transfer not found"
code: string; // "no_transfer_record"
}
/**
* Initiate plugin install and activation.
* @param {string} siteId Site ID.
* @param {string} softwareSet Software set slug.
* @returns {Object} An action object.
*/
export const requestAtomicSoftwareInstall = ( siteId: number, softwareSet: string ) =>
( {
type: ATOMIC_SOFTWARE_INITIATE_INSTALL,
siteId,
softwareSet,
} ) as const;
/**
* Fetch install status.
* @param {string} siteId Site ID.
* @param {string} softwareSet Software set slug.
* @returns {Object} An action object.
*/
export const requestAtomicSoftwareStatus = ( siteId: number, softwareSet: string ) =>
( {
type: ATOMIC_SOFTWARE_REQUEST_STATUS,
siteId,
softwareSet,
} ) as const;
/**
* Set the install status.
* @param {number} siteId The site id to which the status belongs.
* @param {string} softwareSet The software set slug.
* @param {Object} status The new status of the transfer.
* @returns {Object} An action object
*/
export const setAtomicSoftwareStatus = (
siteId: number,
softwareSet: string,
status: AtomicSoftwareStatus
) =>
( {
type: ATOMIC_SOFTWARE_SET_STATUS,
siteId,
softwareSet,
status,
} ) as const;
/**
* Set the install error.
* @param {number} siteId The site id to which the status belongs.
* @param {string} softwareSet The software set slug.*
* @param {AtomicSoftwareError} error The error of the install.
* @returns {Object} An action object
*/
export const setAtomicSoftwareError = (
siteId: number,
softwareSet: string,
error: AtomicSoftwareError
) =>
( {
type: ATOMIC_SOFTWARE_SET_STATUS,
siteId,
softwareSet,
error,
} ) as const;
/**
* Clean the install status.
* @param {number} siteId The site id to which the status belongs.
* @param {string} softwareSet The software set slug.*
* @returns {Object} An action object
*/
export const cleanAtomicSoftwareStatus = ( siteId: number, softwareSet: string ) =>
( {
type: ATOMIC_SOFTWARE_SET_STATUS,
siteId,
softwareSet,
status: null,
error: null,
} ) as const;
|