Commit 4ca65e16 authored by charlie ablett's avatar charlie ablett

Merge branch '323418-verify-and-validate-your-terraform-modules-in-the-ui' into 'master'

Add dedicated details page for terraform registry

See merge request gitlab-org/gitlab!61985
parents bf490f3d db75e4e8
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import PackagesApp from '~/packages/details/components/app.vue';
import createStore from '~/packages/details/store';
import Translate from '~/vue_shared/translate';
Vue.use(Translate);
export default () => {
const el = document.querySelector('#js-vue-packages-detail');
const { package: packageJson, canDelete: canDeleteStr, ...rest } = el.dataset;
const packageEntity = JSON.parse(packageJson);
const canDelete = parseBoolean(canDeleteStr);
const store = createStore({
packageEntity,
packageFiles: packageEntity.package_files,
canDelete,
...rest,
});
return new Vue({
el,
store,
render(createElement) {
return createElement(PackagesApp);
},
});
};
import initDetails from '~/packages_and_registries/infrastructure_registry/details_app_bundle';
initDetails();
......@@ -3,7 +3,19 @@
module Projects
module Packages
class InfrastructureRegistryController < Projects::ApplicationController
before_action :verify_feature_enabled!
feature_category :infrastructure_as_code
def show
@package = project.packages.find(params[:id])
@package_files = @package.package_files.recent
end
private
def verify_feature_enabled!
render_404 unless Feature.enabled?(:infrastructure_registry_page)
end
end
end
end
- add_to_breadcrumbs _("Infrastructure Registry"), project_packages_path(@project)
- add_to_breadcrumbs @package.name, project_packages_path(@project)
- breadcrumb_title @package.version
- page_title _("Infrastructure Registry")
- @content_class = "limit-container-width" unless fluid_layout
.row
.col-12
#js-vue-packages-detail{ data: { package: package_from_presenter(@package),
can_delete: can?(current_user, :destroy_package, @project).to_s,
svg_path: image_path('illustrations/no-packages.svg'),
project_name: @project.name,
project_list_url: project_infrastructure_registry_index_path(@project)} }
......@@ -50,7 +50,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources :infrastructure_registry, only: [:index], module: :packages
resources :infrastructure_registry, only: [:index, :show], module: :packages
resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
collection do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Infrastructure Registry' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
before do
sign_in(user)
project.add_maintainer(user)
end
context 'when feature is not available' do
before do
stub_feature_flags(infrastructure_registry_page: false)
end
it 'gives 404' do
visit_project_infrastructure_registry
expect(status_code).to eq(404)
end
end
context 'when feature is available', :js do
before do
visit_project_infrastructure_registry
end
context 'when there are packages' do
let_it_be(:terraform_module) { create(:terraform_module_package, project: project, created_at: 1.day.ago, version: '1.0.0') }
let_it_be(:terraform_module2) { create(:terraform_module_package, project: project, created_at: 2.days.ago, version: '2.0.0') }
let_it_be(:packages) { [terraform_module, terraform_module2] }
it_behaves_like 'packages list'
context 'deleting a package' do
let_it_be(:project) { create(:project) }
let_it_be(:terraform_module) { create(:terraform_module_package, project: project) }
it 'allows you to delete a module', :aggregate_failures do
# this is still using the package copy in the UI too
click_button('Remove package')
click_button('Delete package')
expect(page).to have_content 'Package deleted successfully'
expect(page).not_to have_content(terraform_module.name)
end
end
end
it 'displays the empty message' do
expect(page).to have_content('You have no Terraform modules in your project')
end
end
def visit_project_infrastructure_registry
visit project_infrastructure_registry_index_path(project)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment