models/communities/ActivityButton.js

import Action from './../actions/Action.js';

export default class ActivityButton {
    /**
     * Creates a new ActivityButton instance.
     *
     * @constructor ActivityButton
     * @param {object} activityButtonMap - Activity Button parameters
     * @param {string} activityButtonMap.title - Button label
     * @param {Action} activityButtonMap.action - Button action
     */
    constructor(activityButtonMap) {
        this.title = activityButtonMap.title;
        const rawAction = activityButtonMap.action;
        if (rawAction !== undefined && rawAction != null) {
            this.action = new Action(rawAction);
        }
        Object.freeze(this);
    }

    /**
     * Create a new ActivityButton instance.
     *
     * @memberof ActivityButton
     * @param {string} title - Button title.
     * @param {Action} action - Button action.
     * @return {ActivityButton} New instance.
     */
    static create(title, action) {
        return new ActivityButton({ title, action });
    }
}