All files / publisher/pages/Releases/actions channelMap.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 6/6
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 101 102 103 104 105 106 107 108            8x 8x 8x 8x 8x                                                                                         4x             40x             3x             18x                 6x                             4x              
import {
  GenericReleasesAction,
  ReleasesReduxState,
  Revision,
} from "../../../types/releaseTypes";
 
export const INIT_CHANNEL_MAP = "INIT_CHANNEL_MAP";
export const SELECT_REVISION = "SELECT_REVISION";
export const CLEAR_SELECTED_REVISIONS = "CLEAR_SELECTED_REVISIONS";
export const RELEASE_REVISION_SUCCESS = "RELEASE_REVISION_SUCCESS";
export const CLOSE_CHANNEL_SUCCESS = "CLOSE_CHANNEL_SUCCESS";
 
export type InitChannelMapAction = GenericReleasesAction<
  typeof INIT_CHANNEL_MAP,
  { channelMap: ReleasesReduxState["channelMap"] }
>;
 
export type SelectRevisionAction = GenericReleasesAction<
  typeof SELECT_REVISION,
  {
    revision: Revision;
    toggle: boolean;
  }
>;
 
export type ClearSelectedRevisionAction = GenericReleasesAction<
  typeof CLEAR_SELECTED_REVISIONS,
  never
>;
 
export type ReleaseRevisionSuccessAction = GenericReleasesAction<
  typeof RELEASE_REVISION_SUCCESS,
  {
    revision: Revision;
    channel: string;
  }
>;
 
export type CloseChannelSuccessAction = GenericReleasesAction<
  typeof CLOSE_CHANNEL_SUCCESS,
  {
    channel: string;
  }
>;
 
export type ChannelMapAction =
  | InitChannelMapAction
  | SelectRevisionAction
  | ClearSelectedRevisionAction
  | ReleaseRevisionSuccessAction
  | CloseChannelSuccessAction;
 
export function initChannelMap(
  channelMap: ReleasesReduxState["channelMap"]
): InitChannelMapAction {
  return {
    type: INIT_CHANNEL_MAP,
    payload: { channelMap },
  };
}
 
export function selectRevision(revision: Revision): SelectRevisionAction {
  return {
    type: SELECT_REVISION,
    payload: { revision, toggle: false },
  };
}
 
export function toggleRevision(revision: Revision): SelectRevisionAction {
  return {
    type: SELECT_REVISION,
    payload: { revision, toggle: true },
  };
}
 
export function clearSelectedRevisions(): ClearSelectedRevisionAction {
  return {
    type: CLEAR_SELECTED_REVISIONS,
  };
}
 
export function releaseRevisionSuccess(
  revision: Revision,
  channel: string
): ReleaseRevisionSuccessAction {
  return {
    type: RELEASE_REVISION_SUCCESS,
    payload: {
      revision,
      channel,
    },
  };
}
 
/**
 * 
 * @param channel Channel to close
 * @returns Action to close channel
 */
export function closeChannelSuccess(channel: string): CloseChannelSuccessAction {
  return {
    type: CLOSE_CHANNEL_SUCCESS,
    payload: {
      channel,
    },
  };
}