Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0a888229
Commit
0a888229
authored
Aug 16, 2021
by
Anna Vovchenko
Committed by
Olena Horal-Koretska
Aug 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upsell the GitLab Terraform features - iteration 2
parent
192e2526
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
52 deletions
+32
-52
app/assets/javascripts/projects/terraform_notification/components/terraform_notification.vue
...raform_notification/components/terraform_notification.vue
+14
-28
app/assets/javascripts/projects/terraform_notification/index.js
...sets/javascripts/projects/terraform_notification/index.js
+9
-4
app/views/projects/_terraform_banner.html.haml
app/views/projects/_terraform_banner.html.haml
+1
-1
spec/frontend/projects/terraform_notification/terraform_notification_spec.js
...cts/terraform_notification/terraform_notification_spec.js
+8
-19
No files found.
app/assets/javascripts/projects/terraform_notification/components/terraform_notification.vue
View file @
0a888229
<
script
>
import
{
GlBanner
}
from
'
@gitlab/ui
'
;
import
{
helpPagePath
}
from
'
~/helpers/help_page_helper
'
;
import
{
parseBoolean
,
setCookie
,
g
etCookie
}
from
'
~/lib/utils/common_utils
'
;
import
{
s
etCookie
}
from
'
~/lib/utils/common_utils
'
;
import
{
s__
}
from
'
~/locale
'
;
export
default
{
...
...
@@ -16,50 +16,36 @@ export default {
components
:
{
GlBanner
,
},
props
:
{
projectId
:
{
type
:
Number
,
required
:
true
,
},
},
inject
:
[
'
terraformImagePath
'
,
'
bannerDismissedKey
'
],
data
()
{
return
{
isVisible
:
true
,
};
},
computed
:
{
bannerDissmisedKey
()
{
return
`terraform_notification_dismissed_for_project_
${
this
.
projectId
}
`
;
},
docsUrl
()
{
return
helpPagePath
(
'
user/infrastructure/terraform_state
'
);
},
},
created
()
{
if
(
parseBoolean
(
getCookie
(
this
.
bannerDissmisedKey
)))
{
this
.
isVisible
=
false
;
}
},
methods
:
{
handleClose
()
{
setCookie
(
this
.
bannerDis
smi
sedKey
,
true
);
setCookie
(
this
.
bannerDis
mis
sedKey
,
true
);
this
.
isVisible
=
false
;
},
},
};
</
script
>
<
template
>
<div
v-if=
"isVisible"
>
<div
class=
"gl-py-5"
>
<div
v-if=
"isVisible"
class=
"gl-py-5"
>
<gl-banner
:title=
"$options.i18n.title"
:button-text=
"$options.i18n.buttonText"
:button-link=
"docsUrl"
variant=
"introduction"
:svg-path=
"terraformImagePath"
variant=
"promotion"
@
close=
"handleClose"
>
<p>
{{
$options
.
i18n
.
description
}}
</p>
</gl-banner>
</div>
</div>
</
template
>
app/assets/javascripts/projects/terraform_notification/index.js
View file @
0a888229
import
Vue
from
'
vue
'
;
import
{
parseBoolean
,
getCookie
}
from
'
~/lib/utils/common_utils
'
;
import
TerraformNotification
from
'
./components/terraform_notification.vue
'
;
export
default
()
=>
{
const
el
=
document
.
querySelector
(
'
.js-terraform-notification
'
);
const
bannerDismissedKey
=
'
terraform_notification_dismissed
'
;
if
(
!
el
)
{
if
(
!
el
||
parseBoolean
(
getCookie
(
bannerDismissedKey
))
)
{
return
false
;
}
const
{
projectId
}
=
el
.
dataset
;
const
{
terraformImagePath
}
=
el
.
dataset
;
return
new
Vue
({
el
,
render
:
(
createElement
)
=>
createElement
(
TerraformNotification
,
{
props
:
{
projectId
:
Number
(
projectId
)
}
}),
provide
:
{
terraformImagePath
,
bannerDismissedKey
,
},
render
:
(
createElement
)
=>
createElement
(
TerraformNotification
),
});
};
app/views/projects/_terraform_banner.html.haml
View file @
0a888229
...
...
@@ -2,4 +2,4 @@
-
if
show_terraform_banner?
(
project
)
.container-fluid
{
class:
@content_class
}
.js-terraform-notification
{
data:
{
project_id:
project
.
id
}
}
.js-terraform-notification
{
data:
{
terraform_image_path:
image_path
(
'illustrations/third-party-logos/ci_cd-template-logos/terraform.svg'
)
}
}
spec/frontend/projects/terraform_notification/terraform_notification_spec.js
View file @
0a888229
...
...
@@ -5,19 +5,21 @@ import TerraformNotification from '~/projects/terraform_notification/components/
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
const
bannerDissmisedKey
=
'
terraform_notification_dismissed_for_project_1
'
;
const
terraformImagePath
=
'
/path/to/image
'
;
const
bannerDismissedKey
=
'
terraform_notification_dismissed
'
;
describe
(
'
TerraformNotificationBanner
'
,
()
=>
{
let
wrapper
;
const
propsData
=
{
projectId
:
1
,
const
provideData
=
{
terraformImagePath
,
bannerDismissedKey
,
};
const
findBanner
=
()
=>
wrapper
.
findComponent
(
GlBanner
);
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
TerraformNotification
,
{
pro
ps
Data
,
pro
vide
:
provide
Data
,
stubs
:
{
GlBanner
},
});
});
...
...
@@ -27,19 +29,6 @@ describe('TerraformNotificationBanner', () => {
parseBoolean
.
mockReturnValue
(
false
);
});
describe
(
'
when the dismiss cookie is set
'
,
()
=>
{
beforeEach
(()
=>
{
parseBoolean
.
mockReturnValue
(
true
);
wrapper
=
shallowMount
(
TerraformNotification
,
{
propsData
,
});
});
it
(
'
should not render the banner
'
,
()
=>
{
expect
(
findBanner
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
when the dismiss cookie is not set
'
,
()
=>
{
it
(
'
should render the banner
'
,
()
=>
{
expect
(
findBanner
().
exists
()).
toBe
(
true
);
...
...
@@ -51,8 +40,8 @@ describe('TerraformNotificationBanner', () => {
await
findBanner
().
vm
.
$emit
(
'
close
'
);
});
it
(
'
should set the cookie with the bannerDis
smi
sedKey
'
,
()
=>
{
expect
(
setCookie
).
toHaveBeenCalledWith
(
bannerDis
smi
sedKey
,
true
);
it
(
'
should set the cookie with the bannerDis
mis
sedKey
'
,
()
=>
{
expect
(
setCookie
).
toHaveBeenCalledWith
(
bannerDis
mis
sedKey
,
true
);
});
it
(
'
should remove the banner
'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment