diff --git a/src/api/artifacts-api.js b/src/api/artifacts-api.js
index 0fe2bdd68..6e431b93b 100644
--- a/src/api/artifacts-api.js
+++ b/src/api/artifacts-api.js
@@ -49,10 +49,19 @@ const fetchArtifacts = (project, filters, config = {}) => {
const artifactsApi = {
addTag: (project, tag, data) => mainHttpClient.put(`/projects/${project}/tags/${tag}`, data),
- replaceTag: (project, tag, data) => mainHttpClient.post(`/projects/${project}/tags/${tag}`, data),
+ buildFunction: data => mainHttpClient.post('/build/function', data),
+ deleteArtifact: (project, key, tag) => {
+ const config = {
+ params: {
+ key,
+ tag
+ }
+ }
+
+ return mainHttpClient.delete(`/projects/${project}/artifacts`, config)
+ },
deleteTag: (project, tag, data) =>
mainHttpClient.delete(`/projects/${project}/tags/${tag}`, { data }),
- buildFunction: data => mainHttpClient.post('/build/function', data),
getArtifactPreview: (project, path, user, fileFormat, cancelToken) => {
const config = {
params: { path }
@@ -153,6 +162,7 @@ const artifactsApi = {
}`,
data
),
+ replaceTag: (project, tag, data) => mainHttpClient.post(`/projects/${project}/tags/${tag}`, data),
updateArtifact: (project, data) =>
mainHttpClient.post(
`/projects/${project}/artifacts/${data.uid || data.metadata?.tree}/${
diff --git a/src/components/Datasets/Datasets.js b/src/components/Datasets/Datasets.js
index 5645dcd9c..9fdd12828 100644
--- a/src/components/Datasets/Datasets.js
+++ b/src/components/Datasets/Datasets.js
@@ -37,18 +37,17 @@ import {
fetchDataSet,
fetchDataSets,
removeDataSet,
- removeDataSets,
- showArtifactsPreview
+ removeDataSets
} from '../../reducers/artifactsReducer'
import {
checkForSelectedDataset,
fetchDataSetRowData,
filters,
+ generateActionsMenu,
generatePageData,
handleApplyDetailsChanges
} from './datasets.util'
import { cancelRequest } from '../../utils/cancelRequest'
-import { createDatasetsRowData, getIsTargetPathValid } from '../../utils/createArtifactsContent'
import { getArtifactIdentifier } from '../../utils/getUniqueIdentifier'
import { isDetailsTabExists } from '../../utils/isDetailsTabExists'
import { openPopUp } from 'igz-controls/utils/common.util'
@@ -59,13 +58,7 @@ import { useGetTagOptions } from '../../hooks/useGetTagOptions.hook'
import { useGroupContent } from '../../hooks/groupContent.hook'
import { useYaml } from '../../hooks/yaml.hook'
import { getViewMode } from '../../utils/helper'
-import { copyToClipboard } from '../../utils/copyToClipboard'
-import { generateUri } from '../../utils/resources'
-
-import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
-import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
-import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
-import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
+import { createDatasetsRowData } from '../../utils/createArtifactsContent'
const Datasets = () => {
const [datasets, setDatasets] = useState([])
@@ -149,45 +142,26 @@ const Datasets = () => {
)
const actionsMenu = useMemo(
- () => dataset => {
- const isTargetPathValid = getIsTargetPathValid(dataset ?? {}, frontendSpec)
-
- return [
- [
- {
- disabled: !isTargetPathValid,
- label: 'Preview',
- icon: ,
- onClick: dataset => {
- dispatch(
- showArtifactsPreview({
- isPreview: true,
- selectedItem: dataset
- })
- )
- }
- }
- ],
- [
- {
- label: 'Copy URI',
- icon: ,
- onClick: dataset => copyToClipboard(generateUri(dataset, DATASETS_PAGE), dispatch)
- },
- {
- label: 'View YAML',
- icon: ,
- onClick: toggleConvertedYaml
- },
- {
- label: 'Add a tag',
- icon: ,
- onClick: handleAddTag
- }
- ]
- ]
- },
- [dispatch, frontendSpec, handleAddTag, toggleConvertedYaml]
+ () => dataset =>
+ generateActionsMenu(
+ dataset,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ params.projectName,
+ handleRefresh,
+ datasetsFilters
+ ),
+ [
+ datasetsFilters,
+ dispatch,
+ frontendSpec,
+ handleAddTag,
+ handleRefresh,
+ params.projectName,
+ toggleConvertedYaml
+ ]
)
const applyDetailsChanges = useCallback(
diff --git a/src/components/Datasets/datasets.util.js b/src/components/Datasets/datasets.util.js
index 05a61a91b..14c3b1c10 100644
--- a/src/components/Datasets/datasets.util.js
+++ b/src/components/Datasets/datasets.util.js
@@ -17,11 +17,13 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
+import React from 'react'
import { applyTagChanges } from '../../utils/artifacts.util'
import { getArtifactIdentifier } from '../../utils/getUniqueIdentifier'
import { generateProducerDetailsInfo } from '../../utils/generateProducerDetailsInfo'
import {
+ DATASET_TYPE,
DATASETS,
DATASETS_PAGE,
FULL_VIEW_MODE,
@@ -30,10 +32,19 @@ import {
NAME_FILTER,
TAG_FILTER
} from '../../constants'
-import { createDatasetsRowData } from '../../utils/createArtifactsContent'
+import { createDatasetsRowData, getIsTargetPathValid } from '../../utils/createArtifactsContent'
import { searchArtifactItem } from '../../utils/searchArtifactItem'
import { sortListByDate } from '../../utils'
-import { fetchDataSet } from '../../reducers/artifactsReducer'
+import { fetchDataSet, showArtifactsPreview } from '../../reducers/artifactsReducer'
+import { copyToClipboard } from '../../utils/copyToClipboard'
+import { generateUri } from '../../utils/resources'
+import { handleDeleteArtifact } from '../../utils/handleDeleteArtifact'
+
+import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
+import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
+import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
+import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
+import { ReactComponent as Delete } from 'igz-controls/images/delete.svg'
export const infoHeaders = [
{
@@ -194,3 +205,66 @@ export const checkForSelectedDataset = (
}
})
}
+
+export const generateActionsMenu = (
+ dataset,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ projectName,
+ handleRefresh,
+ datasetsFilters
+) => {
+ const isTargetPathValid = getIsTargetPathValid(dataset ?? {}, frontendSpec)
+
+ return [
+ [
+ {
+ disabled: !isTargetPathValid,
+ label: 'Preview',
+ icon: ,
+ onClick: dataset => {
+ dispatch(
+ showArtifactsPreview({
+ isPreview: true,
+ selectedItem: dataset
+ })
+ )
+ }
+ }
+ ],
+ [
+ {
+ label: 'Copy URI',
+ icon: ,
+ onClick: dataset => copyToClipboard(generateUri(dataset, DATASETS_PAGE), dispatch)
+ },
+ {
+ label: 'View YAML',
+ icon: ,
+ onClick: toggleConvertedYaml
+ },
+ {
+ label: 'Add a tag',
+ icon: ,
+ onClick: handleAddTag
+ },
+ {
+ label: 'Delete',
+ icon: ,
+ className: 'danger',
+ onClick: () =>
+ handleDeleteArtifact(
+ dispatch,
+ projectName,
+ dataset.db_key,
+ dataset.tag,
+ handleRefresh,
+ datasetsFilters,
+ DATASET_TYPE
+ )
+ }
+ ]
+ ]
+}
diff --git a/src/components/Files/Files.js b/src/components/Files/Files.js
index c09a0b29f..3d3c4c976 100644
--- a/src/components/Files/Files.js
+++ b/src/components/Files/Files.js
@@ -37,18 +37,13 @@ import {
checkForSelectedFile,
fetchFilesRowData,
filters,
+ generateActionsMenu,
generatePageData,
handleApplyDetailsChanges
} from './files.util'
import { cancelRequest } from '../../utils/cancelRequest'
-import { createFilesRowData, getIsTargetPathValid } from '../../utils/createArtifactsContent'
-import {
- fetchFile,
- fetchFiles,
- removeFile,
- removeFiles,
- showArtifactsPreview
-} from '../../reducers/artifactsReducer'
+import { createFilesRowData } from '../../utils/createArtifactsContent'
+import { fetchFile, fetchFiles, removeFile, removeFiles } from '../../reducers/artifactsReducer'
import { getArtifactIdentifier } from '../../utils/getUniqueIdentifier'
import { isDetailsTabExists } from '../../utils/isDetailsTabExists'
import { openPopUp } from 'igz-controls/utils/common.util'
@@ -59,13 +54,6 @@ import { useGetTagOptions } from '../../hooks/useGetTagOptions.hook'
import { useGroupContent } from '../../hooks/groupContent.hook'
import { useYaml } from '../../hooks/yaml.hook'
import { getViewMode } from '../../utils/helper'
-import { copyToClipboard } from '../../utils/copyToClipboard'
-import { generateUri } from '../../utils/resources'
-
-import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
-import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
-import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
-import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
const Files = () => {
const [files, setFiles] = useState([])
@@ -139,45 +127,26 @@ const Files = () => {
)
const actionsMenu = useMemo(
- () => file => {
- const isTargetPathValid = getIsTargetPathValid(file ?? {}, frontendSpec)
-
- return [
- [
- {
- disabled: !isTargetPathValid,
- label: 'Preview',
- icon: ,
- onClick: file => {
- dispatch(
- showArtifactsPreview({
- isPreview: true,
- selectedItem: file
- })
- )
- }
- }
- ],
- [
- {
- label: 'Copy URI',
- icon: ,
- onClick: file => copyToClipboard(generateUri(file, FILES_PAGE), dispatch)
- },
- {
- label: 'View YAML',
- icon: ,
- onClick: toggleConvertedYaml
- },
- {
- label: 'Add a tag',
- icon: ,
- onClick: handleAddTag
- }
- ]
- ]
- },
- [dispatch, frontendSpec, handleAddTag, toggleConvertedYaml]
+ () => file =>
+ generateActionsMenu(
+ file,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ params.projectName,
+ handleRefresh,
+ filesFilters
+ ),
+ [
+ dispatch,
+ filesFilters,
+ frontendSpec,
+ handleAddTag,
+ handleRefresh,
+ params.projectName,
+ toggleConvertedYaml
+ ]
)
const handleRemoveRowData = useCallback(
diff --git a/src/components/Files/files.util.js b/src/components/Files/files.util.js
index 7ecee263b..dbb1ed977 100644
--- a/src/components/Files/files.util.js
+++ b/src/components/Files/files.util.js
@@ -17,8 +17,9 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
-
+import React from 'react'
import {
+ ARTIFACT_TYPE,
FILES_PAGE,
FULL_VIEW_MODE,
ITERATIONS_FILTER,
@@ -27,12 +28,21 @@ import {
TAG_FILTER
} from '../../constants'
import { applyTagChanges } from '../../utils/artifacts.util'
-import { createFilesRowData } from '../../utils/createArtifactsContent'
+import { createFilesRowData, getIsTargetPathValid } from '../../utils/createArtifactsContent'
import { generateProducerDetailsInfo } from '../../utils/generateProducerDetailsInfo'
import { getArtifactIdentifier } from '../../utils/getUniqueIdentifier'
import { searchArtifactItem } from '../../utils/searchArtifactItem'
import { sortListByDate } from '../../utils'
-import { fetchFile } from '../../reducers/artifactsReducer'
+import { fetchFile, showArtifactsPreview } from '../../reducers/artifactsReducer'
+import { copyToClipboard } from '../../utils/copyToClipboard'
+import { generateUri } from '../../utils/resources'
+import { handleDeleteArtifact } from '../../utils/handleDeleteArtifact'
+
+import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
+import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
+import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
+import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
+import { ReactComponent as Delete } from 'igz-controls/images/delete.svg'
export const pageDataInitialState = {
details: {
@@ -193,3 +203,66 @@ export const checkForSelectedFile = (
}
})
}
+
+export const generateActionsMenu = (
+ file,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ projectName,
+ handleRefresh,
+ datasetsFilters
+) => {
+ const isTargetPathValid = getIsTargetPathValid(file ?? {}, frontendSpec)
+
+ return [
+ [
+ {
+ disabled: !isTargetPathValid,
+ label: 'Preview',
+ icon: ,
+ onClick: file => {
+ dispatch(
+ showArtifactsPreview({
+ isPreview: true,
+ selectedItem: file
+ })
+ )
+ }
+ }
+ ],
+ [
+ {
+ label: 'Copy URI',
+ icon: ,
+ onClick: file => copyToClipboard(generateUri(file, FILES_PAGE), dispatch)
+ },
+ {
+ label: 'View YAML',
+ icon: ,
+ onClick: toggleConvertedYaml
+ },
+ {
+ label: 'Add a tag',
+ icon: ,
+ onClick: handleAddTag
+ },
+ {
+ label: 'Delete',
+ icon: ,
+ className: 'danger',
+ onClick: () =>
+ handleDeleteArtifact(
+ dispatch,
+ projectName,
+ file.db_key,
+ file.tag,
+ handleRefresh,
+ datasetsFilters,
+ ARTIFACT_TYPE
+ )
+ }
+ ]
+ ]
+}
diff --git a/src/components/ModelsPage/Models/Models.js b/src/components/ModelsPage/Models/Models.js
index eefb8650f..d8059482d 100644
--- a/src/components/ModelsPage/Models/Models.js
+++ b/src/components/ModelsPage/Models/Models.js
@@ -26,12 +26,7 @@ import AddArtifactTagPopUp from '../../../elements/AddArtifactTagPopUp/AddArtifa
import DeployModelPopUp from '../../../elements/DeployModelPopUp/DeployModelPopUp'
import ModelsView from './ModelsView'
-import {
- fetchModel,
- removeModel,
- removeModels,
- showArtifactsPreview
-} from '../../../reducers/artifactsReducer'
+import { fetchModel, removeModel, removeModels } from '../../../reducers/artifactsReducer'
import {
GROUP_BY_NAME,
MODELS_PAGE,
@@ -45,13 +40,14 @@ import {
checkForSelectedModel,
fetchModelsRowData,
filters,
+ generateActionsMenu,
generatePageData,
getFeatureVectorData,
handleApplyDetailsChanges
} from './models.util'
import detailsActions from '../../../actions/details'
import { cancelRequest } from '../../../utils/cancelRequest'
-import { createModelsRowData, getIsTargetPathValid } from '../../../utils/createArtifactsContent'
+import { createModelsRowData } from '../../../utils/createArtifactsContent'
import { getArtifactIdentifier } from '../../../utils/getUniqueIdentifier'
import { isDetailsTabExists } from '../../../utils/isDetailsTabExists'
import { openPopUp } from 'igz-controls/utils/common.util'
@@ -63,14 +59,6 @@ import { useModelsPage } from '../ModelsPage.context'
import { useSortTable } from '../../../hooks/useSortTable.hook'
import { useGetTagOptions } from '../../../hooks/useGetTagOptions.hook'
import { getViewMode } from '../../../utils/helper'
-import { generateUri } from '../../../utils/resources'
-import { copyToClipboard } from '../../../utils/copyToClipboard'
-
-import { ReactComponent as DeployIcon } from 'igz-controls/images/deploy-icon.svg'
-import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
-import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
-import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
-import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
const Models = ({ fetchModelFeatureVector }) => {
const [selectedModel, setSelectedModel] = useState({})
@@ -139,50 +127,28 @@ const Models = ({ fetchModelFeatureVector }) => {
)
const actionsMenu = useMemo(
- () => model => {
- const isTargetPathValid = getIsTargetPathValid(model ?? {}, frontendSpec)
-
- return [
- [
- {
- disabled: !isTargetPathValid,
- label: 'Preview',
- icon: ,
- onClick: model => {
- dispatch(
- showArtifactsPreview({
- isPreview: true,
- selectedItem: model
- })
- )
- }
- },
- {
- label: 'Deploy',
- icon: ,
- onClick: handleDeployModel
- }
- ],
- [
- {
- label: 'View YAML',
- icon: ,
- onClick: toggleConvertedYaml
- },
- {
- label: 'Copy URI',
- icon: ,
- onClick: model => copyToClipboard(generateUri(model, MODELS_TAB), dispatch)
- },
- {
- label: 'Add a tag',
- icon: ,
- onClick: handleAddTag
- }
- ]
- ]
- },
- [dispatch, frontendSpec, handleAddTag, handleDeployModel, toggleConvertedYaml]
+ () => model =>
+ generateActionsMenu(
+ model,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ params.projectName,
+ handleRefresh,
+ modelsFilters,
+ handleDeployModel
+ ),
+ [
+ dispatch,
+ frontendSpec,
+ handleAddTag,
+ handleDeployModel,
+ handleRefresh,
+ modelsFilters,
+ params.projectName,
+ toggleConvertedYaml
+ ]
)
const handleRemoveRowData = useCallback(
diff --git a/src/components/ModelsPage/Models/models.util.js b/src/components/ModelsPage/Models/models.util.js
index e0b4fefb2..9927a2080 100644
--- a/src/components/ModelsPage/Models/models.util.js
+++ b/src/components/ModelsPage/Models/models.util.js
@@ -17,6 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
+import React from 'react'
import { cloneDeep, isEmpty, omit } from 'lodash'
import {
@@ -27,17 +28,32 @@ import {
MODELS_PAGE,
MODELS_TAB,
TAG_LATEST,
- FULL_VIEW_MODE
+ FULL_VIEW_MODE,
+ MODEL_TYPE
} from '../../../constants'
import { FORBIDDEN_ERROR_STATUS_CODE } from 'igz-controls/constants'
import { applyTagChanges } from '../../../utils/artifacts.util'
-import { createModelsRowData } from '../../../utils/createArtifactsContent'
+import { createModelsRowData, getIsTargetPathValid } from '../../../utils/createArtifactsContent'
import { generateProducerDetailsInfo } from '../../../utils/generateProducerDetailsInfo'
import { getArtifactIdentifier } from '../../../utils/getUniqueIdentifier'
import { searchArtifactItem } from '../../../utils/searchArtifactItem'
-import { fetchModel, updateArtifact } from '../../../reducers/artifactsReducer'
+import {
+ fetchModel,
+ showArtifactsPreview,
+ updateArtifact
+} from '../../../reducers/artifactsReducer'
import { convertChipsData } from '../../../utils/convertChipsData'
import { sortListByDate } from '../../../utils'
+import { copyToClipboard } from '../../../utils/copyToClipboard'
+import { generateUri } from '../../../utils/resources'
+import { handleDeleteArtifact } from '../../../utils/handleDeleteArtifact'
+
+import { ReactComponent as TagIcon } from 'igz-controls/images/tag-icon.svg'
+import { ReactComponent as YamlIcon } from 'igz-controls/images/yaml.svg'
+import { ReactComponent as ArtifactView } from 'igz-controls/images/eye-icon.svg'
+import { ReactComponent as Copy } from 'igz-controls/images/copy-to-clipboard-icon.svg'
+import { ReactComponent as Delete } from 'igz-controls/images/delete.svg'
+import { ReactComponent as DeployIcon } from 'igz-controls/images/deploy-icon.svg'
export const filters = [
{ type: TAG_FILTER, label: 'Version tag:' },
@@ -279,3 +295,72 @@ export const checkForSelectedModel = (
}
})
}
+
+export const generateActionsMenu = (
+ model,
+ frontendSpec,
+ dispatch,
+ toggleConvertedYaml,
+ handleAddTag,
+ projectName,
+ handleRefresh,
+ modelsFilters,
+ handleDeployModel
+) => {
+ const isTargetPathValid = getIsTargetPathValid(model ?? {}, frontendSpec)
+
+ return [
+ [
+ {
+ disabled: !isTargetPathValid,
+ label: 'Preview',
+ icon: ,
+ onClick: model => {
+ dispatch(
+ showArtifactsPreview({
+ isPreview: true,
+ selectedItem: model
+ })
+ )
+ }
+ },
+ {
+ label: 'Deploy',
+ icon: ,
+ onClick: handleDeployModel
+ }
+ ],
+ [
+ {
+ label: 'Copy URI',
+ icon: ,
+ onClick: model => copyToClipboard(generateUri(model, MODELS_TAB), dispatch)
+ },
+ {
+ label: 'View YAML',
+ icon: ,
+ onClick: toggleConvertedYaml
+ },
+ {
+ label: 'Add a tag',
+ icon: ,
+ onClick: handleAddTag
+ },
+ {
+ label: 'Delete',
+ icon: ,
+ className: 'danger',
+ onClick: () =>
+ handleDeleteArtifact(
+ dispatch,
+ projectName,
+ model.db_key,
+ model.tag,
+ handleRefresh,
+ modelsFilters,
+ MODEL_TYPE
+ )
+ }
+ ]
+ ]
+}
diff --git a/src/reducers/artifactsReducer.js b/src/reducers/artifactsReducer.js
index 8fc0f03e3..154ea1cdb 100644
--- a/src/reducers/artifactsReducer.js
+++ b/src/reducers/artifactsReducer.js
@@ -56,6 +56,7 @@ const initialState = {
loading: false
}
},
+ loading: false,
modelEndpoints: [],
models: {
allData: [],
@@ -67,13 +68,18 @@ const initialState = {
}
},
pipelines: [],
- preview: {},
- loading: false
+ preview: {}
}
export const addTag = createAsyncThunk('addTag', ({ project, tag, data }) => {
return artifactsApi.addTag(project, tag, data)
})
+export const buildFunction = createAsyncThunk('buildFunction', ({ funcData }) => {
+ return artifactsApi.buildFunction(funcData)
+})
+export const deleteArtifact = createAsyncThunk('deleteArtifact', ({ project, key, tag }) => {
+ return artifactsApi.deleteArtifact(project, key, tag)
+})
export const deleteTag = createAsyncThunk('deleteTag', ({ project, tag, data }) => {
return artifactsApi.deleteTag(project, tag, data)
})
@@ -84,12 +90,6 @@ export const editTag = createAsyncThunk('editTag', ({ project, oldTag, tag, data
}
})
})
-export const replaceTag = createAsyncThunk('replaceTag', ({ project, tag, data }) => {
- return artifactsApi.replaceTag(project, tag, data)
-})
-export const buildFunction = createAsyncThunk('buildFunction', ({ funcData }) => {
- return artifactsApi.buildFunction(funcData)
-})
export const fetchArtifact = createAsyncThunk('fetchArtifact', ({ project, artifact }) => {
return artifactsApi.getArtifact(project, artifact).then(({ data }) => {
return filterArtifacts(data.artifacts)
@@ -166,6 +166,9 @@ export const fetchModels = createAsyncThunk('fetchModels', ({ project, filters }
return generateArtifacts(result, MODELS_TAB, data.artifacts)
})
})
+export const replaceTag = createAsyncThunk('replaceTag', ({ project, tag, data }) => {
+ return artifactsApi.replaceTag(project, tag, data)
+})
export const updateArtifact = createAsyncThunk('updateArtifact', ({ project, data }) => {
return artifactsApi.updateArtifact(project, data)
})
@@ -174,9 +177,6 @@ const artifactsSlice = createSlice({
name: 'artifactsStore',
initialState,
reducers: {
- showArtifactsPreview(state, action) {
- state.preview = action.payload
- },
closeArtifactsPreview(state) {
state.preview = {
isPreview: false,
@@ -218,21 +218,27 @@ const artifactsSlice = createSlice({
},
removePipelines(state) {
state.pipelines = initialState.pipelines
+ },
+ showArtifactsPreview(state, action) {
+ state.preview = action.payload
}
},
extraReducers: builder => {
builder.addCase(addTag.pending, showLoading)
builder.addCase(addTag.fulfilled, hideLoading)
builder.addCase(addTag.rejected, hideLoading)
+ builder.addCase(buildFunction.pending, defaultPendingHandler)
+ builder.addCase(buildFunction.fulfilled, defaultFulfilledHandler)
+ builder.addCase(buildFunction.rejected, defaultRejectedHandler)
+ builder.addCase(deleteArtifact.pending, showLoading)
+ builder.addCase(deleteArtifact.fulfilled, hideLoading)
+ builder.addCase(deleteArtifact.rejected, hideLoading)
builder.addCase(deleteTag.pending, showLoading)
builder.addCase(deleteTag.fulfilled, hideLoading)
builder.addCase(deleteTag.rejected, hideLoading)
builder.addCase(editTag.pending, showLoading)
builder.addCase(editTag.fulfilled, hideLoading)
builder.addCase(editTag.rejected, hideLoading)
- builder.addCase(buildFunction.pending, defaultPendingHandler)
- builder.addCase(buildFunction.fulfilled, defaultFulfilledHandler)
- builder.addCase(buildFunction.rejected, defaultRejectedHandler)
builder.addCase(fetchArtifacts.pending, defaultPendingHandler)
builder.addCase(fetchArtifacts.fulfilled, (state, action) => {
state.artifacts = action.payload
@@ -243,6 +249,13 @@ const artifactsSlice = createSlice({
state.error = action.payload
state.loading = false
})
+ builder.addCase(fetchArtifactsFunctions.pending, defaultPendingHandler)
+ builder.addCase(fetchArtifactsFunctions.fulfilled, (state, action) => {
+ state.error = null
+ state.pipelines = action.payload
+ state.loading = false
+ })
+ builder.addCase(fetchArtifactsFunctions.rejected, defaultRejectedHandler)
builder.addCase(fetchDataSet.fulfilled, (state, action) => {
state.dataSets.selectedRowData.content[getArtifactIdentifier(action.payload[0])] =
action.payload
@@ -264,25 +277,6 @@ const artifactsSlice = createSlice({
state.loading = false
})
builder.addCase(fetchFiles.rejected, defaultRejectedHandler)
- builder.addCase(fetchArtifactsFunctions.pending, defaultPendingHandler)
- builder.addCase(fetchArtifactsFunctions.fulfilled, (state, action) => {
- state.error = null
- state.pipelines = action.payload
- state.loading = false
- })
- builder.addCase(fetchArtifactsFunctions.rejected, defaultRejectedHandler)
- builder.addCase(fetchModelEndpoints.pending, defaultPendingHandler)
- builder.addCase(fetchModelEndpoints.fulfilled, (state, action) => {
- state.error = null
- state.modelEndpoints = action.payload
- state.loading = false
- })
- builder.addCase(fetchModelEndpoints.rejected, (state, action) => {
- state.error = action.payload
- state.modelEndpoints = []
- state.loading = false
- })
-
builder.addCase(fetchModel.pending, (state, action) => {
state.models.selectedRowData = {
content: initialState.models.selectedRowData.content,
@@ -303,7 +297,17 @@ const artifactsSlice = createSlice({
loading: true
}
})
-
+ builder.addCase(fetchModelEndpoints.pending, defaultPendingHandler)
+ builder.addCase(fetchModelEndpoints.fulfilled, (state, action) => {
+ state.error = null
+ state.modelEndpoints = action.payload
+ state.loading = false
+ })
+ builder.addCase(fetchModelEndpoints.rejected, (state, action) => {
+ state.error = action.payload
+ state.modelEndpoints = []
+ state.loading = false
+ })
builder.addCase(fetchModels.pending, defaultPendingHandler)
builder.addCase(fetchModels.fulfilled, (state, action) => {
state.error = null
diff --git a/src/utils/handleDeleteArtifact.js b/src/utils/handleDeleteArtifact.js
new file mode 100644
index 000000000..bb07fb0b0
--- /dev/null
+++ b/src/utils/handleDeleteArtifact.js
@@ -0,0 +1,65 @@
+/*
+Copyright 2019 Iguazio Systems Ltd.
+
+Licensed under the Apache License, Version 2.0 (the "License") with
+an addition restriction as set forth herein. You may not use this
+file except in compliance with the License. You may obtain a copy of
+the License at http://www.apache.org/licenses/LICENSE-2.0.
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied. See the License for the specific language governing
+permissions and limitations under the License.
+
+In addition, you may not use the software for any purposes that are
+illegal under applicable law, and the grant of the foregoing license
+under the Apache 2.0 license is conditioned upon your compliance with
+such restriction.
+*/
+import { deleteArtifact } from '../reducers/artifactsReducer'
+import { setNotification } from '../reducers/notificationReducer'
+import { TAG_LATEST } from '../constants'
+
+export const handleDeleteArtifact = (
+ dispatch,
+ project,
+ key,
+ tag = TAG_LATEST,
+ refreshArtifacts,
+ filters,
+ artifactType
+) => {
+ console.log(artifactType)
+ dispatch(deleteArtifact({ project, key, tag }))
+ .unwrap()
+ .then(() => {
+ refreshArtifacts(filters)
+ dispatch(
+ setNotification({
+ status: 200,
+ id: Math.random(),
+ message: `${artifactType} is successfully deleted`
+ })
+ )
+ })
+ .catch(error => {
+ dispatch(
+ setNotification({
+ status: error.response?.status || 400,
+ id: Math.random(),
+ retry: () =>
+ handleDeleteArtifact(
+ dispatch,
+ project,
+ key,
+ (tag = TAG_LATEST),
+ refreshArtifacts,
+ filters,
+ artifactType
+ ),
+ message: error.response?.data?.detail || `Deleting ${artifactType} failed`
+ })
+ )
+ })
+}