'Save workflow menu to be shown in the tool panel
PUT /api/workflows/menu'

@expose_api
def set_workflow_menu(self, trans, **kwd):

    payload = kwd.get('payload')
    user = trans.get_user()
    workflow_ids = payload.get('workflow_ids')
    if (workflow_ids is None):
        workflow_ids = []
    elif (type(workflow_ids) != list):
        workflow_ids = [workflow_ids]
    workflow_ids_decoded = []
    for ids in workflow_ids:
        workflow_ids_decoded.append(trans.security.decode_id(ids))
    sess = trans.sa_session
    for m in user.stored_workflow_menu_entries:
        sess.delete(m)
    user.stored_workflow_menu_entries = []
    q = sess.query(model.StoredWorkflow)
    seen_workflow_ids = set()
    for wf_id in workflow_ids_decoded:
        if (wf_id in seen_workflow_ids):
            continue
        else:
            seen_workflow_ids.add(wf_id)
        m = model.StoredWorkflowMenuEntry()
        m.stored_workflow = q.get(wf_id)
        user.stored_workflow_menu_entries.append(m)
    sess.flush()
    message = 'Menu    updated.'
    trans.set_message(message)
    return {'message': message, 'status': 'done'}
