Skip to content

Commit

Permalink
refactor: card schema
Browse files Browse the repository at this point in the history
  • Loading branch information
gor918 committed Feb 8, 2024
1 parent 41d9020 commit 17baf6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 180 deletions.
4 changes: 2 additions & 2 deletions dist/index.js

Large diffs are not rendered by default.

185 changes: 7 additions & 178 deletions src/message-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,121 +16,6 @@ export function createMessageCard(

const author_url = author?.login && author.html_url ? `[(@${author.login})](${author.html_url}) ` : '';

// const messageCard = {
// type: 'message',
// attachments: [
// {
// type: 'AdaptiveCard',
// body: [
// {
// type: 'Container',
// items: [
// {
// type: 'TextBlock',
// size: 'Large',
// weight: 'Bolder',
// text: notificationSummary,
// wrap: true,
// style: 'heading',
// },
// ],
// padding: 'Default',
// spacing: 'None',
// separator: true,
// },
// {
// type: 'Container',
// id: '7d00f965-40bb-9fc3-ff7b-a9b82a09ead4',
// padding: 'Default',
// items: [
// {
// type: 'ColumnSet',
// columns: [
// {
// type: 'Column',
// items: [
// {
// type: 'Image',
// style: 'Person',
// url: avatar_url,
// size: 'Small',
// altText: `${commit.data.commit.author.name}`,
// },
// ],
// width: 'auto',
// padding: 'None',
// },
// {
// type: 'Column',
// items: [
// {
// type: 'TextBlock',
// text: `**CI #${runNum} (commit ${sha.substring(0, 7)})** on [${repoName}](${repoUrl})`,
// wrap: true,
// },
// {
// type: 'TextBlock',
// spacing: 'None',
// color: 'Light',
// text: `by ${commit.data.commit.author.name} ${author_url}on ${timestamp}`,
// wrap: true,
// size: 'Small',
// },
// ],
// width: 'stretch',
// padding: 'None',
// },
// ],
// spacing: 'None',
// padding: 'None',
// },
// ],
// spacing: 'None',
// separator: true,
// },
// {
// type: 'Container',
// id: '353b659f-b668-fac0-5b7f-5d2f1bdb46ac',
// padding: 'Default',
// items: [
// {
// type: 'ActionSet',
// actions: [
// {
// type: 'Action.Http',
// id: 'viewWorkflowRun',
// title: 'View Workflow Run',
// method: 'POST',
// url: `${repoUrl}/actions/runs/${runId}`,
// body: '{}',
// isPrimary: true,
// style: 'positive',
// },
// {
// type: 'Action.Http',
// id: 'viewCommitChanges',
// title: 'View Commit Changes',
// method: 'POST',
// url: commit.data.html_url,
// body: '{}',
// isPrimary: false,
// style: 'positive',
// },
// ],
// spacing: 'None',
// },
// ],
// spacing: 'None',
// separator: true,
// },
// ],
// $schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
// version: '1.0',
// padding: 'None',
// },
// ],
// };

const messageCard = {
type: 'message',
attachments: [
Expand Down Expand Up @@ -177,7 +62,7 @@ export function createMessageCard(
altText: `${commit.data.commit.author.name}`,
},
],
width: 'auto',
width: 'stretch',
padding: 'None',
},
{
Expand Down Expand Up @@ -208,74 +93,18 @@ export function createMessageCard(
spacing: 'None',
separator: true,
},
{
type: 'Container',
id: '353b659f-b668-fac0-5b7f-5d2f1bdb46ac',
padding: 'Default',
items: [
{
type: 'ActionSet',
actions: [
{
type: 'Action.Http',
id: 'viewWorkflowRun',
title: 'View Workflow Run',
method: 'POST',
url: `${repoUrl}/actions/runs/${runId}`,
body: '{}',
isPrimary: true,
style: 'positive',
},
{
type: 'Action.Http',
id: 'viewCommitChanges',
title: 'View Commit Changes',
method: 'POST',
url: commit.data.html_url,
body: '{}',
isPrimary: false,
style: 'positive',
},
],
spacing: 'None',
},
],
spacing: 'None',
separator: true,
},
],
actions: [
{
type: 'Action.ShowCard',
title: 'Set due date',
card: {
type: 'AdaptiveCard',
body: [
{
type: 'Input.Date',
label: 'Enter the due date',
id: 'dueDate',
},
{
type: 'Input.Text',
id: 'comment',
isMultiline: true,
label: 'Add a comment',
},
],
actions: [
{
type: 'Action.Submit',
title: 'OK',
},
],
$schema: 'http://adaptivecards.io/schemas/adaptive-card.json',
},
type: 'Action.OpenUrl',
title: 'View Workflow Run',
url: `${repoUrl}/actions/runs/${runId}`,
role: 'button',
},
{
type: 'Action.OpenUrl',
title: 'View',
url: '${viewUrl}',
title: 'View Commit Changes',
url: commit.data.html_url,
role: 'button',
},
],
Expand Down

0 comments on commit 17baf6a

Please sign in to comment.