Commit 06301ff3 authored by Anna Vovchenko's avatar Anna Vovchenko Committed by Nicolò Maria Mezzopera

Empty state frontend

parent 883a98d9
...@@ -87,6 +87,20 @@ ...@@ -87,6 +87,20 @@
width: 145px; width: 145px;
} }
.empty-state--agent {
.text-content {
@include gl-max-w-full;
@include media-breakpoint-up(lg) {
max-width: 70%;
}
}
.gl-alert-actions {
@include gl-mt-0;
@include gl-flex-wrap;
}
}
.top-area .nav-controls > .btn.btn-add-cluster { .top-area .nav-controls > .btn.btn-add-cluster {
margin-right: 0; margin-right: 0;
} }
......
<script> <script>
import { GlButton, GlEmptyState, GlLink, GlSprintf } from '@gitlab/ui'; import { GlButton, GlEmptyState, GlLink, GlSprintf, GlAlert } from '@gitlab/ui';
export default { export default {
components: { components: {
...@@ -7,12 +7,26 @@ export default { ...@@ -7,12 +7,26 @@ export default {
GlEmptyState, GlEmptyState,
GlLink, GlLink,
GlSprintf, GlSprintf,
GlAlert,
}, },
props: { props: {
image: { image: {
type: String, type: String,
required: true, required: true,
}, },
projectPath: {
type: String,
required: true,
},
hasConfigurations: {
type: Boolean,
required: true,
},
},
computed: {
repositoryPath() {
return `/${this.projectPath}`;
},
}, },
}; };
</script> </script>
...@@ -21,9 +35,10 @@ export default { ...@@ -21,9 +35,10 @@ export default {
<gl-empty-state <gl-empty-state
:svg-path="image" :svg-path="image"
:title="s__('ClusterAgents|Integrate Kubernetes with a GitLab Agent')" :title="s__('ClusterAgents|Integrate Kubernetes with a GitLab Agent')"
class="empty-state--agent"
> >
<template #description> <template #description>
<p> <p class="mw-460 gl-mx-auto">
<gl-sprintf <gl-sprintf
:message=" :message="
s__( s__(
...@@ -39,7 +54,7 @@ export default { ...@@ -39,7 +54,7 @@ export default {
</gl-sprintf> </gl-sprintf>
</p> </p>
<p> <p class="mw-460 gl-mx-auto">
<gl-sprintf <gl-sprintf
:message=" :message="
s__( s__(
...@@ -57,10 +72,40 @@ export default { ...@@ -57,10 +72,40 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
<gl-alert
v-if="!hasConfigurations"
variant="warning"
class="gl-mb-5 text-left"
:dismissible="false"
>
{{
s__(
'ClusterAgents|To install an Agent you should create an agent directory in the Repository first. We recommend that you add the Agent configuration to the directory before you start the installation process.',
)
}}
<template #actions>
<gl-button
category="primary"
variant="info"
href="https://docs.gitlab.com/ee/user/clusters/agent/#define-a-configuration-repository"
target="_blank"
class="gl-ml-0!"
>
{{ s__('ClusterAgents|Read more about getting started') }}
</gl-button>
<gl-button category="secondary" variant="info" :href="repositoryPath">
{{ s__('ClusterAgents|Go to the repository') }}
</gl-button>
</template>
</gl-alert>
</template> </template>
<template #actions> <template #actions>
<gl-button <gl-button
:disabled="!hasConfigurations"
data-testid="integration-primary-button"
category="primary" category="primary"
variant="success" variant="success"
href="https://docs.gitlab.com/ee/user/clusters/agent/#get-started-with-gitops-and-the-gitlab-agent" href="https://docs.gitlab.com/ee/user/clusters/agent/#get-started-with-gitops-and-the-gitlab-agent"
......
...@@ -78,6 +78,9 @@ export default { ...@@ -78,6 +78,9 @@ export default {
treePageInfo() { treePageInfo() {
return this.agents?.project?.repository?.tree?.trees?.pageInfo || {}; return this.agents?.project?.repository?.tree?.trees?.pageInfo || {};
}, },
hasConfigurations() {
return Boolean(this.agents?.project?.repository?.tree?.trees?.nodes?.length);
},
}, },
methods: { methods: {
nextPage() { nextPage() {
...@@ -121,7 +124,12 @@ export default { ...@@ -121,7 +124,12 @@ export default {
</div> </div>
</div> </div>
<AgentEmptyState v-else :image="emptyStateImage" /> <AgentEmptyState
v-else
:image="emptyStateImage"
:project-path="projectPath"
:has-configurations="hasConfigurations"
/>
</section> </section>
<gl-alert v-else variant="danger" :dismissible="false"> <gl-alert v-else variant="danger" :dismissible="false">
......
import { GlEmptyState, GlSprintf } from '@gitlab/ui'; import { GlAlert, GlEmptyState, GlSprintf } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import AgentEmptyState from 'ee/clusters_list/components/agent_empty_state.vue'; import AgentEmptyState from 'ee/clusters_list/components/agent_empty_state.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
describe('AgentEmptyStateComponent', () => { describe('AgentEmptyStateComponent', () => {
let wrapper; let wrapper;
const propsData = { const propsData = {
image: '/image/path', image: '/image/path',
projectPath: 'path/to/project',
hasConfigurations: false,
}; };
const findConfigurationsAlert = () => wrapper.findComponent(GlAlert);
const findIntegrationButton = () => wrapper.findByTestId('integration-primary-button');
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(AgentEmptyState, { propsData, stubs: { GlEmptyState, GlSprintf } }); wrapper = shallowMountExtended(AgentEmptyState, {
propsData,
stubs: { GlEmptyState, GlSprintf },
});
}); });
afterEach(() => { afterEach(() => {
...@@ -20,8 +29,27 @@ describe('AgentEmptyStateComponent', () => { ...@@ -20,8 +29,27 @@ describe('AgentEmptyStateComponent', () => {
} }
}); });
it('should render content', () => { describe('when there are no agent configurations in repository', () => {
expect(wrapper.find(GlEmptyState).exists()).toBe(true); it('should render notification message box', () => {
expect(wrapper.text()).toContain('Integrate with the GitLab Agent'); expect(findConfigurationsAlert().exists()).toBe(true);
});
it('should disable integration button', () => {
expect(findIntegrationButton().attributes('disabled')).toBe('true');
});
});
describe('when there is a list of agent configurations', () => {
beforeEach(() => {
propsData.hasConfigurations = true;
wrapper = shallowMountExtended(AgentEmptyState, {
propsData,
});
});
it('should render content without notification message box', () => {
expect(findEmptyState().exists()).toBe(true);
expect(findConfigurationsAlert().exists()).toBe(false);
expect(findIntegrationButton().attributes('disabled')).toBeUndefined();
});
}); });
}); });
...@@ -138,6 +138,28 @@ describe('Agents', () => { ...@@ -138,6 +138,28 @@ describe('Agents', () => {
expect(findAgentTable().exists()).toBe(false); expect(findAgentTable().exists()).toBe(false);
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
}); });
it('should pass the correct project path to empty state component', () => {
expect(findEmptyState().props('projectPath')).toEqual('path/to/project');
});
});
describe('when the agent configurations are present', () => {
const trees = [
{
name: 'agent-1',
path: '.gitlab/agents/agent-1',
webPath: '/project/path/.gitlab/agents/agent-1',
},
];
beforeEach(() => {
return createWrapper({ agents: [], trees });
});
it('should pass the correct hasConfigurations boolean value to empty state component', () => {
expect(findEmptyState().props('hasConfigurations')).toEqual(true);
});
}); });
describe('when agents query has errored', () => { describe('when agents query has errored', () => {
......
...@@ -6958,6 +6958,9 @@ msgstr "" ...@@ -6958,6 +6958,9 @@ msgstr ""
msgid "ClusterAgents|Description" msgid "ClusterAgents|Description"
msgstr "" msgstr ""
msgid "ClusterAgents|Go to the repository"
msgstr ""
msgid "ClusterAgents|Integrate Kubernetes with a GitLab Agent" msgid "ClusterAgents|Integrate Kubernetes with a GitLab Agent"
msgstr "" msgstr ""
...@@ -6979,6 +6982,9 @@ msgstr "" ...@@ -6979,6 +6982,9 @@ msgstr ""
msgid "ClusterAgents|Never" msgid "ClusterAgents|Never"
msgstr "" msgstr ""
msgid "ClusterAgents|Read more about getting started"
msgstr ""
msgid "ClusterAgents|The GitLab Agent also requires %{linkStart}enabling the Agent Server%{linkEnd}" msgid "ClusterAgents|The GitLab Agent also requires %{linkStart}enabling the Agent Server%{linkEnd}"
msgstr "" msgstr ""
...@@ -6988,6 +6994,9 @@ msgstr "" ...@@ -6988,6 +6994,9 @@ msgstr ""
msgid "ClusterAgents|This agent has no tokens" msgid "ClusterAgents|This agent has no tokens"
msgstr "" msgstr ""
msgid "ClusterAgents|To install an Agent you should create an agent directory in the Repository first. We recommend that you add the Agent configuration to the directory before you start the installation process."
msgstr ""
msgid "ClusterAgents|Unknown user" msgid "ClusterAgents|Unknown user"
msgstr "" msgstr ""
......
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