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
38f872fe
Commit
38f872fe
authored
Oct 01, 2020
by
Nicolò Maria Mezzopera
Committed by
Natalia Tepluhina
Oct 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove vuex store and tests
- store files - tests
parent
04ddebf3
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
0 additions
and
395 deletions
+0
-395
app/assets/javascripts/registry/settings/registry_settings_bundle.js
...javascripts/registry/settings/registry_settings_bundle.js
+0
-3
app/assets/javascripts/registry/settings/store/actions.js
app/assets/javascripts/registry/settings/store/actions.js
+0
-30
app/assets/javascripts/registry/settings/store/getters.js
app/assets/javascripts/registry/settings/store/getters.js
+0
-26
app/assets/javascripts/registry/settings/store/index.js
app/assets/javascripts/registry/settings/store/index.js
+0
-18
app/assets/javascripts/registry/settings/store/mutation_types.js
...ets/javascripts/registry/settings/store/mutation_types.js
+0
-5
app/assets/javascripts/registry/settings/store/mutations.js
app/assets/javascripts/registry/settings/store/mutations.js
+0
-29
app/assets/javascripts/registry/settings/store/state.js
app/assets/javascripts/registry/settings/store/state.js
+0
-42
spec/frontend/registry/settings/store/actions_spec.js
spec/frontend/registry/settings/store/actions_spec.js
+0
-90
spec/frontend/registry/settings/store/getters_spec.js
spec/frontend/registry/settings/store/getters_spec.js
+0
-72
spec/frontend/registry/settings/store/mutations_spec.js
spec/frontend/registry/settings/store/mutations_spec.js
+0
-80
No files found.
app/assets/javascripts/registry/settings/registry_settings_bundle.js
View file @
38f872fe
import
Vue
from
'
vue
'
;
import
{
GlToast
}
from
'
@gitlab/ui
'
;
import
Translate
from
'
~/vue_shared/translate
'
;
import
store
from
'
./store
'
;
import
RegistrySettingsApp
from
'
./components/registry_settings_app.vue
'
;
import
{
apolloProvider
}
from
'
./graphql/index
'
;
...
...
@@ -13,11 +12,9 @@ export default () => {
if
(
!
el
)
{
return
null
;
}
store
.
dispatch
(
'
setInitialState
'
,
el
.
dataset
);
const
{
projectPath
,
isAdmin
,
adminSettingsPath
,
enableHistoricEntries
}
=
el
.
dataset
;
return
new
Vue
({
el
,
store
,
apolloProvider
,
components
:
{
RegistrySettingsApp
,
...
...
app/assets/javascripts/registry/settings/store/actions.js
deleted
100644 → 0
View file @
04ddebf3
import
Api
from
'
~/api
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
const
setInitialState
=
({
commit
},
data
)
=>
commit
(
types
.
SET_INITIAL_STATE
,
data
);
export
const
updateSettings
=
({
commit
},
data
)
=>
commit
(
types
.
UPDATE_SETTINGS
,
data
);
export
const
toggleLoading
=
({
commit
})
=>
commit
(
types
.
TOGGLE_LOADING
);
export
const
receiveSettingsSuccess
=
({
commit
},
data
)
=>
{
commit
(
types
.
SET_SETTINGS
,
data
);
};
export
const
resetSettings
=
({
commit
})
=>
commit
(
types
.
RESET_SETTINGS
);
export
const
fetchSettings
=
({
dispatch
,
state
})
=>
{
dispatch
(
'
toggleLoading
'
);
return
Api
.
project
(
state
.
projectId
)
.
then
(({
data
:
{
container_expiration_policy
}
})
=>
dispatch
(
'
receiveSettingsSuccess
'
,
container_expiration_policy
),
)
.
finally
(()
=>
dispatch
(
'
toggleLoading
'
));
};
export
const
saveSettings
=
({
dispatch
,
state
})
=>
{
dispatch
(
'
toggleLoading
'
);
return
Api
.
updateProject
(
state
.
projectId
,
{
container_expiration_policy_attributes
:
state
.
settings
,
})
.
then
(({
data
:
{
container_expiration_policy
}
})
=>
dispatch
(
'
receiveSettingsSuccess
'
,
container_expiration_policy
),
)
.
finally
(()
=>
dispatch
(
'
toggleLoading
'
));
};
app/assets/javascripts/registry/settings/store/getters.js
deleted
100644 → 0
View file @
04ddebf3
import
{
isEqual
}
from
'
lodash
'
;
import
{
findDefaultOption
}
from
'
../../shared/utils
'
;
export
const
getCadence
=
state
=>
state
.
settings
.
cadence
||
findDefaultOption
(
state
.
formOptions
.
cadence
);
export
const
getKeepN
=
state
=>
state
.
settings
.
keep_n
||
findDefaultOption
(
state
.
formOptions
.
keepN
);
export
const
getOlderThan
=
state
=>
state
.
settings
.
older_than
||
findDefaultOption
(
state
.
formOptions
.
olderThan
);
export
const
getSettings
=
(
state
,
getters
)
=>
({
enabled
:
state
.
settings
.
enabled
,
cadence
:
getters
.
getCadence
,
older_than
:
getters
.
getOlderThan
,
keep_n
:
getters
.
getKeepN
,
name_regex
:
state
.
settings
.
name_regex
,
name_regex_keep
:
state
.
settings
.
name_regex_keep
,
});
export
const
getIsEdited
=
state
=>
!
isEqual
(
state
.
original
,
state
.
settings
);
export
const
getIsDisabled
=
state
=>
{
return
!
(
state
.
original
||
state
.
enableHistoricEntries
);
};
app/assets/javascripts/registry/settings/store/index.js
deleted
100644 → 0
View file @
04ddebf3
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
*
as
actions
from
'
./actions
'
;
import
mutations
from
'
./mutations
'
;
import
*
as
getters
from
'
./getters
'
;
import
state
from
'
./state
'
;
Vue
.
use
(
Vuex
);
export
const
createStore
=
()
=>
new
Vuex
.
Store
({
state
,
actions
,
mutations
,
getters
,
});
export
default
createStore
();
app/assets/javascripts/registry/settings/store/mutation_types.js
deleted
100644 → 0
View file @
04ddebf3
export
const
SET_INITIAL_STATE
=
'
SET_INITIAL_STATE
'
;
export
const
UPDATE_SETTINGS
=
'
UPDATE_SETTINGS
'
;
export
const
TOGGLE_LOADING
=
'
TOGGLE_LOADING
'
;
export
const
SET_SETTINGS
=
'
SET_SETTINGS
'
;
export
const
RESET_SETTINGS
=
'
RESET_SETTINGS
'
;
app/assets/javascripts/registry/settings/store/mutations.js
deleted
100644 → 0
View file @
04ddebf3
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
default
{
[
types
.
SET_INITIAL_STATE
](
state
,
initialState
)
{
state
.
projectId
=
initialState
.
projectId
;
state
.
formOptions
=
{
cadence
:
JSON
.
parse
(
initialState
.
cadenceOptions
),
keepN
:
JSON
.
parse
(
initialState
.
keepNOptions
),
olderThan
:
JSON
.
parse
(
initialState
.
olderThanOptions
),
};
state
.
enableHistoricEntries
=
parseBoolean
(
initialState
.
enableHistoricEntries
);
state
.
isAdmin
=
parseBoolean
(
initialState
.
isAdmin
);
state
.
adminSettingsPath
=
initialState
.
adminSettingsPath
;
},
[
types
.
UPDATE_SETTINGS
](
state
,
data
)
{
state
.
settings
=
{
...
state
.
settings
,
...
data
.
settings
};
},
[
types
.
SET_SETTINGS
](
state
,
settings
)
{
state
.
settings
=
settings
??
state
.
settings
;
state
.
original
=
Object
.
freeze
(
settings
);
},
[
types
.
RESET_SETTINGS
](
state
)
{
state
.
settings
=
{
...
state
.
original
};
},
[
types
.
TOGGLE_LOADING
](
state
)
{
state
.
isLoading
=
!
state
.
isLoading
;
},
};
app/assets/javascripts/registry/settings/store/state.js
deleted
100644 → 0
View file @
04ddebf3
export
default
()
=>
({
/*
* Project Id used to build the API call
*/
projectId
:
''
,
/*
* Boolean to determine if the UI is loading data from the API
*/
isLoading
:
false
,
/*
* Boolean to determine if the user is an admin
*/
isAdmin
:
false
,
/*
* String containing the full path to the admin config page for CI/CD
*/
adminSettingsPath
:
''
,
/*
* Boolean to determine if project created before 12.8 can use this feature
*/
enableHistoricEntries
:
false
,
/*
* This contains the data shown and manipulated in the UI
* Has the following structure:
* {
* enabled: Boolean
* cadence: String,
* older_than: String,
* keep_n: String,
* name_regex: String
* }
*/
settings
:
{},
/*
* Same structure as settings, above but Frozen object and used only in case the user clicks 'cancel', initialized to null
*/
original
:
null
,
/*
* Contains the options used to populate the form selects
*/
formOptions
:
{},
});
spec/frontend/registry/settings/store/actions_spec.js
deleted
100644 → 0
View file @
04ddebf3
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
Api
from
'
~/api
'
;
import
*
as
actions
from
'
~/registry/settings/store/actions
'
;
import
*
as
types
from
'
~/registry/settings/store/mutation_types
'
;
describe
(
'
Actions Registry Store
'
,
()
=>
{
describe
.
each
`
actionName | mutationName | payload
${
'
setInitialState
'
}
|
${
types
.
SET_INITIAL_STATE
}
|
${
'
foo
'
}
${
'
updateSettings
'
}
|
${
types
.
UPDATE_SETTINGS
}
|
${
'
foo
'
}
${
'
toggleLoading
'
}
|
${
types
.
TOGGLE_LOADING
}
|
${
undefined
}
${
'
resetSettings
'
}
|
${
types
.
RESET_SETTINGS
}
|
${
undefined
}
`
(
'
$actionName invokes $mutationName with payload $payload
'
,
({
actionName
,
mutationName
,
payload
})
=>
{
it
(
'
should set state
'
,
done
=>
{
testAction
(
actions
[
actionName
],
payload
,
{},
[{
type
:
mutationName
,
payload
}],
[],
done
);
});
},
);
describe
(
'
receiveSettingsSuccess
'
,
()
=>
{
it
(
'
calls SET_SETTINGS
'
,
()
=>
{
testAction
(
actions
.
receiveSettingsSuccess
,
'
foo
'
,
{},
[{
type
:
types
.
SET_SETTINGS
,
payload
:
'
foo
'
}],
[],
);
});
});
describe
(
'
fetchSettings
'
,
()
=>
{
const
state
=
{
projectId
:
'
bar
'
,
};
const
payload
=
{
data
:
{
container_expiration_policy
:
'
foo
'
,
},
};
it
(
'
should fetch the data from the API
'
,
done
=>
{
Api
.
project
=
jest
.
fn
().
mockResolvedValue
(
payload
);
testAction
(
actions
.
fetchSettings
,
null
,
state
,
[],
[
{
type
:
'
toggleLoading
'
},
{
type
:
'
receiveSettingsSuccess
'
,
payload
:
payload
.
data
.
container_expiration_policy
},
{
type
:
'
toggleLoading
'
},
],
done
,
);
});
});
describe
(
'
saveSettings
'
,
()
=>
{
const
state
=
{
projectId
:
'
bar
'
,
settings
:
'
baz
'
,
};
const
payload
=
{
data
:
{
tag_expiration_policies
:
'
foo
'
,
},
};
it
(
'
should fetch the data from the API
'
,
done
=>
{
Api
.
updateProject
=
jest
.
fn
().
mockResolvedValue
(
payload
);
testAction
(
actions
.
saveSettings
,
null
,
state
,
[],
[
{
type
:
'
toggleLoading
'
},
{
type
:
'
receiveSettingsSuccess
'
,
payload
:
payload
.
data
.
container_expiration_policy
},
{
type
:
'
toggleLoading
'
},
],
done
,
);
});
});
});
spec/frontend/registry/settings/store/getters_spec.js
deleted
100644 → 0
View file @
04ddebf3
import
*
as
getters
from
'
~/registry/settings/store/getters
'
;
import
*
as
utils
from
'
~/registry/shared/utils
'
;
import
{
formOptions
}
from
'
../../shared/mock_data
'
;
describe
(
'
Getters registry settings store
'
,
()
=>
{
const
settings
=
{
enabled
:
true
,
cadence
:
'
foo
'
,
keep_n
:
'
bar
'
,
older_than
:
'
baz
'
,
name_regex
:
'
name-foo
'
,
name_regex_keep
:
'
name-keep-bar
'
,
};
describe
.
each
`
getter | variable | formOption
${
'
getCadence
'
}
|
${
'
cadence
'
}
|
${
'
cadence
'
}
${
'
getKeepN
'
}
|
${
'
keep_n
'
}
|
${
'
keepN
'
}
${
'
getOlderThan
'
}
|
${
'
older_than
'
}
|
${
'
olderThan
'
}
`
(
'
Options getter
'
,
({
getter
,
variable
,
formOption
})
=>
{
beforeEach
(()
=>
{
utils
.
findDefaultOption
=
jest
.
fn
();
});
it
(
`
${
getter
}
returns
${
variable
}
when
${
variable
}
exists in settings`
,
()
=>
{
expect
(
getters
[
getter
]({
settings
})).
toBe
(
settings
[
variable
]);
});
it
(
`
${
getter
}
calls findDefaultOption when
${
variable
}
does not exists in settings`
,
()
=>
{
getters
[
getter
]({
settings
:
{},
formOptions
});
expect
(
utils
.
findDefaultOption
).
toHaveBeenCalledWith
(
formOptions
[
formOption
]);
});
});
describe
(
'
getSettings
'
,
()
=>
{
it
(
'
returns the content of settings
'
,
()
=>
{
const
computedGetters
=
{
getCadence
:
settings
.
cadence
,
getOlderThan
:
settings
.
older_than
,
getKeepN
:
settings
.
keep_n
,
};
expect
(
getters
.
getSettings
({
settings
},
computedGetters
)).
toEqual
(
settings
);
});
});
describe
(
'
getIsEdited
'
,
()
=>
{
it
(
'
returns false when original is equal to settings
'
,
()
=>
{
const
same
=
{
foo
:
'
bar
'
};
expect
(
getters
.
getIsEdited
({
original
:
same
,
settings
:
same
})).
toBe
(
false
);
});
it
(
'
returns true when original is different from settings
'
,
()
=>
{
expect
(
getters
.
getIsEdited
({
original
:
{
foo
:
'
bar
'
},
settings
:
{
foo
:
'
baz
'
}
})).
toBe
(
true
,
);
});
});
describe
(
'
getIsDisabled
'
,
()
=>
{
it
.
each
`
original | enableHistoricEntries | result
${
undefined
}
|
${
false
}
|
${
true
}
${{
foo
:
'
bar
'
}
} |
${
undefined
}
|
${
false
}
${{}}
|
$
{
false
}
|
${
false
}
`
(
'
returns $result when original is $original and enableHistoricEntries is $enableHistoricEntries
'
,
({
original
,
enableHistoricEntries
,
result
})
=>
{
expect
(
getters
.
getIsDisabled
({
original
,
enableHistoricEntries
})).
toBe
(
result
);
},
);
});
});
spec/frontend/registry/settings/store/mutations_spec.js
deleted
100644 → 0
View file @
04ddebf3
import
mutations
from
'
~/registry/settings/store/mutations
'
;
import
*
as
types
from
'
~/registry/settings/store/mutation_types
'
;
import
createState
from
'
~/registry/settings/store/state
'
;
import
{
formOptions
,
stringifiedFormOptions
}
from
'
../../shared/mock_data
'
;
describe
(
'
Mutations Registry Store
'
,
()
=>
{
let
mockState
;
beforeEach
(()
=>
{
mockState
=
createState
();
});
describe
(
'
SET_INITIAL_STATE
'
,
()
=>
{
it
(
'
should set the initial state
'
,
()
=>
{
const
payload
=
{
projectId
:
'
foo
'
,
enableHistoricEntries
:
false
,
adminSettingsPath
:
'
foo
'
,
isAdmin
:
true
,
};
const
expectedState
=
{
...
mockState
,
...
payload
,
formOptions
};
mutations
[
types
.
SET_INITIAL_STATE
](
mockState
,
{
...
payload
,
...
stringifiedFormOptions
,
});
expect
(
mockState
).
toEqual
(
expectedState
);
});
});
describe
(
'
UPDATE_SETTINGS
'
,
()
=>
{
it
(
'
should update the settings
'
,
()
=>
{
mockState
.
settings
=
{
foo
:
'
bar
'
};
const
payload
=
{
foo
:
'
baz
'
};
const
expectedState
=
{
...
mockState
,
settings
:
payload
};
mutations
[
types
.
UPDATE_SETTINGS
](
mockState
,
{
settings
:
payload
});
expect
(
mockState
.
settings
).
toEqual
(
expectedState
.
settings
);
});
});
describe
(
'
SET_SETTINGS
'
,
()
=>
{
it
(
'
should set the settings and original
'
,
()
=>
{
const
payload
=
{
foo
:
'
baz
'
};
const
expectedState
=
{
...
mockState
,
settings
:
payload
};
mutations
[
types
.
SET_SETTINGS
](
mockState
,
payload
);
expect
(
mockState
.
settings
).
toEqual
(
expectedState
.
settings
);
expect
(
mockState
.
original
).
toEqual
(
expectedState
.
settings
);
});
it
(
'
should keep the default state when settings is not present
'
,
()
=>
{
const
originalSettings
=
{
...
mockState
.
settings
};
mutations
[
types
.
SET_SETTINGS
](
mockState
);
expect
(
mockState
.
settings
).
toEqual
(
originalSettings
);
expect
(
mockState
.
original
).
toEqual
(
undefined
);
});
});
describe
(
'
RESET_SETTINGS
'
,
()
=>
{
it
(
'
should copy original over settings
'
,
()
=>
{
mockState
.
settings
=
{
foo
:
'
bar
'
};
mockState
.
original
=
{
foo
:
'
baz
'
};
mutations
[
types
.
RESET_SETTINGS
](
mockState
);
expect
(
mockState
.
settings
).
toEqual
(
mockState
.
original
);
});
it
(
'
if original is undefined it should initialize to empty object
'
,
()
=>
{
mockState
.
settings
=
{
foo
:
'
bar
'
};
mockState
.
original
=
undefined
;
mutations
[
types
.
RESET_SETTINGS
](
mockState
);
expect
(
mockState
.
settings
).
toEqual
({});
});
});
describe
(
'
TOGGLE_LOADING
'
,
()
=>
{
it
(
'
should toggle the loading
'
,
()
=>
{
mutations
[
types
.
TOGGLE_LOADING
](
mockState
);
expect
(
mockState
.
isLoading
).
toEqual
(
true
);
});
});
});
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