Commit Graph

45 Commits

Author SHA1 Message Date
GitLab Bot 5b98c2c506 Add latest changes from gitlab-org/gitlab@master 2022-12-09 12:08:19 +00:00
GitLab Bot 6170bdc060 Add latest changes from gitlab-org/gitlab@master 2022-08-31 09:13:12 +00:00
GitLab Bot b420660ef1 Add latest changes from gitlab-org/gitlab@master 2022-07-28 18:09:03 +00:00
GitLab Bot b267f3a3ac Add latest changes from gitlab-org/gitlab@master 2021-10-28 18:14:18 +00:00
GitLab Bot ed01bf9b25 Add latest changes from gitlab-org/gitlab@master 2021-08-13 03:10:09 +00:00
GitLab Bot fdb953945d Add latest changes from gitlab-org/gitlab@master 2021-03-05 12:08:55 +00:00
GitLab Bot 6965dc27dc Add latest changes from gitlab-org/gitlab@master 2021-01-12 03:10:47 +00:00
GitLab Bot f569792df8 Add latest changes from gitlab-org/gitlab@master 2020-04-27 18:09:41 +00:00
GitLab Bot 5bd24a54ef Add latest changes from gitlab-org/gitlab@master 2019-12-17 09:07:48 +00:00
GitLab Bot 7cdd70dcec Add latest changes from gitlab-org/gitlab@master 2019-11-28 15:06:57 +00:00
Stan Hu dcba5279b6 Fix inability to set visibility_level on project via API
Consider the scenario:

1. The default visibility level is set to internal
2. A user attempts to create a private project within a private group

Previously this would always fail because default_value_for would
overwrite the private visibility setting, no matter what
visibility_level were specified. This was happening because
default_value_for was confused by the default value of 0 specified by
the database schema.

default_value_for attempts to assign the default value in the block by
checking whether the attribute has changed. The problem is that since
the default value by the database was 0, and the user requested 0, this
appeared as though no changes were made. As a result, default_value_for
would always overwrite the user's preference.

To fix this, we remove the use of default_value_for and only set the
visibility level to the default application setting when no preference
has been given at creation time.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/63158
2019-06-14 07:36:35 -07:00
Sara Ahbabou dc00fa90e9 Squashed commits and modified visibility level output
Added changelog and rebased
2019-04-12 05:00:50 +00:00
gfyoung c858f70d07 Enable frozen string for lib/gitlab/*.rb 2018-10-22 07:00:50 +00:00
Douwe Maan cd5d75c362 Merge branch 'bvl-fix-500-on-fork-without-restricted-visibility-levels' into 'master'
Avoid error when creating forks and restricted levels are defined

Closes #42607

See merge request gitlab-org/gitlab-ce!16881
2018-02-02 19:12:55 +00:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Bob Van Landuyt 948150f050 Avoid error when no restricted levels are defined
When no visibility levels are defined they could sometimes return
`nil` instead of an empty array. In this case we want to allow all
levels.
2018-02-02 13:17:32 +01:00
Bob Van Landuyt 0618487906 Forking a project to a namespace with lower visibility.
In this case the project will get the minimum between both
visibilities.

If that visibility is restricted, then a lower level will be picked.
2017-12-29 11:15:26 +01:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Ruben Davila 2f6d02c4ee Always return the translated level name.
There are many places that expect the `.level_name` method to return the
translated level name.
2017-07-13 12:11:09 -05:00
Toon Claes b90f1098cf Add User#full_private_access? to check if user has Private access
In CE only the admin has access to all private groups & projects. In EE also an
auditor can have full private access.

To overcome merge conflicts, or accidental incorrect access rights, abstract
this out in `User#full_private_access?`.

`User#admin?` now only should be used for admin-only features. For private
access-related features `User#full_private_access?` should be used.

Backported from gitlab-org/gitlab-ee!2199
2017-06-23 11:15:35 +02:00
Yorick Peterse d29347220c
Refactor ProjectsFinder#init_collection
This changes ProjectsFinder#init_collection so it no longer relies on a
UNION. For example, to get starred projects of a user we used to run:

    SELECT projects.*
    FROM projects
    WHERE projects.pending_delete = 'f'
    AND (
        projects.id IN (
            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            INNER JOIN project_authorizations
                ON projects.id = project_authorizations.project_id
            WHERE projects.pending_delete = 'f'
            AND project_authorizations.user_id = 1
            AND users_star_projects.user_id = 1

            UNION

            SELECT projects.id
            FROM projects
            INNER JOIN users_star_projects
                ON users_star_projects.project_id = projects.id
            WHERE projects.visibility_level IN (20, 10)
            AND users_star_projects.user_id = 1
        )
    )
    ORDER BY projects.id DESC;

With these changes the above query is turned into the following instead:

    SELECT projects.*
    FROM projects
    INNER JOIN users_star_projects
        ON users_star_projects.project_id = projects.id
    WHERE projects.pending_delete = 'f'
    AND (
        EXISTS (
            SELECT 1
            FROM project_authorizations
            WHERE project_authorizations.user_id = 1
            AND (project_id = projects.id)
        )
        OR projects.visibility_level IN (20,10)
    )
    AND users_star_projects.user_id = 1
    ORDER BY projects.id DESC;

This query in turn produces a better execution plan and takes less time,
though the difference is only a few milliseconds (this however depends
on the amount of data involved and additional conditions that may be
added).
2017-06-16 13:49:09 +02:00
Bob Van Landuyt bdebe849b8 Translate project & repository pages 2017-06-07 20:13:44 +00:00
Rémy Coutable 4cfa5ce4a9
Enable the Style/PreferredHashMethods cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:11:26 +02:00
blackst0ne 11aff97d88 Remove the User#is_admin? method 2017-04-09 13:20:57 +11:00
Toon Claes 71306f14f6 Make level_value accept string integers
When a VisibilityLevel is an integer formatted as a string, convert it
to an integer, instead of looking it up in the hash map.

When the value is not recognized, default to PRIVATE.
2017-03-20 22:53:29 +01:00
Toon Claes a3fdd6acd2 Use string based `visibility` getter & setter
Add `visibility` & `visibility=` methods to the
`Gitlab::VisibilityLevel` module so the `visibility_level` can be
get/set with a string value.
2017-03-02 12:15:25 +01:00
Toon Claes fc28719145 A VisibilityLevel also can be presented as string
For the API, the VisibilityLevel will be exposed as String instead of
Integer. So add the string values and method to translate a level
integer to a string.
2017-03-02 09:28:41 +01:00
Douwe Maan 75f5fa997d Enable Rails/Delegate 2017-02-23 09:32:42 -06:00
Douwe Maan ffcbc63693 List all groups/projects for admins on explore pages 2017-02-06 21:02:07 -06:00
Kamil Trzcinski b7f4553e3e
Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1083 2017-01-20 12:25:53 +01:00
Felipe Artur 5273335247 Fix forks creation when visibility level is restricted 2016-05-25 10:57:00 -04:00
Douwe Maan 45e8650c4f Fix specs 2016-03-20 23:26:58 +01:00
Douwe Maan 8db1292139 Tweaks, refactoring, and specs 2016-03-20 21:04:07 +01:00
Zeger-Jan van de Weg b959ae553b Improve group visibility level feature 2016-03-18 16:58:04 -03:00
Felipe Artur 0a7f716119 Code fixes 2016-03-17 19:42:46 -03:00
Felipe Artur c3e70280df Prevent projects to have higher visibility than groups
Prevent Groups to have smaller visibility than projects
Add default_group_visibility_level to configuration
Code improvements
2016-03-10 10:38:36 -03:00
Tomasz Maczukin 3bc012db77 Fix GitlabV::isibilityLevel::level_name method 2015-11-04 22:13:40 +01:00
Tomasz Maczukin 9e1db139eb Move level_name resolving to Gitlan::VisibilityLevel 2015-11-03 17:23:19 +01:00
Valery Sizov 111ebe5471 Fork visibility level fix 2015-07-06 17:40:33 +03:00
Marin Jankovski 63f7129483 Move application setting to separate variable. 2015-03-18 13:55:41 -07:00
Vinnie Okada e535d21768 Handle nil restricted visibility settings
Return `true` from `non_restricted_level?` when the
`restricted_visibility_levels` setting is nil.
2015-03-18 12:50:27 -06:00
Vinnie Okada cacac147de Move restricted visibility settings to the UI
Add checkboxes to the application settings page for restricted
visibility levels, and remove those settings from gitlab.yml.
2015-03-07 13:11:08 -07:00
Job van der Voort 68fd66c6e3 block visibility level restriction override in controller 2014-08-28 20:33:41 +02:00
Jeroen van Baarsen 3c439888a6 Removed some constant allready defined warnings
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2014-07-16 20:12:46 +02:00
Jason Hollingsworth d9bb4230cc Adding authenticated public mode (internal).
Added visibility_level icons to project view (rather than just text).
Added public projects to search results.
Added ability to restrict visibility levels standard users can set.
2013-11-26 22:22:07 -06:00