Changeset View
Changeset View
Standalone View
Standalone View
swh/web/assets/src/bundles/webapp/webapp-utils.js
/** | /** | ||||
* Copyright (C) 2018-2019 The Software Heritage developers | * Copyright (C) 2018-2020 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import objectFitImages from 'object-fit-images'; | import objectFitImages from 'object-fit-images'; | ||||
import {selectText} from 'utils/functions'; | import {selectText} from 'utils/functions'; | ||||
import {BREAKPOINT_MD} from 'utils/constants'; | import {BREAKPOINT_MD} from 'utils/constants'; | ||||
▲ Show 20 Lines • Show All 280 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// This will contain a mapping between an archived object type | // This will contain a mapping between an archived object type | ||||
// and its related SWHID metadata for each object reachable from | // and its related SWHID metadata for each object reachable from | ||||
// the current browse view. | // the current browse view. | ||||
// SWHID metadata contain the following keys: | // SWHID metadata contain the following keys: | ||||
// * object_type: type of archived object | // * object_type: type of archived object | ||||
// * object_id: sha1 object identifier | // * object_id: sha1 object identifier | ||||
// * swh_id: SWH persistent identifier without contextual info | // * swhid: SWH persistent identifier without contextual info | ||||
// * swh_id_url: URL to resolve SWH persistent identifier without contextual info | // * swhid_url: URL to resolve SWH persistent identifier without contextual info | ||||
// * context: object describing SWHID context | |||||
// * swhid_with_context: SWH persistent identifier with contextual info | |||||
// * swhid_with_context_url: URL to resolve SWH persistent identifier with contextual info | |||||
let swhidsContext_ = {}; | let swhidsContext_ = {}; | ||||
export function setSwhIdsContext(swhidsContext) { | export function setSwhIdsContext(swhidsContext) { | ||||
swhidsContext_ = {}; | swhidsContext_ = {}; | ||||
for (let swhidContext of swhidsContext) { | for (let swhidContext of swhidsContext) { | ||||
swhidsContext_[swhidContext.object_type] = swhidContext; | swhidsContext_[swhidContext.object_type] = swhidContext; | ||||
} | } | ||||
} | } | ||||
export function getSwhIdsContext() { | export function getSwhIdsContext() { | ||||
return swhidsContext_; | return swhidsContext_; | ||||
} | } |