mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-23 14:46:21 +00:00
Show forge icons in UI (#987)
This commit is contained in:
parent
99f1b70570
commit
42c745362b
13 changed files with 84 additions and 4 deletions
|
@ -60,6 +60,11 @@ func New(opts *Opts) (remote.Remote, error) {
|
||||||
// TODO: add checks
|
// TODO: add checks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *config) Name() string {
|
||||||
|
return "bitbucket"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates an account with Bitbucket using the oauth2 protocol. The
|
// Login authenticates an account with Bitbucket using the oauth2 protocol. The
|
||||||
// Bitbucket account details are returned when the user is successfully authenticated.
|
// Bitbucket account details are returned when the user is successfully authenticated.
|
||||||
func (c *config) Login(ctx context.Context, w http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *config) Login(ctx context.Context, w http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
|
|
|
@ -104,6 +104,11 @@ func New(opts Opts) (remote.Remote, error) {
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *Config) Name() string {
|
||||||
|
return "stash"
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Config) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *Config) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
requestToken, u, err := c.Consumer.GetRequestTokenAndUrl("oob")
|
requestToken, u, err := c.Consumer.GetRequestTokenAndUrl("oob")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -74,6 +74,11 @@ type Coding struct {
|
||||||
SkipVerify bool
|
SkipVerify bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *Coding) Name() string {
|
||||||
|
return "coding"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates the session and returns the
|
// Login authenticates the session and returns the
|
||||||
// remote user details.
|
// remote user details.
|
||||||
func (c *Coding) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *Coding) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
|
|
|
@ -79,6 +79,11 @@ func New(opts Opts) (remote.Remote, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *Gitea) Name() string {
|
||||||
|
return "gitea"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates an account with Gitea using basic authentication. The
|
// Login authenticates an account with Gitea using basic authentication. The
|
||||||
// Gitea account details are returned when the user is successfully authenticated.
|
// Gitea account details are returned when the user is successfully authenticated.
|
||||||
func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
|
|
|
@ -78,6 +78,11 @@ type client struct {
|
||||||
MergeRef bool
|
MergeRef bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *client) Name() string {
|
||||||
|
return "github"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates the session and returns the remote user details.
|
// Login authenticates the session and returns the remote user details.
|
||||||
func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
config := c.newConfig(req)
|
config := c.newConfig(req)
|
||||||
|
|
|
@ -69,6 +69,11 @@ func New(opts Opts) (remote.Remote, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (g *Gitlab) Name() string {
|
||||||
|
return "gitlab"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates the session and returns the
|
// Login authenticates the session and returns the
|
||||||
// remote user details.
|
// remote user details.
|
||||||
func (g *Gitlab) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (g *Gitlab) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
|
|
|
@ -67,6 +67,11 @@ func New(opts Opts) (remote.Remote, error) {
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
func (c *client) Name() string {
|
||||||
|
return "gogs"
|
||||||
|
}
|
||||||
|
|
||||||
// Login authenticates an account with Gogs using basic authentication. The
|
// Login authenticates an account with Gogs using basic authentication. The
|
||||||
// Gogs account details are returned when the user is successfully authenticated.
|
// Gogs account details are returned when the user is successfully authenticated.
|
||||||
func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by mockery v1.0.0. DO NOT EDIT.
|
// Code generated by mockery v2.13.1. DO NOT EDIT.
|
||||||
|
|
||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
|
@ -191,6 +191,20 @@ func (_m *Remote) Login(ctx context.Context, w http.ResponseWriter, r *http.Requ
|
||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name provides a mock function with given fields:
|
||||||
|
func (_m *Remote) Name() string {
|
||||||
|
ret := _m.Called()
|
||||||
|
|
||||||
|
var r0 string
|
||||||
|
if rf, ok := ret.Get(0).(func() string); ok {
|
||||||
|
r0 = rf()
|
||||||
|
} else {
|
||||||
|
r0 = ret.Get(0).(string)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0
|
||||||
|
}
|
||||||
|
|
||||||
// Netrc provides a mock function with given fields: u, r
|
// Netrc provides a mock function with given fields: u, r
|
||||||
func (_m *Remote) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
func (_m *Remote) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
||||||
ret := _m.Called(u, r)
|
ret := _m.Called(u, r)
|
||||||
|
@ -319,3 +333,18 @@ func (_m *Remote) Teams(ctx context.Context, u *model.User) ([]*model.Team, erro
|
||||||
|
|
||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type mockConstructorTestingTNewRemote interface {
|
||||||
|
mock.TestingT
|
||||||
|
Cleanup(func())
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRemote creates a new instance of Remote. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||||
|
func NewRemote(t mockConstructorTestingTNewRemote) *Remote {
|
||||||
|
mock := &Remote{}
|
||||||
|
mock.Mock.Test(t)
|
||||||
|
|
||||||
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||||
|
|
||||||
|
return mock
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ import (
|
||||||
// TODO: add Driver() who return source forge back
|
// TODO: add Driver() who return source forge back
|
||||||
|
|
||||||
type Remote interface {
|
type Remote interface {
|
||||||
|
// Name returns the string name of this driver
|
||||||
|
Name() string
|
||||||
|
|
||||||
// Login authenticates the session and returns the
|
// Login authenticates the session and returns the
|
||||||
// remote user details.
|
// remote user details.
|
||||||
Login(ctx context.Context, w http.ResponseWriter, r *http.Request) (*model.User, error)
|
Login(ctx context.Context, w http.ResponseWriter, r *http.Request) (*model.User, error)
|
||||||
|
|
|
@ -51,6 +51,7 @@ func Config(c *gin.Context) {
|
||||||
"syncing": syncing,
|
"syncing": syncing,
|
||||||
"docs": server.Config.Server.Docs,
|
"docs": server.Config.Server.Docs,
|
||||||
"version": version.String(),
|
"version": version.String(),
|
||||||
|
"forge": server.Config.Services.Remote.Name(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// default func map with json parser.
|
// default func map with json parser.
|
||||||
|
@ -76,4 +77,5 @@ window.WOODPECKER_SYNC = {{ .syncing }};
|
||||||
window.WOODPECKER_CSRF = "{{ .csrf }}";
|
window.WOODPECKER_CSRF = "{{ .csrf }}";
|
||||||
window.WOODPECKER_VERSION = "{{ .version }}";
|
window.WOODPECKER_VERSION = "{{ .version }}";
|
||||||
window.WOODPECKER_DOCS = "{{ .docs }}";
|
window.WOODPECKER_DOCS = "{{ .docs }}";
|
||||||
|
window.WOODPECKER_FORGE = "{{ .forge }}";
|
||||||
`
|
`
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
<i-ph-prohibit v-else-if="name === 'status-skipped'" class="h-8 w-8" />
|
<i-ph-prohibit v-else-if="name === 'status-skipped'" class="h-8 w-8" />
|
||||||
<i-entypo-dots-two-vertical v-else-if="name === 'status-started'" class="h-8 w-8" />
|
<i-entypo-dots-two-vertical v-else-if="name === 'status-started'" class="h-8 w-8" />
|
||||||
<i-ph-check-circle v-else-if="name === 'status-success'" class="h-8 w-8" />
|
<i-ph-check-circle v-else-if="name === 'status-success'" class="h-8 w-8" />
|
||||||
<i-cib-gitea v-else-if="name === 'gitea'" class="h-8 w-8" />
|
<i-simple-icons-gitea v-else-if="name === 'gitea'" class="h-8 w-8" />
|
||||||
|
<i-ph-gitlab-logo-simple-fill v-else-if="name === 'gitlab'" class="h-8 w-8" />
|
||||||
|
<i-mdi-bitbucket v-else-if="name === 'bitbucket'" class="h-8 w-8" />
|
||||||
<i-vaadin-question-circle-o v-else-if="name === 'question'" class="h-6 w-6" />
|
<i-vaadin-question-circle-o v-else-if="name === 'question'" class="h-6 w-6" />
|
||||||
<i-ic-twotone-add v-else-if="name === 'plus'" class="h-6 w-6" />
|
<i-ic-twotone-add v-else-if="name === 'plus'" class="h-6 w-6" />
|
||||||
<i-mdi-format-list-bulleted v-else-if="name === 'list'" class="h-6 w-6" />
|
<i-mdi-format-list-bulleted v-else-if="name === 'list'" class="h-6 w-6" />
|
||||||
|
@ -64,6 +66,8 @@ export type IconNames =
|
||||||
| 'status-started'
|
| 'status-started'
|
||||||
| 'status-success'
|
| 'status-success'
|
||||||
| 'gitea'
|
| 'gitea'
|
||||||
|
| 'gitlab'
|
||||||
|
| 'bitbucket'
|
||||||
| 'question'
|
| 'question'
|
||||||
| 'list'
|
| 'list'
|
||||||
| 'loading'
|
| 'loading'
|
||||||
|
|
|
@ -7,6 +7,7 @@ declare global {
|
||||||
WOODPECKER_DOCS: string | undefined;
|
WOODPECKER_DOCS: string | undefined;
|
||||||
WOODPECKER_VERSION: string | undefined;
|
WOODPECKER_VERSION: string | undefined;
|
||||||
WOODPECKER_CSRF: string | undefined;
|
WOODPECKER_CSRF: string | undefined;
|
||||||
|
WOODPECKER_FORGE: string | undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,4 +17,5 @@ export default () => ({
|
||||||
docs: window.WOODPECKER_DOCS || null,
|
docs: window.WOODPECKER_DOCS || null,
|
||||||
version: window.WOODPECKER_VERSION,
|
version: window.WOODPECKER_VERSION,
|
||||||
csrf: window.WOODPECKER_CSRF || null,
|
csrf: window.WOODPECKER_CSRF || null,
|
||||||
|
forge: window.WOODPECKER_FORGE || null,
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="flex ml-4 p-1 rounded-full text-color hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-600"
|
class="flex ml-4 p-1 rounded-full text-color hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-600"
|
||||||
>
|
>
|
||||||
<Icon v-if="repo.link_url.startsWith('https://github.com/')" name="github" />
|
<Icon v-if="forge === 'github'" name="github" />
|
||||||
|
<Icon v-else-if="forge === 'gitea'" name="gitea" />
|
||||||
|
<Icon v-else-if="forge === 'gitlab'" name="gitlab" />
|
||||||
|
<Icon v-else-if="forge === 'bitbucket' || forge === 'stash'" name="bitbucket" />
|
||||||
<Icon v-else name="repo" />
|
<Icon v-else name="repo" />
|
||||||
</a>
|
</a>
|
||||||
<IconButton v-if="repoPermissions.admin" class="ml-2" :to="{ name: 'repo-settings' }" icon="settings" />
|
<IconButton v-if="repoPermissions.admin" class="ml-2" :to="{ name: 'repo-settings' }" icon="settings" />
|
||||||
|
@ -41,6 +44,7 @@ import Tab from '~/components/tabs/Tab.vue';
|
||||||
import Tabs from '~/components/tabs/Tabs.vue';
|
import Tabs from '~/components/tabs/Tabs.vue';
|
||||||
import useApiClient from '~/compositions/useApiClient';
|
import useApiClient from '~/compositions/useApiClient';
|
||||||
import useAuthentication from '~/compositions/useAuthentication';
|
import useAuthentication from '~/compositions/useAuthentication';
|
||||||
|
import useConfig from '~/compositions/useConfig';
|
||||||
import useNotifications from '~/compositions/useNotifications';
|
import useNotifications from '~/compositions/useNotifications';
|
||||||
import { RepoPermissions } from '~/lib/api/types';
|
import { RepoPermissions } from '~/lib/api/types';
|
||||||
import BuildStore from '~/store/builds';
|
import BuildStore from '~/store/builds';
|
||||||
|
@ -79,6 +83,7 @@ export default defineComponent({
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
|
||||||
|
const { forge } = useConfig();
|
||||||
const repo = repoStore.getRepo(repoOwner, repoName);
|
const repo = repoStore.getRepo(repoOwner, repoName);
|
||||||
const repoPermissions = ref<RepoPermissions>();
|
const repoPermissions = ref<RepoPermissions>();
|
||||||
const builds = buildStore.getSortedBuilds(repoOwner, repoName);
|
const builds = buildStore.getSortedBuilds(repoOwner, repoName);
|
||||||
|
@ -129,7 +134,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { repo, repoPermissions, badgeUrl, activeTab };
|
return { repo, repoPermissions, badgeUrl, activeTab, forge };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue