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
9f9ae8da
Commit
9f9ae8da
authored
Feb 06, 2020
by
Zack Cuddy
Committed by
Martin Wortschack
Feb 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace Geo notice with Toast in Vue
Update Designs Update Nodes Node toast Lint and node test Fix tsts
parent
d56cf9ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
22 deletions
+42
-22
ee/app/assets/javascripts/geo_designs/store/actions.js
ee/app/assets/javascripts/geo_designs/store/actions.js
+7
-4
ee/app/assets/javascripts/geo_nodes/components/app.vue
ee/app/assets/javascripts/geo_nodes/components/app.vue
+2
-2
ee/app/assets/javascripts/geo_nodes/index.js
ee/app/assets/javascripts/geo_nodes/index.js
+2
-0
ee/spec/frontend/geo_designs/store/actions_spec.js
ee/spec/frontend/geo_designs/store/actions_spec.js
+19
-8
ee/spec/frontend/geo_nodes/components/app_spec.js
ee/spec/frontend/geo_nodes/components/app_spec.js
+12
-8
No files found.
ee/app/assets/javascripts/geo_designs/store/actions.js
View file @
9f9ae8da
import
Api
from
'
ee/api
'
;
import
createFlash
from
'
~/flash
'
;
import
toast
from
'
~/vue_shared/plugins/global_toast
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
parseIntPagination
,
...
...
@@ -50,7 +51,8 @@ export const fetchDesigns = ({ state, dispatch }) => {
// Initiate All Design Syncs
export
const
requestInitiateAllDesignSyncs
=
({
commit
})
=>
commit
(
types
.
REQUEST_INITIATE_ALL_DESIGN_SYNCS
);
export
const
receiveInitiateAllDesignSyncsSuccess
=
({
commit
,
dispatch
})
=>
{
export
const
receiveInitiateAllDesignSyncsSuccess
=
({
commit
,
dispatch
},
{
action
})
=>
{
toast
(
__
(
`All designs are being scheduled for
${
action
}
`
));
commit
(
types
.
RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS
);
dispatch
(
'
fetchDesigns
'
);
};
...
...
@@ -63,7 +65,7 @@ export const initiateAllDesignSyncs = ({ dispatch }, action) => {
dispatch
(
'
requestInitiateAllDesignSyncs
'
);
Api
.
initiateAllGeoDesignSyncs
(
action
)
.
then
(()
=>
dispatch
(
'
receiveInitiateAllDesignSyncsSuccess
'
))
.
then
(()
=>
dispatch
(
'
receiveInitiateAllDesignSyncsSuccess
'
,
{
action
}
))
.
catch
(()
=>
{
dispatch
(
'
receiveInitiateAllDesignSyncsError
'
);
});
...
...
@@ -71,7 +73,8 @@ export const initiateAllDesignSyncs = ({ dispatch }, action) => {
// Initiate Design Sync
export
const
requestInitiateDesignSync
=
({
commit
})
=>
commit
(
types
.
REQUEST_INITIATE_DESIGN_SYNC
);
export
const
receiveInitiateDesignSyncSuccess
=
({
commit
,
dispatch
})
=>
{
export
const
receiveInitiateDesignSyncSuccess
=
({
commit
,
dispatch
},
{
name
,
action
})
=>
{
toast
(
__
(
`
${
name
}
is scheduled for
${
action
}
`
));
commit
(
types
.
RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS
);
dispatch
(
'
fetchDesigns
'
);
};
...
...
@@ -84,7 +87,7 @@ export const initiateDesignSync = ({ dispatch }, { projectId, name, action }) =>
dispatch
(
'
requestInitiateDesignSync
'
);
Api
.
initiateGeoDesignSync
({
projectId
,
action
})
.
then
(()
=>
dispatch
(
'
receiveInitiateDesignSyncSuccess
'
))
.
then
(()
=>
dispatch
(
'
receiveInitiateDesignSyncSuccess
'
,
{
name
,
action
}
))
.
catch
(()
=>
{
dispatch
(
'
receiveInitiateDesignSyncError
'
,
{
name
});
});
...
...
ee/app/assets/javascripts/geo_nodes/components/app.vue
View file @
9f9ae8da
...
...
@@ -131,7 +131,7 @@ export default {
.
repairNode
(
targetNode
)
.
then
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
Flash
(
s__
(
'
GeoNodes|Node Authentication was successfully repaired.
'
),
'
notice
'
);
this
.
$toast
.
show
(
s__
(
'
GeoNodes|Node Authentication was successfully repaired.
'
)
);
})
.
catch
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
...
...
@@ -160,7 +160,7 @@ export default {
.
removeNode
(
targetNode
)
.
then
(()
=>
{
this
.
store
.
removeNode
(
targetNode
);
Flash
(
s__
(
'
GeoNodes|Node was successfully removed.
'
),
'
notice
'
);
this
.
$toast
.
show
(
s__
(
'
GeoNodes|Node was successfully removed.
'
)
);
})
.
catch
(()
=>
{
this
.
setNodeActionStatus
(
targetNode
,
false
);
...
...
ee/app/assets/javascripts/geo_nodes/index.js
View file @
9f9ae8da
import
Vue
from
'
vue
'
;
import
{
GlToast
}
from
'
@gitlab/ui
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
...
...
@@ -9,6 +10,7 @@ import GeoNodesService from './service/geo_nodes_service';
import
geoNodesApp
from
'
./components/app.vue
'
;
Vue
.
use
(
Translate
);
Vue
.
use
(
GlToast
);
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
js-geo-nodes
'
);
...
...
ee/spec/frontend/geo_designs/store/actions_spec.js
View file @
9f9ae8da
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
flash
from
'
~/flash
'
;
import
toast
from
'
~/vue_shared/plugins/global_toast
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
*
as
actions
from
'
ee/geo_designs/store/actions
'
;
import
*
as
types
from
'
ee/geo_designs/store/mutation_types
'
;
...
...
@@ -13,6 +14,7 @@ import {
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/vue_shared/plugins/global_toast
'
);
describe
(
'
GeoDesigns Store Actions
'
,
()
=>
{
let
state
;
...
...
@@ -182,14 +184,17 @@ describe('GeoDesigns Store Actions', () => {
});
describe
(
'
receiveInitiateAllDesignSyncsSuccess
'
,
()
=>
{
it
(
'
should commit mutation RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS and
fetchDesigns
'
,
done
=>
{
it
(
'
should commit mutation RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS and
call fetchDesigns and toast
'
,
()
=>
{
testAction
(
actions
.
receiveInitiateAllDesignSyncsSuccess
,
null
,
{
action
:
ACTION_TYPES
.
RESYNC
}
,
state
,
[{
type
:
types
.
RECEIVE_INITIATE_ALL_DESIGN_SYNCS_SUCCESS
}],
[{
type
:
'
fetchDesigns
'
}],
done
,
()
=>
{
expect
(
toast
).
toHaveBeenCalledTimes
(
1
);
toast
.
mockClear
();
},
);
});
});
...
...
@@ -228,7 +233,7 @@ describe('GeoDesigns Store Actions', () => {
[],
[
{
type
:
'
requestInitiateAllDesignSyncs
'
},
{
type
:
'
receiveInitiateAllDesignSyncsSuccess
'
},
{
type
:
'
receiveInitiateAllDesignSyncsSuccess
'
,
payload
:
{
action
}
},
],
done
,
);
...
...
@@ -272,14 +277,17 @@ describe('GeoDesigns Store Actions', () => {
});
describe
(
'
receiveInitiateDesignSyncSuccess
'
,
()
=>
{
it
(
'
should commit mutation RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS and
fetchDesigns
'
,
done
=>
{
it
(
'
should commit mutation RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS and
call fetchDesigns and toast
'
,
()
=>
{
testAction
(
actions
.
receiveInitiateDesignSyncSuccess
,
null
,
{
action
:
ACTION_TYPES
.
RESYNC
,
projectName
:
'
test
'
}
,
state
,
[{
type
:
types
.
RECEIVE_INITIATE_DESIGN_SYNC_SUCCESS
}],
[{
type
:
'
fetchDesigns
'
}],
done
,
()
=>
{
expect
(
toast
).
toHaveBeenCalledTimes
(
1
);
toast
.
mockClear
();
},
);
});
});
...
...
@@ -320,7 +328,10 @@ describe('GeoDesigns Store Actions', () => {
{
projectId
,
name
,
action
},
state
,
[],
[{
type
:
'
requestInitiateDesignSync
'
},
{
type
:
'
receiveInitiateDesignSyncSuccess
'
}],
[
{
type
:
'
requestInitiateDesignSync
'
},
{
type
:
'
receiveInitiateDesignSyncSuccess
'
,
payload
:
{
name
,
action
}
},
],
done
,
);
});
...
...
ee/spec/frontend/geo_nodes/components/app_spec.js
View file @
9f9ae8da
...
...
@@ -8,6 +8,8 @@ import GeoNodesService from 'ee/geo_nodes/service/geo_nodes_service';
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
NODE_ACTIONS
}
from
'
ee/geo_nodes/constants
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
'
~/vue_shared/plugins/global_toast
'
;
import
{
PRIMARY_VERSION
,
NODE_DETAILS_PATH
,
...
...
@@ -33,6 +35,9 @@ const createComponent = () => {
});
};
const
getToastMessage
=
()
=>
document
.
querySelector
(
'
.gl-toast
'
).
innerText
.
trim
();
const
cleanupToastMessage
=
()
=>
document
.
querySelector
(
'
.gl-toast
'
).
remove
();
describe
(
'
AppComponent
'
,
()
=>
{
let
vm
;
let
mock
;
...
...
@@ -46,6 +51,7 @@ describe('AppComponent', () => {
mock
=
new
MockAdapter
(
axios
);
document
.
body
.
innerHTML
+=
'
<div class="flash-container"></div>
'
;
mock
.
onGet
(
/
(
.*
)\/
geo_nodes$/
).
reply
(()
=>
[
statusCode
,
response
]);
vm
=
createComponent
();
});
...
...
@@ -193,7 +199,7 @@ describe('AppComponent', () => {
});
describe
(
'
repairNode
'
,
()
=>
{
it
(
'
calls service.repairNode and shows success
Flash
message on request success
'
,
done
=>
{
it
(
'
calls service.repairNode and shows success
Toast
message on request success
'
,
done
=>
{
const
node
=
{
...
mockNode
};
mock
.
onPost
(
node
.
repairPath
).
reply
(()
=>
{
expect
(
node
.
nodeActionActive
).
toBe
(
true
);
...
...
@@ -204,9 +210,8 @@ describe('AppComponent', () => {
vm
.
repairNode
(
node
)
.
then
(()
=>
{
expect
(
vm
.
service
.
repairNode
).
toHaveBeenCalledWith
(
node
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
innerText
.
trim
()).
toBe
(
'
Node Authentication was successfully repaired.
'
,
);
expect
(
getToastMessage
()).
toBe
(
'
Node Authentication was successfully repaired.
'
);
cleanupToastMessage
();
expect
(
node
.
nodeActionActive
).
toBe
(
false
);
})
...
...
@@ -285,7 +290,7 @@ describe('AppComponent', () => {
});
describe
(
'
removeNode
'
,
()
=>
{
it
(
'
calls service.removeNode for removing node and shows
Flash
message on request success
'
,
done
=>
{
it
(
'
calls service.removeNode for removing node and shows
Toast
message on request success
'
,
done
=>
{
const
node
=
{
...
mockNode
};
mock
.
onDelete
(
node
.
basePath
).
reply
(()
=>
{
expect
(
node
.
nodeActionActive
).
toBe
(
true
);
...
...
@@ -298,9 +303,8 @@ describe('AppComponent', () => {
.
then
(()
=>
{
expect
(
vm
.
service
.
removeNode
).
toHaveBeenCalledWith
(
node
);
expect
(
vm
.
store
.
removeNode
).
toHaveBeenCalledWith
(
node
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
innerText
.
trim
()).
toBe
(
'
Node was successfully removed.
'
,
);
expect
(
getToastMessage
()).
toBe
(
'
Node was successfully removed.
'
);
cleanupToastMessage
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
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