2026-01-03 02:44:25 +00:00
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
customElement,
|
|
|
|
|
html,
|
|
|
|
|
css,
|
|
|
|
|
cssManager,
|
|
|
|
|
property,
|
|
|
|
|
type TemplateResult,
|
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
|
'sz-tokens-view': SzTokensView;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface IToken {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
type: 'global' | 'ci';
|
|
|
|
|
service?: string;
|
|
|
|
|
createdAt: string;
|
|
|
|
|
lastUsed?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@customElement('sz-tokens-view')
|
|
|
|
|
export class SzTokensView extends DeesElement {
|
|
|
|
|
public static demo = () => html`
|
|
|
|
|
<div style="padding: 24px; max-width: 1000px;">
|
|
|
|
|
<sz-tokens-view
|
|
|
|
|
.globalTokens=${[
|
|
|
|
|
{ id: '1', name: 'CI/CD Pipeline', type: 'global', createdAt: '2024-01-15', lastUsed: '2024-01-20' },
|
|
|
|
|
{ id: '2', name: 'Development', type: 'global', createdAt: '2024-01-10' },
|
|
|
|
|
]}
|
|
|
|
|
.ciTokens=${[
|
|
|
|
|
{ id: '3', name: 'hello-world-ci', type: 'ci', service: 'hello-world', createdAt: '2024-01-18' },
|
|
|
|
|
{ id: '4', name: 'api-service-ci', type: 'ci', service: 'api-service', createdAt: '2024-01-12', lastUsed: '2024-01-19' },
|
|
|
|
|
]}
|
|
|
|
|
></sz-tokens-view>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
|
2026-02-20 13:29:07 +00:00
|
|
|
public static demoGroups = ['Auth & Settings'];
|
|
|
|
|
|
2026-01-03 02:44:25 +00:00
|
|
|
@property({ type: Array })
|
|
|
|
|
public accessor globalTokens: IToken[] = [];
|
|
|
|
|
|
|
|
|
|
@property({ type: Array })
|
|
|
|
|
public accessor ciTokens: IToken[] = [];
|
|
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
css`
|
|
|
|
|
:host {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-07 22:27:23 +00:00
|
|
|
dees-tile {
|
|
|
|
|
display: block;
|
2026-01-03 02:44:25 +00:00
|
|
|
margin-bottom: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-header {
|
2026-04-07 22:27:23 +00:00
|
|
|
height: 36px;
|
2026-01-03 02:44:25 +00:00
|
|
|
display: flex;
|
2026-04-07 22:27:23 +00:00
|
|
|
align-items: center;
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-07 22:27:23 +00:00
|
|
|
.section-heading {
|
|
|
|
|
flex: 1;
|
2026-01-03 02:44:25 +00:00
|
|
|
display: flex;
|
2026-04-07 22:27:23 +00:00
|
|
|
align-items: baseline;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
min-width: 0;
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-title {
|
2026-04-07 22:27:23 +00:00
|
|
|
font-weight: 500;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
letter-spacing: -0.01em;
|
|
|
|
|
color: var(--dees-color-text-secondary);
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-subtitle {
|
2026-04-07 22:27:23 +00:00
|
|
|
font-size: 12px;
|
|
|
|
|
color: var(--dees-color-text-muted);
|
|
|
|
|
letter-spacing: -0.01em;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-07 22:27:23 +00:00
|
|
|
.section-footer {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
justify-content: flex-end;
|
2026-01-03 02:44:25 +00:00
|
|
|
align-items: center;
|
2026-04-07 22:27:23 +00:00
|
|
|
gap: 0;
|
|
|
|
|
height: 36px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tile-button {
|
|
|
|
|
padding: 0 16px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
text-align: center;
|
|
|
|
|
font-size: 12px;
|
2026-01-03 02:44:25 +00:00
|
|
|
font-weight: 500;
|
|
|
|
|
cursor: pointer;
|
2026-04-07 22:27:23 +00:00
|
|
|
user-select: none;
|
|
|
|
|
transition: all 0.15s ease;
|
|
|
|
|
background: transparent;
|
|
|
|
|
border: none;
|
|
|
|
|
border-left: 1px solid var(--dees-color-border-subtle);
|
|
|
|
|
color: var(--dees-color-text-muted);
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tile-button:first-child {
|
|
|
|
|
border-left: none;
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
2026-04-07 22:27:23 +00:00
|
|
|
.tile-button:hover {
|
|
|
|
|
background: var(--dees-color-hover);
|
|
|
|
|
color: var(--dees-color-text-primary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tile-button.primary {
|
|
|
|
|
color: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8%)', 'hsl(213.1 93.9% 67.8%)')};
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tile-button.primary:hover {
|
|
|
|
|
background: ${cssManager.bdTheme('hsl(217.2 91.2% 59.8% / 0.08)', 'hsl(213.1 93.9% 67.8% / 0.08)')};
|
|
|
|
|
color: ${cssManager.bdTheme('hsl(217.2 91.2% 50%)', 'hsl(213.1 93.9% 75%)')};
|
2026-01-03 02:44:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-list {
|
|
|
|
|
padding: 16px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-item {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
background: ${cssManager.bdTheme('#f4f4f5', '#18181b')};
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
margin-bottom: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-item:last-child {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-name {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
color: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-meta {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-service {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
background: ${cssManager.bdTheme('#dbeafe', 'rgba(59, 130, 246, 0.2)')};
|
|
|
|
|
color: ${cssManager.bdTheme('#2563eb', '#60a5fa')};
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
margin-right: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.token-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button {
|
|
|
|
|
padding: 6px 12px;
|
|
|
|
|
background: transparent;
|
|
|
|
|
border: 1px solid ${cssManager.bdTheme('#e4e4e7', '#27272a')};
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: all 200ms ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button:hover {
|
|
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#09090b')};
|
|
|
|
|
color: ${cssManager.bdTheme('#18181b', '#fafafa')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button.delete {
|
|
|
|
|
color: ${cssManager.bdTheme('#dc2626', '#ef4444')};
|
|
|
|
|
border-color: ${cssManager.bdTheme('#fee2e2', 'rgba(239, 68, 68, 0.3)')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-button.delete:hover {
|
|
|
|
|
background: ${cssManager.bdTheme('#fee2e2', 'rgba(239, 68, 68, 0.2)')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.empty-state {
|
|
|
|
|
padding: 32px 16px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.empty-text {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: ${cssManager.bdTheme('#71717a', '#a1a1aa')};
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
2026-04-07 22:27:23 +00:00
|
|
|
<dees-tile>
|
|
|
|
|
<div slot="header" class="section-header">
|
|
|
|
|
<div class="section-heading">
|
|
|
|
|
<span class="section-title">Global Tokens</span>
|
|
|
|
|
<span class="section-subtitle">Tokens that can push images to multiple services</span>
|
2026-01-03 02:44:25 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
${this.globalTokens.length > 0 ? html`
|
|
|
|
|
<div class="token-list">
|
|
|
|
|
${this.globalTokens.map(token => this.renderToken(token))}
|
|
|
|
|
</div>
|
|
|
|
|
` : html`
|
|
|
|
|
<div class="empty-state">
|
|
|
|
|
<div class="empty-text">No global tokens created</div>
|
|
|
|
|
</div>
|
|
|
|
|
`}
|
2026-04-07 22:27:23 +00:00
|
|
|
<div slot="footer" class="section-footer">
|
|
|
|
|
<button class="tile-button primary" @click=${() => this.handleCreate('global')}>
|
|
|
|
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
2026-01-03 02:44:25 +00:00
|
|
|
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
|
|
|
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
|
|
|
</svg>
|
|
|
|
|
Create Token
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2026-04-07 22:27:23 +00:00
|
|
|
</dees-tile>
|
|
|
|
|
|
|
|
|
|
<dees-tile>
|
|
|
|
|
<div slot="header" class="section-header">
|
|
|
|
|
<div class="section-heading">
|
|
|
|
|
<span class="section-title">CI Tokens (Service-specific)</span>
|
|
|
|
|
<span class="section-subtitle">Tokens tied to individual services for CI/CD pipelines</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-03 02:44:25 +00:00
|
|
|
${this.ciTokens.length > 0 ? html`
|
|
|
|
|
<div class="token-list">
|
|
|
|
|
${this.ciTokens.map(token => this.renderToken(token))}
|
|
|
|
|
</div>
|
|
|
|
|
` : html`
|
|
|
|
|
<div class="empty-state">
|
|
|
|
|
<div class="empty-text">No CI tokens created</div>
|
|
|
|
|
</div>
|
|
|
|
|
`}
|
2026-04-07 22:27:23 +00:00
|
|
|
<div slot="footer" class="section-footer">
|
|
|
|
|
<button class="tile-button primary" @click=${() => this.handleCreate('ci')}>
|
|
|
|
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
|
|
|
<line x1="12" y1="5" x2="12" y2="19"></line>
|
|
|
|
|
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
|
|
|
</svg>
|
|
|
|
|
Create Token
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</dees-tile>
|
2026-01-03 02:44:25 +00:00
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderToken(token: IToken): TemplateResult {
|
|
|
|
|
return html`
|
|
|
|
|
<div class="token-item">
|
|
|
|
|
<div class="token-info">
|
|
|
|
|
<div class="token-name">${token.name}</div>
|
|
|
|
|
<div class="token-meta">
|
|
|
|
|
${token.service ? html`<span class="token-service">${token.service}</span>` : ''}
|
|
|
|
|
Created ${token.createdAt}
|
|
|
|
|
${token.lastUsed ? html` · Last used ${token.lastUsed}` : ''}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="token-actions">
|
|
|
|
|
<button class="action-button" @click=${() => this.handleCopy(token)}>Copy</button>
|
|
|
|
|
<button class="action-button" @click=${() => this.handleRegenerate(token)}>Regenerate</button>
|
|
|
|
|
<button class="action-button delete" @click=${() => this.handleDelete(token)}>Delete</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleCreate(type: 'global' | 'ci') {
|
|
|
|
|
this.dispatchEvent(new CustomEvent('create', { detail: { type }, bubbles: true, composed: true }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleCopy(token: IToken) {
|
|
|
|
|
this.dispatchEvent(new CustomEvent('copy', { detail: token, bubbles: true, composed: true }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleRegenerate(token: IToken) {
|
|
|
|
|
this.dispatchEvent(new CustomEvent('regenerate', { detail: token, bubbles: true, composed: true }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private handleDelete(token: IToken) {
|
|
|
|
|
this.dispatchEvent(new CustomEvent('delete', { detail: token, bubbles: true, composed: true }));
|
|
|
|
|
}
|
|
|
|
|
}
|