Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/add_forge/create-request.js
/** | /** | ||||
* Copyright (C) 2022 The Software Heritage developers | * Copyright (C) 2022 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 {handleFetchError, errorMessageFromResponse, csrfPost, | |||||
getHumanReadableDate, genLink} from 'utils/functions'; | |||||
import userRequestsFilterCheckboxFn from 'utils/requests-filter-checkbox.ejs'; | |||||
import {swhSpinnerSrc} from 'utils/constants'; | import {swhSpinnerSrc} from 'utils/constants'; | ||||
import { | |||||
csrfPost, errorMessageFromResponse, genLink, getHumanReadableDate, | |||||
handleFetchError, validateUrl | |||||
} from 'utils/functions'; | |||||
import userRequestsFilterCheckboxFn from 'utils/requests-filter-checkbox.ejs'; | |||||
let requestBrowseTable; | let requestBrowseTable; | ||||
const addForgeCheckboxId = 'swh-add-forge-user-filter'; | const addForgeCheckboxId = 'swh-add-forge-user-filter'; | ||||
const userRequestsFilterCheckbox = userRequestsFilterCheckboxFn({ | const userRequestsFilterCheckbox = userRequestsFilterCheckboxFn({ | ||||
'inputId': addForgeCheckboxId, | 'inputId': addForgeCheckboxId, | ||||
'checked': true // by default, display only user requests | 'checked': true // by default, display only user requests | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | .DataTable({ | ||||
name: 'status', | name: 'status', | ||||
render: function(data, type, row, meta) { | render: function(data, type, row, meta) { | ||||
return swh.add_forge.formatRequestStatusName(data); | return swh.add_forge.formatRequestStatusName(data); | ||||
} | } | ||||
} | } | ||||
] | ] | ||||
}); | }); | ||||
} | } | ||||
export function validateForgeUrl(input) { | |||||
let customValidity = ''; | |||||
if (!validateUrl(input.value.trim(), ['http', 'https'])) { | |||||
customValidity = 'The provided forge URL is not valid.'; | |||||
} | |||||
input.setCustomValidity(customValidity); | |||||
} |