open-nomad/ui/mirage/utils.js

271 lines
8.0 KiB
JavaScript
Raw Normal View History

import faker from 'nomad-ui/mirage/faker';
2017-09-19 14:47:10 +00:00
export function provide(count, provider) {
if (typeof count === 'function') {
count = count();
}
Epic: Evaluation Detail Sidebar (#12370) * chore: prettify gutter-menu * chore: add portal packages * styling: add styles sidebar and portal behavior * ui: sidebar component * ui: create and implement statechart for evals * ui: actor-relationship service and provider component * ui: d3 hierarchy computation * chore: add render-modifiers and curved arrows * ui: create evaluation actor div * fix related evaluations schema * ui: register/deregister evaluation divs * ui: handle resize behavior * bug: infinite re-render cycle * fix: conditional logic to prevent infinite render of flex resizing * ui: related evaluations schema and request param * ui: fix testing for evaluations * refact: make related-evals a proper has-many * chore: don't pauseTest * temp: debug d3 hierarchy * ui: move derived state logic into backing component class for detail * ui: deprecated related evaluations logic in statechart * ui: update evaluation models * ui: update logic to paint svg in non-viewable scroll region * ui: update styling * ui: testing for eval detail view * ui: delete detail from template directory * ui: break detail component down * ui: static data for /evaluation/:id endpoint * ui: fix styling of d3 viz * ui: add query parameter adapter for evals * ui: last minute design requests * wip: address browser updating detail view behavior * refact: handle query-state change in statechart * conditional class looking for currentEval equality (#12411) * F UI/evaluation detail sidebar rel evals (#12415) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: bug fixes on related evaluations view (#12423) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: update error state * ui: related evaluation outline styling * Related evaluation stylefile and non-link if it matches the active sidebar (#12428) * Adds tabbable and keyboard pressable evaluation table rows (#12433) * ui: fix failing eval list tests (#12437) * ui: move styling into classes (#12438) * fix test failures (#12444) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: fix evaluation refresh button (#12447) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: refresh bug * ui: final touches on sidebar (#12462) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * Modification to mocked related evals and manually set 100% height on svg (#12460) * F UI/evaluation detail sidebar final touches (#12463) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * ui: account for new related eval added to chain Co-authored-by: Michael Klein <michael@firstiwaslike.com> Co-authored-by: Phil Renaud <phil@riotindustries.com>
2022-04-05 18:34:37 +00:00
return Array(count).fill(null).map(provider);
2017-09-19 14:47:10 +00:00
}
export function provider() {
return () => provide(...arguments);
}
export function pickOne(list) {
return list[faker.random.number(list.length - 1)];
}
export function arrToObj(prop, alias = '') {
return (obj, element) => {
const name = element[prop];
delete element[prop];
obj[name] = alias ? element[alias] : element;
return obj;
};
}
Epic: Evaluation Detail Sidebar (#12370) * chore: prettify gutter-menu * chore: add portal packages * styling: add styles sidebar and portal behavior * ui: sidebar component * ui: create and implement statechart for evals * ui: actor-relationship service and provider component * ui: d3 hierarchy computation * chore: add render-modifiers and curved arrows * ui: create evaluation actor div * fix related evaluations schema * ui: register/deregister evaluation divs * ui: handle resize behavior * bug: infinite re-render cycle * fix: conditional logic to prevent infinite render of flex resizing * ui: related evaluations schema and request param * ui: fix testing for evaluations * refact: make related-evals a proper has-many * chore: don't pauseTest * temp: debug d3 hierarchy * ui: move derived state logic into backing component class for detail * ui: deprecated related evaluations logic in statechart * ui: update evaluation models * ui: update logic to paint svg in non-viewable scroll region * ui: update styling * ui: testing for eval detail view * ui: delete detail from template directory * ui: break detail component down * ui: static data for /evaluation/:id endpoint * ui: fix styling of d3 viz * ui: add query parameter adapter for evals * ui: last minute design requests * wip: address browser updating detail view behavior * refact: handle query-state change in statechart * conditional class looking for currentEval equality (#12411) * F UI/evaluation detail sidebar rel evals (#12415) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: bug fixes on related evaluations view (#12423) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: update error state * ui: related evaluation outline styling * Related evaluation stylefile and non-link if it matches the active sidebar (#12428) * Adds tabbable and keyboard pressable evaluation table rows (#12433) * ui: fix failing eval list tests (#12437) * ui: move styling into classes (#12438) * fix test failures (#12444) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: fix evaluation refresh button (#12447) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: refresh bug * ui: final touches on sidebar (#12462) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * Modification to mocked related evals and manually set 100% height on svg (#12460) * F UI/evaluation detail sidebar final touches (#12463) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * ui: account for new related eval added to chain Co-authored-by: Michael Klein <michael@firstiwaslike.com> Co-authored-by: Phil Renaud <phil@riotindustries.com>
2022-04-05 18:34:37 +00:00
export const generateAcceptanceTestEvalMock = (id) => {
Epic: Evaluation Detail Sidebar (#12370) * chore: prettify gutter-menu * chore: add portal packages * styling: add styles sidebar and portal behavior * ui: sidebar component * ui: create and implement statechart for evals * ui: actor-relationship service and provider component * ui: d3 hierarchy computation * chore: add render-modifiers and curved arrows * ui: create evaluation actor div * fix related evaluations schema * ui: register/deregister evaluation divs * ui: handle resize behavior * bug: infinite re-render cycle * fix: conditional logic to prevent infinite render of flex resizing * ui: related evaluations schema and request param * ui: fix testing for evaluations * refact: make related-evals a proper has-many * chore: don't pauseTest * temp: debug d3 hierarchy * ui: move derived state logic into backing component class for detail * ui: deprecated related evaluations logic in statechart * ui: update evaluation models * ui: update logic to paint svg in non-viewable scroll region * ui: update styling * ui: testing for eval detail view * ui: delete detail from template directory * ui: break detail component down * ui: static data for /evaluation/:id endpoint * ui: fix styling of d3 viz * ui: add query parameter adapter for evals * ui: last minute design requests * wip: address browser updating detail view behavior * refact: handle query-state change in statechart * conditional class looking for currentEval equality (#12411) * F UI/evaluation detail sidebar rel evals (#12415) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: bug fixes on related evaluations view (#12423) * ui: remove busy id alias from statechart * ui: edit related evaluations viz error message * ui: update error state * ui: related evaluation outline styling * Related evaluation stylefile and non-link if it matches the active sidebar (#12428) * Adds tabbable and keyboard pressable evaluation table rows (#12433) * ui: fix failing eval list tests (#12437) * ui: move styling into classes (#12438) * fix test failures (#12444) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: fix evaluation refresh button (#12447) * ui: move styling into classes * ui: eslint disable * ui: allocations have evaluations as async relationships * ui: refresh bug * ui: final touches on sidebar (#12462) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * Modification to mocked related evals and manually set 100% height on svg (#12460) * F UI/evaluation detail sidebar final touches (#12463) * chore: turn off template linting rules Temporarily turning off template linting because we dont have a set CSS convention and the release needs to go out ASAP. * doc: deprecate out of date comments and vars * ui: edit mirage server fetch logic * ui: style sidebar relative * ui: account for new related eval added to chain Co-authored-by: Michael Klein <michael@firstiwaslike.com> Co-authored-by: Phil Renaud <phil@riotindustries.com>
2022-04-05 18:34:37 +00:00
return {
CreateIndex: 20,
CreateTime: 1647899150314738000,
ID: id,
JobID: 'example',
JobModifyIndex: 10,
ModifyIndex: 31,
ModifyTime: 1647899318007569000,
Namespace: 'default',
NextEval: 'fd1cd898-d655-c7e4-17f6-a1a2e98b18ef',
PreviousEval: 'd8a5c14f-120a-3d83-6305-90927356dd6c',
Priority: 50,
RelatedEvals: [
{
BlockedEval: '',
CreateIndex: 31,
CreateTime: 1647899318007563000,
DeploymentID: '',
ID: 'fd1cd898-d655-c7e4-17f6-a1a2e98b18ef',
JobID: 'example',
ModifyIndex: 44,
ModifyTime: 1647899591412413000,
Namespace: 'default',
NextEval: 'cac7dfa0-b79b-ee55-c86a-0ca89dffb9e1',
NodeID: '',
PreviousEval: id,
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 31,
CreateTime: 1647899318007563000,
DeploymentID: '',
ID: 'fd1cd898-d655-c7e4-17f6-a1a2e98b18ef-deux',
JobID: 'example',
ModifyIndex: 44,
ModifyTime: 1647899591412413000,
Namespace: 'default',
NextEval: 'cac7dfa0-b79b-ee55-c86a-0ca89dffb9e1',
NodeID: '',
PreviousEval: id,
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 10,
CreateTime: 1647899129298997000,
DeploymentID: '',
ID: 'd8a5c14f-120a-3d83-6305-90927356dd6c',
JobID: 'example',
ModifyIndex: 20,
ModifyTime: 1647899150314745000,
Namespace: 'default',
NextEval: id,
NodeID: '',
PreviousEval: '',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'job-register',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 44,
CreateTime: 1647899591412410000,
DeploymentID: '',
ID: 'cac7dfa0-b79b-ee55-c86a-0ca89dffb9e1',
JobID: 'example',
ModifyIndex: 53,
ModifyTime: 1647899729480596000,
Namespace: 'default',
NextEval: 'e49bf53c-da6a-c869-8317-f2089682f503',
NodeID: '',
PreviousEval: 'fd1cd898-d655-c7e4-17f6-a1a2e98b18ef',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 53,
CreateTime: 1647899729480592000,
DeploymentID: '',
ID: 'e49bf53c-da6a-c869-8317-f2089682f503',
JobID: 'example',
ModifyIndex: 64,
ModifyTime: 1647899881302731000,
Namespace: 'default',
NextEval: 'a8d29cfc-517c-2e4c-9722-b47e84152c64',
NodeID: '',
PreviousEval: 'cac7dfa0-b79b-ee55-c86a-0ca89dffb9e1',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 64,
CreateTime: 1647899881302723000,
DeploymentID: '',
ID: 'a8d29cfc-517c-2e4c-9722-b47e84152c64',
JobID: 'example',
ModifyIndex: 81,
ModifyTime: 1647900212725381000,
Namespace: 'default',
NextEval: 'b37d06e4-4eb4-b29d-3b4a-b0c7bf2528ad',
NodeID: '',
PreviousEval: 'e49bf53c-da6a-c869-8317-f2089682f503',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 81,
CreateTime: 1647900212725376000,
DeploymentID: '',
ID: 'b37d06e4-4eb4-b29d-3b4a-b0c7bf2528ad',
JobID: 'example',
ModifyIndex: 97,
ModifyTime: 1647900516944239000,
Namespace: 'default',
NextEval: 'd7c50aa5-5bf1-5119-d7e7-0d0ae5381856',
NodeID: '',
PreviousEval: 'a8d29cfc-517c-2e4c-9722-b47e84152c64',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 97,
CreateTime: 1647900516944236000,
DeploymentID: '',
ID: 'd7c50aa5-5bf1-5119-d7e7-0d0ae5381856',
JobID: 'example',
ModifyIndex: 114,
ModifyTime: 1647900825385587000,
Namespace: 'default',
NextEval: 'ea2239aa-26d6-8874-8c56-e1600585772b',
NodeID: '',
PreviousEval: 'b37d06e4-4eb4-b29d-3b4a-b0c7bf2528ad',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 114,
CreateTime: 1647900825385584000,
DeploymentID: '',
ID: 'ea2239aa-26d6-8874-8c56-e1600585772b',
JobID: 'example',
ModifyIndex: 128,
ModifyTime: 1647900979511304000,
Namespace: 'default',
NextEval: '25a2dd19-8d22-d1dd-280a-79860c9b8bdb',
NodeID: '',
PreviousEval: 'd7c50aa5-5bf1-5119-d7e7-0d0ae5381856',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 128,
CreateTime: 1647900979511301000,
DeploymentID: '',
ID: '25a2dd19-8d22-d1dd-280a-79860c9b8bdb',
JobID: 'example',
ModifyIndex: 136,
ModifyTime: 1647901211369652000,
Namespace: 'default',
NextEval: '1fded690-20ad-6afa-3b89-59e319dfce18',
NodeID: '',
PreviousEval: 'ea2239aa-26d6-8874-8c56-e1600585772b',
Priority: 50,
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
{
BlockedEval: '',
CreateIndex: 136,
CreateTime: 1647901211369648000,
DeploymentID: '',
ID: '1fded690-20ad-6afa-3b89-59e319dfce18',
JobID: 'example',
ModifyIndex: 136,
ModifyTime: 1647901211369648000,
Namespace: 'default',
NextEval: '',
NodeID: '',
PreviousEval: '25a2dd19-8d22-d1dd-280a-79860c9b8bdb',
Priority: 50,
Status: 'pending',
StatusDescription: '',
TriggeredBy: 'failed-follow-up',
Type: 'service',
WaitUntil: null,
},
],
Status: 'failed',
StatusDescription: 'evaluation reached delivery limit (3)',
TriggeredBy: 'failed-follow-up',
Type: 'service',
Wait: 20000000000,
};
};