# By: Riasat Ullah
# This file contains functions that will generate the context of advanced pages.

from constants import label_names as lbl, var_names
from context_manager import components_context, resources_context, users_context
from translators import label_translator as lt


def get_status_dashboard_context(lang, allowed_components):
    '''
    Context for the status dashboard page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    months_days_context = components_context.get_months_days_context(lang)

    page_labels = [lbl.det_duration, lbl.det_healthy, lbl.det_impacted, lbl.det_you_are_subscribed_to_this_incident,
                   lbl.ins_cancel, lbl.ins_create, lbl.ins_no, lbl.ins_save, lbl.ins_yes,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_status_dashboard, lbl.ttl_all_business_services,
                   lbl.ttl_business_service, lbl.ttl_business_services, lbl.ttl_dashboard_name, lbl.ttl_dashboard_url,
                   lbl.ttl_delete_dashboard, lbl.ttl_edit_dashboard, lbl.ttl_incidents, lbl.ttl_new_dashboard,
                   lbl.ttl_status_updates, lbl.ttl_subscribe, lbl.ttl_unsubscribe]

    option_labels = [lbl.opt_critical, lbl.opt_high, lbl.opt_medium, lbl.opt_low, lbl.opt_minor]
    page_labels += option_labels

    page_descriptions = [lbl.err_status_dashboard_min_business_services, lbl.err_status_dashboard_name,
                         lbl.err_status_dashboard_non_custom, lbl.err_status_dashboard_url]

    final_context = {**top_bar_context, **months_days_context, **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context


def get_status_page_sidebar_context(lang):
    '''
    Context for the status pages sidebar.
    '''
    sidebar_labels = [lbl.ttl_business_services, lbl.ttl_design, lbl.ttl_incidents, lbl.ttl_page_info,
                      lbl.ttl_permissions, lbl.ttl_preview_page, lbl.ttl_subscribers, lbl.ttl_templates,
                      lbl.ttl_view_live_page, lbl.ttl_your_page]
    sidebar_context = lt.get_context(sidebar_labels, lang)
    return sidebar_context


def get_status_pages_list_context(lang, allowed_components):
    '''
    Context for status pages list page. This page shows the list of all status pages.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    months_days_context = components_context.get_months_days_context(lang)

    page_labels = [lbl.det_current_version, lbl.det_draft, lbl.det_maintenance, lbl.det_none, lbl.det_ongoing,
                   lbl.det_pending, lbl.det_published, lbl.det_published_version, lbl.det_status, lbl.ins_delete,
                   lbl.ins_edit, lbl.ins_no, lbl.ins_publish, lbl.ins_unpublish, lbl.ins_view, lbl.ins_yes,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_status_page,
                   lbl.qqs_are_you_sure_you_want_to_publish_this_status_page,
                   lbl.qqs_are_you_sure_you_want_to_unpublish_this_status_page, lbl.res_resources, lbl.ttl_incidents,
                   lbl.ttl_new_status_page, lbl.ttl_page_name, lbl.ttl_your_status_pages]

    page_descriptions = [lbl.desc_no_status_pages_created, lbl.desc_status_pages]

    res_labels = [lbl.res_creating_on_call_routines, lbl.res_editing_routines, lbl.res_overriding_routines,
                  lbl.res_on_call_schedule_examples, lbl.res_configuring_escalation_policies, lbl.res_creating_services,
                  lbl.res_team_components]
    page_labels += res_labels

    final_context = {**top_bar_context, **months_days_context, **lt.get_context(page_labels + page_descriptions, lang)}
    final_context[var_names.resource_items] = resources_context.get_resources_content(res_labels, final_context)
    return final_context


def get_status_pages_details_context(lang, allowed_components):
    '''
    Context for status pages details page. This page shows the configuration details of a status page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)

    page_labels = [lbl.clr_background_color, lbl.clr_border_color, lbl.clr_font_color, lbl.clr_footer_color,
                   lbl.clr_graph_color, lbl.clr_light_font_color, lbl.clr_link_color, lbl.clr_navbar_color,
                   lbl.clr_no_data_color, lbl.clr_operational_color, lbl.clr_outage_color, lbl.clr_warning_color,
                   lbl.det_all_admins, lbl.det_all_users_notified_but_one_approver_required,
                   lbl.det_all_users_with_responder_roles, lbl.det_all_users_with_responder_roles_from_these_teams,
                   lbl.det_allow_syncing_between_system_incidents_and_status_pages,
                   lbl.det_allow_visitors_to_see_historical_incidents,
                   lbl.det_allow_visitors_to_subscribe_for_status_alerts, lbl.det_automated_incident_posts,
                   lbl.det_colors, lbl.det_column, lbl.det_cover_image, lbl.det_description, lbl.det_double_column,
                   lbl.det_favicon, lbl.det_hide_page_from_search_engines, lbl.det_images, lbl.det_language,
                   lbl.det_layout, lbl.det_logo, lbl.det_make_page_private, lbl.det_managers_from_these_teams,
                   lbl.det_name, lbl.det_navigation_bar, lbl.det_no_approval_needed, lbl.det_optional,
                   lbl.det_page_footer, lbl.det_post_approval, lbl.det_require_approval_from_at_least_one_user,
                   lbl.det_select_external_sso_to_restrict_page_access, lbl.det_show_link_on_the_navigation_bar,
                   lbl.det_show_uptime_bar, lbl.det_single_column, lbl.det_status_page_add_footer_links,
                   lbl.det_status_page_msg_to_show_operational, lbl.det_status_page_notify_about_pending_incidents,
                   lbl.det_status_page_select_business_services, lbl.det_status_page_select_colors,
                   lbl.dsm_category_name, lbl.dsm_days, lbl.dsm_hours, lbl.dsm_link, lbl.dsm_section_name,
                   lbl.dsm_select_business_services, lbl.dsm_text, lbl.emd_email, lbl.emd_slack,
                   lbl.emd_text, lbl.emd_webhook, lbl.err_image_format, lbl.err_invalid_hyperlinks,
                   lbl.err_invalid_ip_address, lbl.err_invalid_url, lbl.err_status_page_business_services,
                   lbl.err_status_page_footer_section, lbl.err_status_page_images_required,
                   lbl.err_status_page_name_description, lbl.err_status_page_private, lbl.ins_add,
                   lbl.ins_add_category, lbl.ins_add_column, lbl.ins_add_link, lbl.ins_cancel, lbl.ins_go_back,
                   lbl.ins_next, lbl.ins_no, lbl.ins_save, lbl.ins_save_and_publish, lbl.ins_yes,
                   lbl.msg_status_page_edited, lbl.opt_english, lbl.opt_spanish, lbl.ttl_new_status_page,
                   lbl.qqs_are_you_sure_you_want_to_publish_this_status_page, lbl.qqs_who_can_edit_this_status_page,
                   lbl.qqs_who_can_post_on_this_status_page, lbl.ttl_business_services, lbl.ttl_design,
                   lbl.ttl_google_analytics_tracking_id, lbl.ttl_ip_allowlist, lbl.ttl_new_status_page,
                   lbl.ttl_page_info, lbl.ttl_page_timezone, lbl.ttl_page_url, lbl.ttl_permissions, lbl.ttl_status_page,
                   lbl.ttl_status_pages, lbl.ttl_your_status_pages]

    user_role_labels = list(users_context.user_role_maps.values())
    page_labels = page_labels + user_role_labels
    final_context = {**top_bar_context, **sidebar_context, **lt.get_context(page_labels, lang)}
    return final_context


def get_status_pages_incidents_context(lang, allowed_components):
    '''
    Context for status page incidents page. Shows all the incidents, actions pending approval and maintenances.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)
    months_days_context = components_context.get_months_days_context(lang)

    page_labels = [lbl.det_completed, lbl.det_created, lbl.det_duration, lbl.det_impacted, lbl.det_items_per_page,
                   lbl.det_last_update, lbl.det_maintenance, lbl.det_ongoing, lbl.det_pending, lbl.det_post,
                   lbl.det_posted_by, lbl.det_resolved,
                   lbl.det_select_system_incident_to_sync_status_page_incident_with, lbl.det_showing, lbl.det_starts_on,
                   lbl.det_status, lbl.det_status_update, lbl.det_sync_with_system_incident,
                   lbl.det_synced_with_system_incident, lbl.det_upcoming, lbl.dsm_per_page, lbl.dsm_search,
                   lbl.dsm_type, lbl.err_no_incidents_were_selected, lbl.ins_approve, lbl.ins_cancel, lbl.ins_delete,
                   lbl.ins_no, lbl.ins_review, lbl.ins_save, lbl.ins_update, lbl.ins_view, lbl.ins_yes, lbl.plc_ago,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_status_page_incident, lbl.sts_completed,
                   lbl.sts_identified, lbl.sts_investigating, lbl.sts_in_progress, lbl.sts_monitoring, lbl.sts_resolved,
                   lbl.sts_scheduled, lbl.sts_verifying, lbl.ttl_created_on, lbl.ttl_external_status_pages,
                   lbl.ttl_incident, lbl.ttl_incidents, lbl.ttl_new_incident, lbl.ttl_new_maintenance,
                   lbl.ttl_schedule_maintenance, lbl.ttl_post_incident]

    page_descriptions = [lbl.desc_no_incidents_here]

    final_context = {**top_bar_context, **sidebar_context, **months_days_context,
                     **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context


def get_status_pages_post_details_context(lang, allowed_components):
    '''
    Context for status pages post details page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)
    months_days_context = components_context.get_months_days_context(lang)

    page_labels = [lbl.det_automatically_update_maintenance, lbl.det_create_new_template, lbl.det_ends_on,
                   lbl.det_impact, lbl.det_maintenance, lbl.det_message, lbl.det_notify_subscribers, lbl.det_pending,
                   lbl.det_post, lbl.det_select_impact_on_the_overall_status_of_page,
                   lbl.det_show_time_till_next_update, lbl.det_starts_on, lbl.det_status, lbl.det_status_update,
                   lbl.det_title, lbl.dsm_minutes, lbl.dsm_hour, lbl.dsm_hours,
                   lbl.dsm_select_impacted_business_services, lbl.err_maintenance_period, lbl.err_status_page_post,
                   lbl.ins_approve, lbl.ins_cancel, lbl.ins_delete, lbl.opt_major, lbl.opt_minor, lbl.opt_no_impact,
                   lbl.plc_ago, lbl.sts_completed, lbl.sts_identified, lbl.sts_in_progress, lbl.sts_investigating,
                   lbl.sts_monitoring, lbl.sts_operational, lbl.sts_outage, lbl.sts_partial_outage, lbl.sts_resolved,
                   lbl.sts_scheduled, lbl.sts_verifying, lbl.ttl_apply_template, lbl.ttl_external_status_pages,
                   lbl.ttl_impacted_business_services, lbl.ttl_incident, lbl.ttl_new_incident, lbl.ttl_new_post,
                   lbl.ttl_status_pages, lbl.ttl_timeline]

    final_context = {**top_bar_context, **sidebar_context, **months_days_context, **lt.get_context(page_labels, lang)}
    return final_context


def get_status_pages_subscribers_context(lang, allowed_components):
    '''
    Context for status pages subscribers page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)

    page_labels = [lbl.det_all_methods, lbl.det_all_updates, lbl.det_confirmed, lbl.det_impacted,
                   lbl.det_items_per_page, lbl.det_method, lbl.det_pending, lbl.det_showing, lbl.det_status,
                   lbl.det_status_page_subscriber_file, lbl.det_subscribed_to, lbl.det_subscriber,
                   lbl.dsm_search, lbl.dsm_type, lbl.emd_email, lbl.emd_slack, lbl.emd_text,
                   lbl.emd_webhook, lbl.err_invalid_email, lbl.err_invalid_url, lbl.err_no_items_were_selected,
                   lbl.err_select_at_least_one_service, lbl.err_status_page_subscriber_file, lbl.ins_cancel,
                   lbl.ins_delete, lbl.ins_edit, lbl.ins_no, lbl.ins_resend_invite, lbl.ins_yes, lbl.ins_upload_file,
                   lbl.msg_status_page_subscriber_added, lbl.opt_all_services,
                   lbl.qqs_are_you_sure_you_want_to_delete_selected_subscribers,
                   lbl.qqs_are_you_sure_you_want_to_resend_subscription_invitations, lbl.ttl_add_subscribers,
                   lbl.ttl_external_status_pages, lbl.ttl_services, lbl.ttl_subscribe, lbl.ttl_subscribers]

    page_descriptions = [lbl.desc_no_subscribers_added]

    final_context = {**top_bar_context, **sidebar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context


def get_status_pages_templates_context(lang, allowed_components):
    '''
    Context for status pages templates page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)

    page_labels = [lbl.det_impacted, lbl.det_items_per_page, lbl.det_maintenance, lbl.det_showing, lbl.det_status,
                   lbl.dsm_type, lbl.ins_delete, lbl.ins_edit, lbl.ins_no, lbl.ins_view, lbl.ins_yes,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_template, lbl.sts_completed, lbl.sts_identified,
                   lbl.sts_in_progress, lbl.sts_investigating, lbl.sts_monitoring, lbl.sts_resolved,
                   lbl.sts_scheduled, lbl.sts_verifying, lbl.ttl_external_status_pages, lbl.ttl_incident,
                   lbl.ttl_new_template, lbl.ttl_template, lbl.ttl_templates]

    page_descriptions = [lbl.desc_no_templates_created]

    final_context = {**top_bar_context, **sidebar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context


def get_status_pages_template_details_context(lang, allowed_components):
    '''
    Context for status pages templates page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    sidebar_context = get_status_page_sidebar_context(lang)

    page_labels = [lbl.det_description, lbl.det_ends_on, lbl.det_impact, lbl.det_maintenance, lbl.det_message,
                   lbl.det_name, lbl.det_notify_subscribers, lbl.det_select_impact_on_the_overall_status_of_page,
                   lbl.det_show_time_till_next_update, lbl.det_starts_on, lbl.det_status, lbl.det_title, lbl.dsm_hour,
                   lbl.dsm_hours, lbl.dsm_minutes, lbl.dsm_select_impacted_business_services, lbl.dsm_type,
                   lbl.err_status_page_template_name, lbl.err_status_page_template_requirements, lbl.ins_cancel,
                   lbl.ins_save, lbl.opt_major, lbl.opt_minor, lbl.opt_no_impact, lbl.sts_completed, lbl.sts_identified,
                   lbl.sts_investigating, lbl.sts_in_progress, lbl.sts_monitoring, lbl.sts_operational, lbl.sts_outage,
                   lbl.sts_partial_outage, lbl.sts_resolved, lbl.sts_scheduled, lbl.sts_verifying,
                   lbl.ttl_apply_template, lbl.ttl_external_status_pages, lbl.ttl_impacted_business_services,
                   lbl.ttl_incident, lbl.ttl_itsm, lbl.ttl_new_template, lbl.ttl_template_description,
                   lbl.ttl_template_name]

    final_context = {**top_bar_context, **sidebar_context, **lt.get_context(page_labels, lang)}
    return final_context


def get_status_pages_preview_context(lang):
    '''
    Context for status pages preview page.
    '''
    months_days_context = components_context.get_months_days_context(lang)

    page_labels = [lbl.det_all, lbl.det_maintenance, lbl.det_no_reported_incidents, lbl.det_no_reported_maintenance,
                   lbl.det_subscription_cancelled, lbl.det_subscription_confirmed, lbl.det_show_less, lbl.det_show_more,
                   lbl.det_subscribe_for_updates, lbl.dsm_last_30_days, lbl.dsm_last_90_days, lbl.emd_email,
                   lbl.emd_slack, lbl.emd_text, lbl.emd_webhook, lbl.err_invalid_value, lbl.err_unknown_resource,
                   lbl.ins_back_to_system_status, lbl.ins_cancel, lbl.mth_full_january, lbl.mth_full_february,
                   lbl.mth_full_march, lbl.mth_full_april, lbl.mth_full_may, lbl.mth_full_june, lbl.mth_full_july,
                   lbl.mth_full_august, lbl.mth_full_september, lbl.mth_full_october, lbl.mth_full_november,
                   lbl.mth_full_december, lbl.plc_next_update_in_minutes, lbl.sts_completed, lbl.sts_identified,
                   lbl.sts_investigating, lbl.sts_in_progress, lbl.sts_monitoring, lbl.sts_operational, lbl.sts_outage,
                   lbl.sts_partial_outage, lbl.sts_resolved, lbl.sts_scheduled, lbl.sts_verifying,
                   lbl.ttl_current_status, lbl.ttl_impacted_services, lbl.ttl_past_incidents,
                   lbl.ttl_reported_incidents, lbl.ttl_services, lbl.ttl_system_status, lbl.ttl_subscribe,
                   lbl.ttl_timezone]

    final_context = {**months_days_context, **lt.get_context(page_labels, lang)}
    return final_context


def get_itsm_login_context(lang):
    '''
    Context for the login page that will be shown for accessing restricted external ITSM pages.
    This is for the stakeholders of a TaskCall client.
    '''
    page_labels = [lbl.desc_itsm_page_access_restricted, lbl.det_contact_system_admin_for_support,
                   lbl.det_log_in_to_access_this_page, lbl.ttl_log_in]
    final_context = {**lt.get_context(page_labels, lang)}
    return final_context


def get_group_list_context(lang, allowed_components):
    '''
    Context for the group list page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)

    page_labels = [lbl.det_group, lbl.dsm_per_page, lbl.dsm_search, lbl.dsm_type, lbl.ins_delete, lbl.ins_edit,
                   lbl.ins_no, lbl.ins_view, lbl.ins_yes, lbl.res_resources, lbl.ttl_new_group, lbl.ttl_groups]

    res_labels = [lbl.res_creating_on_call_routines, lbl.res_editing_routines, lbl.res_overriding_routines,
                  lbl.res_on_call_schedule_examples, lbl.res_configuring_escalation_policies, lbl.res_creating_services,
                  lbl.res_team_components]
    page_labels += res_labels

    page_descriptions = [lbl.desc_group, lbl.desc_group_empty]
    final_context = {**top_bar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    final_context[var_names.resource_items] = resources_context.get_resources_content(res_labels, final_context)
    return final_context


def get_group_details_context(lang, allowed_components):
    '''
    Context for the group details page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    group_types_context = components_context.get_group_types_context(lang)

    page_labels = [lbl.det_description, lbl.det_group, lbl.det_group_delete_associated_people,
                   lbl.det_group_select_people_to_add, lbl.det_name, lbl.det_phone, lbl.det_title, lbl.dsm_search,
                   lbl.dsm_type, lbl.err_select_at_least_one_person, lbl.ins_add, lbl.ins_cancel,
                   lbl.ins_delete, lbl.ins_edit, lbl.ins_no, lbl.ins_save, lbl.ins_yes,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_group,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_person_from_this_group, lbl.res_resources,
                   lbl.ttl_add_people, lbl.ttl_delete_group, lbl.ttl_edit_group, lbl.ttl_email, lbl.ttl_people]

    res_labels = [lbl.res_creating_on_call_routines, lbl.res_editing_routines, lbl.res_overriding_routines,
                  lbl.res_on_call_schedule_examples, lbl.res_configuring_escalation_policies, lbl.res_creating_services,
                  lbl.res_team_components]
    page_labels += res_labels

    final_context = {**top_bar_context, **group_types_context, **lt.get_context(page_labels, lang)}
    final_context[var_names.resource_items] = resources_context.get_resources_content(res_labels, final_context)
    return final_context


def get_group_new_context(lang, allowed_components):
    '''
    Context for the new group page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)
    group_types_context = components_context.get_group_types_context(lang)

    page_labels = [lbl.det_description, lbl.det_group, lbl.det_name, lbl.dsm_type, lbl.err_group_name_invalid,
                   lbl.ins_add, lbl.ins_cancel, lbl.ins_create, lbl.ttl_new_group, lbl.ttl_people]

    page_descriptions = [lbl.desc_group]
    final_context = {**top_bar_context, **group_types_context, **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context


def get_people_list_context(lang, allowed_components):
    '''
    Context for the people list page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)

    page_labels = [lbl.desc_people_csv_file_upload, lbl.det_file_import_completed, lbl.det_file_importing,
                   lbl.det_group, lbl.det_name, lbl.det_none, lbl.det_phone, lbl.det_row, lbl.det_title,
                   lbl.dsm_per_page, lbl.dsm_search, lbl.err_file_upload, lbl.err_invalid_rows,
                   lbl.err_invalid_value, lbl.err_people_details, lbl.ins_add, lbl.ins_cancel, lbl.ins_delete,
                   lbl.ins_edit, lbl.ins_no, lbl.ins_save, lbl.ins_upload_file, lbl.ins_view, lbl.ins_yes,
                   lbl.msg_person_added, lbl.msg_person_deleted, lbl.msg_person_edited,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_person, lbl.res_resources,
                   lbl.ttl_email, lbl.ttl_first_name, lbl.ttl_last_name, lbl.ttl_new_person, lbl.ttl_people]

    res_labels = [lbl.res_creating_on_call_routines, lbl.res_editing_routines, lbl.res_overriding_routines,
                  lbl.res_on_call_schedule_examples, lbl.res_configuring_escalation_policies, lbl.res_creating_services,
                  lbl.res_team_components]
    page_labels += res_labels

    page_descriptions = [lbl.desc_people, lbl.desc_people_empty]
    final_context = {**top_bar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    final_context[var_names.resource_items] = resources_context.get_resources_content(res_labels, final_context)
    return final_context


def get_external_sso_list_context(lang, allowed_components):
    '''
    Context for the external sso list page.
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)

    page_labels = [lbl.dsm_type, lbl.ins_delete, lbl.ins_edit, lbl.ins_no, lbl.ins_yes, lbl.msg_external_sso_deleted,
                   lbl.qqs_are_you_sure_you_want_to_delete_this_external_sso, lbl.res_resources, lbl.ttl_external_sso,
                   lbl.ttl_new_sso, lbl.ttl_sso]

    res_labels = [lbl.res_creating_on_call_routines, lbl.res_editing_routines, lbl.res_overriding_routines,
                  lbl.res_on_call_schedule_examples, lbl.res_configuring_escalation_policies, lbl.res_creating_services,
                  lbl.res_team_components]
    page_labels += res_labels

    page_descriptions = [lbl.desc_external_sso, lbl.desc_external_sso_empty]

    final_context = {**top_bar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    final_context[var_names.resource_items] = resources_context.get_resources_content(res_labels, final_context)
    return final_context


def get_external_sso_details_context(lang, allowed_components):
    '''
    Context for the external sso details page
    '''
    top_bar_context = components_context.get_dashboard_topbar_context(lang, allowed_components)

    page_labels = [lbl.det_assertion_consumer_service_url, lbl.det_certificate_x509, lbl.det_configuration_name,
                   lbl.det_description, lbl.det_enter_azure_ad_account_domain, lbl.det_enter_google_apps_account_domain,
                   lbl.det_enter_okta_account_domain, lbl.det_enter_okta_client_id, lbl.det_enter_okta_client_secret,
                   lbl.det_idp_entity_id, lbl.det_login_url, lbl.err_configuration_name_invalid,
                   lbl.err_org_client_id_and_secret, lbl.err_sso_invalid_vendor_domain, lbl.err_sso_saml,
                   lbl.ins_cancel, lbl.ins_save, lbl.msg_external_sso_created, lbl.msg_external_sso_edited,
                   lbl.ttl_external_sso, lbl.ttl_new_sso, lbl.ttl_single_sign_on]

    page_descriptions = [lbl.desc_sso_oidc_authentication_protocol, lbl.desc_sso_saml_authentication_protocol]

    final_context = {**top_bar_context, **lt.get_context(page_labels + page_descriptions, lang)}
    return final_context
