Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui,api): modal style, labels validation, remove z-indexes #4986

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(ui,api): modal style, labels validation, remove z-indexes
richardlt committed Feb 16, 2020
commit 01a4d7673d913f8fe080ffad672b3cd63fe94c40
5 changes: 4 additions & 1 deletion engine/api/project.go
Original file line number Diff line number Diff line change
@@ -363,10 +363,13 @@ func (api *API) putProjectLabelsHandler() service.Handler {
key := vars[permProjectKey]
db := api.mustDB()

var labels []sdk.Label
var labels sdk.Labels
if err := service.UnmarshalBody(r, &labels); err != nil {
return sdk.WrapError(err, "Unmarshall error")
}
if err := labels.IsValid(); err != nil {
return err
}

// Check is project exist
proj, err := project.Load(db, api.Cache, key, project.LoadOptions.WithLabels)
8 changes: 4 additions & 4 deletions engine/api/project/dao.go
Original file line number Diff line number Diff line change
@@ -341,8 +341,8 @@ func DeleteLabel(db gorp.SqlExecutor, labelID int64) error {

// InsertLabel insert a label
func InsertLabel(db gorp.SqlExecutor, label *sdk.Label) error {
if err := label.Validate(); err != nil {
return sdk.WithStack(err)
if err := label.IsValid(); err != nil {
return err
}

lbl := dbLabel(*label)
@@ -356,8 +356,8 @@ func InsertLabel(db gorp.SqlExecutor, label *sdk.Label) error {

// UpdateLabel update a label
func UpdateLabel(db gorp.SqlExecutor, label *sdk.Label) error {
if err := label.Validate(); err != nil {
return sdk.WithStack(err)
if err := label.IsValid(); err != nil {
return err
}

lbl := dbLabel(*label)
23 changes: 18 additions & 5 deletions sdk/workflow.go
Original file line number Diff line number Diff line change
@@ -259,26 +259,39 @@ type Label struct {
WorkflowID int64 `json:"workflow_id,omitempty" db:"-"`
}

//Validate return error or update label if it is not valid
func (label *Label) Validate() error {
// IsValid return an error or update label if it is not valid.
func (label *Label) IsValid() error {
if label.Name == "" {
return WrapError(fmt.Errorf("Label must have a name"), "IsValid>")
return NewErrorFrom(ErrWrongRequest, "label must have a name")
}
if label.Color == "" {
bytes := make([]byte, 3)
if _, err := rand.Read(bytes); err != nil {
return WrapError(err, "IsValid> Cannot create random color")
return WrapError(err, "cannot create random color")
}
label.Color = "#" + hex.EncodeToString(bytes)
} else {
if !ColorRegexp.Match([]byte(label.Color)) {
return ErrIconBadFormat
return WithStack(ErrIconBadFormat)
}
}

return nil
}

// Labels slice.
type Labels []Label

// IsValid returns an error if a label is not valid.
func (l Labels) IsValid() error {
for i := range l {
if err := l[i].IsValid(); err != nil {
return err
}
}
return nil
}

// WorkflowToIDs returns ids of given workflows.
func WorkflowToIDs(ws []*Workflow) []int64 {
ids := make([]int64, len(ws))
12 changes: 7 additions & 5 deletions ui/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<div id="AppComponent">
<ng-container *ngIf="!isConnected || !maintenance || user?.ring === 'ADMIN'">
<div id="navbar" *ngIf="isConnected && !hideNavBar" [class.connected]="isConnected">
<ng-container *ngIf="isConnected && !hideNavBar">
<app-navbar></app-navbar>
</div>
<div class="maintenance banner" [class.mt50]="isConnected" *ngIf="maintenance && (!isConnected || user?.ring == 'ADMIN')">
</ng-container>
<div class="maintenance banner" [class.mt50]="isConnected"
*ngIf="maintenance && (!isConnected || user?.ring == 'ADMIN')">
<span>{{ 'maintenance_title' | translate }}</span>
<img src="assets/images/maintenance.svg"/>
<img src="assets/images/maintenance.svg" />
</div>
<div class="banner pointing" (click)="refresh()" *ngIf="showUIUpdatedBanner">
{{ 'ui_updated' | translate }}
@@ -17,7 +18,8 @@
<toaster-container [toasterconfig]="toasterConfig"></toaster-container>
</div>
<router-outlet></router-outlet>
<div class="ui active text loader" *ngIf="displayResolver">{{ 'common_loading_project' | translate }}</div>
<div class="ui active text loader" *ngIf="displayResolver">{{ 'common_loading_project' | translate }}
</div>
</div>
</div>
</ng-container>
176 changes: 82 additions & 94 deletions ui/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,113 +1,101 @@
@import '../common';
@import "../common";

#AppComponent {
height: 100%;
#navbar {
padding: 0px;
width: 100%;
position: fixed;
display: none;
z-index: 1020;
}
#navbar.connected {
display: inherit;
}
.maintenance.banner {
margin-top: 0;
img {
position: absolute;
left: 0;
animation: slideinbanner 10s infinite;
height: 50px;
height: 100%;
.maintenance.banner {
margin-top: 0;
img {
position: absolute;
left: 0;
animation: slideinbanner 10s infinite;
height: 50px;
}
}
}
.maintenance.banner.mt50 {
margin-top: 50px;
}
.banner {
height: 50px;
margin-top: $navbarHeight;
background-color: $cds_color_red;
text-align: center;
line-height: 50px;
color: white;
font-weight: 600;
}
.page.connected {
padding-top: $navbarHeight;
}
.page {
height: inherit;
z-index: 0;
.content {
height: inherit;
margin-left: $sidebarCloseWidth;
transition: all .4s ease 0s;
padding-top: 0px;
.maintenance.banner.mt50 {
margin-top: 50px;
}
.banner {
height: 50px;
margin-top: $navbarHeight;
background-color: $cds_color_red;
text-align: center;
line-height: 50px;
color: white;
font-weight: 600;
}
.page.connected {
padding-top: $navbarHeight;
}
.page {
height: inherit;
.content {
height: inherit;
margin-left: $sidebarCloseWidth;
transition: all 0.4s ease 0s;
padding-top: 0px;
}
}
}

.maintenance {
.maintenance {
h2 {
margin: 20px 0;
text-align: center;
}

h2 {
margin: 20px 0;
text-align: center;
.logo {
width: 400px;
margin: auto;
img {
height: 150px;
animation: slidein 10s infinite;
}
}
}

.logo {
width: 400px;
margin: auto;
img {
height: 150px;
animation: slidein 10s infinite;
}
.gamification {
width: 450px;
height: 450px;
margin: auto;
}
}
.gamification {
width: 450px;
height: 450px;
margin: auto;
}
}

@keyframes slidein {
from {
margin-left: -50%;
transform: scaleX(1);
}
from {
margin-left: -50%;
transform: scaleX(1);
}

50% {
margin-left: 100%;
transform: scaleX(1);
}
51% {
margin-left: 100%;
transform: scaleX(-1);
}
50% {
margin-left: 100%;
transform: scaleX(1);
}
51% {
margin-left: 100%;
transform: scaleX(-1);
}

to {
margin-left: -50%;
transform: scaleX(-1);
}
to {
margin-left: -50%;
transform: scaleX(-1);
}
}

@keyframes slideinbanner {
from {
left: 0;
transform: scaleX(1);
}
from {
left: 0;
transform: scaleX(1);
}

50% {
left: 96%;
transform: scaleX(1);
}
51% {
left: 96%;
transform: scaleX(-1);
}
50% {
left: 96%;
transform: scaleX(1);
}
51% {
left: 96%;
transform: scaleX(-1);
}

to {
left: 0%;
transform: scaleX(-1);
}
to {
left: 0%;
transform: scaleX(-1);
}
}
3 changes: 1 addition & 2 deletions ui/src/app/shared/action/action.scss
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@
background-color: #f9f9f9;
position: fixed;
bottom: 0;
z-index: 30;
right: 0;
width: 430px;
padding-top: 20px;
@@ -81,4 +80,4 @@
padding: 3px 0 !important;
}
}
}
}
3 changes: 1 addition & 2 deletions ui/src/app/shared/breadcrumb/breadcrumb.scss
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

.CDSbreadcrumb {
padding: 15px;
z-index: 100;
height: $navbarHeight;
position: relative;
box-shadow: 0px 1px 2px 0 rgba(34, 36, 38, 0.15);
@@ -17,4 +16,4 @@
border-left: none;
border-right: none;
}
}
}
1 change: 0 additions & 1 deletion ui/src/app/shared/button/upload/upload.button.scss
Original file line number Diff line number Diff line change
@@ -4,5 +4,4 @@
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
Loading